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...

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

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginRun (const edm::Run &r, const edm::EventSetup &c) override
 
 PFCandidateChecker (const edm::ParameterSet &)
 
 ~PFCandidateChecker () override
 
- Public Member Functions inherited from edm::stream::EDAnalyzer< T >
 EDAnalyzer ()=default
 
- Public Member Functions inherited from edm::stream::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
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
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
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< T >
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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 24 of file PFCandidateChecker.cc.

Constructor & Destructor Documentation

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

Definition at line 73 of file PFCandidateChecker.cc.

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

73  {
74  inputTagPFCandidatesReco_ = iConfig.getParameter<InputTag>("pfCandidatesReco");
75 
76  inputTagPFCandidatesReReco_ = iConfig.getParameter<InputTag>("pfCandidatesReReco");
77 
78  inputTagPFJetsReco_ = iConfig.getParameter<InputTag>("pfJetsReco");
79 
80  inputTagPFJetsReReco_ = iConfig.getParameter<InputTag>("pfJetsReReco");
81 
82  deltaEMax_ = iConfig.getParameter<double>("deltaEMax");
83 
84  deltaEtaMax_ = iConfig.getParameter<double>("deltaEtaMax");
85 
86  deltaPhiMax_ = iConfig.getParameter<double>("deltaPhiMax");
87 
88  verbose_ = iConfig.getUntrackedParameter<bool>("verbose", false);
89 
90  printBlocks_ = iConfig.getUntrackedParameter<bool>("printBlocks", false);
91 
92  rankByPt_ = iConfig.getUntrackedParameter<bool>("rankByPt", false);
93 
94  entry_ = 0;
95 
96  LogDebug("PFCandidateChecker") << " input collections : " << inputTagPFCandidatesReco_ << " "
98 }
#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 ( )
override

Definition at line 100 of file PFCandidateChecker.cc.

100 {}

Member Function Documentation

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

Definition at line 104 of file PFCandidateChecker.cc.

References gather_cfg::cout, EgHLTOffHistBins_cfi::deltaE, spr::deltaEta, SiPixelRawToDigiRegional_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().

104  {
105  LogDebug("PFCandidateChecker") << "START event: " << iEvent.id().event() << " in run " << iEvent.id().run() << endl;
106 
107  // get PFCandidates
108 
109  Handle<PFCandidateCollection> pfCandidatesReco;
110  iEvent.getByLabel(inputTagPFCandidatesReco_, pfCandidatesReco);
111 
112  Handle<PFCandidateCollection> pfCandidatesReReco;
113  iEvent.getByLabel(inputTagPFCandidatesReReco_, pfCandidatesReReco);
114 
115  Handle<PFJetCollection> pfJetsReco;
116  iEvent.getByLabel(inputTagPFJetsReco_, pfJetsReco);
117 
118  Handle<PFJetCollection> pfJetsReReco;
119  iEvent.getByLabel(inputTagPFJetsReReco_, pfJetsReReco);
120 
121  reco::PFCandidateCollection pfReco, pfReReco;
122 
123  // to sort, one needs to copy
124  if (rankByPt_) {
125  pfReco = *pfCandidatesReco;
126  pfReReco = *pfCandidatesReReco;
127  sort(pfReco.begin(), pfReco.end(), greaterPt);
128  sort(pfReReco.begin(), pfReReco.end(), greaterPt);
129  }
130 
131  unsigned minSize = pfReco.size() < pfReReco.size() ? pfReco.size() : pfReReco.size();
132  bool differentCand = false;
133  bool differentSize = pfReco.size() != pfReReco.size();
134  if (differentSize)
135  std::cout << "+++WARNING+++ PFCandidate size changed for entry " << entry_ << " !" << endl
136  << " - RECO size : " << pfReco.size() << endl
137  << " - Re-RECO size : " << pfReReco.size() << endl;
138 
139  unsigned npr = 0;
140  for (unsigned i = 0; i < minSize; i++) {
141  const reco::PFCandidate& candReco = (rankByPt_) ? pfReco[i] : (*pfCandidatesReco)[i];
142  const reco::PFCandidate& candReReco = (rankByPt_) ? pfReReco[i] : (*pfCandidatesReReco)[i];
143 
144  double deltaE = (candReReco.energy() - candReco.energy()) / (candReReco.energy() + candReco.energy());
145  double deltaEta = candReReco.eta() - candReco.eta();
146  double deltaPhi = candReReco.phi() - candReco.phi();
147  if (fabs(deltaE) > deltaEMax_ || fabs(deltaEta) > deltaEtaMax_ || fabs(deltaPhi) > deltaPhiMax_) {
148  differentCand = true;
149  std::cout << "+++WARNING+++ PFCandidate " << i << " changed for entry " << entry_ << " ! " << std::endl
150  << " - RECO : " << candReco << std::endl
151  << " - Re-RECO : " << candReReco << std::endl
152  << " DeltaE = : " << deltaE << std::endl
153  << " DeltaEta = : " << deltaEta << std::endl
154  << " DeltaPhi = : " << deltaPhi << std::endl
155  << std::endl;
156  if (printBlocks_) {
157  std::cout << "Elements in Block for RECO: " << std::endl;
158  printElementsInBlocks(candReco);
159  std::cout << "Elements in Block for Re-RECO: " << std::endl;
160  printElementsInBlocks(candReReco);
161  }
162  if (++npr == 5)
163  break;
164  }
165  }
166 
167  if (differentSize || differentCand) {
168  printJets(*pfJetsReco, *pfJetsReReco);
169  printMet(pfReco, pfReReco);
170  }
171 
172  ++entry_;
173  LogDebug("PFCandidateChecker") << "STOP event: " << iEvent.id().event() << " in run " << iEvent.id().run()
174  << std::endl;
175 }
#define LogDebug(id)
RunNumber_t run() const
Definition: EventID.h:38
EventNumber_t event() const
Definition: EventID.h:40
static bool greaterPt(const reco::PFCandidate &a, const reco::PFCandidate &b)
double eta() const final
momentum pseudorapidity
unsigned entry_
Counter.
double deltaEMax_
Cuts for comparison.
static const double deltaEta
Definition: CaloConstants.h:8
double energy() const final
energy
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:488
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:59
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
edm::InputTag inputTagPFCandidatesReco_
PFCandidates in which we&#39;ll look for pile up particles.
bool printBlocks_
print the blocks associated to a given candidate ?
double phi() const final
momentum azimuthal angle
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 
)
override

Definition at line 102 of file PFCandidateChecker.cc.

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

Definition at line 64 of file PFCandidateChecker.cc.

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

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

Definition at line 230 of file PFCandidateChecker.cc.

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

230  {
231  if (!out)
232  return;
233 
234  PFBlockRef firstRef;
235 
236  assert(!cand.elementsInBlocks().empty());
237  for (unsigned i = 0; i < cand.elementsInBlocks().size(); i++) {
238  PFBlockRef blockRef = cand.elementsInBlocks()[i].first;
239 
240  if (blockRef.isNull()) {
241  cerr << "ERROR! no block ref!";
242  continue;
243  }
244 
245  if (!i) {
246  out << (*blockRef);
247  firstRef = blockRef;
248  } else if (blockRef != firstRef) {
249  cerr << "WARNING! This PFCandidate is not made from a single block" << endl;
250  }
251 
252  out << "\t" << cand.elementsInBlocks()[i].second << endl;
253  }
254 }
bool isNull() const
Checks for null.
Definition: Ref.h:235
const ElementsInBlocks & elementsInBlocks() const
Definition: PFCandidate.cc:636
void PFCandidateChecker::printJets ( const reco::PFJetCollection pfJetsReco,
const reco::PFJetCollection pfJetsReReco 
) const
private

Definition at line 197 of file PFCandidateChecker.cc.

References gather_cfg::cout, EgHLTOffHistBins_cfi::deltaE, spr::deltaEta, SiPixelRawToDigiRegional_cfi::deltaPhi, reco::LeafCandidate::et(), reco::LeafCandidate::eta(), mps_fire::i, and reco::LeafCandidate::phi().

197  {
198  bool differentSize = pfJetsReco.size() != pfJetsReReco.size();
199  if (differentSize)
200  std::cout << "+++WARNING+++ PFJet size changed for entry " << entry_ << " !" << endl
201  << " - RECO size : " << pfJetsReco.size() << endl
202  << " - Re-RECO size : " << pfJetsReReco.size() << endl;
203  unsigned minSize = pfJetsReco.size() < pfJetsReReco.size() ? pfJetsReco.size() : pfJetsReReco.size();
204  unsigned npr = 0;
205  for (unsigned i = 0; i < minSize; ++i) {
206  const reco::PFJet& candReco = pfJetsReco[i];
207  const reco::PFJet& candReReco = pfJetsReReco[i];
208  if (candReco.et() < 20. && candReReco.et() < 20.)
209  break;
210  double deltaE = (candReReco.et() - candReco.et()) / (candReReco.et() + candReco.et());
211  double deltaEta = candReReco.eta() - candReco.eta();
212  double deltaPhi = candReReco.phi() - candReco.phi();
213  if (fabs(deltaE) > deltaEMax_ || fabs(deltaEta) > deltaEtaMax_ || fabs(deltaPhi) > deltaPhiMax_) {
214  std::cout << "+++WARNING+++ PFJet " << i << " changed for entry " << entry_ << " ! " << std::endl
215  << " - RECO : " << candReco.et() << " " << candReco.eta() << " " << candReco.phi() << std::endl
216  << " - Re-RECO : " << candReReco.et() << " " << candReReco.eta() << " " << candReReco.phi()
217  << std::endl
218  << " DeltaE = : " << deltaE << std::endl
219  << " DeltaEta = : " << deltaEta << std::endl
220  << " DeltaPhi = : " << deltaPhi << std::endl
221  << std::endl;
222  if (++npr == 5)
223  break;
224  } else {
225  std::cout << "Jet " << i << " " << candReco.et() << std::endl;
226  }
227  }
228 }
double eta() const final
momentum pseudorapidity
unsigned entry_
Counter.
double deltaEMax_
Cuts for comparison.
Jets made from PFObjects.
Definition: PFJet.h:20
static const double deltaEta
Definition: CaloConstants.h:8
double et() const final
transverse energy
double phi() const final
momentum azimuthal angle
void PFCandidateChecker::printMet ( const reco::PFCandidateCollection pfReco,
const reco::PFCandidateCollection pfReReco 
) const
private

Definition at line 177 of file PFCandidateChecker.cc.

References gather_cfg::cout, mps_fire::i, BTaggingMonitor_cfi::met, and mathSSE::sqrt().

177  {
178  double metX = 0.;
179  double metY = 0.;
180  for (unsigned i = 0; i < pfReco.size(); i++) {
181  metX += pfReco[i].px();
182  metY += pfReco[i].py();
183  }
184  double met = std::sqrt(metX * metX + metY * metY);
185  std::cout << "MET RECO = " << metX << " " << metY << " " << met << std::endl;
186 
187  metX = 0.;
188  metY = 0.;
189  for (unsigned i = 0; i < pfReReco.size(); i++) {
190  metX += pfReReco[i].px();
191  metY += pfReReco[i].py();
192  }
193  met = std::sqrt(metX * metX + metY * metY);
194  std::cout << "MET Re-RECO = " << metX << " " << metY << " " << met << std::endl;
195 }
T sqrt(T t)
Definition: SSEVec.h:19

Member Data Documentation

double PFCandidateChecker::deltaEMax_
private

Cuts for comparison.

Definition at line 48 of file PFCandidateChecker.cc.

double PFCandidateChecker::deltaEtaMax_
private

Definition at line 49 of file PFCandidateChecker.cc.

double PFCandidateChecker::deltaPhiMax_
private

Definition at line 50 of file PFCandidateChecker.cc.

unsigned PFCandidateChecker::entry_
private

Counter.

Definition at line 62 of file PFCandidateChecker.cc.

edm::InputTag PFCandidateChecker::inputTagPFCandidatesReco_
private

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

Definition at line 42 of file PFCandidateChecker.cc.

edm::InputTag PFCandidateChecker::inputTagPFCandidatesReReco_
private

Definition at line 43 of file PFCandidateChecker.cc.

edm::InputTag PFCandidateChecker::inputTagPFJetsReco_
private

Definition at line 44 of file PFCandidateChecker.cc.

edm::InputTag PFCandidateChecker::inputTagPFJetsReReco_
private

Definition at line 45 of file PFCandidateChecker.cc.

bool PFCandidateChecker::printBlocks_
private

print the blocks associated to a given candidate ?

Definition at line 56 of file PFCandidateChecker.cc.

bool PFCandidateChecker::rankByPt_
private

rank the candidates by Pt

Definition at line 59 of file PFCandidateChecker.cc.

bool PFCandidateChecker::verbose_
private

verbose ?

Definition at line 53 of file PFCandidateChecker.cc.