Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 10:06:17

0001 #include "Validation/EventGenerator/interface/TauDecay_CMSSW.h"
0002 #include "Validation/EventGenerator/interface/PdtPdgMini.h"
0003 
0004 #include <iomanip>
0005 #include <cstdlib>
0006 
0007 TauDecay_CMSSW::TauDecay_CMSSW() : TauDecay() {}
0008 
0009 TauDecay_CMSSW::~TauDecay_CMSSW() {}
0010 
0011 bool TauDecay_CMSSW::AnalyzeTau(
0012     HepMC::GenParticle *Tau, unsigned int &MODE_ID, unsigned int &TauBitMask, bool dores, bool dopi0) {
0013   Reset();
0014   MotherIdx.clear();
0015   TauDecayProducts.clear();
0016   if (abs(Tau->pdg_id()) == PdtPdgMini::tau_minus) {  // check that it is a tau
0017     unsigned int Tauidx = TauDecayProducts.size();
0018     HepMC::GenVertex::particle_iterator des;
0019     if (Tau->end_vertex()) {
0020       for (des = Tau->end_vertex()->particles_begin(HepMC::children);
0021            des != Tau->end_vertex()->particles_end(HepMC::children);
0022            ++des) {
0023         Analyze((*des), Tauidx, dores, dopi0);
0024       }
0025       ClassifyDecayMode(MODE_ID, TauBitMask);
0026       return true;
0027     }
0028   }
0029   return false;
0030 }
0031 
0032 void TauDecay_CMSSW::Analyze(HepMC::GenParticle *Particle, unsigned int midx, bool dores, bool dopi0) {
0033   unsigned int pdgid = abs(Particle->pdg_id());
0034   isTauResonanceCounter(pdgid);
0035   if (isTauFinalStateParticle(pdgid)) {
0036     if (!isTauParticleCounter(pdgid))
0037       std::cout << "TauDecay_CMSSW::Analyze WARNING: Unknow Final State Particle in Tau Decay... " << pdgid
0038                 << std::endl;
0039     TauDecayProducts.push_back(Particle);
0040     MotherIdx.push_back(midx);
0041     return;
0042   }
0043   HepMC::GenVertex::particle_iterator des;
0044   if (Particle->end_vertex()) {
0045     for (des = Particle->end_vertex()->particles_begin(HepMC::children);
0046          des != Particle->end_vertex()->particles_end(HepMC::children) &&
0047          Particle->end_vertex()->particles_out_size() > 0;
0048          ++des) {
0049       Analyze((*des), midx, dores, dopi0);
0050     }
0051   } else {
0052     std::cout << "Unstable particle that is undecayed in Tau decay tree. PDG ID: " << pdgid << std::endl;
0053   }
0054 }
0055 
0056 void TauDecay_CMSSW::AddPi0Info(HepMC::GenParticle *Particle, unsigned int midx) {
0057   if (Particle->status() == 1) {
0058     TauDecayProducts.push_back(Particle);
0059     MotherIdx.push_back(midx);
0060     return;
0061   }
0062   HepMC::GenVertex::particle_iterator des;
0063   for (des = Particle->end_vertex()->particles_begin(HepMC::children);
0064        des != Particle->end_vertex()->particles_end(HepMC::children);
0065        ++des) {
0066     AddPi0Info((*des), midx);
0067   }
0068 }