Analysis Software
Documentation for
sPHENIX
simulation software
Home page
Related Pages
Modules
Namespaces
Classes
Files
Examples
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
PHG4BlockCellGeom.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file PHG4BlockCellGeom.cc
1
#include "
PHG4BlockCellGeom.h
"
2
#include "
PHG4CylinderCellDefs.h
"
3
4
#include <cmath>
5
#include <cstdlib>
6
7
using namespace
std;
8
9
PHG4BlockCellGeom::PHG4BlockCellGeom
()
10
: _layer(-9999)
11
, _binning(0)
12
, _nzbins(-1)
13
, _zmin(NAN)
14
, _zstep(NAN)
15
, _nxbins(-1)
16
, _xmin(NAN)
17
, _xstep(NAN)
18
{
19
return
;
20
}
21
22
void
PHG4BlockCellGeom::set_zbins
(
const
int
i
)
23
{
24
check_binning_method
(
PHG4CylinderCellDefs::sizebinning
);
25
_nzbins
=
i
;
26
}
27
28
void
PHG4BlockCellGeom::set_zmin
(
const
double
z
)
29
{
30
check_binning_method
(
PHG4CylinderCellDefs::sizebinning
);
31
_zmin
=
z
;
32
}
33
34
int
PHG4BlockCellGeom::get_zbins
()
const
35
{
36
check_binning_method
(
PHG4CylinderCellDefs::sizebinning
);
37
return
_nzbins
;
38
}
39
40
double
41
PHG4BlockCellGeom::get_zmin
()
const
42
{
43
check_binning_method
(
PHG4CylinderCellDefs::sizebinning
);
44
return
_zmin
;
45
}
46
47
double
48
PHG4BlockCellGeom::get_zstep
()
const
49
{
50
check_binning_method
(
PHG4CylinderCellDefs::sizebinning
);
51
return
_zstep
;
52
}
53
54
void
PHG4BlockCellGeom::set_zstep
(
const
double
z
)
55
{
56
check_binning_method
(
PHG4CylinderCellDefs::sizebinning
);
57
_zstep
=
z
;
58
}
59
60
int
PHG4BlockCellGeom::get_xbins
()
const
61
{
62
check_binning_method_x
(
"PHG4BlockCellGeom::get_xbins"
);
63
return
_nxbins
;
64
}
65
66
double
67
PHG4BlockCellGeom::get_xstep
()
const
68
{
69
check_binning_method_x
(
"PHG4BlockCellGeom::get_xstep"
);
70
return
_xstep
;
71
}
72
73
double
74
PHG4BlockCellGeom::get_xmin
()
const
75
{
76
check_binning_method_x
(
"PHG4BlockCellGeom::get_xmin"
);
77
return
_xmin
;
78
}
79
80
void
PHG4BlockCellGeom::set_xbins
(
const
int
i
)
81
{
82
check_binning_method_x
(
"PHG4BlockCellGeom::set_xbins"
);
83
_nxbins
=
i
;
84
}
85
86
void
PHG4BlockCellGeom::set_xstep
(
const
double
r
)
87
{
88
check_binning_method_x
(
"PHG4BlockCellGeom::set_xstep"
);
89
_xstep
=
r
;
90
}
91
92
void
PHG4BlockCellGeom::set_xmin
(
const
double
r
)
93
{
94
check_binning_method_x
(
"PHG4BlockCellGeom::set_xmin"
);
95
_xmin
=
r
;
96
}
97
98
int
PHG4BlockCellGeom::get_etabins
()
const
99
{
100
check_binning_method_eta
(
"PHG4BlockCellGeom::get_etabins"
);
101
return
_nzbins
;
102
}
103
104
double
105
PHG4BlockCellGeom::get_etastep
()
const
106
{
107
check_binning_method_eta
(
"PHG4BlockCellGeom::get_etastep"
);
108
return
_zstep
;
109
}
110
double
111
PHG4BlockCellGeom::get_etamin
()
const
112
{
113
check_binning_method_eta
(
"PHG4BlockCellGeom::get_etamin"
);
114
return
_zmin
;
115
}
116
117
void
PHG4BlockCellGeom::set_etamin
(
const
double
z
)
118
{
119
check_binning_method_eta
(
"PHG4BlockCellGeom::set_etamin"
);
120
_zmin
=
z
;
121
}
122
123
void
PHG4BlockCellGeom::set_etastep
(
const
double
z
)
124
{
125
check_binning_method_eta
(
"PHG4BlockCellGeom::set_etastep"
);
126
_zstep
=
z
;
127
}
128
129
void
PHG4BlockCellGeom::set_etabins
(
const
int
i
)
130
{
131
check_binning_method_eta
(
"PHG4BlockCellGeom::set_etabins"
);
132
_nzbins
=
i
;
133
}
134
135
void
PHG4BlockCellGeom::identify
(std::ostream&
os
)
const
136
{
137
os <<
"layer: "
<<
_layer
;
138
switch
(
_binning
)
139
{
140
case
PHG4CylinderCellDefs::sizebinning
:
141
os <<
", zbins: "
<<
_nzbins
142
<<
", zmin: "
<<
_zmin
143
<<
", zstepsize: "
<<
_zstep
;
144
break
;
145
146
case
PHG4CylinderCellDefs::etaphibinning
:
147
os <<
", etabins: "
<<
_nzbins
148
<<
", etamin: "
<<
_zmin
149
<<
", etastepsize: "
<<
_zstep
;
150
break
;
151
152
case
PHG4CylinderCellDefs::etaslatbinning
:
153
os <<
", etabins: "
<<
_nzbins
154
<<
", etamin: "
<<
_zmin
155
<<
", etastepsize: "
<<
_zstep
;
156
break
;
157
158
default
:
159
os <<
"no valid binning method: "
<<
_binning
<< endl;
160
return
;
161
break
;
162
}
163
164
os <<
", xmin: "
<<
_xmin
165
<<
", xbins: "
<<
_nxbins
166
<<
", xstep: "
<<
_xstep
167
<< endl;
168
return
;
169
}
170
171
pair<double, double>
172
PHG4BlockCellGeom::get_zbounds
(
const
int
ibin
)
const
173
{
174
if
(ibin < 0 || ibin >
_nzbins
)
175
{
176
cout <<
"Asking for invalid bin in z: "
<< ibin << endl;
177
exit(1);
178
}
179
check_binning_method
(
PHG4CylinderCellDefs::sizebinning
);
180
double
zlow =
_zmin
+ ibin *
_zstep
;
181
double
zhigh = zlow +
_zstep
;
182
return
make_pair(zlow, zhigh);
183
}
184
185
pair<double, double>
186
PHG4BlockCellGeom::get_etabounds
(
const
int
ibin
)
const
187
{
188
if
(ibin < 0 || ibin >
_nzbins
)
189
{
190
cout <<
"Asking for invalid bin in z: "
<< ibin << endl;
191
exit(1);
192
}
193
check_binning_method_eta
(
"PHG4BlockCellGeom::get_etabounds"
);
194
// check_binning_method(PHG4CylinderCellDefs::etaphibinning);
195
double
zlow =
_zmin
+ ibin *
_zstep
;
196
double
zhigh = zlow +
_zstep
;
197
return
make_pair(zlow, zhigh);
198
}
199
200
pair<double, double>
201
PHG4BlockCellGeom::get_xbounds
(
const
int
ibin
)
const
202
{
203
if
(ibin < 0 || ibin >
_nxbins
)
204
{
205
cout <<
"Asking for invalid bin in x: "
<< ibin << endl;
206
exit(1);
207
}
208
209
double
xlow =
_xmin
+ ibin *
_xstep
;
210
double
xhigh = xlow +
_xstep
;
211
return
make_pair(xlow, xhigh);
212
}
213
214
int
PHG4BlockCellGeom::get_zbin
(
const
double
z
)
const
215
{
216
if
(z < _zmin || z > (
_zmin
+
_nzbins
*
_zstep
))
217
{
218
cout <<
"Asking for bin for z outside of z range: "
<< z << endl;
219
return
-1;
220
}
221
222
check_binning_method
(
PHG4CylinderCellDefs::sizebinning
);
223
return
floor((z -
_zmin
) / _zstep);
224
}
225
226
int
PHG4BlockCellGeom::get_etabin
(
const
double
eta
)
const
227
{
228
if
(eta < _zmin || eta > (
_zmin
+
_nzbins
*
_zstep
))
229
{
230
cout <<
"Asking for bin for eta outside of eta range: "
<< eta << endl;
231
return
-1;
232
}
233
check_binning_method_eta
();
234
return
floor((eta -
_zmin
) / _zstep);
235
}
236
237
int
PHG4BlockCellGeom::get_xbin
(
const
double
x
)
const
238
{
239
double
norm_x =
x
;
240
if
(x < _xmin || x > (
_xmin
+
_nxbins
*
_xstep
))
241
{
242
cout <<
"Asking for bin for x outside of x range: "
<< x << endl;
243
return
-1;
244
}
245
check_binning_method_x
();
246
return
floor((norm_x -
_xmin
) / _xstep);
247
}
248
249
double
250
PHG4BlockCellGeom::get_zcenter
(
const
int
ibin
)
const
251
{
252
if
(ibin < 0 || ibin >
_nzbins
)
253
{
254
cout <<
"Asking for invalid bin in z: "
<< ibin << endl;
255
exit(1);
256
}
257
check_binning_method
(
PHG4CylinderCellDefs::sizebinning
);
258
return
_zmin
+ (ibin + 0.5) *
_zstep
;
259
}
260
261
double
262
PHG4BlockCellGeom::get_etacenter
(
const
int
ibin
)
const
263
{
264
if
(ibin < 0 || ibin >
_nzbins
)
265
{
266
cout <<
"Asking for invalid bin in eta: "
<< ibin << endl;
267
cout <<
"minbin: 0, maxbin "
<< _nzbins << endl;
268
exit(1);
269
}
270
check_binning_method_eta
();
271
return
_zmin
+ (ibin + 0.5) *
_zstep
;
272
}
273
274
double
275
PHG4BlockCellGeom::get_xcenter
(
const
int
ibin
)
const
276
{
277
if
(ibin < 0 || ibin >
_nxbins
)
278
{
279
cout <<
"Asking for invalid bin in x: "
<< ibin << endl;
280
exit(1);
281
}
282
283
check_binning_method_x
();
284
return
(
_xmin
+ (ibin + 0.5) *
_xstep
);
285
}
286
287
string
288
PHG4BlockCellGeom::methodname
(
const
int
i
)
const
289
{
290
switch
(i)
291
{
292
case
PHG4CylinderCellDefs::sizebinning
:
293
return
"Bins in cm"
;
294
break
;
295
case
PHG4CylinderCellDefs::etaphibinning
:
296
return
"Eta/Phi bins"
;
297
break
;
298
case
PHG4CylinderCellDefs::etaslatbinning
:
299
return
"Eta/numslat bins"
;
300
break
;
301
default
:
302
break
;
303
}
304
return
"Unknown"
;
305
}
306
307
void
PHG4BlockCellGeom::check_binning_method
(
const
int
i
)
const
308
{
309
if
(
_binning
!= i)
310
{
311
cout <<
"different binning method used "
<<
methodname
(
_binning
)
312
<<
", not : "
<<
methodname
(i)
313
<< endl;
314
exit(1);
315
}
316
return
;
317
}
318
319
void
PHG4BlockCellGeom::check_binning_method_eta
(
const
std::string
& src)
const
320
{
321
if
(
_binning
!=
PHG4CylinderCellDefs::etaphibinning
&&
322
_binning
!=
PHG4CylinderCellDefs::etaslatbinning
)
323
{
324
if
(src.size())
325
cout << src <<
" : "
;
326
327
cout <<
"different binning method used "
<<
methodname
(
_binning
)
328
<<
", not : "
<<
methodname
(
PHG4CylinderCellDefs::etaphibinning
)
329
<<
" or "
<<
methodname
(
PHG4CylinderCellDefs::etaslatbinning
)
330
<< endl;
331
exit(1);
332
}
333
return
;
334
}
335
336
void
PHG4BlockCellGeom::check_binning_method_x
(
const
std::string
& src)
const
337
{
338
if
(
_binning
!=
PHG4CylinderCellDefs::etaphibinning
&&
339
_binning
!=
PHG4CylinderCellDefs::sizebinning
&&
340
_binning
!=
PHG4CylinderCellDefs::etaslatbinning
)
341
{
342
if
(src.size())
343
cout << src <<
" : "
;
344
345
cout <<
"different binning method used "
<<
methodname
(
_binning
)
346
<<
", not : "
<<
methodname
(
PHG4CylinderCellDefs::etaphibinning
)
347
<<
" or "
<<
methodname
(
PHG4CylinderCellDefs::sizebinning
)
348
<< endl;
349
exit(1);
350
}
351
return
;
352
}
coresoftware
blob
master
simulation
g4simulation
g4detectors
PHG4BlockCellGeom.cc
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:18:12
using
1.8.2 with
sPHENIX GitHub integration