Line data Source code
1 : #include "PhotosHEPEVTEvent.h"
2 : #include "Log.h"
3 :
4 : const static int fortranNMXHEP = 10000;
5 :
6 : /** Definition of the HEPEVT common block it can be adapted to user env of F77*/
7 : struct 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 :
25 : struct PHOQED
26 : {
27 : int qedrad[fortranNMXHEP]; // Photos flag
28 : } phoqed_;
29 :
30 : namespace Photospp
31 : {
32 :
33 : PhotosHEPEVTEvent::~PhotosHEPEVTEvent()
34 0 : {
35 0 : for(unsigned int i=0;i<particle_list.size();i++) delete particle_list[i];
36 0 : }
37 :
38 0 : PhotosHEPEVTEvent::PhotosHEPEVTEvent() {}
39 :
40 : void PhotosHEPEVTEvent::addParticle(PhotosHEPEVTParticle *p)
41 : {
42 0 : p->setEvent(this);
43 :
44 0 : p->setBarcode(particle_list.size());
45 0 : particle_list.push_back(p);
46 0 : }
47 :
48 : PhotosHEPEVTParticle *PhotosHEPEVTEvent::getParticle(int i)
49 : {
50 0 : if( i<0 || i>=(int)particle_list.size() ) return NULL;
51 0 : return particle_list[i];
52 0 : }
53 :
54 : void PhotosHEPEVTEvent::setParticle(int i, PhotosHEPEVTParticle *p)
55 : {
56 0 : if( i<0 || i>=(int)particle_list.size() ) return;
57 0 : particle_list[i] = p;
58 0 : }
59 :
60 : int PhotosHEPEVTEvent::getParticleCount()
61 : {
62 0 : return particle_list.size();
63 : }
64 :
65 : std::vector<PhotosParticle*> PhotosHEPEVTEvent::getParticleList()
66 : {
67 0 : std::vector<PhotosParticle*> ret;
68 :
69 0 : for(unsigned int i=0;i<particle_list.size();i++) ret.push_back( (PhotosParticle*)particle_list[i] );
70 :
71 : return ret;
72 0 : }
73 :
74 : void PhotosHEPEVTEvent::print()
75 : {
76 0 : Log::Info()<<"PhotosHEPEVTEvent"<<endl<<"-----------------"<<endl;
77 0 : for(unsigned int i=0;i<particle_list.size();i++) particle_list[i]->print();
78 0 : }
79 :
80 : void PhotosHEPEVTEvent::clear()
81 : {
82 0 : for(unsigned int i=0;i<particle_list.size();i++) delete particle_list[i];
83 0 : particle_list.clear();
84 0 : }
85 :
86 : void PhotosHEPEVTEvent::read_event_from_HEPEVT(PhotosHEPEVTEvent *evt)
87 : // vertex info is not needed, but what about info for write_event_to_HEPEVT?
88 : // need to be fixed later.
89 : {
90 0 : if(evt==NULL) return;
91 :
92 0 : for(int i=0; i<hepevt_.nhep; i++)
93 : {
94 0 : PhotosHEPEVTParticle *p = new PhotosHEPEVTParticle
95 : (
96 0 : hepevt_.idhep [i],
97 0 : hepevt_.isthep[i],
98 0 : hepevt_.phep [i][0],
99 0 : hepevt_.phep [i][1],
100 0 : hepevt_.phep [i][2],
101 0 : hepevt_.phep [i][3],
102 0 : hepevt_.phep [i][4],
103 0 : hepevt_.jmohep[i][0]-1,
104 0 : hepevt_.jmohep[i][1]-1,
105 0 : hepevt_.jdahep[i][0]-1,
106 0 : hepevt_.jdahep[i][1]-1
107 : );
108 0 : evt->addParticle(p);
109 : }
110 0 : }
111 :
112 : void PhotosHEPEVTEvent::write_event_to_HEPEVT(PhotosHEPEVTEvent *evt)
113 : // vertex info is needed, for photons it should be as of other sisters
114 : // taken at read_event_from_HEPEVT
115 : // need to be fixed later.
116 :
117 : {
118 0 : if(evt==NULL) return;
119 :
120 0 : hepevt_.nhep = evt->getParticleCount();
121 :
122 0 : for(int i=0; i<hepevt_.nhep; i++)
123 : {
124 0 : PhotosHEPEVTParticle *p = evt->getParticle(i);
125 :
126 0 : hepevt_.idhep [i] =p->getPdgID();
127 0 : hepevt_.isthep[i] =p->getStatus();
128 0 : hepevt_.phep [i][0]=p->getPx();
129 0 : hepevt_.phep [i][1]=p->getPy();
130 0 : hepevt_.phep [i][2]=p->getPz();
131 0 : hepevt_.phep [i][3]=p->getE();
132 0 : hepevt_.phep [i][4]=p->getMass();
133 0 : hepevt_.jmohep[i][0]=p->getFirstMotherIndex() +1;
134 0 : hepevt_.jmohep[i][1]=p->getSecondMotherIndex() +1;
135 0 : hepevt_.jdahep[i][0]=p->getDaughterRangeStart()+1;
136 0 : hepevt_.jdahep[i][1]=p->getDaughterRangeEnd() +1;
137 0 : hepevt_.vhep [i][0]=0.0;
138 0 : hepevt_.vhep [i][1]=0.0;
139 0 : hepevt_.vhep [i][2]=0.0;
140 0 : hepevt_.vhep [i][3]=0.0;
141 : }
142 0 : }
143 :
144 : } // namespace Photospp
|