CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
PFCandidateChecker Class Reference

Checks what a re-reco changes in PFCandidates. More...

#include <PFCandidateChecker.h>

Inheritance diagram for PFCandidateChecker:
edm::stream::EDAnalyzer<> edm::stream::EDAnalyzerBase edm::EDConsumerBase

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 ()
 
- Public Member Functions inherited from edm::stream::EDAnalyzer<>
 EDAnalyzer ()=default
 
- Public Member Functions inherited from edm::stream::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDAnalyzerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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. More...
 
double deltaEtaMax_
 
double deltaPhiMax_
 
unsigned entry_
 Counter. More...
 
edm::InputTag inputTagPFCandidatesReco_
 PFCandidates in which we'll look for pile up particles. More...
 
edm::InputTag inputTagPFCandidatesReReco_
 
edm::InputTag inputTagPFJetsReco_
 
edm::InputTag inputTagPFJetsReReco_
 
bool printBlocks_
 print the blocks associated to a given candidate ? More...
 
bool rankByPt_
 rank the candidates by Pt More...
 
bool verbose_
 verbose ? More...
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDAnalyzer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDAnalyzerBase
typedef EDAnalyzerAdaptorBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Checks what a re-reco changes in PFCandidates.

Author
Patrick Janot
Date
August 2011

Definition at line 31 of file PFCandidateChecker.h.

Constructor & Destructor Documentation

PFCandidateChecker::PFCandidateChecker ( const edm::ParameterSet iConfig)
explicit

Definition at line 17 of file PFCandidateChecker.cc.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), and LogDebug.

17  {
18 
19 
20 
22  = iConfig.getParameter<InputTag>("pfCandidatesReco");
23 
25  = iConfig.getParameter<InputTag>("pfCandidatesReReco");
26 
28  = iConfig.getParameter<InputTag>("pfJetsReco");
29 
31  = iConfig.getParameter<InputTag>("pfJetsReReco");
32 
33  deltaEMax_
34  = iConfig.getParameter<double>("deltaEMax");
35 
37  = iConfig.getParameter<double>("deltaEtaMax");
38 
40  = iConfig.getParameter<double>("deltaPhiMax");
41 
42  verbose_ =
43  iConfig.getUntrackedParameter<bool>("verbose",false);
44 
45  printBlocks_ =
46  iConfig.getUntrackedParameter<bool>("printBlocks",false);
47 
48  rankByPt_ =
49  iConfig.getUntrackedParameter<bool>("rankByPt",false);
50 
51  entry_ = 0;
52 
53 
54  LogDebug("PFCandidateChecker")
55  <<" input collections : "<<inputTagPFCandidatesReco_<<" "<<inputTagPFCandidatesReReco_;
56 
57 }
#define LogDebug(id)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
unsigned entry_
Counter.
double deltaEMax_
Cuts for comparison.
bool verbose_
verbose ?
edm::InputTag inputTagPFJetsReReco_
bool rankByPt_
rank the candidates by Pt
edm::InputTag inputTagPFJetsReco_
edm::InputTag inputTagPFCandidatesReco_
PFCandidates in which we&#39;ll look for pile up particles.
bool printBlocks_
print the blocks associated to a given candidate ?
edm::InputTag inputTagPFCandidatesReReco_
PFCandidateChecker::~PFCandidateChecker ( )

Definition at line 61 of file PFCandidateChecker.cc.

61 { }

Member Function Documentation

void PFCandidateChecker::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Definition at line 71 of file PFCandidateChecker.cc.

References gather_cfg::cout, spr::deltaEta, MuonCkfTrajectoryBuilder_cfi::deltaPhi, reco::LeafCandidate::energy(), reco::LeafCandidate::eta(), edm::EventID::event(), edm::Event::getByLabel(), mps_fire::i, edm::EventBase::id(), LogDebug, reco::LeafCandidate::phi(), and edm::EventID::run().

72  {
73 
74  LogDebug("PFCandidateChecker")<<"START event: "<<iEvent.id().event()
75  <<" in run "<<iEvent.id().run()<<endl;
76 
77 
78 
79  // get PFCandidates
80 
81  Handle<PFCandidateCollection> pfCandidatesReco;
82  iEvent.getByLabel(inputTagPFCandidatesReco_, pfCandidatesReco);
83 
84  Handle<PFCandidateCollection> pfCandidatesReReco;
85  iEvent.getByLabel(inputTagPFCandidatesReReco_, pfCandidatesReReco);
86 
87  Handle<PFJetCollection> pfJetsReco;
88  iEvent.getByLabel(inputTagPFJetsReco_, pfJetsReco);
89 
90  Handle<PFJetCollection> pfJetsReReco;
91  iEvent.getByLabel(inputTagPFJetsReReco_, pfJetsReReco);
92 
93  reco::PFCandidateCollection pfReco, pfReReco;
94 
95  // to sort, one needs to copy
96  if(rankByPt_)
97  {
98  pfReco=*pfCandidatesReco;
99  pfReReco=*pfCandidatesReReco;
100  sort(pfReco.begin(),pfReco.end(),greaterPt);
101  sort(pfReReco.begin(),pfReReco.end(),greaterPt);
102  }
103 
104  unsigned minSize = pfReco.size() < pfReReco.size() ? pfReco.size() : pfReReco.size();
105  bool differentCand = false;
106  bool differentSize = pfReco.size() != pfReReco.size();
107  if ( differentSize )
108  std::cout << "+++WARNING+++ PFCandidate size changed for entry "
109  << entry_ << " !" << endl
110  << " - RECO size : " << pfReco.size() << endl
111  << " - Re-RECO size : " << pfReReco.size() << endl;
112 
113  unsigned npr = 0;
114  for( unsigned i=0; i<minSize; i++ ) {
115 
116  const reco::PFCandidate & candReco = (rankByPt_) ? pfReco[i] : (*pfCandidatesReco)[i];
117  const reco::PFCandidate & candReReco = (rankByPt_) ? pfReReco[i] : (*pfCandidatesReReco)[i];
118 
119  double deltaE = (candReReco.energy()-candReco.energy())/(candReReco.energy()+candReco.energy());
120  double deltaEta = candReReco.eta()-candReco.eta();
121  double deltaPhi = candReReco.phi()-candReco.phi();
122  if ( fabs(deltaE) > deltaEMax_ ||
123  fabs(deltaEta) > deltaEtaMax_ ||
124  fabs(deltaPhi) > deltaPhiMax_ ) {
125  differentCand = true;
126  std::cout << "+++WARNING+++ PFCandidate " << i
127  << " changed for entry " << entry_ << " ! " << std::endl
128  << " - RECO : " << candReco << std::endl
129  << " - Re-RECO : " << candReReco << std::endl
130  << " DeltaE = : " << deltaE << std::endl
131  << " DeltaEta = : " << deltaEta << std::endl
132  << " DeltaPhi = : " << deltaPhi << std::endl << std::endl;
133  if (printBlocks_) {
134  std::cout << "Elements in Block for RECO: " <<std::endl;
135  printElementsInBlocks(candReco);
136  std::cout << "Elements in Block for Re-RECO: " <<std::endl;
137  printElementsInBlocks(candReReco);
138  }
139  if ( ++npr == 5 ) break;
140  }
141  }
142 
143  if ( differentSize || differentCand ) {
144  printJets(*pfJetsReco, *pfJetsReReco);
145  printMet(pfReco, pfReReco);
146  }
147 
148  ++entry_;
149  LogDebug("PFCandidateChecker")<<"STOP event: "<<iEvent.id().event()
150  <<" in run "<<iEvent.id().run()<<std::endl;
151 }
#define LogDebug(id)
RunNumber_t run() const
Definition: EventID.h:39
EventNumber_t event() const
Definition: EventID.h:41
static bool greaterPt(const reco::PFCandidate &a, const reco::PFCandidate &b)
unsigned entry_
Counter.
virtual double eta() const final
momentum pseudorapidity
double deltaEMax_
Cuts for comparison.
static const double deltaEta
Definition: CaloConstants.h:8
virtual double phi() const final
momentum azimuthal angle
virtual double energy() const final
energy
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:416
edm::InputTag inputTagPFJetsReReco_
bool rankByPt_
rank the candidates by Pt
edm::InputTag inputTagPFJetsReco_
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
void printElementsInBlocks(const reco::PFCandidate &cand, std::ostream &out=std::cout) const
edm::EventID id() const
Definition: EventBase.h:60
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:39
edm::InputTag inputTagPFCandidatesReco_
PFCandidates in which we&#39;ll look for pile up particles.
bool printBlocks_
print the blocks associated to a given candidate ?
edm::InputTag inputTagPFCandidatesReReco_
void printMet(const reco::PFCandidateCollection &pfReco, const reco::PFCandidateCollection &pfReReco) const
void printJets(const reco::PFJetCollection &pfJetsReco, const reco::PFJetCollection &pfJetsReReco) const
void PFCandidateChecker::beginRun ( const edm::Run r,
const edm::EventSetup c 
)
virtual

Definition at line 66 of file PFCandidateChecker.cc.

67  { }
static bool PFCandidateChecker::greaterPt ( const reco::PFCandidate a,
const reco::PFCandidate b 
)
inlinestaticprivate

Definition at line 78 of file PFCandidateChecker.h.

References DEFINE_FWK_MODULE, and reco::LeafCandidate::pt().

78  {
79  return (a.pt()>b.pt());
80  }
virtual double pt() const final
transverse momentum
void PFCandidateChecker::printElementsInBlocks ( const reco::PFCandidate cand,
std::ostream &  out = std::cout 
) const
private

Definition at line 214 of file PFCandidateChecker.cc.

References MessageLogger_cfi::cerr, reco::PFCandidate::elementsInBlocks(), mps_fire::i, and edm::Ref< C, T, F >::isNull().

215  {
216  if(!out) return;
217 
218  PFBlockRef firstRef;
219 
220  assert(!cand.elementsInBlocks().empty() );
221  for(unsigned i=0; i<cand.elementsInBlocks().size(); i++) {
222  PFBlockRef blockRef = cand.elementsInBlocks()[i].first;
223 
224  if(blockRef.isNull()) {
225  cerr<<"ERROR! no block ref!";
226  continue;
227  }
228 
229  if(!i) {
230  out<<(*blockRef);
231  firstRef = blockRef;
232  }
233  else if( blockRef!=firstRef) {
234  cerr<<"WARNING! This PFCandidate is not made from a single block"<<endl;
235  }
236 
237  out<<"\t"<<cand.elementsInBlocks()[i].second<<endl;
238  }
239 }
bool isNull() const
Checks for null.
Definition: Ref.h:249
const ElementsInBlocks & elementsInBlocks() const
Definition: PFCandidate.cc:687
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, spr::deltaEta, MuonCkfTrajectoryBuilder_cfi::deltaPhi, reco::LeafCandidate::et(), reco::LeafCandidate::eta(), mps_fire::i, and reco::LeafCandidate::phi().

178  {
179 
180  bool differentSize = pfJetsReco.size() != pfJetsReReco.size();
181  if ( differentSize )
182  std::cout << "+++WARNING+++ PFJet size changed for entry "
183  << entry_ << " !" << endl
184  << " - RECO size : " << pfJetsReco.size() << endl
185  << " - Re-RECO size : " << pfJetsReReco.size() << endl;
186  unsigned minSize = pfJetsReco.size() < pfJetsReReco.size() ? pfJetsReco.size() : pfJetsReReco.size();
187  unsigned npr = 0;
188  for ( unsigned i = 0; i < minSize; ++i) {
189  const reco::PFJet & candReco = pfJetsReco[i];
190  const reco::PFJet & candReReco = pfJetsReReco[i];
191  if ( candReco.et() < 20. && candReReco.et() < 20. ) break;
192  double deltaE = (candReReco.et()-candReco.et())/(candReReco.et()+candReco.et());
193  double deltaEta = candReReco.eta()-candReco.eta();
194  double deltaPhi = candReReco.phi()-candReco.phi();
195  if ( fabs(deltaE) > deltaEMax_ ||
196  fabs(deltaEta) > deltaEtaMax_ ||
197  fabs(deltaPhi) > deltaPhiMax_ ) {
198  std::cout << "+++WARNING+++ PFJet " << i
199  << " changed for entry " << entry_ << " ! " << std::endl
200  << " - RECO : " << candReco.et() << " " << candReco.eta() << " " << candReco.phi() << std::endl
201  << " - Re-RECO : " << candReReco.et() << " " << candReReco.eta() << " " << candReReco.phi() << std::endl
202  << " DeltaE = : " << deltaE << std::endl
203  << " DeltaEta = : " << deltaEta << std::endl
204  << " DeltaPhi = : " << deltaPhi << std::endl << std::endl;
205  if ( ++npr == 5 ) break;
206  } else {
207  std::cout << "Jet " << i << " " << candReco.et() << std::endl;
208  }
209  }
210 
211 }
unsigned entry_
Counter.
virtual double eta() const final
momentum pseudorapidity
double deltaEMax_
Cuts for comparison.
Jets made from PFObjects.
Definition: PFJet.h:21
static const double deltaEta
Definition: CaloConstants.h:8
virtual double phi() const final
momentum azimuthal angle
virtual double et() const final
transverse energy
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, mps_fire::i, RazorAnalyzer::met, and mathSSE::sqrt().

155  {
156 
157  double metX = 0.;
158  double metY = 0.;
159  for( unsigned i=0; i<pfReco.size(); i++ ) {
160  metX += pfReco[i].px();
161  metY += pfReco[i].py();
162  }
163  double met = std::sqrt(metX*metX + metY*metY);
164  std::cout << "MET RECO = " << metX << " " << metY << " " << met << std::endl;
165 
166  metX = 0.;
167  metY = 0.;
168  for( unsigned i=0; i<pfReReco.size(); i++ ) {
169  metX += pfReReco[i].px();
170  metY += pfReReco[i].py();
171  }
172  met = std::sqrt(metX*metX + metY*metY);
173  std::cout << "MET Re-RECO = " << metX << " " << metY << " " << met << std::endl;
174 
175 }
T sqrt(T t)
Definition: SSEVec.h:18
met
===> hadronic RAZOR

Member Data Documentation

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.

edm::InputTag PFCandidateChecker::inputTagPFCandidatesReco_
private

PFCandidates in which we'll look for pile up particles.

Definition at line 56 of file PFCandidateChecker.h.

edm::InputTag PFCandidateChecker::inputTagPFCandidatesReReco_
private

Definition at line 57 of file PFCandidateChecker.h.

edm::InputTag PFCandidateChecker::inputTagPFJetsReco_
private

Definition at line 58 of file PFCandidateChecker.h.

edm::InputTag PFCandidateChecker::inputTagPFJetsReReco_
private

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.