photos_hepevt_example.cxx

00001 /**
00002  * Example of use of Photos C++ interface.
00003  * e+, e- -> tau + tau - HEPEVT events are constructed.
00004  * Taus are subsequently decayed via Photos.
00005  *
00006  * @author Tomasz Przedzinski
00007  * @date 24 November 2011
00008  */
00009 
00010 #include "Photos/Photos.h"
00011 #include "Photos/PhotosHEPEVTParticle.h"
00012 #include "Photos/PhotosHEPEVTEvent.h"
00013 using namespace std;
00014 using namespace Photospp;
00015 
00016 int NumberOfEvents = 1000;
00017 int EventsToCheck  = 1000;
00018 
00019 void checkMomentumConservationInEvent(PhotosHEPEVTEvent *evt)
00020 {
00021   int n = evt->getParticleCount();
00022   double px=0.0,py=0.0,pz=0.0,e=0.0;
00023 
00024   for(int i=0;i<n;i++)
00025   {
00026     PhotosHEPEVTParticle *p = evt->getParticle(i);
00027     if(p->getStatus() != 1) continue;
00028 
00029     px += p->getPx();
00030     py += p->getPy();
00031     pz += p->getPz();
00032     e  += p->getE();
00033   }
00034 
00035   cout.precision(6);
00036   cout.setf(ios_base::floatfield);
00037   cout<<endl<<"Vector Sum: "<<px<<" "<<py<<" "<<pz<<" "<<e<<endl;
00038 }
00039 
00040 /** Create a simple e+ + e- -> Z -> tau+ tau- HEPEVT event **/
00041 PhotosHEPEVTEvent* make_simple_tau_event(){
00042 
00043   PhotosHEPEVTEvent * evt = new PhotosHEPEVTEvent();
00044 
00045   const double amell = 0.0005111;
00046 
00047   // Make PhotosParticles for boosting
00048   PhotosHEPEVTParticle *first_e      = new PhotosHEPEVTParticle(  11, 6,  1.7763568394002505e-15, -3.5565894425761324e-15,  4.5521681043409913e+01, 4.5521681043409934e+01,     amell,              -1, -1,  2,  2);
00049   PhotosHEPEVTParticle *second_e     = new PhotosHEPEVTParticle( -11, 6, -1.7763568394002505e-15,  3.5488352204797800e-15, -4.5584999071936601e+01, 4.5584999071936622e+01,     amell,              -1, -1,  2,  2);
00050   PhotosHEPEVTParticle *intermediate = new PhotosHEPEVTParticle(  23, 5,  0,                       0,                      -6.3318028526687442e-02, 9.1106680115346506e+01, 9.1106658112716090e+01,  0,  1,  3,  4);
00051   PhotosHEPEVTParticle *first_tau    = new PhotosHEPEVTParticle(  15, 2, -2.3191595992562256e+01, -2.6310500920665142e+01, -2.9046412466624929e+01, 4.5573504956498098e+01, 1.7769900000002097e+00,  2, -1,  5,  6);
00052   PhotosHEPEVTParticle *second_tau   = new PhotosHEPEVTParticle( -15, 2,  2.3191595992562256e+01,  2.6310500920665142e+01,  2.8983094438098242e+01, 4.5533175158848429e+01, 1.7769900000000818e+00,  2, -1,  7,  8);
00053   PhotosHEPEVTParticle *t1d1         = new PhotosHEPEVTParticle(  16, 1, -1.2566536214715378e+00, -1.7970251138317268e+00, -1.3801323581022720e+00, 2.5910119010468553e+00, 9.9872238934040070e-03,  3, -1, -1, -1);
00054   PhotosHEPEVTParticle *t1d2         = new PhotosHEPEVTParticle(-211, 1, -2.1935073012334062e+01, -2.4513624017269400e+01, -2.7666443730700312e+01, 4.2982749776866747e+01, 1.3956783711910248e-01,  3, -1, -1, -1);
00055   PhotosHEPEVTParticle *t2d1         = new PhotosHEPEVTParticle( -16, 1,  8.4364531743909055e+00,  8.3202830831667836e+00,  9.6202800273055971e+00, 1.5262723881157640e+01, 9.9829332903027534e-03,  4, -1, -1, -1);
00056   PhotosHEPEVTParticle *t2d2         = new PhotosHEPEVTParticle( 211, 1,  1.4755273459419701e+01,  1.7990366047940022e+01,  1.9362977676297948e+01, 3.0270707771933196e+01, 1.3956753909587860e-01,  4, -1, -1, -1);
00057       
00058   // Order matters!
00059   evt->addParticle(first_e     );
00060   evt->addParticle(second_e    );
00061   evt->addParticle(intermediate);
00062   evt->addParticle(first_tau   );
00063   evt->addParticle(second_tau  );
00064   evt->addParticle(t1d1        );
00065   evt->addParticle(t1d2        );
00066   evt->addParticle(t2d1        );
00067   evt->addParticle(t2d2        );
00068 
00069   return evt;
00070 }
00071 
00072 /** Example of using Photos to process event stored in HEPEVT event record */
00073 int main(void){
00074 
00075   Photos::initialize();
00076 
00077         int photonAdded=0,twoAdded=0,moreAdded=0,evtCount=0;
00078 
00079   // Begin event loop. Generate event.
00080   for (int iEvent = 0; iEvent < NumberOfEvents; ++iEvent) {
00081 
00082     if(iEvent%10000==0) cout<<"Event: "<<iEvent<<"\t("<<iEvent*(100./NumberOfEvents)<<"%)"<<endl;
00083 
00084     // Create simple event
00085     PhotosHEPEVTEvent * event = make_simple_tau_event();
00086 
00087     int buf = -event->getParticleCount();
00088 
00089     //cout << "BEFORE:"<<endl;
00090     //event->print();
00091 
00092     if(iEvent<EventsToCheck)
00093     {
00094       cout<<"                                          "<<endl;
00095       cout<<"Momentum conservation chceck BEFORE/AFTER Photos"<<endl;
00096       checkMomentumConservationInEvent(event);
00097     }
00098     
00099     event->process();
00100 
00101     buf += event->getParticleCount();
00102                 if     (buf==1) photonAdded++;
00103                 else if(buf==2) twoAdded++;
00104                 else if(buf>2)  moreAdded++;
00105 
00106     if(iEvent<EventsToCheck)
00107     {
00108       checkMomentumConservationInEvent(event);
00109     }
00110     
00111     //cout << "AFTER:"<<endl;
00112     //event->print();
00113 
00114     evtCount++;
00115 
00116     //clean up
00117     delete event;
00118   }
00119 
00120         // Print results
00121         cout.precision(3);
00122         cout.setf(ios::fixed);
00123         cout<<endl;
00124         cout<<"Summary of processing simple events:    e+ e- -> Z -> tau+ tau-"<<endl;
00125         cout<<evtCount   <<"\tevents processed"<<endl;
00126         cout<<photonAdded<<"\ttimes one photon added to the event           \t("<<(photonAdded*100./evtCount)<<"%)"<<endl;
00127         cout<<twoAdded   <<"\ttimes two photons added to the event          \t("<<(twoAdded*100./evtCount)<<"%)"<<endl;
00128         cout<<moreAdded  <<"\ttimes more than two photons added to the event\t("<<(moreAdded*100./evtCount)<<"%)"<<endl<<endl;
00129         cout<<"(Contrary to results from MC-Tester, these values are technical and infrared unstable)"<<endl<<endl;
00130 }
00131 
Generated on Sun Oct 20 20:23:56 2013 for C++InterfacetoPHOTOS by  doxygen 1.6.3