photos_test.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 using namespace std;
00024 using namespace Pythia8;
00025 using namespace Photospp;
00026
00027 unsigned long NumberOfEvents = 10000;
00028 unsigned int EventsToCheck=20;
00029
00030
00031
00032
00033
00034 void checkMomentumConservationInEvent(HepMC::GenEvent *evt)
00035 {
00036
00037
00038 double px=0.0,py=0.0,pz=0.0,e=0.0;
00039
00040 for ( HepMC::GenEvent::particle_const_iterator p = evt->particles_begin();
00041 p != evt->particles_end(); ++p )
00042 {
00043 if( (*p)->status() == 1 )
00044 {
00045 HepMC::FourVector m = (*p)->momentum();
00046 px+=m.px();
00047 py+=m.py();
00048 pz+=m.pz();
00049 e +=m.e();
00050
00051 }
00052 }
00053 cout.precision(6);
00054 cout.setf(ios_base::floatfield);
00055 cout<<endl<<"Vector Sum: "<<px<<" "<<py<<" "<<pz<<" "<<e<<endl;
00056 }
00057
00058
00059
00060 void fixForMctester(HepMC::GenEvent *evt)
00061 {
00062 for(HepMC::GenEvent::particle_const_iterator p=evt->particles_begin();p!=evt->particles_end(); p++)
00063 if((*p)->pdg_id()==6)
00064 {
00065 HepMC::GenParticle *pt = *p;
00066 int id=(* pt->production_vertex()->particles_in_const_begin() )->pdg_id();
00067 if(id!=21 && id!=11 && id>5) continue;
00068
00069
00070 HepMC::GenParticle *X = (* pt->production_vertex()->particles_in_const_begin());
00071 HepMC::GenParticle *Y = (* ++(pt->production_vertex()->particles_in_const_begin()) );
00072 HepMC::FourVector fX = X->momentum();
00073 HepMC::FourVector fY = Y->momentum();
00074 HepMC::FourVector fXY(fX.px()+fY.px(),fX.py()+fY.py(),fX.pz()+fY.pz(),fX.e()+fY.e());
00075 X->set_momentum(fXY);
00076
00077 X->set_pdg_id(100);
00078
00079
00080 Y->set_status(1);
00081 (* Y->production_vertex()->particles_in_const_begin())->set_status(1);
00082 pt->production_vertex()->remove_particle(Y);
00083 return;
00084 }
00085 }
00086
00087 int main(int argc,char **argv)
00088 {
00089
00090
00091 if(argc<4)
00092 {
00093 cout<<endl<<"Usage: "<<argv[0]<<" <pythia_conf> <pythia_mode> <no_events> [ <special_mode> ]"<<endl;
00094 cout<<endl<<" eg. "<<argv[0]<<" pythia_W.conf 0 10000 4 0"<<endl;
00095 cout<<endl;
00096 return -1;
00097 }
00098
00099 HepMC::I_Pythia8 ToHepMC;
00100
00101
00102 Pythia pythia;
00103 Event& event = pythia.event;
00104
00105 pythia.readString("HadronLevel:Hadronize = off");
00106 pythia.readString("SpaceShower:QEDshower = off");
00107 pythia.readString("SpaceShower:QEDshowerByL = off");
00108 pythia.readString("SpaceShower:QEDshowerByQ = off");
00109 pythia.readString("PartonLevel:ISR = off");
00110 pythia.readString("PartonLevel:FSR = off");
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134 if(argc>1) pythia.readFile(argv[1]);
00135
00136
00137 if(atoi(argv[2])==0) pythia.init( 11, -11, 200.);
00138 else if(atoi(argv[2])==1) pythia.init( 11, -11, 91.187);
00139 else pythia.init( -2212, -2212, 14000.0);
00140
00141
00142 if(argc>3) NumberOfEvents=atoi(argv[3]);
00143
00144 Photos::initialize();
00145
00146 Photos::setInfraredCutOff(1.e-6);
00147 Photos::maxWtInterference(3.0);
00148
00149 bool topDecays = false;
00150
00151
00152 if(argc>4)
00153 {
00154
00155 if(atoi(argv[4])==1) topDecays=true;
00156
00157 else if(atoi(argv[4])==2)
00158 {
00159 Photos::setMeCorrectionWtForW(true);
00160 Photos::setMeCorrectionWtForZ(true);
00161
00162 }
00163 }
00164
00165
00166 if(argc>5 && atoi(argv[5])==1)
00167 {
00168 Photos::setDoubleBrem(false);
00169 Photos::setExponentiation(false);
00170 Photos::setInfraredCutOff(0.001);
00171 Photos::maxWtInterference(2.0);
00172
00173
00174 }
00175
00176
00177 MC_Initialize();
00178
00179 Photos::iniInfo();
00180 Log::SummaryAtExit();
00181 cout.setf(ios::fixed);
00182
00183
00184 for(unsigned long iEvent = 0; iEvent < NumberOfEvents; ++iEvent)
00185 {
00186 if(iEvent%1000==0) Log::Info()<<"Event: "<<iEvent<<"\t("<<iEvent*(100./NumberOfEvents)<<"%)"<<endl;
00187 if (!pythia.next()) continue;
00188
00189 HepMC::GenEvent * HepMCEvt = new HepMC::GenEvent();
00190 ToHepMC.fill_next_event(event, HepMCEvt);
00191
00192 if(iEvent<EventsToCheck)
00193 {
00194 cout<<" "<<endl;
00195 cout<<"Momentum conservation chceck BEFORE/AFTER Photos"<<endl;
00196 checkMomentumConservationInEvent(HepMCEvt);
00197 }
00198
00199
00200 PhotosHepMCEvent evt(HepMCEvt);
00201 evt.process();
00202
00203 if(iEvent<EventsToCheck)
00204 {
00205 checkMomentumConservationInEvent(HepMCEvt);
00206 }
00207
00208
00209 if(topDecays) fixForMctester(HepMCEvt);
00210
00211
00212 HepMCEvent temp_event(*HepMCEvt,false);
00213 MC_Analyze(&temp_event);
00214
00215
00216 delete HepMCEvt;
00217 }
00218 pythia.statistics();
00219 MC_Finalize();
00220 }