Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4CylinderCellGeom.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4CylinderCellGeom.cc
1 #include "PHG4CylinderCellGeom.h"
2 #include "PHG4CylinderCellDefs.h"
3 
4 #include <phool/phool.h>
5 #include <cstdlib>
6 
8 {
10  nzbins = i;
11 }
12 
14 {
16  zmin = z;
17 }
18 
20 {
22  return nzbins;
23 }
24 
25 double
27 {
29  return zmin;
30 }
31 
32 double
34 {
36  return zstep;
37 }
38 
40 {
42  zstep = z;
43 }
44 
46 {
47  check_binning_method_phi("PHG4CylinderCellGeom::get_phibins");
48  return nphibins;
49 }
50 
51 double
53 {
54  check_binning_method_phi("PHG4CylinderCellGeom::get_phistep");
55  return phistep;
56 }
57 
58 double
60 {
61  check_binning_method_phi("PHG4CylinderCellGeom::get_phimin");
62  return phimin;
63 }
64 
66 {
67  check_binning_method_phi("PHG4CylinderCellGeom::set_phibins");
68  nphibins = i;
69 }
70 
72 {
73  check_binning_method_phi("PHG4CylinderCellGeom::set_phistep");
74  phistep = r;
75 }
76 
78 {
79  check_binning_method_phi("PHG4CylinderCellGeom::set_phimin");
80  phimin = r;
81 }
82 
84 {
85  check_binning_method_eta("PHG4CylinderCellGeom::get_etabins");
86  return nzbins;
87 }
88 
89 double
91 {
92  check_binning_method_eta("PHG4CylinderCellGeom::get_etastep");
93  return zstep;
94 }
95 double
97 {
98  check_binning_method_eta("PHG4CylinderCellGeom::get_etamin");
99  return zmin;
100 }
101 
103 {
104  check_binning_method_eta("PHG4CylinderCellGeom::set_etamin");
105  zmin = z;
106 }
107 
109 {
110  check_binning_method_eta("PHG4CylinderCellGeom::set_etastep");
111  zstep = z;
112 }
113 
115 {
116  check_binning_method_eta("PHG4CylinderCellGeom::set_etabins");
117  nzbins = i;
118 }
119 
120 void PHG4CylinderCellGeom::identify(std::ostream& os) const
121 {
122  os << "PHG4CylinderCellGeom::identify - layer: " << layer
123  << ", radius: " << radius
124  << ", thickness: " << thickness;
125  switch (binning)
126  {
128  os << ", zbins: " << nzbins
129  << ", zmin: " << zmin
130  << ", zstepsize: " << zstep;
131  break;
133  os << ", etabins: " << nzbins
134  << ", etamin: " << zmin
135  << ", etastepsize: " << zstep;
136  break;
138  os << ", etabins: " << nzbins
139  << ", etamin: " << zmin
140  << ", etastepsize: " << zstep;
141  break;
143  os << ", etabins: " << nzbins << " for Spacal";
144  break;
145  default:
146  os << "no valid binning method: " << binning << std::endl;
147  return;
148  break;
149  }
150  os << ", phimin: " << phimin
151  << ", phibins: " << nphibins
152  << ", phistep: " << phistep
153  << std::endl;
154  return;
155 }
156 
157 std::pair<double, double>
159 {
160  if (ibin < 0 || ibin > nzbins)
161  {
162  std::cout << PHWHERE << " Asking for invalid bin in z: " << ibin << std::endl;
163  exit(1);
164  }
166  double zlow = zmin + ibin * zstep;
167  double zhigh = zlow + zstep;
168  return std::make_pair(zlow, zhigh);
169 }
170 
171 std::pair<double, double>
173 {
174  if (ibin < 0 || ibin > nzbins)
175  {
176  std::cout << PHWHERE << " Asking for invalid bin in z: " << ibin << std::endl;
177  exit(1);
178  }
179  check_binning_method_eta("PHG4CylinderCellGeom::get_etabounds");
180  // check_binning_method(PHG4CylinderCellDefs::etaphibinning);
181  double zlow = zmin + ibin * zstep;
182  double zhigh = zlow + zstep;
183  return std::make_pair(zlow, zhigh);
184 }
185 
186 std::pair<double, double>
188 {
189  if (ibin < 0 || ibin > nphibins)
190  {
191  std::cout << PHWHERE << "Asking for invalid bin in phi: " << ibin << std::endl;
192  exit(1);
193  }
194 
195  double philow = phimin + ibin * phistep;
196  double phihigh = philow + phistep;
197  return std::make_pair(philow, phihigh);
198 }
199 
200 int PHG4CylinderCellGeom::get_zbin(const double z) const
201 {
202  if (z < zmin || z > (zmin + nzbins * zstep))
203  {
204  // cout << PHWHERE << "Asking for bin for z outside of z range: " << z << endl;
205  return -1;
206  }
207 
209  return floor((z - zmin) / zstep);
210 }
211 
212 int PHG4CylinderCellGeom::get_etabin(const double eta) const
213 {
214  if (eta < zmin || eta > (zmin + nzbins * zstep))
215  {
216  // cout << "Asking for bin for eta outside of eta range: " << eta << endl;
217  return -1;
218  }
220  return floor((eta - zmin) / zstep);
221 }
222 
223 int PHG4CylinderCellGeom::get_phibin(const double phi) const
224 {
225  double norm_phi = phi;
226  if (phi < phimin || phi > (phimin + nphibins * phistep))
227  {
228  int nwraparound = -floor((phi - phimin) * 0.5 / M_PI);
229  norm_phi += 2 * M_PI * nwraparound;
230  }
232  return floor((norm_phi - phimin) / phistep);
233 }
234 
235 double
237 {
238  if (ibin < 0 || ibin > nzbins)
239  {
240  std::cout << PHWHERE << "Asking for invalid bin in z: " << ibin << std::endl;
241  exit(1);
242  }
244  return zmin + (ibin + 0.5) * zstep;
245 }
246 
247 double
249 {
250  if (ibin < 0 || ibin > nzbins)
251  {
252  std::cout << PHWHERE << "Asking for invalid bin in eta: " << ibin << std::endl;
253  std::cout << "minbin: 0, maxbin " << nzbins << std::endl;
254  exit(1);
255  }
257  return zmin + (ibin + 0.5) * zstep;
258 }
259 
260 double
262 {
263  if (ibin < 0 || ibin > nphibins)
264  {
265  std::cout << PHWHERE << "Asking for invalid bin in phi: " << ibin << std::endl;
266  exit(1);
267  }
268 
270  return (phimin + (ibin + 0.5) * phistep);
271 }
272 
275 {
276  switch (i)
277  {
279  return "Bins in cm";
280  break;
282  return "Eta/Phi bins";
283  break;
285  return "Eta/numslat bins";
286  break;
288  return "SPACAL Tower bins";
289  break;
290  default:
291  break;
292  }
293  return "Unknown";
294 }
295 
297 {
298  if (binning != i)
299  {
300  std::cout << "different binning method used " << methodname(binning)
301  << ", not : " << methodname(i)
302  << std::endl;
303  exit(1);
304  }
305  return;
306 }
307 
309 {
313  {
314  if (src.size())
315  std::cout << src << " : ";
316 
317  std::cout << "different binning method used " << methodname(binning)
321  << std::endl;
322  exit(1);
323  }
324  return;
325 }
326 
328 {
333  {
334  if (src.size())
335  std::cout << src << " : ";
336 
337  std::cout << "different binning method used " << methodname(binning)
342  << std::endl;
343  exit(1);
344  }
345  return;
346 }