ECCE @ EIC 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 
7 void
9 {
11  nzbins = i;
12 }
13 
14 void
16 {
18  zmin = z;
19 }
20 
21 int
23 {
25  return nzbins;
26 }
27 
28 double
30 {
32  return zmin;
33 }
34 
35 double
37 {
39  return zstep;
40 }
41 
42 void
44 {
46  zstep = z;
47 }
48 
49 int
51 {
52  check_binning_method_phi("PHG4CylinderCellGeom::get_phibins");
53 return nphibins;
54 }
55 
56 double
58 {
59  check_binning_method_phi("PHG4CylinderCellGeom::get_phistep");
60  return phistep;
61 }
62 
63 double
65 {
66  check_binning_method_phi("PHG4CylinderCellGeom::get_phimin");
67  return phimin;
68 }
69 
70 void
72 {
73  check_binning_method_phi("PHG4CylinderCellGeom::set_phibins");
74  nphibins = i;
75 }
76 
77 void
79 {
80  check_binning_method_phi("PHG4CylinderCellGeom::set_phistep");
81  phistep = r;
82 }
83 
84 void
86 {
87  check_binning_method_phi("PHG4CylinderCellGeom::set_phimin");
88  phimin = r;
89 }
90 
91 int
93 {
94  check_binning_method_eta("PHG4CylinderCellGeom::get_etabins");
95  return nzbins;
96 }
97 
98 double
100 {
101  check_binning_method_eta("PHG4CylinderCellGeom::get_etastep");
102  return zstep;
103 }
104 double
106 {
107  check_binning_method_eta("PHG4CylinderCellGeom::get_etamin");
108  return zmin;
109 }
110 
111 void
113 {
114  check_binning_method_eta("PHG4CylinderCellGeom::set_etamin");
115  zmin = z;
116 }
117 
118 void
120 {
121  check_binning_method_eta("PHG4CylinderCellGeom::set_etastep");
122  zstep = z;
123 }
124 
125 void
127 {
128  check_binning_method_eta("PHG4CylinderCellGeom::set_etabins");
129  nzbins = i;
130 }
131 
132 void
133 PHG4CylinderCellGeom::identify(std::ostream& os) const
134 {
135  os << "PHG4CylinderCellGeom::identify - layer: " << layer
136  << ", radius: " << radius
137  << ", thickness: " << thickness;
138  switch (binning)
139  {
141  os << ", zbins: " << nzbins
142  << ", zmin: " << zmin
143  << ", zstepsize: " << zstep;
144  break;
146  os << ", etabins: " << nzbins
147  << ", etamin: " << zmin
148  << ", etastepsize: " << zstep;
149  break;
151  os << ", etabins: " << nzbins
152  << ", etamin: " << zmin
153  << ", etastepsize: " << zstep;
154  break;
156  os << ", etabins: " << nzbins<<" for Spacal";
157  break;
158  default:
159  os << "no valid binning method: " << binning << std::endl;
160  return;
161  break;
162  }
163  os << ", phimin: " << phimin
164  << ", phibins: " << nphibins
165  << ", phistep: " << phistep
166  << std::endl;
167  return;
168 }
169 
170 std::pair<double, double>
172 {
173  if (ibin < 0 || ibin > nzbins)
174  {
175  std::cout << PHWHERE << " Asking for invalid bin in z: " << ibin << std::endl;
176  exit(1);
177  }
179  double zlow = zmin + ibin * zstep;
180  double zhigh = zlow + zstep;
181  return std::make_pair(zlow, zhigh);
182 }
183 
184 std::pair<double, double>
186 {
187  if (ibin < 0 || ibin > nzbins)
188  {
189  std::cout << PHWHERE << " Asking for invalid bin in z: " << ibin << std::endl;
190  exit(1);
191  }
192  check_binning_method_eta("PHG4CylinderCellGeom::get_etabounds");
193 // check_binning_method(PHG4CylinderCellDefs::etaphibinning);
194  double zlow = zmin + ibin * zstep;
195  double zhigh = zlow + zstep;
196  return std::make_pair(zlow, zhigh);
197 }
198 
199 
200 std::pair<double, double>
202 {
203  if (ibin < 0 || ibin > nphibins)
204  {
205  std::cout << PHWHERE << "Asking for invalid bin in phi: " << ibin << std::endl;
206  exit(1);
207  }
208 
209  double philow = phimin + ibin * phistep;
210  double phihigh = philow + phistep;
211  return std::make_pair(philow, phihigh);
212 }
213 
214 int
216 {
217  if (z < zmin || z > (zmin+nzbins*zstep))
218  {
219  // cout << PHWHERE << "Asking for bin for z outside of z range: " << z << endl;
220  return -1;
221  }
222 
224  return floor( (z-zmin)/zstep );
225 }
226 
227 int
229 {
230  if (eta < zmin || eta > (zmin+nzbins*zstep))
231  {
232  // cout << "Asking for bin for eta outside of eta range: " << eta << endl;
233  return -1;
234  }
236  return floor( (eta-zmin)/zstep );
237 }
238 
239 int
241 {
242  double norm_phi = phi;
243  if(phi < phimin || phi > (phimin+nphibins*phistep))
244  {
245  int nwraparound = -floor((phi-phimin) * 0.5 / M_PI);
246  norm_phi += 2*M_PI*nwraparound;
247  }
249  return floor( (norm_phi-phimin)/phistep );
250 }
251 
252 double
254 {
255  if (ibin < 0 || ibin > nzbins)
256  {
257  std::cout << PHWHERE << "Asking for invalid bin in z: " << ibin << std::endl;
258  exit(1);
259  }
261  return zmin + (ibin + 0.5)*zstep;
262 }
263 
264 double
266 {
267  if (ibin < 0 || ibin > nzbins)
268  {
269  std::cout << PHWHERE << "Asking for invalid bin in eta: " << ibin << std::endl;
270  std::cout << "minbin: 0, maxbin " << nzbins << std::endl;
271  exit(1);
272  }
274  return zmin + (ibin + 0.5)*zstep;
275 }
276 
277 double
279 {
280  if (ibin < 0 || ibin > nphibins)
281  {
282  std::cout << PHWHERE << "Asking for invalid bin in phi: " << ibin << std::endl;
283  exit(1);
284  }
285 
287  return (phimin + (ibin + 0.5)*phistep);
288 }
289 
290 std::string
292 {
293  switch (i)
294  {
296  return "Bins in cm";
297  break;
299  return "Eta/Phi bins";
300  break;
302  return "Eta/numslat bins";
303  break;
305  return "SPACAL Tower bins";
306  break;
307  default:
308  break;
309  }
310  return "Unknown";
311 }
312 
313 void
315 {
316  if (binning != i)
317  {
318  std::cout << "different binning method used " << methodname(binning)
319  << ", not : " << methodname(i)
320  << std::endl;
321  exit(1);
322  }
323  return;
324 }
325 
326 void
328 {
332  {
333  if (src.size())
334  std::cout << src<<" : ";
335 
336  std::cout << "different binning method used " << methodname(binning)
340  << std::endl;
341  exit(1);
342  }
343  return;
344 }
345 
346 void
348 {
353  {
354  if (src.size())
355  std::cout << src<<" : ";
356 
357  std::cout << "different binning method used " << methodname(binning)
362  << std::endl;
363  exit(1);
364  }
365  return;
366 }