CMS 3D CMS Logo

PFCandidateMonitor.h
Go to the documentation of this file.
1 #ifndef DQMOffline_PFTau_PFCandidateMonitor_h
2 #define DQMOffline_PFTau_PFCandidateMonitor_h
3 
8 
11 
12 #include <vector>
13 
14 #include <TH1.h> //needed by the deltaR->Fill() call
15 
16 class PFCandidateMonitor : public Benchmark {
17 public:
19 
20  ~PFCandidateMonitor() override;
21 
23  void setParameters(float dRMax,
24  bool matchCharge,
26  float ptmin,
27  float ptmax,
28  float etamin,
29  float etamax,
30  float phimin,
31  float phimax,
32  bool refHistoFlag);
33 
36 
38  void setDirectory(TDirectory *dir) override;
39 
41  void setup(DQMStore::IBooker &b);
43 
45  template <class T, class C>
46  /*void fill(const T& candidateCollection,
47  const C& matchedCandCollection, float& minVal, float& maxVal) ;*/
48  void fill(const T &candidateCollection,
49  const C &matchedCandCollection,
50  float &minVal,
51  float &maxVal,
53  template <class T, class C, class M>
54  void fill(const T &candidateCollection,
55  const C &matchedCandCollection,
56  float &minVal,
57  float &maxVal,
59  const M &muonMatchedCandCollection);
60 
61  void fillOne(const reco::Candidate &cand);
62 
63 protected:
66 
67  TH1F *pt_gen_;
68  TH1F *eta_gen_;
69  TH1F *phi_gen_;
70 
71  TH1F *pt_ref_;
72  TH1F *eta_ref_;
73  TH1F *phi_ref_;
74 
75  TH1F *deltaR_;
76  float dRMax_;
80 
83 };
84 
86 template <class T, class C>
87 void PFCandidateMonitor::fill(const T &candCollection,
88  const C &matchedCandCollection,
89  float &minVal,
90  float &maxVal,
92  matching_done_ = false;
94  for (unsigned i = 0; i < candCollection.size(); ++i) {
95  if (!isInRange(candCollection[i].pt(), candCollection[i].eta(), candCollection[i].phi()))
96  continue;
97  fillOne(candCollection[i]); // fill pt_gen, eta_gen and phi_gen histos for
98  // UNMATCHED generated candidate
99 
100  for (unsigned j = 0; j < matchedCandCollection.size(); ++j) // for DeltaR spectrum
101  if (deltaR_)
102  deltaR_->Fill(reco::deltaR(candCollection[i], matchedCandCollection[j]));
103  }
104  }
105 
106  std::vector<int> matchIndices;
107  PFB::match(candCollection, matchedCandCollection, matchIndices, matchCharge_, dRMax_);
108  // PFB::match( candCollection, matchedCandCollection, matchIndices,
109  // parameterSet, matchCharge_, dRMax_ );
110  // now matchIndices[i] stores the j-th closest matched jet
111  matching_done_ = true;
112 
113  for (unsigned int i = 0; i < (candCollection).size(); i++) {
114  const reco::Candidate &cand = candCollection[i];
115 
116  if (!isInRange(cand.pt(), cand.eta(), cand.phi()))
117  continue;
118 
119  int iMatch = matchIndices[i];
120  assert(iMatch < static_cast<int>(matchedCandCollection.size()));
121 
122  if (iMatch != -1) {
123  const reco::Candidate &matchedCand = matchedCandCollection[iMatch];
124  if (!isInRange(matchedCand.pt(), matchedCand.eta(), matchedCand.phi()))
125  continue;
126  // std::cout <<"PFJet pT " <<cand.pt() <<" eta " <<cand.eta() <<" phi "
127  // <<cand.phi() ; std::cout <<"\nmatched genJet pT " <<matchedCand.pt()
128  // <<" eta " <<matchedCand.eta() <<" phi " <<matchedCand.phi() <<"\n"
129  // <<std::endl ;
130  float ptRes = (cand.pt() - matchedCand.pt()) / matchedCand.pt();
131 
132  if (ptRes > maxVal)
133  maxVal = ptRes;
134  if (ptRes < minVal)
135  minVal = ptRes;
136 
138  candBench_.fillOne(cand); // fill pt, eta phi and charge histos for MATCHED candidate
139  // matchCandBench_.fillOne(cand, matchedCand); // fill delta_x_VS_y
140  // histos for matched couple
141  matchCandBench_.fillOne(cand, matchedCand,
142  parameterSet); // fill delta_x_VS_y histos for matched couple
144  fillOne(matchedCand); // fill pt_ref, eta_ref and phi_ref histos for
145  // MATCHED reference candidate
146  } else {
147  candBench_.fillOne(matchedCand); // fill pt, eta phi and charge histos
148  // for MATCHED candidate
149  // matchCandBench_.fillOne(matchedCand, cand); // fill delta_x_VS_y
150  // histos for matched couple
151  matchCandBench_.fillOne(cand, matchedCand,
152  parameterSet); // fill delta_x_VS_y histos for matched couple
154  fillOne(cand); // fill pt_ref, eta_ref and phi_ref histos for MATCHED
155  // reference candidate
156  }
157  }
158  }
159 }
160 
161 template <class T, class C, class M>
162 /*void PFCandidateMonitor::fill(const T& candCollection,
163  const C& matchedCandCollection, float& minVal, float& maxVal) {*/
164 void PFCandidateMonitor::fill(const T &candCollection,
165  const C &matchedCandCollection,
166  float &minVal,
167  float &maxVal,
169  const M &muonMatchedCandCollection) {
170  matching_done_ = false;
172  for (unsigned i = 0; i < candCollection.size(); ++i) {
173  if (!isInRange(candCollection[i].pt(), candCollection[i].eta(), candCollection[i].phi()))
174  continue;
175  fillOne(candCollection[i]); // fill pt_gen, eta_gen and phi_gen histos for
176  // UNMATCHED generated candidate
177 
178  for (unsigned j = 0; j < matchedCandCollection.size(); ++j) // for DeltaR spectrum
179  if (deltaR_)
180  deltaR_->Fill(reco::deltaR(candCollection[i], matchedCandCollection[j]));
181  }
182  }
183 
184  std::vector<int> matchIndices;
185  // PFB::match( candCollection, matchedCandCollection, matchIndices,
186  // matchCharge_, dRMax_ ); PFB::match( candCollection, matchedCandCollection,
187  // matchIndices, parameterSet, matchCharge_, dRMax_ );
188  PFB::match(candCollection,
189  matchedCandCollection,
190  matchIndices,
191  parameterSet,
192  muonMatchedCandCollection,
193  matchCharge_,
194  dRMax_);
195  // now matchIndices[i] stores the j-th closest matched jet
196  matching_done_ = true;
197 
198  for (unsigned int i = 0; i < (candCollection).size(); i++) {
199  const reco::Candidate &cand = candCollection[i];
200 
201  if (!isInRange(cand.pt(), cand.eta(), cand.phi()))
202  continue;
203 
204  int iMatch = matchIndices[i];
205  assert(iMatch < static_cast<int>(matchedCandCollection.size()));
206 
207  if (iMatch != -1) {
208  const reco::Candidate &matchedCand = matchedCandCollection[iMatch];
209  if (!isInRange(matchedCand.pt(), matchedCand.eta(), matchedCand.phi()))
210  continue;
211  // std::cout <<"PFJet pT " <<cand.pt() <<" eta " <<cand.eta() <<" phi "
212  // <<cand.phi() ; std::cout <<"\nmatched genJet pT " <<matchedCand.pt()
213  // <<" eta " <<matchedCand.eta() <<" phi " <<matchedCand.phi() <<"\n"
214  // <<std::endl ;
215  float ptRes = (cand.pt() - matchedCand.pt()) / matchedCand.pt();
216 
217  if (ptRes > maxVal)
218  maxVal = ptRes;
219  if (ptRes < minVal)
220  minVal = ptRes;
221 
223  candBench_.fillOne(cand); // fill pt, eta phi and charge histos for MATCHED candidate
224  matchCandBench_.fillOne(cand, matchedCand,
225  parameterSet); // fill delta_x_VS_y histos for matched couple
227  fillOne(matchedCand); // fill pt_ref, eta_ref and phi_ref histos for
228  // MATCHED reference candidate
229  } else {
230  candBench_.fillOne(matchedCand); // fill pt, eta phi and charge histos
231  // for MATCHED candidate
232  matchCandBench_.fillOne(cand, matchedCand,
233  parameterSet); // fill delta_x_VS_y histos for matched couple
235  fillOne(cand); // fill pt_ref, eta_ref and phi_ref histos for MATCHED
236  // reference candidate
237  }
238  }
239  }
240 }
241 #endif
Benchmark
abstract base class
Definition: Benchmark.h:19
PFCandidateMonitor::matchCharge_
bool matchCharge_
Definition: PFCandidateMonitor.h:77
mps_fire.i
i
Definition: mps_fire.py:428
PFCandidateMonitor::createEfficiencyHistos_
bool createEfficiencyHistos_
Definition: PFCandidateMonitor.h:82
Benchmark::isInRange
bool isInRange(float pt, float eta, float phi) const
Definition: Benchmark.h:50
PFB::match
void match(const C &candCollection, const M &matchedCandCollection, std::vector< int > &matchIndices, bool matchCharge=false, float dRMax=-1)
Definition: Matchers.h:17
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
reco::Candidate::eta
virtual double eta() const =0
momentum pseudorapidity
phimin
float phimin
Definition: ReggeGribovPartonMCHadronizer.h:107
Matchers.h
ALCARECOPromptCalibProdSiPixelAli0T_cff.mode
mode
Definition: ALCARECOPromptCalibProdSiPixelAli0T_cff.py:96
reco::Candidate::pt
virtual double pt() const =0
transverse momentum
cms::cuda::assert
assert(be >=bs)
CandidateBenchmark
To plot Candidate quantities.
Definition: CandidateBenchmark.h:10
PFCandidateMonitor::phi_ref_
TH1F * phi_ref_
Definition: PFCandidateMonitor.h:73
MatchCandidateBenchmark::fillOne
void fillOne(const reco::Candidate &candidate, const reco::Candidate &matchedCandidate)
fill histograms with a given particle
Definition: MatchCandidateBenchmark.cc:228
PFCandidateMonitor::setParameters
void setParameters(float dRMax, bool matchCharge, Benchmark::Mode mode, float ptmin, float ptmax, float etamin, float etamax, float phimin, float phimax, bool refHistoFlag)
set the parameters locally
Definition: PFCandidateMonitor.cc:62
PFCandidateMonitor::fill
void fill(const T &candidateCollection, const C &matchedCandCollection, float &minVal, float &maxVal, const edm::ParameterSet &parameterSet)
fill histograms with all particle
Definition: PFCandidateMonitor.h:87
muonTiming_cfi.etamin
etamin
Definition: muonTiming_cfi.py:30
PFCandidateMonitor::candBench_
CandidateBenchmark candBench_
Definition: PFCandidateMonitor.h:64
edm::parameterSet
ParameterSet const & parameterSet(StableProvenance const &provenance, ProcessHistory const &history)
Definition: Provenance.cc:11
CandidateFwd.h
pfCandidateManager_cfi.matchCharge
matchCharge
Definition: pfCandidateManager_cfi.py:15
PFCandidateMonitor::dRMax_
float dRMax_
Definition: PFCandidateMonitor.h:76
PFCandidateMonitor::createReferenceHistos_
bool createReferenceHistos_
Definition: PFCandidateMonitor.h:78
PFCandidateMonitor::pt_ref_
TH1F * pt_ref_
Definition: PFCandidateMonitor.h:71
PVValHelper::eta
Definition: PVValidationHelpers.h:70
PFCandidateMonitor::histogramBooked_
bool histogramBooked_
Definition: PFCandidateMonitor.h:79
MatchCandidateBenchmark
To plot Candidate quantities.
Definition: MatchCandidateBenchmark.h:13
CandidateBenchmark.h
MatchCandidateBenchmark.h
b
double b
Definition: hdecay.h:118
PFCandidateMonitor::pt_gen_
TH1F * pt_gen_
Definition: PFCandidateMonitor.h:67
Benchmark.h
PFCandidateMonitor::matchCandBench_
MatchCandidateBenchmark matchCandBench_
Definition: PFCandidateMonitor.h:65
PFCandidateMonitor::setDirectory
void setDirectory(TDirectory *dir) override
set directory (to use in ROOT)
Definition: PFCandidateMonitor.cc:195
edm::ParameterSet
Definition: ParameterSet.h:47
Benchmark::Mode
Mode
Definition: Benchmark.h:32
PFCandidateMonitor::fillOne
void fillOne(const reco::Candidate &cand)
Definition: PFCandidateMonitor.cc:205
cand
Definition: decayParser.h:32
PFCandidateMonitor::setup
void setup(DQMStore::IBooker &b)
book histograms
Definition: PFCandidateMonitor.cc:164
CandidateBenchmark::fillOne
void fillOne(const reco::Candidate &candidate)
fill histograms with a given particle
Definition: CandidateBenchmark.cc:90
PFCandidateMonitor::phi_gen_
TH1F * phi_gen_
Definition: PFCandidateMonitor.h:69
PFCandidateMonitor::PFCandidateMonitor
PFCandidateMonitor(float dRMax=0.3, bool matchCharge=true, Benchmark::Mode mode=Benchmark::DEFAULT)
Definition: PFCandidateMonitor.cc:15
reco::Candidate
Definition: Candidate.h:27
phimax
float phimax
Definition: ReggeGribovPartonMCHadronizer.h:106
DDAxes::phi
metBenchmark_cfi.dRMax
dRMax
Definition: metBenchmark_cfi.py:18
muonTiming_cfi.ptmax
ptmax
Definition: muonTiming_cfi.py:22
gen::C
C
Definition: PomwigHadronizer.cc:78
T
long double T
Definition: Basic3DVectorLD.h:48
muonTiming_cfi.etamax
etamax
Definition: muonTiming_cfi.py:23
Benchmark::DEFAULT
Definition: Benchmark.h:32
PFCandidateMonitor::~PFCandidateMonitor
~PFCandidateMonitor() override
Definition: PFCandidateMonitor.cc:36
ptmin
double ptmin
Definition: HydjetWrapper.h:84
reco::deltaR
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
PFCandidateMonitor
Definition: PFCandidateMonitor.h:16
dqm::implementation::IBooker
Definition: DQMStore.h:43
PFCandidateMonitor::eta_gen_
TH1F * eta_gen_
Definition: PFCandidateMonitor.h:68
Candidate.h
ParameterSet.h
PFCandidateMonitor::matching_done_
bool matching_done_
Definition: PFCandidateMonitor.h:81
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
PFCandidateMonitor::eta_ref_
TH1F * eta_ref_
Definition: PFCandidateMonitor.h:72
reco::Candidate::phi
virtual double phi() const =0
momentum azimuthal angle
PFCandidateMonitor::deltaR_
TH1F * deltaR_
Definition: PFCandidateMonitor.h:75
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443