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