2 * Example of use of photos C++ interface. Pythia events are
3 * generated first and photos used for FSR.
5 * @author LCG & Tomasz Przedzinski
11 #include "HepMCInterface.h"
14 #include "Photos/Photos.h"
15 #include "Photos/PhotosHepMCEvent.h"
16 #include "Photos/Log.h"
19 using namespace Pythia8;
20 using namespace Photospp;
23 unsigned long NumberOfEvents = 100000;
25 // Calculates energy ratio between (l + bar_l) and (l + bar_l + X)
26 double calculate_ratio(HepMC::GenEvent *evt, double *ratio_2)
29 for(HepMC::GenEvent::particle_const_iterator p=evt->particles_begin();p!=evt->particles_end(); p++)
32 if( (*p)->pdg_id() != 23 ) continue;
34 // Ignore this Z if it does not have at least two daughters
35 if( !(*p)->end_vertex() || (*p)->end_vertex()->particles_out_size() < 2 ) continue;
37 // Sum all daughters other than photons
39 for(HepMC::GenVertex::particle_iterator pp = (*p)->end_vertex()->particles_begin(HepMC::children);
40 pp != (*p)->end_vertex()->particles_end(HepMC::children);
44 if( (*pp)->pdg_id() != 22 ) sum += (*pp)->momentum().e();
47 // Calculate ratio and ratio^2
48 ratio = sum / (*p)->momentum().e();
49 *ratio_2 = sum*sum / ( (*p)->momentum().e() * (*p)->momentum().e() );
51 // Assuming only one Z decay per event
57 int main(int argc,char **argv)
59 // Initialization of pythia
60 HepMC::I_Pythia8 ToHepMC;
62 Event& event = pythia.event;
63 //pythia.settings.listAll();
67 //pythia.readString("HadronLevel:all = off");
68 pythia.readString("HadronLevel:Hadronize = off");
69 pythia.readString("SpaceShower:QEDshower = off");
70 pythia.readString("SpaceShower:QEDshowerByL = off");
71 pythia.readString("SpaceShower:QEDshowerByQ = off");
73 pythia.readString("PartonLevel:ISR = on");
74 pythia.readString("PartonLevel:FSR = off");
76 pythia.readString("WeakSingleBoson:ffbar2gmZ = on");
77 pythia.readString("23:onMode = off");
78 pythia.readString("23:onIfAny = 13");
79 //pythia.readString("23:onIfAny = 11");
80 pythia.init( 11, -11, 91.187); //e+ e- collisions
84 // Turn on NLO corrections - only for PHOTOS 3.2 or higher
86 //Photos::setMeCorrectionWtForZ(zNLO);
87 //Photos::maxWtInterference(4.0);
91 cout.setf(ios::fixed);
93 double ratio_exp = 0.0, ratio_alpha = 0.0;
94 double ratio_exp_2 = 0.0, ratio_alpha_2 = 0.0;
97 Photos::setDoubleBrem(true);
98 Photos::setExponentiation(true);
99 Photos::setInfraredCutOff(0.000001);
101 Log::Info() << "---------------- First run - EXP ----------------" <<endl;
104 for(unsigned long iEvent = 0; iEvent < NumberOfEvents; ++iEvent)
106 if(iEvent%10000==0) Log::Info()<<"Event: "<<iEvent<<"\t("<<iEvent*(100./NumberOfEvents)<<"%)"<<endl;
107 if (!pythia.next()) continue;
109 HepMC::GenEvent * HepMCEvt = new HepMC::GenEvent();
110 ToHepMC.fill_next_event(event, HepMCEvt);
113 //Log::LogPhlupa(1,3);
116 PhotosHepMCEvent evt(HepMCEvt);
119 ratio_exp += calculate_ratio(HepMCEvt,&buf);
128 Photos::setDoubleBrem(false);
129 Photos::setExponentiation(false);
130 Photos::setInfraredCutOff(1./91.187); // that is 1 GeV for
131 // pythia.init( 11, -11, 91.187);
133 Log::Info() << "---------------- Second run - ALPHA ORDER ----------------" <<endl;
136 for(unsigned long iEvent = 0; iEvent < NumberOfEvents; ++iEvent)
138 if(iEvent%10000==0) Log::Info()<<"Event: "<<iEvent<<"\t("<<iEvent*(100./NumberOfEvents)<<"%)"<<endl;
139 if (!pythia.next()) continue;
141 HepMC::GenEvent * HepMCEvt = new HepMC::GenEvent();
142 ToHepMC.fill_next_event(event, HepMCEvt);
145 //Log::LogPhlupa(1,3);
148 PhotosHepMCEvent evt(HepMCEvt);
151 ratio_alpha += calculate_ratio(HepMCEvt,&buf);
152 ratio_alpha_2 += buf;
162 ratio_exp = ratio_exp / (double)NumberOfEvents;
163 ratio_exp_2 = ratio_exp_2 / (double)NumberOfEvents;
165 ratio_alpha = ratio_alpha / (double)NumberOfEvents;
166 ratio_alpha_2 = ratio_alpha_2 / (double)NumberOfEvents;
168 double err_exp = sqrt( (ratio_exp_2 - ratio_exp * ratio_exp ) / (double)NumberOfEvents );
169 double err_alpha = sqrt( (ratio_alpha_2 - ratio_alpha * ratio_alpha) / (double)NumberOfEvents );
172 cout.setf(ios::fixed);
173 cout << "********************************************************" << endl;
174 cout << "* Z -> l + bar_l + gammas *" << endl;
175 cout << "* E(l + bar_l) / E(l + bar_l + gammas) ratio *" << endl;
176 cout << "* *" << endl;
177 cout << "* PHOTOS - EXP: " << ratio_exp <<" +/- "<<err_exp <<" *" << endl;
178 cout << "* PHOTOS - ALPHA ORDER: " << ratio_alpha <<" +/- "<<err_alpha<<" *" << endl;
179 cout << "********************************************************" << endl;