ATLAS Offline Software
MuonReadoutElement.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 #ifndef MUONGEOMODELR4_MUONREADOUTELEMENT_ICC
5 #define MUONGEOMODELR4_MUONREADOUTELEMENT_ICC
6 
7 #include <ActsGeoUtils/TransformCache.h>
8 namespace ActsTrk{
9  template <> inline Amg::Transform3D
10  TransformCacheDetEle<MuonGMR4::MuonReadoutElement>::fetchTransform(const DetectorAlignStore* store) const {
11  return m_parent->toStation(store);
12  }
13 }
14 
15 namespace MuonGMR4 {
16 
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 const 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; }
26 
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();
31 }
32 inline Amg::Vector3D MuonReadoutElement::center(const ActsGeometryContext& ctx,
33  const Identifier& id) const {
34  return localToGlobalTrans(ctx, id).translation();
35 }
36 inline Amg::Vector3D MuonReadoutElement::center(const ActsGeometryContext& ctx,
37  const IdentifierHash& hash) const {
38  return localToGlobalTrans(ctx, hash).translation();
39 }
40 inline Amg::Transform3D MuonReadoutElement::globalToLocalTrans(const ActsGeometryContext& ctx,
41  const IdentifierHash& hash) const {
42  return localToGlobalTrans(ctx, hash).inverse();
43 }
44 inline Amg::Transform3D MuonReadoutElement::globalToLocalTrans(const ActsGeometryContext& ctx,
45  const Identifier& id) const {
46  return globalToLocalTrans(ctx, layerHash(id));
47 }
48 inline const Amg::Transform3D& MuonReadoutElement::localToGlobalTrans(const ActsGeometryContext& ctx,
49  const Identifier& id) const {
50  return localToGlobalTrans(ctx, layerHash(id));
51 }
52 #ifndef SIMULATIONBASE
53 inline const SpectrometerSector* MuonReadoutElement::msSector() const { return m_msSectorLink; }
54 inline const Chamber* MuonReadoutElement::chamber() const { return m_chambLink; }
55 #endif
56 
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;
64  }
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;
68 }
69 
70 } // namespace MuonGMR4
71 #endif