Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4CylinderCellGeom_Spacalv1.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4CylinderCellGeom_Spacalv1.cc
1 // $Id: $
2 
12 #include "PHG4CylinderCellDefs.h"
13 
14 #include <cassert>
15 #include <cstdlib>
16 #include <iostream>
17 #include <sstream>
18 #include <stdexcept>
19 
20 using namespace std;
21 
23 
25 {
26  // TODO Auto-generated destructor stub
27 }
28 
30 {
32 
33  cout << "PHG4CylinderCellGeom_Spacalv1::identify - Tower mapping:" << endl;
34  for (const tower_z_ID_eta_bin_map_t::value_type& tower_z_ID_eta_bin :
35  get_tower_z_ID_eta_bin_map())
36  {
37  cout << "\t"
38  << "Tower Z ID[" << tower_z_ID_eta_bin.first
39  << "] \t-> Eta Bin " << tower_z_ID_eta_bin.second << endl;
40  }
41 
42  cout << "PHG4CylinderCellGeom_Spacalv1::identify - Bin -> z range:" << endl;
43  for (const bound_map_t::value_type& b : z_bound_map)
44  {
45  cout << "\t"
46  << "bin[" << b.first << "] \t-> z = " << b.second.first
47  << " - " << b.second.second << endl;
48  }
49 
50  cout << "PHG4CylinderCellGeom_Spacalv1::identify - Bin -> eta range:" << endl;
51  for (const bound_map_t::value_type& b : eta_bound_map)
52  {
53  cout << "\t"
54  << "bin[" << b.first << "] \t-> eta = " << b.second.first
55  << " - " << b.second.second << endl;
56  }
57  return;
58 }
59 
61 {
62  if ((size_t) nzbins != z_bound_map.size())
63  {
64  cout << "PHG4CylinderCellGeom_Spacalv1::map_consistency_check - "
65  << "z_bound_map.size() of " << z_bound_map.size()
66  << " in inconsistent with nzbins of " << nzbins << endl;
67  exit(1);
68  }
69  if ((size_t) nzbins != eta_bound_map.size())
70  {
71  cout << "PHG4CylinderCellGeom_Spacalv1::map_consistency_check - "
72  << "eta_bound_map.size() of " << eta_bound_map.size()
73  << " in inconsistent with nzbins of " << nzbins << endl;
74  exit(1);
75  }
76  if ((size_t) nzbins < tower_z_ID_eta_bin_map.size())
77  {
78  cout << "PHG4CylinderCellGeom_Spacalv1::map_consistency_check - "
79  << "tower_z_ID_eta_bin_map.size() of " << tower_z_ID_eta_bin_map.size()
80  << " in inconsistent with nzbins of " << nzbins << endl;
81  exit(1);
82  }
83 }
84 
86  const std::pair<double, double>& bounds)
87 {
88  assert(ibin >= 0);
89  z_bound_map[ibin] = bounds;
90 }
91 
93  const std::pair<double, double>& bounds)
94 {
95  assert(ibin >= 0);
96  eta_bound_map[ibin] = bounds;
97 }
98 
99 pair<double, double>
101 {
102  map_consistency_check();
103  check_binning_method(PHG4CylinderCellDefs::spacalbinning);
104  bound_map_t ::const_iterator iter =
105  z_bound_map.find(ibin);
106 
107  if (iter == z_bound_map.end())
108  {
109  cout
110  << "PHG4CylinderCellGeom_Spacalv1::get_zbounds - Fatal Error - Asking for invalid bin in z: "
111  << ibin << ". Print of content:" << endl;
112  identify();
113  exit(1);
114  }
115  return iter->second;
116 }
117 
118 pair<double, double>
120 {
121  map_consistency_check();
122  check_binning_method(PHG4CylinderCellDefs::spacalbinning);
123 
124  bound_map_t ::const_iterator iter =
125  eta_bound_map.find(ibin);
126 
127  if (iter == eta_bound_map.end())
128  {
129  cout
130  << "PHG4CylinderCellGeom_Spacalv1::get_etabounds - Fatal Error - Asking for invalid bin in z: "
131  << ibin << ". Print of content:" << endl;
132  identify();
133  exit(1);
134  }
135  return iter->second;
136 }
137 
138 int PHG4CylinderCellGeom_Spacalv1::get_zbin(const double /*z*/) const
139 {
140  cout << "PHG4CylinderCellGeom_Spacalv1::get_zbin is invalid" << endl;
141  exit(1);
142  return -1;
143 }
144 
145 int PHG4CylinderCellGeom_Spacalv1::get_etabin(const double /*eta*/) const
146 {
147  cout << "PHG4CylinderCellGeom_Spacalv1::get_etabin is invalid" << endl;
148  exit(1);
149  return -1;
150 }
151 
152 double
154 {
155  pair<double, double> bound = get_zbounds(ibin);
156  return 0.5 * (bound.first + bound.second);
157 }
158 
159 double
161 {
162  pair<double, double> bound = get_etabounds(ibin);
163  return 0.5 * (bound.first + bound.second);
164 }
165 
166 int PHG4CylinderCellGeom_Spacalv1::get_etabin_block(const int tower_z_ID) const
167 {
168  map_consistency_check();
169 
170  tower_z_ID_eta_bin_map_t::const_iterator iter = tower_z_ID_eta_bin_map.find(tower_z_ID);
171 
172  if (iter == tower_z_ID_eta_bin_map.end())
173  {
174  ostringstream o;
175 
176  o << "PHG4CylinderCellGeom_Spacalv1::get_etabin - Fatal Error - can not find tower_z_ID of " << tower_z_ID << ".";
177 
178  throw range_error(o.str());
179  }
180 
181  return iter->second;
182 }