10 #include "Pythia8/Pythia.h"
11 #include "Pythia8Plugins/HepMC2.h"
14 #include "Photos/Photos.h"
15 #include "Photos/PhotosHepMCParticle.h"
16 #include "Photos/Log.h"
19 using namespace Pythia8;
20 using namespace Photospp;
28 void checkMomentumConservationInEvent(HepMC::GenEvent *evt)
32 double px=0.0,py=0.0,pz=0.0,e=0.0;
34 for ( HepMC::GenEvent::particle_const_iterator p = evt->particles_begin();
35 p != evt->particles_end(); ++p )
37 if( (*p)->status() == 1 )
39 HepMC::FourVector m = (*p)->momentum();
48 cout.setf(ios_base::scientific, ios_base::floatfield);
49 cout<<endl<<
"Vector Sum: "<<px<<
" "<<py<<
" "<<pz<<
" "<<e<<endl;
52 int main(
int argc,
char **argv)
55 HepMC::Pythia8ToHepMC ToHepMC;
57 Event&
event = pythia.event;
59 pythia.readFile(
"single_photos_gun_example.conf");
63 Photos::setInfraredCutOff(0.001/200);
65 int NumberOfEvents = 10000;
66 if(argc>1) NumberOfEvents=atoi(argv[1]);
68 int photonAdded=0,twoAdded=0,moreAdded=0,tauCount=0;
71 for (
int iEvent = 0; iEvent < NumberOfEvents; ++iEvent)
73 if(iEvent%(NumberOfEvents/10)==0) Log::Info()<<iEvent<<endl;
74 if(!pythia.next())
continue;
76 HepMC::GenEvent * HepMCEvt =
new HepMC::GenEvent();
77 ToHepMC.fill_next_event(event, HepMCEvt);
79 if(iEvent<EventsToCheck)
82 cout<<
"Momentum conservation chceck BEFORE/AFTER Photos"<<endl;
83 checkMomentumConservationInEvent(HepMCEvt);
87 HepMC::GenParticle *tau=0;
88 for(HepMC::GenEvent::vertex_const_iterator i = HepMCEvt->vertices_begin();i!=HepMCEvt->vertices_end();i++)
90 for(HepMC::GenVertex::particles_in_const_iterator p=(*i)->particles_in_const_begin();p!=(*i)->particles_in_const_end(); p++)
92 if((*p)->pdg_id()==15) tau=*p;
100 int buf = -HepMCEvt->particles_size();
105 buf+=HepMCEvt->particles_size();
106 if(buf==1) photonAdded++;
107 else if(buf==2) twoAdded++;
108 else if(buf>2) moreAdded++;
111 if(iEvent<EventsToCheck)
113 checkMomentumConservationInEvent(HepMCEvt);
123 cout.setf(ios_base::fixed, ios_base::floatfield);
127 cout<<
"Something went wrong with pythia generation."<<endl;
128 cout<<
"No taus were processed."<<endl<<endl;
131 cout<<
"Summary (single tau decay processing):"<<endl;
132 cout<<tauCount <<
"\ttaus processed"<<endl;
133 cout<<photonAdded<<
"\ttimes one photon added to the decay \t("<<(photonAdded*100./tauCount)<<
"%)"<<endl;
134 cout<<twoAdded <<
"\ttimes two photons added to the decay \t("<<(twoAdded*100./tauCount)<<
"%)"<<endl;
135 cout<<moreAdded <<
"\ttimes more than two photons added to the decay\t("<<(moreAdded*100./tauCount)<<
"%)"<<endl<<endl;
136 cout<<
"(Contrary to results from MC-Tester, these values are technical and infrared unstable)"<<endl<<endl;
137 cout<<
"To proccess different number of events use:"<<endl<<
" ./single_photos_gun_example <number_of_events>"<<endl<<endl;