Belle II Software development
TauDecayModeModule.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <analysis/modules/TauDecayMode/TauDecayModeModule.h>
10#include <framework/logging/Logger.h>
11#include <framework/particledb/EvtGenDatabasePDG.h>
12#include <vector>
13#include <algorithm>
14#include <TParticlePDG.h>
15#include <map>
16#include <fstream>
17#include <Math/LorentzRotation.h>
18#include <Math/Boost.h>
19using namespace std;
20using namespace Belle2;
21
22std::map<std::string, int> make_map(const std::string& file, int chg)
23{
24 std::string fileName;
25 if (file == "") {
26 if (chg < 0) {
27 B2INFO("Missing input mapping file: use mp_file_minus=basf2.find_file('data/analysis/modules/TauDecayMode/map_tauminus.txt') TauDecayMode.param('file_minus', mp_file_minus) to classify with default mapping.");
28 } else {
29 B2INFO("Missing input mapping file: use mp_file_plus=basf2.find_file('data/analysis/modules/TauDecayMode/map_tauplus.txt') TauDecayMode.param('file_plus', mp_file_plus) to classify with default mapping.");
30 }
31 } else {
32 fileName = file;
33 }
34
35 ifstream f;
36 f.open(fileName);
37 std::string line;
38 std::string key;
39 int value;
40 std::map <std::string, int> map_tau;
41 while (f.good()) {
42 getline(f, line);
43 istringstream ss(line);
44 ss >> key >> value;
45 map_tau[key] = value;
46 }
47 f.close();
48 return map_tau;
49}
50
51//-----------------------------------------------------------------
52// Register the Module
53//-----------------------------------------------------------------
54REG_MODULE(TauDecayMode);
55//-----------------------------------------------------------------
56// Implementation
57//-----------------------------------------------------------------
58
61 m_pmode(-2), m_mprong(0), m_pprong(0), m_megstar(0), m_pegstar(0), tauPair(false),
66{
67 // Set module properties
68 setDescription("Module to identify generated tau pair decays, using MCParticle information.\n"
69 "By default, each tau decay is numbered as TauolaBelle2DecayMode [Ref: BELLE2-NOTE-PH-2020-055]");
70 //Parameter definition
71 addParam("printmode", m_printmode, "Printout more information from each event", std::string("default"));
72 addParam("file_minus", m_file_minus, "Path for an alternative mapping for tau- decays", std::string(""));
73 addParam("file_plus", m_file_plus, "Path for an alternative mapping for tau+ decays", std::string(""));
74}
75
76//
78{
79 mode_decay_minus = make_map(m_file_minus, -1);
80 mode_decay_plus = make_map(m_file_plus, 1);
81 m_tauDecay.registerInDataStore();
82 m_event_metadata.isRequired();
83}
84
85//
87{
88
90 if (tauPair) {
91
93
94 if (m_printmode == "missing") {
95 if (m_mmode == -1) {
96 B2INFO("TauDecayMode:: EventNumber = " << m_event_metadata->getEvent()
97 << " Decay: tau- -> " << m_tauminusdecaymode << " Mode = " << m_mmode);
98 }
99 if (m_pmode == -1) {
100 B2INFO("TauDecayMode:: EventNumber = " << m_event_metadata->getEvent()
101 << " Decay: tau+ -> " << m_tauplusdecaymode << " Mode = " << m_pmode);
102 }
103 }
104
105 if (m_printmode == "all") {
106 B2INFO("TauDecayMode:: EventNumber = " << m_event_metadata->getEvent()
107 << " Decay: tau- -> " << m_tauminusdecaymode << " Mode = " << m_mmode);
108 B2INFO("TauDecayMode:: EventNumber = " << m_event_metadata->getEvent()
109 << " Decay: tau+ -> " << m_tauplusdecaymode << " Mode = " << m_pmode);
110 }
111
112 //
113 if (m_mmode == -1) {
114 m_taum_no = m_taum_no - 1;
116 }
117 if (m_pmode == -1) {
118 m_taup_no = m_taup_no - 1;
120 }
121
124
127
128 } else {
129 m_pmode = -1;
130 m_mmode = -1;
131 m_pprong = -1;
132 m_mprong = -1;
133 m_megstar = -1;
134 m_pegstar = -1;
135 }
136
137 if (!m_tauDecay) m_tauDecay.create();
138 m_tauDecay->addTauMinusIdMode(m_mmode);
139 m_tauDecay->addTauPlusIdMode(m_pmode);
140
141 m_tauDecay->addTauPlusMcProng(m_pprong);
142 m_tauDecay->addTauMinusMcProng(m_mprong);
143
144 m_tauDecay->addTauMinusEgstar(m_megstar);
145 m_tauDecay->addTauPlusEgstar(m_pegstar);
146}
147
149{
150 // Clear local vectors
151 vec_radgam_taum.clear();
152 vec_radgam_taup.clear();
153 //
154 // One (initially empty) vector of particle indices per PDG code
155 map<int, std::vector<int>> map_vec;
156 for (int pdg : {
157 11, -11, 12, -12, 13, -13, 14, -14,
158 16, -16, -211, 211, -321, 321, -2212, 2212,
159 111, 310, 130, 221, 223, 331, 333, -213,
160 213, 113, -323, 323, 313, -313, -20213, 20213,
161 -9000211, 9000211, 9000111, -10211, 10211, 10111, -10213, 10213,
162 20223, 9010221, 3122, -3122, 94144, 22
163 })
164 map_vec[pdg];
165
166 bool TauMinusIsLeptonicDecay = false;
167 bool TauPlusIsLeptonicDecay = false;
168
169 bool elecFirst = true;
170 bool muonFirst = true;
171
172 bool isPiPizGamTauMinusFirst = true;
173 bool isPiPizGamTauPlusFirst = true;
174
175 bool isPiGamTauMinusFirst = true;
176 bool isPiGamTauPlusFirst = true;
177
178 bool isLFVTauMinus2BodyDecayFirst = true;
179 bool isLFVTauPlus2BodyDecayFirst = true;
180
181 bool isChargedRhoFromTauMinusFirst = true;
182 bool isChargedRhoFromTauPlusFirst = true;
183
184 bool isChargedA1FromTauMinusFirst = true;
185 bool isChargedA1FromTauPlusFirst = true;
186
187 bool isEtaPPGFromTauMinusFirst = true;
188 bool isEtaPPGFromTauPlusFirst = true;
189
190 bool isOmegaPizGamFromTauMinusFirst = true;
191 bool isOmegaPizGamFromTauPlusFirst = true;
192
193 bool isEtaPizPizPizFromTauMinusFirst = true;
194 bool isEtaPizPizPizFromTauPlusFirst = true;
195
198
199 bool isOmegaPimPipFromTauMinusFirst = true;
200 bool isOmegaPimPipFromTauPlusFirst = true;
201
204
205 // Loop of MCParticles
206 for (int i = 0; i < MCParticles.getEntries(); i++) {
207
208 const MCParticle& p = *MCParticles[i];
209
210 int pdgid = p.getPDG();
211
212 if (pdgid == -Const::Klong.getPDGCode()) pdgid = -pdgid; // Strange feature in TauolaBelle2
213
214 // Special treatment for photons
215 bool accept_photon = false;
216
217 if (!p.hasStatus(MCParticle::c_PrimaryParticle))
218 continue; // only consider particles coming from generator, e.g. discard particles added by Geant4
219 if (p.isInitial()) continue; // pick e- e+, but not from the incoming beams
220
221 // Check IsLeptonicDecay first
222 if (abs(pdgid) == 12 || abs(pdgid) == 14) { // (anti-)nu_e or (anti-)nu_mu
223 int leptonicdecay = 0;
224 const MCParticle* mother = p.getMother(); // tau- or tau+
225 const vector<MCParticle*> daughters = mother->getDaughters();
226 for (const MCParticle* d : daughters) {
227 int dauid = abs(d->getPDG());
228 if (dauid == 11 || dauid == 12 || dauid == 13 || dauid == 14 || dauid == 16) {
229 leptonicdecay++;
230 }
231 }
232 if (leptonicdecay == 3) {
233 if (mother->getPDG() == 15) TauMinusIsLeptonicDecay = true;
234 if (mother->getPDG() == -15) TauPlusIsLeptonicDecay = true;
235 }
236 }
237
238 else if (pdgid == Const::electron.getPDGCode() && elecFirst) {
239 elecFirst = false;
240 const MCParticle* mother = p.getMother();
241 if (not mother) continue; // In some low multiplicity generators there may be no mother
242 const vector<MCParticle*> daughters = mother->getDaughters();
243 int nElMinus = 0;
244 int nElPlus = 0;
245 stringstream elec_ss;
246 for (const MCParticle* d : daughters) {
247 if (!d->hasStatus(MCParticle::c_PrimaryParticle)) continue;
248 elec_ss << d->getPDG() << " ";
249 if (d->getPDG() == Const::electron.getPDGCode()) nElMinus++;
250 if (d->getPDG() == -Const::electron.getPDGCode()) nElPlus++;
251 }
252 if (nElMinus == 1 && nElPlus == 1) { // use this information in getRecursiveMotherCharge
253 B2DEBUG(19, "Mother of elec pair is = " << mother->getPDG() << " which has daughters : " << elec_ss.str());
254 }
255 }
256
257 else if (pdgid == Const::muon.getPDGCode() && muonFirst) {
258 muonFirst = false;
259 const MCParticle* mother = p.getMother();
260 if (not mother) continue; // In some low multiplicity generators there may be no mother
261 const vector<MCParticle*> daughters = mother->getDaughters();
262 int nMuMinus = 0;
263 int nMuPlus = 0;
264 stringstream muon_ss;
265 for (const MCParticle* d : daughters) {
266 if (!d->hasStatus(MCParticle::c_PrimaryParticle)) continue;
267 muon_ss << d->getPDG() << " ";
268 if (d->getPDG() == Const::muon.getPDGCode()) nMuMinus++;
269 if (d->getPDG() == -Const::muon.getPDGCode()) nMuPlus++;
270 }
271 if (nMuMinus == 1 && nMuPlus == 1) { // use this information in getRecursiveMotherCharge
272 B2DEBUG(19, "Mother of muon pair is = " << mother->getPDG() << " which has daughters : " << muon_ss.str());
273 }
274 }
275
276 // Photons from PHOTOS are radiative photons
277 else if (pdgid == Const::photon.getPDGCode() && p.hasStatus(MCParticle::c_IsPHOTOSPhoton)) {
279 if (chg < 0) vec_radgam_taum.push_back(i);
280 if (chg > 0) vec_radgam_taup.push_back(i);
281 }
282
283 // Photons from PHOTOS do not define tau decay mode
284 else if (pdgid == Const::photon.getPDGCode() && !p.hasStatus(MCParticle::c_IsPHOTOSPhoton)) {
285 const MCParticle* mother = p.getMother();
286 if (not mother) continue; // In some low multiplicity generators there may be no mother
287 int mothid = abs(mother->getPDG());
288
289 // check if the gamma comes from final state charged particles {e, mu, pi, K, p, b_1}
290 bool isRadiationfromFinalStateChargedParticle = false;
291 if (mothid == 11 ||
292 mothid == 13 ||
293 mothid == 211 ||
294 mothid == 321 ||
295 mothid == 2212 ||
296 mothid == 10213) {
297 isRadiationfromFinalStateChargedParticle = true;
298 }
299
300 // check if the gamma from ChargedRho
301 bool isRadiationFromChargedRho = false;
302 if (mothid == 213) {
303 int chg = getRecursiveMotherCharge(mother);
304 if (chg < 0 && isChargedRhoFromTauMinusFirst) {
305 isChargedRhoFromTauMinusFirst = false;
306 isRadiationFromChargedRho = true;
307 }
308 if (chg > 0 && isChargedRhoFromTauPlusFirst) {
309 isChargedRhoFromTauPlusFirst = false;
310 isRadiationFromChargedRho = true;
311 }
312 }
313
314 // check if the gamma from ChargedA1
315 bool isRadiationFromChargedA1 = false;
316 if (mothid == 20213) {
317 int chg = getRecursiveMotherCharge(mother);
318 if (chg < 0 && isChargedA1FromTauMinusFirst) {
319 isChargedA1FromTauMinusFirst = false;
320 isRadiationFromChargedA1 = true;
321 }
322 if (chg > 0 && isChargedA1FromTauPlusFirst) {
323 isChargedA1FromTauPlusFirst = false;
324 isRadiationFromChargedA1 = true;
325 }
326 }
327
328 // check if the gamma comes from intermediate W+- boson
329 bool isRadiationfromIntermediateWBoson = false;
330 if (mothid == 24) isRadiationfromIntermediateWBoson = true;
331
332 // check if it is a tau- -> pi- omega nu, omega -> pi0 gamma decay
333 // Note: TauolaBelle2 generator treats this a coherent production
334 // e.g. includes omega in the form factor but not as an explicit final state particle
335 bool isPiPizGam = false;
336 bool isPiGam = false;
337 if (isRadiationfromIntermediateWBoson) {
338 const vector<MCParticle*> daughters = mother->getDaughters();
339 int nPiSisters = 0;
340 int nPizSisters = 0;
341 int nTotSisters = 0;
342 int nOtherSisters = 0;
343 for (const MCParticle* d : daughters) {
344 if (!d->hasStatus(MCParticle::c_PrimaryParticle)) continue;
345 nTotSisters++;
346 if (abs(d->getPDG()) == Const::pion.getPDGCode()) {
347 nPiSisters++;
348 } else if (abs(d->getPDG()) == Const::pi0.getPDGCode()) {
349 nPizSisters++;
350 } else if (abs(d->getPDG()) != Const::photon.getPDGCode()) {
351 nOtherSisters++;
352 }
353 }
354 // allow final state radiation from the tau lepton, but ignore information on number of photons for decay mode classifiction
355 if (nTotSisters >= 3 && nPiSisters == 1 && nPizSisters == 1 && nOtherSisters == 0) {
356 int chg = getRecursiveMotherCharge(mother);
357 if (chg < 0 && isPiPizGamTauMinusFirst) {
358 isPiPizGamTauMinusFirst = false;
359 isPiPizGam = true;
360 }
361 if (chg > 0 && isPiPizGamTauPlusFirst) {
362 isPiPizGamTauPlusFirst = false;
363 isPiPizGam = true;
364 }
365 } else if (nTotSisters >= 2 && nPiSisters == 1 && nPizSisters == 0 && nOtherSisters == 0) {
366 int chg = getRecursiveMotherCharge(mother);
367 if (chg < 0 && isPiGamTauMinusFirst) {
368 isPiGamTauMinusFirst = false;
369 isPiGam = true;
370 }
371 if (chg > 0 && isPiGamTauPlusFirst) {
372 isPiGamTauPlusFirst = false;
373 isPiGam = true;
374 }
375 }
376 }
377
378 // check if the gamma comes from tau
379 bool isRadiationfromTau = false;
380 if (mothid == 15) isRadiationfromTau = true;
381
382 // Photons from LeptonicTauDecays are radiative photons not added by PHOTOS
383 if (isRadiationfromTau) {
385 if (chg < 0 && TauMinusIsLeptonicDecay) vec_radgam_taum.push_back(i);
386 if (chg > 0 && TauPlusIsLeptonicDecay) vec_radgam_taup.push_back(i);
387 }
388
389 // check if the gamma comes from 2 body LFV decays of tau, e.g. tau- -> e-/mu- gamma with arbitrary number of extra photon radiations from PHOTOS/FSR
390 bool isLFVTau2BodyDecay = false;
391 if (isRadiationfromTau) {
392 bool hasNeutrinoAsSister = false;
393 int numChargedSister = 0;
394 int numNeutralNonNeutrinoNonPhotonSister = 0;
395 const vector<MCParticle*> daughters = mother->getDaughters();
396 for (const MCParticle* d : daughters) {
397 if (!d->hasStatus(MCParticle::c_PrimaryParticle)) continue;
398 hasNeutrinoAsSister = find(Neutrinos.begin(), Neutrinos.end(), abs(d->getPDG())) != Neutrinos.end();
399 if (hasNeutrinoAsSister) break;
400 }
401 if (!hasNeutrinoAsSister) {
402 for (const MCParticle* d : daughters) {
403 if (!d->hasStatus(MCParticle::c_PrimaryParticle)) continue;
404 bool isChargedFinalState = find(finalStatePDGs.begin(), finalStatePDGs.end(), abs(d->getPDG())) != finalStatePDGs.end();
405 if (isChargedFinalState) {
406 numChargedSister++;
407 } else if (d->getPDG() != Const::photon.getPDGCode()) {
408 numNeutralNonNeutrinoNonPhotonSister++;
409 }
410 }
411 if (numChargedSister == 1 && numNeutralNonNeutrinoNonPhotonSister == 0) {
412 if (mother->getPDG() == 15 && isLFVTauMinus2BodyDecayFirst) {
413 isLFVTauMinus2BodyDecayFirst = false;
414 isLFVTau2BodyDecay = true;
415 }
416 if (mother->getPDG() == -15 && isLFVTauPlus2BodyDecayFirst) {
417 isLFVTauPlus2BodyDecayFirst = false;
418 isLFVTau2BodyDecay = true;
419 }
420 }
421 }
422 B2DEBUG(19, "hasNeutrinoAsSister = " << hasNeutrinoAsSister
423 << " numChargedSister = " << numChargedSister
424 << " numNeutralNonNeutrinoNonPhotonSister = " << numNeutralNonNeutrinoNonPhotonSister
425 << " isLFVTau2BodyDecay = " << isLFVTau2BodyDecay);
426 }
427
428 bool isPi0GG = false;
429 bool isEtaGG = false;
430 bool isEtpGG = false;
431 bool isPi0GEE = false;
432 bool isEtaPPG = false;
433 bool isOmPizG = false;
434 if (mothid == 111 || mothid == 221 || mothid == 331 || mothid == 223) {
435 const vector<MCParticle*> daughters = mother->getDaughters();
436 int numberofTotalDaughters = 0;
437 int numberOfPhotonDaughters = 0;
438 int numberOfElectronDaughters = 0;
439 int numberOfPionDaughters = 0;
440 int numberOfPizDaughters = 0;
441 for (const MCParticle* d : daughters) {
442 if (!d->hasStatus(MCParticle::c_PrimaryParticle)) continue;
443 numberofTotalDaughters ++;
444 if (abs(d->getPDG()) == Const::photon.getPDGCode()) numberOfPhotonDaughters++;
445 if (abs(d->getPDG()) == Const::electron.getPDGCode()) numberOfElectronDaughters++;
446 if (abs(d->getPDG()) == Const::pion.getPDGCode()) numberOfPionDaughters++;
447 if (abs(d->getPDG()) == Const::pi0.getPDGCode()) numberOfPizDaughters++;
448 }
449 if (numberofTotalDaughters == 2 && numberOfPhotonDaughters == 2) {
450 if (mothid == Const::pi0.getPDGCode()) isPi0GG = true;
451 if (mothid == 221) isEtaGG = true;
452 if (mothid == 331) isEtpGG = true;
453 }
454 if (numberofTotalDaughters >= 3 && numberOfPhotonDaughters >= 1 && numberOfElectronDaughters == 2 && numberOfPionDaughters == 0
455 && numberOfPizDaughters == 0) {
456 if (mothid == Const::pi0.getPDGCode()) isPi0GEE = true;
457 }
458 if (numberofTotalDaughters >= 3 && numberOfPhotonDaughters >= 1 && numberOfPizDaughters == 0 && numberOfPionDaughters == 2) {
459 if (mothid == 221) {
460 int chg = getRecursiveMotherCharge(mother);
461 if (chg < 0 && isEtaPPGFromTauMinusFirst) {
462 isEtaPPGFromTauMinusFirst = false;
463 isEtaPPG = true;
464 }
465 if (chg > 0 && isEtaPPGFromTauPlusFirst) {
466 isEtaPPGFromTauPlusFirst = false;
467 isEtaPPG = true;
468 }
469 }
470 }
471 if (numberofTotalDaughters >= 2 && numberOfPhotonDaughters >= 1 && numberOfPizDaughters == 1 && numberOfPionDaughters == 0) {
472 if (mothid == 223) {
473 int chg = getRecursiveMotherCharge(mother);
474 if (chg < 0 && isOmegaPizGamFromTauMinusFirst) {
475 isOmegaPizGamFromTauMinusFirst = false;
476 isOmPizG = true;
477 }
478 if (chg > 0 && isOmegaPizGamFromTauPlusFirst) {
479 isOmegaPizGamFromTauPlusFirst = false;
480 isOmPizG = true;
481 }
482 }
483 }
484 }
485
486 B2DEBUG(19, "isRadiationfromFinalStateChargedParticle = " << isRadiationfromFinalStateChargedParticle);
487 B2DEBUG(19, "isRadiationFromChargedRho = " << isRadiationFromChargedRho);
488 B2DEBUG(19, "isRadiationFromChargedA1 = " << isRadiationFromChargedA1);
489 B2DEBUG(19, "isRadiationfromIntermediateWBoson = " << isRadiationfromIntermediateWBoson << " isPiPizGam = " << isPiPizGam <<
490 " isPiGam = " << isPiGam);
491 B2DEBUG(19, "isRadiationfromTau = " << isRadiationfromTau << " isLFVTau2BodyDecay = " << isLFVTau2BodyDecay);
492 B2DEBUG(19, "isPi0GG = " << isPi0GG << " isEtaGG = " << isEtaGG << " isEtpGG = " << isEtpGG << " isPi0GEE = " << isPi0GEE);
493 B2DEBUG(19, "isEtaPPG = " << isEtaPPG << " isOmPizG = " << isOmPizG);
494
495 // accept photons if (isRadiationfromFinalStateChargedParticle is false) or
496 // if (isRadiationfromIntermediateWBoson is false) or
497 // if (isRadiationfromTau is true) {gamma is from 2 body LFV decays of tau} or
498 // if the radiation is coming from any other decay [except pi0 -> gamma gamma, eta-> gamma gamma, eta' -> gamma gamma]
499 if (isRadiationfromFinalStateChargedParticle) {
500 } else if (isRadiationFromChargedRho) {
501 accept_photon = true;
502 } else if (isRadiationFromChargedA1) {
503 accept_photon = true;
504 } else if (isRadiationfromIntermediateWBoson) {
505 if (isPiPizGam || isPiGam) {
506 accept_photon = true;
507 }
508 } else if (isRadiationfromTau) { // accept one photon from tau -> (charged particle) + gamma [no neutrinos]
509 if (isLFVTau2BodyDecay) {
510 accept_photon = true;
511 }
512 } else if (isPi0GG) {
513 } else if (isEtaGG) {
514 } else if (isEtpGG) {
515 } else if (isPi0GEE) {
516 } else if (isEtaPPG) {
517 accept_photon = true;
518 } else if (isOmPizG) {
519 accept_photon = true;
520 }
521 }
522
523 // Without further analysis, it is NOT possible to separate
524 // tau- -> pi- 2pi0 eta (-> pi- pi+ pi0) nu decays [Mode 39] from
525 // tau- -> 2pi- pi+ eta (-> pi0 pi0 pi0) nu decays [Mode 42]
526
527 else if (pdgid == Const::pi0.getPDGCode() && (isEtaPizPizPizFromTauMinusFirst || isEtaPizPizPizFromTauPlusFirst)) {
528 const MCParticle* mother = p.getMother();
529 // In some low multiplicity generators there may be no mother
530 if (mother and (mother->getPDG() == 221)) { // eta -> pi0 pi0 pi0
531 const vector<MCParticle*> daughters = mother->getDaughters();
532 int nPizSisters = 0;
533 for (const MCParticle* d : daughters) {
534 if (!d->hasStatus(MCParticle::c_PrimaryParticle)) continue;
535 if (d->getPDG() == Const::pi0.getPDGCode()) nPizSisters++;
536 }
537 B2DEBUG(19, "nPizSisters = " << nPizSisters);
538 if (nPizSisters == 3) {
539 int chg = getRecursiveMotherCharge(mother);
540 if (chg < 0 && isEtaPizPizPizFromTauMinusFirst) {
541 isEtaPizPizPizFromTauMinusFirst = false;
543 }
544 if (chg > 0 && isEtaPizPizPizFromTauPlusFirst) {
545 isEtaPizPizPizFromTauPlusFirst = false;
547 }
548 }
549 }
550 }
551
552 // Without further analysis, it is NOT possible to separate
553 // tau- -> pi- 2pi0 omega (-> pi- pi+) nu decays [Mode 49] from
554 // tau- -> 2pi- pi+ 2pi0 nu decays [Mode 66]
555 // Note: TauolaBelle2 treats Mode 66 is coherent production,
556 // e.g. includes omega in the form factor but not as an explicit final state particle.
557 // Note2: omega is explicitly included in following mode:
558 // tau- -> pi- pi0 omega (-> pi- pi+ pi0) nu decays [Mode 130]
559 // which is where Mode 49 is mapped to if there is no omega->pi-pi+ decay
560
561 // Same confusion can also happen for
562 // tau- -> pi- pi0 omega (-> pi- pi+) nu decays [Mode 131]
563 // tau- -> pi- omega (-> pi- pi+ pi0) nu decays [Mode 236]
564
565 else if (pdgid == -Const::pion.getPDGCode() && (isOmegaPimPipFromTauMinusFirst || isOmegaPimPipFromTauPlusFirst)) {
566 const MCParticle* mother = p.getMother();
567 // In some low multiplicity generators there may be no mother
568 if (mother and (mother->getPDG() == 223)) { // omega -> pi- pi+
569 const vector<MCParticle*> daughters = mother->getDaughters();
570 int nOmegaDaughters = 0;
571 int nPimSisters = 0;
572 int nPipSisters = 0;
573 int nPizSisters = 0;
574 for (const MCParticle* d : daughters) {
575 if (!d->hasStatus(MCParticle::c_PrimaryParticle)) continue;
576 nOmegaDaughters++;
577 if (d->getPDG() == -Const::pion.getPDGCode()) nPimSisters++;
578 if (d->getPDG() == Const::pion.getPDGCode()) nPipSisters++;
579 if (d->getPDG() == Const::pi0.getPDGCode()) nPizSisters++;
580 }
581 B2DEBUG(19,
582 "nOmegaDaughters = " << nOmegaDaughters << " "
583 "nPimSisters = " << nPimSisters << " "
584 "nPipSisters = " << nPipSisters << " "
585 "nPizSisters = " << nPizSisters);
586 if (nOmegaDaughters >= 2 && nPimSisters == 1 && nPipSisters == 1 && nPizSisters == 0) { // allow omega->pi-pi+gama
587 int chg = getRecursiveMotherCharge(mother);
588 if (chg < 0 && isOmegaPimPipFromTauMinusFirst) {
589 isOmegaPimPipFromTauMinusFirst = false;
591 }
592 if (chg > 0 && isOmegaPimPipFromTauPlusFirst) {
593 isOmegaPimPipFromTauPlusFirst = false;
595 }
596 }
597 }
598 }
599 B2DEBUG(19,
600 "isEtaPizPizPizFromTauMinusFirst = " << isEtaPizPizPizFromTauMinusFirst << " "
601 "m_isEtaPizPizPizFromTauMinus = " << m_isEtaPizPizPizFromTauMinus << " "
602 "isEtaPizPizPizFromTauPlusFirst = " << isEtaPizPizPizFromTauPlusFirst << " "
603 "m_isEtaPizPizPizFromTauPlus = " << m_isEtaPizPizPizFromTauPlus
604 );
605 B2DEBUG(19,
606 "isOmegaPimPipFromTauMinusFirst = " << isOmegaPimPipFromTauMinusFirst << " "
607 "m_isOmegaPimPipFromTauMinus = " << m_isOmegaPimPipFromTauMinus << " "
608 "isOmegaPimPipFromTauPlusFirst = " << isOmegaPimPipFromTauPlusFirst << " "
609 "m_isOmegaPimPipFromTauPlus = " << m_isEtaPizPizPizFromTauPlus
610 );
611
612 // Fill up all the vector of particles
613 map<int, std::vector<int>>::iterator ite ;
614 for (ite = map_vec.begin(); ite != map_vec.end(); ++ite) {
615 if (pdgid == ite->first) {
616 if (pdgid == Const::photon.getPDGCode()) {
617 if (accept_photon) {
618 B2DEBUG(19, "Photon accepted");
619 ite-> second.push_back(i);
620 }
621 } else {
622 ite-> second.push_back(i);
623 }
624 break;
625 }
626 }
627
628 } // End of loop over MCParticles
629
630 vec_dau_tauminus.clear();
631 vec_dau_tauplus.clear();
632
633 map<int, std::vector<int>>::iterator itr ;
634 for (itr = map_vec.begin(); itr != map_vec.end(); ++itr) {
635 for (unsigned int i = 0; i < itr-> second.size(); i++) {
636 int ii = itr-> second[i];
638 if (chg < 0) vec_dau_tauminus.push_back(ii);
639 if (chg > 0) vec_dau_tauplus.push_back(ii);
640 }
641 }
642
644 std::string pdgname;
645
646 //make decay string for tau-
648 for (unsigned iorder = 0; iorder < OrderedList.size(); ++iorder) {
649 int ii = OrderedList[iorder];
650 //
651 for (unsigned int i = 0; i < vec_dau_tauminus.size(); i++) {
653 int pdg = p->getPDG();
654 if (pdg == -Const::Klong.getPDGCode()) pdg = -pdg; // Strange Feature in TauolaBelle2
655 if (pdg != ii) continue;
656 m_tauminusdecaymode.append(".");
657 if (pdg == 94144) {
658 pdgname = "alpha";
659 } else {
660 pdgname = databasePDG->GetParticle(pdg)->GetName();
661 }
662 m_tauminusdecaymode.append(pdgname);
663 }
664 }
665 //
667
668 //make decay string for tau+
670 for (unsigned iorder = 0; iorder < OrderedList.size(); ++iorder) {
671 int ii = OrderedList[iorder];
672 //
673 for (unsigned int i = 0; i < vec_dau_tauplus.size(); i++) {
675 int pdg = p->getPDG();
676 if (pdg == -Const::Klong.getPDGCode()) pdg = -pdg; // Strange Feature in TauolaBelle2
677 if (pdg != ii) continue;
678 m_tauplusdecaymode.append(".");
679 if (pdg == 94144) {
680 pdgname = "alpha";
681 } else {
682 pdgname = databasePDG->GetParticle(pdg)->GetName();
683 }
684 m_tauplusdecaymode.append(pdgname);
685 }
686 }
687 //
689
690}
691
692//
693int TauDecayModeModule::TauolaBelle2DecayMode(const std::string& state, int chg)
694{
695 std::map<std::string, int> mode_decay = (chg < 0) ? mode_decay_minus : mode_decay_plus;
696 map<std::string, int>::iterator itr ;
697 for (itr = mode_decay.begin(); itr != mode_decay.end(); ++itr) {
698 if (state == itr-> first) {
699 int mode = itr-> second;
700 if (mode == 39) {
701 if (chg < 0 && m_isEtaPizPizPizFromTauMinus) mode = 42;
702 if (chg > 0 && m_isEtaPizPizPizFromTauPlus) mode = 42;
703 }
704 if (mode == 49) {
705 if (chg < 0 && !m_isOmegaPimPipFromTauMinus) mode = 130;
706 if (chg > 0 && !m_isOmegaPimPipFromTauPlus) mode = 130;
707 }
708 if (mode == 131) {
709 if (chg < 0 && !m_isOmegaPimPipFromTauMinus) mode = 236;
710 if (chg > 0 && !m_isOmegaPimPipFromTauPlus) mode = 236;
711 }
712 if (mode == 247) {
713 if (chg < 0 && !m_isEtaPizPizPizFromTauMinus) mode = 15;
714 if (chg > 0 && !m_isEtaPizPizPizFromTauPlus) mode = 15;
715 }
716 return mode;
717 }
718 }
719 return -1;
720}
721
722//
724{
725 const MCParticle* mother = p->getMother();
726 if (mother == nullptr) {
727 return 0;
728 } else if (abs(p->getPDG()) == Const::electron.getPDGCode() && mother->getPDG() == Const::pi0.getPDGCode()) { // pi0 -> e-e+ gamma
729 return 0;
730 } else if (abs(p->getPDG()) == Const::electron.getPDGCode() && mother->getPDG() == 221) { // eta -> e-e+ gamma
731 return 0;
732 } else if (abs(p->getPDG()) == Const::electron.getPDGCode() && mother->getPDG() == 113) { // rho0 -> e-e+
733 return 0;
734 } else if (abs(p->getPDG()) == Const::electron.getPDGCode() && mother->getPDG() == 223) { // omega -> e- e+
735 return 0;
736 } else if (abs(p->getPDG()) == Const::electron.getPDGCode() && mother->getPDG() == 333) { // phi -> e- e+
737 return 0;
738 } else if (abs(p->getPDG()) == Const::muon.getPDGCode() && mother->getPDG() == 221) { // eta -> mu-mu+ gamma
739 return 0;
740 } else if (abs(p->getPDG()) == Const::muon.getPDGCode() && mother->getPDG() == 113) { // rho0 -> mu-mu+
741 return 0;
742 } else if (abs(p->getPDG()) == Const::muon.getPDGCode() && mother->getPDG() == 333) { // phi -> mu-mu+
743 return 0;
744 } else if (mother->getPDG() == 15) {
745 return -1;
746 } else if (mother->getPDG() == -15) {
747 return 1;
748 } else {
749 return getRecursiveMotherCharge(mother);
750 }
751}
752
753//
755{
756 numOfTauPlus = 0;
757 numOfTauMinus = 0;
758 idOfTauPlus = 0;
759 idOfTauMinus = 0;
760 for (int i = 0; i < MCParticles.getEntries(); i++) {
761 const MCParticle& p = *MCParticles[i];
762
763 if (p.getStatus() == 1 && p.getPDG() == 15) {
765 idOfTauMinus = p.getIndex();
766 }
767 if (p.getStatus() == 1 && p.getPDG() == -15) {
768 numOfTauPlus++;
769 idOfTauPlus = p.getIndex();
770 }
771 }
772 if (numOfTauPlus == 1 && numOfTauMinus == 1) {
773 tauPair = true;
774 } else tauPair = false;
775}
776
777//
779{
780 int ret = 0;
781 const vector<MCParticle*> daughters = p.getDaughters();
782 if (daughters.empty()) return ret;
783 for (const MCParticle* d : daughters) {
784 if (!d->hasStatus(MCParticle::c_PrimaryParticle)) continue;
785 // TODO: Improve how to identify a final state particle.
786 bool isChargedFinalState = find(finalStatePDGs.begin(),
787 finalStatePDGs.end(),
788 abs(d->getPDG())) != finalStatePDGs.end();
789 if (isChargedFinalState) ret++;
790 else ret += getProngOfDecay(*d);
791 }
792 return ret;
793}
794
795// Energy of the radiative photon in tau rest frame
796double TauDecayModeModule::getEgstar(const std::vector<int>& vec_radgam, const MCParticle& p)
797{
798 double egstar = -1.;
799 ROOT::Math::PxPyPzEVector p4_tau = p.get4Vector();
800 B2DEBUG(19, "p4_tau: " << p4_tau << " " << p4_tau.P());
801 ROOT::Math::Boost boost_to_mother_rest_frame(p4_tau.BoostToCM());
802 for (auto i : vec_radgam) {
803 ROOT::Math::PxPyPzEVector p4_gamma = MCParticles[i]->get4Vector();
804 B2DEBUG(19, "p4_gamma: " << p4_gamma << " " << p4_gamma.P());
805 ROOT::Math::PxPyPzEVector p4_gamma_rest = boost_to_mother_rest_frame * p4_gamma;
806 B2DEBUG(19, "p4_gamma_rest: " << p4_gamma_rest << " " << p4_gamma_rest.P());
807 double energy_rest = p4_gamma_rest.E();
808 if (energy_rest > egstar) egstar = energy_rest;
809 }
810 B2DEBUG(19, "egstar: " << egstar);
811 return egstar;
812}
static const ParticleType pi0
neutral pion particle
Definition Const.h:675
static const ChargedStable muon
muon particle
Definition Const.h:661
static const ChargedStable pion
charged pion particle
Definition Const.h:662
static const ParticleType Klong
K^0_L particle.
Definition Const.h:679
static const ParticleType photon
photon particle
Definition Const.h:674
static const ChargedStable electron
electron particle
Definition Const.h:660
Replacement for TDatabasePDG that is filled from EvtGen's evt.pdl.
static EvtGenDatabasePDG * Instance()
Instance method that loads the EvtGen table.
A Class to store the Monte Carlo particle information.
Definition MCParticle.h:32
@ c_IsPHOTOSPhoton
bit 8: Particle is an radiative photon from PHOTOS
Definition MCParticle.h:63
@ c_PrimaryParticle
bit 0: Particle is primary particle.
Definition MCParticle.h:47
std::vector< Belle2::MCParticle * > getDaughters() const
Get vector of all daughter particles, empty vector if none.
Definition MCParticle.cc:50
int getPDG() const
Return PDG code of particle.
Definition MCParticle.h:101
void setDescription(const std::string &description)
Sets the description of the module.
Definition Module.cc:214
Module()
Constructor.
Definition Module.cc:30
Int_t m_mprong
Prong of the decay channel of tau-.
int numOfTauPlus
Number of tau+ in the event.
Int_t m_pprong
Prong of the decay channel of tau+.
StoreObjPtr< EventMetaData > m_event_metadata
event number
void IdentifyTauPair()
Identifies if the event is a generated tau pair.
double getEgstar(const std::vector< int > &vec_radgam, const MCParticle &mc)
Energy of the radiative photon in tau rest frame.
std::vector< int > vec_radgam_taum
Variable name of the vector where particles identified in the event are stored.
StoreArray< MCParticle > MCParticles
StoreArray of MCParticles.
virtual void initialize() override
Initializes the module.
std::string m_file_plus
Alternative mapping for tau+.
static constexpr std::array< int, 46 > OrderedList
PDG codes of ORDERED particles.
virtual void event() override
Method is called for each event.
bool m_isEtaPizPizPizFromTauMinus
Flag for eta->pi0pi0pi0 decays from tau-.
static constexpr std::array< int, 3 > Neutrinos
PDG codes of neutrinos in final state particles in generation: {nu_e, nu_mu, mu_tau}...
double m_pegstar
Energy of radiative photon from tau+.
Int_t m_mmode
ID of the decay channel of tau-.
void AnalyzeTauPairEvent()
Analyze a generated tau pair event.
bool m_isOmegaPimPipFromTauMinus
Flag for omega->pi-pi+ decays from tau-.
static int getRecursiveMotherCharge(const MCParticle *mc)
Identifies particles coming from tau decays.
int m_taum_no
number of tau- unclassified events
std::string m_tauminusdecaymode
Variable name for the decay mode of the tau-.
bool m_isOmegaPimPipFromTauPlus
Flag for omega->pi-pi+ decays from tau+.
bool tauPair
Boolean variable used to identify tau event.
int TauolaBelle2DecayMode(const std::string &s, int chg)
Classifies the decays of the event and assigns a decay mode.
int idOfTauMinus
Index of the generated tau-.
Int_t m_pmode
ID of the decay channel of tau+.
int numOfTauMinus
Number of tau- in the event.
std::vector< int > vec_radgam_taup
Variable name of the vector where particles identified in the event are stored.
static int getProngOfDecay(const MCParticle &mc)
Identifies the number of charged final state particles in the decay.
int idOfTauPlus
Index of the generated tau+.
StoreObjPtr< TauPairDecay > m_tauDecay
pointer to tau pair decay objects
std::string m_printmode
Parameter passed by the user to indicate the information to be printed.
bool m_isEtaPizPizPizFromTauPlus
Flag for eta->pi0pi0pi0 decays from tau+.
std::string m_tauplusdecaymode
Variable name for the decay mode of the tau+.
double m_megstar
Energy of radiative photon from tau-.
TauDecayModeModule()
Constructor: Sets the description, the properties and the parameters of the module.
std::vector< int > vec_dau_tauplus
Variable name of the vector where particles identified in the event are stored.
std::string m_file_minus
Alternative mapping for tau-.
int m_taup_no
number of tau+ unclassified events
std::vector< int > vec_dau_tauminus
Variable name of the vector where particles identified in the event are stored.
static constexpr std::array< int, 5 > finalStatePDGs
PDG codes accepted as charged final state particles in generation: {e, mu, pi, K, p}...
std::map< std::string, int > mode_decay_minus
Mapping for tau- decays.
std::map< std::string, int > mode_decay_plus
Mapping for tau+ decays.
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition Module.h:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition Module.h:650
Abstract base class for different kinds of events.
STL namespace.