ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RawTowerZDCContainer.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file RawTowerZDCContainer.cc
1 #include "RawTowerZDCContainer.h"
2 
3 #include "RawTowerZDC.h"
4 
5 #include <cstdlib>
6 #include <iostream>
7 
8 using namespace std;
9 
11 {
12  if (emin <= 0) // no need to loop through the map if we don't apply a cut
13  {
14  return;
15  }
16  Iterator itr = _towers.begin();
17  Iterator last = _towers.end();
18  for (; itr != last;)
19  {
20  RawTowerZDC *tower = (itr->second);
21  if (tower->get_energy() < emin)
22  {
23  delete tower;
24  _towers.erase(itr++);
25  }
26  else
27  {
28  ++itr;
29  }
30  }
31 }
32 
35 {
36  return make_pair(_towers.begin(), _towers.end());
37 }
38 
41 {
42  return make_pair(_towers.begin(), _towers.end());
43 }
44 
46 RawTowerZDCContainer::AddTower(const unsigned int ieta, const int unsigned iphi, const int unsigned il, RawTowerZDC *rawtower)
47 {
49  _towers[key] = rawtower;
50  rawtower->set_id(key); // force tower key to be synced to container key
51 
52  return _towers.find(key);
53 }
54 
57 {
58  if (RawTowerZDCDefs::decode_caloid(key) != _caloid)
59  {
60  cout << "RawTowerZDCContainer::AddTower - Error - adding tower to wrong container! Container CaloID = "
61  << _caloid << ", requested CaloID = " << RawTowerZDCDefs::decode_caloid(key) << " based on key " << key << endl;
62  exit(2);
63  }
64 
65  _towers[key] = twr;
66  twr->set_id(key); // force tower key to be synced to container key
67 
68  return _towers.find(key);
69 }
70 
73 {
74  ConstIterator it = _towers.find(key);
75  if (it != _towers.end())
76  {
77  return it->second;
78  }
79  return NULL;
80 }
81 
82 const RawTowerZDC *
84 {
85  ConstIterator it = _towers.find(key);
86  if (it != _towers.end())
87  {
88  return it->second;
89  }
90  return NULL;
91 }
92 
94 RawTowerZDCContainer::getTower(const unsigned int ieta, const unsigned int iphi , const unsigned int il)
95 {
97  return getTower(key);
98 }
99 
100 const RawTowerZDC *
101 RawTowerZDCContainer::getTower(const unsigned int ieta, const unsigned int iphi, const unsigned int il) const
102 {
103  RawTowerZDCDefs::keytype key = RawTowerZDCDefs::encode_towerid_zdc(_caloid, ieta, iphi, il);
104  return getTower(key);
105 }
106 
107 
109 {
110  return (!_towers.empty());
111 }
112 
114 {
115  while (_towers.begin() != _towers.end())
116  {
117  delete _towers.begin()->second;
118  _towers.erase(_towers.begin());
119  }
120 }
121 
122 void RawTowerZDCContainer::identify(std::ostream &os) const
123 {
124  os << "RawTowerZDCContainer, number of towers: " << size() << std::endl;
125 }
126 
127 double
129 {
130  double totalenergy = 0;
131  ConstIterator iter;
132  for (iter = _towers.begin(); iter != _towers.end(); ++iter)
133  {
134  totalenergy += iter->second->get_energy();
135  }
136  return totalenergy;
137 }