ATLAS Offline Software
Loading...
Searching...
No Matches
TrackingVolume.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6// TrackingVolume.h, (b) ATLAS Detector software
8
9#ifndef TRKGEOMETRY_TRACKINGVOLUME_H
10#define TRKGEOMETRY_TRACKINGVOLUME_H
11
12// Amg
14// Trk
18#include <memory>
25#include "TrkSurfaces/Surface.h"
30#include "TrkVolumes/Volume.h"
31// STL
32#include <string>
33#include <span>
34// ATH_MSG macros
36
39#ifndef TRKGEOMETRY_MAXLAYERATTEMPTS
40#define TRKGEOMETRY_MAXLAYERATTEMPTS 100
41#endif
42
43class MsgStream;
44
45namespace Trk {
46
47// classes
48class Layer;
49class PlaneLayer;
50class TrackingVolume;
51class DetachedTrackingVolume;
52class VolumeBounds;
53
54//Binned Array arrayObjects returns a span
57
58template<class T>
59using ArraySpan = std::span<T>;
60
61//Helper for const correct access to boundary surfaces via a span
62//We want const correct access to the underlying plain ptrs.
63template<class T>
65{
66public:
67 ConstSharedPtrSpan(const std::vector<std::shared_ptr<T>>& var)
68 : m_span(var)
69 {
70 }
71 // access the ptr
72 const T * operator[](size_t i) const { return m_span[i].get(); }
73 constexpr bool empty() const noexcept { return m_span.empty(); }
74 constexpr size_t size() const noexcept { return m_span.size(); }
75
76private:
78};
79
80
81template<class T>
83template<class T>
86
115
117 : public Volume
118 , public Material
119{
120
123
125 friend class TrackingGeometry;
126
129
130public:
132 TrackingVolume() = default;
133
136 TrackingVolume(std::unique_ptr<Amg::Transform3D> htrans,
137 std::shared_ptr<VolumeBounds> volbounds,
138 std::unique_ptr<LayerArray> subLayers = nullptr,
139 std::unique_ptr<TrackingVolumeArray> subVolumes = nullptr,
140 const std::string& volumeName = "undefined");
141
144 TrackingVolume(const Volume& volume,
145 const Material& matprop,
146 std::unique_ptr<LayerArray> subLayers = nullptr,
147 std::unique_ptr<TrackingVolumeArray> subVolumes = nullptr,
148 const std::string& volumeName = "undefined");
149
152 TrackingVolume(std::unique_ptr<Amg::Transform3D> htrans,
153 std::shared_ptr<VolumeBounds> volbounds,
154 const Material& matprop,
155 std::unique_ptr<LayerArray> subLayers = nullptr,
156 std::unique_ptr<TrackingVolumeArray> subVolumes = nullptr,
157 const std::string& volumeName = "undefined");
158
162 std::unique_ptr<Amg::Transform3D> htrans,
163 std::shared_ptr<VolumeBounds> volbounds,
164 const Material& matprop,
165 std::unique_ptr<std::vector<DetachedTrackingVolume*>> detachedSubVolumes,
166 const std::string& volumeName = "undefined");
167
171 const Volume& volume,
172 const Material& matprop,
173 std::unique_ptr<std::vector<DetachedTrackingVolume*>> detachedSubVolumes,
174 const std::string& volumeName = "undefined");
175
178 TrackingVolume(std::unique_ptr<Amg::Transform3D> htrans,
179 std::shared_ptr<VolumeBounds> volbounds,
180 const Material& matprop,
181 std::unique_ptr<const std::vector<TrackingVolume*>> unorderedSubVolumes,
182 const std::string& volumeName = "undefined");
183
186 TrackingVolume(const Volume& volume,
187 const Material& matprop,
188 std::unique_ptr<const std::vector<TrackingVolume*>> unorderedSubVolumes,
189 const std::string& volumeName = "undefined");
190
193 TrackingVolume(std::unique_ptr<Amg::Transform3D> htrans,
194 std::shared_ptr<VolumeBounds> volbounds,
195 const Material& matprop,
196 std::unique_ptr<const std::vector<Layer*>> arbitraryLayers,
197 const std::string& volumeName = "undefined");
198
201 TrackingVolume(const Volume& volume,
202 const Material& matprop,
203 std::unique_ptr<const std::vector<Layer*>> arbitraryLayers,
204 const std::string& volumeName = "undefined");
205
209 TrackingVolume(std::unique_ptr<Amg::Transform3D> htrans,
210 std::shared_ptr<VolumeBounds> volbounds,
211 std::unique_ptr<const std::vector<Layer*>> arbitraryLayers,
212 std::unique_ptr<const std::vector<TrackingVolume*>> unorderedSubVolumes,
213 const Material& matprop,
214 const std::string& volumeName = "undefined");
215
219 TrackingVolume(const Volume& volume,
220 std::unique_ptr<const std::vector<Layer*>> arbitraryLayers,
221 std::unique_ptr<const std::vector<TrackingVolume*>> unorderedSubVolumes,
222 const Material& matprop,
223 const std::string& volumeName = "undefined");
224
227
229 virtual ~TrackingVolume() override;
230
232 const Layer* associatedLayer(const Amg::Vector3D& gp) const;
234
235
237 const Layer* nextLayer(const Amg::Vector3D& gp,
238 const Amg::Vector3D& mom,
239 bool asres = true,
240 bool skipNavLayer = false) const;
241
245 const Amg::Vector3D& dir) const;
246
248 const Layer* exitLayer(const Amg::Vector3D& gp,
249 const Amg::Vector3D& dir) const;
250
254 template<class T>
255 std::vector<LayerIntersection<T>> materialLayersOrdered(
256 const Layer* sLayer,
257 const Layer* eLayer,
258 const T& parameters,
260 const BoundaryCheck& bchk = true,
261 bool resolveSubSurfaces = false) const;
262
269 const Amg::Vector3D& gp,
270 const Amg::Vector3D& dir,
272 const BoundaryCheck& bchk = true) const;
273
275 const TrackingVolume* associatedSubVolume(const Amg::Vector3D& gp) const;
277
279 const TrackingVolume* nextVolume(const Amg::Vector3D& gp,
280 const Amg::Vector3D& dir,
281 PropDirection pDir = alongMomentum) const;
282
286 const Amg::Vector3D& dir) const;
287
289 std::vector<const DetachedTrackingVolume*> assocDetachedSubVolumes(
290 const Amg::Vector3D& gp,
291 double tol) const;
292
294 unsigned int layerAttempts(BoundarySurfaceFace exitFace) const;
295
297 unsigned int maxLayerAttempts() const;
298
301
304
307
310
312 const LayerArray* checkoutConfinedLayers() const;
313
316
319
323
327
329 const std::string& volumeName() const;
330
332 std::vector<std::shared_ptr<BoundarySurface<TrackingVolume>>>& boundarySurfaces() ;
336 template<class T>
337 std::vector<BoundaryIntersection<T>> boundarySurfacesOrdered(
338 const T& parameters,
340 bool startOffBoundary = false) const;
341
344 const ObjectAccessor::value_type& oa) const;
345
347 template<class T>
348 bool onVolumeBoundary(const T& pars) const;
349
356
358
361
363 void sign(GeometrySignature signat, GeometryType gtype = Static);
364
367
370
372 void registerColorCode(unsigned int icolor);
373
375 unsigned int colorCode() const;
376
379
382
384 void moveVolume(Amg::Transform3D& shift);
385
387 void addMaterial(const Material& mat, float fact = 1.);
388
389 virtual bool isAlignable() const;
390
391 void screenDump(MsgStream& msg) const;
392
393private:
395 void indexContainedStaticLayers(GeometrySignature geoSig, int& offset);
396
398 void indexContainedMaterialLayers(GeometrySignature geoSig, int& offset);
399
402
405
410 void compactify(size_t& rSurfaces, size_t& tSurfaces);
411
416 void synchronizeLayers (MsgStream& msgstream, double envelope = 1.);
417
419 void interlinkLayers ();
420
422 static const Layer* closest(const Amg::Vector3D& pos,
423 const Amg::Vector3D& dir,
424 const Layer& first,
425 const Layer& second);
426
429
434
438 std::vector<std::shared_ptr<BoundarySurface<TrackingVolume>>> m_boundarySurfaces{nullptr};
440 std::unique_ptr<LayerArray> m_confinedLayers{nullptr};
442 std::unique_ptr<TrackingVolumeArray> m_confinedVolumes{nullptr};
444 std::unique_ptr<const std::vector<DetachedTrackingVolume*>> m_confinedDetachedVolumes{nullptr};
446 std::unique_ptr<const std::vector<TrackingVolume*>> m_confinedDenseVolumes{nullptr};
448 std::unique_ptr<const std::vector<Layer*>> m_confinedArbitraryLayers{nullptr};
452 std::unique_ptr<LayerAttemptsCalculator> m_layerAttemptsCalculator{nullptr};
457 std::string m_name {"undefined"};
458 unsigned int m_colorCode{20} ;
459};
460
461} // end of namespace
463#endif // TRKGEOMETRY_TRACKINGVOLUME_H
464
Cached unique_ptr with atomic update.
Define macros for attributes used to control the static checker.
Cached pointer with atomic update.
Binned Array for avoiding map searches/.
Definition BinnedArray.h:36
The BoundaryCheck class allows to steer the way surface boundaries are used for inside/outside checks...
Description of a BoundarySurface inside the tracking realm, it extends the Surface description to mak...
constexpr size_t size() const noexcept
constexpr bool empty() const noexcept
const T * operator[](size_t i) const
ConstSharedPtrSpan(const std::vector< std::shared_ptr< T > > &var)
ArraySpan< const std::shared_ptr< T > > m_span
Class extension to return the object, a represenation & the result.
Descriptor class to hold GlueVolumes of a TrackingGeometry object.
Base Class for a Detector Layer in the Tracking realm.
Definition Layer.h:72
Material()
Default Constructor needed for POOL.
Definition Material.h:130
Abstract Base Class for tracking surfaces.
void setMotherVolume(const TrackingVolume *mvol)
set the MotherVolume
ArraySpan< TrackingVolume *const > confinedDenseVolumes()
friend class TrackingGeometry
Give the TrackingGeometry friend rights.
friend class DetachedTrackingVolume
Give the DetachedTrackingVolume friend rights.
const LayerArray * confinedLayers() const
Return the subLayer array.
GeometrySignature geometrySignature() const
return the Signature
friend class TrackingVolumeManipulator
The TrackingVolumeManipulator has to be a friend.
const TrackingVolume * nextVolume(const Amg::Vector3D &gp, const Amg::Vector3D &dir, PropDirection pDir=alongMomentum) const
Return the next volume along the navigation stream.
TrackingVolume(const TrackingVolume &)=delete
Forbidden copy constructor.
LayerIntersection< Amg::Vector3D > closestMaterialLayer(const Amg::Vector3D &gp, const Amg::Vector3D &dir, PropDirection pDir=alongMomentum, const BoundaryCheck &bchk=true) const
Return the closest layer with material description.
const Layer * entryLayer(const Amg::Vector3D &gp, const Amg::Vector3D &dir) const
Return the entry Layer to a TrackingVolume depending on the entry point.
std::vector< LayerIntersection< T > > materialLayersOrdered(const Layer *sLayer, const Layer *eLayer, const T &parameters, PropDirection pDir=alongMomentum, const BoundaryCheck &bchk=true, bool resolveSubSurfaces=false) const
Return the material layers ordered based on straight line intersections:
void moveTV(Amg::Transform3D &transform)
move the Tracking Volume
void indexContainedMaterialLayers(GeometrySignature geoSig, int &offset)
reIndex the material layers of the TrackingVolume
const TrackingVolume * nextSubVolume(const Amg::Vector3D &gp, const Amg::Vector3D &dir) const
Return the next sub Volume if existing, returns THIS if no subVolume exists.
ArraySpan< DetachedTrackingVolume *const > confinedDetachedVolumes()
std::unique_ptr< LayerAttemptsCalculator > m_layerAttemptsCalculator
defines how the Extrapolator propagates through this
TrackingVolume()=default
Default Constructor.
const Layer * associatedLayer(const Amg::Vector3D &gp) const
Return the associated Layer.
unsigned int m_colorCode
Color code for displaying.
TrackingVolume & operator=(const TrackingVolume &)=delete
Forbid assignment.
const LayerArray * checkoutConfinedLayers() const
Return the subLayerarray including the ownership.
bool onVolumeBoundary(const T &pars) const
show if you are on a boundary surface
const TrackingVolumeArray * confinedVolumes() const
Return the subLayer array.
const TrackingVolume * getMotherVolume() const
Return the MotherVolume - if it exists.
std::vector< const DetachedTrackingVolume * > assocDetachedSubVolumes(const Amg::Vector3D &gp, double tol) const
Return the associated detached subvolumes.
std::unique_ptr< const std::vector< TrackingVolume * > > m_confinedDenseVolumes
Additionally, Unordered Layers inside the Volume (we own the elements)
TrackingVolumeArray * confinedVolumes()
Return the subLayer array.
const TrackingVolume * associatedSubVolume(const Amg::Vector3D &gp) const
Return the associated sub Volume, returns THIS if no subVolume exists.
void registerColorCode(unsigned int icolor)
Register the color code.
void indexContainedStaticLayers(GeometrySignature geoSig, int &offset)
reIndex the static layers of the TrackingVolume
std::vector< std::shared_ptr< BoundarySurface< TrackingVolume > > > & boundarySurfaces()
Method to return the BoundarySurfaces.
LayerArray * confinedLayers()
Return the subLayer array.
const std::string & volumeName() const
Returns the VolumeName - for debug reason, might be depreciated later.
std::unique_ptr< const std::vector< DetachedTrackingVolume * > > m_confinedDetachedVolumes
Additionally, Unordered subvolumes (we own the elements)
std::unique_ptr< LayerArray > m_confinedLayers
Array of Volumes inside the Volume.
std::vector< BoundaryIntersection< T > > boundarySurfacesOrdered(const T &parameters, PropDirection pDir=alongMomentum, bool startOffBoundary=false) const
Returns the boundary surfaces ordered in probability to hit them based on straight line intersection.
const Layer * nextLayer(const Amg::Vector3D &gp, const Amg::Vector3D &mom, bool asres=true, bool skipNavLayer=false) const
Return the next Layer if existing, NULL if no next layer corresponds.
std::unique_ptr< TrackingVolumeArray > m_confinedVolumes
Detached subvolumes.
std::string m_name
Volume name for debug reasons.
void registerOutsideGlueVolumes(GlueVolumesDescriptor *gvd)
Register the outside glue volumes - ordering is in the TrackingVolume Frame:
void addMaterial(const Material &mat, float fact=1.)
add Material
void interlinkLayers()
Register Next - Previous for Layers, set volumelink.
void synchronizeLayers(MsgStream &msgstream, double envelope=1.)
method to synchronize the layers with potentially updated volume bounds:
void moveVolume(Amg::Transform3D &shift)
move Volume
CxxUtils::CachedUniquePtrT< GlueVolumesDescriptor > m_outsideGlueVolumes
provided the number of layer attempts
unsigned int layerAttempts(BoundarySurfaceFace exitFace) const
Layer attempts - as provided by the LayerAttemptCreator.
ArraySpan< DetachedTrackingVolume const *const > confinedDetachedVolumes() const
Return detached subVolumes - not the ownership.
void sign(GeometrySignature signat, GeometryType gtype=Static)
sign the volume - the geometry builder has to do that
const Layer * exitLayer(const Amg::Vector3D &gp, const Amg::Vector3D &dir) const
Return the exit Layer from a TrackingVolume.
void compactify(size_t &rSurfaces, size_t &tSurfaces)
compactify the memory usage in the event by setting ownership to TackingGeometry the referenced types...
const TrackingVolume * m_motherVolume
boundary Surfaces, they can be shared between volumes
std::vector< std::shared_ptr< BoundarySurface< TrackingVolume > > > m_boundarySurfaces
GeometryType m_geometryType
The Signature done by the GeometryBuilder.
void createLayerAttemptsCalculator()
Create Layer Attempts Caluclator.
unsigned int colorCode() const
Get the color code.
std::unique_ptr< const std::vector< Layer * > > m_confinedArbitraryLayers
GeometryType geometryType() const
return the Signature
unsigned int maxLayerAttempts() const
Layer attempts - as provided by the LayerAttemptCreator.
void screenDump(MsgStream &msg) const
GlueVolumesDescriptor & glueVolumesDescriptor()
const BoundarySurface< TrackingVolume > * boundarySurface(const ObjectAccessor::value_type &oa) const
Get the BoundarySurface to the appointed Accessor state.
virtual bool isAlignable() const
static const Layer * closest(const Amg::Vector3D &pos, const Amg::Vector3D &dir, const Layer &first, const Layer &second)
Helper method - find closest of two layers.
ArraySpan< Layer *const > confinedArbitraryLayers()
Return the confined subLayer array.
ArraySpan< Layer const *const > confinedArbitraryLayers() const
Return the confined subLayer array.
void createBoundarySurfaces()
Create Boundary Surface.
ArraySpan< TrackingVolume const *const > confinedDenseVolumes() const
Return unordered subVolumes - not the ownership.
virtual ~TrackingVolume() override
Destructor.
GeometrySignature m_geometrySignature
Volume()=default
Defaults copies are special due ot unique ptr data member.
const Amg::Transform3D & transform() const
Return methods for geometry transform.
Definition Volume.h:83
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
Ensure that the ATLAS eigen extensions are properly loaded.
PropDirection
PropDirection, enum for direction of the propagation.
@ alongMomentum
BinnedArray< Layer > LayerArray
simply for the eye
std::span< T > ArraySpan
FullIntersection< BoundarySurface< TrackingVolume >, Surface, T > BoundaryIntersection
BoundarySurfaceFace
Enum to describe the position of the BoundarySurface respectively to the frame orientatin of the volu...
BinnedArray< TrackingVolume > TrackingVolumeArray
simply for the eye
@ NumberOfGeometryTypes
FullIntersection< Layer, Surface, T > LayerIntersection
MsgStream & msg
Definition testRead.cxx:32