ATLAS Offline Software
LayerArrayCreator.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 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  Trk::BinUtility* binUtility = nullptr;
58  std::vector< std::pair<Trk::SharedObject<Trk::Layer>, Amg::Vector3D> > layerOrderVector;
59 
60  switch (btype) {
61 
62  // equidistant binning - no navigation layers built
63  case Trk::equidistant :
64  {
65  // count the layers
66  unsigned int layers = cylLayers.size();
67  // loop over layers and put them in
68  for (auto& layIter : cylLayers ) {
69  // get the R
70  const Trk::CylinderSurface& layerSurface = layIter->surfaceRepresentation();
71  double currentR = layerSurface.bounds().r();
72  ATH_MSG_VERBOSE( "equidistant : registering cylindrical MaterialLayer at radius : " << currentR );
73  layerOrderVector.emplace_back(Trk::SharedObject<Layer>(layIter),
74  Amg::Vector3D(currentR, 0.,0.));
75  }
76  // create the binUtility
77  binUtility = new Trk::BinUtility(layers,rmin,rmax,Trk::open, Trk::binR);
78  ATH_MSG_VERBOSE( "equidistant : created a BinUtility as " << *binUtility );
79 
80  // create the BinnedArray; BinnedArray now owns the binUtility pointer
81  cylinderLayerArray = new Trk::BinnedArray1D<Trk::Layer>(layerOrderVector, binUtility);
82  } break;
83 
84  // bi-equidistant binning - take care the layers have to be binned equidistant + same thickness
85  case Trk::biequidistant :
86  {
87 
88  // count the layers
89  unsigned int layers = cylLayers.size();
90  // take a reference thinkness
91  double layerThickness = cylLayers[0]->thickness();
92  // the radialstep
93  double radialStep = (rmax-rmin)/(layers-1);
94  // the next step
95  Trk::NavigationLayer* navLayer = nullptr;
96  double navigationR = 0.;
97  double navLayerHalflengthZ = 0.;
98  const Amg::Transform3D* layerTransform = nullptr;
99 
100  // loop over layers
101  for (auto& layIter : cylLayers ) {
102  // get the dimensions
103  const Trk::CylinderSurface& layerSurface = layIter->surfaceRepresentation();
104  layerTransform = layerSurface.transform().isApprox(Amg::Transform3D::Identity()) ? nullptr : &layerSurface.transform();
105 
106  double currentR = layerSurface.bounds().r();
107  navigationR = currentR - 0.5*radialStep;
108 
109  navLayerHalflengthZ = layerSurface.bounds().halflengthZ();
110  ATH_MSG_VERBOSE( "bi-equidistant : creating cylindrical NavigationLayer at radius : " << navigationR );
111  Trk::CylinderSurface* navLayerSurface = layerTransform ?
112  new Trk::CylinderSurface(Amg::Transform3D(*layerTransform), navigationR, navLayerHalflengthZ) :
113  new Trk::CylinderSurface(navigationR, navLayerHalflengthZ);
114  // the navigation layer
115  navLayer = new Trk::NavigationLayer(navLayerSurface);
116  // push the navigation layer in
117  layerOrderVector.emplace_back(Trk::SharedObject<Trk::Layer>(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(Trk::SharedObject<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  Trk::CylinderSurface* navLayerSurfacFinal = layerTransform ?
128  new Trk::CylinderSurface(Amg::Transform3D(*layerTransform), navigationR+radialStep, navLayerHalflengthZ) :
129  new Trk::CylinderSurface(navigationR+radialStep, navLayerHalflengthZ);
130  // the navigation layer
131  navLayer = new Trk::NavigationLayer(navLayerSurfacFinal);
132  // push the navigation layer in
133  layerOrderVector.emplace_back(Trk::SharedObject<Trk::Layer>(navLayer),
134  Amg::Vector3D(navigationR+radialStep, 0., 0.));
135 
136  ATH_MSG_VERBOSE( layerOrderVector.size() << " cylindrical Layers (material + navigation) built. " );
137 
138  // create the binUtility
139  double rMinBoundary = rmin-radialStep+0.5*layerThickness;
140  double rMaxBoundary = rmax+radialStep+0.5*layerThickness;
141  binUtility = new Trk::BinUtility(layers, layerThickness, rMinBoundary, rMaxBoundary, Trk::open, Trk::binR);
142  ATH_MSG_VERBOSE( "bi-equidistant : created a BinUtility as " << *binUtility );
143 
144  // create the BinnedArray; BinnedArray now owns the binUtility pointer
145  cylinderLayerArray = new Trk::BinnedArray1D<Trk::Layer>(layerOrderVector, binUtility);
146 
147  } break;
148 
149  // arbitrary binning
150  case Trk::arbitrary :
151  {
152  std::vector<float> boundaries;
153  // maz z extension
154  double halfLengthZ = 0;
155  const Amg::Transform3D* layerTransform = nullptr;
156 
157  // initial step
158  boundaries.push_back(rmin);
159 
160  // loop over the provided layers and put Navigation layers in between
161  for (auto& layIter : cylLayers) {
162  // get the cylinder surface
163  const Trk::CylinderSurface& layerSurface = layIter->surfaceRepresentation();
164  layerTransform = layerSurface.transform().isApprox(Amg::Transform3D::Identity()) ? nullptr : &layerSurface.transform();
165  // and get the halflength
166  double currentHalfLengthZ = layerSurface.bounds().halflengthZ();
167  takeBigger(halfLengthZ, currentHalfLengthZ);
168  double layerRadius = layerSurface.bounds().r();
169  double layerThickness = layIter->thickness();
170  // navigation layer : previous bin
171  double navLayerRadius = 0.5*( (layerRadius-0.5*layerThickness) + boundaries[boundaries.size()-1] );
172  Trk::CylinderSurface* navLayerSurface = layerTransform ?
173  new Trk::CylinderSurface(Amg::Transform3D(*layerTransform), navLayerRadius, halfLengthZ) :
174  new Trk::CylinderSurface(navLayerRadius, halfLengthZ);
175  // material layer : current bin
176  cylinderLayer = checkAndReplaceEmptyLayer(layIter);
177  if (cylinderLayer){
178  ATH_MSG_VERBOSE( "arbitrary : creating cylindrical NavigationLayer at radius : " << navLayerRadius );
179  layerOrderVector.emplace_back(
181  Amg::Vector3D(navLayerRadius, 0., 0.));
182  ATH_MSG_VERBOSE( "arbitrary : registering cylindrical MaterialLayer at radius :" << layerRadius );
183  layerOrderVector.emplace_back(
184  Trk::SharedObject<Trk::Layer>(cylinderLayer),
185  Amg::Vector3D(layerRadius, 0.,0.));
186  boundaries.push_back(layerRadius-0.5*layerThickness);
187  boundaries.push_back(layerRadius+0.5*layerThickness);
188  } else {
189  ATH_MSG_VERBOSE( "arbitrary : empty layer configuration cancelled this building of navigation layer.");
190  delete navLayerSurface;
191  }
192  }
193  // close up the array with last bin
194  double navLayerRadiusFinal = 0.5*(rmax+boundaries[boundaries.size()-1]);
195  Trk::CylinderSurface* navLayerSurfaceFinal = layerTransform ?
196  new Trk::CylinderSurface(Amg::Transform3D(*layerTransform), navLayerRadiusFinal, halfLengthZ) :
197  new Trk::CylinderSurface(navLayerRadiusFinal, halfLengthZ);
198  boundaries.push_back(rmax);
199  ATH_MSG_VERBOSE( "arbitrary : creating cylindrical NavigationLayer at radius : " << navLayerRadiusFinal );
200  layerOrderVector.emplace_back(
201  Trk::SharedObject<Trk::Layer>(new Trk::NavigationLayer(navLayerSurfaceFinal)),
202  Amg::Vector3D(navLayerRadiusFinal, 0., 0.));
203 
204  ATH_MSG_VERBOSE( layerOrderVector.size() << " cylindrical Layers (material + navigation) built. " );
205  // create the BinUtility
206  binUtility = new Trk::BinUtility(boundaries, Trk::open, Trk::binR);
207  ATH_MSG_VERBOSE( "arbitrary : created a BinUtility as " << *binUtility );
208 
209  // create the BinnedArray; BinnedArray now owns the binUtility pointer
210  cylinderLayerArray = new Trk::BinnedArray1D<Trk::Layer>(layerOrderVector, binUtility);
211 
212  } break;
213 
214  // default return 0
215  default : { return nullptr; }
216  }
217 
218  return cylinderLayerArray;
219 }
220 
221 
222 Trk::LayerArray* Trk::LayerArrayCreator::discLayerArray(const std::vector<Trk::DiscLayer*>& discLayersInput,
223  double zmin,
224  double zmax,
225  Trk::BinningType btype) const
226 {
227 
228  ATH_MSG_VERBOSE( " build LayerArray with " << discLayersInput.size() << " disc-like material layers." );
229  ATH_MSG_VERBOSE( " zmin/zmax provided : " << zmin << " / " << zmax );
230 
231  // needed for all cases
232  Trk::LayerArray* discLayerArray = nullptr;
233  Trk::BinUtility* binUtility = nullptr;
234  std::vector<std::pair<Trk::SharedObject<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(Trk::SharedObject<Layer>(discLayer),
258  layerSurface.center());
259  }
260  // create the binUitlity
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  Trk::DiscSurface* navLayerSurface = nullptr;
284  double navigationZ = 0.;
285  // loop over layers
286  for (auto& layIter : discLayers) {
287  // get the dimensions
288  const Trk::DiscSurface& layerSurface = layIter->surfaceRepresentation();
289  double currentZ = layerSurface.center().z();
290  // create the navigation Z from current Z
291  navigationZ = currentZ - 0.5*(zStep);
292  navLayerTransform = Amg::Transform3D(Amg::Translation3D(0.,0.,navigationZ));
293  navLayerSurface = new Trk::DiscSurface(navLayerTransform, minR, maxR);
294  // push that layer back
295  ATH_MSG_VERBOSE( "bi-equidistant : creating disc-like NavigationLayer at z-Position : " << navigationZ );
296  layerOrderVector.emplace_back(
298  navLayerSurface->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(Trk::SharedObject<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  navLayerSurface = new Trk::DiscSurface(navLayerTransform, minR, maxR);
317  layerOrderVector.emplace_back(
319  navLayerSurface->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  binUtility = new 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  Trk::DiscSurface* navLayerSurface = new 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(
377  Amg::Vector3D(0., 0., navLayerPositionZ));
378  ATH_MSG_VERBOSE( "arbitrary : registering disc-like MaterialLayer at z-Position : " << layerPositionZ );
379  layerOrderVector.emplace_back(
381  Amg::Vector3D(0.,0., layerPositionZ));
382  boundaries.push_back(layerPositionZ-0.5*layerThickness);
383  boundaries.push_back(layerPositionZ+0.5*layerThickness);
384  } else {
385  ATH_MSG_VERBOSE( "arbitrary : empty layer configuration cancelled this building of navigation layer.");
386  delete navLayerSurface;
387  }
388  }
389  // final material layer
390  double navLayerPositionZFinal = 0.5*(zmax+boundaries[boundaries.size()-1]);
391  Amg::Transform3D navLayerTransformFinal = Amg::Transform3D(
392  Amg::Translation3D(0., 0., navLayerPositionZFinal));
393  Trk::DiscSurface* navLayerSurfaceFinal =
394  new Trk::DiscSurface(navLayerTransformFinal, minR, maxR);
395  ATH_MSG_VERBOSE( "arbitrary : creating disc-like NavigationLayer at z-Position : " << navLayerPositionZFinal );
396  layerOrderVector.emplace_back(
397  Trk::SharedObject<Trk::Layer>(new Trk::NavigationLayer(navLayerSurfaceFinal)),
398  Amg::Vector3D(0., 0., navLayerPositionZFinal));
399  ATH_MSG_VERBOSE( layerOrderVector.size() << " disc Layers (material + navigation) built. " );
400  // register the last bounday
401  boundaries.push_back(zmax);
402  // create the BinUtility
403  binUtility = new Trk::BinUtility(boundaries, Trk::open, Trk::binZ);
404  ATH_MSG_VERBOSE( "arbitrary : created a BinUtility as " << *binUtility );
405 
406  // create the BinnedArray; BinnedArray now owns the binUtility pointer
407  // cppcheck-suppress memleak
408  discLayerArray = new Trk::BinnedArray1D<Trk::Layer>(layerOrderVector, binUtility);
409 
410  } break;
411 
412  // default return 0
413  default : { return nullptr; }
414  }
415 
416  return discLayerArray;
417 }
418 
419 
420 Trk::LayerArray* Trk::LayerArrayCreator::planeLayerArray(const std::vector<Trk::PlaneLayer*>& planeLayersInput,
421  double posmin, double posmax, Trk::BinningType btype, Trk::BinningValue bv) const
422 {
423  ATH_MSG_VERBOSE( " build LayerArray with " << planeLayersInput.size() << " plane-like material layers." );
424 
425  // needed for all cases
426  Trk::LayerArray* planeLayerArray = nullptr;
427  Trk::BinUtility* binUtility = nullptr;
428  std::vector< std::pair< Trk::SharedObject<Trk::Layer>, Amg::Vector3D> > layerOrderVector;
429  Amg::Vector3D layerCenter(0.,0.,0.);
430 
431  //copy so that you can sort
432  std::vector<Trk::PlaneLayer*> planeLayers(planeLayersInput);
433 
434  auto sortBegin = planeLayers.begin();
435  auto sortEnd = planeLayers.end();
436  switch (bv) {
437  case Trk::binX : { std::sort(sortBegin, sortEnd, Trk::PlaneLayerSorterX()); } break;
438  case Trk::binY : { std::sort(sortBegin, sortEnd, Trk::PlaneLayerSorterY()); } break;
439  case Trk::binZ : { std::sort(sortBegin, sortEnd, Trk::PlaneLayerSorterZ()); } break;
440  default : {
441  ATH_MSG_WARNING("Plane Layers can only be sorted in x/y/z. Returning 0.");
442  return nullptr;
443  }
444  }
445 
446  // the iterator
447  auto layIter = planeLayers.begin();
448 
449  switch (btype) {
450 
451  // equidistant binning
452  case Trk::equidistant :
453  {
454  // count the layers
455  unsigned int layers = planeLayers.size();
456  // loop over layers and put them in
457  for ( ; layIter != planeLayers.end(); ++layIter) {
458  // get the X
459  const Trk::PlaneSurface& layerSurface = (*layIter)->surfaceRepresentation();
460  ATH_MSG_VERBOSE( "equidistant : registering plane-like MaterialLayer at position : " << layerSurface.center() );
461 
462  layerOrderVector.emplace_back(
463  Trk::SharedObject<Layer>(*layIter),
464  layerSurface.center());
465  }
466  // create the binUitlity
467  binUtility = new Trk::BinUtility(layers,posmin,posmax, Trk::open, bv);
468  // create the BinnedArray
469  planeLayerArray = new Trk::BinnedArray1D<Trk::Layer>(layerOrderVector, binUtility);
470 
471  } break;
472 
473  // bi-equidistant binning
474  case Trk::biequidistant :
475  {
476  // count the layers
477  unsigned int layers = planeLayers.size();
478  // the x-step
479  double posStep = (posmax-posmin)/(layers+1);
480 
481  double currentPos = posmin + posStep;
482  double lastPos = posmin;
483 
484  double minHalfX = 0.;
485  double maxHalfX = 0.;
486  double halfY = 0.;
487 
488  double layerThickness = 0.;
489 
490  // loop over layers
491  for ( ; layIter != planeLayers.end() ; ++layIter) {
492 
493  // get the dimensions
494  const Trk::PlaneSurface& layerSurface = (*layIter)->surfaceRepresentation();
495  // get dimensions
496  const Trk::RectangleBounds* recbounds = dynamic_cast<const Trk::RectangleBounds*>(&(layerSurface.bounds()));
497  // try rectangular hypothesis
498  if (recbounds) {
499  maxHalfX = recbounds->halflengthX();
500  halfY = recbounds->halflengthY();
501  } else {
502  // try trapezoidal hypothesis
503  const Trk::TrapezoidBounds* trapbounds = dynamic_cast<const Trk::TrapezoidBounds*>(&(layerSurface.bounds()));
504  if (trapbounds) {
505  minHalfX = trapbounds->minHalflengthX();
506  maxHalfX = trapbounds->maxHalflengthX();
507  halfY = trapbounds->halflengthY();
508  } else {
509  // protection
510  minHalfX = 0.;
511  maxHalfX = 10e10;
512  halfY = 10e10;
513  }
514  }
515 
516  layerThickness = ((*layIter)->thickness() > layerThickness ) ? (*layIter)->thickness() : layerThickness;
517 
518  // the navigation Layer
519  double navigationPos = 0.5*(currentPos+lastPos);
520  double navigationX = (bv == Trk::binX) ? navigationPos : 0.;
521  double navigationY = (bv == Trk::binY) ? navigationPos : 0.;
522  double navigationZ = (bv == Trk::binZ) ? navigationPos : 0.;
523  Amg::Translation3D(navigationX,navigationY,navigationZ);
524 
525  Trk::PlaneSurface* navLayerSurface = nullptr;
526  Amg::Transform3D navLayerTransform(Amg::Translation3D(navigationX,0.,0.));
527 
528  if (std::abs(minHalfX)<10e-5) {
529  navLayerSurface = new Trk::PlaneSurface(navLayerTransform,
530  maxHalfX,
531  halfY);
532  } else {
533  navLayerSurface = new Trk::PlaneSurface(navLayerTransform,
534  minHalfX,
535  maxHalfX,
536  halfY);
537  }
538 
539  ATH_MSG_VERBOSE( "bi-equidistant : creating plane-like NavigationLayer at position : " << navigationX );
540 
541  layerOrderVector.emplace_back(
543  Amg::Vector3D(navigationX, 0.,0.));
544  // restore
545  lastPos = currentPos;
546  // the material Layer
547 
548  ATH_MSG_VERBOSE( "bi-equidistant : registering plane-like MaterialLayer at position : " << currentPos );
549  layerOrderVector.emplace_back(
551  layerSurface.center());
552 
553  // increase the Step
554  currentPos += posStep;
555  }
556 
557  // the final navigation layer
558  double navigationPosFinal = 0.5*(currentPos+lastPos);
559  double navigationXFinal = (bv == Trk::binX) ? navigationPosFinal : 0.;
560  double navigationYFinal = (bv == Trk::binY) ? navigationPosFinal : 0.;
561  double navigationZFinal = (bv == Trk::binZ) ? navigationPosFinal : 0.;
562 
563  Amg::Transform3D navLayerTransform(Amg::Translation3D(navigationXFinal,navigationYFinal,navigationZFinal));
564 
565  Trk::PlaneSurface* navLayerSurface = (std::abs(minHalfX)<10e-5) ?
566  new Trk::PlaneSurface(navLayerTransform, maxHalfX,halfY) :
567  new Trk::PlaneSurface(navLayerTransform, minHalfX, maxHalfX, halfY);
568 
569  ATH_MSG_VERBOSE( "bi-equidistant : creating plane-like NavigationLayer at position : " << navLayerSurface->center() );
570 
571  layerOrderVector.emplace_back(
573  navLayerSurface->center() );
574 
575  // create the binUtility
576  binUtility = new Trk::BinUtility(layers, layerThickness, posmin, posmax, Trk::open, bv);
577 
578  // create the BinnedArray
579  planeLayerArray = new Trk::BinnedArray1D<Trk::Layer>(layerOrderVector, binUtility);
580 
581  } break;
582 
583  // arbitrary binning
584  case Trk::arbitrary :
585  {
586 
587  std::vector<float> boundaries;
588  boundaries.push_back(posmin);
589  // max plane dimension
590  double minHalfX = 0.;
591  double maxHalfX = 0.;
592  double halfY = 0.;
593 
594  // loop over the layers and register navigation layers in between
595  for ( ; layIter != planeLayers.end(); ++layIter) {
596 
597  // get the cylinder surface
598  const Trk::PlaneSurface& layerSurface = (*layIter)->surfaceRepresentation();
599  // get dimensions
600  const Trk::RectangleBounds* recbounds = dynamic_cast<const Trk::RectangleBounds*>(&(layerSurface.bounds()));
601  // try rectangular hypothesis
602  if (recbounds) {
603  maxHalfX = recbounds->halflengthX();
604  halfY = recbounds->halflengthY();
605  } else {
606  // try trapezoidal hypothesis
607  const Trk::TrapezoidBounds* trapbounds = dynamic_cast<const Trk::TrapezoidBounds*>(&(layerSurface.bounds()));
608  if (trapbounds) {
609  minHalfX = trapbounds->minHalflengthX();
610  maxHalfX = trapbounds->maxHalflengthX();
611  halfY = trapbounds->halflengthY();
612  } else {
613  // protection
614  minHalfX = 0.;
615  maxHalfX = 10e10;
616  halfY = 10e10;
617  }
618  }
619  // the x position
620  // and get dimensions
621  layerCenter = layerSurface.center();
622  double layerPosition = layerCenter[bv];
623  // get the thickness
624  double layerThickness = (*layIter)->thickness();
625  // register
626  boundaries.push_back(layerPosition-0.5*layerThickness);
627  double navLayerPositionX = (bv == Trk::binX) ? 0.5*(layerPosition+boundaries[boundaries.size()-1]) : layerCenter.x();
628  double navLayerPositionY = (bv == Trk::binY) ? 0.5*(layerPosition+boundaries[boundaries.size()-1]) : layerCenter.y();
629  double navLayerPositionZ = (bv == Trk::binZ) ? 0.5*(layerPosition+boundaries[boundaries.size()-1]) : layerCenter.z();
630  Amg::Translation3D navLayerPosition(navLayerPositionX,navLayerPositionY,navLayerPositionZ);
631  Amg::Transform3D navLayerTransform(navLayerPosition);
632  // create the navigation plane layer
633  Trk::PlaneSurface* navLayerSurface = (std::abs(minHalfX)<10e-5) ?
634  new Trk::PlaneSurface( navLayerTransform, maxHalfX, halfY ) :
635  new Trk::PlaneSurface( navLayerTransform, minHalfX, maxHalfX, halfY );
636  ATH_MSG_VERBOSE( "arbitrary : creating plane-like NavigationLayer at position : " << navLayerPositionX );
637  layerOrderVector.emplace_back(
639  Amg::Vector3D(navLayerPositionX, navLayerPositionY, navLayerPositionZ));
640  // register the material layer
641  boundaries.push_back(layerPosition+0.5*layerThickness);
642  // material layer
643  layerOrderVector.emplace_back(
645  layerSurface.center());
646 
647  }
648  // last NavigationLayer
649  double navLayerPositionXFinal = (bv == Trk::binX) ? 0.5*(posmax+boundaries[boundaries.size()-1]) : layerCenter.x();
650  double navLayerPositionYFinal = (bv == Trk::binY) ? 0.5*(posmax+boundaries[boundaries.size()-1]) : layerCenter.y();
651  double navLayerPositionZFinal = (bv == Trk::binZ) ? 0.5*(posmax+boundaries[boundaries.size()-1]) : layerCenter.z();
652  Amg::Translation3D navLayerPositionFinal(navLayerPositionXFinal,navLayerPositionYFinal,navLayerPositionZFinal);
653  Amg::Transform3D navLayerTransformFinal(navLayerPositionFinal);
654  // create the navigation plane layer
655  Trk::PlaneSurface* navLayerSurfaceFinal = (std::abs(minHalfX)<10e-5) ?
656  new Trk::PlaneSurface( navLayerTransformFinal, maxHalfX, halfY ) :
657  new Trk::PlaneSurface( navLayerTransformFinal, minHalfX, maxHalfX, halfY );
658  ATH_MSG_VERBOSE( "arbitrary : creating plane-like NavigationLayer at position : " << 0.5*(posmax+boundaries[boundaries.size()-1]) );
659  layerOrderVector.emplace_back(
660  Trk::SharedObject<Trk::Layer>(new Trk::NavigationLayer(navLayerSurfaceFinal)),
661  Amg::Vector3D(navLayerPositionXFinal, navLayerPositionYFinal, navLayerPositionZFinal));
662 
663  ATH_MSG_VERBOSE( layerOrderVector.size() << " plane Layers (material + navigation) built. " );
664 
665  // create the BinUtility
666  binUtility = new Trk::BinUtility(boundaries, Trk::open, bv);
667  // and the BinnedArray
668  planeLayerArray = new Trk::BinnedArray1D<Trk::Layer>(layerOrderVector, binUtility);
669 
670  } break;
671  // default return 0
672  default : { return nullptr; }
673  }
674 
675  return planeLayerArray;
676  //cppcheck-suppress memleak
677 }
678 
680  // empty layers will be replaced by navigation layers
681  if (m_emptyLayerMode){
682  if (lay->layerMaterialProperties() || lay->surfaceArray()) return lay;
683  ATH_MSG_VERBOSE(" replacing dummyMaterial layer with " << ( m_emptyLayerMode > 1 ? " nothing" :" NavigationLayer." ) );
684  Trk::NavigationLayer* nLayer = m_emptyLayerMode > 1 ? nullptr : new Trk::NavigationLayer(lay->surfaceRepresentation().clone(), 1.);
685  delete lay;
686  return nLayer;
687  }
688  // don't replace - just give back what you had
689  return lay;
690 }
691 
692 
693 
TrapezoidBounds.h
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
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
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:176
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:420
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:39
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:222
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.
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:176
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:679
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::Surface::clone
virtual Surface * clone() const =0
Implicit constructor - uses the copy constructor.
Trk::open
@ open
Definition: BinningType.h:40
Trk::LayerArrayCreator::~LayerArrayCreator
virtual ~LayerArrayCreator()
Destructor.
Trk::binR
@ binR
Definition: BinningType.h:50
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
Trk::SharedObject
std::shared_ptr< T > SharedObject
Definition: SharedObject.h:24
Trk::CylinderLayerSorterR
Definition: CylinderLayer.h:175
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
python.CaloScaleNoiseConfig.default
default
Definition: CaloScaleNoiseConfig.py:79
AthAlgTool
Definition: AthAlgTool.h:26
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
Trk::Surface::transform
const Amg::Transform3D & transform() const
Returns HepGeom::Transform3D by reference.
Trk::BinnedArray1D
Definition: BinnedArray1D.h:36
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:73
Trk::DiscLayerSorterZ
Definition: DiscLayer.h:152