ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4BlockGeomContainer.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4BlockGeomContainer.cc
2 
3 #include "PHG4BlockGeom.h"
4 
5 #include <cmath>
6 
7 using namespace std;
8 
10  : _magfield(NAN)
11 {}
12 
14 {
15  while(_layergeoms.begin() != _layergeoms.end())
16  {
17  delete _layergeoms.begin()->second;
18  _layergeoms.erase(_layergeoms.begin());
19  }
20  return;
21 }
22 
23 void
24 PHG4BlockGeomContainer::identify(std::ostream& os) const
25 {
26  os << "mag field: " << _magfield << endl;
27  os << "number of layers: " << _layergeoms.size() << endl;
28  map<int,PHG4BlockGeom *>::const_iterator iter;
29  for (iter=_layergeoms.begin(); iter != _layergeoms.end(); ++iter)
30  {
31  (iter->second)->identify(os);
32  }
33  return;
34 }
35 
36 int
38 {
39  if (_layergeoms.find(i) != _layergeoms.end())
40  {
41  cout << "layer " << i << " already added to PHBlockGeomContainer" << endl;
42  return -1;
43  }
44  mygeom->set_layer(i);
45  _layergeoms[i] = mygeom;
46  return 0;
47 }
48 
49 int
51 {
52  int layer = mygeom->get_layer();
53  if (_layergeoms.find(layer) != _layergeoms.end())
54  {
55  cout << "layer " << layer << " already added to PHBlockGeomContainer" << endl;
56  return -1;
57  }
58  _layergeoms[layer] = mygeom;
59  return 0;
60 }
61 
64 {
65  map<int,PHG4BlockGeom *>::const_iterator iter = _layergeoms.find(i);
66  if (iter != _layergeoms.end())
67  {
68  return iter->second;
69  }
70  cout << "Could not locate layer " << i << " in PHG4BlockGeomContainer" << endl;
71  return nullptr;
72 }
73