ATLAS Offline Software
Loading...
Searching...
No Matches
TRT_BarrelElement.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "Identifier/Identifier.h"
9
12
14
17
19
21
22
23namespace InDetDD {
24
25TRT_BarrelElement::TRT_BarrelElement(const GeoVFullPhysVol* volume,
26 const TRT_BarrelDescriptor* descriptor,
27 bool isPositive,
28 unsigned int modIndex,
29 unsigned int phiIndex,
30 unsigned int strawLayIndex,
31 const TRT_ID* idHelper,
33 : TRT_BaseElement(volume,
34 idHelper->layer_id((isPositive ? 1 : -1),
35 phiIndex,
36 modIndex,
37 strawLayIndex),
38 idHelper,
40 , m_code(isPositive, modIndex, phiIndex, strawLayIndex)
41 , m_descriptor(descriptor)
42 , m_nextInPhi(nullptr)
43 , m_previousInPhi(nullptr)
44 , m_nextInR(nullptr)
45 , m_previousInR(nullptr)
46
47{
48 m_nstraws = m_descriptor->nStraws();
51}
52
66
67const TRT_BarrelConditions * TRT_BarrelElement::getConditionsData()
68{
69 return nullptr;
70}
71
76
78{
79 m_nextInPhi=element;
80}
81
86
88{
89 m_nextInR=element;
90}
91
93{
94 m_previousInR=element;
95}
96
97
98
99HepGeom::Transform3D TRT_BarrelElement::calculateStrawTransform(int straw, GeoAlignmentStore* alignStore) const
100{
101 // NB The tranformation to a straw is reconstructed here precisely as
102 // it was ... hopefully... in the factory. One could eliminate this
103 // requirement and make the code a little more robust in this regard but
104 // at the cost of doubling the descriptors. (One descriptor now suffices
105 // for both positive and negative endcaps).
106 //std::cout << "In calculateStrawTransform" << std::endl;
107
108 const GeoXF::Function *f= m_descriptor->getStrawTransform();
109 if (f) {
110 size_t offsetInto = m_descriptor->getStrawTransformOffset();
111 double zPos = -m_descriptor->strawZPos();
112 double zAng = m_code.isPosZ() ? M_PI : 0;
113 return Amg::EigenTransformToCLHEP(getMaterialGeom()->getAbsoluteTransform(alignStore)*((*f)(straw+offsetInto)))
114 * HepGeom::RotateY3D(zAng)*HepGeom::TranslateZ3D(zPos)
120 } else {
121 std::cout << "calculateStrawTransform: f is 0 !!!!" << std::endl;
122 return {};
123 }
124}
125
126HepGeom::Transform3D TRT_BarrelElement::calculateLocalStrawTransform(int straw) const
127{
129 HepGeom::Transform3D rc ;
130 if(!container) {
131 // std::cout << " TRT_BarrelElement: no local transform found " << std::endl;
132 } else {
133 // important note: dx1 moves the 'negative' wire endpoint end dx2
134 // the 'positive' wire endpoint in the local straw frame. In the
135 // global frame, 'dx1' corresponds to the readout side and 'dx2'
136 // to the wire joint side for both sides of the barrel.
137
138 int bec = getCode().isPosZ() ? +1 : -1 ;
139 int layer = getCode().getModuleIndex();
140 int phimodule = getCode().getPhiIndex();
141 int strawlayer = getCode().getStrawLayerIndex();
143 (bec,layer,phimodule,strawlayer,straw,TRTCond::ExpandedIdentifier::STRAW);
144 double dx1 = container->getDx1(id);
145 double dx2 = container->getDx2(id);
146 double ang = (dx2-dx1)/strawLength();
147 double dx = (dx2+dx1)/2.;
148 rc = HepGeom::TranslateX3D(dx)*HepGeom::RotateY3D(ang) ;
149 }
150 return rc ;
151}
152
154{
155 return m_descriptor->strawBounds();
156}
157
159{
160 if (not m_surface) {
161 m_surface.set(std::make_unique<Trk::PlaneSurface>(*this));
162 }
163 return *m_surface;
164}
165
167{
168 // create the surface cache
169 if (!m_surfaceCache.isValid()) {
171 }
172 // creaete the surface (only if needed, links are still ok even if cache
173 // update)
174 if (!m_surface) {
176 }
177}
180
181 // Calculate the surface from the two end straws.
182 int firstStraw = 0;
183 int lastStraw = nStraws() - 1;
184
185 const Amg::Vector3D& centerFirstStraw =
186 center(m_idHelper->straw_id(identify(), firstStraw), alignStore);
187 const Amg::Vector3D& centerLastStraw =
188 center(m_idHelper->straw_id(identify(), lastStraw), alignStore);
189
190 // Calculate center as the average position of the end straws.
191 auto center = Amg::Vector3D(0.5 * (centerFirstStraw + centerLastStraw));
192
193 Amg::Vector3D phiAxis = centerLastStraw - centerFirstStraw;
194 double width = phiAxis.mag();
195 phiAxis = phiAxis.normalized();
196 double elementWidth =
197 width + 2 * m_descriptor->innerTubeRadius(); // Add the straw tube radius
198
199 // Get local z-axis. This is roughly in +ve global z direction (exactly if no
200 // misalignment) We could probably use any straw for this but we average the
201 // first and last straw and renormalize to a unit vector.
202 Amg::Vector3D etaAxis = 0.5 * (strawAxis(firstStraw) + strawAxis(lastStraw));
203 etaAxis = etaAxis.normalized();
204
205 // Calculate normal. This will point away from the beam line based
206 // on the assumption that the straw numbering goes in the direction
207 // of increasing phi and the straw axis is in +ve z direction.
208 auto normal = Amg::Vector3D(phiAxis.cross(etaAxis)); // phi cross z
209
210 // Transform from local to global.
211 // local x axis -> phiAxis
212 // local y axis -> etaAxis
213 // local z axis -> cross product of local x and local y
214 // translation -> center
215
216 Amg::RotationMatrix3D rotation;
217 rotation.col(0) = phiAxis;
218 rotation.col(1) = etaAxis;
219 rotation.col(2) = normal;
220
221 // This constructor takes three points in the two coordinate systems.
223
224 // create the element bounds
225 auto elementBounds = std::make_unique<Trk::RectangleBounds>(
226 0.5 * elementWidth, 0.5 * strawLength());
227
228 return { transform, center, normal, std::move(elementBounds) };
229}
230
232{
233 // Return +1 if the straw local axis is in the same direction as the z axis, -1 otherwise.
234 // The straw axis by convention goes in the direction away from the readout.
235 // So for -ve endcap this is the positive z direction (we return +1) and in the
236 // +ve endcap its in the -ve z direction (we return -1).
237 //
238 return !(m_code.isPosZ()) ? +1 : -1;
239}
240
241
242} // end namespace
#define M_PI
static Double_t rc
Class for storing/accessing trt endpoint corrections data.
This is an Identifier helper class for the TRT subdetector.
const double width
Ensure that the extensions for the Vector3D are properly loaded.
unsigned int isPosZ() const
unsigned int getPhiIndex() const
unsigned int getStrawLayerIndex() const
unsigned int getModuleIndex() const
Local Straw Positions (from the center of the module.)
virtual int strawDirection() const override final
StrawDirection.
virtual const Trk::Surface & elementSurface() const override
return the surface of the element
HepGeom::Transform3D calculateLocalStrawTransform(int straw) const
virtual const Trk::SurfaceBounds & strawBounds() const override final
Surface bounds.
virtual void createSurfaceCache(GeoAlignmentStore *alignStore) const override
create the cache for the element
void setPreviousInR(const TRT_BarrelElement *element)
Sets the previous-in-r detector.
const TRT_BarrelDescriptor * m_descriptor
static const TRT_BarrelConditions * getConditionsData()
Returns a pointer to conditions data.
const TRT_BarrelElement * m_nextInR
const TRT_BarrelElement * m_previousInPhi
const TRT_BarrelElement * m_nextInPhi
void setNextInPhi(const TRT_BarrelElement *element)
Sets the next-in-phi detector.
const TRT_BarrelElement * m_previousInR
virtual HepGeom::Transform3D calculateStrawTransform(int straw, GeoAlignmentStore *alignStore) const override
These transforms are effectively to the local coord system of a straw derived from GeoModel -> hence ...
SurfaceCache createSurfaceCacheHelper(GeoAlignmentStore *alignStore) const
virtual const double & strawLength() const override final
Get the length of the straws (active length):
const TRT_BarrelCode & getCode() const
Doomed (?):
const TRT_BarrelDescriptor * getDescriptor() const
Returns a pointer to a descriptor, giving common information on module construction:
TRT_BarrelElement(const GeoVFullPhysVol *volume, const TRT_BarrelDescriptor *descriptor, bool isPositive, unsigned int modIndex, unsigned int phiIndex, unsigned int strawLayIndex, const TRT_ID *idHelper, const TRT_Conditions *conditions)
Constructor:
void setNextInR(const TRT_BarrelElement *element)
Sets the next-in-r detector.
void setPreviousInPhi(const TRT_BarrelElement *element)
Sets the previous-in-phi detector.
const HepGeom::Transform3D getAbsoluteTransform(int straw) const
This is an alias to strawTransform(int straw)
unsigned int nStraws() const
Number of straws in the element.
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:
const TRT_Conditions * conditions() const
Return the TRT_Conditions object associated to this Detector element.
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
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
std::vector< CxxUtils::CachedUniquePtr< Trk::StraightLineSurface > > m_strawSurfaces
This class is an interface to conditions objects.
const TRTCond::StrawDxContainer * dxContainer() const
specialise to detector level
This is an Identifier helper class for the TRT subdetector.
Definition TRT_ID.h:82
Abstract base class for surface bounds to be specified.
Abstract Base Class for tracking surfaces.
HepGeom::Transform3D EigenTransformToCLHEP(const Amg::Transform3D &eigenTransf)
Converts an Eigen-based Amg::Transform3D into a CLHEP-based HepGeom::Transform3D.
Eigen::Matrix< double, 3, 3 > RotationMatrix3D
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
Eigen::Translation< double, 3 > Translation3D
Message Stream Member.