LayerBuilder interface method - returning Endcap-like layers.
92{
93 ATH_MSG_DEBUG(
"calling HGTD_LayerBuilderCond::discLayers()" );
94
95
97 ATH_MSG_ERROR(
"HGTD Detector Manager or ID Helper could not be retrieved - giving up.");
98 return nullptr;
99 }
100
101
103 if(*readHandle == nullptr){
104 return nullptr;
105 }
107
110
111
112
113
114 int nlayers = 0;
115 for (; hgtdDetIter != readCdo->
end(); ++hgtdDetIter){
116 Identifier currentId((*hgtdDetIter)->identify());
117
120 nlayers++;
121 }
122
123 nlayers+=1;
124
125 ATH_MSG_DEBUG(
"Configured to build " << nlayers <<
" *2 disc-like layers (+ additional support layers)." );
126
127
128 std::vector<float> discZpos(2*nlayers,0.);
129 std::vector< std::vector<Trk::SurfaceOrderPosition> > discSurfaces(2*nlayers, std::vector<Trk::SurfaceOrderPosition>());
130
131 int hgtdModules = 0;
132 int sumCheckhgtdModules = 0;
133 unsigned int currentlayer = 0;
134 float maxRmax = -std::numeric_limits<float>::max();
135 float minRmin = std::numeric_limits<float>::max();
136
137
138 hgtdDetIter = readCdo->
begin();
139 for (; hgtdDetIter != readCdo->
end(); ++hgtdDetIter){
140
141
142 if ( (*hgtdDetIter) ) {
143
144 Identifier currentId((*hgtdDetIter)->identify());
145
150
151
152 hgtdModules++;
153
154
155 float currentZ = (*hgtdDetIter)->center().z();
156
158
159 currentlayer += currentZ > 0. ? nlayers : 0;
161
162
163
164 discZpos[currentlayer] = currentZ;
165
166
167 float currentRmin = (*hgtdDetIter)->rMin();
168 float currentRmax = (*hgtdDetIter)->rMax();
169 ATH_MSG_DEBUG(
" ---- rmin/rmax: " << currentRmin <<
"/" << currentRmax );
170 if (maxRmax<currentRmax)
171 maxRmax = currentRmax;
172 if (minRmin>currentRmin)
173 minRmin = currentRmin;
174
175
176
177 const Amg::Vector3D& orderPosition = (*hgtdDetIter)->center();
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193 Trk::Surface* mutableSurace = const_cast<Trk::Surface*>(&((*hgtdDetIter)->surface()));
194 std::shared_ptr<Trk::Surface> sharedSurface(mutableSurace,[](Trk::Surface*) {});
195
197
198 discSurfaces[currentlayer].push_back(surfaceOrder);
199
200 } else if (!(*hgtdDetIter))
201 ATH_MSG_WARNING(
"Not valid pointer to HGTD Detector element... something wrong with the Id dictionary?");
202 }
203
204
207
208
209 auto discLayers = std::make_unique<std::vector<Trk::DiscLayer*> >();
210
212
213 int discCounter = 0;
214 for (auto& thisDiscZpos : discZpos) {
215
219 ATH_MSG_DEBUG(
" -> With Rmin/Rmax (est) : " << minRmin <<
" / " << maxRmax );
220
222
223 std::vector<float> rBins = {minRmin};
224 std::vector<std::vector<float>> phiBins = {{}};
225
227
228
229
231 auto subBinUtilitiesPhi = std::vector<Trk::BinUtility>();
233
234 for (
unsigned int bin = 0;
bin < rBins.size()-1;
bin++) {
236 subBinUtilitiesPhi.push_back(BinUtilityY);
237 ATH_MSG_DEBUG(bin <<
") BinUtilityPhi --> " << BinUtilityY );
238 }
239
240
241 auto currentBinnedArray =
242 std::make_unique<Trk::BinnedArray1D1D<Trk::Surface>>(
243 discSurfaces[discCounter], BinUtilityR, subBinUtilitiesPhi);
244
246
247 int discSurfacesNum = (discSurfaces[discCounter]).size();
248
249 ATH_MSG_DEBUG(
"Constructed BinnedArray for DiscLayer with "<< discSurfacesNum <<
" SubSurfaces." );
250
251
253
254
255
256 std::map< const Trk::Surface*,Amg::Vector3D > uniqueSurfaceMap;
257 std::map< const Trk::Surface*,Amg::Vector3D >::iterator usmIter = uniqueSurfaceMap.end();
258
259 std::span<Trk::Surface * const> arraySurfaces = currentBinnedArray->arrayObjects();
260 size_t dsumCheckSurfaces = 0;
261 double lastPhi = 0.;
262 for (const auto & asurfIter : arraySurfaces){
263 if ( asurfIter ) {
264 ++dsumCheckSurfaces;
265 usmIter = uniqueSurfaceMap.find(asurfIter);
266 lastPhi = asurfIter->center().phi();
267 if (usmIter != uniqueSurfaceMap.end()) {
269 << asurfIter->center().eta() << " / "
270 << asurfIter->center().phi());
271 } else {
272 uniqueSurfaceMap[asurfIter] = asurfIter->center();
273 }
274 } else {
276 "valid phi value was = "
277 << lastPhi << " --> discCounter: " << discCounter);
278 }
279 }
280 sumCheckhgtdModules += dsumCheckSurfaces;
281 }
282
283
284 const Trk::LayerMaterialProperties& layerMaterial =
discLayerMaterial(minRmin,maxRmax);
285
289
290 auto activeLayerBounds = std::make_shared<Trk::DiscBounds>(minRmin, maxRmax);
291
292 auto olDescriptor = std::make_unique<HGTD_OverlapDescriptor>(
293 currentBinnedArray.get(), rBins, phiBins);
294
295
296 std::span<Trk::Surface * const> layerSurfaces = currentBinnedArray->arrayObjects();
297
298
299 Trk::DiscLayer* activeLayer = new Trk::DiscLayer(activeLayerTransform,
300 activeLayerBounds,
301 std::move(currentBinnedArray),
302 layerMaterial,
303 thickness,
304 std::move(olDescriptor));
305
308
309 ++discCounter;
310 }
311
312
313 ATH_MSG_DEBUG( hgtdModules <<
" HGTD Modules parsed for Disc Layer dimensions." );
315 ATH_MSG_DEBUG( sumCheckhgtdModules <<
" HGTD Modules filled in Disc Layer Arrays." );
316 if ( hgtdModules-sumCheckhgtdModules )
317 ATH_MSG_WARNING( hgtdModules-sumCheckhgtdModules <<
" Modules not registered properly in binned array." );
318 }
319
320
321 Trk::DiscLayerSorterZ zSorter;
323
325}
#define ATH_MSG_WARNING(x)
DataModel_detail::const_iterator< DataVector > const_iterator
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
virtual std::unique_ptr< const std::vector< Trk::DiscLayer * > > discLayers(const EventContext &ctx, SG::WriteCondHandle< Trk::TrackingGeometry > &whandle) const override final
LayerBuilder interface method - returning Endcap-like layers.
SG::ReadCondHandle< InDetDD::HGTD_DetectorElementCollection > retrieveHGTDdetElements(const EventContext &ctx) const
helper method to construct HGTD materia
void registerSurfacesToLayer(std::span< Trk::Surface *const > &surfaces, const Trk::Layer &layer) const
static void evaluateBestBinning(std::vector< Trk::SurfaceOrderPosition > &surfaces, std::vector< float > &rBins, float &maxRadius, std::vector< std::vector< float > > &phiBins)
const Trk::BinnedLayerMaterial discLayerMaterial(double rMin, double rMax) const
layer association
void addDependency(const EventIDRange &range)
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
Eigen::Translation< double, 3 > Translation3D
DataVector< HGTD_DetectorElement > HGTD_DetectorElementCollection
std::pair< std::shared_ptr< Surface >, Amg::Vector3D > SurfaceOrderPosition
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.