ATLAS Offline Software
Loading...
Searching...
No Matches
SiHitIdHelper.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 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
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
58bool SiHitIdHelper::isPixel(const int& hid) const
59{
60 int psh = this->GetFieldValue("Part", hid);
61 return psh ==0;
62}
63
64bool SiHitIdHelper::isSCT(const int& hid) const
65{
66 int psh = this->GetFieldValue("Part", hid);
67 return psh ==1;
68}
69
70bool SiHitIdHelper::isHGTD(const int& hid) const
71{
72 int psh = this->GetFieldValue("Part", hid);
73 return psh ==2;
74}
75
76bool 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
86int SiHitIdHelper::getBarrelEndcap(const int& hid) const
87{
88 return this->GetFieldValue("BarrelEndcap", hid);
89}
90
91// Layer/Disk
92int SiHitIdHelper::getLayerDisk(const int& hid) const
93{
94 return this->GetFieldValue("LayerDisk", hid);
95}
96
97// eta module
98int SiHitIdHelper::getEtaModule(const int& hid) const
99{
100 return this->GetFieldValue("EtaModule", hid);
101}
102
103// phi module
104int SiHitIdHelper::getPhiModule(const int& hid) const
105{
106 return this->GetFieldValue("PhiModule", hid);
107}
108
109// side
110int SiHitIdHelper::getSide(const int& hid) const
111{
112 return this->GetFieldValue("Side", hid);
113}
114
115
116//
117// Info packing:
118int 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
131int 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(const 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
149int 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(const 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}
This is an Identifier helper class for the Pixel subdetector.
bool isDBM(uint32_t robId)
int GetFieldValue(const std::string &name, HitID targetID) const
void InitializeField(const std::string &n, int vmn, int vmx)
void SetFieldValue(const std::string &name, int n, HitID &targetID) const
This is an Identifier helper class for the Pixel subdetector.
Definition PixelID.h:67
int buildHitIdFromStringHGTD(int part, const std::string &) const
int getBarrelEndcap(const int &hid) const
int buildHitId(const int, const int, const int, const int, const int, const int) const
int buildHitIdFromStringITk(int part, const std::string &) const
bool isPixel(const int &hid) const
int getEtaModule(const int &hid) const
bool isPLR(const int &hid) const
int getLayerDisk(const int &hid) const
int getPhiModule(const int &hid) const
bool isHGTD(const int &hid) const
bool isSCT(const int &hid) const
int getSide(const int &hid) const
static const SiHitIdHelper * GetHelper()
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:138