PhotosHepMCEvent.cxx
1 #include <vector>
2 #include "PhotosHepMCParticle.h"
3 #include "PhotosHepMCEvent.h"
4 #include "Log.h"
5 using namespace std;
6 
7 namespace Photospp
8 {
9 
10 PhotosHepMCEvent::PhotosHepMCEvent(HepMC::GenEvent * event)
11 {
12  m_event=event;
13  HepMC::GenEvent::particle_const_iterator part_itr = m_event->particles_begin();
14  for( ; part_itr!=m_event->particles_end(); part_itr++)
15  {
16  PhotosParticle *particle = new PhotosHepMCParticle(*part_itr);
17  particles.push_back(particle);
18  }
19 
20  switch(m_event->momentum_unit()) {
21  case HepMC::Units::GEV:
22  Photos::setMomentumUnit(Photos::GEV);
23  break;
24  case HepMC::Units::MEV:
25  Photos::setMomentumUnit(Photos::MEV);
26  break;
27  default:
28  Log::Error()<<"PhotosHepMCEvent: undefined unit, important for pair emission only"<<endl;
29  Photos::setMomentumUnit(Photos::DEFAULT_MOMENTUM);
30  break;
31  };
32 }
33 
34 PhotosHepMCEvent::~PhotosHepMCEvent()
35 {
36  while(particles.size())
37  {
38  PhotosParticle *p = particles.back();
39  particles.pop_back();
40  if(p) delete p;
41  }
42 }
43 
44 HepMC::GenEvent * PhotosHepMCEvent::getEvent()
45 {
46  return m_event;
47 }
48 
49 void PhotosHepMCEvent::print()
50 {
51  if(!m_event) return;
52  m_event->print();
53 }
54 
55 vector<PhotosParticle*> PhotosHepMCEvent::getParticleList()
56 {
57  return particles;
58 }
59 
60 } // namespace Photospp
virtual void print()=0