FairRoot/PandaRoot
Functions | Variables
single_photos_gun_example.cxx File Reference
#include "Pythia.h"
#include "HepMCInterface.h"
#include "Photos/Photos.h"
#include "Photos/PhotosHepMCParticle.h"
#include "Photos/Log.h"

Go to the source code of this file.

Functions

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

Variables

int EventsToCheck =20
 

Function Documentation

void checkMomentumConservationInEvent ( HepMC::GenEvent *  evt)

Definition at line 28 of file single_photos_gun_example.cxx.

References m, p, and pz.

29 {
30  //cout<<"List of stable particles: "<<endl;
31 
32  double px=0.0,py=0.0,pz=0.0,e=0.0;
33 
34  for ( HepMC::GenEvent::particle_const_iterator p = evt->particles_begin();
35  p != evt->particles_end(); ++p )
36  {
37  if( (*p)->status() == 1 )
38  {
39  HepMC::FourVector m = (*p)->momentum();
40  px+=m.px();
41  py+=m.py();
42  pz+=m.pz();
43  e +=m.e();
44  //(*p)->print();
45  }
46  }
47  cout.precision(6);
48  cout.setf(ios_base::floatfield);
49  cout<<endl<<"Vector Sum: "<<px<<" "<<py<<" "<<pz<<" "<<e<<endl;
50 }
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 52 of file single_photos_gun_example.cxx.

References checkMomentumConservationInEvent(), EventsToCheck, i, chigen::initialize(), NumberOfEvents, p, and chigen::pythia::pythia.

53 {
54  // Initialization of pythia
55  HepMC::I_Pythia8 ToHepMC;
56  Pythia pythia;
57  Event& event = pythia.event;
58  pythia.readString("WeakSingleBoson:ffbar2gmZ = on");
59  pythia.readString("23:onMode = off");
60  pythia.readString("23:onIfAny = 15");
61  pythia.readString("HadronLevel:Hadronize = off");
62  pythia.readString("SpaceShower:QEDshower = off");
63  pythia.readString("SpaceShower:QEDshowerByL = off");
64  pythia.readString("SpaceShower:QEDshowerByQ = off");
65  pythia.readString("PartonLevel:ISR = off");
66  pythia.readString("PartonLevel:FSR = off");
67  pythia.init( 11, -11, 92.);
68 
70  Photos::setInfraredCutOff(0.001/200);
71 
72  int NumberOfEvents = 10000;
73  if(argc>1) NumberOfEvents=atoi(argv[1]);
74 
75  int photonAdded=0,twoAdded=0,moreAdded=0,tauCount=0;
76 
77  // Begin event loop. Generate event.
78  for (int iEvent = 0; iEvent < NumberOfEvents; ++iEvent)
79  {
80  if(iEvent%(NumberOfEvents/10)==0) Log::Info()<<iEvent<<endl;
81  if(!pythia.next()) continue;
82 
83  HepMC::GenEvent * HepMCEvt = new HepMC::GenEvent();
84  ToHepMC.fill_next_event(event, HepMCEvt);
85 
86  if(iEvent<EventsToCheck)
87  {
88  cout<<" "<<endl;
89  cout<<"Momentum conservation chceck BEFORE/AFTER Photos"<<endl;
91  }
92 
93  // Find tau
94  HepMC::GenParticle *tau=0;
95  for(HepMC::GenEvent::vertex_const_iterator i = HepMCEvt->vertices_begin();i!=HepMCEvt->vertices_end();i++)
96  {
97  for(HepMC::GenVertex::particles_in_const_iterator p=(*i)->particles_in_const_begin();p!=(*i)->particles_in_const_end(); p++)
98  {
99  if((*p)->pdg_id()==15) tau=*p;
100  break;
101  }
102  if(tau) break;
103  }
104  if(tau)
105  {
106  tauCount++;
107  int buf = -HepMCEvt->particles_size();
108 
109  // Call photos
110  Photos::processParticle( new PhotosHepMCParticle(tau) );
111 
112  buf+=HepMCEvt->particles_size();
113  if(buf==1) photonAdded++;
114  else if(buf==2) twoAdded++;
115  else if(buf>2) moreAdded++;
116  }
117 
118  if(iEvent<EventsToCheck)
119  {
121  }
122 
123  //clean up
124  delete HepMCEvt;
125  }
126  pythia.statistics();
127 
128  // Print results
129  cout.precision(2);
130  cout.setf(ios::fixed);
131  cout<<endl;
132  if(tauCount==0)
133  {
134  cout<<"Something went wrong with pythia generation."<<endl;
135  cout<<"No taus were processed."<<endl<<endl;
136  return 0;
137  }
138  cout<<"Summary (single tau decay processing):"<<endl;
139  cout<<tauCount <<"\ttaus processed"<<endl;
140  cout<<photonAdded<<"\ttimes one photon added to the decay \t("<<(photonAdded*100./tauCount)<<"%)"<<endl;
141  cout<<twoAdded <<"\ttimes two photons added to the decay \t("<<(twoAdded*100./tauCount)<<"%)"<<endl;
142  cout<<moreAdded <<"\ttimes more than two photons added to the decay\t("<<(moreAdded*100./tauCount)<<"%)"<<endl<<endl;
143  cout<<"(Contrary to results from MC-Tester, these values are technical and infrared unstable)"<<endl<<endl;
144  cout<<"To proccess different number of events use:"<<endl<<" ./single_photos_gun_example <number_of_events>"<<endl<<endl;
145 }
Double_t p
Definition: anasim.C:58
int EventsToCheck
Int_t i
Definition: run_full.C:25
int NumberOfEvents
void initialize()
void checkMomentumConservationInEvent(PhotosHEPEVTEvent *evt)
Pythia8::Pythia * pythia

Variable Documentation

int EventsToCheck =20

Definition at line 22 of file single_photos_gun_example.cxx.