ATLAS Offline Software
Loading...
Searching...
No Matches
Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6// Surface.h, (c) ATLAS Detector software
8
9#ifndef TRKSURFACES_SURFACE_H
10#define TRKSURFACES_SURFACE_H
11
12// Amg
13// Ensure Eigen plugin comes first
16
17// Trk
21//
28//
34// Identifier
35#include "Identifier/Identifier.h"
36//
39#include <atomic>
40#include <memory>
41#include <optional>
42
43class MsgStream;
44class SurfaceCnv_p1;
45
46namespace Trk {
47
49class SurfaceBounds;
50class Layer;
51class MaterialLayer;
52
53/* enum that affects how this surface is to be managed.
54 * See TrkEventPrimitives/SurfaceHolderImpl.
55 */
57 noOwn = 0, // Surface is free can be deleted at will.
58 TGOwn = 1, // Surface is owned by the Geometry and will be deleted by it.
59 DetElOwn = 2, // Surface is associated with a detector element. So can not be
60 // deleted as long this is active.
61 userOwn = 3 // Surface is owned by the user. e.g could be "static"
62};
63
77
78class Surface: public Trk::ObjectCounter<Trk::Surface>
79{
80
81public:
82 /*
83 * struct holding the transform, center, normal,
84 * needed by surfaces when not delegating
85 * to a detector element
86 */
88 {
89 // constructor with just a Amg::Transform3D input
90 inline Transforms(const Amg::Transform3D& atransform)
91 : transform(atransform)
92 , center(transform.translation())
93 , normal(transform.linear().col(2))
94 {
95 }
96
97 // constructor with Amg::Transform3D and center input
98 inline Transforms(const Amg::Transform3D& atransform,
99 const Amg::Vector3D& acenter)
100 : transform(atransform)
101 , center(acenter)
102 , normal(transform.linear().col(2))
103 {
104 }
105
106 // constructor with Amg::Transform3D , center and normal input
107 inline Transforms(const Amg::Transform3D& atransform,
108 const Amg::Vector3D& acenter,
109 const Amg::Vector3D& anormal)
110 : transform(atransform)
111 , center(acenter)
112 , normal(anormal)
113 {
114 }
115 Transforms(const Transforms&) = default;
116 Transforms(Transforms&&) = default;
117 Transforms& operator=(const Transforms&) = default;
119 ~Transforms() = default;
126 };
127
129 std::unique_ptr<ParametersBase<5, Trk::Charged>>;
131 std::unique_ptr<ParametersBase<5, Trk::Neutral>>;
132
136
138 virtual ~Surface();
139
141 Surface(const Amg::Transform3D& htrans);
142
144 Surface(const TrkDetElementBase& detelement);
145
147 Surface(const TrkDetElementBase& detelement, const Identifier& id);
148
150 virtual bool operator==(const Surface& sf) const = 0;
151
153 bool operator!=(const Surface& sf) const;
154
156 virtual Surface* clone() const = 0;
157
159 std::unique_ptr<Surface> uniqueClone() const;
160
162 constexpr virtual SurfaceType type() const = 0;
163
167
170
172 const Amg::Vector3D& center() const;
173
176 virtual const Amg::Vector3D& normal() const;
177
180 virtual Amg::Vector3D normal(const Amg::Vector2D& lp) const;
181
186 virtual const Amg::Vector3D& globalReferencePoint() const;
187
190
193
196
200
202 virtual const Trk::Surface* baseSurface() const;
203
208 double l1,
209 double l2,
210 double phi,
211 double theat,
212 double qop,
213 std::optional<AmgSymMatrix(5)> cov = std::nullopt) const = 0;
214
219 const Amg::Vector3D&,
220 const Amg::Vector3D&,
221 double,
222 std::optional<AmgSymMatrix(5)> cov = std::nullopt) const = 0;
223
228 double l1,
229 double l2,
230 double phi,
231 double theat,
232 double qop,
233 std::optional<AmgSymMatrix(5)> cov = std::nullopt) const = 0;
234
239 const Amg::Vector3D&,
240 const Amg::Vector3D&,
241 double charge = 0.,
242 std::optional<AmgSymMatrix(5)> cov = std::nullopt) const = 0;
243
252 std::optional<Amg::Vector2D> positionOnSurface(
253 const Amg::Vector3D& glopo,
254 const BoundaryCheck& bchk = true,
255 double tol1 = 0.,
256 double tol2 = 0.) const;
257
260 template<class T>
261 bool onSurface(const T& parameters,
262 const BoundaryCheck& bchk = BoundaryCheck(true)) const;
263
267 virtual bool isOnSurface(const Amg::Vector3D& glopo,
268 const BoundaryCheck& bchk = true,
269 double tol1 = 0.,
270 double tol2 = 0.) const;
271
273 virtual bool insideBounds(const Amg::Vector2D& locpos,
274 double tol1 = 0.,
275 double tol2 = 0.) const = 0;
276
277 virtual bool insideBoundsCheck(const Amg::Vector2D& locpos,
278 const BoundaryCheck& bchk) const = 0;
279
282 virtual void localToGlobal(const Amg::Vector2D& locp,
283 const Amg::Vector3D& mom,
284 Amg::Vector3D& glob) const = 0;
285
290
296 const Amg::Vector3D& glomom) const;
297
302
308 const Amg::Vector3D& glomom) const;
309
312 virtual bool globalToLocal(const Amg::Vector3D& glob,
313 const Amg::Vector3D& mom,
314 Amg::Vector2D& loc) const = 0;
315
321 std::optional<Amg::Vector2D> globalToLocal(const Amg::Vector3D& glopos,
322 double tol = 0.) const;
323
329 std::optional<Amg::Vector2D> globalToLocal(const Amg::Vector3D& glopos,
330 const Amg::Vector3D& glomom) const;
331
334 const LocalParameters& locpars) const;
335
338 virtual double pathCorrection(const Amg::Vector3D& pos,
339 const Amg::Vector3D& mom) const;
340
346 const Amg::Vector3D& glopos,
347 const Amg::Vector3D& glomom) const;
348
351 template<typename T>
353 const T& pars,
354 bool forceDir = false,
355 const Trk::BoundaryCheck& bchk = false) const
356 {
358 pars.position(), pars.momentum().unit(), forceDir, bchk);
359 }
360
366 const Amg::Vector3D& pos,
367 const Amg::Vector3D& dir,
368 bool forceDir = false,
369 Trk::BoundaryCheck bchk = false) const = 0;
370
373 const Amg::Vector3D& pos,
374 const Amg::Vector3D& dir) const = 0;
375
378 const Amg::Vector3D& pos,
379 const Amg::Vector3D& dir,
380 bool Bound) const = 0;
381
383 virtual const SurfaceBounds& bounds() const = 0;
384
387 bool isFree() const;
388
390 bool isActive() const;
391
393 void setTransform(const Amg::Transform3D& trans);
394
397
400
402 void setMaterialLayer(std::shared_ptr<Trk::MaterialLayer> mlay);
403
405 virtual MsgStream& dump(MsgStream& sl) const;
406
408 virtual std::ostream& dump(std::ostream& sl) const;
409
411 virtual std::string name() const = 0;
412
416 void associateLayer(const Layer& lay);
417
418protected:
423 Surface(const Surface& sf);
424 Surface& operator=(const Surface& sf);
426 Surface(const Surface& sf, const Amg::Transform3D& transf);
427 // Move operators for inheriting classes
428 Surface(Surface&& sf) noexcept = default;
429 Surface& operator=(Surface&& sf) noexcept = default;
430
435
436 friend class ::SurfaceCnv_p1;
437
439 std::unique_ptr<Transforms> m_transforms{};
453 std::shared_ptr<MaterialLayer> m_materialLayer{};
456
458 static constexpr double s_onSurfaceTolerance = 10e-5; // 0.1 * micron
459};
460
462MsgStream&
463operator<<(MsgStream& sl, const Surface& sf);
464std::ostream&
465operator<<(std::ostream& sl, const Surface& sf);
466
469} //
470#include "Surface.icc"
471#endif // TRKSURFACES_SURFACE_H
double charge(const T &p)
Definition AtlasPID.h:997
Cached unique_ptr with atomic update.
#define AmgSymMatrix(dim)
Handle conditional ownership of surfaces.
Define macros for attributes used to control the static checker.
The BoundaryCheck class allows to steer the way surface boundaries are used for inside/outside checks...
Access to distance solutions.
Base Class for a Detector Layer in the Tracking realm.
Definition Layer.h:72
A material layer is a simple helper class to attach material information to a boundary surface.
Helper to enable counting number of instantiations in debug builds.
Abstract base class for surface bounds to be specified.
Abstract Base Class for tracking surfaces.
Surface & operator=(Surface &&sf) noexcept=default
Amg::Transform3D inverseTransformHelper() const
Helper method to factorize in one place common operations calculate inverse transofrm and multiply wi...
const Amg::Transform3D * cachedTransform() const
Return the cached transformation directly.
std::unique_ptr< ParametersBase< 5, Trk::Charged > > ChargedTrackParametersUniquePtr
Unique ptr types.
Surface & operator=(const Surface &sf)
Definition Surface.cxx:91
virtual bool globalToLocal(const Amg::Vector3D &glob, const Amg::Vector3D &mom, Amg::Vector2D &loc) const =0
Specified by each surface type: GlobalToLocal method without dynamic memory allocation - boolean chec...
virtual bool insideBounds(const Amg::Vector2D &locpos, double tol1=0., double tol2=0.) const =0
virtual methods to be overwritten by the inherited surfaces
bool onSurface(const T &parameters, const BoundaryCheck &bchk=BoundaryCheck(true)) const
The templated Parameters OnSurface method - checks on surface pointer first.
const TrkDetElementBase * associatedDetectorElement() const
return associated Detector Element
virtual DistanceSolution straightLineDistanceEstimate(const Amg::Vector3D &pos, const Amg::Vector3D &dir) const =0
fast straight line distance evaluation to Surface
void associateLayer(const Layer &lay)
method to associate a Trk::Layer.
virtual NeutralTrackParametersUniquePtr createUniqueNeutralParameters(double l1, double l2, double phi, double theat, double qop, std::optional< AmgSymMatrix(5)> cov=std::nullopt) const =0
Use the Surface as a ParametersBase constructor, from local parameters - neutral.
SurfaceOwner m_owner
enum for surface owner : default free surface
virtual Intersection straightLineIntersection(const Amg::Vector3D &pos, const Amg::Vector3D &dir, bool forceDir=false, Trk::BoundaryCheck bchk=false) const =0
fast straight line intersection schema - standard: provides closest intersection and (signed) path le...
std::shared_ptr< MaterialLayer > m_materialLayer
Possibility to attach a material description to the surface.
bool isFree() const
Returns 'true' if this surface is 'free', i.e.
void setTransform(const Amg::Transform3D &trans)
Set the transform updates center and normal.
virtual Amg::RotationMatrix3D measurementFrame(const Amg::Vector3D &glopos, const Amg::Vector3D &glomom) const
Return the measurement frame - this is needed for alignment, in particular for StraightLine and Perig...
Definition Surface.cxx:135
static constexpr double s_onSurfaceTolerance
Tolerance for being on Surface.
const TrkDetElementBase * m_associatedDetElement
Not owning Pointer to the Detector Element.
virtual bool operator==(const Surface &sf) const =0
Equality operator.
virtual const Trk::Surface * baseSurface() const
return the base surface (simplified for persistification)
virtual ChargedTrackParametersUniquePtr createUniqueTrackParameters(double l1, double l2, double phi, double theat, double qop, std::optional< AmgSymMatrix(5)> cov=std::nullopt) const =0
Use the Surface as a ParametersBase constructor, from local parameters - charged.
Amg::Vector3D localToGlobal(const LocalParameters &locpars) const
This method returns the GlobalPosition from LocalParameters The LocalParameters can be outside Surfac...
Trk::MaterialLayer * materialLayer()
virtual double pathCorrection(const Amg::Vector3D &pos, const Amg::Vector3D &mom) const
the pathCorrection for derived classes with thickness - it reflects if the direction projection is po...
Amg::Vector3D localToGlobal(const Amg::Vector2D &locpos) const
This method returns the GlobalPosition from a LocalPosition uses the per surface localToGlobal.
Amg::Vector3D inverseTransformMultHelper(const Amg::Vector3D &glopos) const
const Layer * m_associatedLayer
The associated layer Trk::Layer This is the layer in which the Surface is embedded.
Amg::Vector3D localToGlobal(const Amg::Vector2D &locpos, const Amg::Vector3D &glomom) const
This method returns the GlobalPosition from a LocalPosition The LocalPosition can be outside Surface ...
virtual Amg::Vector2D localParametersToPosition(const LocalParameters &locpars) const
Optionally specified by each surface type : LocalParameters to Vector2D.
virtual Surface * clone() const =0
Implicit constructor - uses the copy constructor.
virtual ChargedTrackParametersUniquePtr createUniqueTrackParameters(const Amg::Vector3D &, const Amg::Vector3D &, double, std::optional< AmgSymMatrix(5)> cov=std::nullopt) const =0
Use the Surface as a ParametersBase constructor, from global parameters - charged.
virtual ~Surface()
Virtual Destructor.
bool isActive() const
Return 'true' if this surface is owned by the detector element.
Surface()
Default Constructor for inheriting classes.
virtual const Amg::Vector3D & normal() const
Returns the normal vector of the Surface (i.e.
bool operator!=(const Surface &sf) const
Non-equality operator.
std::optional< Amg::Vector2D > globalToLocal(const Amg::Vector3D &glopos, double tol=0.) const
This method returns the LocalPosition from a provided GlobalPosition.
virtual bool insideBoundsCheck(const Amg::Vector2D &locpos, const BoundaryCheck &bchk) const =0
const Amg::Transform3D & transform() const
Returns HepGeom::Transform3D by reference.
virtual DistanceSolution straightLineDistanceEstimate(const Amg::Vector3D &pos, const Amg::Vector3D &dir, bool Bound) const =0
fast straight line distance evaluation to Surface - with bound option
Identifier associatedDetectorElementIdentifier() const
return Identifier of the associated Detector Element
virtual Amg::Vector3D normal(const Amg::Vector2D &lp) const
Returns a normal vector at a specific local position.
Amg::Vector3D localToGlobal(const LocalParameters &locpars, const Amg::Vector3D &glomom) const
This method returns the GlobalPosition from LocalParameters The LocalParameters can be outside Surfac...
Identifier m_associatedDetElementId
Identifier to the Detector Element.
virtual constexpr SurfaceType type() const =0
Returns the Surface type to avoid dynamic casts.
void setOwner(SurfaceOwner x)
set Ownership
virtual NeutralTrackParametersUniquePtr createUniqueNeutralParameters(const Amg::Vector3D &, const Amg::Vector3D &, double charge=0., std::optional< AmgSymMatrix(5)> cov=std::nullopt) const =0
Use the Surface as a ParametersBase constructor, from global parameters - neutral.
virtual const Amg::Vector3D & globalReferencePoint() const
Returns a global reference point on the surface, for PlaneSurface, StraightLineSurface,...
std::unique_ptr< Transforms > m_transforms
Unique Pointer to the Transforms struct.
virtual bool isOnSurface(const Amg::Vector3D &glopo, const BoundaryCheck &bchk=true, double tol1=0., double tol2=0.) const
This method returns true if the GlobalPosition is on the Surface for both, within or without check of...
Definition Surface.cxx:123
void setMaterialLayer(std::shared_ptr< Trk::MaterialLayer > mlay)
set material layer
virtual const SurfaceBounds & bounds() const =0
Surface Bounds method.
const Trk::Layer * associatedLayer() const
return the associated Layer
const Amg::Vector3D & center() const
Returns the center position of the Surface.
std::optional< Amg::Vector2D > globalToLocal(const Amg::Vector3D &glopos, const Amg::Vector3D &glomom) const
This method returns the LocalPosition from a provided GlobalPosition.
virtual std::string name() const =0
Return properly formatted class name.
virtual void localToGlobal(const Amg::Vector2D &locp, const Amg::Vector3D &mom, Amg::Vector3D &glob) const =0
Specified by each surface type: LocalToGlobal method without dynamic memory allocation.
Surface(Surface &&sf) noexcept=default
SurfaceOwner owner() const
return ownership
std::unique_ptr< Surface > uniqueClone() const
NVI method returning unique_ptr clone.
Intersection straightLineIntersection(const T &pars, bool forceDir=false, const Trk::BoundaryCheck &bchk=false) const
fst straight line intersection schema - templated for charged and neutral parameters
std::unique_ptr< ParametersBase< 5, Trk::Neutral > > NeutralTrackParametersUniquePtr
std::optional< Amg::Vector2D > positionOnSurface(const Amg::Vector3D &glopo, const BoundaryCheck &bchk=true, double tol1=0., double tol2=0.) const
positionOnSurface() returns the LocalPosition on the Surface, If BoundaryCheck==false it just return...
Definition Surface.cxx:106
const Trk::MaterialLayer * materialLayer() const
return the material Layer
This is the base class for all tracking detector elements with read-out relevant information.
Eigen::Matrix< double, 3, 3 > RotationMatrix3D
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
Ensure that the ATLAS eigen extensions are properly loaded.
SurfaceUniquePtrT< Trk::Surface > SurfaceUniquePtr
SurfaceType
This enumerator simplifies the persistency & calculations,.
MsgStream & operator<<(MsgStream &sl, const AlignModule &alignModule)
overload of << operator for MsgStream for debug output
SurfaceUniquePtrT< const Trk::Surface > ConstSurfaceUniquePtr
@ x
Definition ParamDefs.h:55
@ phi
Definition ParamDefs.h:75
std::unique_ptr< S, SurfaceDeleter< S > > SurfaceUniquePtrT
-event-from-file
Amg::Transform3D transform
center position of the surface
Transforms(Transforms &&)=default
~Transforms()=default
Transform3D to orient surface w.r.t to global frame.
Transforms(const Transforms &)=default
Transforms & operator=(const Transforms &)=default
Transforms(const Amg::Transform3D &atransform, const Amg::Vector3D &acenter, const Amg::Vector3D &anormal)
Transforms & operator=(Transforms &&)=default
Transforms(const Amg::Transform3D &atransform, const Amg::Vector3D &acenter)