FairRoot/PandaRoot
single_photos_gun_example.cxx
Go to the documentation of this file.
1 
9 //pythia header files
10 #include "Pythia.h"
11 #include "HepMCInterface.h"
12 
13 //PHOTOS header files
14 #include "Photos/Photos.h"
16 #include "Photos/Log.h"
17 
18 using namespace std;
19 using namespace Pythia8;
20 using namespace Photospp;
21 
23 
24 // elementary test of HepMC typically executed before
25 // detector simulation based on http://home.fnal.gov/~mrenna/HCPSS/HCPSShepmc.html
26 // similar test was performed in Fortran
27 // we perform it before and after Photos (for the first several events)
28 void checkMomentumConservationInEvent(HepMC::GenEvent *evt)
29 {
30  //cout<<"List of stable particles: "<<endl;
31 
32  double px=0.0,py=0.0,pz=0.0,e=0.0;
33 
34  for ( HepMC::GenEvent::particle_const_iterator p = evt->particles_begin();
35  p != evt->particles_end(); ++p )
36  {
37  if( (*p)->status() == 1 )
38  {
39  HepMC::FourVector m = (*p)->momentum();
40  px+=m.px();
41  py+=m.py();
42  pz+=m.pz();
43  e +=m.e();
44  //(*p)->print();
45  }
46  }
47  cout.precision(6);
48  cout.setf(ios_base::floatfield);
49  cout<<endl<<"Vector Sum: "<<px<<" "<<py<<" "<<pz<<" "<<e<<endl;
50 }
51 
52 int main(int argc,char **argv)
53 {
54  // Initialization of pythia
55  HepMC::I_Pythia8 ToHepMC;
56  Pythia pythia;
57  Event& event = pythia.event;
58  pythia.readString("WeakSingleBoson:ffbar2gmZ = on");
59  pythia.readString("23:onMode = off");
60  pythia.readString("23:onIfAny = 15");
61  pythia.readString("HadronLevel:Hadronize = off");
62  pythia.readString("SpaceShower:QEDshower = off");
63  pythia.readString("SpaceShower:QEDshowerByL = off");
64  pythia.readString("SpaceShower:QEDshowerByQ = off");
65  pythia.readString("PartonLevel:ISR = off");
66  pythia.readString("PartonLevel:FSR = off");
67  pythia.init( 11, -11, 92.);
68 
70  Photos::setInfraredCutOff(0.001/200);
71 
72  int NumberOfEvents = 10000;
73  if(argc>1) NumberOfEvents=atoi(argv[1]);
74 
75  int photonAdded=0,twoAdded=0,moreAdded=0,tauCount=0;
76 
77  // Begin event loop. Generate event.
78  for (int iEvent = 0; iEvent < NumberOfEvents; ++iEvent)
79  {
80  if(iEvent%(NumberOfEvents/10)==0) Log::Info()<<iEvent<<endl;
81  if(!pythia.next()) continue;
82 
83  HepMC::GenEvent * HepMCEvt = new HepMC::GenEvent();
84  ToHepMC.fill_next_event(event, HepMCEvt);
85 
86  if(iEvent<EventsToCheck)
87  {
88  cout<<" "<<endl;
89  cout<<"Momentum conservation chceck BEFORE/AFTER Photos"<<endl;
91  }
92 
93  // Find tau
94  HepMC::GenParticle *tau=0;
95  for(HepMC::GenEvent::vertex_const_iterator i = HepMCEvt->vertices_begin();i!=HepMCEvt->vertices_end();i++)
96  {
97  for(HepMC::GenVertex::particles_in_const_iterator p=(*i)->particles_in_const_begin();p!=(*i)->particles_in_const_end(); p++)
98  {
99  if((*p)->pdg_id()==15) tau=*p;
100  break;
101  }
102  if(tau) break;
103  }
104  if(tau)
105  {
106  tauCount++;
107  int buf = -HepMCEvt->particles_size();
108 
109  // Call photos
110  Photos::processParticle( new PhotosHepMCParticle(tau) );
111 
112  buf+=HepMCEvt->particles_size();
113  if(buf==1) photonAdded++;
114  else if(buf==2) twoAdded++;
115  else if(buf>2) moreAdded++;
116  }
117 
118  if(iEvent<EventsToCheck)
119  {
121  }
122 
123  //clean up
124  delete HepMCEvt;
125  }
126  pythia.statistics();
127 
128  // Print results
129  cout.precision(2);
130  cout.setf(ios::fixed);
131  cout<<endl;
132  if(tauCount==0)
133  {
134  cout<<"Something went wrong with pythia generation."<<endl;
135  cout<<"No taus were processed."<<endl<<endl;
136  return 0;
137  }
138  cout<<"Summary (single tau decay processing):"<<endl;
139  cout<<tauCount <<"\ttaus processed"<<endl;
140  cout<<photonAdded<<"\ttimes one photon added to the decay \t("<<(photonAdded*100./tauCount)<<"%)"<<endl;
141  cout<<twoAdded <<"\ttimes two photons added to the decay \t("<<(twoAdded*100./tauCount)<<"%)"<<endl;
142  cout<<moreAdded <<"\ttimes more than two photons added to the decay\t("<<(moreAdded*100./tauCount)<<"%)"<<endl<<endl;
143  cout<<"(Contrary to results from MC-Tester, these values are technical and infrared unstable)"<<endl<<endl;
144  cout<<"To proccess different number of events use:"<<endl<<" ./single_photos_gun_example <number_of_events>"<<endl<<endl;
145 }
146 
int main(int argc, char **argv)
Int_t i
Definition: run_full.C:25
__m128 m
Definition: P4_F32vec4.h:28
int NumberOfEvents
int evt
Definition: checkhelixhit.C:36
Double_t p
Definition: anasim.C:58
Definition: Log.h:30
void initialize()
void checkMomentumConservationInEvent(HepMC::GenEvent *evt)
return buf
Pythia8::Pythia * pythia
double pz[39]
Definition: pipisigmas.h:14