TauolaHEPEVTEvent.cxx

00001 #include "TauolaHEPEVTEvent.h"
00002 
00003 #include "Log.h"
00004 
00005 namespace Tauolapp
00006 {
00007 
00008 TauolaHEPEVTEvent::~TauolaHEPEVTEvent()
00009 {
00010   for(unsigned int i=0;i<particle_list.size();i++) delete particle_list[i];
00011 }
00012 
00013 TauolaHEPEVTEvent::TauolaHEPEVTEvent() {}
00014 
00015 void TauolaHEPEVTEvent::addParticle(TauolaHEPEVTParticle *p)
00016 {
00017   p->setEvent(this);
00018 
00019   p->setBarcode(particle_list.size());
00020   particle_list.push_back(p);
00021 }
00022 
00023 TauolaHEPEVTParticle *TauolaHEPEVTEvent::getParticle(int i)
00024 {
00025   if( i<0 || i>=(int)particle_list.size() ) return NULL;
00026   return particle_list[i];
00027 }
00028 
00029 int TauolaHEPEVTEvent::getParticleCount()
00030 {
00031   return particle_list.size();
00032 }
00033 
00034 // we have conflict in names, looks for -pdg_id also...
00035 std::vector<TauolaParticle*> TauolaHEPEVTEvent::findParticles(int pdg_id){
00036 
00037   std::vector<TauolaParticle*> list;
00038 
00039   // Loop over all particles in the event looking
00040   // for tau (or other) particle with specified pdg_id and -pdg_id
00041   for(unsigned int i=0; i<particle_list.size(); i++)
00042   {
00043     if( abs(particle_list[i]->getPdgID() ) == pdg_id)
00044       list.push_back(particle_list[i]);
00045   }
00046 
00047   return list;
00048 }
00049 
00050 // we have conflict in names, should be findStableTaus or have another argument. 
00051 std::vector<TauolaParticle*> TauolaHEPEVTEvent::findStableParticles(int pdg_id){
00052 
00053   std::vector<TauolaParticle*> tau_list = findParticles(pdg_id);
00054   std::vector<TauolaParticle*> stable_tau_list;
00055 
00056   for(int i=0; i<(int) tau_list.size(); i++){
00057 
00058     if(!tau_list.at(i)->hasDaughters())
00059       stable_tau_list.push_back(tau_list[i]);
00060     else
00061     {
00062       std::vector<TauolaParticle*> t = tau_list[i]->getDaughters();
00063       //Ignore taus that we won't be decaying anyway
00064       if(t.size()==1) continue;
00065       if(t.size()==2 && (abs(t[0]->getPdgID())==15 || abs(t[1]->getPdgID())==15) ) continue;
00066       Log::Warning()<<"Particle with pdg code "<<tau_list.at(i)->getPdgID()
00067                     <<" already has daughters" <<endl;
00068     }
00069   }
00070 
00071   return stable_tau_list;
00072 
00073 }
00074 
00075 void TauolaHEPEVTEvent::print()
00076 {
00077   printf("TauolaHEPEVTEvent\n-----------------\n");
00078   for(unsigned int i=0;i<particle_list.size();i++) particle_list[i]->print();
00079 }
00080 
00081 void TauolaHEPEVTEvent::clear()
00082 {
00083   for(unsigned int i=0;i<particle_list.size();i++) delete particle_list[i];
00084   particle_list.clear();
00085 }
00086 
00087 #ifdef USE_HEPEVT_INTERFACE
00088 
00089 void TauolaHEPEVTEvent::read_event_from_HEPEVT(TauolaHEPEVTEvent *evt)
00090 {
00091   if(evt==NULL) return;
00092   
00093   for(int i=0; i<hepevt_.nhep; i++)
00094   {
00095     TauolaHEPEVTParticle *p = new TauolaHEPEVTParticle
00096     (
00097       hepevt_.idhep [i],
00098       hepevt_.isthep[i],
00099       hepevt_.phep  [i][0],
00100       hepevt_.phep  [i][1],
00101       hepevt_.phep  [i][2],
00102       hepevt_.phep  [i][3],
00103       hepevt_.phep  [i][4],
00104       hepevt_.jmohep[i][0]-1,
00105       hepevt_.jmohep[i][1]-1,
00106       hepevt_.jdahep[i][0]-1,
00107       hepevt_.jdahep[i][1]-1
00108     );
00109     evt->addParticle(p);
00110   }
00111 }
00112 
00113 void TauolaHEPEVTEvent::write_event_to_HEPEVT(TauolaHEPEVTEvent *evt)
00114 {
00115   if(evt==NULL) return;
00116   
00117   hepevt_.nhep = evt->getParticleCount();
00118   
00119   for(int i=0; i<hepevt_.nhep; i++)
00120   {
00121     TauolaHEPEVTParticle *p = evt->getParticle(i);
00122     
00123     hepevt_.idhep [i]   =p->getPdgID();
00124     hepevt_.isthep[i]   =p->getStatus();
00125     hepevt_.phep  [i][0]=p->getPx();
00126     hepevt_.phep  [i][1]=p->getPy();
00127     hepevt_.phep  [i][2]=p->getPz();
00128     hepevt_.phep  [i][3]=p->getE();
00129     hepevt_.phep  [i][4]=p->getMass();
00130     hepevt_.jmohep[i][0]=p->getFirstMotherIndex()  +1;
00131     hepevt_.jmohep[i][1]=p->getSecondMotherIndex() +1;
00132     hepevt_.jdahep[i][0]=p->getDaughterRangeStart()+1;
00133     hepevt_.jdahep[i][1]=p->getDaughterRangeEnd()  +1;
00134     hepevt_.vhep  [i][0]=0.0;
00135     hepevt_.vhep  [i][1]=0.0;
00136     hepevt_.vhep  [i][2]=0.0;
00137     hepevt_.vhep  [i][3]=0.0;
00138   }
00139 }
00140 
00141 #endif
00142 
00143 } // namespace Tauolapp
Generated on Sun Oct 20 20:24:11 2013 for C++InterfacetoTauola by  doxygen 1.6.3