CMS 3D CMS Logo

TauValidation.cc
Go to the documentation of this file.
1 /*class TauValidation
2  *
3  * Class to fill dqm monitor elements from existing EDM file
4  *
5  */
7 #include "CLHEP/Units/defs.h"
8 #include "CLHEP/Units/PhysicalConstants.h"
14 #include <iostream>
16 using namespace edm;
17 
19  : // wmanager_(iPSet,consumesCollector())
20  genparticleCollection_(iPSet.getParameter<edm::InputTag>("genparticleCollection")),
21  NMODEID(TauDecay::NMODEID - 1), // fortran to C++ index
22  zsbins(20),
23  zsmin(-0.5),
24  zsmax(0.5) {
25  genparticleCollectionToken_ = consumes<reco::GenParticleCollection>(genparticleCollection_);
26  fPDGTableToken = esConsumes<edm::Transition::BeginRun>();
27 }
28 
30 
32  fPDGTable = c.getHandle(fPDGTableToken);
33 }
34 
37  DQMHelper dqm(&i);
38  i.setCurrentFolder("Generator/Tau");
39  // Number of analyzed events
40  nTaus = dqm.book1dHisto("nTaus", "n analyzed Taus", 1, 0., 1., "bin", "Number of #tau's found");
41  nPrimeTaus =
42  dqm.book1dHisto("nPrimeTaus", "n analyzed prime Taus", 1, 0., 1., "bin", "Number of #tau's from Gauge Bosons");
43 
44  //Kinematics
45  TauPt = dqm.book1dHisto("TauPt", "Tau pT", 100, 0, 100, "P_{T}^{#tau}", "Number of #tau's from Gauge Bosons");
46  TauEta = dqm.book1dHisto("TauEta", "Tau eta", 100, -2.5, 2.5, "#eta^{#tau}", "Number of #tau's from Gauge Bosons");
47  TauPhi = dqm.book1dHisto("TauPhi", "Tau phi", 100, -3.14, 3.14, "#phi^{#tau}", "Number of #tau's from Gauge Bosons");
48  TauProngs = dqm.book1dHisto("TauProngs", "Tau n prongs", 7, 0, 7, "N_{prongs}", "Number of #tau's from Gauge Bosons");
49  TauDecayChannels = dqm.book1dHisto(
50  "TauDecayChannels", "Tau decay channels", 13, 0, 13, "Tau POG Decay Mode", "Number of #tau's from Gauge Bosons");
53  TauDecayChannels->setBinLabel(1 + muon, "mu");
54  TauDecayChannels->setBinLabel(1 + pi, "#pi^{#pm}");
55  TauDecayChannels->setBinLabel(1 + rho, "#rho^{#pm}");
56  TauDecayChannels->setBinLabel(1 + a1, "a_{1}^{#pm}");
57  TauDecayChannels->setBinLabel(1 + pi1pi0, "#pi^{#pm}#pi^{0}");
58  TauDecayChannels->setBinLabel(1 + pinpi0, "#pi^{#pm}n#pi^{0}");
59  TauDecayChannels->setBinLabel(1 + tripi, "3#pi^{#pm}");
60  TauDecayChannels->setBinLabel(1 + tripinpi0, "3#pi^{#pm}n#pi^{0}");
61  TauDecayChannels->setBinLabel(1 + K, "K");
62  TauDecayChannels->setBinLabel(1 + Kstar, "K^{*}");
63  TauDecayChannels->setBinLabel(1 + stable, "Stable");
64 
65  TauMothers = dqm.book1dHisto("TauMothers", "Tau mother particles", 10, 0, 10, "Mother of #tau", "Number of #tau's");
66 
67  TauMothers->setBinLabel(1 + other, "?");
68  TauMothers->setBinLabel(1 + B, "B Decays");
69  TauMothers->setBinLabel(1 + D, "D Decays");
70  TauMothers->setBinLabel(1 + gamma, "#gamma");
71  TauMothers->setBinLabel(1 + Z, "Z");
72  TauMothers->setBinLabel(1 + W, "W");
73  TauMothers->setBinLabel(1 + HSM, "H_{SM}/h^{0}");
74  TauMothers->setBinLabel(1 + H0, "H^{0}");
75  TauMothers->setBinLabel(1 + A0, "A^{0}");
76  TauMothers->setBinLabel(1 + Hpm, "H^{#pm}");
77 
78  DecayLength = dqm.book1dHisto(
79  "DecayLength", "#tau Decay Length", 100, -20, 20, "L_{#tau} (cm)", "Number of #tau's from Gauge Bosons");
80  LifeTime = dqm.book1dHisto(
81  "LifeTime", "#tau LifeTime ", 500, 0, 10000E-15, "#tau_{#tau} (s)", "Number of #tau's from Gauge Bosons");
82 
83  TauSpinEffectsW_X = dqm.book1dHisto(
84  "TauSpinEffectsWX", "X for pion", 50, 0, 1, "X", "Number of #tau#rightarrow#pi#nu from W^{#pm} Bosons");
85  TauSpinEffectsHpm_X = dqm.book1dHisto(
86  "TauSpinEffectsHpmX", "X for pion", 50, 0, 1, "X", "Number of #tau#rightarrow#pi#nu from H^{#pm} Bosons");
87 
88  TauSpinEffectsW_eX = dqm.book1dHisto(
89  "TauSpinEffectsWeX", "X for e", 50, 0, 1, "X", "Number of #tau#rightarrowe#nu#nu from W^{#pm} Bosons");
90  TauSpinEffectsHpm_eX = dqm.book1dHisto(
91  "TauSpinEffectsHpmeX", "X for e", 50, 0, 1, "X", "Number of #tau#rightarrowe#nu#nu from H^{#pm} Bosons");
92 
93  TauSpinEffectsW_muX = dqm.book1dHisto(
94  "TauSpinEffectsWmuX", "X for mu", 50, 0, 1, "X", "Number of #tau#rightarrow#mu#nu#nu from W^{#pm} Bosons");
95  TauSpinEffectsHpm_muX = dqm.book1dHisto(
96  "TauSpinEffectsHpmmuX", "X for mue", 50, 0, 1, "X", "Number of #tau#rightarrow#mu#nu#nu from H^{#pm} Bosons");
97 
98  TauSpinEffectsW_UpsilonRho = dqm.book1dHisto("TauSpinEffectsWUpsilonRho",
99  "#Upsilon for #rho",
100  50,
101  -1,
102  1,
103  "#Upsilon",
104  "Number of #tau#rightarrow#rho#nu from Gauge Bosons");
105  TauSpinEffectsHpm_UpsilonRho = dqm.book1dHisto("TauSpinEffectsHpmUpsilonRho",
106  "#Upsilon for #rho",
107  50,
108  -1,
109  1,
110  "#Upsilon",
111  "Number of #tau#rightarrow#rho#nu from Gauge Bosons");
112 
113  TauSpinEffectsW_UpsilonA1 = dqm.book1dHisto("TauSpinEffectsWUpsilonA1",
114  "#Upsilon for a1",
115  50,
116  -1,
117  1,
118  "#Upsilon",
119  "Number of #tau#rightarrow#pi#pi#pi#nu from Gauge Bosons");
120  TauSpinEffectsHpm_UpsilonA1 = dqm.book1dHisto("TauSpinEffectsHpmUpsilonA1",
121  "#Upsilon for a1",
122  50,
123  -1,
124  1,
125  "#Upsilon",
126  "Number of #tau#rightarrow#pi#pi#pi#nu from Gauge Bosons");
127 
129  dqm.book1dHisto("TauSpinEffectsH_pipiAcoplanarity",
130  "H Acoplanarity for #pi^{-}#pi^{+}",
131  50,
132  0,
133  2 * TMath::Pi(),
134  "Acoplanarity",
135  "Number of H#rightarrow#tau^{-}(#rightarrow#pi^{-}#nu)#tau^{+}(#rightarrow#pi^{+}#nu) Events");
136 
138  dqm.book1dHisto("TauSpinEffectsH_pipiAcollinearity",
139  "H Acollinearity for #pi^{-}#pi^{+}",
140  50,
141  0,
142  TMath::Pi(),
143  "Acollinearity",
144  "Number of H#rightarrow#tau^{-}(#rightarrow#pi^{-}#nu)#tau^{+}(#rightarrow#pi^{+}#nu) Events");
146  dqm.book1dHisto("TauSpinEffectsH_pipiAcollinearityzoom",
147  "H Acollinearity for #pi^{-}#pi^{+}",
148  50,
149  3,
150  TMath::Pi(),
151  "Acollinearity",
152  "Number of H#rightarrow#tau^{-}(#rightarrow#pi^{-}#nu)#tau^{+}(#rightarrow#pi^{+}#nu) Events");
153 
155  dqm.book1dHisto("TauSpinEffectsZMVis",
156  "Mass of pi+ pi-",
157  25,
158  0,
159  1.1,
160  "M_{#pi^{+}#pi^{-}} (GeV)",
161  "Number of Z#rightarrow#tau^{-}(#rightarrow#pi^{-}#nu)#tau^{+}(#rightarrow#pi^{+}#nu) Events");
163  dqm.book1dHisto("TauSpinEffectsHMVis",
164  "Mass of pi+ pi-",
165  25,
166  0,
167  1.1,
168  "M_{#pi^{+}#pi^{-}} (GeV)",
169  "Number of H#rightarrow#tau^{-}(#rightarrow#pi^{-}#nu)#tau^{+}(#rightarrow#pi^{+}#nu) Events");
170 
172  dqm.book1dHisto("TauSpinEffectsZZs",
173  "Z_{s}",
174  zsbins,
175  zsmin,
176  zsmax,
177  "Z_{s}",
178  "Number of Z#rightarrow#tau^{-}(#rightarrow#pi^{-}#nu)#tau^{+}(#rightarrow#pi^{+}#nu Events");
180  dqm.book1dHisto("TauSpinEffectsHZs",
181  "Z_{s}",
182  zsbins,
183  zsmin,
184  zsmax,
185  "Z_{s}",
186  "Number of H#rightarrow#tau^{-}(#rightarrow#pi^{-}#nu)#tau^{+}(#rightarrow#pi^{+}#nu Events");
187 
188  TauSpinEffectsZ_X = dqm.book1dHisto(
189  "TauSpinEffectsZX", "X for pion of #tau^{-}", 25, 0, 1.0, "X", "Number of #tau#rightarrow#pi#nu from Z Bosons");
190  TauSpinEffectsZ_X50to75 = dqm.book1dHisto("TauSpinEffectsZX50to75",
191  "X for pion of #tau^{-} (50GeV-75GeV)",
192  10,
193  0,
194  1.0,
195  "X",
196  "Number of #tau#rightarrow#pi#nu from Z(50GeV<M<75GeV) Bosons");
197  TauSpinEffectsZ_X75to88 = dqm.book1dHisto("TauSpinEffectsZX75to88",
198  "X for pion of #tau^{-} (75GeV-88GeV)",
199  10,
200  0,
201  1.0,
202  "X",
203  "Number of #tau#rightarrow#pi#nu from Z(75GeV<M<88GeV) Bosons");
204  TauSpinEffectsZ_X88to100 = dqm.book1dHisto("TauSpinEffectsZX88to100",
205  "X for pion of #tau^{-} (88GeV-100GeV)",
206  10,
207  0,
208  1.0,
209  "X",
210  "Number of #tau#rightarrow#pi#nu from Z(88GeV<M<100GeV) Bosons");
211  TauSpinEffectsZ_X100to120 = dqm.book1dHisto("TauSpinEffectsZX100to120",
212  "X for pion of #tau^{-} (100GeV-120GeV)",
213  10,
214  0,
215  1.0,
216  "X",
217  "Number of #tau#rightarrow#pi#nu from Z(100GeV<M<120GeV) Bosons");
218  TauSpinEffectsZ_X120UP = dqm.book1dHisto("TauSpinEffectsZX120UP",
219  "X for pion of #tau^{-} (>120GeV)",
220  10,
221  0,
222  1.0,
223  "X",
224  "Number of #tau#rightarrow#pi#nu from Z(120GeV<MGeV) Bosons");
225 
226  TauSpinEffectsH_X = dqm.book1dHisto(
227  "TauSpinEffectsH_X", "X for pion of #tau^{-}", 25, 0, 1.0, "X", "Number of #tau#rightarrow#pi#nu from H Bosons");
228 
229  TauSpinEffectsZ_Xf = dqm.book1dHisto("TauSpinEffectsZXf",
230  "X for pion of forward emitted #tau^{-}",
231  25,
232  0,
233  1.0,
234  "X_{f}",
235  "Number of #tau#rightarrow#pi#nu from Z Bosons");
236  TauSpinEffectsH_Xf = dqm.book1dHisto("TauSpinEffectsHXf",
237  "X for pion of forward emitted #tau^{-}",
238  25,
239  0,
240  1.0,
241  "X_{f}",
242  "Number of #tau#rightarrow#pi#nu from H Bosons");
243 
244  TauSpinEffectsZ_Xb = dqm.book1dHisto("TauSpinEffectsZXb",
245  "X for pion of backward emitted #tau^{-}",
246  25,
247  0,
248  1.0,
249  "X_{b}",
250  "Number of #tau#rightarrow#pi#nu from Z Bosons");
251  TauSpinEffectsH_Xb = dqm.book1dHisto("TauSpinEffectsHXb",
252  "X for pion of backward emitted #tau^{-}",
253  25,
254  0,
255  1.0,
256  "X_{b}",
257  "Number of #tau#rightarrow#pi#nu from H Bosons");
258 
259  TauSpinEffectsZ_eX = dqm.book1dHisto(
260  "TauSpinEffectsZeX", "X for e", 50, 0, 1, "X", "Number of #tau#rightarrowe#nu#nu from Gauge Bosons");
261  TauSpinEffectsH_eX = dqm.book1dHisto(
262  "TauSpinEffectsHeX", "X for e", 50, 0, 1, "X", "Number of #tau#rightarrowe#nu#nu from Gauge Bosons");
263 
264  TauSpinEffectsZ_muX = dqm.book1dHisto(
265  "TauSpinEffectsZmuX", "X for mu", 50, 0, 1, "X", "Number of #tau#rightarrow#mu#nu#nu from Gauge Bosons");
266  TauSpinEffectsH_muX = dqm.book1dHisto(
267  "TauSpinEffectsHmuX", "X for mu", 50, 0, 1, "X", "Number of #tau#rightarrow#mu#nu#nu from Gauge Bosons");
268 
270  dqm.book1dHisto("TauSpinEffectsH_rhorhoAcoplanarityminus",
271  "#phi^{*-} (acoplanarity) for Higgs #rightarrow #rho-#rho (y_{1}*y_{2}<0)",
272  32,
273  0,
274  2 * TMath::Pi(),
275  "#phi^{*-} (Acoplanarity)",
276  "Number of H#rightarrow#tau^{-}(#rightarrow#rho^{-}#nu)#tau^{+}(#rightarrow#rho^{+}#nu) Events");
278  dqm.book1dHisto("TauSpinEffectsH_rhorhoAcoplanarityplus",
279  "#phi^{*+} (acoplanarity) for Higgs #rightarrow #rho-#rho (y_{1}*y_{2}>0)",
280  32,
281  0,
282  2 * TMath::Pi(),
283  "#phi^{*+} (Acoplanarity)",
284  "Number of H#rightarrow#tau^{-}(#rightarrow#rho^{-}#nu)#tau^{+}(#rightarrow#rho^{+}#nu) Events");
285 
286  TauFSRPhotonsN = dqm.book1dHisto("TauFSRPhotonsN",
287  "FSR Photons radiating from/with tau (Gauge Boson)",
288  5,
289  -0.5,
290  4.5,
291  "N^{FSR Photons radiating from/with #tau}",
292  "Number of #tau's from Gauge Bosons");
293  TauFSRPhotonsPt = dqm.book1dHisto("TauFSRPhotonsPt",
294  "Pt of FSR Photons radiating from/with tau (Gauge Boson)",
295  100,
296  0,
297  100,
298  "P_{t}^{FSR Photons radiating from/with #tau [per #tau]} (GeV)",
299  "Number of #tau's from Gauge Bosons");
300  TauFSRPhotonsPtSum = dqm.book1dHisto("TauFSRPhotonsPtSum",
301  "Pt of FSR Photons radiating from/with tau (Gauge Boson)",
302  100,
303  0,
304  100,
305  "P_{t}^{FSR Photons radiating from/with #tau [per #tau]} (GeV)",
306  "Number of #tau's from Gauge Bosons");
307 
308  TauBremPhotonsN = dqm.book1dHisto("TauBremPhotonsN",
309  "Brem. Photons radiating in tau decay",
310  5,
311  -0.5,
312  4.5,
313  "N FSR Photons radiating from/with tau",
314  "Number of #tau's from Gauge Bosons");
315  TauBremPhotonsPt = dqm.book1dHisto("TauBremPhotonsPt",
316  "Sum Brem Pt ",
317  100,
318  0,
319  100,
320  "P_{t}^{Brem. Photons radiating in tau decay} (GeV)",
321  "Number of #tau's from Gauge Bosons");
322  TauBremPhotonsPtSum = dqm.book1dHisto("TauBremPhotonsPtSum",
323  "Sum of Brem Pt ",
324  100,
325  0,
326  100,
327  "Sum P_{t}^{Brem. Photons radiating in tau decay} (GeV)",
328  "Number of #tau's from Gauge Bosons");
329 
330  MODEID = dqm.book1dHisto("JAKID", "JAK ID", NMODEID + 1, -0.5, NMODEID + 0.5);
331  for (unsigned int j = 0; j < NMODEID + 1; j++) {
332  MODEInvMass.push_back(std::vector<MonitorElement *>());
333  std::string tmp = "JAKID";
334  tmp += std::to_string(j);
335  MODEInvMass.at(j).push_back(dqm.book1dHisto("M" + tmp,
336  "M_{" + TauDecay::DecayMode(j) + "} (GeV)",
337  80,
338  0,
339  2.0,
340  "M_{" + TauDecay::DecayMode(j) + "} (GeV)",
341  "Number of #tau's from Gauge Bosons"));
344  j == TauDecay::MODE_KPIPI) {
345  MODEInvMass.at(j).push_back(dqm.book1dHisto("M13" + tmp,
346  "M_{13," + TauDecay::DecayMode(j) + "} (GeV)",
347  80,
348  0,
349  2.0,
350  "M_{13," + TauDecay::DecayMode(j) + "} (GeV)",
351  "Number of #tau's from Gauge Bosons"));
352  MODEInvMass.at(j).push_back(dqm.book1dHisto("M23" + tmp,
353  "M_{23," + TauDecay::DecayMode(j) + "} (GeV)",
354  80,
355  0,
356  2.0,
357  "M_{23," + TauDecay::DecayMode(j) + "} (GeV)",
358  "Number of #tau's from Gauge Bosons"));
359  MODEInvMass.at(j).push_back(dqm.book1dHisto("M12" + tmp,
360  "M_{12," + TauDecay::DecayMode(j) + "} (GeV)",
361  80,
362  0,
363  2.0,
364  "M_{12," + TauDecay::DecayMode(j) + "} (GeV)",
365  "Number of #tau's from Gauge Bosons"));
366  }
367  }
368  return;
369 }
370 
375 
376  double weight = 1.0; //= wmanager_.weight(iEvent);
378  // find taus
379  for (reco::GenParticleCollection::const_iterator iter = genParticles->begin(); iter != genParticles->end(); ++iter) {
380  if (abs(iter->pdgId()) == PdtPdgMini::Z0 || abs(iter->pdgId()) == PdtPdgMini::Higgs0) {
381  spinEffectsZH(&(*iter), weight);
382  }
383  if (abs(iter->pdgId()) == 15) {
384  if (isLastTauinChain(&(*iter))) {
385  nTaus->Fill(0.5, weight);
386  int mother = tauMother(&(*iter), weight);
387  if (mother > -1) { // exclude B, D and other non-signal decay modes
388  nPrimeTaus->Fill(0.5, weight);
389  TauPt->Fill(iter->pt(), weight);
390  TauEta->Fill(iter->eta(), weight);
391  TauPhi->Fill(iter->phi(), weight);
392  photons(&(*iter), weight);
394  // Adding MODEID and Mass information
396  unsigned int jak_id, TauBitMask;
397  if (TD.AnalyzeTau(&(*iter), jak_id, TauBitMask, false, false)) {
398  MODEID->Fill(jak_id, weight);
399  TauProngs->Fill(TD.nProng(TauBitMask), weight);
400  tauDecayChannel(&(*iter), jak_id, TauBitMask, weight);
401  if (jak_id <= NMODEID) {
402  int tcharge = iter->pdgId() / abs(iter->pdgId());
403  std::vector<const reco::GenParticle *> part = TD.Get_TauDecayProducts();
404  spinEffectsWHpm(&(*iter), mother, jak_id, part, weight);
405  TLorentzVector LVQ(0, 0, 0, 0);
406  TLorentzVector LVS12(0, 0, 0, 0);
407  TLorentzVector LVS13(0, 0, 0, 0);
408  TLorentzVector LVS23(0, 0, 0, 0);
409  bool haspart1 = false;
410  TVector3 PV, SV;
411  bool hasDL(false);
412  for (unsigned int i = 0; i < part.size(); i++) {
413  if (abs(part.at(i)->pdgId()) != PdtPdgMini::nu_tau && TD.isTauFinalStateParticle(part.at(i)->pdgId()) &&
414  !hasDL) {
415  hasDL = true;
416  TLorentzVector tlv(iter->px(), iter->py(), iter->pz(), iter->energy());
417  PV = TVector3(iter->vx(), iter->vy(), iter->vz());
418  SV = TVector3(part.at(i)->vx(), part.at(i)->vy(), part.at(i)->vz());
419  TVector3 DL = SV - PV;
420  DecayLength->Fill(DL.Dot(tlv.Vect()) / tlv.P(), weight);
421  double c(2.99792458E8), Ltau(DL.Mag() / 100) /*cm->m*/, beta(iter->p() / iter->mass());
422  LifeTime->Fill(Ltau / (c * beta), weight);
423  }
424 
425  if (TD.isTauFinalStateParticle(part.at(i)->pdgId()) && abs(part.at(i)->pdgId()) != PdtPdgMini::nu_e &&
426  abs(part.at(i)->pdgId()) != PdtPdgMini::nu_mu && abs(part.at(i)->pdgId()) != PdtPdgMini::nu_tau) {
427  TLorentzVector LV(part.at(i)->px(), part.at(i)->py(), part.at(i)->pz(), part.at(i)->energy());
428  LVQ += LV;
429  if (jak_id == TauDecay::MODE_3PI || jak_id == TauDecay::MODE_PI2PI0 ||
430  jak_id == TauDecay::MODE_KPIK || jak_id == TauDecay::MODE_KPIPI) {
431  if ((tcharge == part.at(i)->pdgId() / abs(part.at(i)->pdgId()) && TD.nProng(TauBitMask) == 3) ||
432  ((jak_id == TauDecay::MODE_3PI || jak_id == TauDecay::MODE_PI2PI0) &&
433  TD.nProng(TauBitMask) == 1 && abs(part.at(i)->pdgId()) == PdtPdgMini::pi_plus)) {
434  LVS13 += LV;
435  LVS23 += LV;
436  } else {
437  LVS12 += LV;
438  if (!haspart1 && ((jak_id == TauDecay::MODE_3PI || jak_id == TauDecay::MODE_PI2PI0) ||
439  ((jak_id != TauDecay::MODE_3PI || jak_id == TauDecay::MODE_PI2PI0) &&
440  abs(part.at(i)->pdgId()) == PdtPdgMini::K_plus))) {
441  LVS13 += LV;
442  haspart1 = true;
443  } else {
444  LVS23 += LV;
445  }
446  }
447  }
448  }
449  }
450  part.clear();
451  MODEInvMass.at(jak_id).at(0)->Fill(LVQ.M(), weight);
452  if (jak_id == TauDecay::MODE_3PI || jak_id == TauDecay::MODE_PI2PI0 || jak_id == TauDecay::MODE_KPIK ||
453  jak_id == TauDecay::MODE_KPIPI) {
454  MODEInvMass.at(jak_id).at(1)->Fill(LVS13.M(), weight);
455  MODEInvMass.at(jak_id).at(2)->Fill(LVS23.M(), weight);
456  MODEInvMass.at(jak_id).at(3)->Fill(LVS12.M(), weight);
457  }
458  }
459  } else {
460  MODEID->Fill(jak_id, weight);
461  }
462  }
463  }
464  }
465  }
466 } //analyze
467 
469  for (unsigned int i = 0; i < tau->numberOfMothers(); i++) {
470  const reco::GenParticle *mother = static_cast<const reco::GenParticle *>(tau->mother(i));
471  if (mother->pdgId() == tau->pdgId())
472  return GetMother(mother);
473  return mother;
474  }
475  return tau;
476 }
477 
478 const std::vector<const reco::GenParticle *> TauValidation::GetMothers(const reco::GenParticle *boson) {
479  std::vector<const reco::GenParticle *> mothers;
480  for (unsigned int i = 0; i < boson->numberOfMothers(); i++) {
481  const reco::GenParticle *mother = static_cast<const reco::GenParticle *>(boson->mother(i));
482  if (mother->pdgId() == boson->pdgId())
483  return GetMothers(mother);
484  mothers.push_back(mother);
485  }
486  return mothers;
487 }
488 
490 
492  for (unsigned int i = 0; i < tau->numberOfDaughters(); i++) {
493  if (tau->daughter(i)->pdgId() == tau->pdgId())
494  return false;
495  }
496  return true;
497 }
498 
499 void TauValidation::findTauList(const reco::GenParticle *tau, std::vector<const reco::GenParticle *> &TauList) {
500  TauList.insert(TauList.begin(), tau);
501  for (unsigned int i = 0; i < tau->numberOfMothers(); i++) {
502  const reco::GenParticle *mother = static_cast<const reco::GenParticle *>(tau->mother(i));
503  if (mother->pdgId() == tau->pdgId()) {
504  findTauList(mother, TauList);
505  }
506  }
507 }
508 
510  bool doBrem,
511  std::vector<const reco::GenParticle *> &ListofFSR,
512  std::vector<const reco::GenParticle *> &ListofBrem) {
513  // note this code split the FSR and Brem based one if the tau decays into a tau+photon or not with the Fortran Tauola Interface, this is not 100% correct because photos puts the tau with the regular tau decay products.
514  if (abs(p->pdgId()) == 15) {
515  if (isLastTauinChain(p)) {
516  doBrem = true;
517  } else {
518  doBrem = false;
519  }
520  }
521  int photo_ID = 22;
522  for (unsigned int i = 0; i < p->numberOfDaughters(); i++) {
523  const reco::GenParticle *dau = static_cast<const reco::GenParticle *>(p->daughter(i));
524  if (abs((dau)->pdgId()) == abs(photo_ID) && !doBrem) {
525  ListofFSR.push_back(dau);
526  }
527  if (abs((dau)->pdgId()) == abs(photo_ID) && doBrem) {
528  ListofBrem.push_back(dau);
529  }
530  if (abs((dau)->pdgId()) != 111 && abs((dau)->pdgId()) != 221) { // remove pi0 and eta decays
531  findFSRandBrem(dau, doBrem, ListofFSR, ListofBrem);
532  }
533  }
534 }
535 
537  std::vector<const reco::GenParticle *> &ListofFSR,
538  double &BosonScale) {
539  BosonScale = 0.0;
540  const reco::GenParticle *m = GetMother(p);
541  int mother_pid = m->pdgId();
542  if (m->pdgId() != p->pdgId()) {
543  for (unsigned int i = 0; i < m->numberOfDaughters(); i++) {
544  const reco::GenParticle *dau = static_cast<const reco::GenParticle *>(m->daughter(i));
545  if (abs(dau->pdgId()) == 22) {
546  ListofFSR.push_back(dau);
547  }
548  }
549  }
550  if (abs(mother_pid) == 24)
551  BosonScale = 1.0; // W
552  if (abs(mother_pid) == 23)
553  BosonScale = 2.0; // Z;
554  if (abs(mother_pid) == 22)
555  BosonScale = 2.0; // gamma;
556  if (abs(mother_pid) == 25)
557  BosonScale = 2.0; // HSM;
558  if (abs(mother_pid) == 35)
559  BosonScale = 2.0; // H0;
560  if (abs(mother_pid) == 36)
561  BosonScale = 2.0; // A0;
562  if (abs(mother_pid) == 37)
563  BosonScale = 1.0; //Hpm;
564 }
565 
567  if (abs(tau->pdgId()) != 15)
568  return -3;
569  int mother_pid = findMother(tau);
570  if (mother_pid == -2)
571  return -2;
572  int label = other;
573  if (abs(mother_pid) == 24)
574  label = W;
575  if (abs(mother_pid) == 23)
576  label = Z;
577  if (abs(mother_pid) == 22)
578  label = gamma;
579  if (abs(mother_pid) == 25)
580  label = HSM;
581  if (abs(mother_pid) == 35)
582  label = H0;
583  if (abs(mother_pid) == 36)
584  label = A0;
585  if (abs(mother_pid) == 37)
586  label = Hpm;
587  int mother_shortpid = (abs(mother_pid) % 10000);
588  if (mother_shortpid > 500 && mother_shortpid < 600)
589  label = B;
590  if (mother_shortpid > 400 && mother_shortpid < 500)
591  label = D;
593  if (label == B || label == D || label == other)
594  return -1;
595  return mother_pid;
596 }
597 
598 int TauValidation::tauDecayChannel(const reco::GenParticle *tau, int jak_id, unsigned int TauBitMask, double weight) {
599  int channel = undetermined;
600  if (tau->status() == 1)
601  channel = stable;
602  int allCount = 0, eCount = 0, muCount = 0, pi0Count = 0, piCount = 0, rhoCount = 0, a1Count = 0, KCount = 0,
603  KstarCount = 0;
604 
605  countParticles(tau, allCount, eCount, muCount, pi0Count, piCount, rhoCount, a1Count, KCount, KstarCount);
606 
607  // resonances
608  if (KCount >= 1)
609  channel = K;
610  if (KstarCount >= 1)
611  channel = Kstar;
612  if (a1Count >= 1)
613  channel = a1;
614  if (rhoCount >= 1)
615  channel = rho;
616  if (channel != undetermined && weight != 0.0)
617  TauDecayChannels->Fill(channel, weight);
618 
619  // final state products
620  if (piCount == 1 && pi0Count == 0)
621  channel = pi;
622  if (piCount == 1 && pi0Count == 1)
623  channel = pi1pi0;
624  if (piCount == 1 && pi0Count > 1)
625  channel = pinpi0;
626  if (piCount == 3 && pi0Count == 0)
627  channel = tripi;
628  if (piCount == 3 && pi0Count > 0)
629  channel = tripinpi0;
630  if (eCount == 1)
631  channel = electron;
632  if (muCount == 1)
633  channel = muon;
634  if (weight != 0.0)
635  TauDecayChannels->Fill(channel, weight);
636  return channel;
637 }
638 
640  int &allCount,
641  int &eCount,
642  int &muCount,
643  int &pi0Count,
644  int &piCount,
645  int &rhoCount,
646  int &a1Count,
647  int &KCount,
648  int &KstarCount) {
649  for (unsigned int i = 0; i < p->numberOfDaughters(); i++) {
650  const reco::GenParticle *dau = static_cast<const reco::GenParticle *>(p->daughter(i));
651  int pid = dau->pdgId();
652  allCount++;
653  if (abs(pid) == 11)
654  eCount++;
655  else if (abs(pid) == 13)
656  muCount++;
657  else if (abs(pid) == 111)
658  pi0Count++;
659  else if (abs(pid) == 211)
660  piCount++;
661  else if (abs(pid) == 213)
662  rhoCount++;
663  else if (abs(pid) == 20213)
664  a1Count++;
665  else if (abs(pid) == 321)
666  KCount++;
667  else if (abs(pid) == 323)
668  KstarCount++;
669  countParticles(dau, allCount, eCount, muCount, pi0Count, piCount, rhoCount, a1Count, KCount, KstarCount);
670  }
671 }
672 
674  const reco::GenParticle *tau, int mother, int decay, std::vector<const reco::GenParticle *> &part, double weight) {
675  // polarization only for 1-prong hadronic taus with no neutral pions
677  TLorentzVector momP4 = motherP4(tau);
678  TLorentzVector pionP4 = leadingPionP4(tau);
679  pionP4.Boost(-1 * momP4.BoostVector());
680  double energy = pionP4.E() / (momP4.M() / 2);
681  if (decay == TauDecay::MODE_PION) {
682  if (abs(mother) == 24)
684  else if (abs(mother) == 37)
686  } else if (decay == TauDecay::MODE_MUON) {
687  if (abs(mother) == 24)
689  else if (abs(mother) == 37)
691  } else if (decay == TauDecay::MODE_ELECTRON) {
692  if (abs(mother) == 24)
694  else if (abs(mother) == 37)
696  }
697  } else if (decay == TauDecay::MODE_PIPI0) {
698  TLorentzVector rho(0, 0, 0, 0), pi(0, 0, 0, 0);
699  for (unsigned int i = 0; i < part.size(); i++) {
700  TLorentzVector LV(part.at(i)->px(), part.at(i)->py(), part.at(i)->pz(), part.at(i)->energy());
701  if (abs(part.at(i)->pdgId()) == PdtPdgMini::pi_plus) {
702  pi += LV;
703  rho += LV;
704  } else if (abs(part.at(i)->pdgId()) == PdtPdgMini::pi0) {
705  rho += LV;
706  }
707  }
708  if (abs(mother) == 24)
709  TauSpinEffectsW_UpsilonRho->Fill(2 * pi.P() / rho.P() - 1, weight);
710  else if (abs(mother) == 37)
711  TauSpinEffectsHpm_UpsilonRho->Fill(2 * pi.P() / rho.P() - 1, weight);
712  } else if (decay == TauDecay::MODE_3PI || decay == TauDecay::MODE_PI2PI0) { // only for pi2pi0 for now
713  TLorentzVector a1(0, 0, 0, 0), pi_p(0, 0, 0, 0), pi_m(0, 0, 0, 0);
714  int nplus(0), nminus(0);
715  for (unsigned int i = 0; i < part.size(); i++) {
716  TLorentzVector LV(part.at(i)->px(), part.at(i)->py(), part.at(i)->pz(), part.at(i)->energy());
717  if (part.at(i)->pdgId() == PdtPdgMini::pi_plus) {
718  pi_p += LV;
719  a1 += LV;
720  nplus++;
721  } else if (part.at(i)->pdgId() == PdtPdgMini::pi_minus) {
722  pi_m += LV;
723  a1 += LV;
724  nminus++;
725  }
726  }
727  double gamma = 0;
728  if (nplus + nminus == 3 && nplus == 1)
729  gamma = 2 * pi_p.P() / a1.P() - 1;
730  else if (nplus + nminus == 3 && nminus == 1)
731  gamma = 2 * pi_m.P() / a1.P() - 1;
732  else {
733  pi_p += pi_m;
734  gamma = 2 * pi_p.P() / a1.P() - 1;
735  }
736  if (abs(mother) == 24)
738  else if (abs(mother) == 37)
740  }
741 }
742 
744  int ntau(0);
745  for (unsigned int i = 0; i < boson->numberOfDaughters(); i++) {
746  const reco::GenParticle *dau = static_cast<const reco::GenParticle *>(boson->daughter(i));
747  if (ntau == 1 && dau->pdgId() == 15)
748  return;
749  if (boson->pdgId() != 15 && abs(dau->pdgId()) == 15)
750  ntau++;
751  }
752  if (ntau != 2)
753  return;
754  if (abs(boson->pdgId()) == PdtPdgMini::Z0 || abs(boson->pdgId()) == PdtPdgMini::Higgs0) {
755  TLorentzVector tautau(0, 0, 0, 0);
756  TLorentzVector pipi(0, 0, 0, 0);
757  TLorentzVector taum(0, 0, 0, 0);
758  TLorentzVector taup(0, 0, 0, 0);
759  TLorentzVector rho_plus, rho_minus, pi_rhominus, pi0_rhominus, pi_rhoplus, pi0_rhoplus, pi_plus, pi_minus;
760  bool hasrho_minus(false), hasrho_plus(false), haspi_minus(false), haspi_plus(false);
761  int nSinglePionDecays(0);
762  double x1(0), x2(0);
763  TLorentzVector Zboson(boson->px(), boson->py(), boson->pz(), boson->energy());
764  for (unsigned int i = 0; i < boson->numberOfDaughters(); i++) {
765  const reco::GenParticle *dau = static_cast<const reco::GenParticle *>(boson->daughter(i));
766  int pid = dau->pdgId();
767  if (abs(findMother(dau)) != 15 && abs(pid) == 15) {
769  unsigned int jak_id, TauBitMask;
770  if (TD.AnalyzeTau(dau, jak_id, TauBitMask, false, false)) {
771  std::vector<const reco::GenParticle *> part = TD.Get_TauDecayProducts();
772  if (jak_id == TauDecay::MODE_PION || jak_id == TauDecay::MODE_MUON || jak_id == TauDecay::MODE_ELECTRON) {
773  if (jak_id == TauDecay::MODE_PION)
774  nSinglePionDecays++;
775  TLorentzVector LVtau(dau->px(), dau->py(), dau->pz(), dau->energy());
776  tautau += LVtau;
777  TLorentzVector LVpi = leadingPionP4(dau);
778  pipi += LVpi;
779  const HepPDT::ParticleData *pd = fPDGTable->particle(dau->pdgId());
780  int charge = (int)pd->charge();
781  LVtau.Boost(-1 * Zboson.BoostVector());
782  LVpi.Boost(-1 * Zboson.BoostVector());
783 
784  if (jak_id == TauDecay::MODE_MUON) {
785  if (abs(boson->pdgId()) == PdtPdgMini::Z0)
786  TauSpinEffectsZ_muX->Fill(LVpi.P() / LVtau.E(), weight);
787  if (abs(boson->pdgId()) == PdtPdgMini::Higgs0)
788  TauSpinEffectsH_muX->Fill(LVpi.P() / LVtau.E(), weight);
789  }
790  if (jak_id == TauDecay::MODE_ELECTRON) {
791  if (abs(boson->pdgId()) == PdtPdgMini::Z0)
792  TauSpinEffectsZ_eX->Fill(LVpi.P() / LVtau.E(), weight);
793  if (abs(boson->pdgId()) == PdtPdgMini::Higgs0)
794  TauSpinEffectsH_eX->Fill(LVpi.P() / LVtau.E(), weight);
795  }
796 
797  if (jak_id == TauDecay::MODE_PION) {
798  if (abs(boson->pdgId()) == PdtPdgMini::Z0) {
799  TauSpinEffectsZ_X->Fill(LVpi.P() / LVtau.E(), weight);
800  if (50.0 < Zboson.M() && Zboson.M() < 75.0)
801  TauSpinEffectsZ_X50to75->Fill(LVpi.P() / LVtau.E(), weight);
802  if (75.0 < Zboson.M() && Zboson.M() < 88.0)
803  TauSpinEffectsZ_X75to88->Fill(LVpi.P() / LVtau.E(), weight);
804  if (88.0 < Zboson.M() && Zboson.M() < 100.0)
805  TauSpinEffectsZ_X88to100->Fill(LVpi.P() / LVtau.E(), weight);
806  if (100.0 < Zboson.M() && Zboson.M() < 120.0)
807  TauSpinEffectsZ_X100to120->Fill(LVpi.P() / LVtau.E(), weight);
808  if (120.0 < Zboson.M())
809  TauSpinEffectsZ_X120UP->Fill(LVpi.P() / LVtau.E(), weight);
810  }
811  if (abs(boson->pdgId()) == PdtPdgMini::Higgs0)
812  TauSpinEffectsH_X->Fill(LVpi.P() / LVtau.E(), weight);
813  }
814  if (charge < 0) {
815  x1 = LVpi.P() / LVtau.E();
816  taum = LVtau;
817  } else {
818  x2 = LVpi.P() / LVtau.E();
819  }
820  }
821  TLorentzVector LVtau(dau->px(), dau->py(), dau->pz(), dau->energy());
822  if (pid == 15)
823  taum = LVtau;
824  if (pid == -15)
825  taup = LVtau;
826  if (jak_id == TauDecay::MODE_PIPI0) {
827  for (unsigned int i = 0; i < part.size(); i++) {
828  int pid_d = part.at(i)->pdgId();
829  if (abs(pid_d) == 211 || abs(pid_d) == 111) {
830  TLorentzVector LV(part.at(i)->px(), part.at(i)->py(), part.at(i)->pz(), part.at(i)->energy());
831  if (pid == 15) {
832  hasrho_minus = true;
833  if (pid_d == -211) {
834  pi_rhominus = LV;
835  }
836  if (abs(pid_d) == 111) {
837  pi0_rhominus = LV;
838  }
839  }
840  if (pid == -15) {
841  hasrho_plus = true;
842  if (pid_d == 211) {
843  pi_rhoplus = LV;
844  }
845  if (abs(pid_d) == 111) {
846  pi0_rhoplus = LV;
847  }
848  }
849  }
850  }
851  }
852  if (jak_id == TauDecay::MODE_PION) {
853  for (unsigned int i = 0; i < part.size(); i++) {
854  int pid_d = part.at(i)->pdgId();
855  if (abs(pid_d) == 211) {
856  TLorentzVector LV(part.at(i)->px(), part.at(i)->py(), part.at(i)->pz(), part.at(i)->energy());
857  if (pid == 15) {
858  haspi_minus = true;
859  if (pid_d == -211) {
860  pi_minus = LV;
861  }
862  }
863  if (pid == -15) {
864  haspi_plus = true;
865  if (pid_d == 211) {
866  pi_plus = LV;
867  }
868  }
869  }
870  }
871  }
872  }
873  }
874  }
875  if (hasrho_minus && hasrho_plus) {
876  //compute rhorho
877  rho_minus = pi_rhominus;
878  rho_minus += pi0_rhominus;
879  rho_plus = pi_rhoplus;
880  rho_plus += pi0_rhoplus;
881  TLorentzVector rhorho = rho_minus;
882  rhorho += rho_plus;
883 
884  // boost to rhorho cm
885  TLorentzVector pi_rhoplusb = pi_rhoplus;
886  pi_rhoplusb.Boost(-1 * rhorho.BoostVector());
887  TLorentzVector pi0_rhoplusb = pi0_rhoplus;
888  pi0_rhoplusb.Boost(-1 * rhorho.BoostVector());
889  TLorentzVector pi_rhominusb = pi_rhominus;
890  pi_rhominusb.Boost(-1 * rhorho.BoostVector());
891  TLorentzVector pi0_rhominusb = pi0_rhominus;
892  pi0_rhominusb.Boost(-1 * rhorho.BoostVector());
893 
894  // compute n+/-
895  TVector3 n_plus = pi_rhoplusb.Vect().Cross(pi0_rhoplusb.Vect());
896  TVector3 n_minus = pi_rhominusb.Vect().Cross(pi0_rhominusb.Vect());
897 
898  // compute the acoplanarity
899  double Acoplanarity = acos(n_plus.Dot(n_minus) / (n_plus.Mag() * n_minus.Mag()));
900  if (pi_rhominusb.Vect().Dot(n_plus) > 0) {
901  Acoplanarity *= -1;
902  Acoplanarity += 2 * TMath::Pi();
903  }
904 
905  // now boost to tau frame
906  pi_rhoplus.Boost(-1 * taup.BoostVector());
907  pi0_rhoplus.Boost(-1 * taup.BoostVector());
908  pi_rhominus.Boost(-1 * taum.BoostVector());
909  pi0_rhominus.Boost(-1 * taum.BoostVector());
910 
911  // compute y1 and y2
912  double y1 = (pi_rhoplus.E() - pi0_rhoplus.E()) / (pi_rhoplus.E() + pi0_rhoplus.E());
913  double y2 = (pi_rhominus.E() - pi0_rhominus.E()) / (pi_rhominus.E() + pi0_rhominus.E());
914 
915  // fill histograms
916  if (abs(boson->pdgId()) == PdtPdgMini::Higgs0 && y1 * y2 < 0)
918  if (abs(boson->pdgId()) == PdtPdgMini::Higgs0 && y1 * y2 > 0)
920  }
921  if (haspi_minus && haspi_plus) {
922  TLorentzVector tauporig = taup;
923  TLorentzVector taumorig = taum;
924 
925  // now boost to Higgs frame
926  pi_plus.Boost(-1 * Zboson.BoostVector());
927  pi_minus.Boost(-1 * Zboson.BoostVector());
928 
929  taup.Boost(-1 * Zboson.BoostVector());
930  taum.Boost(-1 * Zboson.BoostVector());
931 
932  if (abs(boson->pdgId()) == PdtPdgMini::Higgs0) {
934  acos(pi_plus.Vect().Dot(pi_minus.Vect()) / (pi_plus.P() * pi_minus.P())));
936  acos(pi_plus.Vect().Dot(pi_minus.Vect()) / (pi_plus.P() * pi_minus.P())));
937  }
938 
939  double proj_m = taum.Vect().Dot(pi_minus.Vect()) / (taum.P() * taum.P());
940  double proj_p = taup.Vect().Dot(pi_plus.Vect()) / (taup.P() * taup.P());
941  TVector3 Tau_m = taum.Vect();
942  TVector3 Tau_p = taup.Vect();
943  Tau_m *= proj_m;
944  Tau_p *= proj_p;
945  TVector3 Pit_m = pi_minus.Vect() - Tau_m;
946  TVector3 Pit_p = pi_plus.Vect() - Tau_p;
947 
948  double Acoplanarity = acos(Pit_m.Dot(Pit_p) / (Pit_p.Mag() * Pit_m.Mag()));
949  TVector3 n = Pit_p.Cross(Pit_m);
950  if (n.Dot(Tau_m) / Tau_m.Mag() > 0) {
951  Acoplanarity *= -1;
952  Acoplanarity += 2 * TMath::Pi();
953  }
954  // fill histograms
955  if (abs(boson->pdgId()) == PdtPdgMini::Higgs0)
957  taup = tauporig;
958  taum = taumorig;
959  }
960  if (nSinglePionDecays == 2 && tautau.M() != 0) {
961  for (int i = 0; i < zsbins; i++) {
962  double zslow = ((double)i) * (zsmax - zsmin) / ((double)zsbins) + zsmin;
963  double zsup = ((double)i + 1) * (zsmax - zsmin) / ((double)zsbins) + zsmin;
964  double aup = Zstoa(zsup), alow = Zstoa(zslow);
965  if (x2 - x1 > alow && x2 - x1 < aup) {
966  double zs = (zsup + zslow) / 2;
967  if (abs(boson->pdgId()) == PdtPdgMini::Z0)
969  if (abs(boson->pdgId()) == PdtPdgMini::Higgs0)
971  break;
972  }
973  }
974  if (abs(boson->pdgId()) == PdtPdgMini::Z0)
975  TauSpinEffectsZ_MVis->Fill(pipi.M() / tautau.M(), weight);
976  if (abs(boson->pdgId()) == PdtPdgMini::Higgs0)
977  TauSpinEffectsH_MVis->Fill(pipi.M() / tautau.M(), weight);
978 
979  if (x1 != 0) {
980  const std::vector<const reco::GenParticle *> m = GetMothers(boson);
981  int q(0), qbar(0);
982  TLorentzVector Z(0, 0, 0, 0);
983  for (unsigned int i = 0; i < m.size(); i++) {
984  if (m.at(i)->pdgId() == PdtPdgMini::d || m.at(i)->pdgId() == PdtPdgMini::u) {
985  q++;
986  }
987  if (m.at(i)->pdgId() == PdtPdgMini::anti_d || m.at(i)->pdgId() == PdtPdgMini::anti_u) {
988  qbar++;
989  }
990  }
991  if (q == 1 && qbar == 1) { // assume q has largest E (valence vs see quarks)
992  if (taum.Vect().Dot(Zboson.Vect()) / (Zboson.P() * taum.P()) > 0) {
993  if (abs(boson->pdgId()) == PdtPdgMini::Z0)
995  if (abs(boson->pdgId()) == PdtPdgMini::Higgs0)
997  } else {
998  if (abs(boson->pdgId()) == PdtPdgMini::Z0)
1000  if (abs(boson->pdgId()) == PdtPdgMini::Higgs0)
1002  }
1003  }
1004  }
1005  }
1006  }
1007 }
1008 
1009 double TauValidation::Zstoa(double zs) {
1010  double a = 1 - sqrt(fabs(1.0 - 2 * fabs(zs)));
1011  if (zs < 0) {
1012  a *= -1.0;
1013  }
1014  return a;
1015 }
1016 
1018  return leadingPionP4(tau).P();
1019 }
1020 
1022  TLorentzVector p4(0, 0, 0, 0);
1023  for (unsigned int i = 0; i < tau->numberOfDaughters(); i++) {
1024  const reco::GenParticle *dau = static_cast<const reco::GenParticle *>(tau->daughter(i));
1025  int pid = dau->pdgId();
1026  if (abs(pid) == 15)
1027  return leadingPionP4(dau);
1028  if (!(abs(pid) == 211 || abs(pid) == 13 || abs(pid) == 11))
1029  continue;
1030  if (dau->p() > p4.P())
1031  p4 = TLorentzVector(dau->px(), dau->py(), dau->pz(), dau->energy());
1032  }
1033  return p4;
1034 }
1035 
1037  const reco::GenParticle *m = GetMother(tau);
1038  return TLorentzVector(m->px(), m->py(), m->pz(), m->energy());
1039 }
1040 
1042  TLorentzVector p4(tau->px(), tau->py(), tau->pz(), tau->energy());
1043  for (unsigned int i = 0; i < tau->numberOfDaughters(); i++) {
1044  const reco::GenParticle *dau = static_cast<const reco::GenParticle *>(tau->daughter(i));
1045  int pid = dau->pdgId();
1046  if (abs(pid) == 15)
1047  return visibleTauEnergy(dau);
1048  if (abs(pid) == 12 || abs(pid) == 14 || abs(pid) == 16) {
1049  p4 -= TLorentzVector(dau->px(), dau->py(), dau->pz(), dau->energy());
1050  }
1051  }
1052  return p4.E();
1053 }
1054 
1056  // Find First tau in chain
1057  std::vector<const reco::GenParticle *> TauList;
1058  findTauList(tau, TauList);
1059 
1060  // Get List of Gauge Boson to tau(s) FSR and Brem
1061  bool passedW = false;
1062  std::vector<const reco::GenParticle *> ListofFSR;
1063  ListofFSR.clear();
1064  std::vector<const reco::GenParticle *> ListofBrem;
1065  ListofBrem.clear();
1066  std::vector<const reco::GenParticle *> FSR_photos;
1067  FSR_photos.clear();
1068  double BosonScale(1);
1069  if (!TauList.empty()) {
1070  TauValidation::findFSRandBrem(TauList.at(0), passedW, ListofFSR, ListofBrem);
1071  TauValidation::FindPhotosFSR(TauList.at(0), FSR_photos, BosonScale);
1072 
1073  // Add the Tau Brem. information
1074  TauBremPhotonsN->Fill(ListofBrem.size(), weight);
1075  double photonPtSum = 0;
1076  for (unsigned int i = 0; i < ListofBrem.size(); i++) {
1077  photonPtSum += ListofBrem.at(i)->pt();
1078  TauBremPhotonsPt->Fill(ListofBrem.at(i)->pt(), weight);
1079  }
1080  TauBremPhotonsPtSum->Fill(photonPtSum, weight);
1081 
1082  // Now add the Gauge Boson FSR information
1083  if (BosonScale != 0) {
1084  TauFSRPhotonsN->Fill(ListofFSR.size(), weight);
1085  photonPtSum = 0;
1086  for (unsigned int i = 0; i < ListofFSR.size(); i++) {
1087  photonPtSum += ListofFSR.at(i)->pt();
1088  TauFSRPhotonsPt->Fill(ListofFSR.at(i)->pt(), weight);
1089  }
1090  double FSR_photosSum(0);
1091  for (unsigned int i = 0; i < FSR_photos.size(); i++) {
1092  FSR_photosSum += FSR_photos.at(i)->pt();
1093  TauFSRPhotonsPt->Fill(FSR_photos.at(i)->pt() / BosonScale, weight * BosonScale);
1094  }
1095  TauFSRPhotonsPtSum->Fill(photonPtSum + FSR_photosSum / BosonScale, weight);
1096  }
1097  }
1098 }
MonitorElement * TauFSRPhotonsN
Definition: TauValidation.h:81
const double Pi
void findFSRandBrem(const reco::GenParticle *p, bool doBrem, std::vector< const reco::GenParticle *> &ListofFSR, std::vector< const reco::GenParticle *> &ListofBrem)
int findMother(const reco::GenParticle *)
MonitorElement * TauSpinEffectsH_rhorhoAcoplanarityplus
Definition: TauValidation.h:81
MonitorElement * TauPhi
Definition: TauValidation.h:81
MonitorElement * TauSpinEffectsW_X
Definition: TauValidation.h:81
double pz() const final
z coordinate of momentum vector
const Candidate * mother(size_type=0) const override
return mother at a given position, i = 0, ... numberOfMothers() - 1 (read only mode) ...
MonitorElement * TauSpinEffectsHpm_UpsilonA1
Definition: TauValidation.h:81
MonitorElement * MODEID
Definition: TauValidation.h:94
MonitorElement * TauSpinEffectsZ_Xb
Definition: TauValidation.h:81
MonitorElement * nTaus
Definition: TauValidation.h:80
MonitorElement * DecayLength
Definition: TauValidation.h:81
std::vector< std::vector< MonitorElement * > > MODEInvMass
Definition: TauValidation.h:95
TauValidation(const edm::ParameterSet &)
MonitorElement * TauPt
Definition: TauValidation.h:81
~TauValidation() override
MonitorElement * TauSpinEffectsH_MVis
Definition: TauValidation.h:81
MonitorElement * TauMothers
Definition: TauValidation.h:81
MonitorElement * TauSpinEffectsHpm_eX
Definition: TauValidation.h:81
MonitorElement * TauSpinEffectsZ_X100to120
Definition: TauValidation.h:81
size_t numberOfDaughters() const override
number of daughters
MonitorElement * TauSpinEffectsW_muX
Definition: TauValidation.h:81
MonitorElement * TauBremPhotonsN
Definition: TauValidation.h:81
void findTauList(const reco::GenParticle *tau, std::vector< const reco::GenParticle *> &TauList)
MonitorElement * TauSpinEffectsZ_Xf
Definition: TauValidation.h:81
bool isLastTauinChain(const reco::GenParticle *tau)
Definition: weight.py:1
edm::ESGetToken< HepPDT::ParticleDataTable, edm::DefaultRecord > fPDGTableToken
Definition: TauValidation.h:78
MonitorElement * TauBremPhotonsPtSum
Definition: TauValidation.h:81
MonitorElement * TauSpinEffectsH_pipiAcoplanarity
Definition: TauValidation.h:81
size_t numberOfMothers() const override
number of mothers
MonitorElement * TauSpinEffectsHpm_UpsilonRho
Definition: TauValidation.h:81
double leadingPionMomentum(const reco::GenParticle *, double weight)
static std::string to_string(const XMLCh *ch)
MonitorElement * TauSpinEffectsZ_eX
Definition: TauValidation.h:81
MonitorElement * TauProngs
Definition: TauValidation.h:81
TLorentzVector motherP4(const reco::GenParticle *)
int pdgId() const final
PDG identifier.
bool isTauFinalStateParticle(int pdgid)
Definition: TauDecay.cc:32
void dqmBeginRun(const edm::Run &r, const edm::EventSetup &c) override
void Fill(long long x)
MonitorElement * TauSpinEffectsH_pipiAcollinearityzoom
Definition: TauValidation.h:81
char const * label
void photons(const reco::GenParticle *, double weight)
double px() const final
x coordinate of momentum vector
int iEvent
Definition: GenABIO.cc:224
MonitorElement * TauSpinEffectsW_UpsilonRho
Definition: TauValidation.h:81
const reco::GenParticle * GetMother(const reco::GenParticle *tau)
MonitorElement * TauSpinEffectsZ_X88to100
Definition: TauValidation.h:81
double p() const final
magnitude of momentum vector
MonitorElement * TauSpinEffectsH_rhorhoAcoplanarityminus
Definition: TauValidation.h:81
void analyze(edm::Event const &, edm::EventSetup const &) override
MonitorElement * TauSpinEffectsZ_X50to75
Definition: TauValidation.h:81
T sqrt(T t)
Definition: SSEVec.h:23
MonitorElement * TauSpinEffectsH_Xf
Definition: TauValidation.h:81
MonitorElement * TauFSRPhotonsPt
Definition: TauValidation.h:81
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
MonitorElement * TauSpinEffectsZ_muX
Definition: TauValidation.h:81
MonitorElement * TauDecayChannels
Definition: TauValidation.h:81
double py() const final
y coordinate of momentum vector
virtual 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)
MonitorElement * TauSpinEffectsH_Zs
Definition: TauValidation.h:81
unsigned int NMODEID
Definition: TauValidation.h:93
MonitorElement * TauFSRPhotonsPtSum
Definition: TauValidation.h:81
HepPDT::ParticleData ParticleData
int tauMother(const reco::GenParticle *, double weight)
std::vector< const reco::GenParticle * > Get_TauDecayProducts()
void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
const std::vector< const reco::GenParticle * > GetMothers(const reco::GenParticle *boson)
MonitorElement * TauSpinEffectsZ_MVis
Definition: TauValidation.h:81
void FindPhotosFSR(const reco::GenParticle *p, std::vector< const reco::GenParticle *> &ListofFSR, double &BosonScale)
MonitorElement * TauSpinEffectsZ_X75to88
Definition: TauValidation.h:81
double visibleTauEnergy(const reco::GenParticle *)
static std::string DecayMode(unsigned int &MODE_ID)
Definition: TauDecay.cc:393
int tauDecayChannel(const reco::GenParticle *tau, int jak_id, unsigned int TauBitMask, double weight)
MonitorElement * TauSpinEffectsH_pipiAcollinearity
Definition: TauValidation.h:81
part
Definition: HCALResponse.h:20
MonitorElement * TauSpinEffectsZ_X
Definition: TauValidation.h:81
edm::ESHandle< HepPDT::ParticleDataTable > fPDGTable
PDT table.
Definition: TauValidation.h:77
MonitorElement * TauSpinEffectsH_eX
Definition: TauValidation.h:81
MonitorElement * TauSpinEffectsW_eX
Definition: TauValidation.h:81
edm::EDGetTokenT< reco::GenParticleCollection > genparticleCollectionToken_
double Zstoa(double zs)
MonitorElement * LifeTime
Definition: TauValidation.h:81
HLT enums.
MonitorElement * TauSpinEffectsH_muX
Definition: TauValidation.h:81
reco::Particle::LorentzVector LV
MonitorElement * TauSpinEffectsW_UpsilonA1
Definition: TauValidation.h:81
double a
Definition: hdecay.h:121
void countParticles(const reco::GenParticle *p, int &allCount, int &eCount, int &muCount, int &pi0Count, int &piCount, int &rhoCount, int &a1Count, int &KCount, int &KstarCount)
MonitorElement * TauEta
Definition: TauValidation.h:81
edm::InputTag genparticleCollection_
Definition: TauValidation.h:74
MonitorElement * TauSpinEffectsZ_Zs
Definition: TauValidation.h:81
MonitorElement * TauSpinEffectsHpm_X
Definition: TauValidation.h:81
void spinEffectsWHpm(const reco::GenParticle *, int, int, std::vector< const reco::GenParticle *> &part, double weight)
MonitorElement * TauSpinEffectsHpm_muX
Definition: TauValidation.h:81
bool AnalyzeTau(const reco::GenParticle *Tau, unsigned int &MODE_ID, unsigned int &TauBitMask, bool dores, bool dopi0)
tmp
align.sh
Definition: createJobs.py:716
MonitorElement * TauSpinEffectsZ_X120UP
Definition: TauValidation.h:81
Definition: DQMStore.h:18
MonitorElement * TauSpinEffectsH_Xb
Definition: TauValidation.h:81
Definition: PV.py:1
MonitorElement * nPrimeTaus
Definition: TauValidation.h:80
MonitorElement * TauBremPhotonsPt
Definition: TauValidation.h:81
void spinEffectsZH(const reco::GenParticle *boson, double weight)
const Candidate * daughter(size_type) const override
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
Definition: Run.h:45
unsigned int nProng(unsigned int &TauBitMask)
Definition: TauDecay.cc:331
MonitorElement * TauSpinEffectsH_X
Definition: TauValidation.h:81
TLorentzVector leadingPionP4(const reco::GenParticle *)
double energy() const final
energy