Checks what a re-reco changes in PFCandidates. More...
#include <PFCandidateChecker.h>
Public Member Functions | |
virtual void | analyze (const edm::Event &, const edm::EventSetup &) |
virtual void | beginRun (const edm::Run &r, const edm::EventSetup &c) |
PFCandidateChecker (const edm::ParameterSet &) | |
~PFCandidateChecker () | |
Private Member Functions | |
void | printElementsInBlocks (const reco::PFCandidate &cand, std::ostream &out=std::cout) const |
void | printJets (const reco::PFJetCollection &pfJetsReco, const reco::PFJetCollection &pfJetsReReco) const |
void | printMet (const reco::PFCandidateCollection &pfReco, const reco::PFCandidateCollection &pfReReco) const |
Static Private Member Functions | |
static bool | greaterPt (const reco::PFCandidate &a, const reco::PFCandidate &b) |
Private Attributes | |
double | deltaEMax_ |
Cuts for comparison. | |
double | deltaEtaMax_ |
double | deltaPhiMax_ |
unsigned | entry_ |
Counter. | |
edm::InputTag | inputTagPFCandidatesReco_ |
PFCandidates in which we'll look for pile up particles. | |
edm::InputTag | inputTagPFCandidatesReReco_ |
edm::InputTag | inputTagPFJetsReco_ |
edm::InputTag | inputTagPFJetsReReco_ |
bool | printBlocks_ |
print the blocks associated to a given candidate ? | |
bool | rankByPt_ |
rank the candidates by Pt | |
bool | verbose_ |
verbose ? |
Checks what a re-reco changes in PFCandidates.
Definition at line 31 of file PFCandidateChecker.h.
PFCandidateChecker::PFCandidateChecker | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 17 of file PFCandidateChecker.cc.
References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), and LogDebug.
{ inputTagPFCandidatesReco_ = iConfig.getParameter<InputTag>("pfCandidatesReco"); inputTagPFCandidatesReReco_ = iConfig.getParameter<InputTag>("pfCandidatesReReco"); inputTagPFJetsReco_ = iConfig.getParameter<InputTag>("pfJetsReco"); inputTagPFJetsReReco_ = iConfig.getParameter<InputTag>("pfJetsReReco"); deltaEMax_ = iConfig.getParameter<double>("deltaEMax"); deltaEtaMax_ = iConfig.getParameter<double>("deltaEtaMax"); deltaPhiMax_ = iConfig.getParameter<double>("deltaPhiMax"); verbose_ = iConfig.getUntrackedParameter<bool>("verbose",false); printBlocks_ = iConfig.getUntrackedParameter<bool>("printBlocks",false); rankByPt_ = iConfig.getUntrackedParameter<bool>("rankByPt",false); entry_ = 0; LogDebug("PFCandidateChecker") <<" input collections : "<<inputTagPFCandidatesReco_<<" "<<inputTagPFCandidatesReReco_; }
PFCandidateChecker::~PFCandidateChecker | ( | ) |
Definition at line 61 of file PFCandidateChecker.cc.
{ }
void PFCandidateChecker::analyze | ( | const edm::Event & | iEvent, |
const edm::EventSetup & | iSetup | ||
) | [virtual] |
Implements edm::EDAnalyzer.
Definition at line 71 of file PFCandidateChecker.cc.
References gather_cfg::cout, HLTFastRecoForTau_cff::deltaEta, SiPixelRawToDigiRegional_cfi::deltaPhi, reco::LeafCandidate::energy(), reco::LeafCandidate::eta(), edm::EventID::event(), edm::Event::getByLabel(), i, edm::EventBase::id(), LogDebug, reco::LeafCandidate::phi(), edm::EventID::run(), and python::multivaluedict::sort().
{ LogDebug("PFCandidateChecker")<<"START event: "<<iEvent.id().event() <<" in run "<<iEvent.id().run()<<endl; // get PFCandidates Handle<PFCandidateCollection> pfCandidatesReco; iEvent.getByLabel(inputTagPFCandidatesReco_, pfCandidatesReco); Handle<PFCandidateCollection> pfCandidatesReReco; iEvent.getByLabel(inputTagPFCandidatesReReco_, pfCandidatesReReco); Handle<PFJetCollection> pfJetsReco; iEvent.getByLabel(inputTagPFJetsReco_, pfJetsReco); Handle<PFJetCollection> pfJetsReReco; iEvent.getByLabel(inputTagPFJetsReReco_, pfJetsReReco); reco::PFCandidateCollection pfReco, pfReReco; // to sort, one needs to copy if(rankByPt_) { pfReco=*pfCandidatesReco; pfReReco=*pfCandidatesReReco; sort(pfReco.begin(),pfReco.end(),greaterPt); sort(pfReReco.begin(),pfReReco.end(),greaterPt); } unsigned minSize = pfReco.size() < pfReReco.size() ? pfReco.size() : pfReReco.size(); bool differentCand = false; bool differentSize = pfReco.size() != pfReReco.size(); if ( differentSize ) std::cout << "+++WARNING+++ PFCandidate size changed for entry " << entry_ << " !" << endl << " - RECO size : " << pfReco.size() << endl << " - Re-RECO size : " << pfReReco.size() << endl; unsigned npr = 0; for( unsigned i=0; i<minSize; i++ ) { const reco::PFCandidate & candReco = (rankByPt_) ? pfReco[i] : (*pfCandidatesReco)[i]; const reco::PFCandidate & candReReco = (rankByPt_) ? pfReReco[i] : (*pfCandidatesReReco)[i]; double deltaE = (candReReco.energy()-candReco.energy())/(candReReco.energy()+candReco.energy()); double deltaEta = candReReco.eta()-candReco.eta(); double deltaPhi = candReReco.phi()-candReco.phi(); if ( fabs(deltaE) > deltaEMax_ || fabs(deltaEta) > deltaEtaMax_ || fabs(deltaPhi) > deltaPhiMax_ ) { differentCand = true; std::cout << "+++WARNING+++ PFCandidate " << i << " changed for entry " << entry_ << " ! " << std::endl << " - RECO : " << candReco << std::endl << " - Re-RECO : " << candReReco << std::endl << " DeltaE = : " << deltaE << std::endl << " DeltaEta = : " << deltaEta << std::endl << " DeltaPhi = : " << deltaPhi << std::endl << std::endl; if (printBlocks_) { std::cout << "Elements in Block for RECO: " <<std::endl; printElementsInBlocks(candReco); std::cout << "Elements in Block for Re-RECO: " <<std::endl; printElementsInBlocks(candReReco); } if ( ++npr == 5 ) break; } } if ( differentSize || differentCand ) { printJets(*pfJetsReco, *pfJetsReReco); printMet(pfReco, pfReReco); } ++entry_; LogDebug("PFCandidateChecker")<<"STOP event: "<<iEvent.id().event() <<" in run "<<iEvent.id().run()<<std::endl; }
void PFCandidateChecker::beginRun | ( | const edm::Run & | r, |
const edm::EventSetup & | c | ||
) | [virtual] |
static bool PFCandidateChecker::greaterPt | ( | const reco::PFCandidate & | a, |
const reco::PFCandidate & | b | ||
) | [inline, static, private] |
Definition at line 78 of file PFCandidateChecker.h.
References reco::LeafCandidate::pt().
void PFCandidateChecker::printElementsInBlocks | ( | const reco::PFCandidate & | cand, |
std::ostream & | out = std::cout |
||
) | const [private] |
Definition at line 214 of file PFCandidateChecker.cc.
References dtNoiseDBValidation_cfg::cerr, reco::PFCandidate::elementsInBlocks(), i, and edm::Ref< C, T, F >::isNull().
{ if(!out) return; PFBlockRef firstRef; assert(!cand.elementsInBlocks().empty() ); for(unsigned i=0; i<cand.elementsInBlocks().size(); i++) { PFBlockRef blockRef = cand.elementsInBlocks()[i].first; if(blockRef.isNull()) { cerr<<"ERROR! no block ref!"; continue; } if(!i) { out<<(*blockRef); firstRef = blockRef; } else if( blockRef!=firstRef) { cerr<<"WARNING! This PFCandidate is not made from a single block"<<endl; } out<<"\t"<<cand.elementsInBlocks()[i].second<<endl; } }
void PFCandidateChecker::printJets | ( | const reco::PFJetCollection & | pfJetsReco, |
const reco::PFJetCollection & | pfJetsReReco | ||
) | const [private] |
Definition at line 177 of file PFCandidateChecker.cc.
References gather_cfg::cout, HLTFastRecoForTau_cff::deltaEta, SiPixelRawToDigiRegional_cfi::deltaPhi, reco::LeafCandidate::et(), reco::LeafCandidate::eta(), i, and reco::LeafCandidate::phi().
{ bool differentSize = pfJetsReco.size() != pfJetsReReco.size(); if ( differentSize ) std::cout << "+++WARNING+++ PFJet size changed for entry " << entry_ << " !" << endl << " - RECO size : " << pfJetsReco.size() << endl << " - Re-RECO size : " << pfJetsReReco.size() << endl; unsigned minSize = pfJetsReco.size() < pfJetsReReco.size() ? pfJetsReco.size() : pfJetsReReco.size(); unsigned npr = 0; for ( unsigned i = 0; i < minSize; ++i) { const reco::PFJet & candReco = pfJetsReco[i]; const reco::PFJet & candReReco = pfJetsReReco[i]; if ( candReco.et() < 20. && candReReco.et() < 20. ) break; double deltaE = (candReReco.et()-candReco.et())/(candReReco.et()+candReco.et()); double deltaEta = candReReco.eta()-candReco.eta(); double deltaPhi = candReReco.phi()-candReco.phi(); if ( fabs(deltaE) > deltaEMax_ || fabs(deltaEta) > deltaEtaMax_ || fabs(deltaPhi) > deltaPhiMax_ ) { std::cout << "+++WARNING+++ PFJet " << i << " changed for entry " << entry_ << " ! " << std::endl << " - RECO : " << candReco.et() << " " << candReco.eta() << " " << candReco.phi() << std::endl << " - Re-RECO : " << candReReco.et() << " " << candReReco.eta() << " " << candReReco.phi() << std::endl << " DeltaE = : " << deltaE << std::endl << " DeltaEta = : " << deltaEta << std::endl << " DeltaPhi = : " << deltaPhi << std::endl << std::endl; if ( ++npr == 5 ) break; } else { std::cout << "Jet " << i << " " << candReco.et() << std::endl; } } }
void PFCandidateChecker::printMet | ( | const reco::PFCandidateCollection & | pfReco, |
const reco::PFCandidateCollection & | pfReReco | ||
) | const [private] |
Definition at line 154 of file PFCandidateChecker.cc.
References gather_cfg::cout, i, CaloMET_cfi::met, and mathSSE::sqrt().
{ double metX = 0.; double metY = 0.; for( unsigned i=0; i<pfReco.size(); i++ ) { metX += pfReco[i].px(); metY += pfReco[i].py(); } double met = std::sqrt(metX*metX + metY*metY); std::cout << "MET RECO = " << metX << " " << metY << " " << met << std::endl; metX = 0.; metY = 0.; for( unsigned i=0; i<pfReReco.size(); i++ ) { metX += pfReReco[i].px(); metY += pfReReco[i].py(); } met = std::sqrt(metX*metX + metY*metY); std::cout << "MET Re-RECO = " << metX << " " << metY << " " << met << std::endl; }
double PFCandidateChecker::deltaEMax_ [private] |
Cuts for comparison.
Definition at line 62 of file PFCandidateChecker.h.
double PFCandidateChecker::deltaEtaMax_ [private] |
Definition at line 63 of file PFCandidateChecker.h.
double PFCandidateChecker::deltaPhiMax_ [private] |
Definition at line 64 of file PFCandidateChecker.h.
unsigned PFCandidateChecker::entry_ [private] |
Counter.
Definition at line 76 of file PFCandidateChecker.h.
PFCandidates in which we'll look for pile up particles.
Definition at line 56 of file PFCandidateChecker.h.
Definition at line 57 of file PFCandidateChecker.h.
Definition at line 58 of file PFCandidateChecker.h.
Definition at line 59 of file PFCandidateChecker.h.
bool PFCandidateChecker::printBlocks_ [private] |
print the blocks associated to a given candidate ?
Definition at line 70 of file PFCandidateChecker.h.
bool PFCandidateChecker::rankByPt_ [private] |
rank the candidates by Pt
Definition at line 73 of file PFCandidateChecker.h.
bool PFCandidateChecker::verbose_ [private] |
verbose ?
Definition at line 67 of file PFCandidateChecker.h.