FairRoot/PandaRoot
Functions | Variables
photos_pythia_example.cxx File Reference
#include "Pythia.h"
#include "HepMCInterface.h"
#include "Generate.h"
#include "HepMCEvent.H"
#include "Setup.H"
#include "Photos/Photos.h"
#include "Photos/PhotosHepMCEvent.h"
#include "Photos/Log.h"

Go to the source code of this file.

Functions

void checkMomentumConservationInEvent (HepMC::GenEvent *evt)
 
void switch_history_entries_status (HepMC::GenEvent *evt)
 
int main (int argc, char **argv)
 

Variables

bool ShowersOn =true
 
unsigned long NumberOfEvents = 10000
 
unsigned int EventsToCheck =20
 

Function Documentation

void checkMomentumConservationInEvent ( HepMC::GenEvent *  evt)

Definition at line 35 of file photos_pythia_example.cxx.

References m, p, and pz.

36 {
37  //cout<<"List of stable particles: "<<endl;
38 
39  double px=0.0,py=0.0,pz=0.0,e=0.0;
40 
41  for ( HepMC::GenEvent::particle_const_iterator p = evt->particles_begin();
42  p != evt->particles_end(); ++p )
43  {
44  if( (*p)->status() == 1 )
45  {
46  HepMC::FourVector m = (*p)->momentum();
47  px+=m.px();
48  py+=m.py();
49  pz+=m.pz();
50  e +=m.e();
51  //(*p)->print();
52  }
53  }
54  cout.precision(6);
55  cout.setf(ios_base::floatfield);
56  cout<<endl<<"Vector Sum: "<<px<<" "<<py<<" "<<pz<<" "<<e<<endl;
57 }
Double_t p
Definition: anasim.C:58
__m128 m
Definition: P4_F32vec4.h:28
int evt
Definition: checkhelixhit.C:36
double pz[39]
Definition: pipisigmas.h:14
int main ( int  argc,
char **  argv 
)

Definition at line 145 of file photos_pythia_example.cxx.

References checkMomentumConservationInEvent(), EventsToCheck, evt, chigen::initialize(), NumberOfEvents, Photospp::PhotosEvent::process(), and chigen::pythia::pythia.

146 {
147  // Initialization of pythia
148  HepMC::I_Pythia8 ToHepMC;
149  Pythia pythia;
150  Event& event = pythia.event;
151  //pythia.settings.listAll();
152 
153  pythia.readString("PartonLevel:ISR = on");
154  pythia.readString("PartonLevel:FSR = off");
155 
156  pythia.readString("WeakSingleBoson:ffbar2gmZ = on");
157  pythia.readString("23:onMode = off");
158  pythia.readString("23:onIfAny = 13");
159  pythia.init( 11, -11, 91.187); //e+ e- collisions
160 
161  MC_Initialize();
162 
164  //Photos::setDoubleBrem(false);
165  //Photos::setExponentiation(false);
166 
167  Photos::setInfraredCutOff(0.01/91.187); // 10MeV for scale to M_Z=91.187
168  Photos::maxWtInterference(3.0);
169  //Photos::createHistoryEntries(true,3);
170 
171  Photos::iniInfo();
172  Log::SummaryAtExit();
173  cout.setf(ios::fixed);
174 
175  // Begin event loop
176  for(unsigned long iEvent = 0; iEvent < NumberOfEvents; ++iEvent)
177  {
178  if(iEvent%1000==0) Log::Info()<<"Event: "<<iEvent<<"\t("<<iEvent*(100./NumberOfEvents)<<"%)"<<endl;
179  if (!pythia.next()) continue;
180 
181  // Convert event record to HepMC
182  HepMC::GenEvent * HepMCEvt = new HepMC::GenEvent();
183  ToHepMC.fill_next_event(event, HepMCEvt);
184  //HepMCEvt->print();
185 
186  if(iEvent<EventsToCheck)
187  {
188  cout<<" "<<endl;
189  cout<<"Momentum conservation chceck BEFORE/AFTER Photos"<<endl;
191  }
192 
193  //Log::LogPhlupa(1,3);
194 
195  // Run PHOTOS on the event
196  PhotosHepMCEvent evt(HepMCEvt);
197  evt.process();
198 
199  // Uncomment to turn on switching of the status code of history entries
200  // with the regular entries for stable particles
201  //switch_history_entries_status(HepMCEvt);
202 
203  if(iEvent<EventsToCheck)
204  {
206  }
207 
208  //HepMCEvt->print();
209 
210  // Run MC-TESTER on the event
211  HepMCEvent temp_event(*HepMCEvt,false);
212  MC_Analyze(&temp_event);
213 
214  // Print out last 5 events
215  if(iEvent>=NumberOfEvents-5) HepMCEvt->print();
216 
217  // Clean up
218  delete HepMCEvt;
219  }
220  pythia.statistics();
221  MC_Finalize();
222 }
int EventsToCheck
int NumberOfEvents
int evt
Definition: checkhelixhit.C:36
void initialize()
void checkMomentumConservationInEvent(PhotosHEPEVTEvent *evt)
Pythia8::Pythia * pythia
void switch_history_entries_status ( HepMC::GenEvent *  evt)

Definition at line 75 of file photos_pythia_example.cxx.

References exit(), p, p2, and v.

76 {
77  for ( HepMC::GenEvent::particle_const_iterator p = evt->particles_begin();
78  p != evt->particles_end(); ++p )
79  {
80  if((*p)->status()==3)
81  {
82  if((*p)->pdg_id()==22) continue;
83 
84  int barcode = (*p)->barcode();
85 
86  HepMC::GenVertex *v = (*p)->production_vertex();
87 
88  // History entries are added after photons, so we check what is the
89  // position of current particle relative to photons.
90  int position = 0;
91  int last_photon_position = -1;
92 
93  for(HepMC::GenVertex::particles_out_const_iterator p2 = v->particles_out_const_begin();
94  p2 != v->particles_out_const_end(); ++p2)
95  {
96  position++;
97 
98  if((*p2)->barcode()==barcode) break;
99 
100  if((*p2)->pdg_id()==22) { last_photon_position=position; }
101  }
102 
103  // If particle is found prior to photons - it was already processed, so skip it
104  if(last_photon_position<0) continue;
105 
106  position -= last_photon_position;
107  HepMC::GenParticle *part = NULL;
108 
109  // Now, find the particle that corresponds to this history entry
110  for(HepMC::GenVertex::particles_out_const_iterator p2 = v->particles_out_const_begin();
111  p2 != v->particles_out_const_end(); ++p2)
112  {
113  --position;
114 
115  if (position > 0) continue;
116  else if(position == 0) part = *p2;
117  else
118  {
119  // Give all remaining photons status 3
120  if((*p2)->pdg_id()==22 ) (*p2)->set_status(3);
121 
122  // Finish if there are no more photons
123  else break;
124  }
125  }
126 
127  // Check if this is the particle we are looking for
128  if( part->pdg_id() != (*p)->pdg_id())
129  {
130  cout<<"switch_history_entries_status: mismatch in pdg_id of history entry"<<endl;
131  cout<<"and its corresponding particle. The algorithm does not work correctly."<<endl;
132  exit(-1);
133  }
134 
135  // Skip this particle if its status is not 1
136  if(part->status()!=1) continue;
137 
138  // Switch status codes of these particles
139  part->set_status(3);
140  (*p)->set_status(1);
141  }
142  }
143 }
Double_t p
Definition: anasim.C:58
exit(0)
int evt
Definition: checkhelixhit.C:36
__m128 v
Definition: P4_F32vec4.h:4
TPad * p2
Definition: hist-t7.C:117

Variable Documentation

unsigned int EventsToCheck =20

Definition at line 29 of file photos_pythia_example.cxx.

unsigned long NumberOfEvents = 10000

Definition at line 28 of file photos_pythia_example.cxx.

bool ShowersOn =true

Definition at line 27 of file photos_pythia_example.cxx.

Referenced by main().