2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
5 #include "GeoPrimitives/CLHEPtoEigenConverter.h"
6 #include "HGTD_Identifier/HGTD_ID.h"
7 #include "HGTD_ReadoutGeometry/HGTD_DetectorManager.h"
8 #include "InDetIdentifier/PixelID.h"
9 #include "InDetIdentifier/SCT_ID.h"
10 #include "InDetIdentifier/PLR_ID.h"
11 #include "InDetReadoutGeometry/SiDetectorElement.h"
12 #include "InDetSimEvent/SiHit.h"
13 #include "PixelReadoutGeometry/PixelDetectorManager.h"
14 #include "SCT_ReadoutGeometry/SCT_DetectorManager.h"
17 inline GeoSiHit::GeoSiHit (const SiHit & h) {
22 inline HepGeom::Point3D<double> GeoSiHit::getGlobalPosition() const {
24 int Barrel = m_hit->getBarrelEndcap();
25 if (Barrel== 1) Barrel = -2;
27 const InDetDD::SolidStateDetectorElementBase *geoelement{};
28 if (m_hit->isPixel()) {
29 id = pixID()->wafer_id(Barrel,
30 m_hit->getLayerDisk(),
31 m_hit->getPhiModule(),
32 m_hit->getEtaModule());
33 geoelement = pixMgr()->getDetectorElement(id);
34 } else if (m_hit->isSCT()) {
35 id = sctID()->wafer_id(Barrel,
36 m_hit->getLayerDisk(),
37 m_hit->getPhiModule(),
38 m_hit->getEtaModule(),
40 geoelement = sctMgr()->getDetectorElement(id);
41 } else if (m_hit->isPLR()) {
42 id = plrID()->wafer_id(Barrel,
43 m_hit->getLayerDisk(),
44 m_hit->getPhiModule(),
45 m_hit->getEtaModule());
46 geoelement = plrMgr()->getDetectorElement(id);
47 } else if (m_hit->isHGTD()) {
48 id = hgtdID()->wafer_id(Barrel,
49 m_hit->getLayerDisk(),
50 m_hit->getPhiModule(),
51 m_hit->getEtaModule());
52 geoelement = hgtdMgr()->getDetectorElement(id);
57 // This special treatment is necessary because the localStartPosition and localEndPosition
58 // of the SiHit in the HGTD SD class https://gitlab.cern.ch/atlas/athena/-/blob/master/HighGranularityTimingDetector/HGTD_G4/HGTD_G4_SD/src/HGTDSensorGmxSD.cxx#L83-L89
59 // are set with coordinates in the (y, z, x) order.
60 const HepGeom::Point3D<double> localHit = m_hit->localStartPosition();
61 HepGeom::Point3D<double> flippedHit;
62 flippedHit[0]=localHit.y();
63 flippedHit[1]=localHit.z();
64 flippedHit[2]=localHit.x();
65 const HepGeom::Point3D<double> globalStartPos = Amg::EigenTransformToCLHEP(geoelement->transformHit()) * (flippedHit);
66 double x=globalStartPos.x();
67 double y=globalStartPos.y();
68 double z=globalStartPos.z();
69 return HepGeom::Point3D<double>(x,y,z);
71 const HepGeom::Point3D<double> globalStartPos = Amg::EigenTransformToCLHEP(geoelement->transformHit()) * HepGeom::Point3D<double>(m_hit->localStartPosition());
73 double x=globalStartPos.x();
74 double y=globalStartPos.y();
75 double z=globalStartPos.z();
76 return HepGeom::Point3D<double>(x,y,z);
80 return HepGeom::Point3D<double>(0.0,0.0,0.0);