ATLAS Offline Software
CylinderLayer.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 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  Trk::CylinderBounds* cbounds,
25  const Trk::LayerMaterialProperties& laymatprop,
26  double thickness,
27  std::unique_ptr<Trk::OverlapDescriptor> olap,
28  int laytyp)
29  : CylinderSurface(transform, 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 
50  Trk::CylinderBounds* cbounds,
51  std::unique_ptr<Trk::SurfaceArray> surfaceArray,
52  double thickness,
53  std::unique_ptr<Trk::OverlapDescriptor> olap,
55  int laytyp)
56  : CylinderSurface(transform, cbounds)
57  , Layer(std::move(surfaceArray), thickness, std::move(olap), laytyp)
58  , m_approachDescriptor(ades)
59 {
61  if (!ades && m_surfaceArray)
63  // register the layer
64  if (ades)
65  m_approachDescriptor->registerLayer(*this);
66 }
67 
70  Trk::CylinderBounds* cbounds,
71  std::unique_ptr<Trk::SurfaceArray> surfaceArray,
72  const Trk::LayerMaterialProperties& laymatprop,
73  double thickness,
74  std::unique_ptr<Trk::OverlapDescriptor> olap,
76  int laytyp)
77  : CylinderSurface(transform, cbounds)
78  , Layer(std::move(surfaceArray), laymatprop, thickness, std::move(olap), laytyp)
79  , m_approachDescriptor(ades)
80 {
82  if (!ades && m_surfaceArray)
84  // register the layer
85  if (ades)
86  m_approachDescriptor->registerLayer(*this);
87 }
88 
90  Trk::CylinderBounds* cbounds,
91  const Trk::LayerMaterialProperties& laymatprop, double thickness,
92  std::unique_ptr<Trk::OverlapDescriptor> olap, int laytyp)
93  : CylinderSurface(cbounds),
94  Layer(laymatprop, thickness, std::move(olap), laytyp),
95  m_approachDescriptor(nullptr) {
97 }
98 
100  std::unique_ptr<Trk::SurfaceArray> surfaceArray,
101  double thickness,
102  std::unique_ptr<Trk::OverlapDescriptor> olap,
103  Trk::IApproachDescriptor* ades, int laytyp)
104  : CylinderSurface(cbounds),
105  Layer(std::move(surfaceArray), thickness, std::move(olap), laytyp),
106  m_approachDescriptor(ades) {
108  if (!ades && m_surfaceArray) buildApproachDescriptor();
109  // register the layer
110  if (ades) m_approachDescriptor->registerLayer(*this);
111 }
112 
114  Trk::CylinderBounds* cbounds, std::unique_ptr<Trk::SurfaceArray> surfaceArray,
115  const Trk::LayerMaterialProperties& laymatprop, double thickness,
116  std::unique_ptr<Trk::OverlapDescriptor> olap, Trk::IApproachDescriptor* ades, int laytyp)
117  : CylinderSurface(cbounds),
118  Layer(std::move(surfaceArray), laymatprop, thickness, std::move(olap), laytyp),
119  m_approachDescriptor(ades) {
121  if (!ades && m_surfaceArray) buildApproachDescriptor();
122  // register the layer
123  if (ades) m_approachDescriptor->registerLayer(*this);
124 }
125 
127  : CylinderSurface(clay), Layer(clay), m_approachDescriptor(nullptr) {
129  m_approachDescriptor.reset();
130  if (m_surfaceArray)
132 }
133 
135  const Amg::Transform3D& transf)
136  : CylinderSurface(clay, transf),
137  Layer(clay),
138  m_approachDescriptor(nullptr) {
140 }
141 
143  if (this != &clay) {
144  // call the assignments of the base classes
146  Trk::Layer::operator=(clay);
147  if (m_surfaceArray) buildApproachDescriptor();
149  }
150  return (*this);
151 }
152 
155 {
156  return (*this);
157 }
158 
161 {
162  return (*this);
163 }
164 
166  const Trk::TrackParameters& parm, Trk::PropDirection dir) const {
168  // calculate the direction to the normal
169  const Amg::Vector3D& parmPos = parm.position();
170  Amg::Vector3D pastStep(parmPos + dir * parm.momentum().normalized());
171  if (pastStep.perp() > parm.position().perp())
172  return Trk::Layer::m_layerMaterialProperties->alongPreFactor();
173  return Trk::Layer::m_layerMaterialProperties->oppositePreFactor();
174 }
175 
177  const Trk::TrackParameters& parm, Trk::PropDirection dir) const {
179  const Amg::Vector3D& parmPos = parm.position();
180  Amg::Vector3D pastStep(parmPos + dir * parm.momentum().normalized());
181  if (pastStep.perp() > parm.position().perp())
182  return Trk::Layer::m_layerMaterialProperties->alongPostFactor();
183  return Trk::Layer::m_layerMaterialProperties->oppositePostFactor();
184 }
185 
188  std::make_unique<Transforms>(shift * (m_transforms->transform));
189 
190  if (m_approachDescriptor && m_approachDescriptor->rebuild()) {
191  // build the new approach descriptor - deletes the current one
192  buildApproachDescriptor();
193  }
194 }
195 
197  double envelope) {
198  // only do this if the volume bounds a CylinderVolumeBounds
199  const Trk::CylinderVolumeBounds* cvb =
200  dynamic_cast<const Trk::CylinderVolumeBounds*>(&bounds);
201  if (cvb) {
202  // get the dimensions
203  double hLengthZ = cvb->halflengthZ();
204  double r = surfaceRepresentation().bounds().r();
205  // (0) first, resize the layer itself
206  Trk::CylinderBounds* rCylinderBounds =
207  new Trk::CylinderBounds(r, hLengthZ - envelope);
210  // (1) resize the material properties by updating the BinUtility, assuming
211  // rphi/z binning
213  const BinUtility* layerMaterialBU =
215  if (layerMaterialBU && layerMaterialBU->dimensions() > 1) {
216  size_t binsRPhi = layerMaterialBU->max(0) + 1;
217  size_t binsZ = layerMaterialBU->max(1) + 1;
218  // create a new binning with the new dimensions
219  Trk::BinUtility* rBinUtility = new Trk::BinUtility(
220  binsRPhi, -r * M_PI, r * M_PI, Trk::closed, Trk::binRPhi);
221  (*rBinUtility) +=
222  Trk::BinUtility(binsZ, -hLengthZ + envelope, hLengthZ - envelope,
224  Trk::Layer::m_layerMaterialProperties->updateBinning(rBinUtility);
225  }
226  }
227  }
228 
229  if (m_approachDescriptor && m_approachDescriptor->rebuild()) {
230  // build the approach descriptor - delete the current approach descriptor
231  buildApproachDescriptor();
232  }
233 }
234 
238  const Amg::Vector3D& pos, const Amg::Vector3D& dir,
239  const Trk::BoundaryCheck& bcheck) const {
240  if (m_approachDescriptor) {
241  // get the test surfaces from the approach Descriptor
242  const Trk::ApproachSurfaces* surfacesOnApproach =
243  m_approachDescriptor->approachSurfaces(pos, dir);
244  if (surfacesOnApproach) {
245  // test the intersections and go
246  std::vector<Trk::Intersection> sfIntersections;
247  const Trk::Surface* aSurface = nullptr;
248  double aPathLength = 10e10;
249  // get the surfaces
250  for (const auto& sfIter : (*surfacesOnApproach)) {
251  // get the intersection with the surface
252  Trk::Intersection sIntersection =
253  sfIter->straightLineIntersection(pos, dir, true, bcheck);
254  // validation
255  if (sIntersection.valid && sIntersection.pathLength < aPathLength) {
256  aPathLength = sIntersection.pathLength;
257  aSurface = sfIter;
258  }
259  }
260  if (aSurface) return (*aSurface);
261  }
262  }
263  return surfaceRepresentation();
264 }
265 
270  const Trk::BoundaryCheck& bcheck, bool resolveSubSurfaces,
271  const Trk::ICompatibilityEstimator*) const {
272  // resolve the surfaces
273  if (m_approachDescriptor && resolveSubSurfaces) {
274  // resolve based on straight line intersection
275  return approachSurface(pos, double(pDir) * mom.unit(), bcheck);
276  }
277  return surfaceRepresentation();
278 }
279 
282  // delete it
283  // delete the surfaces
284  auto aSurfaces = std::make_unique<Trk::ApproachSurfaces>();
285  // create the new surfaces
286  if (m_transforms) {
287  Amg::Transform3D asTransform = m_transforms->transform;
288  aSurfaces->push_back(new Trk::CylinderSurface(
289  asTransform, m_bounds->r() - 0.5 * thickness(), m_bounds->halflengthZ()));
290  aSurfaces->push_back(new Trk::CylinderSurface(
291  asTransform, m_bounds->r() + 0.5 * thickness(), m_bounds->halflengthZ()));
292  } else {
293  aSurfaces->push_back(new Trk::CylinderSurface(
294  m_bounds->r() - 0.5 * thickness(), m_bounds->halflengthZ()));
295  aSurfaces->push_back(new Trk::CylinderSurface(
296  m_bounds->r() + 0.5 * thickness(), m_bounds->halflengthZ()));
297  }
298  // set the layer and make TGOwn
299  for (auto& sIter : (*aSurfaces)) {
300  sIter->associateLayer(*this);
301  sIter->setOwner(Trk::TGOwn);
302  }
303  m_approachDescriptor =
304  std::make_unique<Trk::ApproachDescriptor>(std::move(aSurfaces));
305 }
306 
308  const Amg::Vector3D& vCenter,
309  double envelope) {
310  // resize first of all
311  resizeLayer(vBounds, envelope);
312  // now reposition to the potentially center if necessary, do not change layers
313  // with no transform
314  if (Trk::CylinderSurface::m_transforms || center().isApprox(vCenter)) {
315  return;
316  }
317  Amg::Transform3D transf(vCenter);
319  std::make_unique<Transforms>(Amg::Transform3D(vCenter), vCenter);
320  // rebuild approaching layers if needed
321  if (m_approachDescriptor && m_approachDescriptor->rebuild())
322  buildApproachDescriptor();
323 }
324 
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:212
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:215
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:142
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:307
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:268
Trk::CylinderLayer::surfaceRepresentation
virtual const CylinderSurface & surfaceRepresentation() const override final
Transforms the layer into a Surface representation for extrapolation.
Definition: CylinderLayer.cxx:154
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:165
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:237
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
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:436
ParticleGun_EoverP_Config.mom
mom
Definition: ParticleGun_EoverP_Config.py:63
Trk::CylinderLayer::buildApproachDescriptor
void buildApproachDescriptor()
build approach surfaces
Definition: CylinderLayer.cxx:281
Trk::CylinderSurface::m_bounds
SharedObject< const CylinderBounds > m_bounds
The global reference point (== a point on the surface)
Definition: CylinderSurface.h:290
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::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:55
Trk::CylinderVolumeBounds
Definition: CylinderVolumeBounds.h:70
Trk::Surface::associateLayer
void associateLayer(const Layer &lay)
method to associate the associated Trk::Layer which is alreay owned
Trk::CylinderSurface::operator=
CylinderSurface & operator=(const CylinderSurface &csf)
Assignment operator.
Definition: CylinderSurface.cxx:115
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::SharedObject
std::shared_ptr< T > SharedObject
Definition: SharedObject.h:24
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:176
Trk::CylinderLayer::moveLayer
virtual void moveLayer(Amg::Transform3D &shift) override final
move the Layer
Definition: CylinderLayer.cxx:186
Trk::CylinderLayer::m_approachDescriptor
std::unique_ptr< IApproachDescriptor > m_approachDescriptor
surfaces on approach to the layer
Definition: CylinderLayer.h:169
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:196
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
LayerMaterialProperties.h
Trk::Layer
Definition: Layer.h:73