From c0ccae8605f3c2e12e79ed60b56e2808f572e611 Mon Sep 17 00:00:00 2001 From: Peter Onyisi <ponyisi@utexas.edu> Date: Sat, 26 Dec 2020 19:37:43 +0100 Subject: [PATCH] Transparent reading of R21 ESD with different muon segment collection names --- Control/AthenaConfiguration/python/AllConfigFlags.py | 8 ++++++++ .../MuonConfig/python/MuonSegmentNameFixConfig.py | 11 +++++++++++ .../CscRawDataMonitoring/CSCSegmValMonAlg.h | 1 - .../python/CscMonitoringESD_Alg.py | 4 ++++ .../CscRawDataMonitoring/src/CSCSegmValMonAlg.cxx | 12 ++---------- .../MdtRawDataMonitoring/MdtRawDataMonAlg.h | 1 - .../python/MDTMonitorAlgorithm.py | 4 ++++ .../MdtRawDataMonitoring/src/MdtRawDataMonAlg.cxx | 12 ++---------- 8 files changed, 31 insertions(+), 22 deletions(-) create mode 100644 MuonSpectrometer/MuonConfig/python/MuonSegmentNameFixConfig.py diff --git a/Control/AthenaConfiguration/python/AllConfigFlags.py b/Control/AthenaConfiguration/python/AllConfigFlags.py index 83e2ed707f9..5025f59995a 100644 --- a/Control/AthenaConfiguration/python/AllConfigFlags.py +++ b/Control/AthenaConfiguration/python/AllConfigFlags.py @@ -48,8 +48,16 @@ def _createCfgFlags(): collections = [col for col in rawCollections if not col.endswith('Aux.') ] return collections + def _typedInputCollections(inputFile): + if not inputFile: + return [] + + collections = ['%s#%s' % type_key for type_key in GetFileMD(inputFile).get("itemList",[])] + return collections + acf.addFlag('Input.Collections', lambda prevFlags : _inputCollections(prevFlags.Input.Files) ) acf.addFlag('Input.SecondaryCollections', lambda prevFlags : _inputCollections(prevFlags.Input.SecondaryFiles) ) + acf.addFlag('Input.TypedCollections', lambda prevFlags : _typedInputCollections(prevFlags.Input.Files) ) acf.addFlag('Concurrency.NumProcs', 0) acf.addFlag('Concurrency.NumThreads', 0) diff --git a/MuonSpectrometer/MuonConfig/python/MuonSegmentNameFixConfig.py b/MuonSpectrometer/MuonConfig/python/MuonSegmentNameFixConfig.py new file mode 100644 index 00000000000..c23d67428bc --- /dev/null +++ b/MuonSpectrometer/MuonConfig/python/MuonSegmentNameFixConfig.py @@ -0,0 +1,11 @@ +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + +# This allows us to convert Run 2 ESD Trk::SegmentCollection "MuonSegments" to +# Run 3 "TrackMuonSegments" +def MuonSegmentNameFixCfg(flags): + from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator + cfg = ComponentAccumulator() + if 'Trk::SegmentCollection#MuonSegments' in flags.Input.TypedCollections: + from SGComps.AddressRemappingConfig import InputRenameCfg + cfg.merge(InputRenameCfg("Trk::SegmentCollection", "MuonSegments", "TrackMuonSegments")) + return cfg diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/CscRawDataMonitoring/CscRawDataMonitoring/CSCSegmValMonAlg.h b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/CscRawDataMonitoring/CscRawDataMonitoring/CSCSegmValMonAlg.h index 6408400df38..7567d39993d 100755 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/CscRawDataMonitoring/CscRawDataMonitoring/CSCSegmValMonAlg.h +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/CscRawDataMonitoring/CscRawDataMonitoring/CSCSegmValMonAlg.h @@ -59,7 +59,6 @@ class CSCSegmValMonAlg : public AthMonitorAlgorithm { "Handle to the service providing the IMuonEDMHelperSvc interface" }; ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; SG::ReadHandleKey<Trk::SegmentCollection> m_segmKey{this,"SegmentKey","TrackMuonSegments","muon segments"}; - SG::ReadHandleKey<Trk::SegmentCollection> m_segmKeyAlt{this,"SegmentKey","MuonSegments","muon segments"}; Gaudi::Property<std::vector<std::string>> m_sampSelTriggers{this,"EventSelTriggers",{}}; Gaudi::Property<bool> m_doEvtSel{this,"DoEventSelection",false}; diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/CscRawDataMonitoring/python/CscMonitoringESD_Alg.py b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/CscRawDataMonitoring/python/CscMonitoringESD_Alg.py index 2935361e463..a87f507615e 100644 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/CscRawDataMonitoring/python/CscMonitoringESD_Alg.py +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/CscRawDataMonitoring/python/CscMonitoringESD_Alg.py @@ -24,6 +24,10 @@ def CscMonitoringESD_AlgConfig(inputFlags): from MuonConfig.MuonGeometryConfig import MuonGeoModelCfg result.merge(MuonGeoModelCfg(inputFlags)) + # Fixup for R21 ESD + from MuonConfig.MuonSegmentNameFixConfig import MuonSegmentNameFixCfg + result.merge(MuonSegmentNameFixCfg(inputFlags)) + # The following class will make a sequence, configure algorithms, and link # them to GenericMonitoringTools from AthenaMonitoring import AthMonitorCfgHelper diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/CscRawDataMonitoring/src/CSCSegmValMonAlg.cxx b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/CscRawDataMonitoring/src/CSCSegmValMonAlg.cxx index 3ddfb1cf622..bef9f5e1191 100755 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/CscRawDataMonitoring/src/CSCSegmValMonAlg.cxx +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/CscRawDataMonitoring/src/CSCSegmValMonAlg.cxx @@ -46,7 +46,6 @@ StatusCode CSCSegmValMonAlg::initialize() { ATH_CHECK(m_edmHelperSvc.retrieve()); ATH_CHECK(m_idHelperSvc.retrieve()); ATH_CHECK(m_segmKey.initialize()); - ATH_CHECK(m_segmKeyAlt.initialize()); return AthMonitorAlgorithm::initialize(); } @@ -78,15 +77,8 @@ StatusCode CSCSegmValMonAlg::fillHistograms(const EventContext& ctx) const{ SG::ReadHandle<Trk::SegmentCollection> segments(m_segmKey, ctx); if (!segments.isValid()) { - if (m_segmKey.key()=="TrackMuonSegments") { - // old DataQuality_required input file (/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/Tier0ChainTests/q431/21.0/myESD.pool.root) still has 'MuonSegments' stored - // -> @TODO: need updated input file (temporary workaround: retrieve 'MuonSegments' instead if 'TrackMuonSegments' here) - segments = SG::ReadHandle<Trk::SegmentCollection>(m_segmKeyAlt, ctx); - } - if (!segments.isValid()) { - ATH_MSG_ERROR("Could not retrieve Trk::SegmentCollection "<<m_segmKey.key()); - return StatusCode::FAILURE; - } + ATH_MSG_ERROR("Could not retrieve Trk::SegmentCollection "<<m_segmKey.key()); + return StatusCode::FAILURE; } if ( segments->empty() ){ diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/MdtRawDataMonitoring/MdtRawDataMonitoring/MdtRawDataMonAlg.h b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/MdtRawDataMonitoring/MdtRawDataMonitoring/MdtRawDataMonAlg.h index 1d7de7822b6..1da9dddb88b 100755 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/MdtRawDataMonitoring/MdtRawDataMonitoring/MdtRawDataMonAlg.h +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/MdtRawDataMonitoring/MdtRawDataMonitoring/MdtRawDataMonAlg.h @@ -161,7 +161,6 @@ class MdtRawDataMonAlg: public AthMonitorAlgorithm { bool m_atlas_ready; SG::ReadHandleKey<Trk::SegmentCollection> m_segm_type{this,"Eff_segm_type","TrackMuonSegments","muon segments"}; - SG::ReadHandleKey<Trk::SegmentCollection> m_segm_typeAlt{this,"Eff_segm_typeAlt","MuonSegments","muon segments"}; std::string returnString(int i) const{ std::stringstream ss; diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/MdtRawDataMonitoring/python/MDTMonitorAlgorithm.py b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/MdtRawDataMonitoring/python/MDTMonitorAlgorithm.py index 25a11b32020..5ed3d6ce704 100644 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/MdtRawDataMonitoring/python/MDTMonitorAlgorithm.py +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/MdtRawDataMonitoring/python/MDTMonitorAlgorithm.py @@ -27,6 +27,10 @@ def MdtMonitoringConfig(inputFlags): from MuonConfig.MuonGeometryConfig import MuonGeoModelCfg result.merge(MuonGeoModelCfg(inputFlags)) + # Fixup for R21 ESD + from MuonConfig.MuonSegmentNameFixConfig import MuonSegmentNameFixCfg + result.merge(MuonSegmentNameFixCfg(inputFlags)) + # The following class will make a sequence, configure algorithms, and link # them to GenericMonitoringTools from AthenaMonitoring import AthMonitorCfgHelper diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/MdtRawDataMonitoring/src/MdtRawDataMonAlg.cxx b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/MdtRawDataMonitoring/src/MdtRawDataMonAlg.cxx index decb471fda6..0b53e791636 100755 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/MdtRawDataMonitoring/src/MdtRawDataMonAlg.cxx +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/MdtRawDataMonitoring/src/MdtRawDataMonAlg.cxx @@ -205,7 +205,6 @@ StatusCode MdtRawDataMonAlg::initialize() ATH_CHECK(m_l1RoiKey.initialize(SG::AllowEmpty)); ATH_CHECK(m_muonKey.initialize()); ATH_CHECK(m_segm_type.initialize()); - ATH_CHECK(m_segm_typeAlt.initialize()); ATH_CHECK(m_key_mdt.initialize()); ATH_CHECK(m_key_rpc.initialize()); ATH_CHECK(m_eventInfo.initialize()); @@ -530,15 +529,8 @@ StatusCode MdtRawDataMonAlg::fillHistograms(const EventContext& ctx) const SG::ReadHandle<Trk::SegmentCollection> segms(m_segm_type, ctx); if (!segms.isValid()) { - if (m_segm_type.key()=="TrackMuonSegments") { - // old DataQuality_required input file (/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/Tier0ChainTests/q431/21.0/myESD.pool.root) still has 'MuonSegments' stored - // -> @TODO: need updated input file (temporary workaround: retrieve 'MuonSegments' instead if 'TrackMuonSegments' here) - segms = SG::ReadHandle<Trk::SegmentCollection>(m_segm_typeAlt, ctx); - } - if (!segms.isValid()) { - ATH_MSG_ERROR("evtStore() does not contain mdt segms Collection with name " << m_segm_type); - return StatusCode::FAILURE; - } + ATH_MSG_ERROR("evtStore() does not contain mdt segms Collection with name " << m_segm_type); + return StatusCode::FAILURE; } MDTSegmentHistogramStruct segsPlots[4][4][16]; // [region][layer][phi] -- GitLab