FairRoot/PandaRoot
photos_tauola_test.cxx
Go to the documentation of this file.
1 
10 //Pythia header files
11 #include "Pythia.h"
12 #include "HepMCInterface.h"
13 
14 //MC-TESTER header files
15 #include "Generate.h"
16 #include "HepMCEvent.H"
17 #include "Setup.H"
18 
19 //TAUOLA header files
20 #include "Tauola/Tauola.h"
21 #include "Tauola/TauolaHepMCEvent.h"
22 
23 //PHOTOS header files
24 #include "Photos/Photos.h"
27 #include "Photos/Log.h"
28 
29 using namespace std;
30 using namespace Pythia8;
31 using namespace Photospp;
32 using namespace Tauolapp;
33 
34 unsigned long NumberOfEvents = 10000;
35 unsigned int EventsToCheck=20;
36 
37 // elementary test of HepMC typically executed before
38 // detector simulation based on http://home.fnal.gov/~mrenna/HCPSS/HCPSShepmc.html
39 // similar test was performed in Fortran
40 // we perform it before and after Photos (for the first several events)
41 void checkMomentumConservationInEvent(HepMC::GenEvent *evt)
42 {
43  //cout<<"List of stable particles: "<<endl;
44 
45  double px=0.0,py=0.0,pz=0.0,e=0.0;
46 
47  for ( HepMC::GenEvent::particle_const_iterator p = evt->particles_begin();
48  p != evt->particles_end(); ++p )
49  {
50  if( (*p)->status() == 1 )
51  {
52  HepMC::FourVector m = (*p)->momentum();
53  px+=m.px();
54  py+=m.py();
55  pz+=m.pz();
56  e +=m.e();
57  //(*p)->print();
58  }
59  }
60  cout.precision(6);
61  cout.setf(ios_base::floatfield);
62  cout<<endl<<"Vector Sum: "<<px<<" "<<py<<" "<<pz<<" "<<e<<endl;
63 }
64 
65 int main(int argc,char **argv)
66 {
67 
68  // Program needs at least 4 parameters
69  if(argc<5)
70  {
71  cout<<endl<<"Usage: "<<argv[0]<<" <pythia_conf> <pythia_mode> <no_events> <tauola_mode> [ <alpha_order> <ScalarNLO_mode> ]"<<endl;
72  cout<<endl<<" eg. "<<argv[0]<<" pythia_H.conf 0 10000 4 0 0"<<endl;
73  cout<<endl;
74  return -1;
75  }
76 
77  HepMC::I_Pythia8 ToHepMC;
78 
79  // Initialization of pythia
80  Pythia pythia;
81  Event& event = pythia.event;
82 
83  pythia.readString("HadronLevel:Hadronize = off");
84  pythia.readString("SpaceShower:QEDshower = off");
85  pythia.readString("SpaceShower:QEDshowerByL = off");
86  pythia.readString("SpaceShower:QEDshowerByQ = off");
87  pythia.readString("PartonLevel:ISR = off");
88  pythia.readString("PartonLevel:FSR = off");
89 
90  // Tauola is currently set to undecay taus. Otherwise, uncomment this line.
91  //pythia.particleData.readString("15:mayDecay = off");
92 
93  /********************************************************
94  Read input parameters from console. List of parameters:
95  1. Pythia configuration filename
96  2. Pythia mode - e+e-@200GeV , e+e-@91.187GeV, pp@14TeV or e+e-@500GeV
97  (only e+e-@91.187GeV and e+e-@500GeV are used in this example)
98  3. Number of events
99  4. Tauola decay mode (refer to Tauola documentation)
100  5. Photos - use 1-photon mode on/off
101  6. Photos - use ScalarNLO mode on/off
102 
103  Example where all input parameters are used:
104 
105  ./photos_tauola_test.exe pythia_H.conf 1 100000 4 0 0
106  - use pythia_H.conf
107  - initialize using e+ e- @ 91.187GeV collisions
108  - generate 100 000 events
109  - fix TAUOLA decay to channel 4 (RHORHO_MODE)
110  - Photos is not using 1-photon mode (default option)
111  - Photos is not in ScalarNLO mode (default option)
112  *********************************************************/
113 
114  // 1. Load pythia configuration file (argv[1], from console)
115  if(argc>1) pythia.readFile(argv[1]);
116 
117  // 2. Initialize pythia to e+e-@91.17GeV or e+e-@500GeV collisions (argv[2], from console)
118  if(atoi(argv[2])==1) pythia.init( 11, -11, 91.187); // e+ e- collisions
119  else if(atoi(argv[2])==3) pythia.init( 11, -11, 500.); // e+ e- collisions
120  else
121  {
122  cout<<"ERROR: Wrong Pythia mode ("<<atoi(argv[4])<<")"<<endl;
123  cout<<" Only modes '1' and '3' are used by this program."<<endl;
124  return -1;
125  }
126 
127  // 3. Get number of events (argv[3], from console)
128  if(argc>3) NumberOfEvents=atoi(argv[3]);
129 
130  // 4. Set Tauola decay mode (argv[4], from console)
131  if(argc>4)
132  {
133  // argv[4]=3 (tau => pi nu_tau) for Ztautau
134  // argv[4]=4 (tau => pi pi nu_tau) for Htautau
135  Tauola::setSameParticleDecayMode(atoi(argv[4]));
136  Tauola::setOppositeParticleDecayMode(atoi(argv[4]));
137  }
138 
141 
142  Photos::setExponentiation(true);
143  Photos::setInfraredCutOff(1.e-6);
144  Photos::maxWtInterference(3.0);
145 
146  // 5. Check if we're using 1-photon mode
147  if( argc>5 && atoi(argv[5]) )
148  {
149  Photos::setDoubleBrem(false);
150  Photos::setExponentiation(false);
151 
152  // Set infrared cutoff to 10MeV for scale M_Z=91.187GeV or 500 GeV
153  if(atoi(argv[2])==1) Photos::setInfraredCutOff(0.01/91.187);
154  else Photos::setInfraredCutOff(0.01/500.);
155 
156  Photos::maxWtInterference(2.0);
157  }
158 
159  // 6. Check if we're in ScalarNLO mode
160  if( argc>6 )
161  {
162  Tauola::setEtaK0sPi(1,1,0);
163 
164  // Check if we are using NLO
165  if(atoi(argv[6])) Photos::setMeCorrectionWtForScalar(true);
166  }
167 
168  Log::SummaryAtExit();
169  cout.setf(ios::fixed);
170 
171  MC_Initialize();
172 
173  // Begin event loop
174  for(unsigned long iEvent = 0; iEvent < NumberOfEvents; ++iEvent)
175  {
176  if(iEvent%1000==0) Log::Info()<<"Event: "<<iEvent<<"\t("<<iEvent*(100./NumberOfEvents)<<"%)"<<endl;
177  if(!pythia.next()) continue;
178 
179  HepMC::GenEvent * HepMCEvt = new HepMC::GenEvent();
180  ToHepMC.fill_next_event(event, HepMCEvt);
181 
182  if(iEvent<EventsToCheck)
183  {
184  cout<<" "<<endl;
185  cout<<"Momentum conservation chceck BEFORE/AFTER Photos"<<endl;
187  }
188 
189  // Run TAUOLA on the event
190  TauolaHepMCEvent * t_event = new TauolaHepMCEvent(HepMCEvt);
191 
192  // Since we let Pythia decay taus, we have to undecay them first.
193  t_event->undecayTaus();
194  t_event->decayTaus();
195  delete t_event;
196 
197  // Run PHOTOS on the event
198  PhotosHepMCEvent evt(HepMCEvt);
199  evt.process();
200 
201  if(iEvent<EventsToCheck)
202  {
204  }
205 
206  // Run MC-TESTER on the event
207  HepMCEvent temp_event(*HepMCEvt,false);
208  MC_Analyze(&temp_event);
209 
210  //clean up
211  delete HepMCEvt;
212  }
213  pythia.statistics();
214  MC_Finalize();
215 }
Double_t p
Definition: anasim.C:58
int main(int argc, char **argv)
int EventsToCheck
__m128 m
Definition: P4_F32vec4.h:28
int NumberOfEvents
int evt
Definition: checkhelixhit.C:36
void initialize()
void checkMomentumConservationInEvent(PhotosHEPEVTEvent *evt)
Pythia8::Pythia * pythia
double pz[39]
Definition: pipisigmas.h:14