Belle II Software  release-06-00-14
PhotosHEPEVTEvent.cc
1 #include "PhotosHEPEVTEvent.h"
2 #include "Log.h"
3 #include <generators/kkmc/KKGenInterface.h>
4 const static int fortranNMXHEP = 4000;
5 
7 /*
8 struct HEPEVT
9 {
10  int nevhep;
11  int nhep;
12  int isthep[fortranNMXHEP];
13  int idhep[fortranNMXHEP];
14  int jmohep[fortranNMXHEP][2];
15  int jdahep[fortranNMXHEP][2];
16  double phep[fortranNMXHEP][5];
17  double vhep[fortranNMXHEP][4];
18  // NEVPHO,NPHO,ISTPHO(NMXPHO),IDPHO(NMXPHO),
19  // JMOPHO(2,NMXPHO),JDAPHO(2,NMXPHO),PPHO(5,NMXPHO),VPHO(4,NMXPHO)
20  // int qedrad[NMXHEP] was an add up
21  // for HEPEVT in F77 times. Separate common PH_PHOQED
22  // also phoif_.chkif[NMXPHO] was add up for PHOEVT
23  // now it is pho.qedrad
24 } hepevt_;
25 */
26 
27 struct PHOQED {
28  int qedrad[fortranNMXHEP]; // Photos flag
29 } phoqed_;
30 
31 namespace Photospp {
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 
71  std::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++) {
100  (
101  hepevt_.idhep [i],
102  hepevt_.isthep[i],
103  hepevt_.phep [i][0],
104  hepevt_.phep [i][1],
105  hepevt_.phep [i][2],
106  hepevt_.phep [i][3],
107  hepevt_.phep [i][4],
108  hepevt_.jmohep[i][0] - 1,
109  hepevt_.jmohep[i][1] - 1,
110  hepevt_.jdahep[i][0] - 1,
111  hepevt_.jdahep[i][1] - 1
112  );
113  evt->addParticle(p);
114  }
115  }
116 
118 // vertex info is needed, for photons it should be as of other sisters
119 // taken at read_event_from_HEPEVT
120 // need to be fixed later.
121 
122  {
123  if (evt == NULL) return;
124 
125  hepevt_.nhep = evt->getParticleCount();
126 
127  for (int i = 0; i < hepevt_.nhep; i++) {
128  PhotosHEPEVTParticle* p = evt->getParticle(i);
129 
130  hepevt_.idhep [i] = p->getPdgID();
131  hepevt_.isthep[i] = p->getStatus();
132  hepevt_.phep [i][0] = p->getPx();
133  hepevt_.phep [i][1] = p->getPy();
134  hepevt_.phep [i][2] = p->getPz();
135  hepevt_.phep [i][3] = p->getE();
136  hepevt_.phep [i][4] = p->getMass();
137  hepevt_.jmohep[i][0] = p->getFirstMotherIndex() + 1;
138  hepevt_.jmohep[i][1] = p->getSecondMotherIndex() + 1;
139  hepevt_.jdahep[i][0] = p->getDaughterRangeStart() + 1;
140  hepevt_.jdahep[i][1] = p->getDaughterRangeEnd() + 1;
141  hepevt_.vhep [i][0] = 0.0;
142  hepevt_.vhep [i][1] = 0.0;
143  hepevt_.vhep [i][2] = 0.0;
144  hepevt_.vhep [i][3] = 0.0;
145  }
146  }
147 
148 } // namespace Photospp
static void read_event_from_HEPEVT(PhotosHEPEVTEvent *evt)
Fill PhotosHEPEVTEvent from HEPEVT common block.
void addParticle(PhotosHEPEVTParticle *p)
Add particle at the end of event record.
void print()
Print out list of particles in the event.
int getParticleCount()
Get higher-most index of the particles in event (nhep)
PhotosHEPEVTParticle * getParticle(int i)
Get particle at index 'i'.
std::vector< PhotosParticle * > getParticleList()
Get an unfiltered list of particles from the event record.
PhotosHEPEVTEvent()
Default constructor.
std::vector< PhotosHEPEVTParticle * > particle_list
List of all particles.
void clear()
Remove all particles from the event.
static void write_event_to_HEPEVT(PhotosHEPEVTEvent *evt)
Write to HEPEVT common block content of PhotosHEPEVTEvent.
~PhotosHEPEVTEvent()
Default destructor.
void setParticle(int i, PhotosHEPEVTParticle *p)
Set particle at index 'i'.
static void setMomentumUnit(MomentumUnits unit)
Set momentum unit.
Definition: Photos.h:137
Definition of the HEPEVT common block it can be adapted to user env of F77.
int jmohep[nmxhep][2]
parent particles.
int isthep[nmxhep]
status code.
double vhep[nmxhep][4]
vertex [mm].
int jdahep[nmxhep][2]
childreen particles.
double phep[nmxhep][5]
four-momentum, mass [GeV].
int idhep[nmxhep]
particle ident KF.
int nhep
number of particles.