ATLAS Offline Software
TRT_EndcapElement.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
8 
9 #include "Identifier/Identifier.h"
10 #include "InDetIdentifier/TRT_ID.h"
11 
14 
15 #include "CLHEP/Geometry/Transform3D.h"
16 #include "GeoModelKernel/GeoDefinitions.h"
18 
19 #include "TrkSurfaces/DiscBounds.h"
21 
24 
25 namespace InDetDD {
26 
27 TRT_EndcapElement::TRT_EndcapElement(const GeoVFullPhysVol* volume,
28  const TRT_EndcapDescriptor* descriptor,
29  bool isPositive,
30  unsigned int wheelIndex,
31  unsigned int strawLayIndex,
32  unsigned int phiIndex,
33  const TRT_ID* idHelper,
34  const TRT_Conditions* conditions)
35  :
36 
37  TRT_BaseElement(volume,
38  idHelper->layer_id((isPositive ? 2 : -2),
39  phiIndex,
40  wheelIndex,
41  strawLayIndex),
42  idHelper,
43  conditions)
44  , m_code(isPositive, wheelIndex, strawLayIndex, phiIndex)
45  , m_descriptor(descriptor)
46  , m_nextInZ(nullptr)
47  , m_previousInZ(nullptr)
48 {
50  m_strawSurfaces.resize(m_nstraws);
52 }
53 
55  : TRT_BaseElement(right)
56  , m_code(right.m_code)
57  , m_descriptor(right.m_descriptor)
58  , m_nextInZ(right.m_nextInZ)
59  , m_previousInZ(right.m_previousInZ)
60 {
61  m_nstraws = right.m_nstraws;
62  m_strawSurfaces.resize(m_nstraws);
64 }
65 
67 
68 
69 const double&
71 {
72  return m_descriptor->strawLength();
73 }
74 
75 const TRT_EndcapConditions*
77 {
78  return nullptr;
79 }
80 
83 {
84  return m_descriptor;
85 }
86 
87 void
89 {
90  m_nextInZ = element;
91 }
92 
93 void
95 {
96  m_previousInZ = element;
97 }
98 
101 {
102  // NB The tranformation to a straw is reconstructed here precisely as
103  // it was ... hopefully... in the factory. One could eliminate this
104  // requirement and make the code a little more robust in this regard but
105  // at the cost of doubling the descriptors. (One descriptor now suffices
106  // for both positive and negative endcaps).
107  const GeoXF::Function* f = m_descriptor->getStrawTransform();
108 
109  if (f) {
110  int istraw = m_code.isPosZ() ? straw : m_descriptor->nStraws() - 1 - straw;
111 
112  size_t offsetInto = m_descriptor->getStrawTransformOffset();
113 
115  getMaterialGeom()->getAbsoluteTransform() *
116  ((*f)(istraw + offsetInto))) *
120 
121  } else {
122 
123  // Will not work properly with alignments.
124  std::cout << "ALTERNATIVE METHOD" << std::endl;
125 
127  double r = m_descriptor->innerRadius() + 0.5 * m_descriptor->strawLength();
128  CLHEP::Hep3Vector pos(
129  r * cos(phi),
130  r * sin(phi),
131  (Amg::EigenTransformToCLHEP(getMaterialGeom()->getAbsoluteTransform()) *
132  HepGeom::Point3D<double>())
133  .z());
134  CLHEP::HepRotation rot;
135  // Axis (in local (0,0,1)) points towards beam axis.
136  rot.rotateY(-0.5 * M_PI); // Make it point along -ve X.
137  rot.rotateZ(phi);
138  return HepGeom::Transform3D(rot, pos);
139  }
140 }
141 
142 // The L3 Alignment
145 {
146  const TRTCond::StrawDxContainer* container = conditions()->dxContainer();
148  if (container) {
149 
150  // important note: dx1 moves the 'negative' wire endpoint end dx2
151  // the 'positive' wire endpoint in the local straw frame.
152  // In the global frame, 'dx1' corresponds to the readout side and 'dx2'
153  // to the side closest the beampipe.
154 
155  int bec = getCode().isPosZ() ? +2 : -2;
156  int wheel = getCode().getWheelIndex();
157  int phimodule = getCode().getPhiIndex();
158  int strawlayer = getCode().getStrawLayerIndex();
161  wheel,
162  phimodule,
163  strawlayer,
164  straw,
166 
167  double dx1 = container->getDx1(id);
168  double dx2 = container->getDx2(id);
169  double ang = (dx2 - dx1) / strawLength();
170  double dy = -1 * (dx2 + dx1) / 2.;
171 
172  // In the local straw frame:
173  // - the z-axis is along the straw and points toward the beampipe
174  // - the x-axis is along global-z and away from the interaction point
175  // (locX = globZ A-side / locX = -1 *gobZ C-side)
176  // - the y-axis is along global phi_hat direction determined by the
177  // other 2.
178  // (clockwise C-side, counter clockwise A-Side)
179  rc = HepGeom::TranslateY3D(dy) * HepGeom::RotateX3D(ang);
180  }
181  return rc;
182 }
183 
184 const Trk::SurfaceBounds&
186 {
187  return m_descriptor->strawBounds();
188 }
189 
190 const Trk::Surface&
192 {
193  if (not m_surface)
194  m_surface.set(std::make_unique<Trk::DiscSurface>(*this));
195  return *m_surface;
196 }
197 
198 void
200 {
201  if (!m_surfaceCache.isValid()) {
203  }
204  // create the surface if needed
205  if (!m_surface) {
206  elementSurface();
207  }
208 }
209 
212 {
213  // Calculate the surface
214  double phiCenter = m_descriptor->startPhi() +
215  m_descriptor->strawPitch() * 0.5 * (nStraws() - 1);
216  double phiHalfWidth = 0.5 * m_descriptor->strawPitch() * nStraws();
217  double rMin = m_descriptor->innerRadius();
218  double rMax = rMin + m_descriptor->strawLength();
219 
220  // The transform of the endcap is a translation in z for no
221  // misalignement. For the -ve endcap there is also a 180deg rotation
222  // around the y axis. getAbsoluteTransform() will also include the
223  // misalignment.
224  //
225  // To get the transform of the element we have to first rotate
226  // around z to the phi center of the element. We want the local z
227  // to point in the same direction for both endcaps (approximately
228  // global z axis). For the negative endcap we therefore have to
229  // rotate 180 CLHEP::deg around the Y axis.
230 
231  // We need to rotate to phi center before we apply the
232  // misalignment. However, in the negative endcap the the phi
233  // location is inverted (due to 180 rotation around y axis). This is
234  // taken care of by the extra 180 CLHEP::deg rotation around Y that we do
235  // to get the z axis pointing in the correct direction.
236  auto transform =
237  m_code.isPosZ()
238  ? Amg::Transform3D((getMaterialGeom()->getAbsoluteTransform() *
239  GeoTrf::RotateZ3D(phiCenter)))
240  : Amg::Transform3D((getMaterialGeom()->getAbsoluteTransform() *
241  GeoTrf::RotateY3D(180 * CLHEP::deg) *
242  GeoTrf::RotateZ3D(phiCenter)));
243 
244  // create the igredients and the cache
245  auto center = Amg::Vector3D(transform.translation());
246  auto bounds = std::make_unique<Trk::DiscBounds>(rMin, rMax, phiHalfWidth);
247  auto normal = Amg::Vector3D(transform.rotation().col(2));
248 
249  return {transform, center, normal, std::move(bounds)};
250 }
251 
252 int
254 {
255  // Return +1 if the straw local axis is in the same direction as increasing
256  // eta direction,
257  // -1 otherwise.
258  // The straw axis by convention goes in the direction away from the readout.
259  // This is towards the beam pipe. For +ve endcap it is what we want. For -ve
260  // endcap it is oppposite.
261  //
262  //
263  return (m_code.isPosZ()) ? +1 : -1;
264 }
265 
266 } // end namespace
267 
beamspotman.r
def r
Definition: beamspotman.py:676
InDetDD::TRT_EndcapCode::getStrawLayerIndex
unsigned int getStrawLayerIndex() const
Definition: TRT_EndcapCode.h:90
python.CaloRecoConfig.f
f
Definition: CaloRecoConfig.py:127
TRT::Hit::straw
@ straw
Definition: HitInfo.h:82
DiscBounds.h
InDetDD::TRT_EndcapElement::TRT_EndcapElement
TRT_EndcapElement(const GeoVFullPhysVol *volume, const TRT_EndcapDescriptor *descriptor, bool isPositive, unsigned int wheelIndex, unsigned int strawLayIndex, unsigned int phiIndex, const TRT_ID *idHelper, const TRT_Conditions *conditions)
Constructor.
Definition: TRT_EndcapElement.cxx:27
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
InDetDD::TRT_EndcapElement::setNextInZ
void setNextInZ(const TRT_EndcapElement *element)
Set Next in Z.
Definition: TRT_EndcapElement.cxx:88
InDetDD::TRT_EndcapDescriptor::innerRadius
double & innerRadius()
The inner radius:
Definition: TRT_EndcapDescriptor.cxx:49
InDetDD::TRT_EndcapElement::strawBounds
virtual const Trk::SurfaceBounds & strawBounds() const override final
the straw bounds
Definition: TRT_EndcapElement.cxx:185
ParticleGun_SamplingFraction.bec
int bec
Definition: ParticleGun_SamplingFraction.py:89
Trk::SurfaceBounds
Definition: SurfaceBounds.h:47
InDetDD::TRT_BaseElement::nStraws
unsigned int nStraws() const
Number of straws in the element.
InDetDD::TRT_EndcapElement::m_descriptor
const TRT_EndcapDescriptor * m_descriptor
Definition: TRT_EndcapElement.h:120
TRT_ID.h
This is an Identifier helper class for the TRT subdetector. This class is a factory for creating comp...
InDetDD::TRT_EndcapDescriptor::strawBounds
const Trk::SurfaceBounds & strawBounds() const
Get Bounds.
Definition: TRT_EndcapDescriptor.cxx:54
M_PI
#define M_PI
Definition: ActiveFraction.h:11
InDetDD::TRT_EndcapElement
Definition: TRT_EndcapElement.h:44
deg
#define deg
Definition: SbPolyhedron.cxx:17
InDetDD::TRT_EndcapDescriptor::nStraws
unsigned int & nStraws()
The number of straws in a module:
Definition: TRT_EndcapDescriptor.cxx:33
ExpandedIdentifier.h
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
InDetDD::TRT_Conditions
Definition: TRT_Conditions.h:30
InDetDD::TRT_EndcapDescriptor
class TRT_EndcapDescriptor
Definition: TRT_EndcapDescriptor.h:30
InDetDD::TRT_BaseElement::m_nstraws
unsigned int m_nstraws
Definition: TRT_BaseElement.h:211
SurfaceCache.h
GeoPrimitives.h
InDetDD::TRT_BaseElement::m_strawSurfaces
std::vector< CxxUtils::CachedUniquePtr< Trk::StraightLineSurface > > m_strawSurfaces
Definition: TRT_BaseElement.h:216
InDetDD::TRT_EndcapCode::getWheelIndex
unsigned int getWheelIndex() const
Definition: TRT_EndcapCode.h:84
TRT_EndcapElement.h
InDetDD::TRT_EndcapDescriptor::getStrawTransform
const GeoXF::Function * getStrawTransform() const
Get the tranformation field, which we do not own:
InDetDD::TRT_BaseElement::m_surfaceCache
CxxUtils::CachedValue< SurfaceCache > m_surfaceCache
Definition: TRT_BaseElement.h:220
z
#define z
InDetDD::TRT_EndcapElement::getCode
const TRT_EndcapCode & getCode() const
Doomed (??)
InDetDD::TRT_EndcapElement::strawDirection
virtual int strawDirection() const override final
StrawDirection.
Definition: TRT_EndcapElement.cxx:253
InDetDD::TRT_EndcapElement::getDescriptor
const TRT_EndcapDescriptor * getDescriptor() const
Returns a pointer to a descriptor, giving common information on module construction.
Definition: TRT_EndcapElement.cxx:82
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
InDetDD::TRT_EndcapElement::calculateStrawTransform
virtual HepGeom::Transform3D calculateStrawTransform(int straw) const override
These transforms are effectively to the local coord system of a straw derived from GeoModel -> hence ...
Definition: TRT_EndcapElement.cxx:100
InDetDD::TRT_EndcapElement::~TRT_EndcapElement
virtual ~TRT_EndcapElement()
Destructor:
InDetDD::TRT_BaseElement::conditions
const TRT_Conditions * conditions() const
Return the TRT_Conditions object associated to this Detector element.
InDetDD::TRT_EndcapElement::m_code
TRT_EndcapCode m_code
Definition: TRT_EndcapElement.h:119
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_EndcapElement::elementSurface
virtual const Trk::Surface & elementSurface() const override
return the surface of the element
Definition: TRT_EndcapElement.cxx:191
InDetDD::TRT_EndcapCode::isPosZ
unsigned int isPosZ() const
Definition: TRT_EndcapCode.h:79
InDetDD::TRT_EndcapElement::m_nextInZ
const TRT_EndcapElement * m_nextInZ
Definition: TRT_EndcapElement.h:121
InDetDD::TRT_EndcapElement::setPreviousInZ
void setPreviousInZ(const TRT_EndcapElement *element)
Set Previous in Z.
Definition: TRT_EndcapElement.cxx:94
CLHEPtoEigenConverter.h
InDetDD::TRT_EndcapDescriptor::startPhi
double & startPhi()
The starting phi (angular!!)
Definition: TRT_EndcapDescriptor.cxx:41
InDetDD::TRT_EndcapElement::getConditionsData
static const TRT_EndcapConditions * getConditionsData()
Returns a pointer to conditions data.
Definition: TRT_EndcapElement.cxx:76
InDetDD::TRT_EndcapDescriptor::getStrawTransformOffset
size_t getStrawTransformOffset() const
Get the offset into the transformation field:
GeoAlignmentStore.h
InDetDD::TRT_BaseElement::m_strawSurfacesCache
std::vector< CxxUtils::CachedUniquePtr< SurfaceCacheBase > > m_strawSurfacesCache
helper element surface for the cache
Definition: TRT_BaseElement.h:217
InDetDD::SurfaceCache
Definition: InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/SurfaceCache.h:68
TRTCond::ExpandedIdentifier::STRAW
@ STRAW
Definition: InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/ExpandedIdentifier.h:37
TRTCond::StrawDxContainer
Definition: StrawDxContainer.h:109
TRTCond::StrawDxContainerTemplate::getDx1
float getDx1(const ExpandedIdentifier &id) const
access to unpacked dx
Definition: StrawDxContainer.h:61
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_EndcapCode::getPhiIndex
unsigned int getPhiIndex() const
Definition: TRT_EndcapCode.h:95
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
eflowRec::phiIndex
unsigned int phiIndex(float phi, float binsize)
calculate phi index for a given phi
Definition: EtaPhiLUT.cxx:23
InDetDD::TRT_EndcapElement::strawLength
virtual const double & strawLength() const override
Active straw length.
Definition: TRT_EndcapElement.cxx:70
makeTRTBarrelCans.dy
tuple dy
Definition: makeTRTBarrelCans.py:21
InDetDD::TRT_EndcapDescriptor::strawPitch
double & strawPitch()
The straw pitch (angular!!)
Definition: TRT_EndcapDescriptor.cxx:37
TRT_ID
Definition: TRT_ID.h:84
InDetDD::TRT_EndcapElement::calculateLocalStrawTransform
HepGeom::Transform3D calculateLocalStrawTransform(int straw) const
Definition: TRT_EndcapElement.cxx:144
InDetDD
Message Stream Member.
Definition: FakeTrackBuilder.h:8
InDetDD::TRT_EndcapDescriptor::strawLength
double & strawLength()
Definition: TRT_EndcapDescriptor.cxx:45
InDetDD::TRT_Conditions::dxContainer
const TRTCond::StrawDxContainer * dxContainer() const
Definition: TRT_Conditions.cxx:14
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
DiscSurface.h
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
InDetDD::TRT_BaseElement::normal
virtual const Amg::Vector3D & normal() const override final
Element Surface: normal of a straw layer.
TRTCond::ExpandedIdentifier
Identifier for TRT detector elements in the conditions code.
Definition: InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/ExpandedIdentifier.h:30
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
TRT_Conditions.h
InDetDD::TRT_EndcapElement::m_previousInZ
const TRT_EndcapElement * m_previousInZ
Definition: TRT_EndcapElement.h:122
StrawDxContainer.h
Class for storing/accessing trt endpoint corrections data.
TRTCond::StrawDxContainerTemplate::getDx2
float getDx2(const ExpandedIdentifier &id) const
Definition: StrawDxContainer.h:65
InDetDD::TRT_BaseElement::m_surface
CxxUtils::CachedUniquePtr< Trk::Surface > m_surface
Definition: TRT_BaseElement.h:214
InDetDD::TRT_EndcapElement::createSurfaceCache
virtual void createSurfaceCache() const override
create the cache for the element
Definition: TRT_EndcapElement.cxx:199
InDetDD::TRT_BaseElement
Definition: TRT_BaseElement.h:57
InDetDD::TRT_EndcapElement::createSurfaceCacheHelper
SurfaceCache createSurfaceCacheHelper() const
Definition: TRT_EndcapElement.cxx:211
InDetDD::TRT_BaseElement::transform
virtual const Amg::Transform3D & transform() const override final
Element Surface: Get Transform of element in Tracking frame: Amg.