tauola_photos_pythia_example.cxx

00001 /**
00002  * Example of use of photos C++ interface. Pythia events are
00003  * generated first and photos used for FSR.
00004  *
00005  * @author Nadia Davidson
00006  * @date 6 July 2009
00007  */
00008 
00009 //pythia header files
00010 #include "Pythia.h"
00011 #include "HepMCInterface.h"
00012 
00013 //MC-TESTER header files
00014 #include "Generate.h"
00015 #include "HepMCEvent.H"
00016 #include "Setup.H"
00017 
00018 //PHOTOS header files
00019 #include "Photos/Photos.h"
00020 #include "Photos/PhotosHepMCEvent.h"
00021 #include "Photos/Log.h"
00022 
00023 //TAUOLA header files
00024 #include "Tauola/Tauola.h"
00025 #include "Tauola/TauolaHepMCEvent.h"
00026 
00027 using namespace std;
00028 using namespace Pythia8;
00029 using namespace Photospp;
00030 using namespace Tauolapp;
00031 
00032 unsigned long NumberOfEvents = 10000;
00033 unsigned int EventsToCheck=20;
00034 
00035 // elementary test of HepMC typically executed before
00036 // detector simulation based on http://home.fnal.gov/~mrenna/HCPSS/HCPSShepmc.html
00037 // similar test was performed in Fortran
00038 // we perform it before and after Photos (for the first several events)
00039 void checkMomentumConservationInEvent(HepMC::GenEvent *evt)
00040 {
00041         //cout<<"List of stable particles: "<<endl;
00042 
00043         double px=0.0,py=0.0,pz=0.0,e=0.0;
00044         
00045         for ( HepMC::GenEvent::particle_const_iterator p = evt->particles_begin();
00046               p != evt->particles_end(); ++p )
00047         {
00048                 if( (*p)->status() == 1 )
00049                 {
00050                         HepMC::FourVector m = (*p)->momentum();
00051                         px+=m.px();
00052                         py+=m.py();
00053                         pz+=m.pz();
00054                         e +=m.e();
00055                         //(*p)->print();
00056                 }
00057         }
00058   cout.precision(6);
00059   cout.setf(ios_base::floatfield);
00060         cout<<endl<<"Vector Sum: "<<px<<" "<<py<<" "<<pz<<" "<<e<<endl;
00061 }
00062 
00063 int main(int argc,char **argv)
00064 {
00065         HepMC::I_Pythia8 ToHepMC;
00066 
00067         // Initialization of pythia
00068         Pythia pythia;
00069         Event& event = pythia.event;
00070 
00071         pythia.readString("PartonLevel:ISR = off");
00072         pythia.readString("PartonLevel:FSR = off");
00073 
00074         pythia.readString("WeakSingleBoson:ffbar2gmZ = on");
00075         pythia.readString("23:onMode = off");
00076         pythia.readString("23:onIfAny = 15");
00077         pythia.particleData.readString("15:mayDecay = off"); //<- uncomment for pythia+tauola
00078 
00079         //pythia.init( -2212, -2212, 14000.0);     //proton proton collisions
00080         pythia.init( 11, -11, 91.187);             //electron positron collisions
00081 
00082         // TAUOLA and PHOTOS initialization
00083         Tauola::initialize();
00084         Photos::initialize();
00085 
00086         Photos::setInfraredCutOff(0.01/91.187); // 10MeV for scale to M_Z=91.187
00087         //Photos::setDoubleBrem(false);
00088         //Photos::setExponentiation(false);
00089 
00090         Log::SummaryAtExit();
00091         cout.setf(ios::fixed);
00092         //Log::LogInfo(false) //To turn printing of last five events and pythia statistics off
00093 
00094         // Example setup - suppress processing of whole Z0 decay,
00095         // leaving only the Z0 -> tau+ tau- decay and whole branch starting
00096         // from tau- to be processed
00097         //Photos::suppressBremForBranch(0,23);
00098         //Photos::forceBremForDecay (2,23,15,-15);
00099         //Photos::forceBremForBranch(0,15);
00100 
00101         // Force mass of electron and positron to be 0.000511
00102         //Photos::forceMass(11,0.000511);
00103 
00104         // Force mass of electron and positron to be taken
00105         // from event record instead of being calculated from 4-vector
00106         //Photos::forceMassFromEventRecord(11);
00107 
00108         // Exclude particles with given status code from being processed
00109         // or taken into account during momentum conservation calculation
00110         //Photos::ignoreParticlesWithStatus(3);
00111 
00112         // Remove status code from the list of ignored status codes
00113         //Photos::DeIgnoreParticlesWithStatus(3);
00114 
00115         // Force writing history decay products for vertices
00116         // modified i.e. with added photons. These particles will
00117         // have the provided status code. Photos will ignore
00118         // all particles with this status code.
00119         //Photos::createHistoryEntries(true,3);
00120 
00121         MC_Initialize();
00122 
00123         // Begin event loop
00124         for (unsigned long iEvent = 0; iEvent < NumberOfEvents; ++iEvent)
00125         {
00126                 if(iEvent%1000==0) Log::Info()<<"Event: "<<iEvent<<"\t("<<iEvent*(100./NumberOfEvents)<<"%)"<<endl;
00127                 if(!pythia.next()) continue;
00128 
00129                 // Convert event record to HepMC
00130                 HepMC::GenEvent * HepMCEvt = new HepMC::GenEvent();
00131                 ToHepMC.fill_next_event(event, HepMCEvt);
00132 
00133                 // Run TAUOLA on the event
00134                 TauolaHepMCEvent * t_event = new TauolaHepMCEvent(HepMCEvt);
00135 
00136                 // We may want to undecay previously decayed taus.
00137                 //t_event->undecayTaus();
00138                 t_event->decayTaus();
00139                 delete t_event;
00140 
00141                 //Log::LogPhlupa(2,4);
00142 
00143                 if(iEvent<EventsToCheck)
00144                 {
00145                         cout<<"                                          "<<endl;
00146                         cout<<"Momentum conservation chceck BEFORE/AFTER Photos"<<endl;
00147                         checkMomentumConservationInEvent(HepMCEvt);
00148                 }
00149 
00150                 // Run PHOTOS on the event
00151                 PhotosHepMCEvent evt(HepMCEvt);
00152                 evt.process();
00153 
00154                 if(iEvent<EventsToCheck)
00155                 {
00156                         checkMomentumConservationInEvent(HepMCEvt);
00157                 }
00158 
00159                 // Run MC-TESTER on the event
00160                 HepMCEvent temp_event(*HepMCEvt,false);
00161                 MC_Analyze(&temp_event);
00162 
00163                 // Print out last 5 events
00164                 if(iEvent>=NumberOfEvents-5)
00165                 {
00166                         Log::RedirectOutput(Log::Info());
00167                         //pythia.event.list();
00168                         HepMCEvt->print();
00169                         Log::RevertOutput();
00170                 }
00171 
00172                 // Clean up
00173                 delete HepMCEvt;
00174         }
00175 
00176         Log::RedirectOutput(Log::Info());
00177         pythia.statistics();
00178         Log::RevertOutput();
00179 
00180         MC_Finalize();
00181 }
Generated on Sun Oct 20 20:23:56 2013 for C++InterfacetoPHOTOS by  doxygen 1.6.3