ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RawTowerZDCGeomContainer.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file RawTowerZDCGeomContainer.cc
2 #include "RawTowerZDCGeom.h"
3 
4 #include <iostream>
5 #include <cassert>
6 #include <cstdlib>
7 
8 using namespace std;
9 
11  : _caloid(caloid)
12 {
13 }
14 
16 {
17  Reset(); //make sure everything is deleted
18 }
19 
20 void RawTowerZDCGeomContainer::identify(std::ostream& os) const
21 {
22  os << "RawTowerZDCGeomContainer, number of tower geometries: " << size()
23  << std::endl;
24 }
25 
28 {
29  assert(geo);
30 
32  {
33  cout << "RawTowerZDCGeomContainer::add_tower_geometry - Fatal Error - "
34  "attempting to add tower geometry with id = "
35  << geo->get_id()
36  << " with CaloID = " << RawTowerZDCDefs::decode_caloid(geo->get_id())
37  << " to this container of CaloID = " << get_calorimeter_id() << ".";
38  geo->identify(cout);
39  exit(2);
40  }
41 
42  Iterator it = _geoms.find(geo->get_id());
43  if (it != _geoms.end())
44  {
45  cout
46  << "RawTowerZDCGeomContainer::add_tower_geometry - WARNING - replace tower geometry for tower #"
47  << geo->get_id() << ". This Old tower will be deleted: ";
48  it->second->identify(cout);
49 
50  delete it->second;
51  _geoms.erase(it);
52  }
53 
54  _geoms[geo->get_id()] = geo;
55  return _geoms.find(geo->get_id());
56 }
57 
60 {
61  return make_pair<ConstIterator, ConstIterator>(_geoms.begin(), _geoms.end());
62 }
63 
66 {
67  return make_pair<Iterator, Iterator>(_geoms.begin(), _geoms.end());
68 }
69 
72 {
73  Iterator it = _geoms.find(key);
74  if (it != _geoms.end())
75  {
76  return it->second;
77  }
78  return NULL;
79 }
80 
82 {
83  return (!_geoms.empty());
84 }
85 
87 {
88  while (_geoms.begin() != _geoms.end())
89  {
90  delete _geoms.begin()->second;
91  _geoms.erase(_geoms.begin());
92  }
93 }