photosLCG_pythia_example.cxx
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "Pythia.h"
00011 #include "HepMCInterface.h"
00012
00013
00014 #include "Photos/Photos.h"
00015 #include "Photos/PhotosHepMCEvent.h"
00016 #include "Photos/Log.h"
00017
00018 using namespace std;
00019 using namespace Pythia8;
00020 using namespace Photospp;
00021
00022 bool ShowersOn=true;
00023 unsigned long NumberOfEvents = 100000;
00024
00025
00026 double calculate_ratio(HepMC::GenEvent *evt, double *ratio_2)
00027 {
00028 double ratio = 0.0;
00029 for(HepMC::GenEvent::particle_const_iterator p=evt->particles_begin();p!=evt->particles_end(); p++)
00030 {
00031
00032 if( (*p)->pdg_id() != 23 ) continue;
00033
00034
00035 if( !(*p)->end_vertex() || (*p)->end_vertex()->particles_out_size() < 2 ) continue;
00036
00037
00038 double sum = 0.0;
00039 for(HepMC::GenVertex::particle_iterator pp = (*p)->end_vertex()->particles_begin(HepMC::children);
00040 pp != (*p)->end_vertex()->particles_end(HepMC::children);
00041 ++pp)
00042 {
00043
00044 if( (*pp)->pdg_id() != 22 ) sum += (*pp)->momentum().e();
00045 }
00046
00047
00048 ratio = sum / (*p)->momentum().e();
00049 *ratio_2 = sum*sum / ( (*p)->momentum().e() * (*p)->momentum().e() );
00050
00051
00052 return ratio;
00053 }
00054 return 0.0;
00055 }
00056
00057 int main(int argc,char **argv)
00058 {
00059
00060 HepMC::I_Pythia8 ToHepMC;
00061 Pythia pythia;
00062 Event& event = pythia.event;
00063
00064
00065 if(!ShowersOn)
00066 {
00067
00068 pythia.readString("HadronLevel:Hadronize = off");
00069 pythia.readString("SpaceShower:QEDshower = off");
00070 pythia.readString("SpaceShower:QEDshowerByL = off");
00071 pythia.readString("SpaceShower:QEDshowerByQ = off");
00072 }
00073 pythia.readString("PartonLevel:ISR = on");
00074 pythia.readString("PartonLevel:FSR = off");
00075
00076 pythia.readString("WeakSingleBoson:ffbar2gmZ = on");
00077 pythia.readString("23:onMode = off");
00078 pythia.readString("23:onIfAny = 13");
00079
00080 pythia.init( 11, -11, 91.187);
00081
00082 Photos::initialize();
00083
00084
00085
00086
00087
00088
00089
00090 Log::SummaryAtExit();
00091 cout.setf(ios::fixed);
00092
00093 double ratio_exp = 0.0, ratio_alpha = 0.0;
00094 double ratio_exp_2 = 0.0, ratio_alpha_2 = 0.0;
00095 double buf = 0.0;
00096
00097 Photos::setDoubleBrem(true);
00098 Photos::setExponentiation(true);
00099 Photos::setInfraredCutOff(0.000001);
00100
00101 Log::Info() << "---------------- First run - EXP ----------------" <<endl;
00102
00103
00104 for(unsigned long iEvent = 0; iEvent < NumberOfEvents; ++iEvent)
00105 {
00106 if(iEvent%10000==0) Log::Info()<<"Event: "<<iEvent<<"\t("<<iEvent*(100./NumberOfEvents)<<"%)"<<endl;
00107 if (!pythia.next()) continue;
00108
00109 HepMC::GenEvent * HepMCEvt = new HepMC::GenEvent();
00110 ToHepMC.fill_next_event(event, HepMCEvt);
00111
00112
00113
00114
00115
00116 PhotosHepMCEvent evt(HepMCEvt);
00117 evt.process();
00118
00119 ratio_exp += calculate_ratio(HepMCEvt,&buf);
00120 ratio_exp_2 += buf;
00121
00122
00123
00124
00125 delete HepMCEvt;
00126 }
00127
00128 Photos::setDoubleBrem(false);
00129 Photos::setExponentiation(false);
00130 Photos::setInfraredCutOff(1./91.187);
00131
00132
00133 Log::Info() << "---------------- Second run - ALPHA ORDER ----------------" <<endl;
00134
00135
00136 for(unsigned long iEvent = 0; iEvent < NumberOfEvents; ++iEvent)
00137 {
00138 if(iEvent%10000==0) Log::Info()<<"Event: "<<iEvent<<"\t("<<iEvent*(100./NumberOfEvents)<<"%)"<<endl;
00139 if (!pythia.next()) continue;
00140
00141 HepMC::GenEvent * HepMCEvt = new HepMC::GenEvent();
00142 ToHepMC.fill_next_event(event, HepMCEvt);
00143
00144
00145
00146
00147
00148 PhotosHepMCEvent evt(HepMCEvt);
00149 evt.process();
00150
00151 ratio_alpha += calculate_ratio(HepMCEvt,&buf);
00152 ratio_alpha_2 += buf;
00153
00154
00155
00156
00157 delete HepMCEvt;
00158 }
00159
00160 pythia.statistics();
00161
00162 ratio_exp = ratio_exp / (double)NumberOfEvents;
00163 ratio_exp_2 = ratio_exp_2 / (double)NumberOfEvents;
00164
00165 ratio_alpha = ratio_alpha / (double)NumberOfEvents;
00166 ratio_alpha_2 = ratio_alpha_2 / (double)NumberOfEvents;
00167
00168 double err_exp = sqrt( (ratio_exp_2 - ratio_exp * ratio_exp ) / (double)NumberOfEvents );
00169 double err_alpha = sqrt( (ratio_alpha_2 - ratio_alpha * ratio_alpha) / (double)NumberOfEvents );
00170
00171 cout.precision(6);
00172 cout.setf(ios::fixed);
00173 cout << "********************************************************" << endl;
00174 cout << "* Z -> l + bar_l + gammas *" << endl;
00175 cout << "* E(l + bar_l) / E(l + bar_l + gammas) ratio *" << endl;
00176 cout << "* *" << endl;
00177 cout << "* PHOTOS - EXP: " << ratio_exp <<" +/- "<<err_exp <<" *" << endl;
00178 cout << "* PHOTOS - ALPHA ORDER: " << ratio_alpha <<" +/- "<<err_alpha<<" *" << endl;
00179 cout << "********************************************************" << endl;
00180
00181 }