Class Reference for E1039 Core & Analysis Software
PHG4CylinderGeomContainer.cc
Go to the documentation of this file.
2 #include "PHG4CylinderGeom.h"
3 #include <cmath>
4 
5 using namespace std;
6 
8  magfield(NAN)
9 {}
10 
12 {
13  while(layergeoms.begin() != layergeoms.end())
14  {
15  delete layergeoms.begin()->second;
16  layergeoms.erase(layergeoms.begin());
17  }
18  return;
19 }
20 
21 void
22 PHG4CylinderGeomContainer::identify(std::ostream& os) const
23 {
24  os << "mag field: " << magfield << endl;
25  os << "number of layers: " << layergeoms.size() << endl;
26  map<int,PHG4CylinderGeom *>::const_iterator iter;
27  for (iter=layergeoms.begin(); iter != layergeoms.end(); ++iter)
28  {
29  (iter->second)->identify(os);
30  }
31 
32  return;
33 }
34 
35 int
37 {
38  if (layergeoms.find(i) != layergeoms.end())
39  {
40  cout << "layer " << i << " already added to PHCylinderGeomContainer" << endl;
41  return -1;
42  }
43  mygeom->set_layer(i);
44  layergeoms[i] = mygeom;
45  return 0;
46 }
47 
48 int
50 {
51  int layer = mygeom->get_layer();
52  if (layergeoms.find(layer) != layergeoms.end())
53  {
54  cout << "layer " << layer << " already added to PHCylinderGeomContainer" << endl;
55  return -1;
56  }
57  layergeoms[layer] = mygeom;
58  return 0;
59 }
60 
63 {
64  map<int,PHG4CylinderGeom *>::const_iterator iter = layergeoms.find(i);
65  if (iter != layergeoms.end())
66  {
67  return iter->second;
68  }
69  cout << "Could not locate layer " << i << " in PHG4CylinderGeomContainer" << endl;
70  return nullptr;
71 }
72 
75 {
76  if (layergeoms.empty())
77  {
78  return nullptr;
79  }
80  return layergeoms.begin()->second;
81 }
82 
PHG4CylinderGeom * GetLayerGeom(const int i)
PHG4CylinderGeom * GetFirstLayerGeom()
int AddLayerGeom(const int i, PHG4CylinderGeom *mygeom)
void identify(std::ostream &os=std::cout) const
std::map< int, PHG4CylinderGeom * > layergeoms
virtual int get_layer() const
virtual void set_layer(const int i)