Loading [MathJax]/jax/output/SVG/config.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
11 #include "InDetIdentifier/TRT_ID.h"
12 
13 #include <vector>
14 
15 namespace InDetDD {
16 
17 TRT_BaseElement::TRT_BaseElement(const GeoVFullPhysVol* volume,
18  const Identifier& id,
19  const TRT_ID* idHelper,
20  const TRT_Conditions* conditions)
21  : Trk::TrkDetElementBase(volume)
22  , m_id(id)
23  , m_idHelper(idHelper)
24  , m_conditions(conditions)
25  , m_surface{}
26  , m_surfaces{}
27  , m_surfaceCache{}
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)
37  , m_conditions(right.m_conditions)
38 {}
39 
40 // [0] GeoModel / CLHEP Access
43 {
45 }
46 
47 const Trk::Surface&
49 {
50  int straw = m_idHelper->straw(id);
51  if (!m_strawSurfaces[straw]) {
53  }
54  return *(m_strawSurfaces[straw]);
55 }
56 
57 const 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 
71 const Trk::SurfaceBounds&
73 {
74  return strawBounds();
75 }
76 
77 const Amg::Transform3D&
79 {
80  int straw = m_idHelper->straw(id);
83  }
84  // forward the transform of the cache
85  return m_strawSurfacesCache[straw]->transform();
86 }
87 
88 const Amg::Transform3D&
90 {
94  }
95  // forward the transform of the cache
96  return m_strawSurfacesCache[straw]->transform();
97 }
98 
99 const 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 
109 const Amg::Vector3D&
111 {
112  int straw = m_idHelper->straw(id);
113  if (!m_strawSurfacesCache[straw]) {
114  createSurfaceCache(id);
115  }
116  // forward the transform of the cache
117  return m_strawSurfacesCache[straw]->center();
118 }
119 
122 {
123  if (!m_strawSurfaces[straw]) {
124  // get the straw identifier to the given straw number and element identifier
126  createSurfaceCache(id);
127  }
128  return *(m_strawSurfaces[straw].get());
129 }
130 
131 const Amg::Transform3D&
133 {
134  if (!m_strawSurfacesCache[straw]) {
136  createSurfaceCache(id);
137  }
138  // forward the transform of the cache
139  return m_strawSurfacesCache[straw]->transform();
140 }
141 
142 const Amg::Vector3D&
144 {
145  if (!m_strawSurfacesCache[straw]) {
147  createSurfaceCache(id);
148  }
149  // forward the transform of the cache
150  return m_strawSurfacesCache[straw]->center();
151 }
152 
155 {
156  return (strawTransform(straw).linear() * Amg::Vector3D::UnitZ() *
157  strawDirection());
158 }
159 
160 void
162 {
163  int straw = m_idHelper->straw(id);
164 
165  // convert neccessary parts to Amg
166  if (!m_strawSurfacesCache[straw]) {
167  // create the surface cache & fill it
169  }
170  // creaete the surface only if needed (the links are still intact)
171  if (!m_strawSurfaces[straw]) {
172  m_strawSurfaces[straw].set(
173  std::make_unique<Trk::StraightLineSurface>(*this, id));
174  }
175 }
176 
177 std::unique_ptr<SurfaceCacheBase>
179 {
180  // get the StrawTransform from GeoModel
181  HepGeom::Transform3D cStrawTransform = calculateStrawTransform(straw,alignStore);
182  auto sTransform =
184  auto sCenter = Amg::Vector3D(sTransform.translation());
185  // create the surface cache & fill it
186  return std::make_unique<SurfaceCacheBase>(sTransform, sCenter);
187 }
188 
189 void
191 {
192  // Invalidate the caches
193  // Call and barrel or endcap specific invalidation
194  invalidateOther();
195  // Its enough to delete and zero the caches.
196  deleteCache();
197 }
198 
199 void
201 {
202  // for all straws
203  for (auto & i : m_strawSurfacesCache) {
204  i.store(nullptr);
205  }
206 }
207 
208 void
210 {
211  // delete the caches first
212  deleteCache();
213  // Strawlayer caches
214  if (!m_surfaceCache.isValid()){
215  createSurfaceCache(alignStore);
216  }
217  // Loop over all straws and request items that get cached.
218  for (unsigned int iStraw = 0; iStraw < nStraws(); iStraw++) {
219  Identifier strawId = m_idHelper->straw_id(identify(), iStraw);
220  createSurfaceCache(strawId,alignStore);
221  }
222 }
223 
224 }
GeoAlignmentStore
Ensure that the extensions for the Vector3D are properly loaded.
Definition: GeoAlignmentStore.h:24
InDetDD::TRT_BaseElement::strawDirection
virtual int strawDirection() const =0
StrawDirection.
TRT::Hit::straw
@ straw
Definition: HitInfo.h:82
CxxUtils::CachedValue::ptr
const T * ptr() const
Return a pointer to the cached value.
InDetDD::TRT_BaseElement::surfaces
const std::vector< const Trk::Surface * > & surfaces() const
Returns the full list of all detection surfaces associated to this detector element.
Definition: TRT_BaseElement.cxx:58
InDetDD::TRT_BaseElement::deleteCache
void deleteCache()
Helper method for cache dealing.
Definition: TRT_BaseElement.cxx:200
Trk::SurfaceBounds
Definition: SurfaceBounds.h:47
CxxUtils::CachedValue::isValid
bool isValid() const
Test to see if the value is valid.
InDetDD::TRT_BaseElement::nStraws
unsigned int nStraws() const
Number of straws in the element.
InDetDD::TRT_BaseElement::strawAxis
Amg::Vector3D strawAxis(int straw) const
Straw axis.
Definition: TRT_BaseElement.cxx:154
TRT_ID.h
This is an Identifier helper class for the TRT subdetector. This class is a factory for creating comp...
InDetDD::TRT_BaseElement::strawCenter
const Amg::Vector3D & strawCenter(int straw) const
Straw Surface: Local -> global transform of the straw via integer.
Definition: TRT_BaseElement.cxx:143
InDetDD::TRT_BaseElement::TRT_BaseElement
TRT_BaseElement(const GeoVFullPhysVol *volume, const Identifier &id, const TRT_ID *idHelper, const TRT_Conditions *conditions)
Constructor:
Definition: TRT_BaseElement.cxx:17
InDetDD::TRT_Conditions
Definition: TRT_Conditions.h:30
InDetDD::TRT_BaseElement::createSurfaceCache
virtual void createSurfaceCache(GeoAlignmentStore *alignStore=nullptr) const =0
create the surface cache of the detector element, to be implementd in the deried class
InDetDD::TRT_BaseElement::m_strawSurfaces
std::vector< CxxUtils::CachedUniquePtr< Trk::StraightLineSurface > > m_strawSurfaces
Definition: TRT_BaseElement.h:211
TRT_ID::straw
int straw(const Identifier &id) const
Definition: TRT_ID.h:902
InDetDD::TRT_BaseElement::m_surfaceCache
CxxUtils::CachedValue< SurfaceCache > m_surfaceCache
Definition: TRT_BaseElement.h:215
InDetDD::TRT_BaseElement::calculateStrawTransform
virtual HepGeom::Transform3D calculateStrawTransform(int straw, GeoAlignmentStore *alignStore=nullptr) const =0
to be overloaded by the extended classes
lumiFormat.i
int i
Definition: lumiFormat.py:85
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
dumpNswErrorDb.linear
def linear
Definition: dumpNswErrorDb.py:23
InDetDD::TRT_BaseElement::m_idHelper
const TRT_ID * m_idHelper
Definition: TRT_BaseElement.h:207
InDetDD::TRT_BaseElement::getAbsoluteTransform
const HepGeom::Transform3D getAbsoluteTransform(int straw) const
This is an alias to strawTransform(int straw)
Definition: TRT_BaseElement.cxx:42
InDetDD::TRT_BaseElement::identify
virtual Identifier identify() const override final
identifier of this detector element:
InDetDD::TRT_BaseElement::m_surfaces
CxxUtils::CachedValue< std::vector< const Trk::Surface * > > m_surfaces
Definition: TRT_BaseElement.h:214
CLHEPtoEigenConverter.h
TRT_BaseElement.h
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
GeoAlignmentStore.h
InDetDD::TRT_BaseElement::m_strawSurfacesCache
std::vector< CxxUtils::CachedUniquePtr< SurfaceCacheBase > > m_strawSurfacesCache
helper element surface for the cache
Definition: TRT_BaseElement.h:212
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:227
InDetDD::TRT_BaseElement::invalidateOther
void invalidateOther() const
invalidate action on the cache
Definition: TRT_BaseElement.h:188
CxxUtils::CachedValue::set
void set(const T &val) const
Set the value, assuming it is currently invalid.
InDetDD::TRT_BaseElement::invalidate
void invalidate()
Invalidate cache.
Definition: TRT_BaseElement.cxx:190
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
InDetDD::TRT_BaseElement::bounds
virtual const Trk::SurfaceBounds & bounds() const override final
Straw layer bounds.
InDetDD::TRT_BaseElement::updateAllCaches
void updateAllCaches(GeoAlignmentStore *alignStore=nullptr)
Update all caches.
Definition: TRT_BaseElement.cxx:209
TRT_ID
Definition: TRT_ID.h:84
InDetDD::TRT_BaseElement::createSurfaceCacheHelper
std::unique_ptr< SurfaceCacheBase > createSurfaceCacheHelper(int straw, GeoAlignmentStore *alignStore=nullptr) const
Definition: TRT_BaseElement.cxx:178
InDetDD::TRT_BaseElement::strawTransform
const Amg::Transform3D & strawTransform(unsigned int straw) const
Straw transform - fast access in array, in Tracking frame: Amg.
Definition: TRT_BaseElement.cxx:89
InDetDD
Message Stream Member.
Definition: FakeTrackBuilder.h:8
Amg::CLHEPTransformToEigen
Amg::Transform3D CLHEPTransformToEigen(const HepGeom::Transform3D &CLHEPtransf)
Converts a CLHEP-based HepGeom::Transform3D into an Eigen Amg::Transform3D.
Definition: CLHEPtoEigenConverter.h:38
InDetDD::TRT_BaseElement::center
virtual const Amg::Vector3D & center() const override final
Element Surface: center of a straw layer.
Amg::EigenTransformToCLHEP
HepGeom::Transform3D EigenTransformToCLHEP(const Amg::Transform3D &eigenTransf)
Converts an Eigen-based Amg::Transform3D into a CLHEP-based HepGeom::Transform3D.
Definition: CLHEPtoEigenConverter.h:120
InDetDD::TRT_BaseElement::strawSurface
const Trk::StraightLineSurface & strawSurface(int straw) const
Straw Surface: access to the surface via integer.
Definition: TRT_BaseElement.cxx:121
InDetDD::TRT_BaseElement::strawBounds
virtual const Trk::SurfaceBounds & strawBounds() const =0
the straw bounds
InDetDD::TRT_BaseElement::normal
virtual const Amg::Vector3D & normal() const override final
Element Surface: normal of a straw layer.
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
TRT_Conditions.h
InDetDD::TRT_BaseElement::surface
virtual const Trk::Surface & surface() const override final
Element Surface: access to the Surface (straw layer)
Trk::StraightLineSurface
Definition: StraightLineSurface.h:51
InDetDD::TRT_BaseElement
Definition: TRT_BaseElement.h:52
TRT_ID::straw_id
Identifier straw_id(int barrel_ec, int phi_module, int layer_or_wheel, int straw_layer, int straw) const
Three ways of getting id for a single straw:
Definition: TRT_ID.h:581
InDetDD::TRT_BaseElement::transform
virtual const Amg::Transform3D & transform() const override final
Element Surface: Get Transform of element in Tracking frame: Amg.
Identifier
Definition: IdentifierFieldParser.cxx:14