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 >
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
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
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (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)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Checks what a re-reco changes in PFCandidates.

Author
Patrick Janot
Date
August 2011

Definition at line 23 of file PFCandidateChecker.cc.

Constructor & Destructor Documentation

◆ PFCandidateChecker()

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

Definition at line 72 of file PFCandidateChecker.cc.

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

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

◆ ~PFCandidateChecker()

PFCandidateChecker::~PFCandidateChecker ( )
override

Definition at line 99 of file PFCandidateChecker.cc.

99 {}

Member Function Documentation

◆ analyze()

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

Implements edm::stream::EDAnalyzerBase.

Definition at line 103 of file PFCandidateChecker.cc.

103  {
104  LogDebug("PFCandidateChecker") << "START event: " << iEvent.id().event() << " in run " << iEvent.id().run() << endl;
105 
106  // get PFCandidates
107 
108  Handle<PFCandidateCollection> pfCandidatesReco;
109  iEvent.getByLabel(inputTagPFCandidatesReco_, pfCandidatesReco);
110 
111  Handle<PFCandidateCollection> pfCandidatesReReco;
112  iEvent.getByLabel(inputTagPFCandidatesReReco_, pfCandidatesReReco);
113 
114  Handle<PFJetCollection> pfJetsReco;
115  iEvent.getByLabel(inputTagPFJetsReco_, pfJetsReco);
116 
117  Handle<PFJetCollection> pfJetsReReco;
118  iEvent.getByLabel(inputTagPFJetsReReco_, pfJetsReReco);
119 
120  reco::PFCandidateCollection pfReco, pfReReco;
121 
122  // to sort, one needs to copy
123  if (rankByPt_) {
124  pfReco = *pfCandidatesReco;
125  pfReReco = *pfCandidatesReReco;
126  sort(pfReco.begin(), pfReco.end(), greaterPt);
127  sort(pfReReco.begin(), pfReReco.end(), greaterPt);
128  }
129 
130  unsigned minSize = pfReco.size() < pfReReco.size() ? pfReco.size() : pfReReco.size();
131  bool differentCand = false;
132  bool differentSize = pfReco.size() != pfReReco.size();
133  if (differentSize)
134  std::cout << "+++WARNING+++ PFCandidate size changed for entry " << entry_ << " !" << endl
135  << " - RECO size : " << pfReco.size() << endl
136  << " - Re-RECO size : " << pfReReco.size() << endl;
137 
138  unsigned npr = 0;
139  for (unsigned i = 0; i < minSize; i++) {
140  const reco::PFCandidate& candReco = (rankByPt_) ? pfReco[i] : (*pfCandidatesReco)[i];
141  const reco::PFCandidate& candReReco = (rankByPt_) ? pfReReco[i] : (*pfCandidatesReReco)[i];
142 
143  double deltaE = (candReReco.energy() - candReco.energy()) / (candReReco.energy() + candReco.energy());
144  double deltaEta = candReReco.eta() - candReco.eta();
145  double deltaPhi = candReReco.phi() - candReco.phi();
146  if (fabs(deltaE) > deltaEMax_ || fabs(deltaEta) > deltaEtaMax_ || fabs(deltaPhi) > deltaPhiMax_) {
147  differentCand = true;
148  std::cout << "+++WARNING+++ PFCandidate " << i << " changed for entry " << entry_ << " ! " << std::endl
149  << " - RECO : " << candReco << std::endl
150  << " - Re-RECO : " << candReReco << std::endl
151  << " DeltaE = : " << deltaE << std::endl
152  << " DeltaEta = : " << deltaEta << std::endl
153  << " DeltaPhi = : " << deltaPhi << std::endl
154  << std::endl;
155  if (printBlocks_) {
156  std::cout << "Elements in Block for RECO: " << std::endl;
157  printElementsInBlocks(candReco);
158  std::cout << "Elements in Block for Re-RECO: " << std::endl;
159  printElementsInBlocks(candReReco);
160  }
161  if (++npr == 5)
162  break;
163  }
164  }
165 
166  if (differentSize || differentCand) {
167  printJets(*pfJetsReco, *pfJetsReReco);
168  printMet(pfReco, pfReReco);
169  }
170 
171  ++entry_;
172  LogDebug("PFCandidateChecker") << "STOP event: " << iEvent.id().event() << " in run " << iEvent.id().run()
173  << std::endl;
174 }

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

◆ beginRun()

void PFCandidateChecker::beginRun ( const edm::Run r,
const edm::EventSetup c 
)
overridevirtual

Reimplemented from edm::stream::EDAnalyzerBase.

Definition at line 101 of file PFCandidateChecker.cc.

101 {}

◆ greaterPt()

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

Definition at line 63 of file PFCandidateChecker.cc.

63 { return (a.pt() > b.pt()); }

References a, and b.

◆ printElementsInBlocks()

void PFCandidateChecker::printElementsInBlocks ( const reco::PFCandidate cand,
std::ostream &  out = std::cout 
) const
private

Definition at line 229 of file PFCandidateChecker.cc.

229  {
230  if (!out)
231  return;
232 
233  PFBlockRef firstRef;
234 
235  assert(!cand.elementsInBlocks().empty());
236  for (unsigned i = 0; i < cand.elementsInBlocks().size(); i++) {
237  PFBlockRef blockRef = cand.elementsInBlocks()[i].first;
238 
239  if (blockRef.isNull()) {
240  cerr << "ERROR! no block ref!";
241  continue;
242  }
243 
244  if (!i) {
245  out << (*blockRef);
246  firstRef = blockRef;
247  } else if (blockRef != firstRef) {
248  cerr << "WARNING! This PFCandidate is not made from a single block" << endl;
249  }
250 
251  out << "\t" << cand.elementsInBlocks()[i].second << endl;
252  }
253 }

References cms::cuda::assert(), beam_dqm_sourceclient-live_cfg::cerr, mps_fire::i, edm::Ref< C, T, F >::isNull(), and MillePedeFileConverter_cfg::out.

◆ printJets()

void PFCandidateChecker::printJets ( const reco::PFJetCollection pfJetsReco,
const reco::PFJetCollection pfJetsReReco 
) const
private

Definition at line 196 of file PFCandidateChecker.cc.

196  {
197  bool differentSize = pfJetsReco.size() != pfJetsReReco.size();
198  if (differentSize)
199  std::cout << "+++WARNING+++ PFJet size changed for entry " << entry_ << " !" << endl
200  << " - RECO size : " << pfJetsReco.size() << endl
201  << " - Re-RECO size : " << pfJetsReReco.size() << endl;
202  unsigned minSize = pfJetsReco.size() < pfJetsReReco.size() ? pfJetsReco.size() : pfJetsReReco.size();
203  unsigned npr = 0;
204  for (unsigned i = 0; i < minSize; ++i) {
205  const reco::PFJet& candReco = pfJetsReco[i];
206  const reco::PFJet& candReReco = pfJetsReReco[i];
207  if (candReco.et() < 20. && candReReco.et() < 20.)
208  break;
209  double deltaE = (candReReco.et() - candReco.et()) / (candReReco.et() + candReco.et());
210  double deltaEta = candReReco.eta() - candReco.eta();
211  double deltaPhi = candReReco.phi() - candReco.phi();
212  if (fabs(deltaE) > deltaEMax_ || fabs(deltaEta) > deltaEtaMax_ || fabs(deltaPhi) > deltaPhiMax_) {
213  std::cout << "+++WARNING+++ PFJet " << i << " changed for entry " << entry_ << " ! " << std::endl
214  << " - RECO : " << candReco.et() << " " << candReco.eta() << " " << candReco.phi() << std::endl
215  << " - Re-RECO : " << candReReco.et() << " " << candReReco.eta() << " " << candReReco.phi()
216  << std::endl
217  << " DeltaE = : " << deltaE << std::endl
218  << " DeltaEta = : " << deltaEta << std::endl
219  << " DeltaPhi = : " << deltaPhi << std::endl
220  << std::endl;
221  if (++npr == 5)
222  break;
223  } else {
224  std::cout << "Jet " << i << " " << candReco.et() << std::endl;
225  }
226  }
227 }

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

◆ printMet()

void PFCandidateChecker::printMet ( const reco::PFCandidateCollection pfReco,
const reco::PFCandidateCollection pfReReco 
) const
private

Definition at line 176 of file PFCandidateChecker.cc.

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

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

Member Data Documentation

◆ deltaEMax_

double PFCandidateChecker::deltaEMax_
private

Cuts for comparison.

Definition at line 47 of file PFCandidateChecker.cc.

◆ deltaEtaMax_

double PFCandidateChecker::deltaEtaMax_
private

Definition at line 48 of file PFCandidateChecker.cc.

◆ deltaPhiMax_

double PFCandidateChecker::deltaPhiMax_
private

Definition at line 49 of file PFCandidateChecker.cc.

◆ entry_

unsigned PFCandidateChecker::entry_
private

Counter.

Definition at line 61 of file PFCandidateChecker.cc.

◆ inputTagPFCandidatesReco_

edm::InputTag PFCandidateChecker::inputTagPFCandidatesReco_
private

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

Definition at line 41 of file PFCandidateChecker.cc.

◆ inputTagPFCandidatesReReco_

edm::InputTag PFCandidateChecker::inputTagPFCandidatesReReco_
private

Definition at line 42 of file PFCandidateChecker.cc.

◆ inputTagPFJetsReco_

edm::InputTag PFCandidateChecker::inputTagPFJetsReco_
private

Definition at line 43 of file PFCandidateChecker.cc.

◆ inputTagPFJetsReReco_

edm::InputTag PFCandidateChecker::inputTagPFJetsReReco_
private

Definition at line 44 of file PFCandidateChecker.cc.

◆ printBlocks_

bool PFCandidateChecker::printBlocks_
private

print the blocks associated to a given candidate ?

Definition at line 55 of file PFCandidateChecker.cc.

◆ rankByPt_

bool PFCandidateChecker::rankByPt_
private

rank the candidates by Pt

Definition at line 58 of file PFCandidateChecker.cc.

◆ verbose_

bool PFCandidateChecker::verbose_
private

verbose ?

Definition at line 52 of file PFCandidateChecker.cc.

PFCandidateChecker::inputTagPFCandidatesReco_
edm::InputTag inputTagPFCandidatesReco_
PFCandidates in which we'll look for pile up particles.
Definition: PFCandidateChecker.cc:41
mps_fire.i
i
Definition: mps_fire.py:355
PFCandidateChecker::verbose_
bool verbose_
verbose ?
Definition: PFCandidateChecker.cc:52
PFCandidateChecker::inputTagPFCandidatesReReco_
edm::InputTag inputTagPFCandidatesReReco_
Definition: PFCandidateChecker.cc:42
PFCandidateChecker::deltaEMax_
double deltaEMax_
Cuts for comparison.
Definition: PFCandidateChecker.cc:47
PFCandidateChecker::inputTagPFJetsReReco_
edm::InputTag inputTagPFJetsReReco_
Definition: PFCandidateChecker.cc:44
edm::Ref::isNull
bool isNull() const
Checks for null.
Definition: Ref.h:235
gather_cfg.cout
cout
Definition: gather_cfg.py:144
cms::cuda::assert
assert(be >=bs)
PFCandidateChecker::printMet
void printMet(const reco::PFCandidateCollection &pfReco, const reco::PFCandidateCollection &pfReReco) const
Definition: PFCandidateChecker.cc:176
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::Handle
Definition: AssociativeIterator.h:50
edm::Ref< PFBlockCollection >
BTaggingMonitor_cfi.met
met
Definition: BTaggingMonitor_cfi.py:84
spr::deltaEta
static const double deltaEta
Definition: CaloConstants.h:8
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition: SiPixelRawToDigiRegional_cfi.py:9
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
b
double b
Definition: hdecay.h:118
PFCandidateChecker::rankByPt_
bool rankByPt_
rank the candidates by Pt
Definition: PFCandidateChecker.cc:58
PFCandidateChecker::printJets
void printJets(const reco::PFJetCollection &pfJetsReco, const reco::PFJetCollection &pfJetsReReco) const
Definition: PFCandidateChecker.cc:196
PFCandidateChecker::greaterPt
static bool greaterPt(const reco::PFCandidate &a, const reco::PFCandidate &b)
Definition: PFCandidateChecker.cc:63
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
a
double a
Definition: hdecay.h:119
reco::LeafCandidate::eta
double eta() const final
momentum pseudorapidity
Definition: LeafCandidate.h:152
beam_dqm_sourceclient-live_cfg.cerr
cerr
Definition: beam_dqm_sourceclient-live_cfg.py:17
EgHLTOffHistBins_cfi.deltaE
deltaE
Definition: EgHLTOffHistBins_cfi.py:28
cand
Definition: decayParser.h:34
iEvent
int iEvent
Definition: GenABIO.cc:224
PFCandidateChecker::entry_
unsigned entry_
Counter.
Definition: PFCandidateChecker.cc:61
PFCandidateChecker::printElementsInBlocks
void printElementsInBlocks(const reco::PFCandidate &cand, std::ostream &out=std::cout) const
Definition: PFCandidateChecker.cc:229
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
reco::LeafCandidate::et
double et() const final
transverse energy
Definition: LeafCandidate.h:127
PFCandidateChecker::deltaPhiMax_
double deltaPhiMax_
Definition: PFCandidateChecker.cc:49
reco::LeafCandidate::phi
double phi() const final
momentum azimuthal angle
Definition: LeafCandidate.h:148
reco::PFCandidateCollection
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
Definition: PFCandidateFwd.h:12
reco::PFJet
Jets made from PFObjects.
Definition: PFJet.h:20
PFCandidateChecker::inputTagPFJetsReco_
edm::InputTag inputTagPFJetsReco_
Definition: PFCandidateChecker.cc:43
reco::LeafCandidate::energy
double energy() const final
energy
Definition: LeafCandidate.h:125
reco::PFCandidate
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
PFCandidateChecker::deltaEtaMax_
double deltaEtaMax_
Definition: PFCandidateChecker.cc:48
edm::InputTag
Definition: InputTag.h:15
PFCandidateChecker::printBlocks_
bool printBlocks_
print the blocks associated to a given candidate ?
Definition: PFCandidateChecker.cc:55