2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
5 //----------------------------------------------------------//
7 // Adaptor for CaloCalibHits. //
9 // Joe Boudreau Apr 14, 2005 //
10 // Mikhail Leltchouk Apr 30, 2005 //
13 //----------------------------------------------------------//
15 #include "CaloIdentifier/CaloIdManager.h"
16 #include "CaloDetDescr/CaloDetDescrElement.h"
17 #include "CaloSimEvent/CaloCalibrationHit.h"
18 #include "CaloIdentifier/CaloDM_ID.h"
19 #include "CaloDetDescr/CaloDetDescrManager.h"
21 #include "CLHEP/Units/SystemOfUnits.h"
25 inline GeoCaloCalibHit::GeoCaloCalibHit(const CaloCalibrationHit & hit
26 , const std::string & collectionName
27 , const CaloDetDescrManager* caloMgr)
29 , m_ddManager(caloMgr)
34 inline GeoCaloCalibHit::operator bool () const {
38 inline double GeoCaloCalibHit::energyEM() const
40 return m_hit->energyEM();
43 inline double GeoCaloCalibHit::energyNonEM() const
45 return m_hit->energyNonEM();
48 inline double GeoCaloCalibHit::energyInvisible() const
50 return m_hit->energyInvisible();
53 inline double GeoCaloCalibHit::energyEscaped() const
55 return m_hit->energyEscaped();
59 inline double GeoCaloCalibHit::energyTotal() const
61 return m_hit->energyTotal();
65 inline double GeoCaloCalibHit::phiMin() const {
66 if (m_ddElement) { // Active and Inactive hits
67 double phi = m_ddElement->phi();
68 double dphi = m_ddElement->dphi();
71 const CaloDM_ID* dmid = m_ddManager->getCalo_Mgr()->getDM_ID();
72 int phiIndex=dmid->phi(m_hit->cellID()); // Dead material hits
74 if(abs(m_subdet) == 4 && m_type==2 && (m_region == 2 || m_region == 3) ) {
76 return (phiIndex-0.5)*M_PI/n_phi;
78 return phiIndex*M_PI/n_phi;
81 inline double GeoCaloCalibHit::phiMax() const {
82 if (m_ddElement) { // Active and Inactive hits
83 double phi = m_ddElement->phi();
84 double dphi = m_ddElement->dphi();
87 const CaloDM_ID* dmid = m_ddManager->getCalo_Mgr()->getDM_ID();
88 int phiIndex=dmid->phi(m_hit->cellID()); // Dead material hits
90 if(abs(m_subdet) == 4 && m_type==2 && (m_region == 2 || m_region == 3) ) {
92 return (phiIndex+0.5)*M_PI/n_phi;
94 return (phiIndex+1.)*M_PI/n_phi;
97 inline double GeoCaloCalibHit::phi() const {
98 if (m_ddElement) { // Active and Inactive hits
99 double phi = m_ddElement->phi();
102 const CaloDM_ID* dmid = m_ddManager->getCalo_Mgr()->getDM_ID();
103 int phiIndex=dmid->phi(m_hit->cellID()); // Dead material hits
105 if(abs(m_subdet) == 4 && m_type==2 && (m_region == 2 || m_region == 3) ) {
107 return (phiIndex)*M_PI/n_phi; // phiBin=0 means between hec module 0 and hec module 1, i.e. 11.25deg
109 return (phiIndex+0.5)*M_PI/n_phi;
113 inline double GeoCaloCalibHit::etaMin() const {
114 if (m_ddElement) { // Active and Inactive hits
115 double eta = m_ddElement->eta();
116 double deta = m_ddElement->deta();
119 double halfEta = 0.05; // Dead material hits
120 if ((m_type==1 && m_sampling==3 && m_region==1) ||
121 (m_type==2 && m_region==3)) {
124 return eta()-halfEta;
127 inline double GeoCaloCalibHit::etaMax() const {
128 if (m_ddElement) { // Active and Inactive hits
129 double eta = m_ddElement->eta();
130 double deta = m_ddElement->deta();
133 double halfEta = 0.05; // Dead material hits
134 if ((m_type==1 && m_sampling==3 && m_region==1) ||
135 (m_type==2 && m_region==3)) {
138 return eta()+halfEta;
141 inline double GeoCaloCalibHit::eta() const {
142 if (m_ddElement) { // Active and Inactive hits
143 double eta = m_ddElement->eta();
146 const CaloDM_ID* dmid = m_ddManager->getCalo_Mgr()->getDM_ID();
147 int etaIndex=dmid->eta(m_hit->cellID()); // Dead material hits
149 if ((m_type==1 && m_sampling==3 && m_region==1) ||
150 (m_type==2 && m_region==3)) {
153 double etaCenter = m_etaOffset + (etaIndex+0.5)*dEta;
155 bool isNegative = dmid->pos_neg_z(m_hit->cellID())<0;
157 etaCenter = -etaCenter;
162 inline std::string GeoCaloCalibHit::hitType() const {
163 if (m_hitType==ACTIVE) return "LArCalibrationHitActive";
164 if (m_hitType==INACTIVE) return "LArCalibrationHitInactive";
165 if (m_hitType==DEAD) return "LArCalibrationHitDeadMaterial";
166 if (m_hitType==TILEAI) return "TileCalibrationCellHitCnt"; // Old format
167 if (m_hitType==TILEDM) return "TileCalibrationDMHitCnt";// Old format
168 if (m_hitType==TILEACTIVE) return "TileCalibHitActiveCell"; // New format
169 if (m_hitType==TILEINACTIVE) return "TileCalibHitInactiveCell";// New format
170 if (m_hitType==TILEDEAD) return "TileCalibHitDeadMaterial";// New format
171 if (m_hitType==UNRECOGNIZED) return "UNRECOGNIZED hit collection";
172 return "UNRECOGNIZED hit collection";
175 inline void GeoCaloCalibHit::init(const std::string & collectionName) {
177 if (collectionName=="LArCalibrationHitActive") {
180 else if (collectionName=="LArCalibrationHitInactive") {
183 else if (collectionName=="LArCalibrationHitDeadMaterial") {
186 else if (collectionName=="TileCalibrationCellHitCnt") {
189 else if (collectionName=="TileCalibrationDMHitCnt") {
192 else if (collectionName=="TileCalibHitDeadMaterial") {
195 else if (collectionName=="TileCalibHitActiveCell") {
196 m_hitType=TILEACTIVE;
198 else if (collectionName=="TileCalibHitInactiveCell") {
199 m_hitType=TILEINACTIVE;
202 m_hitType=UNRECOGNIZED;
207 m_ddElement = getDetDescrElement();
209 //bool inactive = collectionName=="LArCalibrationHitInactive";
211 // Default values of m_etaOffset, m_distance, m_isBarrel(hit orientation)
213 m_distance=230*CLHEP::mm;
216 // if (abs(m_subdet)>= 4) { // Dead hits: LAr: m_subdet= +-4, Tile: m_subdet= +-5)
217 if (m_hitType==DEAD || m_hitType==TILEDM || m_hitType==TILEDEAD) { // Dead hits: LAr: m_subdet= +-4, Tile: m_subdet= +-5)
218 // from Calorimeter/ CaloIdentifier/ CaloIdentifier/ CaloDM_ID.h
220 const CaloDM_ID* dmid = m_ddManager->getCalo_Mgr()->getDM_ID();
221 m_subdet = dmid->pos_neg_z(m_hit->cellID());
222 m_type = dmid->dmat(m_hit->cellID());
223 m_sampling = dmid->sampling(m_hit->cellID());
224 m_region = dmid->region(m_hit->cellID());
225 m_etaBin = dmid->eta(m_hit->cellID());
226 m_phiBin = dmid->phi(m_hit->cellID());
228 } else { // Active and Inactive hit ID from Calorimeter/ CaloIdentifier/ CaloIdentifier/ CaloCell_ID.h
230 const CaloCell_ID* cellid = m_ddManager->getCaloCell_ID();
231 m_subdet = 1 + cellid->sub_calo(m_hit->cellID());
232 m_type = cellid->pos_neg(m_hit->cellID());
233 m_sampling = cellid->calo_sample(m_hit->cellID());
234 m_region = cellid->region(m_hit->cellID());
235 m_etaBin = cellid->eta(m_hit->cellID());
236 m_phiBin = cellid->phi(m_hit->cellID());
240 // Values of m_etaOffset, m_distance, m_isBarrel(hit orientation) which are different from default
241 // To help navigate through statements we will use in comments below
242 // labeling key=abs(subdet)*1000+type*100+sampling*10+region;
244 // for LAr Dead hits:
245 if (abs(m_subdet) == 4) { // subdet = 4 LAr.
248 switch (m_sampling) {
249 case 0: // sampling = 0 Inner Detector
252 m_distance= 250*CLHEP::mm;
255 m_distance= 270*CLHEP::mm; // largest radius for this zone
258 m_distance= 405*CLHEP::mm;
261 m_distance= 595*CLHEP::mm;
264 m_distance= 815*CLHEP::mm;
267 m_distance=1065*CLHEP::mm;
271 std::cout <<"Warning 0, GeoCaloCalibHit with (subdet,type,sampling,region,eta,phi) = "
272 <<m_subdet<<", "<<m_type<<", "<<m_sampling<<", "<<m_region
273 <<m_etaBin<<", "<<m_phiBin
274 << " not decoded" <<std::endl;
280 case 1: // sampling = 1 - in front of and in active LAr calorimeters
283 m_distance=1250*CLHEP::mm;
286 m_distance=1375*CLHEP::mm;
289 m_distance=1410*CLHEP::mm;
292 m_distance=1490*CLHEP::mm;
296 m_distance=3490*CLHEP::mm;
301 m_distance=3511*CLHEP::mm;
306 m_distance=3640*CLHEP::mm;
311 m_distance=3700*CLHEP::mm;
316 std::cout <<"Warning 1, GeoCaloCalibHit with (subdet,type,sampling,region,eta,phi) = "
317 <<m_subdet<<", "<<m_type<<", "<<m_sampling<<", "<<m_region
318 <<m_etaBin<<", "<<m_phiBin
319 << " not decoded" <<std::endl;
325 case 2: // sampling = 2 - dead materials between active calorimeters
328 m_distance=2170*CLHEP::mm;
331 m_distance=2990*CLHEP::mm; // radius of lower part - feedthrough
335 m_distance=3300*CLHEP::mm; // z
336 m_isBarrel=false; // partly around EMB but in front of Extended Barrel of Tile
340 m_distance=4250*CLHEP::mm;
345 m_distance=5110*CLHEP::mm;
350 m_distance=2100*CLHEP::mm; // R
354 std::cout <<"Warning 2, GeoCaloCalibHit with (subdet,type,sampling,region,eta,phi) = "
355 <<m_subdet<<", "<<m_type<<", "<<m_sampling<<", "<<m_region
356 <<m_etaBin<<", "<<m_phiBin
357 << " not decoded" <<std::endl;
363 case 3: // sampling = 3
364 // Eta granularity in region 1 sampling 3 is twice that of previous cases.
368 m_distance=6200*CLHEP::mm;
373 m_distance=6300*CLHEP::mm;
378 m_distance=3500*CLHEP::mm; //or can be attached to end of InDet cavity
383 std::cout <<"Warning 4, GeoCaloCalibHit with (subdet,type,sampling,region,eta,phi) = "
384 <<m_subdet<<", "<<m_type<<", "<<m_sampling<<", "<<m_region
385 <<m_etaBin<<", "<<m_phiBin
386 << " not decoded" <<std::endl;
393 std::cout <<"Warning 5, GeoCaloCalibHit with (subdet,type,sampling,region,eta,phi) = "
394 <<m_subdet<<", "<<m_type<<", "<<m_sampling<<", "<<m_region
395 <<m_etaBin<<", "<<m_phiBin
396 << " not decoded" <<std::endl;
403 case 0: // region = 0 crack between EMB halfs
404 switch (m_sampling) {
406 // distances should be checked with experts
407 m_distance= 1550*CLHEP::mm;
410 m_distance= 1600*CLHEP::mm;
413 m_distance= 1750*CLHEP::mm;
416 m_distance= 1900*CLHEP::mm;
420 std::cout <<"Warning 6, GeoCaloCalibHit with (subdet,type,sampling,region,eta,phi) = "
421 <<m_subdet<<", "<<m_type<<", "<<m_sampling<<", "<<m_region
422 <<m_etaBin<<", "<<m_phiBin
423 << " not decoded" <<std::endl;
428 case 1: // region = 1 dead materials between inner and outer EMEC wheels
431 switch (m_sampling) {
433 // distances should be checked with experts
434 m_distance=3700*CLHEP::mm;
437 m_distance=3800*CLHEP::mm;
440 m_distance=3950*CLHEP::mm;
443 m_distance=4150*CLHEP::mm;
447 std::cout <<"Warning 7, GeoCaloCalibHit with (subdet,type,sampling,region,eta,phi) = "
448 <<m_subdet<<", "<<m_type<<", "<<m_sampling<<", "<<m_region
449 <<m_etaBin<<", "<<m_phiBin
450 << " not decoded" <<std::endl;
455 case 2: // region = 2 - azimuthal cracks between HEC modules (wedges) - outer
458 switch (m_sampling) {
460 // distances should be checked with experts
461 m_distance=4417*CLHEP::mm;
464 m_distance=4825*CLHEP::mm;
467 m_distance=5393*CLHEP::mm;
470 m_distance=5861*CLHEP::mm;
474 std::cout <<"Warning 8, GeoCaloCalibHit with (subdet,type,sampling,region,eta,phi) = "
475 <<m_subdet<<", "<<m_type<<", "<<m_sampling<<", "<<m_region
476 <<m_etaBin<<", "<<m_phiBin
477 << " not decoded" <<std::endl;
482 case 3: // region = 3 - azimuthal cracks between HEC modules (wedges) - inner
485 switch (m_sampling) {
487 // distances should be checked with experts
488 m_distance=4417*CLHEP::mm;
491 m_distance=4825*CLHEP::mm;
494 m_distance=5393*CLHEP::mm;
497 m_distance=5861*CLHEP::mm;
501 std::cout <<"Warning 9, GeoCaloCalibHit with (subdet,type,sampling,region,eta,phi) = "
502 <<m_subdet<<", "<<m_type<<", "<<m_sampling<<", "<<m_region
503 <<m_etaBin<<", "<<m_phiBin
504 << " not decoded" <<std::endl;
509 case 4: // region = 4 - dead materials between HEC and FCal
512 switch (m_sampling) {
514 // distances should be checked with experts
515 m_distance=4600*CLHEP::mm;
518 m_distance=4920*CLHEP::mm;
521 m_distance=5400*CLHEP::mm;
524 m_distance=5820*CLHEP::mm;
528 std::cout <<"Warning 10, GeoCaloCalibHit with (subdet,type,sampling,region,eta,phi) = "
529 <<m_subdet<<", "<<m_type<<", "<<m_sampling<<", "<<m_region
530 <<m_etaBin<<", "<<m_phiBin
531 << " not decoded" <<std::endl;
536 case 5: // region = 4 - dead materials between HEC and FCal
539 switch (m_sampling) {
541 // distances should be checked with experts
542 m_distance=4340*CLHEP::mm;
545 m_distance=4668*CLHEP::mm;
548 m_distance=5138*CLHEP::mm;
551 m_distance=5602*CLHEP::mm;
555 std::cout <<"Warning 11, GeoCaloCalibHit with (subdet,type,sampling,region,eta,phi) = "
556 <<m_subdet<<", "<<m_type<<", "<<m_sampling<<", "<<m_region
557 <<m_etaBin<<", "<<m_phiBin
558 << " not decoded" <<std::endl;
567 // --------------------------- Tile Dead hits --------------------------------------
568 // Values of m_etaOffset, m_distance, m_isBarrel(hit orientation) which are different from default
569 else if (abs(m_subdet) == 5) { //for Tile Dead hits
573 switch (m_sampling) {
574 case 0: // sampling = 0, front plate of the module (1 CLHEP::cm Fe along R)
576 case 0: // 5100, region = 0 - barrel 0.0 < eta < 1.0
577 m_distance= 2295*CLHEP::mm;
579 case 1: // 5101, region = 1 - ext.barrel 1.1 < eta < 1.6
580 m_distance= 2295*CLHEP::mm;
585 std::cout <<"Warning 12, GeoCaloCalibHit with (subdet,type,sampling,region,eta,phi) = "
586 <<m_subdet<<", "<<m_type<<", "<<m_sampling<<", "<<m_region
587 <<m_etaBin<<", "<<m_phiBin
588 << " not decoded" <<std::endl;
594 case 1: // sampling = 1, end plates of the module ( Fe at fixed Z )
597 case 0: // 5110 - region = 0 - end of barrel 0.7 < eta < 1.1
598 m_distance= 2810*CLHEP::mm; // z, thickness = 20 mm
601 case 1: // 5111 - region = 1 - smaller Z end of ext barrel 0.9 < eta < 1.2
602 m_distance= 3527*CLHEP::mm; // z, thickness = 15 mm
605 case 2: // 5112 - region = 2 - higher Z end of ext barrel 1.3 < eta < 1.7
606 m_distance= 6100*CLHEP::mm; // z, thickness = 20 mm
611 std::cout <<"Warning 13, GeoCaloCalibHit with (subdet,type,sampling,region,eta,phi) = "
612 <<m_subdet<<", "<<m_type<<", "<<m_sampling<<", "<<m_region
613 <<m_etaBin<<", "<<m_phiBin
614 << " not decoded" <<std::endl;
620 case 2: // sampling = 2, so-called "girder" - iron at higher R
621 m_distance= 3900*CLHEP::mm; // R, should be checked with experts
623 case 0: // 5120 - region = 0 - barrel 0. < eta < 0.7
626 case 1: // 5121 - region = 1 - ext barrel 0.9 < eta < 1.3
629 case 2: // 5122 - region = 2 - gap between barrel and ext barrel 0.7 < eta < 0.9
634 std::cout <<"Warning 14, GeoCaloCalibHit with (subdet,type,sampling,region,eta,phi) = "
635 <<m_subdet<<", "<<m_type<<", "<<m_sampling<<", "<<m_region
636 <<m_etaBin<<", "<<m_phiBin
637 << " not decoded" <<std::endl;
643 case 3: // 5130 - sampling = 3, leakage outside Tile calorimeters, 0.0 < eta < 1.7; usually is in LAr DM hit container
644 m_distance = 3980*CLHEP::mm;
650 case 2: // type == 2, 5200
651 if (m_region !=0 || m_sampling !=0) {
656 m_distance = 4000*CLHEP::mm;
661 std::cout <<"Warning 15, GeoCaloCalibHit with (subdet,type,sampling,region,eta,phi) = "
662 <<m_subdet<<", "<<m_type<<", "<<m_sampling<<", "<<m_region
663 <<m_etaBin<<", "<<m_phiBin
664 << " not decoded" <<std::endl;
668 } // over types for Tile DM hits
670 std::cout <<"Warning 16, GeoCaloCalibHit with (subdet,type,sampling,region,eta,phi) = "
671 <<m_subdet<<", "<<m_type<<", "<<m_sampling<<", "<<m_region
672 <<m_etaBin<<", "<<m_phiBin
673 << " not decoded" <<std::endl;
678 // ------------------------ Active and Inactive hits --------------------------------
679 // Values of m_etaOffset, m_distance are calculated in eta(), distance()
680 // Value of m_isBarrel(hit orientation) which is different from default is defined here
681 else if (m_subdet == 1) { // LAr EM hits
682 if (abs(m_type)>1){ // EMEC
685 if (abs(m_type) == 2){ // EMEC Outer Wheel
686 m_sampling = m_sampling - 4; // adjustment to ATL-SOFT-2001-004 definition
688 if (abs(m_type) == 3){ // EMEC Outer Wheel
689 m_sampling = m_sampling - 6; // adjustment to ATL-SOFT-2001-004 definition
692 else if (m_subdet == 2) { // LAr HEC hits
694 m_sampling = m_sampling - 8; // adjustment to ATL-SOFT-2001-004 definition
696 else if (m_subdet == 3) { // LAr FCal hits
704 inline double GeoCaloCalibHit::distance() const {
706 if (m_ddElement) { // Active and Inactive hits
707 return m_isBarrel ? m_ddElement->r() : fabs(m_ddElement->z());
709 return m_distance; // Dead hits
712 inline bool GeoCaloCalibHit::isBarrel() const {
716 inline bool GeoCaloCalibHit::isEndcap() const {
720 inline int GeoCaloCalibHit::subdet() const {
724 inline int GeoCaloCalibHit::type() const {
728 inline int GeoCaloCalibHit::sampling() const {
732 inline int GeoCaloCalibHit::region() const {
736 inline const CaloDetDescrElement* GeoCaloCalibHit::getDetDescrElement() const
738 return (m_hitType!=DEAD && m_hitType!=TILEDM && m_hitType!=TILEDEAD)
739 ? m_ddManager->get_element(m_hit->cellID())