CMS 3D CMS Logo

TtSemiLRJetCombObservables.cc
Go to the documentation of this file.
1 //
2 // Author: Jan Heyninck
3 // Created: Tue Apr 3 17:33:23 PDT 2007
4 //
5 //
12 
13 // constructor with path; default should not be used
15  const edm::EDGetTokenT<std::vector<pat::Jet> > &jetSourceToken)
16  : jetSourceToken_(jetSourceToken), genEvtToken_(iC.consumes<TtGenEvent>(edm::InputTag("genEvt"))) {}
17 
18 // destructor
20 
21 std::vector<TtSemiLRJetCombObservables::IntBoolPair> TtSemiLRJetCombObservables::operator()(TtSemiEvtSolution &solution,
22  const edm::Event &iEvent,
23  bool matchOnly) {
24  bool debug = false;
25 
26  evtselectVarVal.clear();
27  evtselectVarMatch.clear();
28 
29  // Check whether the objects are matched:
30  // bool matchHadt = false; //commented out since gcc461 complained that this variable was set but unused
31  // bool matchLept = false; //commented out since gcc461 complained that this variable was set but unused
32  // bool matchHadW = false; //commented out since gcc461 complained that this variable was set but unused
33  // bool matchLepW = false; //commented out since gcc461 complained that this variable was set but unused
34  bool matchHadb = false;
35  bool matchLepb = false;
36  bool matchHadp = false;
37  bool matchHadq = false;
38  bool matchHadpq = false;
39  bool matchHadqp = false;
40  bool matchLepl = false;
41  bool matchLepn = false;
42 
43  if (debug)
44  std::cout << "== start matching the objects " << std::endl;
45 
46  double drLepl = 0, drLepn = 0, drHadb = 0, drLepb = 0, drHadp = 0, drHadq = 0, drHadpq = 0,
47  drHadqp = 0; // drHadt=0, drLept=0, drLepW=0, drHadW=0;
48 
50  iEvent.getByToken(genEvtToken_, genEvent);
51 
52  if (genEvent.failedToGet()) {
53  if (debug)
54  std::cout << "== not found genEvent " << std::endl;
55  } else if (genEvent.isValid()) {
56  if (debug)
57  std::cout << "== found genEvent " << std::endl;
58 
59  if (genEvent->isSemiLeptonic() && genEvent->numberOfBQuarks() == 2) {
60  //if(debug) std::cout << "== genEvent->quarkFromAntiTop() " << genEvent->quarkFromAntiTop()->pt() << std::endl;
61  if (debug)
62  std::cout << "== genEvent->isSemiLeptonic() && genEvent->numberOfBQuarks() == 2 " << std::endl;
63  if (debug)
64  std::cout << "== solution.getDecay() == " << solution.getDecay() << std::endl;
65  if (debug)
66  std::cout << "== solution.getRecLepm().pt() = " << solution.getRecLepm().pt() << std::endl;
67  //if(debug) if(solution.getGenLepl() == 0) std::cout << "solution.getGenLepl() == NULL" << std::endl;
68  if (debug)
69  std::cout << "== *(solution.getGenLept())" << solution.getGenLept()->pt() << std::endl;
70  if (debug)
71  std::cout << "== *(solution.getGenLepl())" << solution.getGenLepl()->pt() << std::endl;
72  // std::cout << "Semilepton:\n";
73  // Match the lepton by deltaR
74  if (solution.getDecay() == "muon")
75  drLepl = DeltaR<pat::Particle, reco::GenParticle>()(solution.getRecLepm(), *(solution.getGenLepl()));
76  if (debug)
77  std::cout << "== matching lepton " << std::endl;
78  if (solution.getDecay() == "electron")
79  drLepl = DeltaR<pat::Particle, reco::GenParticle>()(solution.getRecLepe(), *(solution.getGenLepl()));
80  matchLepl = (drLepl < 0.3);
81 
82  if (debug)
83  std::cout << "== lepton is matched " << std::endl;
84  // Match the neutrino by deltaR
85  drLepn = DeltaR<pat::Particle, reco::GenParticle>()(solution.getRecLepn(), *(solution.getGenLepn()));
86  matchLepn = (drLepn < 0.3);
87 
88  // Match the hadronic b by deltaR
89  drHadb = DeltaR<pat::Jet, reco::GenParticle>()(solution.getRecHadb(), *(solution.getGenHadb()));
90  matchHadb = (drHadb < 0.3);
91 
92  // Match the hadronicleptonic b by deltaR
93  drLepb = DeltaR<pat::Jet, reco::GenParticle>()(solution.getRecLepb(), *(solution.getGenLepb()));
94  matchLepb = (drLepb < 0.3);
95 
96  // Match the hadronic p by deltaR
97  drHadp = DeltaR<pat::Jet, reco::GenParticle>()(solution.getRecHadp(), *(solution.getGenHadp()));
98  matchHadp = (drHadp < 0.3);
99 
100  // Match the hadronic pq by deltaR
101  drHadpq = DeltaR<pat::Jet, reco::GenParticle>()(solution.getRecHadp(), *(solution.getGenHadq()));
102  matchHadpq = (drHadpq < 0.3);
103 
104  // Match the hadronic q by deltaR
105  drHadq = DeltaR<pat::Jet, reco::GenParticle>()(solution.getRecHadq(), *(solution.getGenHadq()));
106  matchHadq = (drHadq < 0.3);
107 
108  // Match the hadronic qp by deltaR
109  drHadqp = DeltaR<pat::Jet, reco::GenParticle>()(solution.getRecHadq(), *(solution.getGenHadp()));
110  matchHadqp = (drHadqp < 0.3);
111 
112  //commented out since gcc461 complained that these variables were set but unused!
113  /*
114  // Match the hadronic W by deltaR
115  drHadW = DeltaR<reco::Particle, reco::GenParticle>()(solution.getRecHadW(), *(solution.getGenHadW()));
116  matchHadW = (drHadW < 0.3);
117 
118  // Match the leptonic W by deltaR
119  drLepW = DeltaR<reco::Particle, reco::GenParticle>()(solution.getRecLepW(), *(solution.getGenLepW()));
120  matchLepW = (drLepW < 0.3);
121 
122  // Match the hadronic t by deltaR
123  drHadt = DeltaR<reco::Particle, reco::GenParticle>()(solution.getRecHadt(), *(solution.getGenHadt()));
124  matchHadt = (drHadt < 0.3);
125 
126  // Match the leptonic t by deltaR
127  drLept = DeltaR<reco::Particle, reco::GenParticle>()(solution.getRecLept(), *(solution.getGenLept()));
128  matchLept = (drLept < 0.3);
129  */
130  }
131  } else {
132  if (debug)
133  std::cout << "== nothing " << std::endl;
134  }
135 
136  if (debug)
137  std::cout << "== objects matched" << std::endl;
138 
140  iEvent.getByToken(jetSourceToken_, jets);
141 
142  if (debug)
143  std::cout << "== start calculating observables" << std::endl;
144 
145  //obs1 : pt(had top)
146  double AverageTop = ((solution.getHadb().p4() + solution.getHadq().p4() + solution.getHadp().p4()).pt() +
147  (solution.getLepb().p4() + solution.getHadq().p4() + solution.getHadp().p4()).pt() +
148  (solution.getHadb().p4() + solution.getLepb().p4() + solution.getHadp().p4()).pt() +
149  (solution.getHadb().p4() + solution.getHadq().p4() + solution.getLepb().p4()).pt()) /
150  4.;
151  double Obs1 = ((solution.getHadb().p4() + solution.getHadq().p4() + solution.getHadp().p4()).pt()) / AverageTop;
152  evtselectVarVal.push_back(IntDblPair(1, Obs1));
153  evtselectVarMatch.push_back(IntBoolPair(1, ((matchHadq && matchHadp) || (matchHadpq && matchHadqp)) && matchHadb));
154 
155  if (debug)
156  std::cout << "== observable 1 " << Obs1 << std::endl;
157 
158  //obs2 : (pt_b1 + pt_b2)/(sum jetpt)
159  double Obs2 =
160  (solution.getHadb().pt() + solution.getLepb().pt()) / (solution.getHadp().pt() + solution.getHadq().pt());
161  evtselectVarVal.push_back(IntDblPair(2, Obs2));
162  evtselectVarMatch.push_back(
163  IntBoolPair(2, ((matchHadp && matchHadq) || (matchHadpq && matchHadqp)) && matchHadb && matchLepb));
164 
165  if (debug)
166  std::cout << "== observable 2 " << Obs2 << std::endl;
167 
168  //obs3: delta R between lep b and lepton
169  double Obs3 = -999;
170  if (solution.getDecay() == "muon")
171  Obs3 = ROOT::Math::VectorUtil::DeltaR(solution.getLepb().p4(), solution.getRecLepm().p4());
172  if (solution.getDecay() == "electron")
173  Obs3 = ROOT::Math::VectorUtil::DeltaR(solution.getLepb().p4(), solution.getRecLepe().p4());
174  evtselectVarVal.push_back(IntDblPair(3, Obs3));
175  evtselectVarMatch.push_back(IntBoolPair(3, matchLepb && matchLepl));
176 
177  if (debug)
178  std::cout << "== observable 3 " << Obs3 << std::endl;
179 
180  //obs4 : del R ( had b, had W)
181  double Obs4 =
182  ROOT::Math::VectorUtil::DeltaR(solution.getHadb().p4(), solution.getHadq().p4() + solution.getHadp().p4());
183  evtselectVarVal.push_back(IntDblPair(4, Obs4));
184  evtselectVarMatch.push_back(IntBoolPair(4, matchHadb && ((matchHadp && matchHadp) || (matchHadpq && matchHadqp))));
185 
186  if (debug)
187  std::cout << "== observable 4 " << Obs4 << std::endl;
188 
189  //obs5 : del R between light quarkssolution.getHadp().phi(
190  double Obs5 = ROOT::Math::VectorUtil::DeltaR(solution.getHadq().p4(), solution.getHadp().p4());
191  evtselectVarVal.push_back(IntDblPair(5, Obs5));
192  evtselectVarMatch.push_back(IntBoolPair(5, (matchHadp && matchHadq) || (matchHadpq && matchHadqp)));
193 
194  if (debug)
195  std::cout << "== observable 5 " << Obs5 << std::endl;
196 
197  //obs6 : b-tagging information
198  double Obs6 = 0;
199  if (fabs(solution.getHadb().bDiscriminator("trackCountingJetTags") + 10) < 0.0001 ||
200  fabs(solution.getLepb().bDiscriminator("trackCountingJetTags") + 10) < 0.0001) {
201  Obs6 = -10.;
202  } else {
203  Obs6 = (solution.getHadb().bDiscriminator("trackCountingJetTags") +
204  solution.getLepb().bDiscriminator("trackCountingJetTags"));
205  }
206  evtselectVarVal.push_back(IntDblPair(6, Obs6));
207  evtselectVarMatch.push_back(IntBoolPair(6, 1));
208 
209  if (debug)
210  std::cout << "== observable 6 " << Obs6 << std::endl;
211 
212  //obs7 : chi2 value of kinematical fit with W-mass constraint
213  double Obs7 = 0;
214  if (solution.getProbChi2() < 0) {
215  Obs7 = -0;
216  } else {
217  Obs7 = log10(solution.getProbChi2() + .00001);
218  }
219  evtselectVarVal.push_back(IntDblPair(7, Obs7));
220  evtselectVarMatch.push_back(IntBoolPair(7, ((matchHadp && matchHadq) || (matchHadpq && matchHadqp))));
221 
222  if (debug)
223  std::cout << "== observable 7 " << Obs7 << std::endl;
224 
225  //obs8(=7+1)
226  double Obs8 = solution.getCalHadt().p4().pt();
227  evtselectVarVal.push_back(IntDblPair(8, Obs8));
228  evtselectVarMatch.push_back(IntBoolPair(8, matchHadb && ((matchHadp && matchHadq) || (matchHadpq && matchHadqp))));
229 
230  if (debug)
231  std::cout << "== observable 8 " << Obs8 << std::endl;
232 
233  //obs9
234  double Obs9 = fabs(solution.getCalHadt().p4().eta());
235  evtselectVarVal.push_back(IntDblPair(9, Obs9));
236  evtselectVarMatch.push_back(IntBoolPair(9, matchHadb && ((matchHadp && matchHadq) || (matchHadpq && matchHadqp))));
237 
238  if (debug)
239  std::cout << "== observable 9 " << Obs9 << std::endl;
240 
241  //obs10
242  double Obs10 = solution.getCalHadt().p4().theta();
243  evtselectVarVal.push_back(IntDblPair(10, Obs10));
244  evtselectVarMatch.push_back(IntBoolPair(10, matchHadb && ((matchHadp && matchHadq) || (matchHadpq && matchHadqp))));
245 
246  if (debug)
247  std::cout << "== observable 10 " << Obs10 << std::endl;
248 
249  //obs11
250  double Obs11 = solution.getCalHadW().p4().pt();
251  evtselectVarVal.push_back(IntDblPair(11, Obs11));
252  evtselectVarMatch.push_back(IntBoolPair(11, (matchHadp && matchHadq) || (matchHadpq && matchHadqp)));
253 
254  if (debug)
255  std::cout << "== observable 11 " << Obs11 << std::endl;
256 
257  //obs12
258  double Obs12 = fabs(solution.getCalHadW().p4().eta());
259  evtselectVarVal.push_back(IntDblPair(12, Obs12));
260  evtselectVarMatch.push_back(IntBoolPair(12, (matchHadp && matchHadq) || (matchHadpq && matchHadqp)));
261 
262  if (debug)
263  std::cout << "== observable 12 " << Obs12 << std::endl;
264 
265  //obs13
266  double Obs13 = solution.getCalHadW().p4().theta();
267  evtselectVarVal.push_back(IntDblPair(13, Obs13));
268  evtselectVarMatch.push_back(IntBoolPair(13, (matchHadp && matchHadq) || (matchHadpq && matchHadqp)));
269 
270  if (debug)
271  std::cout << "== observable 13 " << Obs13 << std::endl;
272 
273  //obs14
274  double Obs14 = solution.getCalHadb().p4().pt();
275  evtselectVarVal.push_back(IntDblPair(14, Obs14));
276  evtselectVarMatch.push_back(IntBoolPair(14, matchHadb));
277 
278  if (debug)
279  std::cout << "== observable 14 " << Obs14 << std::endl;
280 
281  //obs15
282  double Obs15 = fabs(solution.getCalHadb().p4().eta());
283  evtselectVarVal.push_back(IntDblPair(15, Obs15));
284  evtselectVarMatch.push_back(IntBoolPair(15, matchHadb));
285 
286  if (debug)
287  std::cout << "== observable 15 " << Obs15 << std::endl;
288 
289  //obs16
290  double Obs16 = solution.getCalHadb().p4().theta();
291  evtselectVarVal.push_back(IntDblPair(16, Obs16));
292  evtselectVarMatch.push_back(IntBoolPair(16, matchHadb));
293 
294  if (debug)
295  std::cout << "== observable 16 " << Obs16 << std::endl;
296 
297  //obs17
298  double Obs17 = solution.getCalHadp().p4().pt();
299  evtselectVarVal.push_back(IntDblPair(17, Obs17));
300  evtselectVarMatch.push_back(IntBoolPair(17, matchHadp));
301 
302  if (debug)
303  std::cout << "== observable 17 " << Obs17 << std::endl;
304 
305  //obs18
306  double Obs18 = fabs(solution.getCalHadp().p4().eta());
307  evtselectVarVal.push_back(IntDblPair(18, Obs18));
308  evtselectVarMatch.push_back(IntBoolPair(18, matchHadp));
309 
310  if (debug)
311  std::cout << "== observable 18 " << Obs18 << std::endl;
312 
313  //obs19
314  double Obs19 = solution.getCalHadp().p4().theta();
315  evtselectVarVal.push_back(IntDblPair(19, Obs19));
316  evtselectVarMatch.push_back(IntBoolPair(19, matchHadp));
317 
318  if (debug)
319  std::cout << "== observable 19 " << Obs19 << std::endl;
320 
321  //obs20
322  double Obs20 = solution.getCalHadq().p4().pt();
323  evtselectVarVal.push_back(IntDblPair(20, Obs20));
324  evtselectVarMatch.push_back(IntBoolPair(20, matchHadq));
325 
326  if (debug)
327  std::cout << "== observable 20 " << Obs20 << std::endl;
328 
329  //obs21
330  double Obs21 = fabs(solution.getCalHadq().p4().eta());
331  evtselectVarVal.push_back(IntDblPair(21, Obs21));
332  evtselectVarMatch.push_back(IntBoolPair(21, matchHadq));
333 
334  if (debug)
335  std::cout << "== observable 21 " << Obs21 << std::endl;
336 
337  //obs22
338  double Obs22 = solution.getCalHadq().p4().theta();
339  evtselectVarVal.push_back(IntDblPair(22, Obs22));
340  evtselectVarMatch.push_back(IntBoolPair(22, matchHadq));
341 
342  if (debug)
343  std::cout << "== observable 22 " << Obs22 << std::endl;
344 
345  //obs23
346  double Obs23 = solution.getCalLept().p4().pt();
347  evtselectVarVal.push_back(IntDblPair(23, Obs23));
348  evtselectVarMatch.push_back(IntBoolPair(23, matchLepl && matchLepn && matchLepb));
349 
350  if (debug)
351  std::cout << "== observable 23 " << Obs23 << std::endl;
352 
353  //obs24
354  double Obs24 = fabs(solution.getCalLept().p4().eta());
355  evtselectVarVal.push_back(IntDblPair(24, Obs24));
356  evtselectVarMatch.push_back(IntBoolPair(24, matchLepl && matchLepn && matchLepb));
357 
358  if (debug)
359  std::cout << "== observable 24 " << Obs24 << std::endl;
360 
361  //obs25
362  double Obs25 = solution.getCalLept().p4().theta();
363  evtselectVarVal.push_back(IntDblPair(25, Obs25));
364  evtselectVarMatch.push_back(IntBoolPair(25, matchLepl && matchLepn && matchLepb));
365 
366  if (debug)
367  std::cout << "== observable 25 " << Obs25 << std::endl;
368 
369  //obs26
370  double Obs26 = solution.getRecLepW().p4().pt();
371  evtselectVarVal.push_back(IntDblPair(26, Obs26));
372  evtselectVarMatch.push_back(IntBoolPair(26, matchLepl && matchLepn));
373 
374  if (debug)
375  std::cout << "== observable 26 " << Obs26 << std::endl;
376 
377  //obs27
378  double Obs27 = fabs(solution.getRecLepW().p4().eta());
379  evtselectVarVal.push_back(IntDblPair(27, Obs27));
380  evtselectVarMatch.push_back(IntBoolPair(27, matchLepl && matchLepn));
381 
382  if (debug)
383  std::cout << "== observable 27 " << Obs27 << std::endl;
384 
385  //obs28
386  double Obs28 = solution.getRecLepW().p4().theta();
387  evtselectVarVal.push_back(IntDblPair(28, Obs28));
388  evtselectVarMatch.push_back(IntBoolPair(28, matchLepl && matchLepn));
389 
390  if (debug)
391  std::cout << "== observable 28 " << Obs28 << std::endl;
392 
393  //obs29
394  double Obs29 = solution.getCalLepb().p4().pt();
395  evtselectVarVal.push_back(IntDblPair(29, Obs29));
396  evtselectVarMatch.push_back(IntBoolPair(29, matchLepb));
397 
398  if (debug)
399  std::cout << "== observable 29 " << Obs29 << std::endl;
400 
401  //obs30
402  double Obs30 = fabs(solution.getCalLepb().p4().eta());
403  evtselectVarVal.push_back(IntDblPair(30, Obs30));
404  evtselectVarMatch.push_back(IntBoolPair(30, matchLepb));
405 
406  if (debug)
407  std::cout << "== observable 30 " << Obs30 << std::endl;
408 
409  //obs31
410  double Obs31 = solution.getCalLepb().p4().theta();
411  evtselectVarVal.push_back(IntDblPair(31, Obs31));
412  evtselectVarMatch.push_back(IntBoolPair(31, matchLepb));
413 
414  if (debug)
415  std::cout << "== observable 31 " << Obs31 << std::endl;
416 
417  //obs32
418  double Obs32 = -999.;
419  if (solution.getDecay() == "muon")
420  Obs32 = solution.getRecLepm().p4().pt();
421  if (solution.getDecay() == "electron")
422  Obs32 = solution.getRecLepe().p4().pt();
423  evtselectVarVal.push_back(IntDblPair(32, Obs32));
424  evtselectVarMatch.push_back(IntBoolPair(32, matchLepl));
425 
426  if (debug)
427  std::cout << "== observable 32 " << Obs32 << std::endl;
428 
429  //obs33
430  double Obs33 = -999.;
431  if (solution.getDecay() == "muon")
432  Obs33 = fabs(solution.getRecLepm().p4().eta());
433  if (solution.getDecay() == "electron")
434  Obs33 = fabs(solution.getRecLepe().p4().eta());
435  evtselectVarVal.push_back(IntDblPair(33, Obs33));
436  evtselectVarMatch.push_back(IntBoolPair(33, matchLepl));
437 
438  if (debug)
439  std::cout << "== observable 33 " << Obs33 << std::endl;
440 
441  //obs34
442  double Obs34 = -999.;
443  if (solution.getDecay() == "muon")
444  Obs34 = fabs(solution.getRecLepm().p4().theta());
445  if (solution.getDecay() == "electron")
446  Obs34 = fabs(solution.getRecLepe().p4().theta());
447  evtselectVarVal.push_back(IntDblPair(34, Obs34));
448  evtselectVarMatch.push_back(IntBoolPair(34, matchLepl));
449 
450  if (debug)
451  std::cout << "== observable 34 " << Obs34 << std::endl;
452 
453  //obs35
454  double Obs35 = solution.getFitLepn().p4().pt();
455  evtselectVarVal.push_back(IntDblPair(35, Obs35));
456  evtselectVarMatch.push_back(IntBoolPair(35, matchLepn));
457 
458  if (debug)
459  std::cout << "== observable 35 " << Obs35 << std::endl;
460 
461  //obs36
462  double Obs36 = fabs(solution.getFitLepn().p4().eta());
463  evtselectVarVal.push_back(IntDblPair(36, Obs36));
464  evtselectVarMatch.push_back(IntBoolPair(36, matchLepn));
465 
466  if (debug)
467  std::cout << "== observable 36 " << Obs36 << std::endl;
468 
469  //obs37
470  double Obs37 = solution.getFitLepn().p4().theta();
471  evtselectVarVal.push_back(IntDblPair(37, Obs37));
472  evtselectVarMatch.push_back(IntBoolPair(37, matchLepn));
473 
474  if (debug)
475  std::cout << "== observable 37 " << Obs37 << std::endl;
476 
477  // 2 particle kinematics
478  //obs38
479  double Obs38 = fabs(solution.getCalHadW().p4().phi() - solution.getRecLepW().p4().phi());
480  if (Obs38 > 3.1415927)
481  Obs38 = 2 * 3.1415927 - Obs31;
482  if (Obs38 < -3.1415927)
483  Obs38 = -2 * 3.1415927 - Obs31;
484  evtselectVarVal.push_back(IntDblPair(38, Obs38));
485  evtselectVarMatch.push_back(
486  IntBoolPair(38, matchLepl && matchLepn && ((matchHadp && matchHadq) || (matchHadpq && matchHadqp))));
487 
488  if (debug)
489  std::cout << "== observable 38 " << Obs38 << std::endl;
490 
491  //obs39
492  double Obs39 = fabs(solution.getCalHadW().p4().eta() - solution.getRecLepW().p4().eta());
493  evtselectVarVal.push_back(IntDblPair(39, Obs39));
494  evtselectVarMatch.push_back(
495  IntBoolPair(39, matchLepl && matchLepn && ((matchHadp && matchHadq) || (matchHadpq && matchHadqp))));
496 
497  if (debug)
498  std::cout << "== observable 39 " << Obs39 << std::endl;
499 
500  //obs40
501  double Obs40 = fabs(solution.getCalHadW().p4().theta() - solution.getRecLepW().p4().theta());
502  evtselectVarVal.push_back(IntDblPair(40, Obs40));
503  evtselectVarMatch.push_back(
504  IntBoolPair(40, matchLepl && matchLepn && ((matchHadp && matchHadq) || (matchHadpq && matchHadqp))));
505 
506  if (debug)
507  std::cout << "== observable 40 " << Obs40 << std::endl;
508 
509  //obs41
510  double Obs41 = ROOT::Math::VectorUtil::DeltaR(solution.getCalHadW().p4(), solution.getRecLepW().p4());
511  evtselectVarVal.push_back(IntDblPair(41, Obs41));
512  evtselectVarMatch.push_back(
513  IntBoolPair(41, matchLepl && matchLepn && ((matchHadp && matchHadq) || (matchHadpq && matchHadqp))));
514 
515  if (debug)
516  std::cout << "== observable 41 " << Obs41 << std::endl;
517 
518  //obs42
519  double Obs42 = fabs(solution.getCalHadb().p4().phi() - solution.getCalLepb().p4().phi());
520  if (Obs42 > 3.1415927)
521  Obs42 = 2 * 3.1415927 - Obs42;
522  if (Obs42 < -3.1415927)
523  Obs42 = -2 * 3.1415927 - Obs42;
524  evtselectVarVal.push_back(IntDblPair(42, Obs42));
525  evtselectVarMatch.push_back(IntBoolPair(42, matchHadb && matchLepb));
526 
527  if (debug)
528  std::cout << "== observable 42 " << Obs42 << std::endl;
529 
530  //obs43
531  double Obs43 = fabs(solution.getCalHadb().p4().eta() - solution.getCalLepb().p4().eta());
532  evtselectVarVal.push_back(IntDblPair(43, Obs43));
533  evtselectVarMatch.push_back(IntBoolPair(43, matchHadb && matchLepb));
534 
535  if (debug)
536  std::cout << "== observable 43 " << Obs43 << std::endl;
537 
538  //obs44
539  double Obs44 = fabs(solution.getCalHadb().p4().theta() - solution.getCalLepb().p4().theta());
540  evtselectVarVal.push_back(IntDblPair(44, Obs44));
541  evtselectVarMatch.push_back(IntBoolPair(44, matchHadb && matchLepb));
542 
543  if (debug)
544  std::cout << "== observable 44 " << Obs44 << std::endl;
545 
546  //obs45
547  double Obs45 = ROOT::Math::VectorUtil::DeltaR(solution.getCalHadb().p4(), solution.getCalLepb().p4());
548  evtselectVarVal.push_back(IntDblPair(45, Obs45));
549  evtselectVarMatch.push_back(IntBoolPair(45, matchHadb && matchLepb));
550 
551  if (debug)
552  std::cout << "== observable 45 " << Obs45 << std::endl;
553 
554  //obs46
555  double Obs46 = fabs(solution.getCalHadb().p4().phi() - solution.getCalHadW().p4().phi());
556  if (Obs46 > 3.1415927)
557  Obs46 = 2 * 3.1415927 - Obs46;
558  if (Obs46 < -3.1415927)
559  Obs46 = -2 * 3.1415927 - Obs46;
560  evtselectVarVal.push_back(IntDblPair(46, Obs46));
561  evtselectVarMatch.push_back(IntBoolPair(46, matchHadb && ((matchHadq && matchHadp) || (matchHadpq && matchHadqp))));
562 
563  if (debug)
564  std::cout << "== observable 46 " << Obs46 << std::endl;
565 
566  //obs47
567  double Obs47 = fabs(solution.getCalHadb().p4().eta() - solution.getCalHadW().p4().eta());
568  evtselectVarVal.push_back(IntDblPair(47, Obs47));
569  evtselectVarMatch.push_back(IntBoolPair(47, matchHadb && ((matchHadp && matchHadq) || (matchHadpq && matchHadqp))));
570 
571  if (debug)
572  std::cout << "== observable 47 " << Obs47 << std::endl;
573 
574  //obs48
575  double Obs48 = fabs(solution.getCalHadb().p4().theta() - solution.getCalHadW().p4().theta());
576  evtselectVarVal.push_back(IntDblPair(48, Obs48));
577  evtselectVarMatch.push_back(IntBoolPair(48, matchHadb && ((matchHadp && matchHadq) || (matchHadpq && matchHadqp))));
578 
579  if (debug)
580  std::cout << "== observable 48 " << Obs48 << std::endl;
581 
582  //obs49
583  double Obs49 = ROOT::Math::VectorUtil::DeltaR(solution.getCalHadb().p4(), solution.getCalHadW().p4());
584  evtselectVarVal.push_back(IntDblPair(49, Obs49));
585  evtselectVarMatch.push_back(IntBoolPair(49, matchHadb && ((matchHadp && matchHadq) || (matchHadpq && matchHadqp))));
586 
587  if (debug)
588  std::cout << "== observable 49 " << Obs49 << std::endl;
589 
590  //obs50
591  double Obs50 = fabs(solution.getCalLepb().p4().phi() - solution.getRecLepW().p4().phi());
592  if (Obs50 > 3.1415927)
593  Obs50 = 2 * 3.1415927 - Obs50;
594  if (Obs50 < -3.1415927)
595  Obs50 = -2 * 3.1415927 - Obs50;
596  evtselectVarVal.push_back(IntDblPair(50, Obs50));
597  evtselectVarMatch.push_back(IntBoolPair(50, matchLepb && matchLepn && matchLepl));
598 
599  if (debug)
600  std::cout << "== observable 50 " << Obs50 << std::endl;
601 
602  //obs51
603  double Obs51 = fabs(solution.getCalLepb().p4().eta() - solution.getRecLepW().p4().eta());
604  evtselectVarVal.push_back(IntDblPair(51, Obs51));
605  evtselectVarMatch.push_back(IntBoolPair(51, matchLepb && matchLepn && matchLepl));
606 
607  if (debug)
608  std::cout << "== observable 51 " << Obs51 << std::endl;
609 
610  //obs52
611  double Obs52 = fabs(solution.getCalLepb().p4().theta() - solution.getRecLepW().p4().theta());
612  evtselectVarVal.push_back(IntDblPair(52, Obs52));
613  evtselectVarMatch.push_back(IntBoolPair(52, matchLepb && matchLepn && matchLepl));
614 
615  if (debug)
616  std::cout << "== observable 52 " << Obs52 << std::endl;
617 
618  //obs53
619  double Obs53 = ROOT::Math::VectorUtil::DeltaR(solution.getCalLepb().p4(), solution.getRecLepW().p4());
620  evtselectVarVal.push_back(IntDblPair(53, Obs53));
621  evtselectVarMatch.push_back(IntBoolPair(53, matchLepb && matchLepn && matchLepl));
622 
623  if (debug)
624  std::cout << "== observable 53 " << Obs53 << std::endl;
625 
626  //obs54
627  double Obs54 = fabs(solution.getCalHadp().p4().phi() - solution.getCalHadq().p4().phi());
628  if (Obs54 > 3.1415927)
629  Obs54 = 2 * 3.1415927 - Obs54;
630  if (Obs54 < -3.1415927)
631  Obs54 = -2 * 3.1415927 - Obs54;
632  evtselectVarVal.push_back(IntDblPair(54, Obs54));
633  evtselectVarMatch.push_back(IntBoolPair(54, (matchHadp && matchHadq) || (matchHadpq && matchHadqp)));
634 
635  if (debug)
636  std::cout << "== observable 54 " << Obs54 << std::endl;
637 
638  //obs55
639  double Obs55 = fabs(solution.getCalHadp().p4().eta() - solution.getCalHadq().p4().eta());
640  evtselectVarVal.push_back(IntDblPair(55, Obs55));
641  evtselectVarMatch.push_back(IntBoolPair(55, (matchHadp && matchHadq) || (matchHadpq && matchHadqp)));
642 
643  if (debug)
644  std::cout << "== observable 55 " << Obs55 << std::endl;
645 
646  //obs56
647  double Obs56 = fabs(solution.getCalHadp().p4().theta() - solution.getCalHadq().p4().theta());
648  evtselectVarVal.push_back(IntDblPair(56, Obs56));
649  evtselectVarMatch.push_back(IntBoolPair(56, (matchHadp && matchHadq) || (matchHadpq && matchHadqp)));
650 
651  if (debug)
652  std::cout << "== observable 56 " << Obs56 << std::endl;
653 
654  //obs57
655  double Obs57 = ROOT::Math::VectorUtil::DeltaR(solution.getCalHadp().p4(), solution.getCalHadq().p4());
656  evtselectVarVal.push_back(IntDblPair(57, Obs57));
657  evtselectVarMatch.push_back(IntBoolPair(57, (matchHadp && matchHadq) || (matchHadpq && matchHadqp)));
658 
659  if (debug)
660  std::cout << "== observable 57 " << Obs57 << std::endl;
661 
662  //obs58
663  double Obs58 = -999.;
664  if (solution.getDecay() == "muon")
665  Obs58 = fabs(solution.getRecLepm().p4().phi() - solution.getRecLepn().p4().phi());
666  if (solution.getDecay() == "electron")
667  Obs58 = fabs(solution.getRecLepe().p4().phi() - solution.getRecLepn().p4().phi());
668  if (Obs58 > 3.1415927)
669  Obs58 = 2 * 3.1415927 - Obs58;
670  if (Obs58 < -3.1415927)
671  Obs58 = -2 * 3.1415927 - Obs58;
672  evtselectVarVal.push_back(IntDblPair(58, Obs58));
673  evtselectVarMatch.push_back(IntBoolPair(58, matchLepl && matchLepn));
674 
675  if (debug)
676  std::cout << "== observable 58 " << Obs58 << std::endl;
677 
678  //obs59
679  double Obs59 = -999.;
680  if (solution.getDecay() == "muon")
681  Obs59 = fabs(solution.getRecLepm().p4().eta() - solution.getRecLepn().p4().eta());
682  if (solution.getDecay() == "electron")
683  Obs59 = fabs(solution.getRecLepe().p4().eta() - solution.getRecLepn().p4().eta());
684  evtselectVarVal.push_back(IntDblPair(59, Obs59));
685  evtselectVarMatch.push_back(IntBoolPair(59, matchLepl && matchLepn));
686 
687  if (debug)
688  std::cout << "== observable 59 " << Obs59 << std::endl;
689 
690  //obs60
691  double Obs60 = -999.;
692  if (solution.getDecay() == "muon")
693  Obs60 = fabs(solution.getRecLepm().p4().theta() - solution.getRecLepn().p4().theta());
694  if (solution.getDecay() == "electron")
695  Obs60 = fabs(solution.getRecLepe().p4().theta() - solution.getRecLepn().p4().theta());
696  evtselectVarVal.push_back(IntDblPair(60, Obs60));
697  evtselectVarMatch.push_back(IntBoolPair(60, matchLepl && matchLepn));
698 
699  if (debug)
700  std::cout << "== observable 60 " << Obs60 << std::endl;
701 
702  //obs61
703  double Obs61 = -999.;
704  if (solution.getDecay() == "muon")
705  Obs61 = ROOT::Math::VectorUtil::DeltaR(solution.getRecLepm().p4(), solution.getRecLepn().p4());
706  if (solution.getDecay() == "electron")
707  Obs61 = ROOT::Math::VectorUtil::DeltaR(solution.getRecLepe().p4(), solution.getRecLepn().p4());
708  evtselectVarVal.push_back(IntDblPair(61, Obs61));
709  evtselectVarMatch.push_back(IntBoolPair(61, matchLepl && matchLepn));
710 
711  if (debug)
712  std::cout << "== observable 61 " << Obs61 << std::endl;
713 
714  // miscellaneous event variables
715 
716  //obs62
717  double Obs62 =
718  ((jets->size() > 4 && (*jets)[3].p4().Et() > 0.00001) ? (*jets)[4].p4().Et() / (*jets)[3].p4().Et() : 1.0);
719  //double Obs62 = 1;
720  evtselectVarVal.push_back(IntDblPair(62, Obs62));
721  evtselectVarMatch.push_back(
722  IntBoolPair(62, ((matchHadp && matchHadq) || (matchHadpq && matchHadqp)) && matchHadb && matchLepb));
723 
724  if (debug)
725  std::cout << "== observable 62 " << Obs62 << std::endl;
726 
727  float calJetsSumEt = 0;
728  for (unsigned int i = 4; i < jets->size(); i++) {
729  calJetsSumEt += (*jets)[i].p4().Et();
730  }
731 
732  //obs63
733  double Obs63_den = (jets->size() > 4) ? ((*jets)[0].p4().Et() + (*jets)[1].p4().Et() + (*jets)[2].p4().Et() +
734  (*jets)[3].p4().Et() + (*jets)[4].p4().Et())
735  : 0.0;
736  double Obs63 = (Obs63_den > 0.00001) ? calJetsSumEt / Obs63_den : 1.0;
737  //double Obs63 =1;
738  evtselectVarVal.push_back(IntDblPair(63, Obs63));
739  evtselectVarMatch.push_back(
740  IntBoolPair(63, ((matchHadp && matchHadq) || (matchHadpq && matchHadqp)) && matchHadb && matchLepb));
741 
742  if (debug)
743  std::cout << "== observable 63 " << Obs63 << std::endl;
744 
745  //obs64
746  double Obs64 = solution.getProbChi2();
747  evtselectVarVal.push_back(IntDblPair(64, Obs64));
748  evtselectVarMatch.push_back(
749  IntBoolPair(64, ((matchHadp && matchHadq) || (matchHadpq && matchHadqp)) && matchHadb && matchLepb));
750 
751  if (debug)
752  std::cout << "== observable 64 " << Obs64 << std::endl;
753 
754  //obs65
755  double Obs65 = solution.getFitHadt().p4().mass() - solution.getCalHadt().p4().mass();
756  evtselectVarVal.push_back(IntDblPair(65, Obs65));
757  evtselectVarMatch.push_back(
758  IntBoolPair(65, ((matchHadp && matchHadq) || (matchHadpq && matchHadqp)) && matchHadb && matchLepb));
759 
760  if (debug)
761  std::cout << "== observable 65 " << Obs65 << std::endl;
762 
763  //obs66
764  double Obs66 = solution.getFitLept().p4().mass() - solution.getCalLept().p4().mass();
765  evtselectVarVal.push_back(IntDblPair(66, Obs66));
766  evtselectVarMatch.push_back(
767  IntBoolPair(66, ((matchHadp && matchHadq) || (matchHadpq && matchHadqp)) && matchHadb && matchLepb));
768 
769  if (debug)
770  std::cout << "observables calculated" << std::endl;
771 
772  if (!matchOnly)
774  return evtselectVarMatch;
775 }
reco::Particle getCalHadW() const
bool isSemiLeptonic(bool excludeTauLeptons=false) const
check if the event can be classified as semi-laptonic
Definition: TtGenEvent.h:38
pat::Jet getLepb() const
pat::Jet getRecLepb() const
const LorentzVector & p4(P4Kind kind) const
Definition: GsfElectron.cc:211
pat::Jet getHadq() const
TtSemiLRJetCombObservables(edm::ConsumesCollector &&iC, const edm::EDGetTokenT< std::vector< pat::Jet > > &jetSourceToken)
Definition: deltaR.h:58
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
pat::Jet getCalHadq() const
const reco::GenParticle * getGenLept() const
pat::Particle getFitLepn() const
double pt() const final
transverse momentum
reco::Particle getFitHadt() const
std::string getDecay() const
std::pair< unsigned int, bool > IntBoolPair
float bDiscriminator(const std::string &theLabel) const
-— methods for accessing b-tagging info -—
const reco::GenParticle * getGenHadq() const
const LorentzVector & p4() const
four-momentum Lorentz vector
Definition: Particle.h:88
const reco::GenParticle * getGenLepb() const
pat::Jet getHadb() const
edm::EDGetTokenT< TtGenEvent > genEvtToken_
pat::Electron getRecLepe() const
std::vector< IntBoolPair > operator()(TtSemiEvtSolution &, const edm::Event &iEvent, bool matchOnly=false)
const reco::GenParticle * getGenHadp() const
int iEvent
Definition: GenABIO.cc:224
Class derived from the TopGenEvent for ttbar events.
Definition: TtGenEvent.h:18
pat::Jet getRecHadp() const
const reco::GenParticle * getGenHadb() const
pat::Jet getHadp() const
const reco::GenParticle * getGenLepl() const
reco::Particle getCalLept() const
edm::EDGetTokenT< std::vector< pat::Jet > > jetSourceToken_
const LorentzVector & p4() const final
four-momentum Lorentz vector
bool isValid() const
Definition: HandleBase.h:70
std::vector< IntDblPair > evtselectVarVal
pat::Jet getRecHadb() const
void setLRJetCombObservables(const std::vector< std::pair< unsigned int, double > > &varval)
pat::Jet getCalHadb() const
std::pair< unsigned int, double > IntDblPair
bool failedToGet() const
Definition: HandleBase.h:72
int numberOfBQuarks(bool fromTopQuark=true) const
return number of b quarks in the decay chain
Definition: TopGenEvent.cc:99
#define debug
Definition: HDRShower.cc:19
pat::Jet getRecHadq() const
const reco::GenParticle * getGenLepn() const
pat::Muon getRecLepm() const
HLT enums.
pat::Jet getCalLepb() const
std::vector< IntBoolPair > evtselectVarMatch
pat::MET getRecLepn() const
reco::Particle getCalHadt() const
reco::Particle getRecLepW() const
double getProbChi2() const
reco::Particle getFitLept() const
pat::Jet getCalHadp() const