ATLAS Offline Software
Loading...
Searching...
No Matches
CaloDetectorElements.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
6
10
12
14
15#include "GaudiKernel/SystemOfUnits.h"
16
17namespace {
18
19// estimate deta,dphi of Fcal cells (code from Dag Gillberg)
20void fcal_deta_dphi (const CaloDetDescrElement& elt,
21 float& deta,
22 float& dphi)
23{
24 // half width of fcal cells
25 const double Dx = 0.5 * elt.dx();
26 const double Dy = 0.5 * elt.dy();
27 const double phi = elt.phi();
28 const double r = elt.r();
29 const double dxcphi = Dx*std::cos(phi);
30 const double dxsphi = Dx*std::sin(phi);
31 const double dycphi = Dy*std::cos(phi);
32 const double dysphi = Dy*std::sin(phi);
33 // approximate width orthogonal to radial vector
34 const double DrT = std::sqrt(dxsphi*dxsphi+dycphi*dycphi);
35 // total width in phi
36 const double inv_r = 1. / r;
37 dphi = 2.*DrT * inv_r;
38
39 // extension in radius
40 double dr = std::sqrt(dxcphi*dxcphi+dysphi*dysphi);
41
42 // half-width in eta..
43 // sinh(eta) = z/r = f
44 // d(f) = d(z)/r (+) z/r/r*d(r)
45 // cosh(eta)*deta = df
46 // deta = df / cosh(eta) = df / sqrt(1+f*f)
47 // to avoid overlaps between cells, assume a plane geometry with dz =0
48 double f=elt.z() * inv_r;
49 double df = elt.z()*dr*inv_r*inv_r;
50 deta = 2.*std::abs(df) /std::sqrt(f*f+1.);
51}
52
53
54} // anonymous namespace
55
56
57// -- EMBDetectorElement --
59 , const IdentifierHash onl1
60 , const IdentifierHash onl2
62 , EMBCellConstLink& embCell
63 , const EMBDetectorRegion* embRegion
64 , bool isTestBeam
65 , const GeoAlignmentStore* geoAlignStore
66 , const CaloElementPositionShift* posShift)
68 , m_cell(embCell)
69 , m_region(embRegion)
70{
71 init_description(geoAlignStore,posShift);
72 if(isTestBeam) propagateRaw();
73}
74
76 , const CaloElementPositionShift* posShift)
77{
78 m_eta_raw = static_cast<float> ((m_cell->getEtaMin() + m_cell->getEtaMax())/2.);
79 if(m_cell->getEndcapIndex()==0)
80 m_eta_raw *= -1;
81
82 const double phi_loc = (m_cell->getPhiLocalLower() + m_cell->getPhiLocalUpper())/2.;
83
84 double x_loc, y_loc, z_loc, r_loc;
85 const Amg::Transform3D &xfDef = m_region->getDefAbsoluteTransform(geoAlignStore);
86 const Amg::Transform3D &xfAbs = m_region->getAbsoluteTransform(geoAlignStore);
87
88 z_loc = (m_cell->getZMaxLocal(EMBCell::CENTER) + m_cell->getZMinLocal(EMBCell::CENTER))/2.;
89 r_loc = m_cell->getRLocal(EMBCell::CENTER);
90
91 x_loc = r_loc*std::cos(phi_loc);
92 y_loc = r_loc*std::sin(phi_loc);
93
94 Amg::Vector3D globalDefCoords = xfDef*Amg::Vector3D(x_loc,y_loc,z_loc);
95 Amg::Vector3D globalAbsCoords = posShift
96 ? xfAbs*Amg::Vector3D(x_loc+posShift->dx,y_loc+posShift->dy,z_loc+posShift->dz)
97 : xfAbs*Amg::Vector3D(x_loc,y_loc,z_loc);
98
99 m_x_raw = static_cast<float> (globalDefCoords.x());
100 m_y_raw = static_cast<float> (globalDefCoords.y());
101 m_z_raw = static_cast<float> (globalDefCoords.z());
102
103 m_x = static_cast<float> (globalAbsCoords.x());
104 m_y = static_cast<float> (globalAbsCoords.y());
105 m_z = static_cast<float> (globalAbsCoords.z());
106
107 const double r_raw= std::sqrt(globalDefCoords.x()*globalDefCoords.x()+globalDefCoords.y()*globalDefCoords.y());
108 m_r_raw = static_cast<float> (r_raw);
109
110 const double r = std::sqrt(globalAbsCoords.x()*globalAbsCoords.x()+globalAbsCoords.y()*globalAbsCoords.y());
111 m_r=static_cast<float>(r);
112
113
114 if (r>0) {
115 const double big_r = std::sqrt(globalAbsCoords.x()*globalAbsCoords.x()+globalAbsCoords.y()*globalAbsCoords.y()+globalAbsCoords.z()*globalAbsCoords.z());
116 const double inv_big_r = 1. / big_r;
117 const double inv_r = 1. / r;
118 m_eta = static_cast<float> (-std::log((big_r-globalAbsCoords.z()) * inv_r));
119 m_sinTh = static_cast<float> (r * inv_big_r);
120 m_cosTh = static_cast<float> (globalAbsCoords.z() * inv_big_r);
121 m_cosPhi=globalAbsCoords.x() * inv_r;
122 m_sinPhi=globalAbsCoords.y() * inv_r;
123 }
124 else {
125 m_eta = 0.;
126 m_sinTh = 0.;
127 }
128
129 m_phi_raw = static_cast<float> (std::atan2(globalDefCoords.y(),globalDefCoords.x()));
130 m_phi = static_cast<float> (std::atan2(globalAbsCoords.y(),globalAbsCoords.x()));
131
132 m_deta = static_cast<float> (std::abs(m_cell->getEtaMax() - m_cell->getEtaMin()));
133 m_dphi = static_cast<float> (std::abs(m_cell->getPhiLocalUpper() - m_cell->getPhiLocalLower()));
134
135 // TO DO, find better value
136 m_dr = static_cast<float> (std::abs(m_cell->getRLocal(EMBCell::FRONT) - m_cell->getRLocal(EMBCell::BACK))/2.);
137
138 // -- from CaloDDE --
139 m_dx = 0.;
140 m_dy = 0.;
141 m_dz = 0.;
142 // -- from CaloDDE --
143
144}
145
147{
148 return m_region->getSamplingIndex();
149}
150
151// -- EMECDetectorElement --
152
154 , const IdentifierHash onl1
155 , const IdentifierHash onl2
157 , EMECCellConstLink& emecCell
158 , const EMECDetectorRegion* emecRegion
159 , bool isTestBeam
160 , const GeoAlignmentStore* geoAlignStore
161 , const CaloElementPositionShift* posShift)
163 , m_cell(emecCell)
164 , m_region(emecRegion)
165{
166 init_description(isTestBeam,geoAlignStore,posShift);
168 if(isTestBeam) propagateRaw();
169}
170
172 , const GeoAlignmentStore* geoAlignStore
173 , const CaloElementPositionShift* posShift)
174{
175 m_eta_raw = static_cast<float> ((m_cell->getEtaMin() + m_cell->getEtaMax())/2.);
176 if(m_cell->getEndcapIndex()==0)
177 m_eta_raw *= -1;
178
179 m_phi_raw = static_cast<float> ((m_cell->getPhiLocalLower() + m_cell->getPhiLocalUpper())/2.);
180
181 double x_loc, y_loc, z_loc, r_loc;
182 const Amg::Transform3D &xfDef = m_region->getDefAbsoluteTransform(geoAlignStore);
183
184// we need to apply the famous ZShift.
185 Amg::Transform3D xfNominal;
186 if(m_cell->getEndcapIndex()==0)
187 xfNominal = Amg::Translation3D(Amg::Vector3D(0.,0.,m_region->getProjectivityDisplacement()*Gaudi::Units::cm))*xfDef; // Negative EMEC
188 else
189 xfNominal = Amg::Translation3D(Amg::Vector3D(0.,0.,-m_region->getProjectivityDisplacement()*Gaudi::Units::cm))*xfDef; // Positive EMEC
190
191 if(isTestBeam){
192 xfNominal = Amg::Translation3D(Amg::Vector3D(0.,0.,3689.5*Gaudi::Units::mm));
193 }
194
195 const Amg::Transform3D &xfAbs = m_region->getAbsoluteTransform(geoAlignStore);
196
197 z_loc = m_cell->getZLocal(EMECCell::CENTER);
198 r_loc = (m_cell->getRMinLocal(EMECCell::CENTER) + m_cell->getRMaxLocal(EMECCell::CENTER))/2.;
199
200 x_loc = r_loc*std::cos(m_phi_raw);
201 y_loc = r_loc*std::sin(m_phi_raw);
202
203 Amg::Vector3D globalNomCoords = xfNominal*Amg::Vector3D(x_loc,y_loc,z_loc);
204 Amg::Vector3D globalAbsCoords = (posShift!=nullptr ?
205 xfAbs*Amg::Vector3D(x_loc+posShift->dx,y_loc+posShift->dy,z_loc+posShift->dz) :
206 xfAbs*Amg::Vector3D(x_loc,y_loc,z_loc));
207
208 m_x_raw = static_cast<float> (globalNomCoords.x());
209 m_y_raw = static_cast<float> (globalNomCoords.y());
210 m_z_raw = static_cast<float> (globalNomCoords.z());
211
212 m_x = static_cast<float> (globalAbsCoords.x());
213 m_y = static_cast<float> (globalAbsCoords.y());
214 m_z = static_cast<float> (globalAbsCoords.z());
215
216
217 const double r_raw= sqrt(globalNomCoords.x()*globalNomCoords.x()+globalNomCoords.y()*globalNomCoords.y());
218 m_r_raw = static_cast<float> (r_raw);
219
220 const double r = sqrt(globalAbsCoords.x()*globalAbsCoords.x()+globalAbsCoords.y()*globalAbsCoords.y());
221 m_r=static_cast<float>(r);
222
223
224 if (r>0) {
225 const double big_r = std::sqrt(globalAbsCoords.x()*globalAbsCoords.x()+globalAbsCoords.y()*globalAbsCoords.y()+globalAbsCoords.z()*globalAbsCoords.z());
226 const double inv_big_r = 1. / big_r;
227 const double inv_r = 1. /r;
228 m_eta = static_cast<float> (-log((big_r-globalAbsCoords.z()) * inv_r));
229 m_sinTh = static_cast<float> (r * inv_big_r);
230 m_cosTh = static_cast<float> (globalAbsCoords.z() * inv_big_r);
231 m_cosPhi=globalAbsCoords.x() * inv_r;
232 m_sinPhi=globalAbsCoords.y() * inv_r;
233 }
234 else {
235 m_eta = 0.;
236 m_sinTh = 0.;
237 }
238
239 m_phi = static_cast<float> (std::atan2(globalAbsCoords.y(),globalAbsCoords.x()));
240
241 m_deta = static_cast<float> (std::abs(m_cell->getEtaMax() - m_cell->getEtaMin()));
242 m_dphi = static_cast<float> (std::abs(m_cell->getPhiLocalLower() - m_cell->getPhiLocalUpper()));
243 m_dz = static_cast<float> (std::abs(m_cell->getZLocal(EMECCell::BACK) - m_cell->getZLocal(EMECCell::FRONT))/2.);
244
245 // -- from CaloDDE --
246 m_dx = 0.;
247 m_dy = 0.;
248 m_dr = 0.;
249 // -- from CaloDDE --
250}
251
253{
254 // Interpretation of PHI coming from LAr Readout Geometry
255 if(m_cell->getEndcapIndex()==1)
256 { // Positive EMEC
257 if(m_cell->getPhiLocalUpper()<M_PI)
258 m_phi_raw = static_cast<float> ((m_cell->getPhiLocalLower() + m_cell->getPhiLocalUpper())/2.);
259 else
260 m_phi_raw = static_cast<float> ((m_cell->getPhiLocalLower() + m_cell->getPhiLocalUpper())/2. - 2.0*M_PI);
261 }
262 else
263 { // Negative EMEC
264 if(m_cell->getPhiLocalLower()<0)
265 m_phi_raw = static_cast<float> (-M_PI - (m_cell->getPhiLocalLower() + m_cell->getPhiLocalUpper())/2.);
266 else
267 m_phi_raw = static_cast<float> (M_PI - (m_cell->getPhiLocalLower() + m_cell->getPhiLocalUpper())/2.);
268 }
269}
270
272{
273 return m_region->getSamplingIndex();
274}
275
276// -- HECDetectorElement --
278 , const IdentifierHash onl1
279 , const IdentifierHash onl2
281 , HECCellConstLink& hecCell
282 , const HECDetectorRegion* hecRegion
283 , bool isTestBeam
284 , const GeoAlignmentStore* geoAlignStore
285 , const CaloElementPositionShift* posShift)
287 , m_cell(hecCell)
288 , m_region(hecRegion)
289{
290 init_description(isTestBeam,geoAlignStore,posShift);
292
293 if(isTestBeam)
294 propagateRaw();
295}
296
298 , const GeoAlignmentStore* geoAlignStore
299 , const CaloElementPositionShift* posShift)
300{
301 // take PHI_RAW from LAr Readout geometry and use it xor calculations of x_loc and y_loc
302 m_phi_raw = static_cast<float> ((m_cell->getPhiLocalLower() + m_cell->getPhiLocalUpper())/2.);
303
304 m_eta_raw = static_cast<float> ((m_cell->getEtaMaxNominal() + m_cell->getEtaMinNominal())/2.);
305 if(m_cell->getEndcapIndex()==0)
306 m_eta_raw *= -1;
307
308 double x_loc, y_loc, z_loc, r_loc;
309 r_loc = (m_cell->getRMaxLocalNominal(HECCell::CENTER) + m_cell->getRMinLocalNominal(HECCell::CENTER))/2.;
310 z_loc = m_cell->getZLocal(HECCell::CENTER);
311
312
313 const Amg::Transform3D &xfDef = m_region->getDefAbsoluteTransform(geoAlignStore);
314
315 // we need to apply the famous ZShift.
316 Amg::Transform3D xfNominal;
317 if(m_cell->getEndcapIndex()==0)
318 xfNominal = Amg::Translation3D(Amg::Vector3D(0.,0.,m_region->getProjectivityDisplacement()*Gaudi::Units::cm))*xfDef; // Negative HEC
319 else
320 xfNominal = Amg::Translation3D(Amg::Vector3D(0.,0.,-m_region->getProjectivityDisplacement()*Gaudi::Units::cm))*xfDef; // Positive HEC
321
322 if(isTestBeam){
323 xfNominal = Amg::Translation3D(Amg::Vector3D(0.,0., 4277.*Gaudi::Units::mm));
324 }
325
326 const Amg::Transform3D &xfAbs = m_region->getAbsoluteTransform(geoAlignStore);
327
328 x_loc = r_loc*std::cos(m_phi_raw);
329 y_loc = r_loc*std::sin(m_phi_raw);
330
331 Amg::Vector3D globalNomCoords = xfNominal*Amg::Vector3D(x_loc,y_loc,z_loc);
332 Amg::Vector3D globalAbsCoords = (posShift!=nullptr ?
333 xfAbs*Amg::Vector3D(x_loc+posShift->dx,y_loc+posShift->dy,z_loc+posShift->dz) :
334 xfAbs*Amg::Vector3D(x_loc,y_loc,z_loc));
335
336 m_x_raw = static_cast<float> (globalNomCoords.x());
337 m_y_raw = static_cast<float> (globalNomCoords.y());
338 m_z_raw = static_cast<float> (globalNomCoords.z());
339
340 m_x = static_cast<float> (globalAbsCoords.x());
341 m_y = static_cast<float> (globalAbsCoords.y());
342 m_z = static_cast<float> (globalAbsCoords.z());
343
344
345 const double r_raw= std::sqrt(globalNomCoords.x()*globalNomCoords.x()+globalNomCoords.y()*globalNomCoords.y());
346 m_r_raw = static_cast<float> (r_raw);
347
348 const double r = std::sqrt(globalAbsCoords.x()*globalAbsCoords.x()+globalAbsCoords.y()*globalAbsCoords.y());
349 m_r=static_cast<float>(r);
350
351
352 if (r>0) {
353 const double big_r = std::sqrt(globalAbsCoords.x()*globalAbsCoords.x()+globalAbsCoords.y()*globalAbsCoords.y()+globalAbsCoords.z()*globalAbsCoords.z());
354 const double inv_r = 1. / r;
355 const double inv_big_r = 1. / big_r;
356 m_eta = static_cast<float> (-std::log((big_r-globalAbsCoords.z()) * inv_r));
357 m_sinTh = static_cast<float> (r * inv_big_r);
358 m_cosTh = static_cast<float> (globalAbsCoords.z() * inv_big_r);
359 m_cosPhi=globalAbsCoords.x() * inv_r;
360 m_sinPhi=globalAbsCoords.y() * inv_r;
361 }
362 else {
363 m_eta = 0.;
364 m_sinTh = 0.;
365 }
366
367 m_phi = static_cast<float> (std::atan2(globalAbsCoords.y(),globalAbsCoords.x()));
368
369 m_deta = static_cast<float> (m_cell->getEtaMaxNominal() - m_cell->getEtaMinNominal());
370 m_dphi = static_cast<float> (std::abs(m_cell->getPhiLocalUpper() - m_cell->getPhiLocalLower()));
371 m_dz = static_cast<float> (std::abs(m_cell->getZLocal(HECCell::FRONT)-m_cell->getZLocal(HECCell::BACK))/2.);
372
373 // -- from CaloDDE --
374 m_dx = 0.;
375 m_dy = 0.;
376 m_dr = 0.;
377 // -- from CaloDDE --
378}
379
381{
382 // Interpretation of PHI coming from LAr Readout Geometry
383 if(m_cell->getEndcapIndex()==1)
384 { // Positive HEC
385 if(m_cell->getPhiLocalUpper()<M_PI)
386 m_phi_raw = static_cast<float> ((m_cell->getPhiLocalLower() + m_cell->getPhiLocalUpper())/2.);
387 else
388 m_phi_raw = static_cast<float> ((m_cell->getPhiLocalLower() + m_cell->getPhiLocalUpper())/2. - 2.0*M_PI);
389 }
390 else
391 { // Negative HEC
392 if(m_cell->getPhiLocalLower()<0)
393 m_phi_raw = static_cast<float> (-M_PI - (m_cell->getPhiLocalLower() + m_cell->getPhiLocalUpper())/2.);
394 else
395 m_phi_raw = static_cast<float> (M_PI - (m_cell->getPhiLocalLower() + m_cell->getPhiLocalUpper())/2.);
396 }
397
398 if(m_phi_raw>M_PI)
399 m_phi_raw = static_cast<float> (m_phi_raw - (2.0*M_PI));
400 else if(m_phi_raw<-M_PI)
401 m_phi_raw = static_cast<float> (m_phi_raw + (2.0*M_PI));
402}
403
405{
406 return m_region->getSamplingIndex();
407}
408
409// -- FCALDetectorElement --
410
412 , const IdentifierHash onl1
413 , const IdentifierHash onl2
415 , const FCALTile* fcalTile
416 , const FCALModule* fcalModule
417 , bool isTestBeam
418 , const GeoAlignmentStore* geoAlignStore
419 , const CaloElementPositionShift* posShift)
421 , m_tile(fcalTile)
422 , m_module(fcalModule)
423{
424 init_description(isTestBeam,geoAlignStore,posShift);
425 if(isTestBeam) propagateRaw();
426}
427
429 , const GeoAlignmentStore* geoAlignStore
430 , const CaloElementPositionShift* posShift)
431{
432 double x_loc = m_tile->getX();
433 double y_loc = m_tile->getY();
434 // double z_loc = -m_module->getFullDepthZ(*m_tile)/2.;
435 double z_loc = 0.;
436
437 const Amg::Transform3D &xfDef = m_module->getDefAbsoluteTransform(geoAlignStore);
438// we need to apply the famous ZShift.
439 Amg::Transform3D xfNominal;
440 if(m_module->getEndcapIndex()==FCALModule::POS)
441 xfNominal = Amg::Translation3D(Amg::Vector3D(0.,0.,-m_module->getProjectivityDisplacement()*Gaudi::Units::cm))*xfDef;
442 else
443 xfNominal = Amg::Translation3D(Amg::Vector3D(0.,0.,m_module->getProjectivityDisplacement()*Gaudi::Units::cm))*xfDef;
444
445 if(isTestBeam){
446 if(m_module->getModuleIndex() == FCALModule::FCAL1)
447 xfNominal = Amg::Translation3D(Amg::Vector3D(0.,0., 4668.5*Gaudi::Units::mm));
448 else if (m_module->getModuleIndex() == FCALModule::FCAL2)
449 xfNominal = Amg::Translation3D(Amg::Vector3D(0.,0., 5128.3*Gaudi::Units::mm));
450 else {
451 std::cout<<"Wrong FCAL module for TB, using FCAL1 !!!"<<std::endl;
452 xfNominal = Amg::Translation3D( Amg::Vector3D(0.,0.,4668.5*Gaudi::Units::mm));
453 }
454 }
455
456 const Amg::Transform3D &xfAbs = m_module->getAbsoluteTransform(geoAlignStore);
457
458 Amg::Vector3D globalDefCoords = xfNominal*Amg::Vector3D(x_loc,y_loc,z_loc);
459 Amg::Vector3D globalAbsCoords = (posShift!=nullptr ?
460 xfAbs*Amg::Vector3D(x_loc+posShift->dx,y_loc+posShift->dy,z_loc+posShift->dz) :
461 xfAbs*Amg::Vector3D(x_loc,y_loc,z_loc));
462
463 m_x_raw = static_cast<float> (globalDefCoords.x());
464 m_y_raw = static_cast<float> (globalDefCoords.y());
465 m_z_raw = static_cast<float> (globalDefCoords.z());
466
467 m_x = static_cast<float> (globalAbsCoords.x());
468 m_y = static_cast<float> (globalAbsCoords.y());
469 m_z = static_cast<float> (globalAbsCoords.z());
470
471 m_dx =static_cast<float> ( m_module->getFullWidthX(*m_tile));
472 m_dy =static_cast<float> ( m_module->getFullWidthY(*m_tile));
473 m_dz =static_cast<float> ( m_module->getFullDepthZ(*m_tile)/2.);
474
475 m_deta = 0.;
476 m_dphi = 0.;
477 m_dr = 0.;
478
479 // From Calo DDE
480 const double r = std::sqrt(globalAbsCoords.x()*globalAbsCoords.x()+globalAbsCoords.y()*globalAbsCoords.y());
481 m_r=static_cast<float>(r);
482
483
484 if (r>0) {
485 const double big_r = std::sqrt(globalAbsCoords.x()*globalAbsCoords.x()+globalAbsCoords.y()*globalAbsCoords.y()+globalAbsCoords.z()*globalAbsCoords.z());
486 const double inv_big_r = 1. / big_r;
487 const double inv_r = 1. / r;
488 m_eta = static_cast<float> (-log((big_r-globalAbsCoords.z()) * inv_r));
489 m_sinTh = static_cast<float> (r * inv_big_r);
490 m_cosTh = static_cast<float> (globalAbsCoords.z() * inv_big_r);
491 m_cosPhi=globalAbsCoords.x() * inv_r;
492 m_sinPhi=globalAbsCoords.y() * inv_r;
493 }
494 else {
495 m_eta = 0.;
496 m_sinTh = 0.;
497 }
498
499 m_phi_raw = static_cast<float> (std::atan2(globalDefCoords.y(),globalDefCoords.x()));
500 m_phi = static_cast<float> (std::atan2(globalAbsCoords.y(),globalAbsCoords.x()));
501
502// -- from CaloDDE --
503 const double r_raw= sqrt(globalDefCoords.x()*globalDefCoords.x()+globalDefCoords.y()*globalDefCoords.y());
504 m_r_raw = static_cast<float> (r_raw);
505
506 if (m_r_raw>0.001)
507 {
508 const double big_r_raw = std::sqrt(globalDefCoords.x()*globalDefCoords.x()+globalDefCoords.y()*globalDefCoords.y()+globalDefCoords.z()*globalDefCoords.z());
509 // bug !!
510 // m_sinTh = m_r/big_r_raw;
511 m_eta_raw = static_cast<float> (-std::log((big_r_raw-globalDefCoords.z())/r_raw));
512 }
513 else
514 {
515 m_eta_raw = 0.;
516 }
517
518 m_phi = static_cast<float> (std::atan2(globalAbsCoords.y(),globalAbsCoords.x()));
519 m_phi_raw= static_cast<float> (std::atan2(globalDefCoords.y(),globalDefCoords.x()));
520 // -- from CaloDDE --
521
522
523 if (m_r>0.) {
524 // estimate deta,dphi of Fcal cells
525 fcal_deta_dphi (*this, m_deta, m_dphi);
526 }
527
528}
529
531{
532 return m_module->getModuleIndex();
533}
534
542
544 double phi,
545 double r)
546{
547 m_eta = static_cast<float> (eta);
548 m_r= static_cast<float> (r);
549
550 m_phi = static_cast<float> (phi);
551 if(phi<-M_PI)
552 m_phi = static_cast<float> (phi + 2.0*M_PI);
553 else if(phi>M_PI)
554 m_phi = static_cast<float> (phi - 2.0*M_PI);
555
556 m_cosPhi=static_cast<float> (std::cos(m_phi));
557 m_sinPhi=static_cast<float> (std::sin(m_phi));
558 m_sinTh=static_cast<float> (1/std::cosh(eta));
559 m_cosTh=static_cast<float> (std::tanh(eta));
560 m_x = static_cast<float> (r*m_cosPhi);
561 m_y = static_cast<float> (r*m_sinPhi);
562 m_z = static_cast<float> (r*std::sinh(eta));
563
564}
565
567 double phi_raw,
568 double r_raw)
569{
570 m_eta_raw = static_cast<float> (eta_raw);
571 m_r_raw = static_cast<float> (r_raw);
572
573 m_phi_raw = static_cast<float> (phi_raw);
574 if(phi_raw<-M_PI)
575 m_phi_raw = static_cast<float> (phi_raw + 2.0*M_PI);
576 else if(phi_raw>M_PI)
577 m_phi_raw = static_cast<float> (phi_raw - 2.0*M_PI);
578
579 m_x_raw = static_cast<float> (r_raw*std::cos(m_phi_raw));
580 m_y_raw = static_cast<float> (r_raw*std::sin(m_phi_raw));
581 m_z_raw = static_cast<float> (r_raw*std::sinh(eta_raw));
582
583}
584
592
594{
595 return m_id;
596}
597
599{
600 // Compute x,y coordinates of scintillator centre
601 m_x = static_cast<float> (m_r*std::cos(m_phi));
602 m_y = static_cast<float> (m_r*std::sin(m_phi));
603}
604
605
611StatusCode
613(const std::vector<const CaloDetDescrElement*>& fromelts)
614{
615 if (fromelts.empty())
616 return updateNull();
617 else if (fromelts.size() == 1)
618 return updateSingle (fromelts[0]);
619 else if (fromelts[0]->getSubCalo() == CaloCell_Base_ID::LARFCAL)
620 return updateFCAL(fromelts);
621 else
622 return updateBE (fromelts);
623}
624
625
629StatusCode
631{
632 m_eta = 0;
633 m_phi = 0;
634 m_sinTh = 0;
635 m_cosTh = 0;
636 m_deta = 0;
637 m_dphi = 0;
638 m_volume = 0;
639 m_sinPhi = 0;
640 m_cosPhi = 0;
641 m_r = 0;
642 m_eta_raw = 0;
643 m_phi_raw = 0;
644 m_r_raw = 0;
645 m_dr = 0;
646 m_x = 0;
647 m_y = 0;
648 m_z = 0;
649 m_x_raw = 0;
650 m_y_raw = 0;
651 m_z_raw = 0;
652 m_dx = 0;
653 m_dy = 0;
654 m_dz = 0;
655
656 return StatusCode::SUCCESS;
657}
658
659
663StatusCode
665{
666 m_eta = fromelt->eta();
667 m_phi = fromelt->phi();
668 m_sinTh = fromelt->sinTh();
669 m_cosTh = fromelt->cosTh();
670 m_deta = fromelt->deta();
671 m_dphi = fromelt->dphi();
672 m_volume = fromelt->volume();
673 m_sinPhi = fromelt->cosPhi();
674 m_cosPhi = fromelt->sinPhi();
675 m_r = fromelt->r();
676 m_eta_raw = fromelt->eta_raw();
677 m_phi_raw = fromelt->phi_raw();
678 m_r_raw = fromelt->r_raw();
679 m_dr = fromelt->dr();
680 m_x = fromelt->x();
681 m_y = fromelt->y();
682 m_z = fromelt->z();
683 m_x_raw = fromelt->x_raw();
684 m_y_raw = fromelt->y_raw();
685 m_z_raw = fromelt->z_raw();
686 m_dx = fromelt->dx();
687 m_dy = fromelt->dy();
688 m_dz = fromelt->dz();
689
690 return StatusCode::SUCCESS;
691}
692
693
701StatusCode
703(const std::vector<const CaloDetDescrElement*>& fromelts)
704{
705 bool is_barrel = (fromelts[0]->dr() > 0);
706
707 double eta_raw_min = 99999;
708 double eta_raw_max = -99999;
709 double phi_raw_min = 99999;
710 double phi_raw_max = -99999;
711 double rz_raw_min = 99999;
712 double rz_raw_max = -99999;
713 double volume = 0;
714
715 double etasum = 0;
716 double detasum = 0;
717 double phisum = 0;
718 double dphisum = 0;
719 double rzsum = 0;
720 double drzsum = 0;
721
722 for (const CaloDetDescrElement* fromelt : fromelts) {
723 double rz, rz_raw, drz;
724 if (is_barrel) {
725 rz = fromelt->r();
726 rz_raw = fromelt->r_raw();
727 drz = fromelt->dr();
728 }
729 else {
730 rz = fromelt->z();
731 rz_raw = fromelt->z_raw();
732 drz = fromelt->dz();
733 }
734
735 eta_raw_min = std::min (eta_raw_min,
736 (double)fromelt->eta_raw() - fromelt->deta()/2);
737 eta_raw_max = std::max (eta_raw_max,
738 (double)fromelt->eta_raw() + fromelt->deta()/2);
739
740 phi_raw_min = std::min (phi_raw_min,
741 (double)fromelt->phi_raw() - fromelt->dphi()/2);
742 phi_raw_max = std::max (phi_raw_max,
743 (double)fromelt->phi_raw() + fromelt->dphi()/2);
744
745 rz_raw_min = std::min (rz_raw_min, rz_raw - drz / 2);
746 rz_raw_max = std::max (rz_raw_min, rz_raw + drz / 2);
747
748 etasum += fromelt->deta() * fromelt->eta();
749 detasum += fromelt->deta();
750
751 phisum += fromelt->dphi() * fromelt->phi();
752 dphisum += fromelt->dphi();
753
754 rzsum += drz * rz;
755 drzsum += drz;
756
757 volume += fromelt->volume();
758 }
759
761
762 double eta_raw = (eta_raw_min + eta_raw_max) / 2;
763 double phi_raw = (phi_raw_min + phi_raw_max) / 2;
764 double rz_raw = (rz_raw_min + rz_raw_max) / 2;
765
766 m_deta = eta_raw_max - eta_raw_min;
768
769 m_dphi = phi_raw_max - phi_raw_min;
771
772 m_dx = 0;
773 m_dy = 0;
774
776
777 double eta = etasum / detasum;
778 double phi = phisum / dphisum;
779
780 m_eta = eta;
781 m_phi = phi;
782
783 m_cosPhi = std::cos(phi);
784 m_sinPhi = std::sin(phi);
785 m_sinTh = 1/std::cosh(eta);
786 m_cosTh = std::tanh(eta);
787
788 double r = 0;
789 double r_raw = 0;
790 if (is_barrel) {
791 r_raw = rz_raw;
792 r = rzsum / drzsum;
793
794 m_dr = rz_raw_max - rz_raw_min;
795 m_dz = 0;
796
797 m_z_raw = rz_raw * std::sinh(eta_raw);
798 m_z = r * sinh(eta);
799 }
800 else {
801 r_raw = rz_raw / std::sinh(eta_raw);
802 double z = rzsum / drzsum;
803 r = z / std::sinh(eta);
804
805 m_dz = rz_raw_max - rz_raw_min;
806 m_dr = 0;
807
808 m_z_raw = rz_raw;
809 m_z = z;
810 }
811
812 m_x_raw = r_raw * std::cos(phi_raw);
813 m_y_raw = r_raw * std::sin(phi_raw);
814 m_r_raw = r_raw;
815
816 m_x = r * std::cos(phi);
817 m_y = r * std::sin(phi);
818 m_r = r;
819
820 return StatusCode::SUCCESS;
821}
822
823
831StatusCode
833(const std::vector<const CaloDetDescrElement*>& fromelts)
834{
835 double x_raw_min = 99999;
836 double x_raw_max = -99999;
837 double y_raw_min = 99999;
838 double y_raw_max = -99999;
839 double z_raw_min = 99999;
840 double z_raw_max = -99999;
841 double volume = 0;
842
843#if 0
844 double xsum = 0;
845 double dxsum = 0;
846 double ysum = 0;
847 double dysum = 0;
848 double zsum = 0;
849 double dzsum = 0;
850#endif
851
852 // Set the supercell center to be the geometric center of the
853 // offline cells. Warning: the fcal supercells are asymmetric;
854 // this isn't the same as the COG!
855
856 for (const CaloDetDescrElement* fromelt : fromelts) {
857 x_raw_min = std::min (x_raw_min,
858 (double)fromelt->x_raw() - fromelt->dx()/2);
859 x_raw_max = std::max (x_raw_max,
860 (double)fromelt->x_raw() + fromelt->dx()/2);
861
862 y_raw_min = std::min (y_raw_min,
863 (double)fromelt->y_raw() - fromelt->dy()/2);
864 y_raw_max = std::max (y_raw_max,
865 (double)fromelt->y_raw() + fromelt->dy()/2);
866
867 z_raw_min = std::min (z_raw_min,
868 (double)fromelt->z_raw() - fromelt->dz()/2);
869 z_raw_max = std::max (z_raw_max,
870 (double)fromelt->z_raw() + fromelt->dz()/2);
871
872#if 0
873 xsum += fromelt->dx() * fromelt->x();
874 dxsum += fromelt->dx();
875
876 ysum += fromelt->dy() * fromelt->y();
877 dysum += fromelt->dy();
878
879 zsum += fromelt->dz() * fromelt->z();
880 dzsum += fromelt->dz();
881#endif
882
883 volume += fromelt->volume();
884 }
885
887
888 double x_raw = (x_raw_min + x_raw_max) / 2;
889 double y_raw = (y_raw_min + y_raw_max) / 2;
890 double z_raw = (z_raw_min + z_raw_max) / 2;
891
892 m_x_raw = x_raw;
893 m_y_raw = y_raw;
894 m_z_raw = z_raw;
895
896 m_deta = 0;
897 m_dphi = 0;
898 m_dr = 0;
899
900 m_dx = x_raw_max - x_raw_min;
901 m_dy = y_raw_max - y_raw_min;
902 m_dz = z_raw_max - z_raw_min;
903
904#if 0
905 double x = xsum / dxsum;
906 double y = ysum / dysum;
907 double z = zsum / dzsum;
908#endif
909 double x = m_x_raw + fromelts[0]->x() - fromelts[0]->x_raw();
910 double y = m_y_raw + fromelts[0]->y() - fromelts[0]->y_raw();
911 double z = m_z_raw + fromelts[0]->z() - fromelts[0]->z_raw();
912
913 m_x = x;
914 m_y = y;
915 m_z = z;
916
917 m_phi_raw = std::atan2 (y_raw, x_raw);
918 m_phi = std::atan2 (y, x);
919
920 const double r_raw = hypot (x_raw, y_raw);
921 const double r = hypot (x, y);
922 const double inv_r = 1. / r;
923
924 m_r_raw = r_raw;
925 m_r = r;
926
927 const double big_r = std::sqrt (x*x + y*y + z*z);
928 const double big_r_raw = std::sqrt (x_raw*x_raw + y_raw*y_raw + z_raw*z_raw);
929 const double inv_big_r = 1. / big_r;
930
931 m_eta = -std::log ((big_r - z) * inv_r);
932 m_eta_raw = -std::log ((big_r_raw - z_raw) / r_raw);
933 m_sinTh = r * inv_big_r;
934 m_cosTh = z * inv_big_r;
935 m_cosPhi = x * inv_r;
936 m_sinPhi = y * inv_r;
937
938 if (m_r>0.) {
939 // estimate deta,dphi of Fcal cells
940 fcal_deta_dphi (*this, m_deta, m_dphi);
941 }
942
943 return StatusCode::SUCCESS;
944}
945
946
954
956 double phi,
957 double r)
958{
959 m_eta = static_cast<float> (eta);
960 m_r= static_cast<float> (r);
961
962 m_phi = static_cast<float> (phi);
963 if(phi<-M_PI)
964 m_phi = static_cast<float> (phi + 2.0*M_PI);
965 else if(phi>M_PI)
966 m_phi = static_cast<float> (phi - 2.0*M_PI);
967
968 // m_x = r*cos(m_phi);
969 // m_y = r*sin(m_phi);
970 //m_z = r*sinh(eta);
971
972 m_cosPhi=static_cast<float> (std::cos(m_phi));
973 m_sinPhi=static_cast<float> (std::sin(m_phi));
974 m_sinTh=static_cast<float> (1/std::cosh(eta));
975 m_cosTh=static_cast<float> (std::tanh(eta));
976 m_x = static_cast<float> (r*m_cosPhi);
977 m_y = static_cast<float> (r*m_sinPhi);
978 m_z = static_cast<float> (r*std::sinh(eta));
979
980
981 // double big_r = sqrt(m_x*m_x+m_y*m_y+m_z*m_z);
982 //if(big_r > 0.001)
983 // m_sinTh = m_r/big_r;
984 // else
985 // m_sinTh = 0;
986}
987
989 double phi_raw,
990 double r_raw)
991{
992 m_eta_raw = static_cast<float> (eta_raw);
993 m_r_raw = static_cast<float> (r_raw);
994
995 m_phi_raw = static_cast<float> (phi_raw);
996 if(phi_raw<-M_PI)
997 m_phi_raw = static_cast<float> (phi_raw + 2.0*M_PI);
998 else if(phi_raw>M_PI)
999 m_phi_raw = static_cast<float> (phi_raw - 2.0*M_PI);
1000
1001 m_x_raw = static_cast<float> (r_raw*std::cos(m_phi_raw));
1002 m_y_raw = static_cast<float> (r_raw*std::sin(m_phi_raw));
1003 m_z_raw = static_cast<float> (r_raw*std::sinh(eta_raw));
1004
1005 // double big_r = sqrt(m_x_raw*m_x_raw+m_y_raw*m_y_raw+m_z_raw*m_z_raw);
1006 // if(big_r > 0.001)
1007 // m_sinTh = m_r_raw/big_r;
1008 // else
1009 // m_sinTh = 0;
1010}
1011
1013 double dphi,
1014 double dr)
1015{
1016 m_deta = static_cast<float> (deta);
1017 m_dphi = static_cast<float> (dphi);
1018 m_dr= static_cast<float> (dr);
1019}
#define M_PI
Scalar phi() const
phi method
Calo Subsystem specific Detector Elements + Dummy element for testing.
CaloPhiRange class declaration.
static Double_t rz
This class groups all DetDescr information related to a CaloCell.
float cosPhi() const
for fast px py pz computation
void propagateRaw()
In test beam configurations force XXX=XXX_RAW.
float sinTh() const
for algorithm working in transverse Energy
CaloDetDescrElement(const IdentifierHash subcaloHash, const IdentifierHash onl1, const IdentifierHash onl2, const CaloDetDescriptor *descriptor)
Constructor.
float sinPhi() const
for fast px py pz computation
IdentifierHash onl2() const
cell online identifier 2
float m_sinPhi
cache to allow fast px py pz computation
float m_sinTh
this one is cached for algorithm working in transverse Energy
float m_cosPhi
cache to allow fast px py pz computation
float m_cosTh
this one is cached for algorithm working in transverse Energy
const CaloDetDescriptor * descriptor() const
cell descriptor
IdentifierHash onl1() const
cell online identifier 1
This is a base class for LAr and Tile Descriptors The primary goal is to speed up loops over all the ...
StatusCode updateSingle(const CaloDetDescrElement *fromelt)
Copy this element's geometry from the given offline element.
StatusCode updateBE(const std::vector< const CaloDetDescrElement * > &fromelts)
Update this element's geometry from a list of elements.
StatusCode updateFCAL(const std::vector< const CaloDetDescrElement * > &fromelts)
Update this element's geometry from a list of elements.
StatusCode updateNull()
Set this element's geometry to default values.
StatusCode update(const std::vector< const CaloDetDescrElement * > &fromelts)
Update this element's geometry from the given list of offline elements.
DummyDetDescrElement(const IdentifierHash subcaloHash, const IdentifierHash onl1, const IdentifierHash onl2, const CaloDetDescriptor *descriptor)
Constructor, takes all necessary parameters for the base class constructor.
void set_cylindric_raw(double eta_raw, double phi_raw, double r_raw)
set raw cylindric coordinates
void set_cylindric(double eta, double phi, double r)
set cylindric coordinates
void set_cylindric_size(double deta, double dphi, double dr)
set cylindric size deta/dphi/dr
@ BACK
Definition EMBCell.h:33
@ CENTER
Definition EMBCell.h:33
@ FRONT
Definition EMBCell.h:33
virtual int getLayer() const override
get layer
EMBDetectorElement()=delete
default constructor hidden
EMBCellConstLink m_cell
EMB Cell description from LArReadoutGeometry.
const EMBDetectorRegion * m_region
EMB Region description from LArReadoutGeometry.
void init_description(const GeoAlignmentStore *geoAlignStore, const CaloElementPositionShift *posShift)
initialize base description
void init_interpretation()
Fill all missing fields of CaloDetDescrElement which have not been filled by init_description()
const EMECDetectorRegion * m_region
EMEC Region description from LArReadoutGeometry.
virtual int getLayer() const override
get layer
EMECCellConstLink m_cell
EMEC Cell description from LArReadoutGeometry.
void init_description(bool isTestBeam, const GeoAlignmentStore *geoAlignStore, const CaloElementPositionShift *posShift)
initialize base description
EMECDetectorElement()=delete
default constructor hidden
virtual int getLayer() const override
get layer
const FCALTile * m_tile
FCAL Tile description from LArReadoutGeometry.
FCALDetectorElement()=delete
default constructor hidden
void init_description(bool isTestBeam, const GeoAlignmentStore *geoAlignStore, const CaloElementPositionShift *posShift)
initialize base description
const FCALModule * m_module
FCAL Module description from LArReadoutGeometry.
A tile of the forward calorimeter readout geometry.
Definition FCALTile.h:27
Ensure that the extensions for the Vector3D are properly loaded.
@ BACK
Definition HECCell.h:34
@ FRONT
Definition HECCell.h:34
@ CENTER
Definition HECCell.h:34
HECCellConstLink m_cell
HEC Cell description from LArReadoutGeometry.
void init_description(bool isTestBeam, const GeoAlignmentStore *geoAlignStore, const CaloElementPositionShift *posShift)
initialize base description
void init_interpretation()
Fill all missing fields of CaloDetDescrElement which have not been filled by init_description()
const HECDetectorRegion * m_region
HEC Region description from LArReadoutGeometry.
virtual int getLayer() const override
get layer
HECDetectorElement()=delete
default constructor hidden
Description of a region of homogenous granularity in the hadronic endcap calorimeter.
This is a "hash" representation of an Identifier.
MbtsDetectorElement()
Constructor, initializes base class constructor parameters with default values.
virtual Identifier customID() const
void set_cylindric(double eta, double phi, double r)
set cylindric coordinates
TileDetectorElement(const IdentifierHash subcaloHash, const IdentifierHash onl1, const IdentifierHash onl2, const CaloDetDescriptor *descriptor)
Constructor, takes all necessary parameters for the base class constructor.
void set_cylindric_raw(double eta_raw, double phi_raw, double r_raw)
set raw cylindric coordinates
int r
Definition globals.cxx:22
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
Eigen::Translation< double, 3 > Translation3D
df
Printing table to screen.
dx,dy,dz displacement of the calorimeter cell caused by sagging