ATLAS Offline Software
Loading...
Searching...
No Matches
LayerArrayCreator.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6// LayerArrayCreator.cxx, (c) ATLAS Detector software
8
9// Trk include
14#include "TrkGeometry/Layer.h"
23// Amg
25
26
27// constructor
28Trk::LayerArrayCreator::LayerArrayCreator(const std::string& t, const std::string& n, const IInterface* p) : AthAlgTool(t,n,p)
29{
30 declareInterface<ILayerArrayCreator>(this);
31}
32
33
34std::unique_ptr<Trk::BinnedArray1D<Trk::Layer>> Trk::LayerArrayCreator::cylinderLayerArray(
35 const std::vector<Trk::CylinderLayer*>& cylLayersInput,
36 double rmin, double rmax, Trk::BinningType btype) const
37{
38 ATH_MSG_VERBOSE( " build LayerArray with " << cylLayersInput.size() << " cylindrical material layers." );
39 ATH_MSG_VERBOSE( " rmin/rmax provided : " << rmin << " / " << rmax );
40
41 //copy so that you can sort
42 std::vector<Trk::CylinderLayer*> cylLayers(cylLayersInput);
43 // sort the vector
45 std::sort(cylLayers.begin(), cylLayers.end(), rSorter);
46
47 // needed for all cases
48 Trk::Layer* cylinderLayer = nullptr;
49 std::unique_ptr<Trk::BinnedArray1D<Trk::Layer>> cylinderLayerArray = nullptr;
50 std::vector< std::pair<std::shared_ptr<Trk::Layer>, Amg::Vector3D> > layerOrderVector;
51
52 switch (btype) {
53
54 // equidistant binning - no navigation layers built
55 case Trk::equidistant :
56 {
57 // count the layers
58 unsigned int layers = cylLayers.size();
59 // loop over layers and put them in
60 for (auto& layIter : cylLayers ) {
61 // get the R
62 const Trk::CylinderSurface& layerSurface = layIter->surfaceRepresentation();
63 double currentR = layerSurface.bounds().r();
64 ATH_MSG_VERBOSE( "equidistant : registering cylindrical MaterialLayer at radius : " << currentR );
65 layerOrderVector.emplace_back(std::shared_ptr<Layer>(layIter),
66 Amg::Vector3D(currentR, 0.,0.));
67 }
68 // create the binUtility
69 auto binUtility = Trk::BinUtility(layers,rmin,rmax,Trk::open, Trk::binR);
70 ATH_MSG_VERBOSE( "equidistant : created a BinUtility as " << binUtility );
71
72 // create the BinnedArray; BinnedArray now owns the binUtility pointer
73 cylinderLayerArray = std::make_unique<Trk::BinnedArray1D<Trk::Layer>>(layerOrderVector, binUtility);
74 } break;
75
76 // bi-equidistant binning - take care the layers have to be binned equidistant + same thickness
78 {
79
80 // count the layers
81 unsigned int layers = cylLayers.size();
82 // take a reference thinkness
83 double layerThickness = cylLayers[0]->thickness();
84 // the radialstep
85 double radialStep = (rmax-rmin)/(layers-1);
86 // the next step
87 double navigationR = 0.;
88 double navLayerHalflengthZ = 0.;
89 const Amg::Transform3D* layerTransform = nullptr;
90
91 // loop over layers
92 for (auto& layIter : cylLayers ) {
93 // get the dimensions
94 const Trk::CylinderSurface& layerSurface = layIter->surfaceRepresentation();
95 layerTransform = layerSurface.transform().isApprox(Amg::Transform3D::Identity()) ? nullptr : &layerSurface.transform();
96
97 double currentR = layerSurface.bounds().r();
98 navigationR = currentR - 0.5*radialStep;
99
100 navLayerHalflengthZ = layerSurface.bounds().halflengthZ();
101 ATH_MSG_VERBOSE( "bi-equidistant : creating cylindrical NavigationLayer at radius : " << navigationR );
102 auto navLayerSurface =
103 layerTransform ? std::make_unique<Trk::CylinderSurface>(
104 Amg::Transform3D(*layerTransform),navigationR, navLayerHalflengthZ)
105 : std::make_unique<Trk::CylinderSurface>(
106 navigationR, navLayerHalflengthZ);
107 // the navigation layer
108 auto navLayer = std::make_shared<Trk::NavigationLayer>(std::move(navLayerSurface));
109 // push the navigation layer in
110 layerOrderVector.emplace_back(std::move(navLayer),
111 Amg::Vector3D(navigationR, 0., 0.));
112 ATH_MSG_VERBOSE( "bi-equidistant : registering cylindrical MaterialLayer at radius : " << currentR );
113 // push the original layer in
114 layerOrderVector.emplace_back(std::shared_ptr<Trk::Layer>(layIter),
115 Amg::Vector3D(currentR, 0., 0.));
116 }
117
118 // special treatment for the last one
119 ATH_MSG_VERBOSE( "bi-equidistant : creating cylindrical NavigationLayer at radius : " << navigationR+radialStep);
120 auto navLayerSurfacFinal = layerTransform ?
121 std::make_unique<Trk::CylinderSurface>(
122 Amg::Transform3D(*layerTransform), navigationR+radialStep, navLayerHalflengthZ) :
123 std::make_unique<Trk::CylinderSurface>(navigationR+radialStep, navLayerHalflengthZ);
124 // the navigation layer
125 auto navLayer = std::make_shared<Trk::NavigationLayer>(std::move(navLayerSurfacFinal));
126 // push the navigation layer in
127 layerOrderVector.emplace_back(std::move(navLayer),
128 Amg::Vector3D(navigationR+radialStep, 0., 0.));
129
130 ATH_MSG_VERBOSE( layerOrderVector.size() << " cylindrical Layers (material + navigation) built. " );
131
132 // create the binUtility
133 double rMinBoundary = rmin-radialStep+0.5*layerThickness;
134 double rMaxBoundary = rmax+radialStep+0.5*layerThickness;
135 auto binUtility = Trk::BinUtility(layers, layerThickness, rMinBoundary, rMaxBoundary, Trk::open, Trk::binR);
136 ATH_MSG_VERBOSE( "bi-equidistant : created a BinUtility as " << binUtility );
137
138 // create the BinnedArray; BinnedArray now owns the binUtility pointer
139 cylinderLayerArray = std::make_unique<Trk::BinnedArray1D<Trk::Layer>>(layerOrderVector, binUtility);
140
141 } break;
142
143 // arbitrary binning
144 case Trk::arbitrary :
145 {
146 std::vector<float> boundaries;
147 // maz z extension
148 double halfLengthZ = 0;
149 const Amg::Transform3D* layerTransform = nullptr;
150
151 // initial step
152 boundaries.push_back(rmin);
153
154 // loop over the provided layers and put Navigation layers in between
155 for (auto& layIter : cylLayers) {
156 // get the cylinder surface
157 const Trk::CylinderSurface& layerSurface = layIter->surfaceRepresentation();
158 layerTransform = layerSurface.transform().isApprox(Amg::Transform3D::Identity()) ? nullptr : &layerSurface.transform();
159 // and get the halflength
160 double currentHalfLengthZ = layerSurface.bounds().halflengthZ();
161 takeBigger(halfLengthZ, currentHalfLengthZ);
162 double layerRadius = layerSurface.bounds().r();
163 double layerThickness = layIter->thickness();
164 // navigation layer : previous bin
165 double navLayerRadius = 0.5*( (layerRadius-0.5*layerThickness) + boundaries[boundaries.size()-1] );
166 auto navLayerSurface = layerTransform ?
167 std::make_unique<Trk::CylinderSurface>(
168 Amg::Transform3D(*layerTransform), navLayerRadius, halfLengthZ) :
169 std::make_unique<Trk::CylinderSurface>(navLayerRadius, halfLengthZ);
170 // material layer : current bin
171 cylinderLayer = checkAndReplaceEmptyLayer(layIter);
172 if (cylinderLayer){
173 ATH_MSG_VERBOSE( "arbitrary : creating cylindrical NavigationLayer at radius : " << navLayerRadius );
174 layerOrderVector.emplace_back(
175 std::make_shared<Trk::NavigationLayer>(std::move(navLayerSurface)),
176 Amg::Vector3D(navLayerRadius, 0., 0.));
177 ATH_MSG_VERBOSE( "arbitrary : registering cylindrical MaterialLayer at radius :" << layerRadius );
178 layerOrderVector.emplace_back(
179 std::shared_ptr<Trk::Layer>(cylinderLayer),
180 Amg::Vector3D(layerRadius, 0.,0.));
181 boundaries.push_back(layerRadius-0.5*layerThickness);
182 boundaries.push_back(layerRadius+0.5*layerThickness);
183 } else {
184 ATH_MSG_VERBOSE( "arbitrary : empty layer configuration cancelled this building of navigation layer.");
185 }
186 }
187 // close up the array with last bin
188 double navLayerRadiusFinal = 0.5*(rmax+boundaries[boundaries.size()-1]);
189 auto navLayerSurfaceFinal = layerTransform ?
190 std::make_unique<Trk::CylinderSurface>(
191 Amg::Transform3D(*layerTransform), navLayerRadiusFinal, halfLengthZ) :
192 std::make_unique<Trk::CylinderSurface>(navLayerRadiusFinal, halfLengthZ);
193 boundaries.push_back(rmax);
194 ATH_MSG_VERBOSE( "arbitrary : creating cylindrical NavigationLayer at radius : " << navLayerRadiusFinal );
195 layerOrderVector.emplace_back(std::make_shared<Trk::NavigationLayer>(std::move(navLayerSurfaceFinal)),
196 Amg::Vector3D(navLayerRadiusFinal, 0., 0.));
197
198 ATH_MSG_VERBOSE( layerOrderVector.size() << " cylindrical Layers (material + navigation) built. " );
199 // create the BinUtility
200 auto binUtility = Trk::BinUtility(boundaries, Trk::open, Trk::binR);
201 ATH_MSG_VERBOSE( "arbitrary : created a BinUtility as " << binUtility );
202
203 // create the BinnedArray; BinnedArray now owns the binUtility pointer
204 cylinderLayerArray = std::make_unique<Trk::BinnedArray1D<Trk::Layer>>(layerOrderVector, binUtility);
205
206 } break;
207
208 // default return 0
209 default : { return nullptr; }
210 }
211
212 return cylinderLayerArray;
213}
214
215
216std::unique_ptr<Trk::BinnedArray1D<Trk::Layer>> Trk::LayerArrayCreator::discLayerArray(
217 const std::vector<Trk::DiscLayer*>& discLayersInput,
218 double zmin,
219 double zmax,
220 Trk::BinningType btype) const
221{
222
223 ATH_MSG_VERBOSE( " build LayerArray with " << discLayersInput.size() << " disc-like material layers." );
224 ATH_MSG_VERBOSE( " zmin/zmax provided : " << zmin << " / " << zmax );
225
226 // needed for all cases
227 std::unique_ptr<Trk::BinnedArray1D<Trk::Layer>> discLayerArray = nullptr;
228 std::vector<std::pair<std::shared_ptr<Trk::Layer>, Amg::Vector3D>> layerOrderVector;
229
230 //copy so that you can sort
231 std::vector<Trk::DiscLayer*> discLayers(discLayersInput);
232 // sort the vector
233 Trk::DiscLayerSorterZ zSorter;
234 std::sort(discLayers.begin(), discLayers.end(), zSorter);
235 // the layer to be pushed back
236 Trk::Layer* discLayer = nullptr;
237
238 switch (btype) {
239
240 // equidistant binning
241 case Trk::equidistant :
242 {
243 // count the layers
244 size_t layers = discLayers.size();
245 // loop over layers and put them in
246 for (Trk::DiscLayer* layIter : discLayers ) {
247 discLayer = checkAndReplaceEmptyLayer(layIter);
248 // get the Z
249 const Trk::Surface& layerSurface = discLayer->surfaceRepresentation();
250 ATH_MSG_VERBOSE( "equidistant : registering disc-like MaterialLayer at z-Position : " << layerSurface.center().z() );
251 layerOrderVector.emplace_back(std::shared_ptr<Layer>(discLayer),
252 layerSurface.center());
253 }
254 // create the binUitlity
255 auto binUtility = Trk::BinUtility(layers,zmin,zmax,Trk::open,Trk::binZ);
256 ATH_MSG_VERBOSE( "equidistant : created a BinUtility as " << binUtility );
257
258 // create the BinnedArray; BinnedArray now owns the binUtility pointer
259 discLayerArray = std::make_unique<Trk::BinnedArray1D<Trk::Layer>>(layerOrderVector, binUtility);
260
261 } break;
262
263 // bi-equidistant binning
264 case Trk::biequidistant :
265 {
266 // count the layers
267 unsigned int layers = discLayers.size();
268 // take a reference layer thickness
269 double layerThickness = discLayers[0]->thickness();
270 ATH_MSG_VERBOSE( "bi-equidistant : zmin / zmax re-evaluated as = " << zmin << " / " << zmax );
271 // the radialstep
272 double zStep = (zmax-zmin)/(layers-1);
273 double minR = 0.;
274 double maxR = 0.;
275
276 Amg::Transform3D navLayerTransform;
277 double navigationZ = 0.;
278 // loop over layers
279 for (auto& layIter : discLayers) {
280 // get the dimensions
281 const Trk::DiscSurface& layerSurface = layIter->surfaceRepresentation();
282 double currentZ = layerSurface.center().z();
283 // create the navigation Z from current Z
284 navigationZ = currentZ - 0.5*(zStep);
285 navLayerTransform = Amg::Transform3D(Amg::Translation3D(0.,0.,navigationZ));
286 auto navLayerSurface = std::make_unique<Trk::DiscSurface>(navLayerTransform, minR, maxR);
287 // push that layer back
288 ATH_MSG_VERBOSE( "bi-equidistant : creating disc-like NavigationLayer at z-Position : " << navigationZ );
289 const Amg::Vector3D center = navLayerSurface->center();
290 layerOrderVector.emplace_back(
291 std::make_shared<Trk::NavigationLayer>(std::move(navLayerSurface)),
292 center);
293 // and get dimensions
294 const Trk::DiscBounds* dbounds = dynamic_cast<const Trk::DiscBounds*>(&(layerSurface.bounds()));
295 if (dbounds) {
296 minR = dbounds->rMin();
297 maxR = dbounds->rMax();
298 } else { // protection
299 minR = 0.;
300 maxR = 100000.;
301 }
302 // get the material layer first
303 ATH_MSG_VERBOSE( "bi-equidistant : registering disc-like MaterialLayer at z-Position : " << currentZ );
304 layerOrderVector.emplace_back(std::shared_ptr<Trk::Layer>(layIter),
305 layerSurface.center());
306 }
307 // special treatment for last bin
308 ATH_MSG_VERBOSE( "bi-equidistant : creating disc-like NavigationLayer at z-Position : " << navigationZ + zStep );
309 navLayerTransform = Amg::Transform3D(Amg::Translation3D(0.,0.,navigationZ+zStep));
310 auto navLayerSurface = std::make_unique<Trk::DiscSurface>(navLayerTransform, minR, maxR);
311 const Amg::Vector3D center = navLayerSurface->center();
312 layerOrderVector.emplace_back(std::make_shared<Trk::NavigationLayer>(std::move(navLayerSurface)),
313 center);
314 // verbose output
315 ATH_MSG_VERBOSE( layerOrderVector.size() << " disc Layers (material + navigation) built. " );
316
317 // create the binUtility
318 double zminBoundary = zmin-zStep+0.5*layerThickness;
319 double zmaxBoundary = zmax+zStep+0.5*layerThickness;
320 auto binUtility = Trk::BinUtility(layers, layerThickness, zminBoundary, zmaxBoundary, Trk::open, Trk::binZ);
321 ATH_MSG_VERBOSE( "bi-equidistant : created a BinUtility as " << binUtility );
322
323 // create the BinnedArray; BinnedArray now owns the binUtility pointer
324 discLayerArray = std::make_unique<Trk::BinnedArray1D<Trk::Layer>>(layerOrderVector, binUtility);
325
326 } break;
327
328 // arbitrary binning
329 case Trk::arbitrary :
330 {
331 std::vector<float> boundaries;
332
333 // max disc dimension
334 double minR = 10e10;
335 double maxR = 0.;
336
337 // initial boundary
338 boundaries.push_back(zmin);
339
340 // loop over the provided layers and put NavigationLayers in between
341 for (auto& layIter : discLayers ) {
342 // get the cylinder surface
343 const Trk::DiscSurface& layerSurface = layIter->surfaceRepresentation();
344 // and get dimensions
345 const Trk::DiscBounds* dbounds = dynamic_cast<const Trk::DiscBounds*>(&(layerSurface.bounds()));
346 if (dbounds) {
347 double layInnerR = dbounds->rMin();
348 double layOuterR = dbounds->rMax();
349 minR = (layInnerR < minR) ? layInnerR : minR;
350 maxR = (layOuterR > maxR) ? layOuterR : maxR;
351 } else { // protection
352 minR = 0.;
353 maxR = 100000.;
354 }
355 // the radius & position
356 double layerPositionZ = layerSurface.center().z();
357 double layerThickness = layIter->thickness();
358 // navigation Layer
359 double navLayerPositionZ = 0.5*((layerPositionZ-0.5*layerThickness)+boundaries[boundaries.size()-1]);
360 // now fill the layer post slot after navigation layer has been determined
361 // the transform for this
362 Amg::Transform3D navLayerTransform = Amg::Transform3D(Amg::Translation3D(0.,0.,navLayerPositionZ));
363 auto navLayerSurface = std::make_unique<Trk::DiscSurface>(navLayerTransform, minR, maxR);
364
365 // the material layer
366 discLayer = checkAndReplaceEmptyLayer(layIter);
367 if (discLayer) {
368 ATH_MSG_VERBOSE( "arbitrary : creating disc-like NavigationLayer at z-Position : " << navLayerPositionZ );
369 layerOrderVector.emplace_back(std::make_shared<Trk::NavigationLayer>(std::move(navLayerSurface)),
370 Amg::Vector3D(0., 0., navLayerPositionZ));
371 ATH_MSG_VERBOSE( "arbitrary : registering disc-like MaterialLayer at z-Position : " << layerPositionZ );
372 layerOrderVector.emplace_back(
373 std::shared_ptr<Trk::Layer>(discLayer),
374 Amg::Vector3D(0.,0., layerPositionZ));
375 boundaries.push_back(layerPositionZ-0.5*layerThickness);
376 boundaries.push_back(layerPositionZ+0.5*layerThickness);
377 } else {
378 ATH_MSG_VERBOSE( "arbitrary : empty layer configuration cancelled this building of navigation layer.");
379 }
380 }
381 // final material layer
382 double navLayerPositionZFinal = 0.5*(zmax+boundaries[boundaries.size()-1]);
383 Amg::Transform3D navLayerTransformFinal = Amg::Transform3D(
384 Amg::Translation3D(0., 0., navLayerPositionZFinal));
385 auto navLayerSurfaceFinal = std::make_unique<Trk::DiscSurface>(navLayerTransformFinal, minR, maxR);
386 ATH_MSG_VERBOSE( "arbitrary : creating disc-like NavigationLayer at z-Position : " << navLayerPositionZFinal );
387 layerOrderVector.emplace_back(std::make_shared<Trk::NavigationLayer>(std::move(navLayerSurfaceFinal)),
388 Amg::Vector3D(0., 0., navLayerPositionZFinal));
389 ATH_MSG_VERBOSE( layerOrderVector.size() << " disc Layers (material + navigation) built. " );
390 // register the last bounday
391 boundaries.push_back(zmax);
392 // create the BinUtility
393 auto binUtility = Trk::BinUtility(boundaries, Trk::open, Trk::binZ);
394 ATH_MSG_VERBOSE( "arbitrary : created a BinUtility as " << binUtility );
395
396 // create the BinnedArray; BinnedArray now owns the binUtility pointer
397 // cppcheck-suppress memleak
398 discLayerArray = std::make_unique<Trk::BinnedArray1D<Trk::Layer>>(layerOrderVector, binUtility);
399
400 } break;
401
402 // default return 0
403 default : { return nullptr; }
404 }
405
406 return discLayerArray;
407}
408
409
410std::unique_ptr<Trk::BinnedArray1D<Trk::Layer>> Trk::LayerArrayCreator::planeLayerArray(
411 const std::vector<Trk::PlaneLayer*>& planeLayersInput,
412 double posmin,
413 double posmax,
414 Trk::BinningType btype,
415 Trk::BinningValue bv) const
416{
417 ATH_MSG_VERBOSE( " build LayerArray with " << planeLayersInput.size() << " plane-like material layers." );
418
419 // needed for all cases
420 std::unique_ptr<Trk::BinnedArray1D<Trk::Layer>> planeLayerArray = nullptr;
421 std::vector< std::pair< std::shared_ptr<Trk::Layer>, Amg::Vector3D> > layerOrderVector;
422 Amg::Vector3D layerCenter(0.,0.,0.);
423
424 //copy so that you can sort
425 std::vector<Trk::PlaneLayer*> planeLayers(planeLayersInput);
426
427 auto sortBegin = planeLayers.begin();
428 auto sortEnd = planeLayers.end();
429 switch (bv) {
430 case Trk::binX : { std::sort(sortBegin, sortEnd, Trk::PlaneLayerSorterX()); } break;
431 case Trk::binY : { std::sort(sortBegin, sortEnd, Trk::PlaneLayerSorterY()); } break;
432 case Trk::binZ : { std::sort(sortBegin, sortEnd, Trk::PlaneLayerSorterZ()); } break;
433 default : {
434 ATH_MSG_WARNING("Plane Layers can only be sorted in x/y/z. Returning 0.");
435 return nullptr;
436 }
437 }
438
439 // the iterator
440 auto layIter = planeLayers.begin();
441
442 switch (btype) {
443
444 // equidistant binning
445 case Trk::equidistant :
446 {
447 // count the layers
448 unsigned int layers = planeLayers.size();
449 // loop over layers and put them in
450 for ( ; layIter != planeLayers.end(); ++layIter) {
451 // get the X
452 const Trk::PlaneSurface& layerSurface = (*layIter)->surfaceRepresentation();
453 ATH_MSG_VERBOSE( "equidistant : registering plane-like MaterialLayer at position : " << layerSurface.center() );
454
455 layerOrderVector.emplace_back(
456 std::shared_ptr<Layer>(*layIter),
457 layerSurface.center());
458 }
459 // create the binUitlity
460 auto binUtility = Trk::BinUtility(layers,posmin,posmax, Trk::open, bv);
461 // create the BinnedArray
462 planeLayerArray = std::make_unique<Trk::BinnedArray1D<Trk::Layer>>(layerOrderVector, binUtility);
463
464 } break;
465
466 // bi-equidistant binning
467 case Trk::biequidistant :
468 {
469 // count the layers
470 unsigned int layers = planeLayers.size();
471 // the x-step
472 double posStep = (posmax-posmin)/(layers+1);
473
474 double currentPos = posmin + posStep;
475 double lastPos = posmin;
476
477 double minHalfX = 0.;
478 double maxHalfX = 0.;
479 double halfY = 0.;
480
481 double layerThickness = 0.;
482
483 // loop over layers
484 for ( ; layIter != planeLayers.end() ; ++layIter) {
485
486 // get the dimensions
487 const Trk::PlaneSurface& layerSurface = (*layIter)->surfaceRepresentation();
488 // get dimensions
489 const Trk::RectangleBounds* recbounds = dynamic_cast<const Trk::RectangleBounds*>(&(layerSurface.bounds()));
490 // try rectangular hypothesis
491 if (recbounds) {
492 maxHalfX = recbounds->halflengthX();
493 halfY = recbounds->halflengthY();
494 } else {
495 // try trapezoidal hypothesis
496 const Trk::TrapezoidBounds* trapbounds = dynamic_cast<const Trk::TrapezoidBounds*>(&(layerSurface.bounds()));
497 if (trapbounds) {
498 minHalfX = trapbounds->minHalflengthX();
499 maxHalfX = trapbounds->maxHalflengthX();
500 halfY = trapbounds->halflengthY();
501 } else {
502 // protection
503 minHalfX = 0.;
504 maxHalfX = 10e10;
505 halfY = 10e10;
506 }
507 }
508
509 layerThickness = ((*layIter)->thickness() > layerThickness ) ? (*layIter)->thickness() : layerThickness;
510
511 // the navigation Layer
512 double navigationPos = 0.5*(currentPos+lastPos);
513 double navigationX = (bv == Trk::binX) ? navigationPos : 0.;
514 double navigationY = (bv == Trk::binY) ? navigationPos : 0.;
515 double navigationZ = (bv == Trk::binZ) ? navigationPos : 0.;
516 Amg::Translation3D(navigationX,navigationY,navigationZ);
517
518 std::unique_ptr<Trk::PlaneSurface> navLayerSurface = nullptr;
519 Amg::Transform3D navLayerTransform(Amg::Translation3D(navigationX,0.,0.));
520
521 if (std::abs(minHalfX)<10e-5) {
522 navLayerSurface = std::make_unique<Trk::PlaneSurface>(navLayerTransform,
523 maxHalfX,
524 halfY);
525 } else {
526 navLayerSurface = std::make_unique<Trk::PlaneSurface>(navLayerTransform,
527 minHalfX,
528 maxHalfX,
529 halfY);
530 }
531
532 ATH_MSG_VERBOSE( "bi-equidistant : creating plane-like NavigationLayer at position : " << navigationX );
533
534 layerOrderVector.emplace_back(std::make_shared<Trk::NavigationLayer>(std::move(navLayerSurface)),
535 Amg::Vector3D(navigationX, 0.,0.));
536 // restore
537 lastPos = currentPos;
538 // the material Layer
539
540 ATH_MSG_VERBOSE( "bi-equidistant : registering plane-like MaterialLayer at position : " << currentPos );
541 layerOrderVector.emplace_back(
542 std::shared_ptr<Trk::Layer>(*layIter),
543 layerSurface.center());
544
545 // increase the Step
546 currentPos += posStep;
547 }
548
549 // the final navigation layer
550 double navigationPosFinal = 0.5*(currentPos+lastPos);
551 double navigationXFinal = (bv == Trk::binX) ? navigationPosFinal : 0.;
552 double navigationYFinal = (bv == Trk::binY) ? navigationPosFinal : 0.;
553 double navigationZFinal = (bv == Trk::binZ) ? navigationPosFinal : 0.;
554
555 Amg::Transform3D navLayerTransform(Amg::Translation3D(navigationXFinal,navigationYFinal,navigationZFinal));
556
557 auto navLayerSurface = (std::abs(minHalfX)<10e-5) ?
558 std::make_unique<Trk::PlaneSurface>(navLayerTransform, maxHalfX,halfY) :
559 std::make_unique<Trk::PlaneSurface>(navLayerTransform, minHalfX, maxHalfX, halfY);
560
561 ATH_MSG_VERBOSE( "bi-equidistant : creating plane-like NavigationLayer at position : " << navLayerSurface->center() );
562 const Amg::Vector3D center = navLayerSurface->center();
563 layerOrderVector.emplace_back(std::make_shared<Trk::NavigationLayer>(std::move(navLayerSurface)),
564 center);
565
566 // create the binUtility
567 auto binUtility = Trk::BinUtility(layers, layerThickness, posmin, posmax, Trk::open, bv);
568
569 // create the BinnedArray
570 planeLayerArray = std::make_unique<Trk::BinnedArray1D<Trk::Layer>>(layerOrderVector, binUtility);
571
572 } break;
573
574 // arbitrary binning
575 case Trk::arbitrary :
576 {
577
578 std::vector<float> boundaries;
579 boundaries.push_back(posmin);
580 // max plane dimension
581 double minHalfX = 0.;
582 double maxHalfX = 0.;
583 double halfY = 0.;
584
585 // loop over the layers and register navigation layers in between
586 for ( ; layIter != planeLayers.end(); ++layIter) {
587
588 // get the cylinder surface
589 const Trk::PlaneSurface& layerSurface = (*layIter)->surfaceRepresentation();
590 // get dimensions
591 const Trk::RectangleBounds* recbounds = dynamic_cast<const Trk::RectangleBounds*>(&(layerSurface.bounds()));
592 // try rectangular hypothesis
593 if (recbounds) {
594 maxHalfX = recbounds->halflengthX();
595 halfY = recbounds->halflengthY();
596 } else {
597 // try trapezoidal hypothesis
598 const Trk::TrapezoidBounds* trapbounds = dynamic_cast<const Trk::TrapezoidBounds*>(&(layerSurface.bounds()));
599 if (trapbounds) {
600 minHalfX = trapbounds->minHalflengthX();
601 maxHalfX = trapbounds->maxHalflengthX();
602 halfY = trapbounds->halflengthY();
603 } else {
604 // protection
605 minHalfX = 0.;
606 maxHalfX = 10e10;
607 halfY = 10e10;
608 }
609 }
610 // the x position
611 // and get dimensions
612 layerCenter = layerSurface.center();
613 double layerPosition = layerCenter[bv];
614 // get the thickness
615 double layerThickness = (*layIter)->thickness();
616 // register
617 boundaries.push_back(layerPosition-0.5*layerThickness);
618 double navLayerPositionX = (bv == Trk::binX) ? 0.5*(layerPosition+boundaries[boundaries.size()-1]) : layerCenter.x();
619 double navLayerPositionY = (bv == Trk::binY) ? 0.5*(layerPosition+boundaries[boundaries.size()-1]) : layerCenter.y();
620 double navLayerPositionZ = (bv == Trk::binZ) ? 0.5*(layerPosition+boundaries[boundaries.size()-1]) : layerCenter.z();
621 Amg::Translation3D navLayerPosition(navLayerPositionX,navLayerPositionY,navLayerPositionZ);
622 Amg::Transform3D navLayerTransform(navLayerPosition);
623 // create the navigation plane layer
624 auto navLayerSurface = (std::abs(minHalfX)<10e-5) ?
625 std::make_unique<Trk::PlaneSurface>( navLayerTransform, maxHalfX, halfY ) :
626 std::make_unique<Trk::PlaneSurface>( navLayerTransform, minHalfX, maxHalfX, halfY );
627 ATH_MSG_VERBOSE( "arbitrary : creating plane-like NavigationLayer at position : " << navLayerPositionX );
628 layerOrderVector.emplace_back(
629 std::make_shared<Trk::NavigationLayer>(std::move(navLayerSurface)),
630 Amg::Vector3D(navLayerPositionX, navLayerPositionY, navLayerPositionZ));
631 // register the material layer
632 boundaries.push_back(layerPosition+0.5*layerThickness);
633 // material layer
634 layerOrderVector.emplace_back(
635 std::shared_ptr<Trk::Layer>(*layIter),
636 layerSurface.center());
637
638 }
639 // last NavigationLayer
640 double navLayerPositionXFinal = (bv == Trk::binX) ? 0.5*(posmax+boundaries[boundaries.size()-1]) : layerCenter.x();
641 double navLayerPositionYFinal = (bv == Trk::binY) ? 0.5*(posmax+boundaries[boundaries.size()-1]) : layerCenter.y();
642 double navLayerPositionZFinal = (bv == Trk::binZ) ? 0.5*(posmax+boundaries[boundaries.size()-1]) : layerCenter.z();
643 Amg::Translation3D navLayerPositionFinal(navLayerPositionXFinal,navLayerPositionYFinal,navLayerPositionZFinal);
644 Amg::Transform3D navLayerTransformFinal(navLayerPositionFinal);
645 // create the navigation plane layer
646 auto navLayerSurfaceFinal = (std::abs(minHalfX)<10e-5) ?
647 std::make_unique<Trk::PlaneSurface>( navLayerTransformFinal, maxHalfX, halfY ) :
648 std::make_unique<Trk::PlaneSurface>( navLayerTransformFinal, minHalfX, maxHalfX, halfY );
649 ATH_MSG_VERBOSE( "arbitrary : creating plane-like NavigationLayer at position : " << 0.5*(posmax+boundaries[boundaries.size()-1]) );
650 layerOrderVector.emplace_back(std::make_shared<Trk::NavigationLayer>(std::move(navLayerSurfaceFinal)),
651 Amg::Vector3D(navLayerPositionXFinal, navLayerPositionYFinal, navLayerPositionZFinal));
652
653 ATH_MSG_VERBOSE( layerOrderVector.size() << " plane Layers (material + navigation) built. " );
654
655 // create the BinUtility
656 auto binUtility = Trk::BinUtility(boundaries, Trk::open, bv);
657 // and the BinnedArray
658 planeLayerArray = std::make_unique<Trk::BinnedArray1D<Trk::Layer>>(layerOrderVector, binUtility);
659
660 } break;
661 // default return 0
662 default : { return nullptr; }
663 }
664
665 return planeLayerArray;
666 //cppcheck-suppress memleak
667}
668
670 // empty layers will be replaced by navigation layers
671 if (m_emptyLayerMode){
672 if (lay->layerMaterialProperties() || lay->surfaceArray()) return lay;
674 " replacing dummyMaterial layer with "
675 << (m_emptyLayerMode > 1 ? " nothing" : " NavigationLayer."));
676 Trk::NavigationLayer* nLayer =
678 ? nullptr
681 delete lay;
682 return nLayer;
683 }
684 // don't replace - just give back what you had
685 return lay;
686}
687
688
689
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define takeBigger(current, test)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
A generic symmetric BinUtility, for fully symmetric binning in terms of binning grid and binning type...
Definition BinUtility.h:39
virtual double r() const override final
This method returns the radius.
double halflengthZ() const
This method returns the halflengthZ.
Functor for CylinderLayer R-Sorting.
Class for a CylinderSurface in the ATLAS detector.
virtual const CylinderBounds & bounds() const override final
This method returns the CylinderBounds by reference (NoBounds is not possible for cylinder).
Class to describe the bounds for a planar DiscSurface.
Definition DiscBounds.h:44
double rMax() const
This method returns outer radius.
double rMin() const
This method returns inner radius.
simple helper function to allow sorting of DiscLayers in z
Definition DiscLayer.h:152
Class to describe a disc-like detector layer for tracking, it inhertis from both, Layer base class an...
Definition DiscLayer.h:45
Class for a DiscSurface in the ATLAS detector.
Definition DiscSurface.h:54
const SurfaceBounds & bounds() const override final
This method returns the bounds by reference.
std::unique_ptr< Trk::BinnedArray1D< Layer > > cylinderLayerArray(const std::vector< CylinderLayer * > &layers, double rmin, double rmax, BinningType btype=arbitrary) const
LayerArrayCreator interface method - for Barrel-like layers.
std::unique_ptr< Trk::BinnedArray1D< Layer > > discLayerArray(const std::vector< DiscLayer * > &layers, double zmin, double zmax, BinningType btype=arbitrary) const
LayerArrayCreator interface method - for Endcap-like layers.
LayerArrayCreator(const std::string &, const std::string &, const IInterface *)
Constructor.
Trk::Layer * checkAndReplaceEmptyLayer(Trk::Layer *lay) const
Gaudi::Property< int > m_emptyLayerMode
std::unique_ptr< Trk::BinnedArray1D< Layer > > planeLayerArray(const std::vector< PlaneLayer * > &layers, double min, double max, BinningType btype=arbitrary, Trk::BinningValue bv=Trk::binX) const
LayerArrayCreator interface method - for Planar-like layers.
Base Class for a Detector Layer in the Tracking realm.
Definition Layer.h:72
virtual const Surface & surfaceRepresentation() const =0
Transforms the layer into a Surface representation for extrapolation.
const SurfaceArray * surfaceArray() const
Return the entire SurfaceArray, returns nullptr if no SurfaceArray.
const LayerMaterialProperties * layerMaterialProperties() const
getting the LayerMaterialProperties including full/pre/post update
Class to be used for gaps in Volumes as a navigational link.
Functor for PlaneLayer X-Sorting.
Definition PlaneLayer.h:116
Functor for PlaneLayer Y-Sorting.
Definition PlaneLayer.h:129
Functor for PlaneLayer Z-Sorting.
Definition PlaneLayer.h:142
Class for a planaer rectangular or trapezoidal surface in the ATLAS detector.
virtual const SurfaceBounds & bounds() const override final
This method returns the bounds by reference, static NoBounds in case of no boundaries.
Bounds for a rectangular, planar surface.
double halflengthX() const
for consistant naming
double halflengthY() const
for consitant naming
Abstract Base Class for tracking surfaces.
Definition Surface.h:79
const Amg::Transform3D & transform() const
Returns HepGeom::Transform3D by reference.
const Amg::Vector3D & center() const
Returns the center position of the Surface.
std::unique_ptr< Surface > uniqueClone() const
NVI method returning unique_ptr clone.
Bounds for a trapezoidal, planar Surface.
double halflengthY() const
This method returns the halflength in Y (second coordinate of local surface frame).
double minHalflengthX() const
This method returns the minimal halflength in X (first coordinate of local surface frame).
double maxHalflengthX() const
This method returns the maximal halflength in X (first coordinate of local surface frame).
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
Eigen::Translation< double, 3 > Translation3D
@ open
Definition BinningType.h:40
BinningType
, BinningOption & BinningAccess
Definition BinningType.h:31
@ biequidistant
Definition BinningType.h:33
@ equidistant
Definition BinningType.h:32
@ arbitrary
Definition BinningType.h:34
BinningValue
how to take the global / local position
Definition BinningType.h:46
@ binR
Definition BinningType.h:50
@ binX
Definition BinningType.h:47
@ binZ
Definition BinningType.h:49
@ binY
Definition BinningType.h:48
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.