2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
7 inline const std::string&
8 TrackingVolume::volumeName() const
14 TrackingVolume::layerAttempts(BoundarySurfaceFace exitFace) const
16 if (m_layerAttemptsCalculator)
17 return m_layerAttemptsCalculator->layerAttempts(exitFace);
18 return TRKGEOMETRY_MAXLAYERATTEMPTS;
22 TrackingVolume::maxLayerAttempts() const
24 if (m_layerAttemptsCalculator){
25 return m_layerAttemptsCalculator->maxLayerAttempts();
27 return TRKGEOMETRY_MAXLAYERATTEMPTS;
30 inline const LayerArray*
31 TrackingVolume::confinedLayers() const
33 return m_confinedLayers.get();
37 TrackingVolume::confinedLayers()
39 return m_confinedLayers.get();
42 inline const TrackingVolumeArray*
43 TrackingVolume::confinedVolumes() const
45 return m_confinedVolumes.get();
48 inline TrackingVolumeArray*
49 TrackingVolume::confinedVolumes()
51 return m_confinedVolumes.get();
54 inline ArraySpan<Layer const* const>
55 TrackingVolume::confinedArbitraryLayers() const
57 if (m_confinedArbitraryLayers) {
58 return ArraySpan<Layer const* const>(m_confinedArbitraryLayers->begin(),
59 m_confinedArbitraryLayers->end());
64 inline ArraySpan<Layer* const>
65 TrackingVolume::confinedArbitraryLayers()
68 if (m_confinedArbitraryLayers) {
69 return ArraySpan<Layer* const>(m_confinedArbitraryLayers->begin(),
70 m_confinedArbitraryLayers->end());
75 inline ArraySpan<DetachedTrackingVolume const * const>
76 TrackingVolume::confinedDetachedVolumes() const
78 if (m_confinedDetachedVolumes) {
79 return ArraySpan<DetachedTrackingVolume const* const>(
80 m_confinedDetachedVolumes->begin(), m_confinedDetachedVolumes->end());
85 inline ArraySpan<DetachedTrackingVolume* const>
86 TrackingVolume::confinedDetachedVolumes()
88 if (m_confinedDetachedVolumes) {
89 return ArraySpan<DetachedTrackingVolume* const>(
90 m_confinedDetachedVolumes->begin(), m_confinedDetachedVolumes->end());
95 inline ArraySpan<TrackingVolume const* const>
96 TrackingVolume::confinedDenseVolumes() const
98 if (m_confinedDenseVolumes) {
99 return ArraySpan<TrackingVolume const* const>(
100 m_confinedDenseVolumes->begin(), m_confinedDenseVolumes->end());
105 inline ArraySpan<Trk::TrackingVolume* const>
106 TrackingVolume::confinedDenseVolumes()
108 if (m_confinedDenseVolumes) {
109 return ArraySpan<TrackingVolume* const>(m_confinedDenseVolumes->begin(),
110 m_confinedDenseVolumes->end());
117 TrackingVolume::onVolumeBoundary(const T& pars) const
119 // get the associated Surface
120 const Surface* pSurface = &pars.associatedSurface();
121 const auto& bSurfaces = boundarySurfaces();
122 // fast loop pointer comparison of the surfaces
123 for (size_t i = 0; i < bSurfaces.size(); ++i) {
124 const BoundarySurface<TrackingVolume>* bSurface = bSurfaces[i];
125 // pointer of the parameter surface is identical with one of the boundary
127 if (pSurface == &bSurface->surfaceRepresentation())
130 // slow loop - checking the onSurface (does pointer comparison as well)
131 for (size_t i = 0; i < bSurfaces.size(); ++i) {
132 const BoundarySurface<TrackingVolume>* bSurface = bSurfaces[i];
133 // pointer of the parameter surface is identical with one of the boundary
135 if (bSurface->onBoundary(pars))
138 // could not find an onSurface
142 /** Return the material layers ordered based on straight line intersections
143 - start and end layer are always part of it
146 std::vector<LayerIntersection<T>>
147 TrackingVolume::materialLayersOrdered(const Layer* sLayer,
151 const BoundaryCheck& bchk,
152 bool resolveSubSurfaces) const
154 // get position and momentum from the parameters
155 const Amg::Vector3D& gp = pars.position();
156 const Amg::Vector3D& gm = pars.momentum();
157 // the layer intersections
158 std::vector<LayerIntersection<T>> lIntersections;
159 // assign the direction
160 const Amg::Vector3D& dir =
161 (pDir == alongMomentum ? gm.unit() : Amg::Vector3D(-1 * gm.unit()));
162 // the confinedLayers
163 if (m_confinedLayers) {
164 // cache the longest path length to avoid punch-through to the other side
165 Trk::Intersection sLayerIntersection(
166 Amg::Vector3D(0., 0., 0), 0., true, 0.);
167 const Trk::Surface* sLayerSurface = nullptr;
168 double validPathLength = 0.;
169 // start layer given or not - test layer
170 const Trk::Layer* tLayer = sLayer ? sLayer : associatedLayer(gp);
173 // collect material or sensitive layers, always provide the final layer
174 // for the navigation stop
175 if (tLayer->layerMaterialProperties() || tLayer->surfaceArray() ||
177 // get the approaching surface
178 const Surface& tSurface =
179 tLayer->surfaceOnApproach(gp, dir, pDir, bchk, resolveSubSurfaces);
180 // calculate the intersection with the layer
181 Trk::Intersection lIntersection =
182 tSurface.straightLineIntersection(gp, dir, true, bchk);
183 // (a) if the current layer is NOT the start layer - intersection is
185 if (tLayer != sLayer && lIntersection.valid) {
186 lIntersections.push_back(
187 LayerIntersection<T>(lIntersection, tLayer, &tSurface, 0, pDir));
188 validPathLength = lIntersection.pathLength;
189 } else if (tLayer == sLayer) {
190 // (b) the current layer is the start layer - we need to cache it
191 // and check with the path length
192 // this avoids potential punch-through to other side of
193 sLayerIntersection = lIntersection;
194 sLayerSurface = &tSurface;
195 } else if (tLayer == eLayer) {
196 // (c) it is the end layer after all - provide it and break the loop
197 lIntersections.push_back(
198 LayerIntersection<T>(lIntersection, tLayer, &tSurface, 0, pDir));
202 // move to next one or break because you reached the end layer
203 tLayer = (tLayer == eLayer) ? nullptr : tLayer->nextLayer(gp, dir);
207 // final check for compatibility of the start layer in order to avoid
209 if (sLayer && sLayerIntersection.valid &&
210 sLayerIntersection.pathLength < validPathLength)
211 lIntersections.push_back(LayerIntersection<T>(
212 sLayerIntersection, sLayer, sLayerSurface, 0, pDir));
214 // and the arbitraray layers
215 if (m_confinedArbitraryLayers) {
216 // loop over the layers and intersect them
217 for (auto& layer : (*m_confinedArbitraryLayers)) {
219 Trk::Intersection lIntersection =
220 layer->surfaceRepresentation().straightLineIntersection(
221 gp, dir, true, bchk);
222 if (lIntersection.valid)
223 lIntersections.push_back(LayerIntersection<T>(
224 lIntersection, layer, &(layer->surfaceRepresentation()), 0, pDir));
228 // sort them accordingly to the path length
229 std::sort(lIntersections.begin(), lIntersections.end());
231 return lIntersections;
234 /** Returns the boundary surfaces ordered in probability to hit them based on
235 * straight line intersection @todo change hard-coded default */
237 std::vector<BoundaryIntersection<T>>
238 TrackingVolume::boundarySurfacesOrdered(const T& pars,
243 // assign the direction
245 const Amg::Vector3D dir =
246 (pDir == alongMomentum ? pars.momentum().unit()
247 : Amg::Vector3D(-1 * pars.momentum().unit()));
248 // loop over boundarySurfaces and calculate the intersection
249 std::vector<BoundaryIntersection<T>> bIntersections;
250 const auto& bSurfaces = boundarySurfaces();
251 for (size_t i = 0; i < bSurfaces.size(); ++i) {
252 const BoundarySurface<TrackingVolume>* bSurface = bSurfaces[i];
253 Intersection bsIntersection =
254 bSurface->surfaceRepresentation().straightLineIntersection(
255 pars.position(), dir, true, false);
256 if (bsIntersection.valid)
257 bIntersections.push_back(
258 BoundaryIntersection<T>(bsIntersection,
260 &(bSurface->surfaceRepresentation()),
264 // and now sort to get the closest
265 std::sort(bIntersections.begin(), bIntersections.end());
267 return bIntersections;
270 inline GeometrySignature
271 TrackingVolume::geometrySignature() const
273 return m_geometrySignature;
277 TrackingVolume::geometryType() const
279 return m_geometryType;
283 TrackingVolume::registerColorCode(unsigned int icolor)
285 m_colorCode = icolor;
289 TrackingVolume::colorCode() const
294 inline const TrackingVolume*
295 TrackingVolume::getMotherVolume() const
297 return m_motherVolume;
301 TrackingVolume::setMotherVolume(const TrackingVolume* mvol)
303 m_motherVolume = mvol;
307 TrackingVolume::isAlignable() const