ATLAS Offline Software
SiHitIdHelper.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include <mutex>
6 
10 #include "GaudiKernel/ServiceHandle.h"
11 
12 
13 //
14 // private constructor
16  Initialize();
17 }
18 
20  static const SiHitIdHelper helper;
21  return &helper;
22 }
23 
25 
26  const PixelID* pix = nullptr;
27  ServiceHandle<StoreGateSvc> detStore ("DetectorStore", "SiHitIdHelper");
28  if (detStore.retrieve().isSuccess()) {
29  if (detStore->retrieve(pix, "PixelID").isFailure()) { pix = nullptr; }
30  }
31 
32  bool isDBM = (pix != nullptr && pix->dictionaryVersion() == "IBL-DBM");
33  // check for ITk and HGTD
34  bool isITkHGTD = (pix !=nullptr && pix->dictionaryVersion() == "ITkHGTD");
35  // we might include PLR as well, then we have to increase endcap range to +/- 4
36  bool isITkHGTDPLR = (pix !=nullptr && pix->dictionaryVersion() == "ITkHGTDPLR");
37  // new identification scheme for HGTD (endcap-layer-moduleinlayer)
38  bool isITk_HGTD_NewID_PLR = (pix !=nullptr && pix->dictionaryVersion() == "P2-RUN4");
39  // cache the HL-LHC decision
40  m_isITkHGTD = isITkHGTD || isITkHGTDPLR || isITk_HGTD_NewID_PLR;
41 
42  if (isITkHGTD) InitializeField("Part",0,2);
43  else if (isITkHGTDPLR || isITk_HGTD_NewID_PLR) InitializeField("Part",0,3);
44  else InitializeField("Part",0,1);
45  if (isDBM || isITkHGTDPLR || isITk_HGTD_NewID_PLR) InitializeField("BarrelEndcap",-4,4);
46  else InitializeField("BarrelEndcap",-2,2);
47  InitializeField("LayerDisk",0,20);
48  if (m_isITkHGTD) InitializeField("EtaModule",-100,100);
49  else InitializeField("EtaModule",-20,20);
50  if (isITk_HGTD_NewID_PLR) InitializeField("PhiModule",0,1022);
51  else InitializeField("PhiModule",0,200);
52  InitializeField("Side",0,3);
53 
54 }
55 
56 // Info retrieval:
57 // Pixel, SCT, HGTD, or PLR
58 bool SiHitIdHelper::isPixel(const int& hid) const
59 {
60  int psh = this->GetFieldValue("Part", hid);
61  return psh ==0;
62 }
63 
64 bool SiHitIdHelper::isSCT(const int& hid) const
65 {
66  int psh = this->GetFieldValue("Part", hid);
67  return psh ==1;
68 }
69 
70 bool SiHitIdHelper::isHGTD(const int& hid) const
71 {
72  int psh = this->GetFieldValue("Part", hid);
73  return psh ==2;
74 }
75 
76 bool SiHitIdHelper::isPLR(const int& hid) const
77 {
78  if (!m_isITkHGTD) return false;
79 
80  int psh = this->GetFieldValue("BarrelEndcap", hid);
81  return std::abs(psh) == 4;
82 }
83 
84 
85 // Barrel or Endcap
86 int SiHitIdHelper::getBarrelEndcap(const int& hid) const
87 {
88  return this->GetFieldValue("BarrelEndcap", hid);
89 }
90 
91 // Layer/Disk
92 int SiHitIdHelper::getLayerDisk(const int& hid) const
93 {
94  return this->GetFieldValue("LayerDisk", hid);
95 }
96 
97 // eta module
98 int SiHitIdHelper::getEtaModule(const int& hid) const
99 {
100  return this->GetFieldValue("EtaModule", hid);
101 }
102 
103 // phi module
104 int SiHitIdHelper::getPhiModule(const int& hid) const
105 {
106  return this->GetFieldValue("PhiModule", hid);
107 }
108 
109 // side
110 int SiHitIdHelper::getSide(const int& hid) const
111 {
112  return this->GetFieldValue("Side", hid);
113 }
114 
115 
116 //
117 // Info packing:
118 int SiHitIdHelper::buildHitId(const int Part, const int BrlECap, const int LayerDisk,
119  const int etaM, const int phiM, const int side) const
120 {
121  int theID(0);
122  this->SetFieldValue("Part", Part, theID);
123  this->SetFieldValue("BarrelEndcap", BrlECap, theID);
124  this->SetFieldValue("LayerDisk", LayerDisk, theID);
125  this->SetFieldValue("EtaModule", etaM, theID);
126  this->SetFieldValue("PhiModule", phiM, theID);
127  this->SetFieldValue("Side", side, theID);
128  return theID;
129 }
130 
131 int SiHitIdHelper::buildHitIdFromStringITk(int part, const std::string& physVolName) const
132 {
133  int brlEcap = 0;
134  int layerDisk = 0;
135  int etaMod = 0;
136  int phiMod = 0;
137  int side = 0;
138  //Extract the indices from the name, and write them in to the matching int
139  std::map<std::string, int&> fields{{"barrel_endcap",brlEcap},{"layer_wheel",layerDisk},{"phi_module",phiMod},{"eta_module",etaMod},{"side",side}};
140  for(auto field:fields){
141  size_t pos1 = (physVolName).find(field.first+"_");
142  size_t pos2 = (physVolName).find("_",pos1+field.first.size()+1);//start looking only after end of first delimiter (plus 1 for the "_" appended) ends
143  std::string strNew = (physVolName).substr(pos1+field.first.size()+1,pos2-(pos1+field.first.size()+1));
144  field.second = std::stoi(strNew);
145  }
146  return buildHitId(part,brlEcap,layerDisk,etaMod,phiMod,side);
147 }
148 
149 int SiHitIdHelper::buildHitIdFromStringHGTD(int part, const std::string& physVolName) const
150 {
151  int endcap = 0;
152  int layer = 0;
153  int moduleInLayer = 0;
154  //Extract the indices from the name, and write them in to the matching int
155  std::map<std::string, int&> fields{{"endcap",endcap},{"layer",layer},{"moduleInLayer",moduleInLayer}};
156  for(auto field:fields){
157  size_t pos1 = (physVolName).find(field.first+"_");
158  size_t pos2 = (physVolName).find("_",pos1+field.first.size()+1);//start looking only after end of first delimiter (plus 1 for the "_" appended) ends
159  std::string strNew = (physVolName).substr(pos1+field.first.size()+1,pos2-(pos1+field.first.size()+1));
160  field.second = std::stoi(strNew);
161  }
162  return buildHitId(part,endcap,layer,0,moduleInLayer,0);
163 }
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
PixelID.h
This is an Identifier helper class for the Pixel subdetector. This class is a factory for creating co...
SiHitIdHelper::getPhiModule
int getPhiModule(const int &hid) const
Definition: SiHitIdHelper.cxx:104
HitIdHelper::SetFieldValue
void SetFieldValue(const std::string &name, int n, HitID &targetID) const
Definition: HitIdHelper.cxx:31
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
SiHitIdHelper::getSide
int getSide(const int &hid) const
Definition: SiHitIdHelper.cxx:110
SiHitIdHelper::buildHitIdFromStringHGTD
int buildHitIdFromStringHGTD(int part, const std::string &) const
Definition: SiHitIdHelper.cxx:149
SiHitIdHelper::m_isITkHGTD
bool m_isITkHGTD
Definition: SiHitIdHelper.h:69
SiHitIdHelper::SiHitIdHelper
SiHitIdHelper()
Definition: SiHitIdHelper.cxx:15
HitIdHelper::InitializeField
void InitializeField(const std::string &n, int vmn, int vmx)
Definition: HitIdHelper.cxx:10
ReadOfcFromCool.field
field
Definition: ReadOfcFromCool.py:48
TRT::Hit::side
@ side
Definition: HitInfo.h:83
runBeamSpotCalibration.helper
helper
Definition: runBeamSpotCalibration.py:112
SiHitIdHelper.h
HitIdHelper::GetFieldValue
int GetFieldValue(const std::string &name, HitID targetID) const
Definition: HitIdHelper.cxx:48
LayerDisk
Definition: WaferTree.h:57
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
SiHitIdHelper::buildHitIdFromStringITk
int buildHitIdFromStringITk(int part, const std::string &) const
Definition: SiHitIdHelper.cxx:131
SiHitIdHelper::getLayerDisk
int getLayerDisk(const int &hid) const
Definition: SiHitIdHelper.cxx:92
SiHitIdHelper
Definition: SiHitIdHelper.h:25
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
isDBM
bool isDBM(uint32_t robId)
Definition: PixelRodDecoder.cxx:45
HitIdHelper
Definition: HitIdHelper.h:23
SiHitIdHelper::getEtaModule
int getEtaModule(const int &hid) const
Definition: SiHitIdHelper.cxx:98
SiHitIdHelper::Initialize
void Initialize()
Definition: SiHitIdHelper.cxx:24
SiHitIdHelper::isPixel
bool isPixel(const int &hid) const
Definition: SiHitIdHelper.cxx:58
DetType::Part
Part
Definition: DetType.h:14
SiHitIdHelper::getBarrelEndcap
int getBarrelEndcap(const int &hid) const
Definition: SiHitIdHelper.cxx:86
SiHitIdHelper::GetHelper
static const SiHitIdHelper * GetHelper()
Definition: SiHitIdHelper.cxx:19
SiHitIdHelper::isPLR
bool isPLR(const int &hid) const
Definition: SiHitIdHelper.cxx:76
SiHitIdHelper::isSCT
bool isSCT(const int &hid) const
Definition: SiHitIdHelper.cxx:64
CaloCondBlobAlgs_fillNoiseFromASCII.fields
fields
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:106
fillSCTHists.etaMod
etaMod
Definition: fillSCTHists.py:23
pix
Definition: PixelMapping.cxx:16
SiHitIdHelper::buildHitId
int buildHitId(const int, const int, const int, const int, const int, const int) const
Definition: SiHitIdHelper.cxx:118
PixelID
Definition: PixelID.h:67
StoreGateSvc.h
SiHitIdHelper::isHGTD
bool isHGTD(const int &hid) const
Definition: SiHitIdHelper.cxx:70
ServiceHandle< StoreGateSvc >