Class Reference for E1039 Core & Analysis Software
PHHepMCGenEventMap.cc
Go to the documentation of this file.
1 #include "PHHepMCGenEventMap.h"
2 
3 #include "PHHepMCGenEvent.h"
4 
5 #include <cassert>
6 
7 using namespace std;
8 
10 
12  : _map()
13 {
14 }
15 
17  : _map()
18 {
19  for (ConstIter iter = eventmap.begin();
20  iter != eventmap.end();
21  ++iter)
22  {
23  const PHHepMCGenEvent* event = iter->second;
24  _map.insert(make_pair(event->get_embedding_id(), event->Clone()));
25  }
26 }
27 
29 {
30  Reset();
31  for (ConstIter iter = eventmap.begin();
32  iter != eventmap.end();
33  ++iter)
34  {
35  const PHHepMCGenEvent* event = iter->second;
36  _map.insert(make_pair(event->get_embedding_id(), event->Clone()));
37  }
38  return *this;
39 }
40 
42 {
43  Reset();
44 }
45 
47 {
48  for (Iter iter = _map.begin();
49  iter != _map.end();
50  ++iter)
51  {
52  PHHepMCGenEvent* event = iter->second;
53  delete event;
54  }
55  _map.clear();
56 }
57 
58 void PHHepMCGenEventMap::identify(ostream& os) const
59 {
60  os << "PHHepMCGenEventMap: size = " << _map.size() << endl;
61 
62  for (const auto & evt : _map)
63  {
64  cout <<"Event["<<evt.first<<"] : ";
65  assert(evt.second);
66  evt.second -> identify();
67  }
68 
69  return;
70 }
71 
73 {
74  ConstIter iter = _map.find(id);
75  if (iter == _map.end()) return NULL;
76  return iter->second;
77 }
78 
80 {
81  Iter iter = _map.find(id);
82  if (iter == _map.end()) return NULL;
83  return iter->second;
84 }
85 
87 {
88  unsigned int index = 1;
89  if (!_map.empty()) index = _map.rbegin()->first + 1;
90 
91  if (event)
92  _map.insert(make_pair(index, event->Clone()));
93  else
94  _map.insert(make_pair(index, new PHHepMCGenEvent()));
95 
96  _map[index]->set_embedding_id(index);
97  return _map[index];
98 }
99 
101 {
102  unsigned int index = -1;
103  if (!_map.empty()) index = _map.begin()->first - 1;
104 
105  if (event)
106  _map.insert(make_pair(index, event->Clone()));
107  else
108  _map.insert(make_pair(index, new PHHepMCGenEvent()));
109 
110  _map[index]->set_embedding_id(index);
111  return _map[index];
112 }
113 
115 {
116  if (_map.find(index) != _map.end())
117  {
118  cout <<"PHHepMCGenEventMap::insert_event - Fatal Error -"
119  <<"embedding ID "<<index<<" is already used in the PHHepMCGenEventMap. Print map:";
120  identify();
121 
122  exit(10);
123  }
124 
125  if (event)
126  _map.insert(make_pair(index, event->Clone()));
127  else
128  _map.insert(make_pair(index, new PHHepMCGenEvent()));
129 
130  _map[index]->set_embedding_id(index);
131  return _map[index];
132 }
ClassImp(PHHepMCGenEventMap) PHHepMCGenEventMap
#define NULL
Definition: Pdb.h:9
PHHepMCGenEventMap is collection of HEPMC events input into this simulation map of embedding ID -> PH...
PHHepMCGenEvent * insert_active_event(const PHHepMCGenEvent *event=nullptr)
insert a event of interest, e.g. jetty event from pythia
std::map< int, PHHepMCGenEvent * >::iterator Iter
PHHepMCGenEventMap & operator=(const PHHepMCGenEventMap &eventmap)
const PHHepMCGenEvent * get(int idkey) const
fetch event
void Reset()
Clear Event.
std::map< int, PHHepMCGenEvent * >::const_iterator ConstIter
PHHepMCGenEvent * insert_background_event(const PHHepMCGenEvent *event=nullptr)
insert a event of background, e.g. Au+Au collision background. First event has embedding ID = 0,...
PHHepMCGenEvent * insert_event(const int embedding_id, const PHHepMCGenEvent *event=nullptr)
insert a event with specific embedding ID
ConstIter end() const
void identify(std::ostream &os=std::cout) const
ConstIter begin() const
iterator from lowest ID to highest, i.e. background to signal
PHHepMCGenEvent * Clone() const