8#include <GeoModelKernel/GeoPerfUtils.h>
9#include <GeoModelKernel/GeoClearAbsPosAction.h>
13#include "Acts/Utilities/Helpers.hpp"
28 ATH_MSG_FATAL(
"The detector manager does not contain any elements");
29 return StatusCode::FAILURE;
32 return Acts::rangeContainsValue(
m_techs, d);
52 return StatusCode::SUCCESS;
62 (std::abs(
re->stationEta()) == 7 &&
m_idHelperSvc->stationNameString(
re->identify()) ==
"BML")) {
63 return m_idHelperSvc->rpcIdHelper().elementID(
re->stationName(),
re->stationEta(),
re->stationPhi(), 1);
66 return m_idHelperSvc->mdtIdHelper().elementID(
re->stationName(),
re->stationEta(),
re->stationPhi());
70 return re->identify();
76 ATH_MSG_DEBUG(
"Loading of the A line parameters deactivated");
77 return StatusCode::SUCCESS;
81 std::vector<const MuonReadoutElement*> readoutEles =
m_detMgr->getAllReadoutElements();
82 ATH_MSG_INFO(
"Load the alignment of "<<readoutEles.size()<<
" detector elements");
84 const GeoAlignableTransform* alignTrans =
re->alignableTransform();
87 <<
" has no alignable transform.");
90 std::shared_ptr<const Amg::Transform3D>& cached = alignDeltas[alignTrans];
93 <<
" has been cached before. ");
94 techTransforms[
re->detectorType()].insert(alignTrans);
99 ALineContainer::const_iterator aLineItr = aLineContainer->find(stationId);
100 if (aLineItr == aLineContainer->end()) {
102 <<
". Used "<<
m_idHelperSvc->toString(stationId)<<
" as station Identifier");
106 cached = std::make_shared<Amg::Transform3D>(aLineItr->delta());
107 techTransforms[
re->detectorType()].insert(alignTrans);
109 return StatusCode::SUCCESS;
115 return StatusCode::SUCCESS;
117 auto internAlign = std::make_unique<MdtAlignmentStore>(
m_idHelperSvc.get());
129 BLineContainer::const_iterator itr = bLines->find(stationId);
130 if (itr != bLines->end()) bline = &(*itr);
134 MdtAsBuiltContainer::const_iterator itr = asBuiltCont->find(stationId);
135 if (itr != asBuiltCont->end()) asBuilt = &(*itr);
137 if (asBuilt || bline) {
138 internAlign->storeDistortion(stationId, bline, asBuilt);
142 store.internalAlignment = std::move(internAlign);
143 return StatusCode::SUCCESS;
148 return StatusCode::SUCCESS;
150 auto internAlign = std::make_unique<MmAlignmentStore>();
162 BLineContainer::const_iterator itr = bLines->find(stationId);
163 if (itr != bLines->end()) {
164 internAlign->cacheBLine(
re->identify(), *itr);
168 store.internalAlignment = std::move(internAlign);
169 return StatusCode::SUCCESS;
174 return StatusCode::SUCCESS;
176 auto internAlign = std::make_unique<sTgcAlignmentStore>();
183 BLineContainer::const_iterator itr = bLines->find(stationId);
184 if (itr != bLines->end()) {
185 internAlign->cacheBLine(
re->identify(), *itr);
189 store.internalAlignment = std::move(internAlign);
190 return StatusCode::SUCCESS;
231 return StatusCode::SUCCESS;
237 const unsigned memBeforeAlign = GeoPerfUtils::getMem();
241 for (std::size_t det =0 ; det <
m_techs.size(); ++det) {
248 <<
" are still valid.");
251 auto writeCdo = std::make_unique<ActsTrk::DetectorAlignStore>(subDet);
253 const std::set<const GeoAlignableTransform*>& toStore = techTransforms[subDet];
255 for (
const GeoAlignableTransform* alignable : toStore) {
256 const std::shared_ptr<const Amg::Transform3D>& cached = alignDeltas[alignable];
257 if (!cached)
continue;
258 writeCdo->geoModelAlignment->setDelta(alignable, alignDeltas[alignable]);
260 writeCdo->geoModelAlignment->lockDelta();
272 unsigned numAligned{0};
273 std::ranges::for_each(
m_detMgr->getAllReadoutElements(subDet),
275 numAligned += re->storeAlignedTransforms(*writeCdo);
278 writeCdo->geoModelAlignment.reset();
282 std::ranges::for_each(
m_detMgr->getAllReadoutElements(subDet),
284 const Amg::Transform3D& detTrf{re->getMaterialGeom()->getAbsoluteTransform(writeCdo->geoModelAlignment.get())};
289 writeCdo->geoModelAlignment->getDeltas()->clear();
290 writeCdo->geoModelAlignment->lockPosCache();
292 ATH_CHECK(writeHandle.record(std::move(writeCdo)));
296 techTransforms.clear();
298 GeoClearAbsPosAction whipeTreeTop{};
299 for (
unsigned treeTop = 0 ; treeTop < m_detMgr->getNumTreeTops(); ++treeTop) {
300 m_detMgr->getTreeTop(treeTop)->exec(&whipeTreeTop);
303 const unsigned memAfterAlign = GeoPerfUtils::getMem();
304 ATH_MSG_INFO(
"Caching of the alignment parameters required "<<(memAfterAlign - memBeforeAlign) / 1024<<
" MB of memory");
305 return StatusCode::SUCCESS;
const boost::regex re(r_e)
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
std::set< ALinePar, std::less<> > ALineContainer
std::set< MdtAsBuiltPar, std::less<> > MdtAsBuiltContainer
std::set< BLinePar, std::less<> > BLineContainer
const ServiceHandle< StoreGateSvc > & detStore() const
static EventIDRange infiniteTime()
Produces an EventIDRange that is inifinite in Time and invalid in RunLumi.
Container classifier the MDT as-built parameters See parameter description in http://atlas-muon-align...
MuonReadoutElement is an abstract class representing the geometry of a muon detector.
const_id_iterator module_end() const
const_id_iterator module_begin() const
Iterators over full set of ids.
std::unordered_map< const GeoAlignableTransform *, std::shared_ptr< const Amg::Transform3D > > deltaMap
Association map of the GeoAlignableTransforms with the rigid alignment transformations.
StatusCode loadMmDeformPars(const EventContext &ctx, ActsTrk::DetectorAlignStore &store) const
Gaudi::Property< bool > m_applyALines
Apply translations and rotations to align the Muon stations.
const MuonGMR4::MuonDetectorManager * m_detMgr
SG::ReadCondHandleKey< MdtAsBuiltContainer > m_readMdtAsBuiltKey
StatusCode loadMdtDeformPars(const EventContext &ctx, ActsTrk::DetectorAlignStore &store) const
Loads the BLine container and the Mdt-as built parameters from the Conditions store and stores them i...
SG::ReadCondHandleKey< sTGCAsBuiltData > m_readsTgcAsBuiltKey
SG::ReadCondHandleKey< BLineContainer > m_readKeyBLines
Gaudi::Property< bool > m_applyMmPassivation
Gaudi::Property< bool > m_applyMdtAsBuilt
virtual StatusCode initialize() override
std::vector< ActsTrk::DetectorType > m_techs
std::map< ActsTrk::DetectorType, std::set< const GeoAlignableTransform * > > alignTechMap
Association map of the GeoAlignable transforms with the detector technologies.
Gaudi::Property< bool > m_applyBLines
Apply the chamber deformation model (Mdts + Nsw)
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
SG::ReadCondHandleKey< NswPassivationDbData > m_readNswPassivKey
Identifier alignmentId(const MuonGMR4::MuonReadoutElement *reElement) const
Returns the Identifier serving as key to find the alignment parameters connected with the readout ele...
SG::ReadCondHandleKey< NswAsBuiltDbData > m_readNswAsBuiltKey
SG::WriteCondHandleKeyArray< ActsTrk::DetectorAlignStore > m_writeKeys
StatusCode loadDeltas(const EventContext &ctx, deltaMap &alignDeltas, alignTechMap &techTransforms) const
Loads the ALineContainer from the conditions store and fills the deltaMap with the A-Line delta trans...
Gaudi::Property< std::string > m_keyToken
Gaudi::Property< bool > m_applyNswAsBuilt
SG::ReadCondHandleKey< ALineContainer > m_readKeyALines
virtual StatusCode execute(const EventContext &ctx) const override
Gaudi::Property< bool > m_fillAlignStoreCache
Flag toggling whether the alignment store shall be filled with the transforms or not.
StatusCode declareDependencies(const EventContext &ctx, ActsTrk::DetectorType detType, SG::WriteCondHandle< ActsTrk::DetectorAlignStore > &writeHandle) const
Loads the corresponding ReadCondHandles from the Conditions store and adds their IOVs to the dependen...
StatusCode loadStgcDeformPars(const EventContext &ctx, ActsTrk::DetectorAlignStore &store) const
Gaudi::Property< bool > m_fillGeoAlignStore
Flag toggling whether the GeoAlignmentStore shall be filled.
MmAsBuiltPtr microMegaData
void addDependency(const EventIDRange &range)
std::string to_string(const DetectorType &type)
DetectorType
Simple enum to Identify the Type of the ACTS sub detector.
@ Mm
Maybe not needed in the migration.
@ Tgc
Resitive Plate Chambers.
@ Rpc
Monitored Drift Tubes.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
The ReadoutGeomCnvAlg converts the Run4 Readout geometry build from the GeoModelXML into the legacy M...
This header ties the generic definitions in this package.
std::string to_string(const SectorProjector proj)
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.