ATLAS Offline Software
DiscLayer.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 // DiscLayer.cxx, (c) ATLAS Detector software
8 
9 // Trk
10 #include "TrkGeometry/DiscLayer.h"
11 
16 #include "TrkSurfaces/DiscBounds.h"
18 // CLHEP
20 
22  Trk::DiscBounds* dbounds,
23  const Trk::LayerMaterialProperties& laymatprop,
24  double thickness,
25  std::unique_ptr<Trk::OverlapDescriptor> olap,
26  int laytyp)
27  : DiscSurface(transform, dbounds)
28  , Layer(laymatprop, thickness, std::move(olap), laytyp)
29  , m_approachDescriptor(nullptr)
30 {
32 }
33 
35  const Trk::LayerMaterialProperties& laymatprop,
36  double thickness,
37  std::unique_ptr<Trk::OverlapDescriptor> olap,
38  int laytyp)
39  : DiscSurface(*disc)
40  , Layer(laymatprop, thickness, std::move(olap), laytyp)
41  , m_approachDescriptor(nullptr)
42 {
44 }
45 
47  Trk::DiscBounds* dbounds,
48  std::unique_ptr<Trk::SurfaceArray> surfaceArray,
49  double thickness,
50  std::unique_ptr<Trk::OverlapDescriptor> olap,
52  int laytyp)
53  : DiscSurface(transform, dbounds)
54  , Layer(std::move(surfaceArray), thickness, std::move(olap), laytyp)
55  , m_approachDescriptor(ades)
56 {
59  // register the layer
60  if (ades) m_approachDescriptor->registerLayer(*this);
61 }
62 
64  Trk::DiscBounds* dbounds,
65  std::unique_ptr<Trk::SurfaceArray> surfaceArray,
66  const Trk::LayerMaterialProperties& laymatprop,
67  double thickness,
68  std::unique_ptr<Trk::OverlapDescriptor> olap,
70  int laytyp)
71  : DiscSurface(transform, dbounds)
72  , Layer(std::move(surfaceArray), laymatprop, thickness, std::move(olap), laytyp)
73  , m_approachDescriptor(ades)
74 {
76  if (!ades && m_surfaceArray)
78  // register the layer
79  if (ades)
80  m_approachDescriptor->registerLayer(*this);
81 }
82 
84  : DiscSurface(dlay), Layer(dlay), m_approachDescriptor(nullptr) {
87 }
88 
90  const Amg::Transform3D& transf)
91  : DiscSurface(dlay, transf), Layer(dlay), m_approachDescriptor(nullptr) {
94 }
95 
97  if (this != &dlay) {
98  // call the assignments of the base classes
100  Trk::Layer::operator=(dlay);
101  m_approachDescriptor.reset();
102  if (m_surfaceArray) {
103  buildApproachDescriptor();
104  }
106  }
107  return (*this);
108 }
109 
110 const Trk::DiscSurface&
112 {
113  return (*this);
114 }
117 {
118  return (*this);
119 }
120 
122  Trk::PropDirection dir) const {
124  // const Amg::Vector3D& parmPos = parm.position();
125  if (Trk::DiscSurface::normal().dot(dir * parm.momentum().normalized()) > 0.)
126  return Trk::Layer::m_layerMaterialProperties->alongPreFactor();
127  return Trk::Layer::m_layerMaterialProperties->oppositePreFactor();
128 }
129 
131  const Trk::TrackParameters& parm, Trk::PropDirection dir) const {
133  // const Amg::Vector3D& parmPos = parm.position();
134  if (Trk::DiscSurface::normal().dot(dir * parm.momentum().normalized()) > 0.)
135  return Trk::Layer::m_layerMaterialProperties->alongPostFactor();
136  return Trk::Layer::m_layerMaterialProperties->oppositePostFactor();
137 }
138 
140  Amg::Transform3D transf = shift * m_transforms->transform;
141  m_transforms = std::make_unique<Transforms>(transf, transf.translation(),
142  transf.rotation().col(2));
143  // rebuild that - deletes the current one
144  if (m_approachDescriptor && m_approachDescriptor->rebuild()) {
145  buildApproachDescriptor();
146  }
147 }
148 
149 void Trk::DiscLayer::resizeLayer(const VolumeBounds& bounds, double envelope) {
150  // only do this if the volume bounds a CylinderVolumeBounds
151  const Trk::CylinderVolumeBounds* cvb =
152  dynamic_cast<const Trk::CylinderVolumeBounds*>(&bounds);
153  if (cvb) {
154  // get the dimensions
155  double rInner = cvb->innerRadius();
156  double rOuter = cvb->outerRadius();
157  // (0) first, resize the layer itself
158  Trk::DiscBounds* rDiscBounds =
159  new Trk::DiscBounds(rInner + envelope, rOuter - envelope);
162  // (1) resize the material properties by updating the BinUtility, assuming
163  // r/phi binning
165  const BinUtility* layerMaterialBU =
167  if (layerMaterialBU && layerMaterialBU->binningValue(0) == Trk::binR) {
168  size_t binsR = layerMaterialBU->max(0) + 1;
169  // create a new binning with the new dimensions
170  Trk::BinUtility* rBinUtility = new Trk::BinUtility(
171  binsR, rInner + envelope, rOuter - envelope, Trk::open, Trk::binR);
172  // copy the second dimension over if exist
173  if (layerMaterialBU->dimensions() > 1) {
174  (*rBinUtility) += Trk::BinUtility(layerMaterialBU->max(1) + 1, -M_PI,
176  }
177  Trk::Layer::m_layerMaterialProperties->updateBinning(rBinUtility);
178  }
179  }
180  }
181 
182  if (m_approachDescriptor && m_approachDescriptor->rebuild()) {
183  // rebuild the approach descriptor - delete the current approach descriptor
184  buildApproachDescriptor();
185  }
186 }
187 
191  const Amg::Vector3D& pos, const Amg::Vector3D& dir,
192  const Trk::BoundaryCheck& bcheck) const {
193  if (m_approachDescriptor) {
194  // get the test surfaces from the approach Descriptor
195  const Trk::ApproachSurfaces* surfacesOnApproach =
196  m_approachDescriptor->approachSurfaces(pos, dir);
197  if (surfacesOnApproach) {
198  // test the intersections and go
199  std::vector<Trk::Intersection> sfIntersections;
200  const Trk::Surface* aSurface = nullptr;
201  double aPathLength = 10e10;
203  for (const auto& sfIter : (*surfacesOnApproach)) {
204  // get the intersection with the surface
205  Trk::Intersection sIntersection =
206  sfIter->straightLineIntersection(pos, dir, true, bcheck);
207  // validation
208  if (sIntersection.valid && sIntersection.pathLength < aPathLength) {
209  aPathLength = sIntersection.pathLength;
210  aSurface = sfIter;
211  }
212  }
213  if (aSurface) return (*aSurface);
214  }
215  }
216  return surfaceRepresentation();
217 }
218 
223  const Trk::BoundaryCheck& bcheck, bool resolveSubSurfaces,
224  const Trk::ICompatibilityEstimator*) const {
225  // resolve the surfaces
226  if (m_approachDescriptor && resolveSubSurfaces) {
227  // resolve based on straight line intersection
228  return approachSurface(pos, double(pDir) * mom.unit(), bcheck);
229  }
230  return surfaceRepresentation();
231 }
232 
235  // create the surface container
236  auto aSurfaces = std::make_unique<Trk::ApproachSurfaces>();
237  // get the center
238  const auto halfThickness = 0.5 * thickness() * normal();
239  const Amg::Vector3D aspPosition(center() + halfThickness);
240  const Amg::Vector3D asnPosition(center() - halfThickness);
241  // create the new surfaces
242  const Trk::DiscBounds* db =
243  dynamic_cast<const Trk::DiscBounds*>(m_bounds.get());
244  if (db) {
245  // create new surfaces
246  Amg::Transform3D asnTransform =
247  Amg::Transform3D(Amg::Translation3D(asnPosition));
248  Amg::Transform3D aspTransform =
249  Amg::Transform3D(Amg::Translation3D(aspPosition));
250  aSurfaces->push_back(new Trk::DiscSurface(aspTransform, db->clone()));
251  aSurfaces->push_back(new Trk::DiscSurface(asnTransform, db->clone()));
252  // set the layer and make TGOwn
253  for (auto& sIter : (*aSurfaces)) {
254  sIter->associateLayer(*this);
255  sIter->setOwner(Trk::TGOwn);
256  }
257  }
258  // The approach descriptor takes owneship
259  m_approachDescriptor =
260  std::make_unique<Trk::ApproachDescriptor>(std::move(aSurfaces));
261 }
262 
264  const Amg::Vector3D& vCenter,
265  double envelope) {
266  // resize first of all
267  resizeLayer(vBounds, envelope);
268  // now reposition to the potentially center if necessary, do not change layers
269  // with no transform
270  const Trk::CylinderVolumeBounds* cvb =
271  dynamic_cast<const Trk::CylinderVolumeBounds*>(&vBounds);
272  if (cvb) {
273  // get the halflength
274  double hLengthZ = cvb->halflengthZ();
275  Amg::Vector3D nDiscCenter =
276  center().z() < 0.
277  ? Amg::Vector3D(vCenter -
278  Amg::Vector3D(0., 0., hLengthZ - 0.5 * thickness()))
279  : Amg::Vector3D(
280  vCenter +
281  Amg::Vector3D(0., 0., hLengthZ - 0.5 * thickness()));
282  if (center().isApprox(nDiscCenter)) return;
283  // else set to the new volume center
284  Amg::Transform3D transf((Amg::Translation3D(nDiscCenter)));
285  Amg::Vector3D center(nDiscCenter);
286  m_transforms = std::make_unique<Transforms>(transf, center);
287  }
288  // rebuild the approaching layer
289  if (m_approachDescriptor && m_approachDescriptor->rebuild())
290  buildApproachDescriptor();
291 }
Trk::DiscLayer::DiscLayer
DiscLayer()=default
Default Constructor.
Trk::DiscLayer::resizeLayer
virtual void resizeLayer(const VolumeBounds &vBounds, double envelope) override final
Resize the layer to the tracking volume - only works for CylinderVolumeBouns.
Definition: DiscLayer.cxx:149
Trk::Intersection
Definition: Intersection.h:24
DiscBounds.h
TrackParameters.h
Trk::BinUtility::dimensions
size_t dimensions() const
First bin maximal value.
Definition: BinUtility.h:212
MaterialProperties.h
Trk::BinUtility::max
size_t max(size_t ba=0) const
First bin maximal value.
Definition: BinUtility.h:215
Trk::Layer::m_layerMaterialProperties
std::unique_ptr< LayerMaterialProperties > m_layerMaterialProperties
thickness of the Layer
Definition: Layer.h:289
Trk::DiscLayer::m_approachDescriptor
std::unique_ptr< IApproachDescriptor > m_approachDescriptor
< surface for approaching
Definition: DiscLayer.h:146
CaloCondBlobAlgs_fillNoiseFromASCII.db
db
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:43
Trk::DiscSurface::operator=
DiscSurface & operator=(const DiscSurface &dsf)
Assignement operator.
Definition: DiscSurface.cxx:148
Trk::Layer::m_surfaceArray
std::unique_ptr< SurfaceArray > m_surfaceArray
MaterialPoperties of this layer Surface.
Definition: Layer.h:287
Trk::Intersection::pathLength
double pathLength
Definition: Intersection.h:26
BinUtility.h
DiscLayer.h
M_PI
#define M_PI
Definition: ActiveFraction.h:11
Trk::closed
@ closed
Definition: BinningType.h:41
Trk::DiscSurface
Definition: DiscSurface.h:54
Trk::DiscLayer::surfaceOnApproach
virtual const Surface & surfaceOnApproach(const Amg::Vector3D &pos, const Amg::Vector3D &mom, 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: DiscLayer.cxx:221
Trk::ApproachSurfaces
Definition: IApproachDescriptor.h:25
Trk::IApproachDescriptor
Definition: IApproachDescriptor.h:45
GeoPrimitives.h
Trk::DiscLayer::postUpdateMaterialFactor
virtual double postUpdateMaterialFactor(const Trk::TrackParameters &par, Trk::PropDirection dir) const override final
getting the MaterialProperties back - for post-update
Definition: DiscLayer.cxx:130
Trk::VolumeBounds
Definition: VolumeBounds.h:45
CylinderVolumeBounds.h
Trk::PropDirection
PropDirection
Definition: PropDirection.h:19
ParticleGun_EoverP_Config.mom
mom
Definition: ParticleGun_EoverP_Config.py:63
Trk::DiscLayer::resizeAndRepositionLayer
virtual void resizeAndRepositionLayer(const VolumeBounds &vBounds, const Amg::Vector3D &cCenter, double envelop) override final
Resize the layer to the tracking volume - not implemented.
Definition: DiscLayer.cxx:263
Trk::LayerMaterialProperties
Definition: LayerMaterialProperties.h:62
Trk::DiscSurface::m_bounds
SharedObject< const SurfaceBounds > m_bounds
reference Point on the Surface
Definition: DiscSurface.h:285
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
Trk::Surface::normal
virtual const Amg::Vector3D & normal() const
Returns the normal vector of the Surface (i.e.
Trk::DiscLayer
Definition: DiscLayer.h:45
Trk::ParametersBase
Definition: ParametersBase.h:55
dot.dot
def dot(G, fn, nodesToHighlight=[])
Definition: dot.py:5
Trk::BinUtility::binningValue
BinningValue binningValue(size_t ba=0) const
The type/value of the binning.
Definition: BinUtility.h:231
beamspotman.dir
string dir
Definition: beamspotman.py:623
Trk::BinUtility
Definition: BinUtility.h:39
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::DiscLayer::surfaceRepresentation
virtual const DiscSurface & surfaceRepresentation() const override final
Transforms the layer into a Surface representation for extrapolation.
Definition: DiscLayer.cxx:111
Trk::DiscLayer::preUpdateMaterialFactor
virtual double preUpdateMaterialFactor(const Trk::TrackParameters &par, Trk::PropDirection dir) const override final
getting the MaterialProperties back - for pre-update
Definition: DiscLayer.cxx:121
Trk::CylinderVolumeBounds::outerRadius
double outerRadius() const
This method returns the outer radius.
Definition: CylinderVolumeBounds.h:191
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
Trk::ParametersBase::momentum
const Amg::Vector3D & momentum() const
Access method for the momentum.
Trk::binR
@ binR
Definition: BinningType.h:50
Trk::SharedObject
std::shared_ptr< T > SharedObject
Definition: SharedObject.h:24
Trk::CylinderVolumeBounds::innerRadius
double innerRadius() const
This method returns the inner radius.
Definition: CylinderVolumeBounds.h:187
Trk::BoundaryCheck
Definition: BoundaryCheck.h:51
Amg::Translation3D
Eigen::Translation< double, 3 > Translation3D
Definition: GeoPrimitives.h:44
Trk::DiscLayer::operator=
DiscLayer & operator=(const DiscLayer &)
Assignment operator for DiscLayers.
Definition: DiscLayer.cxx:96
Trk::DiscLayer::buildApproachDescriptor
void buildApproachDescriptor()
build approach surfaces
Definition: DiscLayer.cxx:234
Trk::DiscLayer::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: DiscLayer.cxx:190
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
Trk::DiscLayer::moveLayer
virtual void moveLayer(Amg::Transform3D &shift) override final
move the Layer non-const
Definition: DiscLayer.cxx:139
LayerMaterialProperties.h
Trk::DiscBounds
Definition: DiscBounds.h:44
Trk::Layer
Definition: Layer.h:73
Trk::binPhi
@ binPhi
Definition: BinningType.h:51