ATLAS Offline Software
Loading...
Searching...
No Matches
TrigL2LayerNumberToolITk.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 ) :
17 AthAlgTool(t,n,p) {
18
19 declareInterface< ITrigL2LayerNumberTool >( this );
20}
21
23
24 ATH_CHECK( detStore()->retrieve(m_pixelId, "PixelID") );
25 ATH_CHECK( detStore()->retrieve(m_sctId, "SCT_ID") );
26 ATH_CHECK( detStore()->retrieve(m_pixelManager, "ITkPixel") );
27 ATH_CHECK( detStore()->retrieve(m_sctManager, "ITkStrip") );
28
29 //calculate the numbers
30
31 if(!m_useNewScheme) {
32
33 const InDetDD::SiNumerology& pixSiNum = m_pixelManager->numerology();
34 const InDetDD::SiNumerology& sctSiNum = m_sctManager->numerology();
35
36 m_MaxSiliconLayerNum = pixSiNum.numLayers()+pixSiNum.numDisks()+sctSiNum.numLayers()+sctSiNum.numDisks();
37 m_OffsetBarrelSCT = pixSiNum.numLayers();
38 m_OffsetEndcapPixels = pixSiNum.numLayers()+sctSiNum.numLayers();
40 m_OffsetEndcapSCT = pixSiNum.numLayers()+sctSiNum.numLayers()+pixSiNum.numDisks();
41 }
42 else {
44
45 ATH_MSG_INFO("Total number of unique silicon layers = "<<m_hashMap.size());
46
47 m_MaxSiliconLayerNum = static_cast<int>(m_hashMap.size());
49 }
50
51 report();
52
53 return StatusCode::SUCCESS;
54}
55
57
58 ATH_MSG_INFO("TrigL2 Layer numbering scheme:");
59 ATH_MSG_INFO("Total number of layers = "<<maxSiliconLayerNum());
60 ATH_MSG_INFO("OffsetEndcapPixels = "<<offsetEndcapPixels());
61 ATH_MSG_INFO("OffsetBarrelSCT = "<<offsetBarrelSCT());
62 ATH_MSG_INFO("OffsetEndcapSCT = "<<offsetEndcapSCT());
63}
64
65
66void TrigL2LayerNumberToolITk::createModuleHashMap(std::map<std::tuple<int, int, short, short>,std::vector<PhiEtaHashITk> >& hashMap) {
67
68
69 //helper function
70
71
72 short subdetid = 1;
73
74 for(int hash = 0; hash<static_cast<int>(m_pixelId->wafer_hash_max()); hash++) {
75
76 Identifier offlineId = m_pixelId->wafer_id(hash);
77
78 if(offlineId==0) continue;
79
80 short barrel_ec = m_pixelId->barrel_ec(offlineId);
81 if(std::abs(barrel_ec)>2) continue;//no DBM needed
82
83 short phi_index = m_pixelId->phi_module(offlineId);
84 short eta_index = m_pixelId->eta_module(offlineId);
85 int lay_id = m_pixelId->layer_disk(offlineId);
86 int eta_mod = m_pixelId->eta_module(offlineId);
87
88 int vol_id = -1;
89 if(barrel_ec== 0) vol_id = 8;
90 if(barrel_ec==-2) vol_id = 7;
91 if(barrel_ec== 2) vol_id = 9;
92
93 int new_vol=0, new_lay=0;
94
95 if(vol_id == 7 || vol_id == 9) {
96 new_vol = 10*vol_id + lay_id;
97 new_lay = eta_mod;
98 }
99 else if(vol_id == 8) {
100 new_lay = 0;
101 new_vol = 10*vol_id + lay_id;
102 }
103
104 auto t = std::make_tuple(barrel_ec==0 ? -100 : barrel_ec, subdetid, new_vol, new_lay);
105
106 std::map<std::tuple<int, int, short, short>,std::vector<PhiEtaHashITk> >::iterator it = hashMap.find(t);
107 if(it==hashMap.end())
108 hashMap.insert(std::pair<std::tuple<int, int, short, short>,std::vector<PhiEtaHashITk> >(t,std::vector<PhiEtaHashITk>(1, PhiEtaHashITk(phi_index, eta_index, hash) )));
109 else (*it).second.push_back(PhiEtaHashITk(phi_index, eta_index, hash));
110 }
111
112 subdetid = 2;
113
114 for(int hash = 0; hash<static_cast<int>(m_sctId->wafer_hash_max()); hash++) {
115
116 Identifier offlineId = m_sctId->wafer_id(hash);
117
118 if(offlineId==0) continue;
119
120 short barrel_ec = m_sctId->barrel_ec(offlineId);
121 short phi_index = m_sctId->phi_module(offlineId);
122 short eta_index = m_sctId->eta_module(offlineId);
123
124 int vol_id = 13;
125
126 if(barrel_ec) vol_id = 12;
127 if(barrel_ec>0) vol_id = 14;
128
129 int lay_id = m_sctId->layer_disk(offlineId);
130
131 auto t = std::make_tuple(barrel_ec==0 ? -100 : barrel_ec, subdetid, vol_id, lay_id);
132
133 std::map<std::tuple<int, int, short, short>,std::vector<PhiEtaHashITk> >::iterator it = hashMap.find(t);
134 if(it==hashMap.end())
135 hashMap.insert(std::pair<std::tuple<int, int, short, short>,std::vector<PhiEtaHashITk> >(t,std::vector<PhiEtaHashITk>(1, PhiEtaHashITk(phi_index, eta_index, hash))));
136 else (*it).second.push_back(PhiEtaHashITk(phi_index, eta_index, hash));
137 }
138
139 m_pixelLayers.clear();
140 m_sctLayers.clear();
141
142 m_pixelLayers.resize(m_pixelId->wafer_hash_max(), -100);
143 m_sctLayers.resize(m_sctId->wafer_hash_max(), -100);
144 m_layerGeometry.resize(hashMap.size());
145
146 int layerId=0;
147
149
150 for(std::map<std::tuple<int, int, short, short>,std::vector<PhiEtaHashITk> >::iterator it = hashMap.begin();it!=hashMap.end();++it, layerId++) {
151
152 short vol_id = std::get<2>((*it).first);
153 short lay_id = std::get<3>((*it).first);
154 int combinedId = static_cast<int>(vol_id)*1000 + lay_id;
155
156 short subdetId = std::get<1>((*it).first);
157 short barrel_ec = std::get<0>((*it).first);
158
159 if(barrel_ec == -100) barrel_ec = 0;
160
161 if(barrel_ec == 0) m_LastBarrelLayer++;
162
163 m_layerGeometry[layerId].m_type = barrel_ec;
164
165 m_layerGeometry[layerId].m_subdet = combinedId;
166
167 //m_layerGeometry[layerId].m_subdet = subdetId;
168
169 float rc=0.0;
170 float minBound = 100000.0;
171 float maxBound =-100000.0;
172 int nModules = 0;
173
174 for(std::vector<PhiEtaHashITk>::iterator hIt = (*it).second.begin();hIt != (*it).second.end();++hIt) {
175
176 const InDetDD::SiDetectorElement *p = NULL;
177
178 if(subdetId == 1) {//pixel
179 m_pixelLayers[(*hIt).m_hash] = layerId;
180 p = m_pixelManager->getDetectorElement((*hIt).m_hash);
181 }
182 if(subdetId == 2) {//SCT
183 m_sctLayers[(*hIt).m_hash] = layerId;
184 p = m_sctManager->getDetectorElement((*hIt).m_hash);
185 }
186
187 const Amg::Vector3D& C = p->center();
188 if(barrel_ec == 0) {
189 rc += sqrt(C(0)*C(0)+C(1)*C(1));
190 if(p->zMin() < minBound) minBound = p->zMin();
191 if(p->zMax() > maxBound) maxBound = p->zMax();
192 }
193 else {
194 rc += C(2);
195 if(p->rMin() < minBound) minBound = p->rMin();
196 if(p->rMax() > maxBound) maxBound = p->rMax();
197 }
198 nModules++;
199 }
200 m_layerGeometry[layerId].m_refCoord = rc/nModules;
201 m_layerGeometry[layerId].m_minBound = minBound;
202 m_layerGeometry[layerId].m_maxBound = maxBound;
203 }
204
205 ATH_MSG_INFO("List of unique layers in Pixel and SCT :");
206 for(int l=0;l<layerId;l++) {
207 ATH_MSG_INFO("Layer "<<l<<" ("<<m_layerGeometry[l].m_subdet<<") : reference coordinate ="<< m_layerGeometry[l].m_refCoord<<" boundaries: "<<m_layerGeometry[l].m_minBound<<" "<<m_layerGeometry[l].m_maxBound<<" type="<<m_layerGeometry[l].m_type);
208 }
209}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
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:
const ServiceHandle< StoreGateSvc > & detStore() const
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.
const InDetDD::PixelDetectorManager * m_pixelManager
Gaudi::Property< bool > m_useNewScheme
TrigL2LayerNumberToolITk(const std::string &, const std::string &, const IInterface *)
virtual int offsetEndcapSCT() const override
void createModuleHashMap(std::map< std::tuple< int, int, short, short >, std::vector< PhiEtaHashITk > > &)
virtual StatusCode initialize() override
const InDetDD::SCT_DetectorManager * m_sctManager
virtual int offsetBarrelSCT() const override
std::vector< TrigInDetSiLayer > m_layerGeometry
virtual void report() const override
virtual int offsetEndcapPixels() const override
virtual int maxSiliconLayerNum() const override
std::map< std::tuple< int, int, short, short >, std::vector< PhiEtaHashITk > > m_hashMap
struct color C
Eigen::Matrix< double, 3, 1 > Vector3D