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