9#include <analysis/modules/TauDecayMode/TauDecayModeModule.h>
10#include <framework/datastore/StoreArray.h>
11#include <framework/datastore/StoreObjPtr.h>
12#include <framework/logging/Logger.h>
13#include <framework/particledb/EvtGenDatabasePDG.h>
17#include <TParticlePDG.h>
24std::map<std::string, int> make_map(
const std::string& file,
int chg)
29 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.");
31 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.");
42 std::map <std::string, int> map_tau;
45 istringstream ss(line);
62 m_mprong(0), m_pprong(0), tauPair(false), numOfTauMinus(0), numOfTauPlus(0), idOfTauMinus(-1), idOfTauPlus(-1),
63 m_isEtaPizPizPizFromTauMinus(false), m_isEtaPizPizPizFromTauPlus(false),
64 m_isOmegaPimPipFromTauMinus(false), m_isOmegaPimPipFromTauPlus(false)
67 setDescription(
"Module to identify generated tau pair decays, using MCParticle information."
68 "By default, each tau decay is numbered as TauolaBelle2DecayMode [Ref: BELLE2-NOTE-PH-2020-055]");
70 addParam(
"printmode",
m_printmode,
"Printout more information from each event", std::string(
"default"));
71 addParam(
"file_minus",
m_file_minus,
"Path for an alternative mapping for tau- decays", std::string(
""));
72 addParam(
"file_plus",
m_file_plus,
"Path for an alternative mapping for tau+ decays", std::string(
""));
190 map<int, std::vector<int>> map_vec;
233 map_vec[9010221] =
vec_f0;
239 bool elecFirst =
true;
240 bool muonFirst =
true;
242 bool isPiPizGamTauMinusFirst =
true;
243 bool isPiPizGamTauPlusFirst =
true;
245 bool isLFVTauMinus2BodyDecayFirst =
true;
246 bool isLFVTauPlus2BodyDecayFirst =
true;
248 bool isChargedRhoFromTauMinusFirst =
true;
249 bool isChargedRhoFromTauPlusFirst =
true;
251 bool isChargedA1FromTauMinusFirst =
true;
252 bool isChargedA1FromTauPlusFirst =
true;
254 bool isEtaPPGFromTauMinusFirst =
true;
255 bool isEtaPPGFromTauPlusFirst =
true;
257 bool isOmegaPizGamFromTauMinusFirst =
true;
258 bool isOmegaPizGamFromTauPlusFirst =
true;
260 bool isEtaPizPizPizFromTauMinusFirst =
true;
261 bool isEtaPizPizPizFromTauPlusFirst =
true;
266 bool isOmegaPimPipFromTauMinusFirst =
true;
267 bool isOmegaPimPipFromTauPlusFirst =
true;
273 for (
int i = 0; i <
MCParticles.getEntries(); i++) {
277 int pdgid = p.getPDG();
283 if (p.isInitial())
continue;
288 if (not mother)
continue;
289 const vector<MCParticle*> daughters = mother->
getDaughters();
292 stringstream elec_ss;
295 elec_ss << d->getPDG() <<
" ";
299 if (nElMinus == 1 && nElPlus == 1) {
300 B2DEBUG(1,
"Mother of elec pair is = " << mother->
getPDG() <<
" which has daughters : " << elec_ss.str());
304 if (pdgid ==
Const::muon.getPDGCode() && muonFirst) {
307 if (not mother)
continue;
308 const vector<MCParticle*> daughters = mother->
getDaughters();
311 stringstream muon_ss;
314 muon_ss << d->getPDG() <<
" ";
318 if (nMuMinus == 1 && nMuPlus == 1) {
319 B2DEBUG(1,
"Mother of muon pair is = " << mother->
getPDG() <<
" which has daughters : " << muon_ss.str());
324 bool accept_photon =
false;
327 if (not mother)
continue;
328 int mothid = abs(mother->
getPDG());
331 bool isRadiationfromFinalStateChargedParticle =
false;
338 isRadiationfromFinalStateChargedParticle =
true;
342 bool isRadiationFromChargedRho =
false;
345 if (chg < 0 && isChargedRhoFromTauMinusFirst) {
346 isChargedRhoFromTauMinusFirst =
false;
347 isRadiationFromChargedRho =
true;
349 if (chg > 0 && isChargedRhoFromTauPlusFirst) {
350 isChargedRhoFromTauPlusFirst =
false;
351 isRadiationFromChargedRho =
true;
356 bool isRadiationFromChargedA1 =
false;
357 if (mothid == 20213) {
359 if (chg < 0 && isChargedA1FromTauMinusFirst) {
360 isChargedA1FromTauMinusFirst =
false;
361 isRadiationFromChargedA1 =
true;
363 if (chg > 0 && isChargedA1FromTauPlusFirst) {
364 isChargedA1FromTauPlusFirst =
false;
365 isRadiationFromChargedA1 =
true;
370 bool isRadiationfromIntermediateWBoson =
false;
371 if (mothid == 24) isRadiationfromIntermediateWBoson =
true;
376 bool isPiPizGam =
false;
377 if (isRadiationfromIntermediateWBoson) {
378 if (p.get4Vector().E() > 0.050) {
379 const vector<MCParticle*> daughters = mother->
getDaughters();
383 int nOtherSisters = 0;
387 if (abs(d->getPDG()) == 211) {
389 }
else if (abs(d->getPDG()) == 111) {
391 }
else if (abs(d->getPDG()) != 22) {
396 if (nTotSisters >= 3 && nPiSisters == 1 && nPizSisters == 1 && nOtherSisters == 0) {
398 if (chg < 0 && isPiPizGamTauMinusFirst) {
399 isPiPizGamTauMinusFirst =
false;
402 if (chg > 0 && isPiPizGamTauPlusFirst) {
403 isPiPizGamTauPlusFirst =
false;
411 bool isRadiationfromTau =
false;
412 if (mothid == 15) isRadiationfromTau =
true;
415 bool isLFVTau2BodyDecay =
false;
416 if (isRadiationfromTau) {
417 bool hasNeutrinoAsSister =
false;
418 int numChargedSister = 0;
419 int numNeutralNonNeutrinoNonPhotonSister = 0;
420 const vector<MCParticle*> daughters = mother->
getDaughters();
424 if (hasNeutrinoAsSister)
break;
426 if (!hasNeutrinoAsSister) {
430 if (isChargedFinalState) {
432 }
else if (d->getPDG() != 22) {
433 numNeutralNonNeutrinoNonPhotonSister++;
436 if (numChargedSister == 1 && numNeutralNonNeutrinoNonPhotonSister == 0) {
437 if (mother->
getPDG() == 15 && isLFVTauMinus2BodyDecayFirst) {
438 isLFVTauMinus2BodyDecayFirst =
false;
439 isLFVTau2BodyDecay =
true;
441 if (mother->
getPDG() == -15 && isLFVTauPlus2BodyDecayFirst) {
442 isLFVTauPlus2BodyDecayFirst =
false;
443 isLFVTau2BodyDecay =
true;
447 B2DEBUG(1,
"hasNeutrinoAsSister = " << hasNeutrinoAsSister
448 <<
" numChargedSister = " << numChargedSister
449 <<
" numNeutralNonNeutrinoNonPhotonSister = " << numNeutralNonNeutrinoNonPhotonSister
450 <<
" isLFVTau2BodyDecay = " << isLFVTau2BodyDecay);
453 bool isPi0GG =
false;
454 bool isEtaGG =
false;
455 bool isEtpGG =
false;
456 bool isPi0GEE =
false;
457 bool isEtaPPG =
false;
458 bool isOmPizG =
false;
459 if (mothid == 111 || mothid == 221 || mothid == 331 || mothid == 223) {
460 const vector<MCParticle*> daughters = mother->
getDaughters();
461 int numberofTotalDaughters = 0;
462 int numberOfPhotonDaughters = 0;
463 int numberOfElectronDaughters = 0;
464 int numberOfPionDaughters = 0;
465 int numberOfPizDaughters = 0;
468 numberofTotalDaughters ++;
469 if (abs(d->getPDG()) == 22) numberOfPhotonDaughters++;
470 if (abs(d->getPDG()) == 11) numberOfElectronDaughters++;
471 if (abs(d->getPDG()) == 211) numberOfPionDaughters++;
472 if (abs(d->getPDG()) == 111) numberOfPizDaughters++;
474 if (numberofTotalDaughters == 2 && numberOfPhotonDaughters == 2) {
475 if (mothid == 111) isPi0GG =
true;
476 if (mothid == 221) isEtaGG =
true;
477 if (mothid == 331) isEtpGG =
true;
479 if (numberofTotalDaughters >= 3 && numberOfPhotonDaughters >= 1 && numberOfElectronDaughters == 2 && numberOfPionDaughters == 0
480 && numberOfPizDaughters == 0) {
481 if (mothid == 111) isPi0GEE =
true;
483 if (numberofTotalDaughters >= 3 && numberOfPhotonDaughters >= 1 && numberOfPizDaughters == 0 && numberOfPionDaughters == 2) {
486 if (chg < 0 && isEtaPPGFromTauMinusFirst) {
487 isEtaPPGFromTauMinusFirst =
false;
490 if (chg > 0 && isEtaPPGFromTauPlusFirst) {
491 isEtaPPGFromTauPlusFirst =
false;
496 if (numberofTotalDaughters >= 2 && numberOfPhotonDaughters >= 1 && numberOfPizDaughters == 1 && numberOfPionDaughters == 0) {
499 if (chg < 0 && isOmegaPizGamFromTauMinusFirst) {
500 isOmegaPizGamFromTauMinusFirst =
false;
503 if (chg > 0 && isOmegaPizGamFromTauPlusFirst) {
504 isOmegaPizGamFromTauPlusFirst =
false;
511 B2DEBUG(1,
"isRadiationfromFinalStateChargedParticle = " << isRadiationfromFinalStateChargedParticle);
512 B2DEBUG(1,
"isRadiationFromChargedRho = " << isRadiationFromChargedRho);
513 B2DEBUG(1,
"isRadiationFromChargedA1 = " << isRadiationFromChargedA1);
514 B2DEBUG(1,
"isRadiationfromIntermediateWBoson = " << isRadiationfromIntermediateWBoson <<
" isPiPizGam = " << isPiPizGam);
515 B2DEBUG(1,
"isRadiationfromTau = " << isRadiationfromTau <<
" isLFVTau2BodyDecay = " << isLFVTau2BodyDecay);
516 B2DEBUG(1,
"isPi0GG = " << isPi0GG <<
" isEtaGG = " << isEtaGG <<
" isEtpGG = " << isEtpGG <<
" isPi0GEE = " << isPi0GEE);
517 B2DEBUG(1,
"isEtaPPG = " << isEtaPPG <<
" isOmPizG = " << isOmPizG);
523 if (isRadiationfromFinalStateChargedParticle) {
524 }
else if (isRadiationFromChargedRho) {
525 accept_photon =
true;
526 }
else if (isRadiationFromChargedA1) {
527 accept_photon =
true;
528 }
else if (isRadiationfromIntermediateWBoson) {
530 accept_photon =
true;
532 }
else if (isRadiationfromTau) {
533 if (isLFVTau2BodyDecay) {
534 accept_photon =
true;
536 }
else if (isPi0GG) {
537 }
else if (isEtaGG) {
538 }
else if (isEtpGG) {
539 }
else if (isPi0GEE) {
540 }
else if (isEtaPPG) {
541 accept_photon =
true;
542 }
else if (isOmPizG) {
543 accept_photon =
true;
551 if (pdgid == 111 && (isEtaPizPizPizFromTauMinusFirst || isEtaPizPizPizFromTauPlusFirst)) {
554 if (mother and (mother->
getPDG() == 221)) {
555 const vector<MCParticle*> daughters = mother->
getDaughters();
559 if (d->getPDG() == 111) nPizSisters++;
561 B2DEBUG(1,
"nPizSisters = " << nPizSisters);
562 if (nPizSisters == 3) {
564 if (chg < 0 && isEtaPizPizPizFromTauMinusFirst) {
565 isEtaPizPizPizFromTauMinusFirst =
false;
568 if (chg > 0 && isEtaPizPizPizFromTauPlusFirst) {
569 isEtaPizPizPizFromTauPlusFirst =
false;
576 "isEtaPizPizPizFromTauMinusFirst = " << isEtaPizPizPizFromTauMinusFirst <<
" "
578 "isEtaPizPizPizFromTauPlusFirst = " << isEtaPizPizPizFromTauPlusFirst <<
" "
595 if (pdgid == -211 && (isOmegaPimPipFromTauMinusFirst || isOmegaPimPipFromTauPlusFirst)) {
598 if (mother and (mother->
getPDG() == 223)) {
599 const vector<MCParticle*> daughters = mother->
getDaughters();
600 int nOmegaDaughters = 0;
607 if (d->getPDG() == -211) nPimSisters++;
608 if (d->getPDG() == 211) nPipSisters++;
609 if (d->getPDG() == 111) nPizSisters++;
612 "nOmegaDaughters = " << nOmegaDaughters <<
" "
613 "nPimSisters = " << nPimSisters <<
" "
614 "nPipSisters = " << nPipSisters <<
" "
615 "nPizSisters = " << nPizSisters);
616 if (nOmegaDaughters >= 2 && nPimSisters == 1 && nPipSisters == 1 && nPizSisters == 0) {
618 if (chg < 0 && isOmegaPimPipFromTauMinusFirst) {
619 isOmegaPimPipFromTauMinusFirst =
false;
622 if (chg > 0 && isOmegaPimPipFromTauPlusFirst) {
623 isOmegaPimPipFromTauPlusFirst =
false;
630 "isOmegaPimPipFromTauMinusFirst = " << isOmegaPimPipFromTauMinusFirst <<
" "
632 "isOmegaPimPipFromTauPlusFirst = " << isOmegaPimPipFromTauPlusFirst <<
" "
637 map<int, std::vector<int>>::iterator ite ;
638 for (ite = map_vec.begin(); ite != map_vec.end(); ++ite) {
639 if (pdgid == ite->first) {
642 B2DEBUG(1,
"Photon accepted");
643 ite-> second.push_back(i);
646 ite-> second.push_back(i);
657 map<int, std::vector<int>>::iterator itr ;
658 for (itr = map_vec.begin(); itr != map_vec.end(); ++itr) {
659 for (
unsigned int i = 0; i < itr-> second.size(); i++) {
660 int ii = itr-> second[i];
672 for (
unsigned iorder = 0; iorder < 46; ++iorder) {
677 int pdg = p->getPDG();
678 if (pdg == -130) pdg = 130;
679 if (pdg != ii)
continue;
684 pdgname = databasePDG->GetParticle(pdg)->GetName();
694 for (
unsigned iorder = 0; iorder < 46; ++iorder) {
699 int pdg = p->getPDG();
700 if (pdg == -130) pdg = 130;
701 if (pdg != ii)
continue;
706 pdgname = databasePDG->GetParticle(pdg)->GetName();
720 map<std::string, int>::iterator itr ;
721 for (itr = mode_decay.begin(); itr != mode_decay.end(); ++itr) {
722 if (state == itr-> first) {
723 int mode = itr-> second;
750 if (mother ==
nullptr) {
752 }
else if (abs(p->getPDG()) == 11 && mother->
getPDG() == 111) {
754 }
else if (abs(p->getPDG()) == 11 && mother->
getPDG() == 221) {
756 }
else if (abs(p->getPDG()) == 11 && mother->
getPDG() == 113) {
758 }
else if (abs(p->getPDG()) == 11 && mother->
getPDG() == 223) {
760 }
else if (abs(p->getPDG()) == 11 && mother->
getPDG() == 333) {
762 }
else if (abs(p->getPDG()) == 13 && mother->
getPDG() == 221) {
764 }
else if (abs(p->getPDG()) == 13 && mother->
getPDG() == 113) {
766 }
else if (abs(p->getPDG()) == 13 && mother->
getPDG() == 333) {
768 }
else if (mother->
getPDG() == 15) {
770 }
else if (mother->
getPDG() == -15) {
784 for (
int i = 0; i <
MCParticles.getEntries(); i++) {
787 if (p.getStatus() == 1 && p.getPDG() == 15) {
791 if (p.getStatus() == 1 && p.getPDG() == -15) {
805 const vector<MCParticle*> daughters = p.getDaughters();
806 if (daughters.empty())
return ret;
813 if (isChargedFinalState) ret++;
int getPDGCode() const
PDG code.
static const ChargedStable muon
muon particle
static const ParticleType Klong
K^0_L particle.
static const ParticleType photon
photon particle
static const ChargedStable electron
electron particle
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.
@ c_PrimaryParticle
bit 0: Particle is primary particle.
std::vector< Belle2::MCParticle * > getDaughters() const
Get vector of all daughter particles, empty vector if none.
int getPDG() const
Return PDG code of particle.
void setDescription(const std::string &description)
Sets the description of the module.
std::vector< int > vec_numu
Variable name of the vector where particles identified in the event are stored.
std::vector< int > vec_em
Variable name of the vector where particles identified in the event are stored.
std::vector< int > vec_omega
Variable name of the vector where particles identified in the event are stored.
std::vector< int > vec_k0s
Variable name of the vector where particles identified in the event are stored.
Int_t m_mprong
Prong of the decay channel of tau-.
std::vector< int > vec_b1p
Variable name of the vector where particles identified in the event are stored.
std::vector< int > vec_f1
Variable name of the vector where particles identified in the event are stored.
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.
std::vector< int > vec_apro
Variable name of the vector where particles identified in the event are stored.
std::vector< int > vec_pi0
Variable name of the vector where particles identified in the event are stored.
std::vector< int > vec_alpha
Variable name of the vector where particles identified in the event are stored.
StoreArray< MCParticle > MCParticles
StoreArray of MCParticles.
std::vector< int > vec_anue
Variable name of the vector where particles identified in the event are stored.
std::vector< int > vec_nue
Variable name of the vector where particles identified in the event are stored.
virtual void initialize() override
Initializes the module.
std::vector< int > vec_a0p_980
Variable name of the vector where particles identified in the event are stored.
std::string m_file_plus
Alternative mapping for tau+.
std::vector< int > vec_a0m_1450
Variable name of the vector where particles identified in the event are stored.
virtual void event() override
Method is called for each event.
bool m_isEtaPizPizPizFromTauMinus
Flag for eta->pi0pi0pi0 decays from tau-.
std::vector< int > vec_lmb_br
Variable name of the vector where particles identified in the event are stored.
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-.
int getRecursiveMotherCharge(const MCParticle *mc)
Identifies particles coming from tau decays.
std::vector< int > vec_phi
Variable name of the vector where particles identified in the event are stored.
static constexpr int Neutrinos[3]
PDG codes of neutrinos in final state particles in generation: {nu_e, nu_mu, mu_tau}.
int m_taum_no
number of tau- unclassified events
std::string m_tauminusdecaymode
Variable name for the decay mode of the tau-.
std::vector< int > vec_a1p
Variable name of the vector where particles identified in the event are stored.
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-.
std::vector< int > vec_lambda
Variable name of the vector where particles identified in the event are stored.
std::vector< int > vec_anut
Variable name of the vector where particles identified in the event are stored.
std::vector< int > vec_f0
Variable name of the vector where particles identified in the event are stored.
std::vector< int > vec_mum
Variable name of the vector where particles identified in the event are stored.
Int_t m_pmode
ID of the decay channel of tau+.
static constexpr int OrderedList[46]
PDG codes of ORDERED particles.
int numOfTauMinus
Number of tau- in the event.
std::vector< int > vec_nut
Variable name of the vector where particles identified in the event are stored.
std::vector< int > vec_kstar0_br
Variable name of the vector where particles identified in the event are stored.
std::vector< int > vec_a00_1450
Variable name of the vector where particles identified in the event are stored.
std::vector< int > vec_kstar0
Variable name of the vector where particles identified in the event are stored.
std::vector< int > vec_a0m_980
Variable name of the vector where particles identified in the event are stored.
std::vector< int > vec_a00_980
Variable name of the vector where particles identified in the event are stored.
int getProngOfDecay(const MCParticle &mc)
Identifies the number of charged final state particles in the decay.
std::vector< int > vec_a1m
Variable name of the vector where particles identified in the event are stored.
int idOfTauPlus
Index of the generated tau+.
StoreObjPtr< TauPairDecay > m_tauDecay
pointer to tau pair decay objects
std::vector< int > vec_rhop
Variable name of the vector where particles identified in the event are stored.
std::string m_printmode
Parameter passed by the user to indicated the informationt to be printed.
std::vector< int > vec_pro
Variable name of the vector where particles identified in the event are stored.
bool m_isEtaPizPizPizFromTauPlus
Flag for eta->pi0pi0pi0 decays from tau+.
std::string m_tauplusdecaymode
Variable name for the decay mode of the tau+.
std::vector< int > vec_pim
Variable name of the vector where particles identified in the event are stored.
std::vector< int > vec_mup
Variable name of the vector where particles identified in the event are stored.
std::vector< int > vec_pip
Variable name of the vector where particles identified in the event are stored.
std::vector< int > vec_kstarp
Variable name of the vector where particles identified in the event are stored.
std::vector< int > vec_kstarm
Variable name of the vector where particles identified in the event are stored.
std::vector< int > vec_etapr
Variable name of the vector where particles identified in the event are stored.
std::vector< int > vec_ep
Variable name of the vector where particles identified in the event are stored.
TauDecayModeModule()
Constructor: Sets the description, the properties and the parameters of the module.
std::vector< int > vec_k0l
Variable name of the vector where particles identified in the event are stored.
static constexpr int finalStatePDGs[5]
PDG codes accepted as charged final state particles in generation: {e, mu, pi, K, p}.
std::vector< int > vec_eta
Variable name of the vector where particles identified in the event are stored.
std::vector< int > vec_km
Variable name of the vector where particles identified in the event are stored.
std::vector< int > vec_anumu
Variable name of the vector where particles identified in the event are stored.
std::vector< int > vec_dau_tauplus
Variable name of the vector where particles identified in the event are stored.
std::vector< int > vec_rhom
Variable name of the vector where particles identified in the event are stored.
std::vector< int > vec_gam
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.
std::vector< int > vec_kp
Variable name of the vector where particles identified in the event are stored.
std::vector< int > vec_b1m
Variable name of the vector where particles identified in the event are stored.
std::vector< int > vec_rho0
Variable name of the vector where particles identified in the event are stored.
std::map< std::string, int > mode_decay_minus
Mapping for tau- decays.
std::map< std::string, int > mode_decay_plus
Mapping for tau+ decays.
std::vector< int > vec_a0p_1450
Variable name of the vector where particles identified in the event are stored.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.