ATLAS Offline Software
MuonReadoutElement.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 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 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 
53 template<class MuonImpl>
54 StatusCode MuonReadoutElement::insertTransform(const IdentifierHash& hash) {
55  TransformCacheMap::const_iterator cache = m_localToGlobalCaches.find(hash);
56  if (cache != m_localToGlobalCaches.end()) {
57  ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" - "<<idHelperSvc()->toStringDetEl(identify())
58  <<" has already a transformation cached for hash "<<hash);
59  return StatusCode::FAILURE;
60  }
61  auto newCache = std::make_unique<ActsTrk::TransformCacheDetEle<MuonImpl>>(hash, static_cast<MuonImpl*>(this));
62  m_localToGlobalCaches.insert(std::make_pair(hash, std::move(newCache)));
63  return StatusCode::SUCCESS;
64 }
65 
66 } // namespace MuonGMR4
67 #endif