ATLAS Offline Software
Loading...
Searching...
No Matches
GBTSTrigL2LayerNumberTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
10
13
15 const std::string& n,
16 const IInterface* p ): AthAlgTool(t,n,p),
17 m_useNewScheme(false),
22{
23 declareInterface< ITrigL2LayerNumberTool >( this );
24 declareProperty( "UseNewLayerScheme", m_useNewScheme = false );
25}
26
28
29 StatusCode sc = AthAlgTool::initialize();
30
31 ATH_MSG_DEBUG("In initialize...");
32
33 sc = detStore()->retrieve(m_pixelId, "PixelID");
34 if (sc.isFailure()) {
35 ATH_MSG_FATAL("Could not get Pixel ID helper");
36 return sc;
37 }
38
39 sc = detStore()->retrieve(m_sctId, "SCT_ID");
40 if (sc.isFailure()) {
41 ATH_MSG_FATAL("Could not get SCT ID helper");
42 return sc;
43 }
44
45 sc = detStore()->retrieve(m_pixelManager);
46 if( sc.isFailure() ) {
47 ATH_MSG_ERROR("Could not retrieve Pixel DetectorManager from detStore.");
48 return sc;
49 }
50
51 sc = detStore()->retrieve(m_sctManager);
52 if( sc.isFailure() ) {
53 ATH_MSG_ERROR("Could not retrieve SCT DetectorManager from detStore.");
54 return sc;
55 }
56
57 //calculate the numbers
58
59 if(!m_useNewScheme) {
60
61 const InDetDD::SiNumerology& pixSiNum = m_pixelManager->numerology();
62 const InDetDD::SiNumerology& sctSiNum = m_sctManager->numerology();
63
64 m_MaxSiliconLayerNum = pixSiNum.numLayers()+pixSiNum.numDisks()+sctSiNum.numLayers()+sctSiNum.numDisks();
65 m_OffsetBarrelSCT = pixSiNum.numLayers();
66 m_OffsetEndcapPixels = pixSiNum.numLayers()+sctSiNum.numLayers();
68 m_OffsetEndcapSCT = pixSiNum.numLayers()+sctSiNum.numLayers()+pixSiNum.numDisks();
69 }
70 else {
72
73 ATH_MSG_DEBUG("Total number of unique silicon layers = "<<m_hashMap.size());
74
75 m_MaxSiliconLayerNum = (int)m_hashMap.size();
77 }
78
79
80 ATH_MSG_DEBUG("GBTSTrigL2LayerNumberTool initialized ");
81
82 report();
83
84 return sc;
85}
86
88{
89 StatusCode sc = AthAlgTool::finalize();
90 return sc;
91}
92
94
95 ATH_MSG_DEBUG("TrigL2 Layer numbering scheme:");
96 ATH_MSG_DEBUG("Total number of layers = "<<maxSiliconLayerNum());
97 ATH_MSG_DEBUG("OffsetEndcapPixels = "<<offsetEndcapPixels());
98 ATH_MSG_DEBUG("OffsetBarrelSCT = "<<offsetBarrelSCT());
99 ATH_MSG_DEBUG("OffsetEndcapSCT = "<<offsetEndcapSCT());
100}
101
102void GBTSTrigL2LayerNumberTool::createModuleHashMap(std::map<std::tuple<int,int,short,short>,std::vector<GBTSPhiEtaHash> >& hashMap) {
103
104
105 short subdetid = 1;
106
107 for(int hash = 0; hash<static_cast<int>(m_pixelId->wafer_hash_max()); hash++) {
108
109 Identifier offlineId = m_pixelId->wafer_id(hash);
110
111 if(offlineId==0) continue;
112
113 short barrel_ec = m_pixelId->barrel_ec(offlineId);
114 if(std::abs(barrel_ec)>2) {std::cout << "barrel " << " " << hash << std::endl; continue;}//no DBM needed
115
116 short phi_index = m_pixelId->phi_module(offlineId);
117 short eta_index = m_pixelId->eta_module(offlineId);
118 int lay_id = m_pixelId->layer_disk(offlineId);
119 int eta_mod = m_pixelId->eta_module(offlineId);
120
121 int vol_id = -1;
122 if(barrel_ec== 0) vol_id = 8;
123 if(barrel_ec==-2) vol_id = 7;
124 if(barrel_ec== 2) vol_id = 9;
125
126 int new_vol=0, new_lay=0;
127
128 if(vol_id == 7 || vol_id == 9) {
129 new_vol = 10*vol_id + lay_id;
130 new_lay = eta_mod;
131 }
132 else if(vol_id == 8) {
133 new_lay = 0;
134 new_vol = 10*vol_id + lay_id;
135 }
136
137 auto t = std::make_tuple(barrel_ec==0 ? -100 : barrel_ec, subdetid, new_vol, new_lay);
138
139 std::map<std::tuple<int, int, short, short>,std::vector<GBTSPhiEtaHash> >::iterator it = hashMap.find(t);
140 if(it==hashMap.end())
141 hashMap.insert(std::pair<std::tuple<int, int, short, short>,std::vector<GBTSPhiEtaHash> >(t,std::vector<GBTSPhiEtaHash>(1, GBTSPhiEtaHash(phi_index, eta_index, hash) )));
142 else (*it).second.push_back(GBTSPhiEtaHash(phi_index, eta_index, hash));
143 }
144
145 if (false) {
146 subdetid = 2; //SCT
147
148 for(int hash = 0; hash<static_cast<int>(m_sctId->wafer_hash_max()); hash++) {
149
150 Identifier offlineId = m_sctId->wafer_id(hash);
151
152 if(offlineId==0) continue;
153
154 short barrel_ec = m_sctId->barrel_ec(offlineId);
155 short phi_index = m_sctId->phi_module(offlineId);
156 short eta_index = m_sctId->eta_module(offlineId);
157
158 int vol_id = 13;
159
160 if(barrel_ec) vol_id = 12;
161 if(barrel_ec>0) vol_id = 14;
162
163 int lay_id = m_sctId->layer_disk(offlineId);
164
165 auto t = std::make_tuple(barrel_ec==0 ? -100 : barrel_ec, subdetid, vol_id, lay_id);
166
167 std::map<std::tuple<int, int, short, short>,std::vector<GBTSPhiEtaHash> >::iterator it = hashMap.find(t);
168 if(it==hashMap.end())
169 hashMap.insert(std::pair<std::tuple<int, int, short, short>,std::vector<GBTSPhiEtaHash> >(t,std::vector<GBTSPhiEtaHash>(1, GBTSPhiEtaHash(phi_index, eta_index, hash))));
170 else (*it).second.push_back(GBTSPhiEtaHash(phi_index, eta_index, hash));
171 }
172 }
173
174
175 m_pixelLayers.clear();
176 m_sctLayers.clear();
177
178 m_pixelLayers.resize(m_pixelId->wafer_hash_max(), -100);
179 m_sctLayers.resize(m_sctId->wafer_hash_max(), -100);
180 m_layerGeometry.resize(hashMap.size());
181
182 int layerId=0;
184 for(std::map<std::tuple<int,int,short,short>,std::vector<GBTSPhiEtaHash> >::iterator it = hashMap.begin();it!=hashMap.end();++it, layerId++) {
185
186 short vol_id = std::get<2>((*it).first);
187 short lay_id = std::get<3>((*it).first);
188
189 int combinedId = static_cast<int>(vol_id)*1000 + lay_id;
190
191 short subdetId = std::get<1>((*it).first);
192 short barrel_ec = std::get<0>((*it).first);
193
194 if(barrel_ec==-100) barrel_ec = 0;
195
196 if(barrel_ec == 0) m_LastBarrelLayer++;
197
198 m_layerGeometry[layerId].m_type = barrel_ec;
199 m_layerGeometry[layerId].m_subdet = combinedId;
200
201
202 float rc=0.0;
203 float minBound = 100000.0;
204 float maxBound =-100000.0;
205 int nModules = 0;
206
207 for(std::vector<GBTSPhiEtaHash>::iterator hIt = (*it).second.begin();hIt != (*it).second.end();++hIt) {
208
209 const InDetDD::SiDetectorElement *p{nullptr};
210
211 if(subdetId == 1) {//pixel
212 m_pixelLayers[(*hIt).m_hash] = layerId;
213 p = m_pixelManager->getDetectorElement((*hIt).m_hash);
214 }
215 if(subdetId == 2) {//SCT
216 m_sctLayers[(*hIt).m_hash] = layerId;
217 p = m_sctManager->getDetectorElement((*hIt).m_hash);
218 }
219
220 if (p==nullptr) {
221 ATH_MSG_ERROR("nullptr SiDetectorElement with idHash " << (*hIt).m_hash);
222 continue;
223 }
224 const Amg::Vector3D& C = p->center();
225 if(barrel_ec == 0) {
226 rc += sqrt(C(0)*C(0)+C(1)*C(1));
227 if(p->zMin() < minBound) minBound = p->zMin();
228 if(p->zMax() > maxBound) maxBound = p->zMax();
229 }
230 else {
231 rc += C(2);
232 if(p->rMin() < minBound) minBound = p->rMin();
233 if(p->rMax() > maxBound) maxBound = p->rMax();
234 }
235 nModules++;
236 }
237 m_layerGeometry[layerId].m_refCoord = rc/nModules;
238 m_layerGeometry[layerId].m_minBound = minBound;
239 m_layerGeometry[layerId].m_maxBound = maxBound;
240 }
241
242 int M = (layerId-m_LastBarrelLayer)/2;
243
244 ATH_MSG_DEBUG("List of unique layers in Pixel and SCT :");
245 for(int l=0;l<layerId;l++) {
246
247 int oldL = l;
248
249 if(l>m_LastBarrelLayer-1) {
250 oldL = l-m_LastBarrelLayer;
251 oldL = oldL < M ? oldL : oldL - M;
252 oldL += m_LastBarrelLayer;
253 }
254
255 if(m_layerGeometry[l].m_subdet==1) {
256 ATH_MSG_DEBUG("Layer "<<l<<" ("<<oldL<<") : PIX, reference coordinate ="<< m_layerGeometry[l].m_refCoord<<" boundaries: "<<m_layerGeometry[l].m_minBound<<
257 " "<<m_layerGeometry[l].m_maxBound);
258 }
259 if(m_layerGeometry[l].m_subdet==2) {
260 ATH_MSG_DEBUG("Layer "<<l<<" ("<<oldL<<") : SCT, reference coordinate ="<< m_layerGeometry[l].m_refCoord<<" boundaries: "<<m_layerGeometry[l].m_minBound<<
261 " "<<m_layerGeometry[l].m_maxBound);
262 }
263 }
264}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_DEBUG(x)
static Double_t sc
static Double_t rc
This is an Identifier helper class for the Pixel subdetector.
This is an Identifier helper class for the SCT subdetector.
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
const InDetDD::PixelDetectorManager * m_pixelManager
std::vector< TrigInDetSiLayer > m_layerGeometry
std::map< std::tuple< int, int, short, short >, std::vector< GBTSPhiEtaHash > > m_hashMap
void createModuleHashMap(std::map< std::tuple< int, int, short, short >, std::vector< GBTSPhiEtaHash > > &)
GBTSTrigL2LayerNumberTool(const std::string &, const std::string &, const IInterface *)
const InDetDD::SCT_DetectorManager * m_sctManager
Class to hold geometrical description of a silicon detector element.
Class to extract numerology for Pixel and SCT.
int numLayers() const
Number of layers.
int numDisks() const
Number of disks.
struct color C
Eigen::Matrix< double, 3, 1 > Vector3D