ATLAS Offline Software
Layer.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 // 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  : m_surfaceArray(nullptr),
20  m_layerMaterialProperties(nullptr),
21  m_layerThickness(0.),
22  m_overlapDescriptor(nullptr),
23  m_previousLayer(nullptr),
24  m_nextLayer(nullptr),
25  m_binUtility(nullptr),
26  m_enclosingTrackingVolume(nullptr),
27  m_enclosingDetachedTrackingVolume(nullptr),
28  m_index(-1),
29  m_layerType(Trk::active),
30  m_ref(0.) {}
31 
33  double thickness,
34  std::unique_ptr<Trk::OverlapDescriptor> olap, int laytyp)
35  : m_surfaceArray(nullptr),
36  m_layerMaterialProperties(laymatprop.clone()),
37  m_layerThickness(thickness),
38  m_overlapDescriptor(std::move(olap)),
39  m_previousLayer(nullptr),
40  m_nextLayer(nullptr),
41  m_binUtility(nullptr),
42  m_enclosingTrackingVolume(nullptr),
43  m_enclosingDetachedTrackingVolume(nullptr),
44  m_index(-1),
45  m_layerType(laytyp),
46  m_ref(0.) {}
47 
48 Trk::Layer::Layer(std::unique_ptr<Trk::SurfaceArray> surfaceArray, double thickness,
49  std::unique_ptr<Trk::OverlapDescriptor> olap, int laytyp)
50  : m_surfaceArray(std::move(surfaceArray)),
51  m_layerMaterialProperties(nullptr),
52  m_layerThickness(thickness),
53  m_overlapDescriptor(std::move(olap)),
54  m_previousLayer(nullptr),
55  m_nextLayer(nullptr),
56  m_binUtility(nullptr),
57  m_enclosingTrackingVolume(nullptr),
58  m_enclosingDetachedTrackingVolume(nullptr),
59  m_index(-1),
60  m_layerType(laytyp),
61  m_ref(0.) {}
62 
63 Trk::Layer::Layer(std::unique_ptr<Trk::SurfaceArray> surfaceArray,
64  const Trk::LayerMaterialProperties& laymatprop,
65  double thickness,
66  std::unique_ptr<Trk::OverlapDescriptor> olap, int laytyp)
67  : m_surfaceArray(std::move(surfaceArray)),
68  m_layerMaterialProperties(laymatprop.clone()),
69  m_layerThickness(thickness),
70  m_overlapDescriptor(std::move(olap)),
71  m_previousLayer(nullptr),
72  m_nextLayer(nullptr),
73  m_binUtility(nullptr),
74  m_enclosingTrackingVolume(nullptr),
75  m_enclosingDetachedTrackingVolume(nullptr),
76  m_index(-1),
77  m_layerType(laytyp),
78  m_ref(0.) {}
79 
81  : m_surfaceArray(lay.m_surfaceArray ? lay.m_surfaceArray->clone()
82  : nullptr),
83  m_layerMaterialProperties(lay.m_layerMaterialProperties
84  ? lay.m_layerMaterialProperties->clone()
85  : nullptr),
86  m_layerThickness(lay.m_layerThickness),
87  m_overlapDescriptor(
88  lay.m_overlapDescriptor ? lay.m_overlapDescriptor->clone() : nullptr),
89  m_previousLayer(nullptr),
90  m_nextLayer(nullptr),
91  m_binUtility(nullptr),
92  m_enclosingTrackingVolume(nullptr),
93  m_enclosingDetachedTrackingVolume(nullptr),
94  m_index(-1),
95  m_layerType(lay.m_layerType),
96  m_ref(lay.m_ref) {}
97 
99  if (this != &lay) {
100  m_layerThickness = lay.m_layerThickness;
101  m_enclosingDetachedTrackingVolume = lay.m_enclosingDetachedTrackingVolume;
102  m_overlapDescriptor.reset(
103  (lay.m_overlapDescriptor) ? lay.m_overlapDescriptor->clone() : nullptr);
104  m_surfaceArray.reset((lay.m_surfaceArray) ? lay.m_surfaceArray->clone()
105  : nullptr);
106  m_layerMaterialProperties.reset(lay.m_layerMaterialProperties->clone());
107 
108  // just assign by pointer
109  m_nextLayer = lay.m_nextLayer;
110  m_previousLayer = lay.m_previousLayer;
111  m_binUtility = lay.m_binUtility;
112  m_enclosingTrackingVolume = lay.m_enclosingTrackingVolume;
113  //
114  m_index = lay.m_index;
115  m_layerType = lay.m_layerType;
116  m_ref = lay.m_ref;
117  }
118  return (*this);
119 }
120 
122  if (m_surfaceArray) return m_surfaceArray->object(gp);
123  return nullptr;
124 }
125 
127  if (m_surfaceArray) return m_surfaceArray->object(lp);
128  return nullptr;
129 }
130 
132  // the reference surface
133  const Trk::Surface* referenceSurface = nullptr;
134  if (m_surfaceArray) {
135  // get a reference surface
136  Trk::BinnedArraySpan<Trk::Surface const * const> surfaces = std::as_const(*m_surfaceArray).arrayObjects();
137  // get a reference surface
138  unsigned int rfSurfaces = surfaces.size();
139  if (idx && idx < rfSurfaces) return surfaces[idx];
140  // get the first one which is non zero
141  for (unsigned int rsf = 0; rsf < rfSurfaces; ++rsf) {
142  referenceSurface = surfaces[rsf];
143  if (referenceSurface) break;
144  }
145  }
146  return referenceSurface;
147 }
148 
150  const BoundaryCheck& bchk) const {
151  return (surfaceRepresentation())
152  .isOnSurface(gp, bchk, 0.5 * m_layerThickness);
153 }
154 
155 const Trk::Layer* Trk::Layer::previousLayer(bool skipNavLayer) const {
156  if (!skipNavLayer) return m_previousLayer;
157  const Trk::Layer* prevMatLayer = m_previousLayer;
158  // get the previoys Material layer
159  while (prevMatLayer && !prevMatLayer->layerMaterialProperties() &&
160  !prevMatLayer->surfaceArray())
161  prevMatLayer = prevMatLayer->previousLayer();
162  return prevMatLayer;
163 }
164 
165 const Trk::Layer* Trk::Layer::nextLayer(bool skipNavLayer) const {
166  if (!skipNavLayer) return m_nextLayer;
167  const Trk::Layer* nextMatLayer = m_nextLayer;
168  // get the next Material layer
169  while (nextMatLayer && !nextMatLayer->layerMaterialProperties() &&
170  !nextMatLayer->surfaceArray())
171  nextMatLayer = nextMatLayer->nextLayer();
172  return nextMatLayer;
173 }
174 
176  const Amg::Vector3D& mom) const {
177  // no binutility -> no chance to find out the direction
178  if (!m_binUtility) return nullptr;
179  return (m_binUtility->orderDirection(gp, mom) == Trk::next) ? m_nextLayer
180  : m_previousLayer;
181 }
182 
184  const Trk::TrackParameters& parm) const {
185  if (m_layerMaterialProperties){
186  return m_layerMaterialProperties->fullMaterial(parm.position());
187  }
188  return nullptr;
189 }
190 
192  double scale) {
193  m_layerMaterialProperties.reset(prop.clone());
194  if (scale != 1.0) {
195  (*(m_layerMaterialProperties)) *= scale;
196  }
197 }
198 
199 void
200 Trk::Layer::compactify(size_t& cSurfaces, size_t& tSurfaces)
201 {
202  // set the layer surface representation
203  ++tSurfaces;
204  if (surfaceRepresentation().owner() == Trk::noOwn) {
205  surfaceRepresentation().setOwner(Trk::TGOwn);
206  ++cSurfaces;
207  }
208  // set the subsurface representation, usually already owned by DetElement
209  if (m_surfaceArray) {
210  BinnedArraySpan<Trk::Surface * const> surfaces = m_surfaceArray->arrayObjects();
211  for (Trk::Surface * const sIter : surfaces) {
212  if (sIter && (*sIter).owner() == Trk::noOwn) {
213  (*sIter).setOwner(Trk::TGOwn);
214  ++cSurfaces;
215  }
216  ++tSurfaces;
217  }
218  }
219 }
220 
225  const Trk::BoundaryCheck&, bool,
226  const Trk::ICompatibilityEstimator*) const {
227  return surfaceRepresentation();
228 }
229 
231  std::vector<Trk::SurfaceIntersection>& cSurfaces,
233  const Trk::BoundaryCheck& bcheck, bool materialSurfacesOnly,
234  const Trk::Surface* startSurface, const Trk::Surface* endSurface,
235  const Trk::ICompatibilityEstimator* ice) const {
236  return getCompatibleSurfaces(cSurfaces, pars, pdir, bcheck,
237  materialSurfacesOnly, startSurface, endSurface,
238  ice);
239 }
240 
242  std::vector<Trk::SurfaceIntersection>& cSurfaces,
244  const Trk::BoundaryCheck& bcheck, bool materialSurfacesOnly,
245  const Trk::Surface* startSurface, const Trk::Surface* endSurface,
246  const Trk::ICompatibilityEstimator* ice) const {
247  return getCompatibleSurfaces(cSurfaces, pars, pdir, bcheck,
248  materialSurfacesOnly, startSurface, endSurface,
249  ice);
250 }
251 
252 inline bool Trk::Layer::hasSubStructure(bool resolveSensitive) const {
253  return resolveSensitive && m_surfaceArray;
254 }
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:149
Trk::Layer::fullUpdateMaterialProperties
const MaterialProperties * fullUpdateMaterialProperties(const TrackParameters &par) const
getting the MaterialProperties back - for full update
Definition: Layer.cxx:183
TrackParameters.h
Surface.h
Trk::Layer::m_previousLayer
const Layer * m_previousLayer
< the previous Layer according to BinGenUtils
Definition: Layer.h:297
Trk::noOwn
@ noOwn
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:54
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:289
Trk::Layer::m_overlapDescriptor
std::unique_ptr< OverlapDescriptor > m_overlapDescriptor
Definition: Layer.h:293
Trk::Layer::m_surfaceArray
std::unique_ptr< SurfaceArray > m_surfaceArray
MaterialPoperties of this layer Surface.
Definition: Layer.h:287
BinUtility.h
Trk::Layer::compactify
void compactify(size_t &cSurfaces, size_t &tSurfaces)
register layer index for material map registration
Definition: Layer.cxx:200
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:131
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:121
Trk::Layer::assignMaterialProperties
void assignMaterialProperties(const LayerMaterialProperties &, double scale=1.0)
assignMaterialPropeties
Definition: Layer.cxx:191
Volume.h
Trk::PropDirection
PropDirection
Definition: PropDirection.h:19
ParticleGun_EoverP_Config.mom
mom
Definition: ParticleGun_EoverP_Config.py:63
Trk::active
@ active
Definition: Layer.h:48
Trk::Layer::m_layerType
int m_layerType
active passive layer
Definition: Layer.h:308
Trk::LayerMaterialProperties
Definition: LayerMaterialProperties.h:62
Trk::Layer::operator=
Layer & operator=(const Layer &lay)
Assignment operator for Derived classes.
Definition: Layer.cxx:98
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:175
Trk::Layer::m_enclosingTrackingVolume
const TrackingVolume * m_enclosingTrackingVolume
Enclosing DetachedTrackingVolume.
Definition: Layer.h:303
Trk::Layer::m_ref
double m_ref
reference measure for local coordinate convertors
Definition: Layer.h:309
Trk::Layer::hasSubStructure
virtual bool hasSubStructure(bool resolveSensitive=false) const
Has sub-structure method:
Definition: Layer.cxx:252
Trk::ParametersBase
Definition: ParametersBase.h:55
Trk::Layer::Layer
Layer()
Default Constructor.
Definition: Layer.cxx:18
Trk::TGOwn
@ TGOwn
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:55
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
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:299
Trk::Layer::m_binUtility
const BinUtility * m_binUtility
Enclosing TrackingVolume.
Definition: Layer.h:301
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:155
Trk::Layer::m_index
LayerIndex m_index
LayerIndex.
Definition: Layer.h:307
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:291
LArNewCalib_Delay_OFC_Cali.pdir
string pdir
Definition: LArNewCalib_Delay_OFC_Cali.py:172
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
Trk::BinnedArraySpan
std::span< T > BinnedArraySpan
Definition: BinnedArray.h:34
Trk::Layer::m_enclosingDetachedTrackingVolume
const DetachedTrackingVolume * m_enclosingDetachedTrackingVolume
Definition: Layer.h:305
LayerMaterialProperties.h
Trk::Layer
Definition: Layer.h:73
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:223