Analysis Software
Documentation for sPHENIX simulation 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 }
13 
15 {
16  while (_layergeoms.begin() != _layergeoms.end())
17  {
18  delete _layergeoms.begin()->second;
19  _layergeoms.erase(_layergeoms.begin());
20  }
21  return;
22 }
23 
24 void 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 
37 {
38  if (_layergeoms.find(i) != _layergeoms.end())
39  {
40  cout << "layer " << i << " already added to PHBlockGeomContainer" << endl;
41  return -1;
42  }
43  mygeom->set_layer(i);
44  _layergeoms[i] = mygeom;
45  return 0;
46 }
47 
49 {
50  int layer = mygeom->get_layer();
51  if (_layergeoms.find(layer) != _layergeoms.end())
52  {
53  cout << "layer " << layer << " already added to PHBlockGeomContainer" << endl;
54  return -1;
55  }
56  _layergeoms[layer] = mygeom;
57  return 0;
58 }
59 
62 {
63  map<int, PHG4BlockGeom *>::const_iterator iter = _layergeoms.find(i);
64  if (iter != _layergeoms.end())
65  {
66  return iter->second;
67  }
68  cout << "Could not locate layer " << i << " in PHG4BlockGeomContainer" << endl;
69  return nullptr;
70 }