Belle II Software  release-06-02-00
ECLCrystalData.cc
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 //This module
10 #include <ecl/modules/eclBackgroundStudy/ECLCrystalData.h>
11 
12 //Framework
13 #include <framework/logging/Logger.h>
14 
15 //STL
16 #include <cmath>
17 #define PI 3.14159265358979323846
18 #define DEGTORAD 1.74532925199432955e-02
19 
20 using namespace Belle2;
21 
22 //ECL has 16-fold symmetry in phi. Multiply this by 16 to get the total number of crystals at each theta location.
23 int const ECLCrystalData::Ring[69] = {
24  3, 3, 4, 4, 4, 6, 6, 6, 6, 6, 6, 9, 9, //forward calorimeter
25  9, 9, 9, 9, 9 , 9, 9, 9, 9, 9 , 9, 9, 9, 9, 9 , 9, 9, 9, 9, 9, //barrel
26  9, 9, 9, 9, 9 , 9, 9, 9, 9, 9 , 9, 9, 9, 9, 9 , 9, 9, 9, 9, 9, //barrel
27  9, 9, 9, 9, 9 , 9, //barrel
28  9, 9, 6, 6, 6, 6, 6, 4, 4, 4 //backward calorimeter
29 };
30 
31 int const ECLCrystalData::sumPrevious[24] = {0, 3, 6, 10, 14, 18, 24, 30, 36, 42, 48, 54, 63, 72, 81, 90, 96, 102, 108, 114, 120, 124, 128, 132};
32 
33 //endcap crystal masses
34 float const ECLCrystalData::CrystalMassEndcap[132] = {4.99, 5.01, 4.99, 5.82, 5.94, 5.83, 4.75, 4.76, 4.77, 4.74, 5.14, 5.16, 5.16,
35  5.14, 5.76, 5.8, 5.79, 5.78, 4.14, 4.28, 4.15, 4.16, 4.28, 4.14, 4.32, 4.34,
36  4.34, 4.34, 4.34, 4.32, 4.85, 4.87, 4.87, 4.87, 4.87, 4.85, 4.99, 5.02, 5.02,
37  5.02, 5.02, 4.99, 5.37, 5.39, 5.39, 5.39, 5.39, 5.37, 5.89, 5.92, 5.92, 5.92,
38  5.92, 5.9, 4.03, 4.12, 4.05, 4.05, 4.12, 4.05, 4.05, 4.12, 4.03, 4.16, 4.18,
39  4.18, 4.18, 4.18, 4.18, 4.18, 4.18, 4.16, 4.47, 4.49, 4.49, 4.49, 4.49, 4.49,
40  4.49, 4.49, 4.47, 4.26, 4.34, 4.28, 4.28, 4.34, 4.28, 4.28, 4.34, 4.26, 5.88,
41  5.91, 5.91, 5.91, 5.91, 5.88, 5.46, 5.48, 5.48, 5.48, 5.48, 5.46, 5.02, 5.04,
42  5.04, 5.04, 5.04, 5.02, 4.63, 4.65, 4.65, 4.65, 4.65, 4.63, 4.4, 4.53, 4.42,
43  4.42, 4.53, 4.4, 5.74, 5.77, 5.76, 5.74, 5.09, 5.11, 5.11, 5.09, 4.56, 4.58,
44  4.58, 4.56
45  };
46 
47 //Barrel crystal masses
48 float const ECLCrystalData::CrystalMassBarrel[46] = {4.599, 4.619, 4.639, 4.659, 4.680, 4.701, 4.722, 4.744, 4.765,
49  4.786, 4.807, 4.828, 4.848, 4.868, 4.887, 4.906, 4.923, 4.940,
50  4.955, 4.969, 4.981, 4.992, 5.001, 5.008, 5.013, 5.016, 5.017,
51  5.016, 4.455, 4.455, 5.016, 5.017, 5.016, 5.013, 5.008, 5.001,
52  4.992, 4.981, 4.969, 4.955, 4.940, 4.923, 4.906, 4.887, 4.868,
53  4.848
54  };
55 
56 
57 //Theta ID to theta(deg)
58 double const ECLCrystalData::theta[69] = {13.9486666667, 15.4862, 17.110575, 18.757625, 20.255425, 21.8637333333,
59  23.4259666667, 24.96125, 26.4777833333, 27.9407, 29.36275, 30.8382555556,
60  32.2618444444, 33.667039, 35.062886, 36.509337, 38.007345, 39.557769,
61  41.161373, 42.818633, 44.530027, 46.295838, 48.115876, 49.990235, 51.91882,
62  53.900865, 55.935415, 58.021324, 60.157158, 62.3412, 64.571442, 66.8455,
63  69.160698, 71.513983, 73.902011, 76.321253, 78.767888, 81.237718, 83.726351,
64  86.229301, 88.741891, 90, 90, 91.258109, 93.770699, 96.273649, 98.762282,
65  101.232112, 103.678747, 106.097989, 108.486017, 110.839302, 113.154501,
66  115.428558, 117.658801, 119.842842, 121.978676, 124.064585, 126.099135,
67  128.2902222222, 130.4424444444, 132.6918333333, 134.9551666667, 137.3811666667,
68  139.9081666667, 142.5951666667, 145.374, 148.0185, 150.8355
69  };
70 
72 double const ECLCrystalData::EndcapRadius[132] = {
73 // 3,3,4,4,4,6,6,6,6,6,6,9,9, //forward calorimeter
74  217.25, 217.25, 217.25,
75  218.72, 218.72, 218.72,
76  220.29, 220.29, 220.29, 220.29,
77  222.00, 222.00, 222.00, 222.00,
78  223.96, 223.96, 223.96, 223.96,
79  226.01, 226.01, 226.01, 226.01, 226.01, 226.01,
80  228.21, 228.21, 228.21, 228.21, 228.21, 228.21,
81  230.67, 230.67, 230.67, 230.67, 230.67, 230.67,
82  233.20, 233.20, 233.20, 233.20, 233.20, 233.20,
83  235.89, 235.89, 235.89, 235.89, 235.89, 235.89,
84  238.89, 238.89, 238.89, 238.89, 238.89, 238.89,
85  241.94, 241.94, 241.94, 241.94, 241.94, 241.94, 241.94, 241.94, 241.94,
86  245.16, 245.16, 245.16, 245.16, 245.16, 245.16, 245.16, 245.16, 245.16,
87 // 9,9,6,6,6,6,6,4,4,4 //backward calorimeter
88  172.06, 172.06, 172.06, 172.06, 172.06, 172.06, 172.06, 172.06, 172.06,
89  165.69, 165.69, 165.69, 165.69, 165.69, 165.69, 165.69, 165.69, 165.69,
90  159.78, 159.78, 159.78, 159.78, 159.78, 159.78,
91  154.36, 154.36, 154.36, 154.36, 154.36, 154.36,
92  149.37, 149.37, 149.37, 149.37, 149.37, 149.37,
93  144.82, 144.82, 144.82, 144.82, 144.82, 144.82,
94  140.67, 140.67, 140.67, 140.67, 140.67, 140.67,
95  136.89, 136.89, 136.89, 136.89,
96  133.49, 133.49, 133.49, 133.49,
97  133.49, 133.49, 133.49, 133.49
98 };
99 
100 
102 double const ECLCrystalData::BarrelZ[46] = {210.15, 200.14, 190.44, 181.05, 171.95, 163.03, 154.45, 146.10, 137.98, 129.99, 122.27, 114.72, 107.34, 100.05, 92.96, 86.00, 79.15, 72.36, 65.72, 59.16, 52.69, 46.22, 39.87, 33.56, 27.29, 21.01, 14.81, 8.62, 2.78, -2.78, -14.81, -21.01, -27.29, -33.56, -39.87, -46.22, -52.69, -59.16, -65.72, -72.36, -79.15, -86.00, -92.95, -100.05, -107 - 28};
103 
104 
105 
106 
109 {
110  m_cell_ID = -1;
111  m_phi_ID = -1;
112  m_theta_ID = -1;
113  m_phi_idx = -1;
114  m_theta_idx = -1;
115 
116  m_mass = -1;
117  m_volume = -1;
118  m_PosR = -1;
119  m_PosP = -1;
120  m_PosX = -1;
121  m_PosY = -1;
122  m_PosZ = -1;
123 }
124 
126 {
127  m_cell_ID = cid;
128  Mapping(cid);
129 
130  Eval();
131 
132 }
133 
135 {
136  m_phi_idx = -1;
137  m_theta_idx = -1;
138  m_theta_ID = tid;
139  m_phi_ID = pid;
140  m_cell_ID = GetCellID(tid, pid);
141 
142  Eval();
143 }
144 
146 {
147 }
148 
149 
152 {
153  //Crystal properties
154  m_mass = EvalMass();
155  m_volume = m_mass / 4.51;
156 
157  //Crystal Location
158  m_PosP = EvalPhi();
159  m_PosR = EvalR();
160 
161  m_PosZ = EvalZ();
162  m_PosX = EvalX();
163  m_PosY = EvalY();
164 
165 
166 }
167 
169 {
170  return m_PosR * cos(DEGTORAD * m_PosP);
171 }
172 
174 {
175  return m_PosR * sin(DEGTORAD * m_PosP);
176 }
177 
178 
179 //Determine mass of crystal
181 {
182  if (IsEndCap()) {
184 
185  } else {
187  }
188 }
189 
191 {
192  if (m_theta_ID <= 12) { //forward ECL crystal
194 
195  } else if (m_theta_ID >= 59) { //backward ECL crystal
196  return m_phi_ID % Ring[m_theta_ID] + sumPrevious[m_theta_ID - 46];
197 
198  } else if (12 < m_theta_ID && m_theta_ID < 59) { //barrel ECL crystal
199  return m_theta_ID - 13;
200  }
201 
202  B2ERROR("ERROR: invalid theta_ID=" << m_theta_ID);
203  return -1;
204 }
205 
207 {
208  return m_theta_ID < 13 || m_theta_ID > 58 ;
209 }
210 
212 {
213  return !IsEndCap();
214 }
215 
216 
218 {
219  return m_cell_ID;
220 }
221 
223 {
224  return 22.5 * m_phi_ID / Ring[m_theta_ID];
225 }
226 
228 {
229  if (IsEndCap()) {
230  return EndcapRadius[GetCrystalIndex()] * cos(DEGTORAD * theta[m_theta_ID]);
231  }
232 
233  return BarrelZ[GetCrystalIndex()];
234 }
235 
237 {
238  if (IsEndCap()) {
239  return EndcapRadius[GetCrystalIndex()] * sin(DEGTORAD * theta[m_theta_ID]);
240  }
241 
242  return 147.7;
243 }
244 
245 
246 //Get CellID from theta and phi IDs
247 int ECLCrystalData::GetCellID(int ThetaId, int PhiId)
248 {
252  if (ThetaId < 13) {
253  int forwRing[13] = {0, 3, 6, 10, 14, 18, 24, 30, 36, 42, 48, 54, 63 };
254  return forwRing[ThetaId] * 16 + PhiId;
255 
256  } else if (ThetaId > 58) {
257  int backRing[10] = {0, 9, 18, 24, 30, 36, 42, 48, 52, 56} ;
258  return 7776 + backRing[ThetaId - 59] * 16 + PhiId;
259 
260  }
261 
262  return 1152 + 144 * (ThetaId - 13) + PhiId;
263 }
264 
266 {
267  if (cid < 0) {
268  B2ERROR("ECL ECLGeometryPar Mapping " << cid << ". Out of range.");
269 
270  } else if (cid < 3 * 16) { //Forkward start
271  m_theta_ID = 0;
272  m_phi_ID = cid;
273  m_phi_idx = m_phi_ID % 3;
274  m_theta_idx = m_phi_ID / 3;
275  } else if (cid < 6 * 16) {
276  m_theta_ID = 1;
277  m_phi_ID = cid - 3 * 16;
278  m_phi_idx = m_phi_ID % 3 + 3;
279  m_theta_idx = m_phi_ID / 3;
280  } else if (cid < 10 * 16) {
281  m_theta_ID = 2;
282  m_phi_ID = cid - 6 * 16 ;
283  m_phi_idx = m_phi_ID % 4 + 6;
284  m_theta_idx = m_phi_ID / 4;
285  } else if (cid < 14 * 16) {
286  m_theta_ID = 3;
287  m_phi_ID = cid - 10 * 16 ;
288  m_phi_idx = m_phi_ID % 4 + 10;
289  m_theta_idx = m_phi_ID / 4;
290  } else if (cid < 18 * 16) {
291  m_theta_ID = 4;
292  m_phi_ID = cid - 14 * 16 ;
293  m_phi_idx = m_phi_ID % 4 + 14;
294  m_theta_idx = m_phi_ID / 4;
295  } else if (cid < 24 * 16) {
296  m_theta_ID = 5;
297  m_phi_ID = cid - 18 * 16 ;
298  m_phi_idx = m_phi_ID % 6 + 18;
299  m_theta_idx = m_phi_ID / 6;
300  } else if (cid < 30 * 16) {
301  m_theta_ID = 6;
302  m_phi_ID = cid - 24 * 16 ;
303  m_phi_idx = m_phi_ID % 6 + 24;
304  m_theta_idx = m_phi_ID / 6;
305  } else if (cid < 36 * 16) {
306  m_theta_ID = 7;
307  m_phi_ID = cid - 30 * 16 ;
308  m_phi_idx = m_phi_ID % 6 + 30;
309  m_theta_idx = m_phi_ID / 6;
310  } else if (cid < 42 * 16) {
311  m_theta_ID = 8;
312  m_phi_ID = cid - 36 * 16 ;
313  m_phi_idx = m_phi_ID % 6 + 36;
314  m_theta_idx = m_phi_ID / 6;
315  } else if (cid < 48 * 16) {
316  m_theta_ID = 9;
317  m_phi_ID = cid - 42 * 16 ;
318  m_phi_idx = m_phi_ID % 6 + 42;
319  m_theta_idx = m_phi_ID / 6;
320  } else if (cid < 54 * 16) {
321  m_theta_ID = 10;
322  m_phi_ID = cid - 48 * 16 ;
323  m_phi_idx = m_phi_ID % 6 + 48;
324  m_theta_idx = m_phi_ID / 6;
325  } else if (cid < 63 * 16) {
326  m_theta_ID = 11;
327  m_phi_ID = cid - 54 * 16 ;
328  m_phi_idx = m_phi_ID % 9 + 54;
329  m_theta_idx = m_phi_ID / 9;
330  } else if (cid < 72 * 16) {
331  m_theta_ID = 12;
332  m_phi_ID = cid - 63 * 16 ;
333  m_phi_idx = m_phi_ID % 9 + 63;
334  m_theta_idx = m_phi_ID / 9;
335  } else if (cid < 7776) {//Barrel start
336  m_phi_ID = (cid - 1152) % 144;
337  m_theta_ID = (cid - 1152) / 144 + 13;
338  m_theta_idx = (cid - 1152) / 144;
340  } else if (cid < 7776 + 9 * 16) { //Backward start
341  m_theta_ID = 59;
342  m_phi_ID = cid - 7776 ;
343  m_phi_idx = m_phi_ID % 9 + 72;
344  m_theta_idx = m_phi_ID / 9;
345  } else if (cid < 7776 + 18 * 16) {
346  m_theta_ID = 60;
347  m_phi_ID = cid - 7776 - 9 * 16 ;
348  m_phi_idx = m_phi_ID % 9 + 81;
349  m_theta_idx = m_phi_ID / 9;
350  } else if (cid < 7776 + 24 * 16) {
351  m_theta_ID = 61;
352  m_phi_ID = cid - 7776 - 18 * 16 ;
353  m_phi_idx = m_phi_ID % 6 + 90;
354  m_theta_idx = m_phi_ID / 6;
355  } else if (cid < 7776 + 30 * 16) {
356  m_theta_ID = 62;
357  m_phi_ID = cid - 7776 - 24 * 16 ;
358  m_phi_idx = m_phi_ID % 6 + 96;
359  m_theta_idx = m_phi_ID / 6;
360  } else if (cid < 7776 + 36 * 16) {
361  m_theta_ID = 63;
362  m_phi_ID = cid - 7776 - 30 * 16 ;
363  m_phi_idx = m_phi_ID % 6 + 102;
364  m_theta_idx = m_phi_ID / 6;
365  } else if (cid < 7776 + 42 * 16) {
366  m_theta_ID = 64;
367  m_phi_ID = cid - 7776 - 36 * 16 ;
368  m_phi_idx = m_phi_ID % 6 + 108;
369  m_theta_idx = m_phi_ID / 6;
370  } else if (cid < 7776 + 48 * 16) {
371  m_theta_ID = 65;
372  m_phi_ID = cid - 7776 - 42 * 16 ;
373  m_phi_idx = m_phi_ID % 6 + 114;
374  m_theta_idx = m_phi_ID / 6;
375  } else if (cid < 7776 + 52 * 16) {
376  m_theta_ID = 66;
377  m_phi_ID = cid - 7776 - 48 * 16 ;
378  m_phi_idx = m_phi_ID % 4 + 120;
379  m_theta_idx = m_phi_ID / 4;
380  } else if (cid < 7776 + 56 * 16) {
381  m_theta_ID = 67;
382  m_phi_ID = cid - 7776 - 52 * 16 ;
383  m_phi_idx = m_phi_ID % 4 + 124;
384  m_theta_idx = m_phi_ID / 4;
385  } else if (cid < 7776 + 60 * 16) {
386  m_theta_ID = 68;
387  m_phi_ID = cid - 7776 - 56 * 16 ;
388  m_phi_idx = m_phi_ID % 4 + 128;
389  m_theta_idx = m_phi_ID / 4;
390  } else {
391  B2ERROR("ECL ECLCrystalData Mapping " << cid << ". Out of range.");
392  }
393 }
void Eval()
Set values for the crystal.
static const double theta[69]
Theta ID to theta(deg)
float m_PosY
Crystal Position - Y.
float m_mass
Crystal Mass.
float m_PosZ
Crystal Position - Z.
double EvalPhi()
Set phi value of crystal.
double EvalR()
Set R value of crystal.
float EvalMass()
Evaluate mass of crystal.
double EvalZ()
Set Z value of crystal.
int GetCrystalIndex()
return crystal index
float m_volume
Crystal Volume.
double EvalY()
Set Y value of crystal.
static const float CrystalMassEndcap[132]
Barrel crystal mass.
int m_cell_ID
Cell ID of crystal.
static const int sumPrevious[24]
Number of crystals in preceding theta rings (endcaps only)
bool IsEndCap()
True if crystal is in endcaps.
static const int Ring[69]
ECL has 16-fold symmetry in phi.
float m_PosR
Crystal Position - R.
float m_PosP
Crystal Position - P.
static const double EndcapRadius[132]
EndCapCrystalID to radius (spherical)
void Mapping(int cid)
set theta and phi value of crystal
ECLCrystalData()
Blank Constructor.
int m_phi_ID
phi ID of crystal
static const float CrystalMassBarrel[46]
Endcap crystal mass.
int m_theta_ID
theta ID of crystal
bool IsBarrel()
True if crystal is in barrel.
double EvalX()
Set X value of crystal.
float m_PosX
Crystal Position - X.
int GetCellID()
return cell ID
static const double BarrelZ[46]
BarrelCrystalID to z-coordinate.
Abstract base class for different kinds of events.