ATLAS Offline Software
Layer.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 // Layer.cxx, (c) ATLAS Detector software
8 
9 // Trk
10 #include "TrkGeometry/Layer.h"
11 
15 #include "TrkSurfaces/Surface.h"
16 #include "TrkVolumes/Volume.h"
17 
19  double thickness,
20  std::unique_ptr<Trk::OverlapDescriptor> olap, int laytyp)
21  : m_surfaceArray(nullptr),
22  m_layerMaterialProperties(laymatprop.clone()),
23  m_layerThickness(thickness),
24  m_overlapDescriptor(std::move(olap)),
25  m_previousLayer(nullptr),
26  m_nextLayer(nullptr),
27  m_binUtility(nullptr),
28  m_enclosingTrackingVolume(nullptr),
29  m_enclosingDetachedTrackingVolume(nullptr),
30  m_index(-1),
31  m_layerType(laytyp),
32  m_ref(0.) {}
33 
34 Trk::Layer::Layer(std::unique_ptr<Trk::SurfaceArray> surfaceArray, double thickness,
35  std::unique_ptr<Trk::OverlapDescriptor> olap, int laytyp)
36  : m_surfaceArray(std::move(surfaceArray)),
37  m_layerMaterialProperties(nullptr),
38  m_layerThickness(thickness),
39  m_overlapDescriptor(std::move(olap)),
40  m_previousLayer(nullptr),
41  m_nextLayer(nullptr),
42  m_binUtility(nullptr),
43  m_enclosingTrackingVolume(nullptr),
44  m_enclosingDetachedTrackingVolume(nullptr),
45  m_index(-1),
46  m_layerType(laytyp),
47  m_ref(0.) {}
48 
49 Trk::Layer::Layer(std::unique_ptr<Trk::SurfaceArray> surfaceArray,
50  const Trk::LayerMaterialProperties& laymatprop,
51  double thickness,
52  std::unique_ptr<Trk::OverlapDescriptor> olap, int laytyp)
53  : m_surfaceArray(std::move(surfaceArray)),
54  m_layerMaterialProperties(laymatprop.clone()),
55  m_layerThickness(thickness),
56  m_overlapDescriptor(std::move(olap)),
57  m_previousLayer(nullptr),
58  m_nextLayer(nullptr),
59  m_binUtility(nullptr),
60  m_enclosingTrackingVolume(nullptr),
61  m_enclosingDetachedTrackingVolume(nullptr),
62  m_index(-1),
63  m_layerType(laytyp),
64  m_ref(0.) {}
65 
67  : m_surfaceArray(lay.m_surfaceArray ? lay.m_surfaceArray->clone()
68  : nullptr),
69  m_layerMaterialProperties(lay.m_layerMaterialProperties
70  ? lay.m_layerMaterialProperties->clone()
71  : nullptr),
72  m_layerThickness(lay.m_layerThickness),
73  m_overlapDescriptor(
74  lay.m_overlapDescriptor ? lay.m_overlapDescriptor->clone() : nullptr),
75  m_previousLayer(nullptr),
76  m_nextLayer(nullptr),
77  m_binUtility(nullptr),
78  m_enclosingTrackingVolume(nullptr),
79  m_enclosingDetachedTrackingVolume(nullptr),
80  m_index(-1),
81  m_layerType(lay.m_layerType),
82  m_ref(lay.m_ref) {}
83 
85  if (this != &lay) {
86  m_layerThickness = lay.m_layerThickness;
87  m_enclosingDetachedTrackingVolume = lay.m_enclosingDetachedTrackingVolume;
88  m_overlapDescriptor.reset(
89  (lay.m_overlapDescriptor) ? lay.m_overlapDescriptor->clone() : nullptr);
90  m_surfaceArray.reset((lay.m_surfaceArray) ? lay.m_surfaceArray->clone()
91  : nullptr);
92  m_layerMaterialProperties.reset(lay.m_layerMaterialProperties->clone());
93 
94  // just assign by pointer
95  m_nextLayer = lay.m_nextLayer;
96  m_previousLayer = lay.m_previousLayer;
97  m_binUtility = lay.m_binUtility;
98  m_enclosingTrackingVolume = lay.m_enclosingTrackingVolume;
99  //
100  m_index = lay.m_index;
101  m_layerType = lay.m_layerType;
102  m_ref = lay.m_ref;
103  }
104  return (*this);
105 }
106 
108  if (m_surfaceArray) return m_surfaceArray->object(gp);
109  return nullptr;
110 }
111 
113  if (m_surfaceArray) return m_surfaceArray->object(lp);
114  return nullptr;
115 }
116 
118  // the reference surface
119  const Trk::Surface* referenceSurface = nullptr;
120  if (m_surfaceArray) {
121  // get a reference surface
122  std::span<Trk::Surface const * const> surfaces = std::as_const(*m_surfaceArray).arrayObjects();
123  // get a reference surface
124  unsigned int rfSurfaces = surfaces.size();
125  if (idx && idx < rfSurfaces) return surfaces[idx];
126  // get the first one which is non zero
127  for (unsigned int rsf = 0; rsf < rfSurfaces; ++rsf) {
128  referenceSurface = surfaces[rsf];
129  if (referenceSurface) break;
130  }
131  }
132  return referenceSurface;
133 }
134 
136  const BoundaryCheck& bchk) const {
137  return (surfaceRepresentation())
138  .isOnSurface(gp, bchk, 0.5 * m_layerThickness);
139 }
140 
141 const Trk::Layer* Trk::Layer::previousLayer(bool skipNavLayer) const {
142  if (!skipNavLayer) return m_previousLayer;
143  const Trk::Layer* prevMatLayer = m_previousLayer;
144  // get the previoys Material layer
145  while (prevMatLayer && !prevMatLayer->layerMaterialProperties() &&
146  !prevMatLayer->surfaceArray())
147  prevMatLayer = prevMatLayer->previousLayer();
148  return prevMatLayer;
149 }
150 
151 const Trk::Layer* Trk::Layer::nextLayer(bool skipNavLayer) const {
152  if (!skipNavLayer) return m_nextLayer;
153  const Trk::Layer* nextMatLayer = m_nextLayer;
154  // get the next Material layer
155  while (nextMatLayer && !nextMatLayer->layerMaterialProperties() &&
156  !nextMatLayer->surfaceArray())
157  nextMatLayer = nextMatLayer->nextLayer();
158  return nextMatLayer;
159 }
160 
162  const Amg::Vector3D& mom) const {
163  // no binutility -> no chance to find out the direction
164  if (!m_binUtility) return nullptr;
165  return (m_binUtility->orderDirection(gp, mom) == Trk::next) ? m_nextLayer
166  : m_previousLayer;
167 }
168 
170  const Trk::TrackParameters& parm) const {
171  if (m_layerMaterialProperties){
172  return m_layerMaterialProperties->fullMaterial(parm.position());
173  }
174  return nullptr;
175 }
176 
178  double scale) {
179  m_layerMaterialProperties.reset(prop.clone());
180  if (scale != 1.0) {
181  (*(m_layerMaterialProperties)) *= scale;
182  }
183 }
184 
185 void
186 Trk::Layer::compactify(size_t& cSurfaces, size_t& tSurfaces)
187 {
188  // set the layer surface representation
189  ++tSurfaces;
190  if (surfaceRepresentation().owner() == Trk::noOwn) {
191  surfaceRepresentation().setOwner(Trk::TGOwn);
192  ++cSurfaces;
193  }
194  // set the subsurface representation, usually already owned by DetElement
195  if (m_surfaceArray) {
196  std::span<Trk::Surface * const> surfaces = m_surfaceArray->arrayObjects();
197  for (Trk::Surface * const sIter : surfaces) {
198  if (sIter && (*sIter).owner() == Trk::noOwn) {
199  (*sIter).setOwner(Trk::TGOwn);
200  ++cSurfaces;
201  }
202  ++tSurfaces;
203  }
204  }
205 }
206 
211  const Trk::BoundaryCheck&, bool,
212  const Trk::ICompatibilityEstimator*) const {
213  return surfaceRepresentation();
214 }
215 
217  std::vector<Trk::SurfaceIntersection>& cSurfaces,
219  const Trk::BoundaryCheck& bcheck, bool materialSurfacesOnly,
220  const Trk::Surface* startSurface, const Trk::Surface* endSurface,
221  const Trk::ICompatibilityEstimator* ice) const {
222  return getCompatibleSurfaces(cSurfaces, pars, pdir, bcheck,
223  materialSurfacesOnly, startSurface, endSurface,
224  ice);
225 }
226 
228  std::vector<Trk::SurfaceIntersection>& cSurfaces,
230  const Trk::BoundaryCheck& bcheck, bool materialSurfacesOnly,
231  const Trk::Surface* startSurface, const Trk::Surface* endSurface,
232  const Trk::ICompatibilityEstimator* ice) const {
233  return getCompatibleSurfaces(cSurfaces, pars, pdir, bcheck,
234  materialSurfacesOnly, startSurface, endSurface,
235  ice);
236 }
237 
238 bool Trk::Layer::hasSubStructure(bool resolveSensitive) const {
239  return resolveSensitive && m_surfaceArray;
240 }
make_hlt_rep.pars
pars
Definition: make_hlt_rep.py:90
Trk::Layer::isOnLayer
virtual bool isOnLayer(const Amg::Vector3D &gp, const BoundaryCheck &bcheck=BoundaryCheck(true)) const
isOnLayer() method, using isOnSurface() with Layer specific tolerance
Definition: Layer.cxx:135
Trk::Layer::fullUpdateMaterialProperties
const MaterialProperties * fullUpdateMaterialProperties(const TrackParameters &par) const
getting the MaterialProperties back - for full update
Definition: Layer.cxx:169
TrackParameters.h
Surface.h
Trk::Layer::m_previousLayer
const Layer * m_previousLayer
< the previous Layer according to BinGenUtils
Definition: Layer.h:296
Trk::noOwn
@ noOwn
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:57
Trk::next
@ next
Definition: BinningData.h:33
Trk::ParametersBase::position
const Amg::Vector3D & position() const
Access method for the position.
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
Trk::Layer::m_layerMaterialProperties
std::unique_ptr< LayerMaterialProperties > m_layerMaterialProperties
thickness of the Layer
Definition: Layer.h:288
Trk::Layer::m_overlapDescriptor
std::unique_ptr< OverlapDescriptor > m_overlapDescriptor
Definition: Layer.h:292
Trk::Layer::m_surfaceArray
std::unique_ptr< SurfaceArray > m_surfaceArray
MaterialPoperties of this layer Surface.
Definition: Layer.h:286
Trk::Layer::Layer
Layer()=default
Default Constructor.
BinUtility.h
Trk::Layer::compactify
void compactify(size_t &cSurfaces, size_t &tSurfaces)
register layer index for material map registration
Definition: Layer.cxx:186
Layer.h
Trk::Layer::subSurfaceReference
const Surface * subSurfaceReference(unsigned int idx=0) const
Return a reference sub surface of the layer, usually the first one in the array.
Definition: Layer.cxx:117
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
Trk::Layer::compatibleSurfaces
size_t compatibleSurfaces(std::vector< SurfaceIntersection > &cSurfaces, const TrackParameters &pars, PropDirection pdir, const BoundaryCheck &bcheck, bool materialSurfacesOnly=true, const Surface *startSurface=nullptr, const Surface *endSurface=nullptr, const ICompatibilityEstimator *ice=nullptr) const
get compatible surfaces starting from charged parameters
python.Utilities.clone
clone
Definition: Utilities.py:134
Trk::Layer::surfaceArray
const SurfaceArray * surfaceArray() const
Return the entire SurfaceArray, returns nullptr if no SurfaceArray.
Trk::Layer::subSurface
const Surface * subSurface(const Amg::Vector3D &gp) const
If no subSurface array is defined or no subSurface can be found to the given Amg::Vector3D,...
Definition: Layer.cxx:107
Trk::Layer::assignMaterialProperties
void assignMaterialProperties(const LayerMaterialProperties &, double scale=1.0)
assignMaterialPropeties
Definition: Layer.cxx:177
Volume.h
Trk::PropDirection
PropDirection
Definition: PropDirection.h:19
ParticleGun_EoverP_Config.mom
mom
Definition: ParticleGun_EoverP_Config.py:63
Trk::Layer::m_layerType
int m_layerType
active passive layer
Definition: Layer.h:307
Trk::LayerMaterialProperties
Definition: LayerMaterialProperties.h:62
Trk::Layer::operator=
Layer & operator=(const Layer &lay)
Assignment operator for Derived classes.
Definition: Layer.cxx:84
Trk::Layer::nextLayer
const Layer * nextLayer(const Amg::Vector3D &gp, const Amg::Vector3D &udir) const
getting the next/previous Layer if registered - unit for direction vector required
Definition: Layer.cxx:161
Trk::Layer::m_enclosingTrackingVolume
const TrackingVolume * m_enclosingTrackingVolume
Enclosing DetachedTrackingVolume.
Definition: Layer.h:302
Trk::Layer::m_ref
double m_ref
reference measure for local coordinate convertors
Definition: Layer.h:308
Trk::Layer::hasSubStructure
virtual bool hasSubStructure(bool resolveSensitive=false) const
Has sub-structure method:
Definition: Layer.cxx:238
Trk::ParametersBase
Definition: ParametersBase.h:55
Trk::TGOwn
@ TGOwn
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:58
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Trk::Layer::m_nextLayer
const Layer * m_nextLayer
BinUtility for next/previous decision.
Definition: Layer.h:298
Trk::Layer::m_binUtility
const BinUtility * m_binUtility
Enclosing TrackingVolume.
Definition: Layer.h:300
Trk::MaterialProperties
Definition: MaterialProperties.h:40
Trk::BoundaryCheck
Definition: BoundaryCheck.h:51
Trk::Layer::previousLayer
const Layer * previousLayer(bool skipNavLayer=false) const
getting what's stored to be the previous Layer, boolean to skip navigation layers
Definition: Layer.cxx:141
Trk::Layer::m_index
LayerIndex m_index
LayerIndex.
Definition: Layer.h:306
Trk::Layer::layerMaterialProperties
const LayerMaterialProperties * layerMaterialProperties() const
getting the LayerMaterialProperties including full/pre/post update
Trk::LayerMaterialProperties::clone
virtual LayerMaterialProperties * clone() const =0
Pseudo-Constructor clone()
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
Trk::Layer::m_layerThickness
double m_layerThickness
descriptor for overlap/next surface (owning ptr)
Definition: Layer.h:290
LArNewCalib_Delay_OFC_Cali.pdir
string pdir
Definition: LArNewCalib_Delay_OFC_Cali.py:182
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:79
Trk::Layer::m_enclosingDetachedTrackingVolume
const DetachedTrackingVolume * m_enclosingDetachedTrackingVolume
Definition: Layer.h:304
LayerMaterialProperties.h
Trk::Layer
Definition: Layer.h:72
Trk::Layer::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
Surface seen on approach - if not defined differently, it is the surfaceRepresentation()
Definition: Layer.cxx:209