]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TEvtGen/Photos/PhotosHEPEVTEvent.cxx
Merge branch 'master' into LocalDev
[u/mrichter/AliRoot.git] / TEvtGen / Photos / PhotosHEPEVTEvent.cxx
CommitLineData
0ca57c2f 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
33PhotosHEPEVTEvent::~PhotosHEPEVTEvent()
34{
35 for(unsigned int i=0;i<particle_list.size();i++) delete particle_list[i];
36}
37
38PhotosHEPEVTEvent::PhotosHEPEVTEvent() {}
39
40void PhotosHEPEVTEvent::addParticle(PhotosHEPEVTParticle *p)
41{
42 p->setEvent(this);
43
44 p->setBarcode(particle_list.size());
45 particle_list.push_back(p);
46}
47
48PhotosHEPEVTParticle *PhotosHEPEVTEvent::getParticle(int i)
49{
50 if( i<0 || i>=(int)particle_list.size() ) return NULL;
51 return particle_list[i];
52}
53
54void PhotosHEPEVTEvent::setParticle(int i, PhotosHEPEVTParticle *p)
55{
56 if( i<0 || i>=(int)particle_list.size() ) return;
57 particle_list[i] = p;
58}
59
60int PhotosHEPEVTEvent::getParticleCount()
61{
62 return particle_list.size();
63}
64
65std::vector<PhotosParticle*> PhotosHEPEVTEvent::getParticleList()
66{
67 std::vector<PhotosParticle*> ret;
68
69 for(unsigned int i=0;i<particle_list.size();i++) ret.push_back( (PhotosParticle*)particle_list[i] );
70
71 return ret;
72}
73
74void PhotosHEPEVTEvent::print()
75{
76 Log::Info()<<"PhotosHEPEVTEvent"<<endl<<"-----------------"<<endl;
77 for(unsigned int i=0;i<particle_list.size();i++) particle_list[i]->print();
78}
79
80void PhotosHEPEVTEvent::clear()
81{
82 for(unsigned int i=0;i<particle_list.size();i++) delete particle_list[i];
83 particle_list.clear();
84}
85
86void 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 if(evt==NULL) return;
91
92 for(int i=0; i<hepevt_.nhep; i++)
93 {
94 PhotosHEPEVTParticle *p = new PhotosHEPEVTParticle
95 (
96 hepevt_.idhep [i],
97 hepevt_.isthep[i],
98 hepevt_.phep [i][0],
99 hepevt_.phep [i][1],
100 hepevt_.phep [i][2],
101 hepevt_.phep [i][3],
102 hepevt_.phep [i][4],
103 hepevt_.jmohep[i][0]-1,
104 hepevt_.jmohep[i][1]-1,
105 hepevt_.jdahep[i][0]-1,
106 hepevt_.jdahep[i][1]-1
107 );
108 evt->addParticle(p);
109 }
110}
111
112void 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 if(evt==NULL) return;
119
120 hepevt_.nhep = evt->getParticleCount();
121
122 for(int i=0; i<hepevt_.nhep; i++)
123 {
124 PhotosHEPEVTParticle *p = evt->getParticle(i);
125
126 hepevt_.idhep [i] =p->getPdgID();
127 hepevt_.isthep[i] =p->getStatus();
128 hepevt_.phep [i][0]=p->getPx();
129 hepevt_.phep [i][1]=p->getPy();
130 hepevt_.phep [i][2]=p->getPz();
131 hepevt_.phep [i][3]=p->getE();
132 hepevt_.phep [i][4]=p->getMass();
133 hepevt_.jmohep[i][0]=p->getFirstMotherIndex() +1;
134 hepevt_.jmohep[i][1]=p->getSecondMotherIndex() +1;
135 hepevt_.jdahep[i][0]=p->getDaughterRangeStart()+1;
136 hepevt_.jdahep[i][1]=p->getDaughterRangeEnd() +1;
137 hepevt_.vhep [i][0]=0.0;
138 hepevt_.vhep [i][1]=0.0;
139 hepevt_.vhep [i][2]=0.0;
140 hepevt_.vhep [i][3]=0.0;
141 }
142}
143
144} // namespace Photospp