ATLAS Offline Software
Loading...
Searching...
No Matches
TRT_BaseElement.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
7
10
12
13#include <vector>
14
15namespace InDetDD {
16
17TRT_BaseElement::TRT_BaseElement(const GeoVFullPhysVol* volume,
18 const Identifier& id,
19 const TRT_ID* idHelper,
21 : Trk::TrkDetElementBase(volume)
22 , m_id(id)
23 , m_idHelper(idHelper)
25 , m_surface{}
26 , m_surfaces{}
28{
29 m_idHash = m_idHelper->straw_layer_hash(id);
30}
31
33 : Trk::TrkDetElementBase(right.getMaterialGeom())
34 , m_id(right.m_id)
35 , m_idHash(right.m_idHash)
36 , m_idHelper(right.m_idHelper)
38{}
39
40// [0] GeoModel / CLHEP Access
41const HepGeom::Transform3D
46
47const Trk::Surface&
49{
50 int straw = m_idHelper->straw(id);
51 if (!m_strawSurfaces[straw]) {
53 }
54 return *(m_strawSurfaces[straw]);
55}
56
57const std::vector<const Trk::Surface*>&
59{
60 if (!m_surfaces.isValid()) {
61 std::vector<const Trk::Surface*> tmp_surfaces;
62 tmp_surfaces.reserve(nStraws());
63 for (unsigned is = 0; is < nStraws(); ++is) {
64 tmp_surfaces.push_back(&strawSurface(is));
65 }
66 m_surfaces.set(tmp_surfaces);
67 }
68 return *(m_surfaces.ptr());
69}
70
73{
74 return strawBounds();
75}
76
79{
80 int straw = m_idHelper->straw(id);
81 if (!m_strawSurfacesCache[straw]) {
83 }
84 // forward the transform of the cache
85 return m_strawSurfacesCache[straw]->transform();
86}
87
89TRT_BaseElement::strawTransform(unsigned int straw) const
90{
91 if (!m_strawSurfacesCache[straw]) {
92 Identifier id = m_idHelper->straw_id(identify(), straw);
94 }
95 // forward the transform of the cache
96 return m_strawSurfacesCache[straw]->transform();
97}
98
99const Amg::Vector3D&
101{
102 // Not sure if the normal of the straw is ever used.
103 // nor is there a well defined normal.
104 // This wont be corrected for alignments.
105 // Just return the element normal
106 return normal();
107}
108
109const Amg::Vector3D&
111{
112 int straw = m_idHelper->straw(id);
113 if (!m_strawSurfacesCache[straw]) {
115 }
116 // forward the transform of the cache
117 return m_strawSurfacesCache[straw]->center();
118}
119
120const Amg::Vector3D&
122{
123 int straw = m_idHelper->straw(id);
124 if (!m_strawSurfacesCache[straw]) {
125 createSurfaceCache(id, alignStore);
126 }
127 // forward the transform of the cache
128 return m_strawSurfacesCache[straw]->center();
129}
130
133{
134 if (!m_strawSurfaces[straw]) {
135 // get the straw identifier to the given straw number and element identifier
136 Identifier id = m_idHelper->straw_id(identify(), straw);
138 }
139 return *(m_strawSurfaces[straw].get());
140}
141
142const Amg::Transform3D&
144{
145 if (!m_strawSurfacesCache[straw]) {
146 Identifier id = m_idHelper->straw_id(identify(), straw);
148 }
149 // forward the transform of the cache
150 return m_strawSurfacesCache[straw]->transform();
151}
152
153const Amg::Vector3D&
155{
156 if (!m_strawSurfacesCache[straw]) {
157 Identifier id = m_idHelper->straw_id(identify(), straw);
159 }
160 // forward the transform of the cache
161 return m_strawSurfacesCache[straw]->center();
162}
163
166{
167 return (strawTransform(straw).linear() * Amg::Vector3D::UnitZ() *
169}
170
171void
173{
174 int straw = m_idHelper->straw(id);
175
176 // convert neccessary parts to Amg
177 if (!m_strawSurfacesCache[straw]) {
178 // create the surface cache & fill it
179 m_strawSurfacesCache[straw].set(createSurfaceCacheHelper(straw,alignStore));
180 }
181 // creaete the surface only if needed (the links are still intact)
182 if (!m_strawSurfaces[straw]) {
183 m_strawSurfaces[straw].set(
184 std::make_unique<Trk::StraightLineSurface>(*this, id));
185 }
186}
187
188std::unique_ptr<SurfaceCacheBase>
190{
191 // get the StrawTransform from GeoModel
192 HepGeom::Transform3D cStrawTransform = calculateStrawTransform(straw,alignStore);
193 auto sTransform =
195 auto sCenter = Amg::Vector3D(sTransform.translation());
196 // create the surface cache & fill it
197 return std::make_unique<SurfaceCacheBase>(sTransform, sCenter);
198}
199
200void
202{
203 // Invalidate the caches
204 // Call and barrel or endcap specific invalidation
206 // Its enough to delete and zero the caches.
207 deleteCache();
208}
209
210void
212{
213 // for all straws
214 for (auto & i : m_strawSurfacesCache) {
215 i.release();
216 }
217}
218
219void
221{
222 // Strawlayer caches
223 if (!m_surfaceCache.isValid()){
224 createSurfaceCache(alignStore);
225 }
226 // Loop over all straws and request items that get cached.
227 for (unsigned int iStraw = 0; iStraw < nStraws(); iStraw++) {
228 Identifier strawId = m_idHelper->straw_id(identify(), iStraw);
229 createSurfaceCache(strawId,alignStore);
230 }
231}
232
233}
This is an Identifier helper class for the TRT subdetector.
Ensure that the extensions for the Vector3D are properly loaded.
const std::vector< const Trk::Surface * > & surfaces() const
Returns the full list of all detection surfaces associated to this detector element.
const HepGeom::Transform3D getAbsoluteTransform(int straw) const
This is an alias to strawTransform(int straw)
void updateAllCaches(GeoAlignmentStore *alignStore=nullptr) const
Update all caches.
const TRT_Conditions * m_conditions
unsigned int nStraws() const
Number of straws in the element.
virtual const Trk::SurfaceBounds & bounds() const override final
Straw layer bounds.
std::unique_ptr< SurfaceCacheBase > createSurfaceCacheHelper(int straw, GeoAlignmentStore *alignStore=nullptr) const
virtual Identifier identify() const override final
identifier of this detector element:
TRT_BaseElement(const GeoVFullPhysVol *volume, const Identifier &id, const TRT_ID *idHelper, const TRT_Conditions *conditions)
Constructor:
virtual const Trk::Surface & surface() const override final
Element Surface: access to the Surface (straw layer)
virtual int strawDirection() const =0
StrawDirection.
void invalidate()
Invalidate cache.
virtual HepGeom::Transform3D calculateStrawTransform(int straw, GeoAlignmentStore *alignStore=nullptr) const =0
to be overloaded by the extended classes
const TRT_Conditions * conditions() const
Return the TRT_Conditions object associated to this Detector element.
CxxUtils::CachedValue< std::vector< const Trk::Surface * > > m_surfaces
void deleteCache()
Helper method for cache dealing.
virtual const Amg::Vector3D & normal() const override final
Element Surface: normal of a straw layer.
virtual const Amg::Transform3D & transform() const override final
Element Surface: Get Transform of element in Tracking frame: Amg.
virtual const Amg::Vector3D & center() const override final
Element Surface: center of a straw layer.
CxxUtils::CachedValue< SurfaceCache > m_surfaceCache
const Amg::Transform3D & strawTransform(unsigned int straw) const
Straw transform - fast access in array, in Tracking frame: Amg.
void invalidateOther() const
invalidate action on the cache
virtual const Trk::SurfaceBounds & strawBounds() const =0
the straw bounds
virtual void createSurfaceCache(GeoAlignmentStore *alignStore=nullptr) const =0
create the surface cache of the detector element, to be implementd in the deried class
std::vector< CxxUtils::CachedUniquePtr< SurfaceCacheBase > > m_strawSurfacesCache
helper element surface for the cache
Amg::Vector3D strawAxis(int straw) const
Straw axis.
CxxUtils::CachedUniquePtr< Trk::Surface > m_surface
const Amg::Vector3D & strawCenter(int straw) const
Straw Surface: Local -> global transform of the straw via integer.
std::vector< CxxUtils::CachedUniquePtr< Trk::StraightLineSurface > > m_strawSurfaces
const Trk::StraightLineSurface & strawSurface(int straw) const
Straw Surface: access to the surface via integer.
This class is an interface to conditions objects.
This is an Identifier helper class for the TRT subdetector.
Definition TRT_ID.h:82
Class for a StraightLineSurface in the ATLAS detector to describe dirft tube and straw like detectors...
Abstract base class for surface bounds to be specified.
Abstract Base Class for tracking surfaces.
TrkDetElementBase(const GeoVFullPhysVol *fullPhysVol)
Constructor from GeoVFullPhysVolume.
HepGeom::Transform3D EigenTransformToCLHEP(const Amg::Transform3D &eigenTransf)
Converts an Eigen-based Amg::Transform3D into a CLHEP-based HepGeom::Transform3D.
Amg::Transform3D CLHEPTransformToEigen(const HepGeom::Transform3D &CLHEPtransf)
Converts a CLHEP-based HepGeom::Transform3D into an Eigen Amg::Transform3D.
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
Message Stream Member.
Ensure that the ATLAS eigen extensions are properly loaded.