CMS 3D CMS Logo

L1TStage2uGTCaloLayer2Comp.cc
Go to the documentation of this file.
2 
4  : monitorDir(ps.getUntrackedParameter<std::string>("monitorDir", "")),
5  collection1Title(ps.getUntrackedParameter<std::string>("collection1Title")),
6  collection2Title(ps.getUntrackedParameter<std::string>("collection2Title")),
7  JetCollection1(consumes <l1t::JetBxCollection>(ps.getParameter<edm::InputTag>("JetCollection1"))),
8  JetCollection2(consumes <l1t::JetBxCollection>(ps.getParameter<edm::InputTag>("JetCollection2"))),
9  EGammaCollection1(consumes <l1t::EGammaBxCollection>(ps.getParameter<edm::InputTag>("EGammaCollection1"))),
10  EGammaCollection2(consumes <l1t::EGammaBxCollection>(ps.getParameter<edm::InputTag>("EGammaCollection2"))),
11  TauCollection1(consumes <l1t::TauBxCollection>(ps.getParameter<edm::InputTag>("TauCollection1"))),
12  TauCollection2(consumes <l1t::TauBxCollection>(ps.getParameter<edm::InputTag>("TauCollection2"))),
13  EtSumCollection1(consumes <l1t::EtSumBxCollection>(ps.getParameter<edm::InputTag>("EtSumCollection1"))),
14  EtSumCollection2(consumes <l1t::EtSumBxCollection>(ps.getParameter<edm::InputTag>("EtSumCollection2"))),
15  verbose(ps.getUntrackedParameter<bool> ("verbose", false))
16 {}
17 
19  DQMStore::IBooker &ibooker,
20  edm::Run const &,
21  edm::EventSetup const&) {
22 
24 
25  // the index of the first bin in histogram should match value of first enum
26  comparisonNum = ibooker.book1D(
27  "errorSummaryNum",
28  collection1Title+" vs "+collection2Title+" Comparison - Numerator (# Disagreements)", 15, 1, 16);
29 
30  comparisonNum->setBinLabel(EVENTBAD, "# bad evts");
31  comparisonNum->setBinLabel(EVENTBADJETCOL, "# evts w/ bad jet col size");
32  comparisonNum->setBinLabel(EVENTBADEGCOL, "# evts w/ bad eg col size");
33  comparisonNum->setBinLabel(EVENTBADTAUCOL, "# evts w/ bad tau col size");
34  comparisonNum->setBinLabel(EVENTBADSUMCOL, "# evts w/ bad sum col size");
35  comparisonNum->setBinLabel(JETBADET, "# jets bad Et");
36  comparisonNum->setBinLabel(JETBADPHI, "# jets bad phi");
37  comparisonNum->setBinLabel(JETBADETA, "# jets bad eta");
38  comparisonNum->setBinLabel(EGBADET, "# egs bad Et");
39  comparisonNum->setBinLabel(EGBADPHI, "# egs bad phi");
40  comparisonNum->setBinLabel(EGBADETA, "# egs bad eta");
41  comparisonNum->setBinLabel(TAUBADET, "# taus bad Et");
42  comparisonNum->setBinLabel(TAUBADPHI, "# taus bad phi");
43  comparisonNum->setBinLabel(TAUBADETA, "# taus bad eta");
44  comparisonNum->setBinLabel(BADSUM, "# bad sums");
45 
46  comparisonDenum = ibooker.book1D(
47  "errorSummaryDen",
48  collection1Title+" vs "+collection2Title+" Comparison - Denominator (# Objects)", 15, 1, 16);
49 
55  comparisonDenum->setBinLabel(JETS1, "# jets");
56  comparisonDenum->setBinLabel(JETS2, "# jets");
57  comparisonDenum->setBinLabel(JETS3, "# jets");
58  comparisonDenum->setBinLabel(EGS1, "# egs");
59  comparisonDenum->setBinLabel(EGS2, "# egs");
60  comparisonDenum->setBinLabel(EGS3, "# egs");
61  comparisonDenum->setBinLabel(TAUS1, "# taus");
62  comparisonDenum->setBinLabel(TAUS2, "# taus");
63  comparisonDenum->setBinLabel(TAUS3, "# taus");
64  comparisonDenum->setBinLabel(SUMS, "# sums");
65  // Setting canExtend to false is needed to get the correct behaviour when running multithreaded.
66  // Otherwise, when merging the histgrams of the threads, TH1::Merge sums bins that have the same label in one bin.
67  // This needs to come after the calls to setBinLabel.
68  comparisonDenum->getTH1F()->GetXaxis()->SetCanExtend(false);
69 }
71  const edm::Event& e,
72  const edm::EventSetup & c) {
73 
74  // define collections to hold lists of objects in event
83 
84  // map event contents to above collections
85  e.getByToken(JetCollection1, jetCol1);
86  e.getByToken(JetCollection2, jetCol2);
87  e.getByToken(EGammaCollection1, egCol1);
88  e.getByToken(EGammaCollection2, egCol2);
89  e.getByToken(TauCollection1, tauCol1);
90  e.getByToken(TauCollection2, tauCol2);
91  e.getByToken(EtSumCollection1, sumCol1);
92  e.getByToken(EtSumCollection2, sumCol2);
93 
94  bool eventGood = true;
95 
96  if (!compareJets(jetCol1, jetCol2)) {
97  eventGood = false;
98  }
99 
100  if (!compareEGs(egCol1, egCol2)) {
101  eventGood = false;
102  }
103 
104  if (!compareTaus(tauCol1, tauCol2)) {
105  eventGood = false;
106  }
107 
108  if (!compareSums(sumCol1, sumCol2)) {
109  eventGood = false;
110  }
111 
112  if (!eventGood) {
114  }
115 
121 }
122 
123 // comparison method for jets
127 {
128  bool eventGood = true;
129 
132 
133  // process jets
134  if (col1->size() != col2->size()) {
136  return false;
137  }
138 
139  int nJets = 0;
140  if (col1It != col1->end() ||
141  col2It != col2->end()) {
142  while(true) {
143 
144  ++nJets;
145 
146  // object pt mismatch
147  if (col1It->hwPt() != col2It->hwPt()) {
149  eventGood = false;
150  }
151 
152  // object position mismatch (phi)
153  if (col1It->hwPhi() != col2It->hwPhi()){
155  eventGood = false;
156  }
157 
158  // object position mismatch (eta)
159  if (col1It->hwEta() != col2It->hwEta()) {
161  eventGood = false;
162  }
163 
164  // keep track of jets
168 
169  // increment position of pointers
170  ++col1It;
171  ++col2It;
172 
173  if (col1It == col1->end() ||
174  col2It == col2->end())
175  break;
176  }
177  } else {
178  if (col1->size() != 0 || col2->size() != 0) {
180  return false;
181  }
182  }
183 
184  // return a boolean that states whether the jet data in the event is in
185  // agreement
186  return eventGood;
187 }
188 
189 // comparison method for e/gammas
193 {
194  bool eventGood = true;
195 
198 
199  // check length of collections
200  if (col1->size() != col2->size()) {
202  return false;
203  }
204 
205  // processing continues only of length of object collections is the same
206  if (col1It != col1->end() ||
207  col2It != col2->end()) {
208 
209  while(true) {
210 
211  // object pt mismatch
212  if (col1It->hwPt() != col2It->hwPt()) {
214  eventGood = false;
215  }
216 
217  // object position mismatch (phi)
218  if (col1It->hwPhi() != col2It->hwPhi()) {
220  eventGood = false;
221  }
222 
223  // object position mismatch (eta)
224  if (col1It->hwEta() != col2It->hwEta()) {
226  eventGood = false;
227  }
228 
229  // keep track of number of objects
233 
234  // increment position of pointers
235  ++col1It;
236  ++col2It;
237 
238  if (col1It == col1->end() ||
239  col2It == col2->end())
240  break;
241  }
242  } else {
243  if (col1->size() != 0 || col2->size() != 0) {
245  return false;
246  }
247  }
248 
249  // return a boolean that states whether the eg data in the event is in
250  // agreement
251  return eventGood;
252 }
253 
254 // comparison method for taus
258 {
259  bool eventGood = true;
260 
263 
264  // check length of collections
265  if (col1->size() != col2->size()) {
267  return false;
268  }
269 
270  // processing continues only of length of object collections is the same
271  if (col1It != col1->end() ||
272  col2It != col2->end()) {
273 
274  while(true) {
275  // object Et mismatch
276  if (col1It->hwPt() != col2It->hwPt()) {
278  eventGood = false;
279  }
280 
281  // object position mismatch (phi)
282  if (col1It->hwPhi() != col2It->hwPhi()) {
284  eventGood = false;
285  }
286 
287  // object position mismatch (eta)
288  if (col1It->hwEta() != col2It->hwEta()) {
290  eventGood = false;
291  }
292 
293  // keep track of number of objects
297 
298  // increment position of pointers
299  ++col1It;
300  ++col2It;
301 
302  if (col1It == col1->end() ||
303  col2It == col2->end())
304  break;
305  }
306  } else {
307  if (col1->size() != 0 || col2->size() != 0) {
309  return false;
310  }
311  }
312 
313  // return a boolean that states whether the tau data in the event is in
314  // agreement
315  return eventGood;
316 }
317 
318 // comparison method for sums
322 {
323  bool eventGood = true;
324 
325  double col1Et = 0;
326  double col2Et = 0;
327  double col1Phi = 0;
328  double col2Phi = 0;
329 
330  // if the calol2 or ugt collections have different size, mark the event as
331  // bad (this should never occur in normal running)
332  if (col1->size() != col2->size()) {
334  return false;
335  }
336 
339 
340  while (col1It != col1->end() && col2It != col2->end()) {
341 
342  // ETT, ETTEM, HTT, TowCnt, MBHFP0, MBHFM0, MBHFP1 or MBHFM1
343  if ((l1t::EtSum::EtSumType::kTotalEt == col1It->getType()) || // ETT
344  (l1t::EtSum::EtSumType::kTotalEtEm == col1It->getType()) || // ETTEM
345  (l1t::EtSum::EtSumType::kTotalHt == col1It->getType()) || // HTT
346  (l1t::EtSum::EtSumType::kTowerCount == col1It->getType()) || // TowCnt
347  (l1t::EtSum::EtSumType::kMinBiasHFP0 == col1It->getType()) ||// MBHFP0
348  (l1t::EtSum::EtSumType::kMinBiasHFM0 == col1It->getType()) ||// MBHFM0
349  (l1t::EtSum::EtSumType::kMinBiasHFP1 == col1It->getType()) ||// MBHFP1
350  (l1t::EtSum::EtSumType::kMinBiasHFM1 == col1It->getType())) {// MBHFM1
351 
352  col1Et = col1It->hwPt();
353  col2Et = col2It->hwPt();
354 
355  if (col1Et != col2Et) {
356  eventGood = false;
358  }
359 
360  // update sum counters
362  }
363 
364  // MET, METHF, MHT or MHTHF
365  if ((l1t::EtSum::EtSumType::kMissingEt == col1It->getType()) || // MET
366  (l1t::EtSum::EtSumType::kMissingEtHF == col1It->getType()) || // METHF
367  (l1t::EtSum::EtSumType::kMissingHt == col1It->getType()) || // MHT
368  (l1t::EtSum::EtSumType::kMissingHtHF == col1It->getType())) { // MHTHF
369 
370  col1Et = col1It->hwPt();
371  col2Et = col2It->hwPt();
372 
373  col1Phi = col1It->hwPhi();
374  col2Phi = col2It->hwPhi();
375 
376  if ((col1Et != col2Et) || (col1Phi != col2Phi)) {
377  eventGood = false;
379  }
380 
381  // update sum counters
383  }
384 
385  ++col1It;
386  ++col2It;
387  }
388 
389  // return a boolean that states whether the sum data in the event is in
390  // agreement
391  return eventGood;
392 }
393 
394 
BXVector< EGamma > EGammaBxCollection
Definition: EGamma.h:11
const_iterator end(int bx) const
bool compareTaus(const edm::Handle< l1t::TauBxCollection > &col1, const edm::Handle< l1t::TauBxCollection > &col2)
unsigned size(int bx) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
TH1F * getTH1F() const
edm::EDGetTokenT< l1t::EtSumBxCollection > EtSumCollection1
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
edm::EDGetTokenT< l1t::EGammaBxCollection > EGammaCollection1
delete x;
Definition: CaloConfig.h:22
BXVector< Tau > TauBxCollection
Definition: Tau.h:11
void Fill(long long x)
bool compareSums(const edm::Handle< l1t::EtSumBxCollection > &col1, const edm::Handle< l1t::EtSumBxCollection > &col2)
edm::EDGetTokenT< l1t::TauBxCollection > TauCollection1
BXVector< EtSum > EtSumBxCollection
Definition: EtSum.h:11
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
edm::EDGetTokenT< l1t::TauBxCollection > TauCollection2
edm::EDGetTokenT< l1t::JetBxCollection > JetCollection2
BXVector< Jet > JetBxCollection
Definition: Jet.h:11
bool compareJets(const edm::Handle< l1t::JetBxCollection > &col1, const edm::Handle< l1t::JetBxCollection > &col2)
void bookHistograms(DQMStore::IBooker &, const edm::Run &, const edm::EventSetup &) override
edm::EDGetTokenT< l1t::EGammaBxCollection > EGammaCollection2
HLT enums.
edm::EDGetTokenT< l1t::EtSumBxCollection > EtSumCollection2
L1TStage2uGTCaloLayer2Comp(const edm::ParameterSet &ps)
edm::EDGetTokenT< l1t::JetBxCollection > JetCollection1
void analyze(const edm::Event &, const edm::EventSetup &) override
bool compareEGs(const edm::Handle< l1t::EGammaBxCollection > &col1, const edm::Handle< l1t::EGammaBxCollection > &col2)
const_iterator begin(int bx) const
Definition: Run.h:45
std::vector< T >::const_iterator const_iterator
Definition: BXVector.h:20