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 {
19 static const Amg::Transform3D dummyTrans{Amg::Transform3D::Identity()};
20}
21namespace MuonGMR4 {
24 : GeoVDetectorElement(args.physVol),
25 AthMessaging("MuonReadoutElement"),
26 m_args{args} {
27 if (!m_idHelperSvc.retrieve().isSuccess()) {
28 ATH_MSG_FATAL("Failed to retrieve the MuonIdHelperSvc");
29 }
30 m_stName = m_idHelperSvc->stationName(identify());
31 m_stEta = m_idHelperSvc->stationEta(identify());
32 m_stPhi = m_idHelperSvc->stationPhi(identify());
33 m_detElHash = m_idHelperSvc->detElementHash(identify());
34 m_chIdx = m_idHelperSvc->chamberIndex(identify());
35}
38 if(!alignableTransform()) {
39 ATH_MSG_FATAL("The readout element "<<idHelperSvc()->toStringDetEl(identify())<<" has no assigned alignable node");
40 return StatusCode::FAILURE;
41 }
43}
45 static const IdentifierHash hash{static_cast<unsigned>(~0)-1};
46 return hash;
47}
48
49
51 const IdentifierHash& hash) const {
52 TransformCacheMap::const_iterator cache = m_localToGlobalCaches.find(hash);
53 if (cache != m_localToGlobalCaches.end()) return cache->second->getTransform(ctx.getStore(detectorType()).get());
54 ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" "<<__func__<<"() -- "
55 <<idHelperSvc()->toStringDetEl(identify())<<" hash: "<<hash<<" is unknown.");
56 return dummyTrans;
57}
58
60 return getMaterialGeom()->getAbsoluteTransform(alignStore ? alignStore->geoModelAlignment.get() : nullptr);
61}
63 for (const auto& cache : m_localToGlobalCaches) {
64 cache.second->releaseNominalCache();
65 }
66}
67
69 if (store.detType != detectorType()) return 0;
70 unsigned int aligned{0};
71 for (const auto& cache : m_localToGlobalCaches) {
72 cache.second->getTransform(&store);
73 ++aligned;
74 }
75 return aligned;
76}
77
84#ifndef SIMULATIONBASE
85const Acts::Transform3& MuonReadoutElement::transform(const Acts::GeometryContext& anygctx) const {
86 const ActsTrk::GeometryContext *gctx = anygctx.get<const ActsTrk::GeometryContext *>();
88}
89std::shared_ptr<Acts::Surface> MuonReadoutElement::surfacePtr(const IdentifierHash& hash) const {
90 ActsTrk::SurfaceCacheSet::const_iterator cache = m_surfaces.find(hash);
91 if(cache != m_surfaces.end()) return (*cache)->getSurface();
92 ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" "<<__func__<<"() -- Hash "<<hash
93 <<" is unknown to "<<idHelperSvc()->toStringDetEl(identify()));
94 return nullptr;
95}
96
97const Acts::Surface& MuonReadoutElement::surface() const { return surface(geoTransformHash()); }
99const Acts::Surface& MuonReadoutElement::surface(const IdentifierHash& hash) const { return *surfacePtr(hash); }
100Acts::Surface& MuonReadoutElement::surface(const IdentifierHash& hash) { return *surfacePtr(hash); }
101
103 std::shared_ptr<const Acts::LineBounds> lBounds) {
104
105 //get the local to global transform cache
106 TransformCacheMap::const_iterator transformCache = m_localToGlobalCaches.find(hash);
107 if (transformCache == m_localToGlobalCaches.end()) {
108 ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" - "<<idHelperSvc()->toString(identify())
109 <<" no transform cache available for hash "<<hash);
110 return StatusCode::FAILURE;
111 }
112
113 auto insert_itr = m_surfaces.insert(std::make_unique<ActsTrk::SurfaceCache>(transformCache->second.get()));
114 if(!insert_itr.second){
115 ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" - "<<idHelperSvc()->toString(identify())
116 <<" Insertion to muon surface cache failed for hash "<<hash);
117 return StatusCode::FAILURE;
118 }
119 //Create straw surface for the surface cache
120 (*insert_itr.first)->setSurface(Acts::Surface::makeShared<Acts::StrawSurface>(lBounds, **insert_itr.first));
121 return StatusCode::SUCCESS;
122
123}
124
126 std::shared_ptr<const Acts::PlanarBounds> pBounds){
127
128 //get the local to global transform cache
129 TransformCacheMap::const_iterator transformCache = m_localToGlobalCaches.find(hash);
130 if (transformCache == m_localToGlobalCaches.end()) {
131 ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" - "<<idHelperSvc()->toString(identify())
132 <<" no transform cache available for hash "<<hash);
133 return StatusCode::FAILURE;
134 }
135 auto insert_itr = m_surfaces.insert(std::make_unique<ActsTrk::SurfaceCache>(transformCache->second.get()));
136 if(!insert_itr.second){
137 ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" - "<<idHelperSvc()->toString(identify())
138 <<" Insertion to muon surface cache failed for hash "<<hash);
139 return StatusCode::FAILURE;
140 }
141 //Create a plane surface for the surface cache
142 (*insert_itr.first)->setSurface(Acts::Surface::makeShared<Acts::PlaneSurface>(pBounds, **insert_itr.first));
143 return StatusCode::SUCCESS;
144}
145
150 m_msSectorLink = envelope;
151}
152
153std::vector<std::shared_ptr<Acts::Surface>> MuonReadoutElement::getSurfaces() const {
154 std::vector<std::shared_ptr<Acts::Surface>> surfaces{};
155 surfaces.reserve(m_surfaces.size());
156 for (const std::unique_ptr<SurfaceCache>& cache : m_surfaces) {
157 if (cache->hash() != geoTransformHash()) {
158 surfaces.push_back(cache->getSurface());
159 ATH_MSG_VERBOSE("Add surface "<<idHelperSvc()->toString(cache->identify())
160 <<std::endl<<(surfaces.back()->bounds()));
161 }
162 }
163 return surfaces;
164}
165#endif
166
167} // namespace MuonGMR4
#define ATH_MSG_FATAL(x)
#define ATH_MSG_VERBOSE(x)
std::shared_ptr< GeoAlignmentStore > geoModelAlignment
Store containing the aligned GeoModel nodes.
AlignmentStorePtr & getStore(const DetectorType type)
Returns the mutable alignable store for the ATLAS detector type (Pixel, Mdt, etc.)
virtual DetectorType detectorType() const =0
Returns the detector element type.
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:28
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 ...
const Amg::Transform3D & transform(const Acts::GeometryContext &gctx) const override final
Wrapper function of the localToGlobalTransform method to satisfy the Acts::IDetectorElementBase inter...
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.
StatusCode insertTransform(const IdentifierHash &hash)
Constructs the TransformDetEleCache associated with the hash of the given Mdt tube or strip layer.
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(const ActsTrk::DetectorAlignStore &store) const override final
Construct the final aligned transformations and store them in the alignment store.
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...
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:130
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
std::shared_ptr< Acts::Surface > surfacePtr
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)