PhotosHEPEVTEvent.cxx
1#include "PhotosHEPEVTEvent.h"
2#include "Log.h"
3
4const static int fortranNMXHEP = 10000;
5
6/** Definition of the HEPEVT common block it can be adapted to user env of F77*/
7struct HEPEVT
8{
9 int nevhep;
10 int nhep;
11 int isthep[fortranNMXHEP];
12 int idhep[fortranNMXHEP];
13 int jmohep[fortranNMXHEP][2];
14 int jdahep[fortranNMXHEP][2];
15 double phep[fortranNMXHEP][5];
16 double vhep[fortranNMXHEP][4];
17 // NEVPHO,NPHO,ISTPHO(NMXPHO),IDPHO(NMXPHO),
18 // JMOPHO(2,NMXPHO),JDAPHO(2,NMXPHO),PPHO(5,NMXPHO),VPHO(4,NMXPHO)
19 // int qedrad[NMXHEP] was an add up
20 // for HEPEVT in F77 times. Separate common PH_PHOQED
21 // also phoif_.chkif[NMXPHO] was add up for PHOEVT
22 // now it is pho.qedrad
23} hepevt_;
24
25struct PHOQED
26{
27 int qedrad[fortranNMXHEP]; // Photos flag
28} phoqed_;
29
30namespace Photospp
31{
32
34{
35 for(unsigned int i=0;i<particle_list.size();i++) delete particle_list[i];
36}
37
39{
40 // NOTE: We set default units to be GEV for HEPEVT events. This can be
41 // overridden by calling Photos::setMomentumUnit(Photos::MEV);
42 // after the event is created.
43 Photos::setMomentumUnit(Photos::GEV);
44}
45
47{
48 p->setEvent(this);
49
50 p->setBarcode(particle_list.size());
51 particle_list.push_back(p);
52}
53
55{
56 if( i<0 || i>=(int)particle_list.size() ) return NULL;
57 return particle_list[i];
58}
59
61{
62 if( i<0 || i>=(int)particle_list.size() ) return;
63 particle_list[i] = p;
64}
65
67{
68 return particle_list.size();
69}
70
71std::vector<PhotosParticle*> PhotosHEPEVTEvent::getParticleList()
72{
73 std::vector<PhotosParticle*> ret;
74
75 for(unsigned int i=0;i<particle_list.size();i++) ret.push_back( (PhotosParticle*)particle_list[i] );
76
77 return ret;
78}
79
81{
82 Log::Info()<<"PhotosHEPEVTEvent"<<endl<<"-----------------"<<endl;
83 for(unsigned int i=0;i<particle_list.size();i++) particle_list[i]->print();
84}
85
87{
88 for(unsigned int i=0;i<particle_list.size();i++) delete particle_list[i];
89 particle_list.clear();
90}
91
93// vertex info is not needed, but what about info for write_event_to_HEPEVT?
94// need to be fixed later.
95{
96 if(evt==NULL) return;
97
98 for(int i=0; i<hepevt_.nhep; i++)
99 {
101 (
102 hepevt_.idhep [i],
103 hepevt_.isthep[i],
104 hepevt_.phep [i][0],
105 hepevt_.phep [i][1],
106 hepevt_.phep [i][2],
107 hepevt_.phep [i][3],
108 hepevt_.phep [i][4],
109 hepevt_.jmohep[i][0]-1,
110 hepevt_.jmohep[i][1]-1,
111 hepevt_.jdahep[i][0]-1,
112 hepevt_.jdahep[i][1]-1
113 );
114 evt->addParticle(p);
115 }
116}
117
119// vertex info is needed, for photons it should be as of other sisters
120// taken at read_event_from_HEPEVT
121// need to be fixed later.
122
123{
124 if(evt==NULL) return;
125
126 hepevt_.nhep = evt->getParticleCount();
127
128 for(int i=0; i<hepevt_.nhep; i++)
129 {
131
132 hepevt_.idhep [i] =p->getPdgID();
133 hepevt_.isthep[i] =p->getStatus();
134 hepevt_.phep [i][0]=p->getPx();
135 hepevt_.phep [i][1]=p->getPy();
136 hepevt_.phep [i][2]=p->getPz();
137 hepevt_.phep [i][3]=p->getE();
138 hepevt_.phep [i][4]=p->getMass();
139 hepevt_.jmohep[i][0]=p->getFirstMotherIndex() +1;
140 hepevt_.jmohep[i][1]=p->getSecondMotherIndex() +1;
141 hepevt_.jdahep[i][0]=p->getDaughterRangeStart()+1;
142 hepevt_.jdahep[i][1]=p->getDaughterRangeEnd() +1;
143 hepevt_.vhep [i][0]=0.0;
144 hepevt_.vhep [i][1]=0.0;
145 hepevt_.vhep [i][2]=0.0;
146 hepevt_.vhep [i][3]=0.0;
147 }
148}
149
150} // namespace Photospp
static void read_event_from_HEPEVT(PhotosHEPEVTEvent *evt)
void addParticle(PhotosHEPEVTParticle *p)
PhotosHEPEVTParticle * getParticle(int i)
std::vector< PhotosHEPEVTParticle * > particle_list
std::vector< PhotosParticle * > getParticleList()
static void write_event_to_HEPEVT(PhotosHEPEVTEvent *evt)
void setParticle(int i, PhotosHEPEVTParticle *p)
void setEvent(PhotosHEPEVTEvent *event)
static void setMomentumUnit(MomentumUnits unit)