tauola_photos_pythia_example.cxx
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "Pythia.h"
00011 #include "HepMCInterface.h"
00012
00013
00014 #include "Generate.h"
00015 #include "HepMCEvent.H"
00016 #include "Setup.H"
00017
00018
00019 #include "Photos/Photos.h"
00020 #include "Photos/PhotosHepMCEvent.h"
00021 #include "Photos/Log.h"
00022
00023
00024 #include "Tauola/Tauola.h"
00025 #include "Tauola/TauolaHepMCEvent.h"
00026
00027 using namespace std;
00028 using namespace Pythia8;
00029 using namespace Photospp;
00030 using namespace Tauolapp;
00031
00032 unsigned long NumberOfEvents = 10000;
00033 unsigned int EventsToCheck=20;
00034
00035
00036
00037
00038
00039 void checkMomentumConservationInEvent(HepMC::GenEvent *evt)
00040 {
00041
00042
00043 double px=0.0,py=0.0,pz=0.0,e=0.0;
00044
00045 for ( HepMC::GenEvent::particle_const_iterator p = evt->particles_begin();
00046 p != evt->particles_end(); ++p )
00047 {
00048 if( (*p)->status() == 1 )
00049 {
00050 HepMC::FourVector m = (*p)->momentum();
00051 px+=m.px();
00052 py+=m.py();
00053 pz+=m.pz();
00054 e +=m.e();
00055
00056 }
00057 }
00058 cout.precision(6);
00059 cout.setf(ios_base::floatfield);
00060 cout<<endl<<"Vector Sum: "<<px<<" "<<py<<" "<<pz<<" "<<e<<endl;
00061 }
00062
00063 int main(int argc,char **argv)
00064 {
00065 HepMC::I_Pythia8 ToHepMC;
00066
00067
00068 Pythia pythia;
00069 Event& event = pythia.event;
00070
00071 pythia.readString("PartonLevel:ISR = off");
00072 pythia.readString("PartonLevel:FSR = off");
00073
00074 pythia.readString("WeakSingleBoson:ffbar2gmZ = on");
00075 pythia.readString("23:onMode = off");
00076 pythia.readString("23:onIfAny = 15");
00077 pythia.particleData.readString("15:mayDecay = off");
00078
00079
00080 pythia.init( 11, -11, 91.187);
00081
00082
00083 Tauola::initialize();
00084 Photos::initialize();
00085
00086 Photos::setInfraredCutOff(0.01/91.187);
00087
00088
00089
00090 Log::SummaryAtExit();
00091 cout.setf(ios::fixed);
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121 MC_Initialize();
00122
00123
00124 for (unsigned long iEvent = 0; iEvent < NumberOfEvents; ++iEvent)
00125 {
00126 if(iEvent%1000==0) Log::Info()<<"Event: "<<iEvent<<"\t("<<iEvent*(100./NumberOfEvents)<<"%)"<<endl;
00127 if(!pythia.next()) continue;
00128
00129
00130 HepMC::GenEvent * HepMCEvt = new HepMC::GenEvent();
00131 ToHepMC.fill_next_event(event, HepMCEvt);
00132
00133
00134 TauolaHepMCEvent * t_event = new TauolaHepMCEvent(HepMCEvt);
00135
00136
00137
00138 t_event->decayTaus();
00139 delete t_event;
00140
00141
00142
00143 if(iEvent<EventsToCheck)
00144 {
00145 cout<<" "<<endl;
00146 cout<<"Momentum conservation chceck BEFORE/AFTER Photos"<<endl;
00147 checkMomentumConservationInEvent(HepMCEvt);
00148 }
00149
00150
00151 PhotosHepMCEvent evt(HepMCEvt);
00152 evt.process();
00153
00154 if(iEvent<EventsToCheck)
00155 {
00156 checkMomentumConservationInEvent(HepMCEvt);
00157 }
00158
00159
00160 HepMCEvent temp_event(*HepMCEvt,false);
00161 MC_Analyze(&temp_event);
00162
00163
00164 if(iEvent>=NumberOfEvents-5)
00165 {
00166 Log::RedirectOutput(Log::Info());
00167
00168 HepMCEvt->print();
00169 Log::RevertOutput();
00170 }
00171
00172
00173 delete HepMCEvt;
00174 }
00175
00176 Log::RedirectOutput(Log::Info());
00177 pythia.statistics();
00178 Log::RevertOutput();
00179
00180 MC_Finalize();
00181 }