From 51b5f02b2318f7b07eefd6a4e8e5bf06aa3d1504 Mon Sep 17 00:00:00 2001 From: Marco Cattaneo <marco.cattaneo@cern.ch> Date: Tue, 14 Aug 2018 16:30:07 +0200 Subject: [PATCH] Add a callback to CommonMuonTool, to update cached geometry when alignment changes --- Muon/MuonID/src/component/CommonMuonTool.cpp | 35 ++++++++++++++++---- Muon/MuonID/src/component/CommonMuonTool.h | 2 ++ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/Muon/MuonID/src/component/CommonMuonTool.cpp b/Muon/MuonID/src/component/CommonMuonTool.cpp index 33f5b0e3686..7f19330c1d9 100644 --- a/Muon/MuonID/src/component/CommonMuonTool.cpp +++ b/Muon/MuonID/src/component/CommonMuonTool.cpp @@ -49,12 +49,7 @@ auto CommonMuonTool::initialize() -> StatusCode { myRegions = m_det->regions()/myStations; first_used_station = myStations - num_active_stations; - // Load station information from detector description - for (unsigned s = 0; s != myStations; ++s) { - m_regionInner.emplace_back(m_det->getInnerX(s), m_det->getInnerY(s)); - m_regionOuter.emplace_back(m_det->getOuterX(s), m_det->getOuterY(s)); - m_stationZ.push_back(m_det->getStationZ(s)); - } + updMgrSvc()->registerCondition( this, m_det->geometry(), &CommonMuonTool::updateGeometry); // Prepare to load information from conditions data base Condition* condFoiFactor = nullptr; @@ -352,3 +347,31 @@ auto CommonMuonTool::i_foi(int station, int region, double p) const noexcept unsigned int CommonMuonTool::getFirstUsedStation() const noexcept { return first_used_station; } + +StatusCode CommonMuonTool::updateGeometry() +{ + if( msgLevel(MSG::DEBUG) ) { + debug() << "Station positions: Inner{X,Y}, Outer{X,Y}, Z :" << endmsg; + } + + // Load station information from detector description + m_regionInner.clear(); + m_regionOuter.clear(); + m_stationZ.clear(); + + if( msgLevel(MSG::DEBUG) ) { + debug() << "Station positions: Inner{X,Y}, Outer{X,Y}, Z :" << endmsg; + } + for (int s = 0; s != m_det->stations(); ++s) { + m_regionInner.emplace_back(m_det->getInnerX(s), m_det->getInnerY(s)); + m_regionOuter.emplace_back(m_det->getOuterX(s), m_det->getOuterY(s)); + m_stationZ.push_back(m_det->getStationZ(s)); + if( msgLevel(MSG::DEBUG) ) { + debug() << m_det->getInnerX(s) << ", " << m_det->getInnerY(s) << ", " << + m_det->getOuterX(s) << ", " << m_det->getOuterY(s) << ", " << + m_det->getStationZ(s) << endmsg; + } + } + + return StatusCode::SUCCESS; +} diff --git a/Muon/MuonID/src/component/CommonMuonTool.h b/Muon/MuonID/src/component/CommonMuonTool.h index 2d31dd1dc2f..830af3db523 100644 --- a/Muon/MuonID/src/component/CommonMuonTool.h +++ b/Muon/MuonID/src/component/CommonMuonTool.h @@ -49,6 +49,8 @@ class CommonMuonTool final : public extends1<GaudiTool, ICommonMuonTool> { -> std::pair<double, double> override; virtual auto getFirstUsedStation() const noexcept -> unsigned int override; + StatusCode updateGeometry(); + unsigned myStations, myRegions; private: -- GitLab