Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RawTowerGeomContainerv1.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file RawTowerGeomContainerv1.cc
2 
3 #include "RawTowerGeom.h"
4 
5 #include <cassert>
6 #include <cstdlib>
7 #include <iostream>
8 #include <map>
9 #include <utility>
10 
11 using namespace std;
12 
14  : _caloid(caloid)
15 {
16 }
17 
19 {
20  Reset(); // make sure everything is deleted
21 }
22 
25 {
26  return make_pair<ConstIterator, ConstIterator>(_geoms.begin(), _geoms.end());
27 }
28 
31 {
32  return make_pair<Iterator, Iterator>(_geoms.begin(), _geoms.end());
33 }
34 
37 {
38  assert(geo);
39 
41  {
42  cout << "RawTowerGeomContainerv1::add_tower_geometry - Fatal Error - "
43  "attempting to add tower geometry with id = "
44  << geo->get_id()
45  << " with CaloID = " << RawTowerDefs::decode_caloid(geo->get_id())
46  << " to this container of CaloID = " << get_calorimeter_id() << ".";
47  geo->identify(cout);
48  exit(2);
49  }
50 
51  Iterator it = _geoms.find(geo->get_id());
52  if (it != _geoms.end())
53  {
54  cout
55  << "RawTowerGeomContainerv1::add_tower_geometry - WARNING - replace tower geometry for tower #"
56  << geo->get_id() << ". This Old tower will be deleted: ";
57  it->second->identify(cout);
58 
59  delete it->second;
60  _geoms.erase(it);
61  }
62 
63  _geoms[geo->get_id()] = geo;
64  return _geoms.find(geo->get_id());
65 }
66 
69 {
70  Iterator it = _geoms.find(key);
71  if (it != _geoms.end())
72  {
73  return it->second;
74  }
75  return nullptr;
76 }
77 
79 {
80  return (!_geoms.empty());
81 }
82 
84 {
85  while (_geoms.begin() != _geoms.end())
86  {
87  delete _geoms.begin()->second;
88  _geoms.erase(_geoms.begin());
89  }
90 }
91 
92 void RawTowerGeomContainerv1::identify(std::ostream& os) const
93 {
94  os << "RawTowerGeomContainerv1, number of tower geometries: " << size()
95  << std::endl;
96 }