10 #include "Pythia8/Pythia.h"
11 #include "Pythia8Plugins/HepMC2.h"
15 #include "HepMCEvent.H"
19 #include "Photos/Photos.h"
20 #include "Photos/PhotosHepMCEvent.h"
21 #include "Photos/Log.h"
24 using namespace Pythia8;
25 using namespace Photospp;
27 unsigned long NumberOfEvents = 10000;
28 unsigned int EventsToCheck=20;
34 void checkMomentumConservationInEvent(HepMC::GenEvent *evt)
38 double px=0.0,py=0.0,pz=0.0,e=0.0;
40 for ( HepMC::GenEvent::particle_const_iterator p = evt->particles_begin();
41 p != evt->particles_end(); ++p )
43 if( (*p)->status() == 1 )
45 HepMC::FourVector m = (*p)->momentum();
54 cout.setf(ios_base::scientific, ios_base::floatfield);
55 cout<<endl<<
"Vector Sum: "<<px<<
" "<<py<<
" "<<pz<<
" "<<e<<endl;
60 void fixForMctester(HepMC::GenEvent *evt)
62 for(HepMC::GenEvent::particle_const_iterator p=evt->particles_begin();p!=evt->particles_end(); p++)
65 HepMC::GenParticle *pt = *p;
66 int id=(* pt->production_vertex()->particles_in_const_begin() )->pdg_id();
67 if(
id!=21 &&
id!=11 &&
id>5)
continue;
70 HepMC::GenParticle *X = (* pt->production_vertex()->particles_in_const_begin());
71 HepMC::GenParticle *Y = (* ++(pt->production_vertex()->particles_in_const_begin()) );
72 HepMC::FourVector fX = X->momentum();
73 HepMC::FourVector fY = Y->momentum();
74 HepMC::FourVector fXY(fX.px()+fY.px(),fX.py()+fY.py(),fX.pz()+fY.pz(),fX.e()+fY.e());
81 (* Y->production_vertex()->particles_in_const_begin())->set_status(1);
82 pt->production_vertex()->remove_particle(Y);
87 int main(
int argc,
char **argv)
93 cout<<endl<<
"Usage: "<<argv[0]<<
" <pythia_conf> <no_events> [ <special_mode> ]"<<endl;
94 cout<<endl<<
" eg. "<<argv[0]<<
" pythia_W.conf 0 10000 4 0"<<endl;
99 HepMC::Pythia8ToHepMC ToHepMC;
103 Event&
event = pythia.event;
122 pythia.readFile(argv[1]);
125 NumberOfEvents = atoi(argv[2]);
128 Photos::initialize();
130 Photos::setInfraredCutOff(1.e-6);
131 Photos::maxWtInterference(3.0);
133 bool topDecays =
false;
134 bool pairEmission =
false;
140 if(atoi(argv[3])==1) topDecays=
true;
142 else if(atoi(argv[3])==2)
144 Photos::setMeCorrectionWtForW(
true);
145 Photos::setMeCorrectionWtForZ(
true);
149 else if(atoi(argv[3])==4)
156 if(argc>4 && atoi(argv[4])==1)
158 Photos::setDoubleBrem(
false);
159 Photos::setExponentiation(
false);
160 Photos::setInfraredCutOff(0.001);
161 Photos::maxWtInterference(2.0);
167 Photos::setPairEmission(pairEmission);
172 Log::SummaryAtExit();
175 for(
unsigned long iEvent = 0; iEvent < NumberOfEvents; ++iEvent)
177 cout.setf(ios_base::fixed, ios_base::floatfield);
178 if(iEvent%1000==0) Log::Info()<<
"Event: "<<iEvent<<
"\t("<<iEvent*(100./NumberOfEvents)<<
"%)"<<endl;
181 Photos::setEventNo(iEvent);
184 if (!pythia.next())
continue;
186 HepMC::GenEvent * HepMCEvt =
new HepMC::GenEvent();
187 ToHepMC.fill_next_event(event, HepMCEvt);
189 if(iEvent<EventsToCheck)
192 cout<<
"Momentum conservation check BEFORE/AFTER Photos"<<endl;
193 checkMomentumConservationInEvent(HepMCEvt);
200 if(iEvent<EventsToCheck)
202 checkMomentumConservationInEvent(HepMCEvt);
206 if(topDecays) fixForMctester(HepMCEvt);
209 HepMCEvent temp_event(*HepMCEvt,
false);
210 MC_Analyze(&temp_event);
222 const double PI=3.141592653589793238462643;
223 const double ALFINV= 137.01;
225 double deno=log(91/2/0.000511);
226 deno=deno*deno*(deno+log(2.))*4;
228 double L=log(2*delta/0.000511)-5.0/6.0;
229 double num=0.99* 4.0/3.0*(L*L*L/3.+ (31./36.- PI*PI/6.)*L+0.5940);
230 printf (
" >>> Soft pairs emission --- probability tests <<< \n");
231 printf (
" Delta = %15.8f GeV (set the same in pairs.cxx): \n", delta);
232 printf (
" Z->ee: \n");
233 printf (
" Abslolute= %15.8f Relative to crude= %15.8f \n",num/PI/PI/ALFINV/ALFINV/0.99, num/deno);
236 deno=log(91/2/0.1056);
237 deno=deno*deno*(deno+log(2.))*4;
238 L=log(2*delta/0.1056)-5.0/6.0;
239 num=0.99* 4.0/3.0*(L*L*L/3.+ (31./36.- PI*PI/6.)*L+0.5940);
240 printf (
" Z->mumu: \n");
241 printf (
" Abslolute= %15.8f Relative to crude= %15.8f \n",num/PI/PI/ALFINV/ALFINV/0.99, num/deno);