ECCE @ EIC 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 <boost/foreach.hpp>
15 
16 #include <cassert>
17 #include <cstdlib>
18 #include <iostream>
19 #include <stdexcept>
20 #include <sstream>
21 
22 using namespace std;
23 
25 {
26 
27 }
28 
30 {
31  // TODO Auto-generated destructor stub
32 }
33 
34 void
36 {
38 
39  cout << "PHG4CylinderCellGeom_Spacalv1::identify - Tower mapping:" << endl;
40  BOOST_FOREACH(const tower_z_ID_eta_bin_map_t::value_type& tower_z_ID_eta_bin,
41  get_tower_z_ID_eta_bin_map())
42  {
43  cout << "\t" << "Tower Z ID[" << tower_z_ID_eta_bin.first
44  << "] \t-> Eta Bin " << tower_z_ID_eta_bin.second << endl;
45  }
46 
47  cout << "PHG4CylinderCellGeom_Spacalv1::identify - Bin -> z range:" << endl;
48  BOOST_FOREACH(const bound_map_t::value_type& b, z_bound_map)
49  {
50  cout << "\t" << "bin[" << b.first << "] \t-> z = " << b.second.first
51  << " - " << b.second.second << endl;
52  }
53 
54  cout << "PHG4CylinderCellGeom_Spacalv1::identify - Bin -> eta range:" << endl;
55  BOOST_FOREACH(const bound_map_t::value_type& b, eta_bound_map)
56  {
57  cout << "\t" << "bin[" << b.first << "] \t-> eta = " << b.second.first
58  << " - " << b.second.second << endl;
59  }
60  return;
61 }
62 
63 void
65 {
66  if ((size_t) nzbins != z_bound_map.size())
67  {
68  cout << "PHG4CylinderCellGeom_Spacalv1::map_consistency_check - "
69  << "z_bound_map.size() of " << z_bound_map.size()
70  << " in inconsistent with nzbins of " << nzbins << endl;
71  exit(1);
72  }
73  if ((size_t) nzbins != eta_bound_map.size())
74  {
75  cout << "PHG4CylinderCellGeom_Spacalv1::map_consistency_check - "
76  << "eta_bound_map.size() of " << eta_bound_map.size()
77  << " in inconsistent with nzbins of " << nzbins << endl;
78  exit(1);
79  }
80  if ((size_t) nzbins < tower_z_ID_eta_bin_map.size())
81  {
82  cout << "PHG4CylinderCellGeom_Spacalv1::map_consistency_check - "
83  << "tower_z_ID_eta_bin_map.size() of " << tower_z_ID_eta_bin_map.size()
84  << " in inconsistent with nzbins of " << nzbins << endl;
85  exit(1);
86  }
87 }
88 
89 void
91  const std::pair<double, double> & bounds)
92 {
93  assert(ibin>=0);
94  z_bound_map[ibin] = bounds;
95 }
96 
97 void
99  const std::pair<double, double> & bounds)
100 {
101  assert(ibin>=0);
102  eta_bound_map[ibin] = bounds;
103 }
104 
105 pair<double, double>
107 {
108  map_consistency_check();
109  check_binning_method(PHG4CylinderCellDefs::spacalbinning);
110  bound_map_t ::const_iterator iter =
111  z_bound_map.find(ibin);
112 
113  if (iter == z_bound_map.end())
114  {
115  cout
116  << "PHG4CylinderCellGeom_Spacalv1::get_zbounds - Fatal Error - Asking for invalid bin in z: "
117  << ibin<<". Print of content:" << endl;
118  identify();
119  exit(1);
120  }
121  return iter->second;
122 }
123 
124 pair<double, double>
126 {
127  map_consistency_check();
128  check_binning_method(PHG4CylinderCellDefs::spacalbinning);
129 
130  bound_map_t ::const_iterator iter =
131  eta_bound_map.find(ibin);
132 
133  if (iter == eta_bound_map.end())
134  {
135  cout
136  << "PHG4CylinderCellGeom_Spacalv1::get_etabounds - Fatal Error - Asking for invalid bin in z: "
137  << ibin<<". Print of content:" << endl;
138  identify();
139  exit(1);
140  }
141  return iter->second;
142 }
143 
144 int
146 {
147  cout << "PHG4CylinderCellGeom_Spacalv1::get_zbin is invalid" << endl;
148  exit(1);
149  return -1;
150 }
151 
152 int
153 PHG4CylinderCellGeom_Spacalv1::get_etabin(const double /*eta*/) const
154 {
155  cout << "PHG4CylinderCellGeom_Spacalv1::get_etabin is invalid" << endl;
156  exit(1);
157  return -1;
158 }
159 
160 double
162 {
163  pair<double, double> bound = get_zbounds(ibin);
164  return 0.5 * (bound.first + bound.second);
165 }
166 
167 double
169 {
170  pair<double, double> bound = get_etabounds(ibin);
171  return 0.5 * (bound.first + bound.second);
172 }
173 
174 int PHG4CylinderCellGeom_Spacalv1::get_etabin_block(const int tower_z_ID) const
175 {
176  map_consistency_check();
177 
178  tower_z_ID_eta_bin_map_t::const_iterator iter = tower_z_ID_eta_bin_map.find(tower_z_ID);
179 
180  if (iter == tower_z_ID_eta_bin_map.end())
181  {
182  ostringstream o;
183 
184  o <<"PHG4CylinderCellGeom_Spacalv1::get_etabin - Fatal Error - can not find tower_z_ID of "<<tower_z_ID<<".";
185 
186  throw range_error(o.str());
187  }
188 
189  return iter->second;
190 }