Skip to content

Commit

Permalink
update config files, separate lepton info computation
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieu committed Dec 15, 2014
1 parent 0e01768 commit 177aa53
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 387 deletions.
92 changes: 53 additions & 39 deletions RecoMET/METPUSubtraction/plugins/PFMETProducerMVA.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,45 +91,9 @@ void PFMETProducerMVA::produce(edm::Event& evt, const edm::EventSetup& es)
// (excluded from sum over PFCandidates when computing hadronic recoil)
int lId = 0;
bool lHasPhotons = false;
std::vector<reco::PUSubMETCandInfo> leptonInfo;
for ( std::vector<edm::EDGetTokenT<reco::CandidateView > >::const_iterator srcLeptons_i = srcLeptons_.begin();
srcLeptons_i != srcLeptons_.end(); ++srcLeptons_i ) {
edm::Handle<reco::CandidateView> leptons;
evt.getByToken(*srcLeptons_i, leptons);
for ( reco::CandidateView::const_iterator lepton1 = leptons->begin();
lepton1 != leptons->end(); ++lepton1 ) {
bool pMatch = false;
for ( std::vector<edm::EDGetTokenT<reco::CandidateView> >::const_iterator srcLeptons_j = srcLeptons_.begin();
srcLeptons_j != srcLeptons_.end(); ++srcLeptons_j ) {
edm::Handle<reco::CandidateView> leptons2;
evt.getByToken(*srcLeptons_j, leptons2);
for ( reco::CandidateView::const_iterator lepton2 = leptons2->begin();
lepton2 != leptons2->end(); ++lepton2 ) {
if(&(*lepton1) == &(*lepton2)) { continue; }
if(deltaR2(lepton1->p4(),lepton2->p4()) < dR2Max) { pMatch = true; }
if(pMatch && !istau(&(*lepton1)) && istau(&(*lepton2))) { pMatch = false; }
if(pMatch && ( (istau(&(*lepton1)) && istau(&(*lepton2))) || (!istau(&(*lepton1)) && !istau(&(*lepton2))))
&& lepton1->pt() > lepton2->pt()) { pMatch = false; }
if(pMatch && lepton1->pt() == lepton2->pt()) {
pMatch = false;
for(unsigned int i0 = 0; i0 < leptonInfo.size(); i0++) {
if(std::abs(lepton1->pt() - leptonInfo[i0].p4_.pt()) < dPtMatch) { pMatch = true; break; }
}
}
if(pMatch) break;
}
if(pMatch) break;
}
if(pMatch) continue;
reco::PUSubMETCandInfo pLeptonInfo;
pLeptonInfo.p4_ = lepton1->p4();
pLeptonInfo.chargedEnFrac_ = chargedEnFrac(&(*lepton1),*pfCandidates_view,hardScatterVertex);
leptonInfo.push_back(pLeptonInfo);
if(lepton1->isPhoton()) { lHasPhotons = true; }
}
lId++;
}

std::vector<reco::PUSubMETCandInfo> leptonInfo = computeLeptonInfo(srcLeptons_,*pfCandidates_view,hardScatterVertex, lId, lHasPhotons,
evt);

// initialize MVA MET algorithm
// (this will load the BDTs, stored as GBRForrest objects;
// either in input ROOT files or in SQL-lite files/the Conditions Database)
Expand Down Expand Up @@ -172,6 +136,56 @@ void PFMETProducerMVA::produce(edm::Event& evt, const edm::EventSetup& es)
evt.put(pfMEtCollection);
}

std::vector<reco::PUSubMETCandInfo>
PFMETProducerMVA::computeLeptonInfo(const std::vector<edm::EDGetTokenT<reco::CandidateView > >& srcLeptons_,
const reco::CandidateView& pfCandidates_view,
const reco::Vertex* hardScatterVertex,
int& lId, bool& lHasPhotons, edm::Event& evt ) {

std::vector<reco::PUSubMETCandInfo> leptonInfo;

for ( std::vector<edm::EDGetTokenT<reco::CandidateView > >::const_iterator srcLeptons_i = srcLeptons_.begin();
srcLeptons_i != srcLeptons_.end(); ++srcLeptons_i ) {
edm::Handle<reco::CandidateView> leptons;
evt.getByToken(*srcLeptons_i, leptons);
for ( reco::CandidateView::const_iterator lepton1 = leptons->begin();
lepton1 != leptons->end(); ++lepton1 ) {
bool pMatch = false;
for ( std::vector<edm::EDGetTokenT<reco::CandidateView> >::const_iterator srcLeptons_j = srcLeptons_.begin();
srcLeptons_j != srcLeptons_.end(); ++srcLeptons_j ) {
edm::Handle<reco::CandidateView> leptons2;
evt.getByToken(*srcLeptons_j, leptons2);
for ( reco::CandidateView::const_iterator lepton2 = leptons2->begin();
lepton2 != leptons2->end(); ++lepton2 ) {
if(&(*lepton1) == &(*lepton2)) { continue; }
if(deltaR2(lepton1->p4(),lepton2->p4()) < dR2Max) { pMatch = true; }
if(pMatch && !istau(&(*lepton1)) && istau(&(*lepton2))) { pMatch = false; }
if(pMatch && ( (istau(&(*lepton1)) && istau(&(*lepton2))) || (!istau(&(*lepton1)) && !istau(&(*lepton2))))
&& lepton1->pt() > lepton2->pt()) { pMatch = false; }
if(pMatch && lepton1->pt() == lepton2->pt()) {
pMatch = false;
for(unsigned int i0 = 0; i0 < leptonInfo.size(); i0++) {
if(std::abs(lepton1->pt() - leptonInfo[i0].p4_.pt()) < dPtMatch) { pMatch = true; break; }
}
}
if(pMatch) break;
}
if(pMatch) break;
}
if(pMatch) continue;
reco::PUSubMETCandInfo pLeptonInfo;
pLeptonInfo.p4_ = lepton1->p4();
pLeptonInfo.chargedEnFrac_ = chargedEnFrac(&(*lepton1),pfCandidates_view,hardScatterVertex);
leptonInfo.push_back(pLeptonInfo);
if(lepton1->isPhoton()) { lHasPhotons = true; }
}
lId++;
}

return leptonInfo;
}


std::vector<reco::PUSubMETCandInfo>
PFMETProducerMVA::computeJetInfo(const reco::PFJetCollection& uncorrJets,
const edm::Handle<reco::PFJetCollection>& corrJets,
Expand Down
5 changes: 5 additions & 0 deletions RecoMET/METPUSubtraction/plugins/PFMETProducerMVA.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ namespace reco
void produce(edm::Event&, const edm::EventSetup&);

// auxiliary functions
std::vector<reco::PUSubMETCandInfo> computeLeptonInfo(const std::vector<edm::EDGetTokenT<reco::CandidateView > >& srcLeptons_,
const reco::CandidateView& pfCandidates,
const reco::Vertex* hardScatterVertex,
int& lId, bool& lHasPhotons, edm::Event & iEvent);

std::vector<reco::PUSubMETCandInfo> computeJetInfo(const reco::PFJetCollection&, const edm::Handle<reco::PFJetCollection>&,
const edm::ValueMap<float>&, const reco::VertexCollection&,
const reco::Vertex*, const JetCorrector &iCorr,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
'selectedPhotons',
'selectedJets'),
minNumLeptons = cms.int32(0),
srcRho = cms.InputTag('kt6PFJets','rho'),
srcRho = cms.InputTag('fixedGridRhoFastjetAll'),
globalThreshold = cms.double(-1.),
minCorrJetPt = cms.double(-1.),
inputFileNames = cms.PSet(
Expand Down
68 changes: 0 additions & 68 deletions RecoMET/METPUSubtraction/python/mvaPFMET_Data_cff.py

This file was deleted.

10 changes: 5 additions & 5 deletions RecoMET/METPUSubtraction/python/mvaPFMET_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@
globalThreshold = cms.double(-1.),#pfMet.globalThreshold,
minCorrJetPt = cms.double(-1.),
inputFileNames = cms.PSet(
U = cms.FileInPath('RecoMET/METPUSubtraction/data/gbrmet_53_June2013_type1.root'),
DPhi = cms.FileInPath('RecoMET/METPUSubtraction/data/gbrmetphi_53_June2013_type1.root'),
CovU1 = cms.FileInPath('RecoMET/METPUSubtraction/data/gbru1cov_53_Dec2012.root'),
CovU2 = cms.FileInPath('RecoMET/METPUSubtraction/data/gbru2cov_53_Dec2012.root')
),
U = cms.FileInPath('RecoMET/METPUSubtraction/data/gbrmet_53_Sep2013_type1.root'),
DPhi = cms.FileInPath('RecoMET/METPUSubtraction/data/gbrmetphi_53_June2013_type1.root'),
CovU1 = cms.FileInPath('RecoMET/METPUSubtraction/data/gbru1cov_53_Dec2012.root'),
CovU2 = cms.FileInPath('RecoMET/METPUSubtraction/data/gbru2cov_53_Dec2012.root')
),
loadMVAfromDB = cms.bool(False),

corrector = cms.string("ak4PFL1Fastjet"),
Expand Down
71 changes: 0 additions & 71 deletions RecoMET/METPUSubtraction/python/mvaPFMET_leptons_cff.py

This file was deleted.

Loading

0 comments on commit 177aa53

Please sign in to comment.