PhotosHEPEVTEvent.cxx
00001 #include "PhotosHEPEVTEvent.h"
00002 #include "Log.h"
00003
00004 namespace Photospp
00005 {
00006
00007 PhotosHEPEVTEvent::~PhotosHEPEVTEvent()
00008 {
00009 for(unsigned int i=0;i<particle_list.size();i++) delete particle_list[i];
00010 }
00011
00012 PhotosHEPEVTEvent::PhotosHEPEVTEvent() {}
00013
00014 void PhotosHEPEVTEvent::addParticle(PhotosHEPEVTParticle *p)
00015 {
00016 p->setEvent(this);
00017
00018 p->setBarcode(particle_list.size());
00019 particle_list.push_back(p);
00020 }
00021
00022 PhotosHEPEVTParticle *PhotosHEPEVTEvent::getParticle(int i)
00023 {
00024 if( i<0 || i>=(int)particle_list.size() ) return NULL;
00025 return particle_list[i];
00026 }
00027
00028 void PhotosHEPEVTEvent::setParticle(int i, PhotosHEPEVTParticle *p)
00029 {
00030 if( i<0 || i>=(int)particle_list.size() ) return;
00031 particle_list[i] = p;
00032 }
00033
00034 int PhotosHEPEVTEvent::getParticleCount()
00035 {
00036 return particle_list.size();
00037 }
00038
00039 std::vector<PhotosParticle*> PhotosHEPEVTEvent::getParticleList()
00040 {
00041 std::vector<PhotosParticle*> ret;
00042
00043 for(unsigned int i=0;i<particle_list.size();i++) ret.push_back( (PhotosParticle*)particle_list[i] );
00044
00045 return ret;
00046 }
00047
00048 void PhotosHEPEVTEvent::print()
00049 {
00050 Log::Info()<<"PhotosHEPEVTEvent"<<endl<<"-----------------"<<endl;
00051 for(unsigned int i=0;i<particle_list.size();i++) particle_list[i]->print();
00052 }
00053
00054 void PhotosHEPEVTEvent::clear()
00055 {
00056 for(unsigned int i=0;i<particle_list.size();i++) delete particle_list[i];
00057 particle_list.clear();
00058 }
00059
00060 #ifdef USE_HEPEVT_INTERFACE
00061
00062 void PhotosHEPEVTEvent::read_event_from_HEPEVT(PhotosHEPEVTEvent *evt)
00063 {
00064 if(evt==NULL) return;
00065
00066 for(int i=0; i<hepevt_.nhep; i++)
00067 {
00068 PhotosHEPEVTParticle *p = new PhotosHEPEVTParticle
00069 (
00070 hepevt_.idhep [i],
00071 hepevt_.isthep[i],
00072 hepevt_.phep [i][0],
00073 hepevt_.phep [i][1],
00074 hepevt_.phep [i][2],
00075 hepevt_.phep [i][3],
00076 hepevt_.phep [i][4],
00077 hepevt_.jmohep[i][0]-1,
00078 hepevt_.jmohep[i][1]-1,
00079 hepevt_.jdahep[i][0]-1,
00080 hepevt_.jdahep[i][1]-1
00081 );
00082 evt->addParticle(p);
00083 }
00084 }
00085
00086 void PhotosHEPEVTEvent::write_event_to_HEPEVT(PhotosHEPEVTEvent *evt)
00087 {
00088 if(evt==NULL) return;
00089
00090 hepevt_.nhep = evt->getParticleCount();
00091
00092 for(int i=0; i<hepevt_.nhep; i++)
00093 {
00094 PhotosHEPEVTParticle *p = evt->getParticle(i);
00095
00096 hepevt_.idhep [i] =p->getPdgID();
00097 hepevt_.isthep[i] =p->getStatus();
00098 hepevt_.phep [i][0]=p->getPx();
00099 hepevt_.phep [i][1]=p->getPy();
00100 hepevt_.phep [i][2]=p->getPz();
00101 hepevt_.phep [i][3]=p->getE();
00102 hepevt_.phep [i][4]=p->getMass();
00103 hepevt_.jmohep[i][0]=p->getFirstMotherIndex() +1;
00104 hepevt_.jmohep[i][1]=p->getSecondMotherIndex() +1;
00105 hepevt_.jdahep[i][0]=p->getDaughterRangeStart()+1;
00106 hepevt_.jdahep[i][1]=p->getDaughterRangeEnd() +1;
00107 hepevt_.vhep [i][0]=0.0;
00108 hepevt_.vhep [i][1]=0.0;
00109 hepevt_.vhep [i][2]=0.0;
00110 hepevt_.vhep [i][3]=0.0;
00111 }
00112 }
00113
00114 #endif
00115
00116 }