2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
4 #ifndef MUONGEOMODELR4_MUONREADOUTELEMENT_ICC
5 #define MUONGEOMODELR4_MUONREADOUTELEMENT_ICC
7 #include <ActsGeoUtils/TransformCache.h>
9 template <> inline Amg::Transform3D
10 TransformCacheDetEle<MuonGMR4::MuonReadoutElement>::fetchTransform(const DetectorAlignStore* store) const {
11 return m_parent->toStation(store);
17 inline const GeoAlignableTransform* MuonReadoutElement::alignableTransform() const { return m_args.alignTransform; }
18 inline Identifier MuonReadoutElement::identify() const { return m_args.detElId; }
19 inline IdentifierHash MuonReadoutElement::identHash() const { return m_detElHash;}
20 inline std::string MuonReadoutElement::chamberDesign() const { return m_args.chambDesign; }
21 inline const Muon::IMuonIdHelperSvc* MuonReadoutElement::idHelperSvc() const { return m_idHelperSvc.get(); }
22 inline Muon::MuonStationIndex::ChIndex MuonReadoutElement::chamberIndex() const { return m_chIdx; }
23 inline int MuonReadoutElement::stationName() const { return m_stName; }
24 inline int MuonReadoutElement::stationEta() const { return m_stEta; }
25 inline int MuonReadoutElement::stationPhi() const { return m_stPhi; }
27 /// Returns the detector center (Which is the same as the detector center of the
28 /// first measurement layer)
29 inline Amg::Vector3D MuonReadoutElement::center(const ActsGeometryContext& ctx) const {
30 return localToGlobalTrans(ctx).translation();
32 inline Amg::Vector3D MuonReadoutElement::center(const ActsGeometryContext& ctx,
33 const Identifier& id) const {
34 return localToGlobalTrans(ctx, id).translation();
36 inline Amg::Vector3D MuonReadoutElement::center(const ActsGeometryContext& ctx,
37 const IdentifierHash& hash) const {
38 return localToGlobalTrans(ctx, hash).translation();
40 inline Amg::Transform3D MuonReadoutElement::globalToLocalTrans(const ActsGeometryContext& ctx,
41 const IdentifierHash& hash) const {
42 return localToGlobalTrans(ctx, hash).inverse();
44 inline Amg::Transform3D MuonReadoutElement::globalToLocalTrans(const ActsGeometryContext& ctx,
45 const Identifier& id) const {
46 return globalToLocalTrans(ctx, layerHash(id));
48 inline const Amg::Transform3D& MuonReadoutElement::localToGlobalTrans(const ActsGeometryContext& ctx,
49 const Identifier& id) const {
50 return localToGlobalTrans(ctx, layerHash(id));
52 #ifndef SIMULATIONBASE
53 inline const SpectrometerSector* MuonReadoutElement::msSector() const { return m_msSectorLink; }
54 inline const Chamber* MuonReadoutElement::chamber() const { return m_chambLink; }
57 template<class MuonImpl>
58 StatusCode MuonReadoutElement::insertTransform(const IdentifierHash& hash) {
59 TransformCacheMap::const_iterator cache = m_localToGlobalCaches.find(hash);
60 if (cache != m_localToGlobalCaches.end()) {
61 ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" - "<<idHelperSvc()->toStringDetEl(identify())
62 <<" has already a transformation cached for hash "<<hash);
63 return StatusCode::FAILURE;
65 auto newCache = std::make_unique<ActsTrk::TransformCacheDetEle<MuonImpl>>(hash, static_cast<MuonImpl*>(this));
66 m_localToGlobalCaches.insert(std::make_pair(hash, std::move(newCache)));
67 return StatusCode::SUCCESS;
70 } // namespace MuonGMR4