Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
CylinderLayer.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 // CylinderLayer.cxx, (c) ATLAS Detector software
8 
9 // Trk
11 
19 // Amg
21 
24  std::shared_ptr<Trk::CylinderBounds> cbounds,
25  const Trk::LayerMaterialProperties& laymatprop,
26  double thickness,
27  std::unique_ptr<Trk::OverlapDescriptor> olap,
28  int laytyp)
29  : CylinderSurface(transform, std::move(cbounds))
30  , Layer(laymatprop, thickness, std::move(olap), laytyp)
31  , m_approachDescriptor(nullptr)
32 {
34 }
35 
38  const Trk::LayerMaterialProperties& laymatprop,
39  double thickness,
40  std::unique_ptr<Trk::OverlapDescriptor> olap,
41  int laytyp)
42  : CylinderSurface(*cyl)
43  , Layer(laymatprop, thickness, std::move(olap), laytyp)
44  , m_approachDescriptor(nullptr)
45 {
47 }
48 
51  std::shared_ptr<Trk::CylinderBounds> cbounds,
52  std::unique_ptr<Trk::SurfaceArray> surfaceArray,
53  double thickness,
54  std::unique_ptr<Trk::OverlapDescriptor> olap,
56  int laytyp)
57  : CylinderSurface(transform, std::move(cbounds))
58  , Layer(std::move(surfaceArray), thickness, std::move(olap), laytyp)
59  , m_approachDescriptor(ades)
60 {
62  if (!ades && m_surfaceArray)
64  // register the layer
65  if (ades)
66  m_approachDescriptor->registerLayer(*this);
67 }
68 
71  std::shared_ptr<Trk::CylinderBounds> cbounds,
72  std::unique_ptr<Trk::SurfaceArray> surfaceArray,
73  const Trk::LayerMaterialProperties& laymatprop,
74  double thickness,
75  std::unique_ptr<Trk::OverlapDescriptor> olap,
77  int laytyp)
78  : CylinderSurface(transform, std::move(cbounds))
79  , Layer(std::move(surfaceArray), laymatprop, thickness, std::move(olap), laytyp)
80  , m_approachDescriptor(ades)
81 {
83  if (!ades && m_surfaceArray)
85  // register the layer
86  if (ades)
87  m_approachDescriptor->registerLayer(*this);
88 }
89 
91  std::shared_ptr<Trk::CylinderBounds> cbounds,
92  const Trk::LayerMaterialProperties& laymatprop,
93  double thickness,
94  std::unique_ptr<Trk::OverlapDescriptor> olap,
95  int laytyp)
96  : CylinderSurface(std::move(cbounds)),
97  Layer(laymatprop, thickness, std::move(olap), laytyp),
98  m_approachDescriptor(nullptr) {
100 }
101 
103  std::shared_ptr<Trk::CylinderBounds> cbounds,
104  std::unique_ptr<Trk::SurfaceArray> surfaceArray,
105  double thickness,
106  std::unique_ptr<Trk::OverlapDescriptor> olap,
107  Trk::IApproachDescriptor* ades, int laytyp)
108  : CylinderSurface(std::move(cbounds)),
109  Layer(std::move(surfaceArray), thickness, std::move(olap), laytyp),
110  m_approachDescriptor(ades) {
112  if (!ades && m_surfaceArray) buildApproachDescriptor();
113  // register the layer
114  if (ades) m_approachDescriptor->registerLayer(*this);
115 }
116 
118  std::shared_ptr<Trk::CylinderBounds> cbounds,
119  std::unique_ptr<Trk::SurfaceArray> surfaceArray,
120  const Trk::LayerMaterialProperties& laymatprop,
121  double thickness,
122  std::unique_ptr<Trk::OverlapDescriptor> olap,
123  Trk::IApproachDescriptor* ades, int laytyp)
124  : CylinderSurface(std::move(cbounds)),
125  Layer(std::move(surfaceArray), laymatprop, thickness, std::move(olap), laytyp),
126  m_approachDescriptor(ades) {
128  if (!ades && m_surfaceArray) buildApproachDescriptor();
129  // register the layer
130  if (ades) m_approachDescriptor->registerLayer(*this);
131 }
132 
134  : CylinderSurface(clay),
135  Layer(clay),
136  m_approachDescriptor(nullptr) {
138  m_approachDescriptor.reset();
139  if (m_surfaceArray)
141 }
142 
144  const Amg::Transform3D& transf)
145  : CylinderSurface(clay, transf),
146  Layer(clay),
147  m_approachDescriptor(nullptr) {
148  if (m_surfaceArray) {
150  }
151 }
152 
154  if (this != &clay) {
155  // call the assignments of the base classes
157  Trk::Layer::operator=(clay);
158  if (m_surfaceArray) buildApproachDescriptor();
160  }
161  return (*this);
162 }
163 
166 {
167  return (*this);
168 }
169 
172 {
173  return (*this);
174 }
175 
177  const Trk::TrackParameters& parm, Trk::PropDirection dir) const {
179  // calculate the direction to the normal
180  const Amg::Vector3D& parmPos = parm.position();
181  Amg::Vector3D pastStep(parmPos + dir * parm.momentum().normalized());
182  if (pastStep.perp() > parm.position().perp())
183  return Trk::Layer::m_layerMaterialProperties->alongPreFactor();
184  return Trk::Layer::m_layerMaterialProperties->oppositePreFactor();
185 }
186 
188  const Trk::TrackParameters& parm, Trk::PropDirection dir) const {
190  const Amg::Vector3D& parmPos = parm.position();
191  Amg::Vector3D pastStep(parmPos + dir * parm.momentum().normalized());
192  if (pastStep.perp() > parm.position().perp())
193  return Trk::Layer::m_layerMaterialProperties->alongPostFactor();
194  return Trk::Layer::m_layerMaterialProperties->oppositePostFactor();
195 }
196 
199  std::make_unique<Transforms>(shift * (m_transforms->transform));
200 
201  if (m_approachDescriptor && m_approachDescriptor->rebuild()) {
202  // build the new approach descriptor - deletes the current one
203  buildApproachDescriptor();
204  }
205 }
206 
208  double envelope) {
209  // only do this if the volume bounds a CylinderVolumeBounds
210  const Trk::CylinderVolumeBounds* cvb =
211  dynamic_cast<const Trk::CylinderVolumeBounds*>(&bounds);
212  if (cvb) {
213  // get the dimensions
214  double hLengthZ = cvb->halflengthZ();
215  double r = surfaceRepresentation().bounds().r();
216  // (0) first, resize the layer itself
217  Trk::CylinderBounds* rCylinderBounds =
218  new Trk::CylinderBounds(r, hLengthZ - envelope);
220  std::shared_ptr<Trk::CylinderBounds>(rCylinderBounds);
221  // (1) resize the material properties by updating the BinUtility, assuming
222  // rphi/z binning
224  const BinUtility* layerMaterialBU =
226  if (layerMaterialBU && layerMaterialBU->dimensions() > 1) {
227  size_t binsRPhi = layerMaterialBU->max(0) + 1;
228  size_t binsZ = layerMaterialBU->max(1) + 1;
229  // create a new binning with the new dimensions
230  Trk::BinUtility* rBinUtility = new Trk::BinUtility(
231  binsRPhi, -r * M_PI, r * M_PI, Trk::closed, Trk::binRPhi);
232  (*rBinUtility) +=
233  Trk::BinUtility(binsZ, -hLengthZ + envelope, hLengthZ - envelope,
235  Trk::Layer::m_layerMaterialProperties->updateBinning(rBinUtility);
236  }
237  }
238  }
239 
240  if (m_approachDescriptor && m_approachDescriptor->rebuild()) {
241  // build the approach descriptor - delete the current approach descriptor
242  buildApproachDescriptor();
243  }
244 }
245 
249  const Amg::Vector3D& pos, const Amg::Vector3D& dir,
250  const Trk::BoundaryCheck& bcheck) const {
251  if (m_approachDescriptor) {
252  // get the test surfaces from the approach Descriptor
253  const Trk::ApproachSurfaces* surfacesOnApproach =
254  m_approachDescriptor->approachSurfaces(pos, dir);
255  if (surfacesOnApproach) {
256  // test the intersections and go
257  std::vector<Trk::Intersection> sfIntersections;
258  const Trk::Surface* aSurface = nullptr;
259  double aPathLength = 10e10;
260  // get the surfaces
261  for (const auto& sfIter : (*surfacesOnApproach)) {
262  // get the intersection with the surface
263  Trk::Intersection sIntersection =
264  sfIter->straightLineIntersection(pos, dir, true, bcheck);
265  // validation
266  if (sIntersection.valid && sIntersection.pathLength < aPathLength) {
267  aPathLength = sIntersection.pathLength;
268  aSurface = sfIter;
269  }
270  }
271  if (aSurface) return (*aSurface);
272  }
273  }
274  return surfaceRepresentation();
275 }
276 
281  const Trk::BoundaryCheck& bcheck, bool resolveSubSurfaces,
282  const Trk::ICompatibilityEstimator*) const {
283  // resolve the surfaces
284  if (m_approachDescriptor && resolveSubSurfaces) {
285  // resolve based on straight line intersection
286  return approachSurface(pos, double(pDir) * mom.unit(), bcheck);
287  }
288  return surfaceRepresentation();
289 }
290 
293  // delete it
294  // delete the surfaces
295  auto aSurfaces = std::make_unique<Trk::ApproachSurfaces>();
296  // create the new surfaces
297  if (m_transforms) {
298  Amg::Transform3D asTransform = m_transforms->transform;
299  aSurfaces->push_back(new Trk::CylinderSurface(
300  asTransform, m_bounds->r() - 0.5 * thickness(), m_bounds->halflengthZ()));
301  aSurfaces->push_back(new Trk::CylinderSurface(
302  asTransform, m_bounds->r() + 0.5 * thickness(), m_bounds->halflengthZ()));
303  } else {
304  aSurfaces->push_back(new Trk::CylinderSurface(
305  m_bounds->r() - 0.5 * thickness(), m_bounds->halflengthZ()));
306  aSurfaces->push_back(new Trk::CylinderSurface(
307  m_bounds->r() + 0.5 * thickness(), m_bounds->halflengthZ()));
308  }
309  // set the layer and make TGOwn
310  for (auto& sIter : (*aSurfaces)) {
311  sIter->associateLayer(*this);
312  sIter->setOwner(Trk::TGOwn);
313  }
314  m_approachDescriptor =
315  std::make_unique<Trk::ApproachDescriptor>(std::move(aSurfaces));
316 }
317 
319  const Amg::Vector3D& vCenter,
320  double envelope) {
321  // resize first of all
322  resizeLayer(vBounds, envelope);
323  // now reposition to the potentially center if necessary, do not change layers
324  // with no transform
325  if (Trk::CylinderSurface::m_transforms || center().isApprox(vCenter)) {
326  return;
327  }
328  Amg::Transform3D transf(vCenter);
330  std::make_unique<Transforms>(Amg::Transform3D(vCenter), vCenter);
331  // rebuild approaching layers if needed
332  if (m_approachDescriptor && m_approachDescriptor->rebuild())
333  buildApproachDescriptor();
334 }
335 
beamspotman.r
def r
Definition: beamspotman.py:676
Trk::CylinderLayer::CylinderLayer
CylinderLayer()
Default Constructor.
Definition: CylinderLayer.h:46
Trk::Intersection
Definition: Intersection.h:24
TrackParameters.h
Trk::BinUtility::dimensions
size_t dimensions() const
First bin maximal value.
Definition: BinUtility.h:209
ApproachDescriptor.h
MaterialProperties.h
Trk::binZ
@ binZ
Definition: BinningType.h:49
Trk::BinUtility::max
size_t max(size_t ba=0) const
First bin maximal value.
Definition: BinUtility.h:212
Trk::ParametersBase::position
const Amg::Vector3D & position() const
Access method for the position.
Trk::Layer::m_layerMaterialProperties
std::unique_ptr< LayerMaterialProperties > m_layerMaterialProperties
thickness of the Layer
Definition: Layer.h:289
Trk::CylinderLayer::operator=
CylinderLayer & operator=(const CylinderLayer &)
Assignment operator for CylinderLayers.
Definition: CylinderLayer.cxx:153
Trk::Layer::m_surfaceArray
std::unique_ptr< SurfaceArray > m_surfaceArray
MaterialPoperties of this layer Surface.
Definition: Layer.h:287
Trk::CylinderLayer::resizeAndRepositionLayer
virtual void resizeAndRepositionLayer(const VolumeBounds &vBounds, const Amg::Vector3D &cCenter, double envelope) override final
Resize the layer to the tracking volume.
Definition: CylinderLayer.cxx:318
Trk::CylinderLayer::surfaceOnApproach
virtual const Surface & surfaceOnApproach(const Amg::Vector3D &pos, const Amg::Vector3D &dir, PropDirection pdir, const BoundaryCheck &bcheck, bool resolveSubSurfaces=0, const ICompatibilityEstimator *ice=nullptr) const override final
Surface seen on approach - if not defined differently, it is the surfaceRepresentation()
Definition: CylinderLayer.cxx:279
Trk::CylinderLayer::surfaceRepresentation
virtual const CylinderSurface & surfaceRepresentation() const override final
Transforms the layer into a Surface representation for extrapolation.
Definition: CylinderLayer.cxx:165
Trk::CylinderLayer::preUpdateMaterialFactor
virtual double preUpdateMaterialFactor(const Trk::TrackParameters &par, Trk::PropDirection dir) const override final
getting the MaterialProperties back - for pre-update
Definition: CylinderLayer.cxx:176
Trk::Intersection::pathLength
double pathLength
Definition: Intersection.h:26
BinUtility.h
M_PI
#define M_PI
Definition: ActiveFraction.h:11
ChangeHistoRange.binsZ
list binsZ
Definition: ChangeHistoRange.py:63
Trk::closed
@ closed
Definition: BinningType.h:41
Trk::CylinderLayer::approachSurface
const Surface & approachSurface(const Amg::Vector3D &pos, const Amg::Vector3D &dir, const BoundaryCheck &bcheck) const
Surface seen on approach - if not defined differently, it is the surfaceRepresentation()
Definition: CylinderLayer.cxx:248
Trk::ApproachSurfaces
Definition: IApproachDescriptor.h:25
Trk::IApproachDescriptor
Definition: IApproachDescriptor.h:45
GeoPrimitives.h
Trk::VolumeBounds
Definition: VolumeBounds.h:45
CylinderVolumeBounds.h
Trk::PropDirection
PropDirection
Definition: PropDirection.h:19
Trk::Surface::m_transforms
std::unique_ptr< Transforms > m_transforms
Unique Pointer to the Transforms struct.
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:440
ParticleGun_EoverP_Config.mom
mom
Definition: ParticleGun_EoverP_Config.py:63
Trk::CylinderLayer::buildApproachDescriptor
void buildApproachDescriptor()
build approach surfaces
Definition: CylinderLayer.cxx:292
Trk::CylinderSurface
Definition: CylinderSurface.h:55
Trk::CylinderBounds
Definition: CylinderBounds.h:46
Trk::LayerMaterialProperties
Definition: LayerMaterialProperties.h:62
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
Amg::transform
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Definition: GeoPrimitivesHelpers.h:156
Trk::CylinderVolumeBounds::halflengthZ
double halflengthZ() const
This method returns the halflengthZ.
Definition: CylinderVolumeBounds.h:207
Trk::Layer::operator=
Layer & operator=(const Layer &lay)
Assignment operator for Derived classes.
Definition: Layer.cxx:98
CylinderLayer.h
Trk::CylinderSurface::m_bounds
std::shared_ptr< const CylinderBounds > m_bounds
The global reference point (== a point on the surface)
Definition: CylinderSurface.h:289
Trk::ParametersBase
Definition: ParametersBase.h:55
beamspotman.dir
string dir
Definition: beamspotman.py:623
Trk::BinUtility
Definition: BinUtility.h:39
Trk::CylinderLayer
Definition: CylinderLayer.h:43
Trk::TGOwn
@ TGOwn
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:58
Trk::CylinderVolumeBounds
Definition: CylinderVolumeBounds.h:70
Trk::Surface::associateLayer
void associateLayer(const Layer &lay)
method to associate a Trk::Layer.
Trk::CylinderSurface::operator=
CylinderSurface & operator=(const CylinderSurface &csf)
Assignment operator.
Definition: CylinderSurface.cxx:112
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Trk::Intersection::valid
bool valid
Definition: Intersection.h:28
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
Trk::open
@ open
Definition: BinningType.h:40
CylinderBounds.h
Trk::ParametersBase::momentum
const Amg::Vector3D & momentum() const
Access method for the momentum.
Trk::binRPhi
@ binRPhi
Definition: BinningType.h:52
Trk::BoundaryCheck
Definition: BoundaryCheck.h:51
Trk::CylinderLayer::postUpdateMaterialFactor
virtual double postUpdateMaterialFactor(const Trk::TrackParameters &par, Trk::PropDirection dir) const override final
getting the MaterialProperties back - for post-update
Definition: CylinderLayer.cxx:187
Trk::CylinderLayer::moveLayer
virtual void moveLayer(Amg::Transform3D &shift) override final
move the Layer
Definition: CylinderLayer.cxx:197
Trk::CylinderLayer::m_approachDescriptor
std::unique_ptr< IApproachDescriptor > m_approachDescriptor
surfaces on approach to the layer
Definition: CylinderLayer.h:174
Trk::CylinderLayer::resizeLayer
virtual void resizeLayer(const VolumeBounds &vBounds, double envelope) override final
Resize the layer to the tracking volume - only works for CylinderVolumeBouns.
Definition: CylinderLayer.cxx:207
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:79
LayerMaterialProperties.h
Trk::Layer
Definition: Layer.h:73