diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonTGMeasAssocAlg/MuonTGMeasAssocAlg/MuonTGMeasAssocAlg.h b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonTGMeasAssocAlg/MuonTGMeasAssocAlg/MuonTGMeasAssocAlg.h index a81ab5b69b83aff3359c62669e6c8517e3996118..f9167d376ef72140b3a81957d576bd8fa69d26bf 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonTGMeasAssocAlg/MuonTGMeasAssocAlg/MuonTGMeasAssocAlg.h +++ b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonTGMeasAssocAlg/MuonTGMeasAssocAlg/MuonTGMeasAssocAlg.h @@ -85,8 +85,8 @@ class MuonTGMeasAssocAlg : public AthAlgorithm { bool m_misAlign; bool m_allowGeomAssoc; - mutable const Trk::TrackingGeometry* m_trackingGeometry; - std::string m_trackingGeometryName; + SG::ReadCondHandleKey<Trk::TrackingGeometry> m_trackingGeometryReadKey; + ToolHandle<Muon::IMuonTGMeasTool> m_muonTgTool{ this, diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonTGMeasAssocAlg/share/MuonTGMeasAssocAlg_jobOptions.py b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonTGMeasAssocAlg/share/MuonTGMeasAssocAlg_jobOptions.py index 0434eede64864f89070f7d23cb8867d06e65fe8e..98c02d784ad38403038f673e371bb112995d0005 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonTGMeasAssocAlg/share/MuonTGMeasAssocAlg_jobOptions.py +++ b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonTGMeasAssocAlg/share/MuonTGMeasAssocAlg_jobOptions.py @@ -9,23 +9,25 @@ MuonStandAloneGeometryBuilder = Trk__GeometryBuilder( name = "MuonStandAloneGeom ToolSvc += MuonStandAloneGeometryBuilder ToolSvc.MuonStandAloneGeometryBuilder.InDetTrackingGeometry = False ToolSvc.MuonStandAloneGeometryBuilder.CaloTrackingGeometry = False -ToolSvc.MuonStandAloneGeometryBuilder.MuonTrackingGeometry = True +ToolSvc.MuonStandAloneGeometryBuilder.MuonTrackingGeometry = True print MuonStandAloneGeometryBuilder # combined tracking geometry options -from TrkDetDescrSvc.TrkDetDescrSvcConf import TrackingGeometrySvc -MuonTrackingGeometrySvc = TrackingGeometrySvc( name ="MuonTrackingGeometrySvc", - TrackingGeometryName = "MuonStandaloneTrackingGeometry", - GeometryBuilder = MuonStandAloneGeometryBuilder, - BuildGeometryFromTagInfo = False, - AssignMaterialFromCOOL = False ) -theApp.CreateSvc += [ "TrackingGeometrySvc/MuonTrackingGeometrySvc" ] +from TrackingGeometryCondAlg.AtlasTrackingGeometryCondAlg import ConfiguredTrackingGeometryCondAlg +MuonTrkGeoCondAlg = ConfiguredTrackingGeometryCondAlg(name = "MuonTrackingGeometryCondAlg", + GeometryBuilder = MuonStandAloneGeometryBuilder, + BuildGeometryFromTagInfo = False, + TrackingGeometryWriteKey = 'MuonStandaloneTrackingGeometry') -# navigator +from AthenaCommon.AlgSequence import AthSequencer +condSeq = AthSequencer("AthCondSeq") +condSeq+= TrkGeoCondAlg + +# navigator from TrkExTools.TrkExToolsConf import Trk__Navigator MuonNavigator = Trk__Navigator(name = "MuonNavigator" ) ToolSvc += MuonNavigator -ToolSvc.MuonNavigator.TrackingGeometrySvc = "MuonTrackingGeometrySvc" +ToolSvc.MuonNavigator.TrackingGeometrySvc = "MuonTrackingGeometrySvc" ToolSvc.MuonNavigator.OutputLevel = 5 print MuonNavigator @@ -35,7 +37,7 @@ MuonMatUpdator = Trk__MaterialEffectsUpdator( name = "MuonMatUpdator" ) ToolSvc += MuonMatUpdator print MuonMatUpdator -# propagator +# propagator from TrkExSTEP_Propagator.TrkExSTEP_PropagatorConf import Trk__STEP_Propagator MuonPropagator = Trk__STEP_Propagator(name = 'MuonPropagator') ToolSvc += MuonPropagator @@ -44,7 +46,7 @@ print MuonPropagator # extrapolator from TrkExTools.TrkExToolsConf import Trk__Extrapolator -MuonExtrapolator = Trk__Extrapolator( name = 'MuonExtrapolator', +MuonExtrapolator = Trk__Extrapolator( name = 'MuonExtrapolator', Propagators = [ MuonPropagator ] , Navigator = MuonNavigator, MaterialEffectsUpdators = [ MuonMatUpdator ] @@ -57,7 +59,7 @@ print MuonExtrapolator # from MuonTGMeasAssocAlg.MuonTGMeasAssocAlgConf import Muon__MuonTGMeasAssocAlg MuonTGMeasAssocAlg = Muon__MuonTGMeasAssocAlg( name = 'MuonTGMeasAssocAlg', - Extrapolator = MuonExtrapolator, + Extrapolator = MuonExtrapolator, TrackingGeometry = 'MuonStandaloneTrackingGeometry', ProcessSegments = True ) topSequence += MuonTGMeasAssocAlg diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonTGMeasAssocAlg/src/MuonTGMeasAssocAlg.cxx b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonTGMeasAssocAlg/src/MuonTGMeasAssocAlg.cxx index 68e917e73c3d2699196d488ae9b749e446e4ec9b..0786fa99d6da796e814d205dcf6df2288377062b 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonTGMeasAssocAlg/src/MuonTGMeasAssocAlg.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonTGMeasAssocAlg/src/MuonTGMeasAssocAlg.cxx @@ -39,8 +39,7 @@ Muon::MuonTGMeasAssocAlg::MuonTGMeasAssocAlg(const std::string& name, ISvcLocato m_reAlign(false), m_misAlign(false), m_allowGeomAssoc(true), - m_trackingGeometry(0), - m_trackingGeometryName("AtlasTrackingGeometry"), + m_trackingGeometryReadKey("AtlasTrackingGeometry"), m_inputSegmentCollectionMoore("MooreSegments"), m_inputSegmentCollectionMoMu("MuonSegments_MoMu"), m_inputSegmentCollectionMBoy("ConvertedMBoySegments"), @@ -56,7 +55,6 @@ Muon::MuonTGMeasAssocAlg::MuonTGMeasAssocAlg(const std::string& name, ISvcLocato m_allHits(0), m_allSegments(0) { - declareProperty("TrackingGeometry", m_trackingGeometryName); declareProperty("ProcessMdtHits", m_mdtIn); declareProperty("ProcessRpcHits", m_rpcIn); declareProperty("ProcessCscHits", m_cscIn); @@ -85,6 +83,8 @@ Muon::MuonTGMeasAssocAlg::initialize() ATH_CHECK(m_DetectorManagerKey.initialize()); + ATH_CHECK(m_trackingGeometryReadKey.initialize()); + // Get an Identifier helper object ATH_CHECK(service("ActiveStoreSvc", m_activeStore)); ATH_CHECK(m_idHelperSvc.retrieve()); @@ -144,14 +144,18 @@ Muon::MuonTGMeasAssocAlg::execute() StatusCode sc; - if (!m_trackingGeometry) { - - ATH_CHECK(detStore()->retrieve(m_trackingGeometry, m_trackingGeometryName)); - ATH_MSG_DEBUG("tracking geometry Svc \"" << m_trackingGeometryName << "\" booked "); + //Set up read handle + SG::ReadCondHandle<Trk::TrackingGeometry> readHandle{m_trackingGeometryReadKey}; + if (!readHandle.isValid() || *readHandle == nullptr) { + ATH_MSG_WARNING(m_trackingGeometryReadKey.fullKey() << " is not available."); + return StatusCode::FAILURE; } + const Trk::TrackingGeometry* trkGeom = *readHandle; + + // create station map if not done already ; misalign stations if required if (!m_stationMap.size()) { - const Trk::TrackingVolume* vol = m_trackingGeometry->highestTrackingVolume(); + const Trk::TrackingVolume* vol = trkGeom->highestTrackingVolume(); ATH_MSG_INFO("creating station map "); createStationMap(vol, MuonDetMgr); ATH_MSG_INFO("station map created with " << m_stationMap.size() << " members "); @@ -371,6 +375,13 @@ Muon::MuonTGMeasAssocAlg::createStationSegmentCollection(const MuonGM::MuonDetec m_allSegments = new MuonTGSegments; + SG::ReadCondHandle<Trk::TrackingGeometry> readHandle{m_trackingGeometryReadKey}; + if (!readHandle.isValid() || *readHandle == nullptr) { + ATH_MSG_WARNING(m_trackingGeometryReadKey.fullKey() << " is not available."); + return StatusCode::FAILURE; + } + const Trk::TrackingGeometry* trkGeom = *readHandle; + for (unsigned int ic = 0; ic < segmColls.size(); ic++) { const Trk::SegmentCollection* segmColl = segmColls[ic]; for (Trk::SegmentCollection::const_iterator iter = segmColl->begin(); iter != segmColl->end(); ++iter) { @@ -381,7 +392,7 @@ Muon::MuonTGMeasAssocAlg::createStationSegmentCollection(const MuonGM::MuonDetec // retrieve station const Trk::DetachedTrackingVolume* detVol = 0; const std::vector<const Trk::DetachedTrackingVolume*>* detVols = - m_trackingGeometry->lowestDetachedTrackingVolumes(segment->globalPosition()); + trkGeom->lowestDetachedTrackingVolumes(segment->globalPosition()); if (detVols) { if (detVols->size() > 1) ATH_MSG_INFO("station overlaps ? "); if (detVols->size()) detVol = detVols->front(); @@ -406,7 +417,7 @@ Muon::MuonTGMeasAssocAlg::createStationSegmentCollection(const MuonGM::MuonDetec const MuonGM::TgcReadoutElement* tgcROE = MuonDetMgr->getTgcReadoutElement(id); pos = tgcROE->channelPos(id); } - const Trk::Layer* lay = m_trackingGeometry->associatedLayer(pos); + const Trk::Layer* lay = trkGeom->associatedLayer(pos); if (lay) detVol = lay->enclosingDetachedTrackingVolume(); if (detVol) ATH_MSG_DEBUG(" enclosing detached volume retrieved:" << detVol->name()); } @@ -970,8 +981,15 @@ Muon::MuonTGMeasAssocAlg::associatedLayer(int techn, Identifier id, const MuonGM // Get the TgcReadoutElement and the tube position from it const MuonGM::TgcReadoutElement* tgcROE = MuonDetMgr->getTgcReadoutElement(id); Amg::Vector3D pos = tgcROE->channelPos(id); - std::vector<const Trk::DetachedTrackingVolume*>* detVols = - m_trackingGeometry->lowestDetachedTrackingVolumes(pos); + + //Get the TrackingGeometry + SG::ReadCondHandle<Trk::TrackingGeometry> readHandle{m_trackingGeometryReadKey}; + if (!readHandle.isValid() || *readHandle == nullptr) { + ATH_MSG_WARNING(m_trackingGeometryReadKey.fullKey() << " is not available."); + } + const Trk::TrackingGeometry* trkGeom = *readHandle; + std::vector<const Trk::DetachedTrackingVolume*>* detVols = trkGeom->lowestDetachedTrackingVolumes(pos); + for (unsigned int i = 0; i < detVols->size(); i++) { Identifier sId((*detVols)[i]->layerRepresentation()->layerType()); ATH_MSG_INFO("geom assoc with station:" << (*detVols)[i] << "," << (*detVols)[i]->name() << ","