ATLAS Offline Software
Loading...
Searching...
No Matches
MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonReadoutElement.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
8#ifndef SIMULATIONBASE
9# include "Acts/Surfaces/LineBounds.hpp"
10# include "Acts/Surfaces/PlanarBounds.hpp"
11# include "Acts/Geometry/GeometryContext.hpp"
12# include "Acts/Surfaces/StrawSurface.hpp"
13# include "Acts/Surfaces/PlaneSurface.hpp"
14#endif
15
16using namespace ActsTrk;
17namespace MuonGMR4 {
20 : GeoVDetectorElement(args.physVol),
21 AthMessaging("MuonReadoutElement"),
22 m_args{args} {
23 if (!m_idHelperSvc.retrieve().isSuccess()) {
24 ATH_MSG_FATAL("Failed to retrieve the MuonIdHelperSvc");
25 }
26 m_stName = m_idHelperSvc->stationName(identify());
27 m_stEta = m_idHelperSvc->stationEta(identify());
28 m_stPhi = m_idHelperSvc->stationPhi(identify());
29 m_detElHash = m_idHelperSvc->detElementHash(identify());
30 m_chIdx = m_idHelperSvc->chamberIndex(identify());
31}
34 if(!alignableTransform()) {
35 ATH_MSG_FATAL("The readout element "<<idHelperSvc()->toStringDetEl(identify())<<" has no assigned alignable node");
36 return StatusCode::FAILURE;
37 }
38 m_centralTrfCache = std::make_unique<TransformCacheDetEle<MuonReadoutElement>>(geoTransformHash(), this);
39 return StatusCode::SUCCESS;
40}
42 static const IdentifierHash hash{static_cast<unsigned>(~0)-1};
43 return hash;
44}
45
47 return getMaterialGeom()->getAbsoluteTransform(alignStore ? alignStore->geoModelAlignment.get() : nullptr);
48}
50 for (const auto& cache : m_localToGlobalCaches) {
51 if (cache){
52 cache->releaseNominalCache();
53 }
54 }
55 m_centralTrfCache->releaseNominalCache();
56}
57
59 if (store.detType != detectorType()) {
60 return 0;
61 }
62 ATH_MSG_DEBUG(__func__<<"() "<<__LINE__<<" - Start "<<idHelperSvc()->toStringDetEl(identify())<<".");
63 unsigned int aligned{0};
64 aligned+=m_centralTrfCache->storeTransform(store);
65 for (const auto& cache : m_localToGlobalCaches) {
66 if (!cache) {
67 continue;
68 }
69 aligned+=cache->storeTransform(store);
70 }
71 ATH_MSG_DEBUG(__func__<<"() "<<__LINE__<<" - Internal caching done.");
72 return aligned;
73}
74
81#ifndef SIMULATIONBASE
82const Acts::Transform3& MuonReadoutElement::localToGlobalTransform(const Acts::GeometryContext& anygctx) const {
83 const GeometryContext *gctx = anygctx.get<const GeometryContext *>();
85}
86std::shared_ptr<Acts::Surface> MuonReadoutElement::surfacePtr(const IdentifierHash& hash) const {
87 SurfaceCacheSet::const_iterator cache = m_surfaces.find(hash);
88 if(cache != m_surfaces.end()) return (*cache)->getSurface();
89 ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" "<<__func__<<"() -- Hash "<<hash
90 <<" is unknown to "<<idHelperSvc()->toStringDetEl(identify()));
91 return nullptr;
92}
93
94const Acts::Surface& MuonReadoutElement::surface() const { return surface(geoTransformHash()); }
96const Acts::Surface& MuonReadoutElement::surface(const IdentifierHash& hash) const { return *surfacePtr(hash); }
97Acts::Surface& MuonReadoutElement::surface(const IdentifierHash& hash) { return *surfacePtr(hash); }
98
100 std::shared_ptr<const Acts::LineBounds> lBounds) {
101
102 //get the local to global transform cache
103 const TransformCache* cache = transformCache(hash);
104 if (!cache) {
105 ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" - "<<idHelperSvc()->toString(identify())
106 <<" no transform cache available for hash "<<hash);
107 return StatusCode::FAILURE;
108 }
109
110 auto insert_itr = m_surfaces.insert(std::make_unique<SurfaceCache>(cache));
111 if(!insert_itr.second){
112 ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" - "<<idHelperSvc()->toString(identify())
113 <<" Insertion to muon surface cache failed for hash "<<hash);
114 return StatusCode::FAILURE;
115 }
116 //Create straw surface for the surface cache
117 (*insert_itr.first)->setSurface(Acts::Surface::makeShared<Acts::StrawSurface>(lBounds, **insert_itr.first));
118 return StatusCode::SUCCESS;
119
120}
121
123 std::shared_ptr<const Acts::PlanarBounds> pBounds){
124
125 //get the local to global transform cache
126 const TransformCache* cache = transformCache(hash);
127 if (!cache) {
128 ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" - "<<idHelperSvc()->toString(identify())
129 <<" no transform cache available for hash "<<hash);
130 return StatusCode::FAILURE;
131 }
132 auto insert_itr = m_surfaces.insert(std::make_unique<SurfaceCache>(cache));
133 if(!insert_itr.second){
134 ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" - "<<idHelperSvc()->toString(identify())
135 <<" Insertion to muon surface cache failed for hash "<<hash);
136 return StatusCode::FAILURE;
137 }
138 //Create a plane surface for the surface cache
139 (*insert_itr.first)->setSurface(Acts::Surface::makeShared<Acts::PlaneSurface>(pBounds, **insert_itr.first));
140 return StatusCode::SUCCESS;
141}
142
147 m_msSectorLink = envelope;
148}
149
150std::vector<std::shared_ptr<Acts::Surface>> MuonReadoutElement::getSurfaces() const {
151 std::vector<std::shared_ptr<Acts::Surface>> surfaces{};
152 surfaces.reserve(m_surfaces.size());
153 for (const std::unique_ptr<SurfaceCache>& cache : m_surfaces) {
154 if (cache->hash() != geoTransformHash()) {
155 surfaces.push_back(cache->getSurface());
156 ATH_MSG_VERBOSE("Add surface "<<idHelperSvc()->toString(cache->identify())
157 <<std::endl<<(surfaces.back()->bounds()));
158 }
159 }
160 return surfaces;
161}
162#endif
163
164} // namespace MuonGMR4
#define ATH_MSG_FATAL(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
std::shared_ptr< GeoAlignmentStore > geoModelAlignment
Store containing the aligned GeoModel nodes.
virtual DetectorType detectorType() const =0
Returns the detector element type.
Implementation used for the Detector elements.
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
This is a "hash" representation of an Identifier.
Chamber represent the volume enclosing a muon station.
Definition Chamber.h:29
std::unique_ptr< ActsTrk::TransformCache > m_centralTrfCache
Cache of the transform of the readout element itself.
std::vector< std::shared_ptr< Acts::Surface > > getSurfaces() const
Returns all surfaces that are associated with the active readout planes.
const Amg::Transform3D & localToGlobalTransform(const ActsTrk::GeometryContext &ctx) const
Returns the transformation from the local coordinate system of the readout element into the global AT...
Amg::Transform3D globalToLocalTransform(const ActsTrk::GeometryContext &ctx) const
Returns the transformation from the global ATLAS coordinate system into the local coordinate system o...
const Amg::Transform3D & toStation(const ActsTrk::DetectorAlignStore *alignStore) const
Returns the transformation from the GeoModel tree and applies the A-lines if a valid alignment store ...
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
IdHelperSvc for Identifier manipulation.
StatusCode strawSurfaceFactory(const IdentifierHash &hash, std::shared_ptr< const Acts::LineBounds > lBounds)
Invokes the factory to create straw surfaces && to associate them with the particular transform cache...
void setChamberLink(const Chamber *chamber)
Sets the link to the enclosing chamber.
void setSectorLink(const SpectrometerSector *envelope)
Set the link to the enclosing sector envelope.
std::shared_ptr< Acts::Surface > surfacePtr(const IdentifierHash &hash) const
Returns the mutable surface pointer associated with the transform of a given readout layer.
StatusCode planeSurfaceFactory(const IdentifierHash &hash, std::shared_ptr< const Acts::PlanarBounds > pBounds)
Invokes the factory to create plane surfaces && to associate them with the particular transform cache...
Identifier identify() const override final
Return the ATLAS identifier.
const Acts::Surface & surface() const override final
Returns the surface associated with the readout element.
const Muon::IMuonIdHelperSvc * idHelperSvc() const
Returns the pointer to the muonIdHelperSvc.
Muon::MuonStationIndex::ChIndex m_chIdx
Cache the chamber index of the Identifier.
StatusCode createGeoTransform()
Creates the TransformCacheDetEle corresponding the generic local -> global transformation of the read...
const Chamber * chamber() const
Returns the pointer to the chamber enclosing this readout element.
MuonReadoutElement(const defineArgs &args)
Constructor taking the basic define arguments.
void releaseUnAlignedTrfs() const
Release all transforms from the memory that are not connected with a geometry context but cached by t...
const SpectrometerSector * m_msSectorLink
Pointer to the associated MS-sector & MuonChamber.
unsigned int storeAlignedTransforms(ActsTrk::DetectorAlignStore &store) const override final
Construct the final aligned transformations and store them in the alignment store.
const ActsTrk::TransformCache * transformCache(const IdentifierHash &measHash) const
Returns the pointer to the TransformCache associated with this measurement hash.
static IdentifierHash geoTransformHash()
Returns the hash that is associated with the surface cache holding the transformation that is placing...
const GeoAlignableTransform * alignableTransform() const
Return the alignable transform node of the readout element.
A spectrometer sector forms the envelope of all chambers that are placed in the same MS sector & laye...
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Eigen::Affine3d Transform3D
The ReadoutGeomCnvAlg converts the Run4 Readout geometry build from the GeoModelXML into the legacy M...
std::string toString(const MuonGMR4::MuonReadoutElement *re)