ATLAS Offline Software
GeoTRTUncompressedHit.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "InDetSimEvent/TRTUncompressedHit.h"
6 #include "TRT_ReadoutGeometry/TRT_DetectorManager.h"
7 #include "TRT_ReadoutGeometry/TRT_BarrelElement.h"
8 #include "TRT_ReadoutGeometry/TRT_EndcapElement.h"
9 
10 #include <bitset>
11 
12 
13 inline GeoTRTUncompressedHit::GeoTRTUncompressedHit (const TRTUncompressedHit & h) {
14  m_hit = &h;
15 }
16 
17 inline HepGeom::Point3D<double> GeoTRTUncompressedHit::getGlobalPosition() const {
18 
19  size_t hitID = m_hit->GetHitID(), strawID=0,layerID=0, moduleID=0, ringID=0, trtID=0,sectorID=0, wheelID=0, planeID=0;
20  static const size_t mask = 0x1F;
21  static const size_t shift = 5;
22  std::bitset<32> idBits(hitID);
23  if (!idBits[21]/*IE: BARREL*/ ) {
24  strawID = hitID & mask;
25  hitID >>= shift;
26  layerID = hitID & mask;
27  hitID >>= shift;
28  moduleID = hitID & mask;
29  hitID >>= shift;
30  ringID = hitID & mask;
31  trtID = hitID >> shift;
32  const InDetDD::TRT_BarrelElement *element = mgr()->getBarrelElement(trtID,ringID,moduleID,layerID);
33  if (element) {
34  HepGeom::Point3D<double> v(m_hit->GetPreStepX(), m_hit->GetPreStepY(), m_hit->GetPreStepZ());
35  return element->getAbsoluteTransform(strawID)*v;
36  }
37  }
38  else /*ENDCAP*/ {
39  strawID = hitID & mask;
40  hitID >>= shift;
41  planeID = hitID & mask;
42  hitID >>= shift;
43  sectorID = hitID & mask;
44  hitID >>= shift;
45  wheelID = hitID & mask;
46  trtID = hitID >> shift;
47  bool isPositive = trtID==2 ? 1:0;
48  const InDetDD::TRT_EndcapElement *element = mgr()->getEndcapElement(isPositive,wheelID,planeID,sectorID);
49  if (element) {
50  HepGeom::Point3D<double> v(m_hit->GetPreStepX(), m_hit->GetPreStepY(), m_hit->GetPreStepZ());
51  return element->getAbsoluteTransform(strawID)*v;
52  }
53  }
54 
55 
56  return HepGeom::Point3D<double>(0.0,0.0,0.0);
57 
58 }