FairRoot/PandaRoot
PhotosHEPEVTEvent.cxx
Go to the documentation of this file.
1 #include "PhotosHEPEVTEvent.h"
2 #include "Log.h"
3 
4 namespace Photospp
5 {
6 
8 {
9  for(unsigned int i=0;i<particle_list.size();i++) delete particle_list[i];
10 }
11 
13 
15 {
16  p->setEvent(this);
17 
18  p->setBarcode(particle_list.size());
19  particle_list.push_back(p);
20 }
21 
23 {
24  if( i<0 || i>=(int)particle_list.size() ) return NULL;
25  return particle_list[i];
26 }
27 
29 {
30  if( i<0 || i>=(int)particle_list.size() ) return;
31  particle_list[i] = p;
32 }
33 
35 {
36  return particle_list.size();
37 }
38 
39 std::vector<PhotosParticle*> PhotosHEPEVTEvent::getParticleList()
40 {
41  std::vector<PhotosParticle*> ret;
42 
43  for(unsigned int i=0;i<particle_list.size();i++) ret.push_back( (PhotosParticle*)particle_list[i] );
44 
45  return ret;
46 }
47 
49 {
50  Log::Info()<<"PhotosHEPEVTEvent"<<endl<<"-----------------"<<endl;
51  for(unsigned int i=0;i<particle_list.size();i++) particle_list[i]->print();
52 }
53 
55 {
56  for(unsigned int i=0;i<particle_list.size();i++) delete particle_list[i];
57  particle_list.clear();
58 }
59 
60 #ifdef USE_HEPEVT_INTERFACE
61 
62 void PhotosHEPEVTEvent::read_event_from_HEPEVT(PhotosHEPEVTEvent *evt)
63 {
64  if(evt==NULL) return;
65 
66  for(int i=0; i<hepevt_.nhep; i++)
67  {
69  (
70  hepevt_.idhep [i],
71  hepevt_.isthep[i],
72  hepevt_.phep [i][0],
73  hepevt_.phep [i][1],
74  hepevt_.phep [i][2],
75  hepevt_.phep [i][3],
76  hepevt_.phep [i][4],
77  hepevt_.jmohep[i][0]-1,
78  hepevt_.jmohep[i][1]-1,
79  hepevt_.jdahep[i][0]-1,
80  hepevt_.jdahep[i][1]-1
81  );
82  evt->addParticle(p);
83  }
84 }
85 
86 void PhotosHEPEVTEvent::write_event_to_HEPEVT(PhotosHEPEVTEvent *evt)
87 {
88  if(evt==NULL) return;
89 
90  hepevt_.nhep = evt->getParticleCount();
91 
92  for(int i=0; i<hepevt_.nhep; i++)
93  {
94  PhotosHEPEVTParticle *p = evt->getParticle(i);
95 
96  hepevt_.idhep [i] =p->getPdgID();
97  hepevt_.isthep[i] =p->getStatus();
98  hepevt_.phep [i][0]=p->getPx();
99  hepevt_.phep [i][1]=p->getPy();
100  hepevt_.phep [i][2]=p->getPz();
101  hepevt_.phep [i][3]=p->getE();
102  hepevt_.phep [i][4]=p->getMass();
103  hepevt_.jmohep[i][0]=p->getFirstMotherIndex() +1;
104  hepevt_.jmohep[i][1]=p->getSecondMotherIndex() +1;
105  hepevt_.jdahep[i][0]=p->getDaughterRangeStart()+1;
106  hepevt_.jdahep[i][1]=p->getDaughterRangeEnd() +1;
107  hepevt_.vhep [i][0]=0.0;
108  hepevt_.vhep [i][1]=0.0;
109  hepevt_.vhep [i][2]=0.0;
110  hepevt_.vhep [i][3]=0.0;
111  }
112 }
113 
114 #endif
115 
116 } // namespace Photospp
std::vector< PhotosParticle * > getParticleList()
Int_t i
Definition: run_full.C:25
void setEvent(PhotosHEPEVTEvent *event)
PhotosHEPEVTParticle * getParticle(int i)
int evt
Definition: checkhelixhit.C:36
static ostream & Info(bool count=true)
Definition: Log.cxx:38
Double_t p
Definition: anasim.C:58
Definition: Log.h:30
std::vector< PhotosHEPEVTParticle * > particle_list
void setParticle(int i, PhotosHEPEVTParticle *p)
void addParticle(PhotosHEPEVTParticle *p)
Single particle of HEPEVT event record.