diff --git a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/CMakeLists.txt b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/CMakeLists.txt index 5216375c95dc295a4f5bd3f715f41b7a86f19486..9d5436d6899772ed0ea7010b16e49bc533d33a80 100644 --- a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/CMakeLists.txt +++ b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/CMakeLists.txt @@ -39,4 +39,5 @@ atlas_add_executable( MCAST_Tester MuonSelectorToolsLib MuonMomentumCorrectionsLib MuonAnalysisInterfacesLib AsgMessagingLib PathResolver) # Install files from the package: -atlas_install_joboptions( share/*.py ) +atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} ) + diff --git a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/MuonMomentumCorrections/MuonCalibTool.h b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/MuonMomentumCorrections/MuonCalibTool.h index 87ec1768845ac891d8c87be2d64dd8ce1ef425a6..0aa7bacb5bd004efe16bec7ee10d0db23014f0af 100644 --- a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/MuonMomentumCorrections/MuonCalibTool.h +++ b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/MuonMomentumCorrections/MuonCalibTool.h @@ -99,12 +99,12 @@ namespace CP { Gaudi::Property<bool> m_2stations_highpt_smearing{this, "do2StationsHighPt", false, "TODO"}; Gaudi::Property<float> m_HighPtSystThreshold{this, "HighPtSystThr", 300.0, "Thershold for high pT smearing in GeV"}; - asg::AnaToolHandle<CP::IMuonSelectionTool> m_MuonSelectionTool; + asg::AnaToolHandle<CP::IMuonSelectionTool> m_MuonSelectionTool{""}; - asg::AnaToolHandle<CP::IMuonCalibIntTool> m_MuonIntSagittaTool; - asg::AnaToolHandle<CP::IMuonCalibIntScaleSmearTool> m_MuonIntScaleSmearTool; + asg::AnaToolHandle<CP::IMuonCalibIntTool> m_MuonIntSagittaTool{""}; + asg::AnaToolHandle<CP::IMuonCalibIntScaleSmearTool> m_MuonIntScaleSmearTool{""}; - asg::AnaToolHandle<CP::IMuonCalibIntTool> m_MuonIntHighTSmearTool; + asg::AnaToolHandle<CP::IMuonCalibIntTool> m_MuonIntHighTSmearTool{""}; // internal tool function diff --git a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/Root/MuonCalibTool.cxx b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/Root/MuonCalibTool.cxx index 1a981efe0b3845f5ee6671a7a3957c06cf1c9d7d..598f80708c5a3e61473fadf2e678bf351b02dc31 100644 --- a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/Root/MuonCalibTool.cxx +++ b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/Root/MuonCalibTool.cxx @@ -15,9 +15,13 @@ namespace CP { - MuonCalibTool::MuonCalibTool(const std::string &name) : asg::AsgTool(name), - m_MuonSelectionTool("") - { + MuonCalibTool::MuonCalibTool(const std::string &name) : asg::AsgTool(name){ + + /// These properties are meant to be expert properties for debugging of the code and shall not touched by the common + m_MuonSelectionTool.declarePropertyFor(this,"MuonSelectionTool", "Instance of the MuonSelectionTool needed for the HighPt categorization"); + m_MuonIntSagittaTool.declarePropertyFor(this, "SagittaTool", "Instance of the Sagitta bias corrections sub tool"); + m_MuonIntScaleSmearTool.declarePropertyFor(this, "ScaleAndSmearTool", "Instance of the tool that applies the smearing & scale corrections"); + m_MuonIntHighTSmearTool.declarePropertyFor(this, "HighPtSmearingTool", "Extra smearing of the high pt working point"); } StatusCode MuonCalibTool::initialize() @@ -57,38 +61,46 @@ namespace CP } // Get the muon selection tool - m_MuonSelectionTool.setTypeAndName("CP::MuonSelectionTool/MCaST_Own_MST"); - ATH_CHECK(m_MuonSelectionTool.setProperty("MaxEta", 2.7)); - ATH_CHECK(m_MuonSelectionTool.setProperty("MuQuality", 1)); - ATH_CHECK(m_MuonSelectionTool.setProperty("TurnOffMomCorr", true)); - ATH_CHECK(m_MuonSelectionTool.setProperty("IsRun3Geo", m_isRun3.value())); - // ATH_CHECK(m_MuonSelectionTool.setProperty("OutputLevel", msg().level())); + if (m_MuonSelectionTool.empty()) { + m_MuonSelectionTool.setTypeAndName("CP::MuonSelectionTool/MCaST_Own_MST"); + ATH_CHECK(m_MuonSelectionTool.setProperty("MaxEta", 2.7)); + ATH_CHECK(m_MuonSelectionTool.setProperty("MuQuality", 1)); + ATH_CHECK(m_MuonSelectionTool.setProperty("TurnOffMomCorr", true)); + ATH_CHECK(m_MuonSelectionTool.setProperty("IsRun3Geo", m_isRun3.value())); + ATH_CHECK(m_MuonSelectionTool.setProperty("OutputLevel", msg().level())); + } ATH_CHECK(m_MuonSelectionTool.retrieve()); // Create the Sagitta tool - m_MuonIntSagittaTool.setTypeAndName("CP::MuonCalibIntSagittaTool/MCaST_Sagitta"); - ATH_CHECK(m_MuonIntSagittaTool.setProperty("release", m_release.value())); - ATH_CHECK(m_MuonIntSagittaTool.setProperty("systematicScheme", m_sysScheme.value())); - ATH_CHECK(m_MuonIntSagittaTool.setProperty("applyCorrectionOnData", m_applyCorrectionOnData.value())); - ATH_CHECK(m_MuonIntSagittaTool.setProperty("doEtaSagittaSys", m_doEtaSagittaSys.value())); - ATH_CHECK(m_MuonIntSagittaTool.setProperty("OutputLevel", msg().level())); + if (m_MuonIntSagittaTool.empty()) { + m_MuonIntSagittaTool.setTypeAndName("CP::MuonCalibIntSagittaTool/MCaST_Sagitta"); + ATH_CHECK(m_MuonIntSagittaTool.setProperty("release", m_release.value())); + ATH_CHECK(m_MuonIntSagittaTool.setProperty("systematicScheme", m_sysScheme.value())); + ATH_CHECK(m_MuonIntSagittaTool.setProperty("applyCorrectionOnData", m_applyCorrectionOnData.value())); + ATH_CHECK(m_MuonIntSagittaTool.setProperty("doEtaSagittaSys", m_doEtaSagittaSys.value())); + ATH_CHECK(m_MuonIntSagittaTool.setProperty("OutputLevel", msg().level())); + } ATH_CHECK(m_MuonIntSagittaTool.retrieve()); // Create the scale smear tool - m_MuonIntScaleSmearTool.setTypeAndName("CP::MuonCalibIntScaleSmearTool/MCaST_ScaleSmear"); - ATH_CHECK(m_MuonIntScaleSmearTool.setProperty("release", m_release.value())); - ATH_CHECK(m_MuonIntScaleSmearTool.setProperty("systematicScheme", m_sysScheme.value())); - ATH_CHECK(m_MuonIntScaleSmearTool.setProperty("doDirectCBCalib", m_doDirectCBCalib.value())); - ATH_CHECK(m_MuonIntScaleSmearTool.setProperty("OutputLevel", msg().level())); - ATH_CHECK(m_MuonIntScaleSmearTool.retrieve()); - - // Create the high pT tool - m_MuonIntHighTSmearTool.setTypeAndName("CP::MuonCalibIntHighpTSmearTool/MCaST_highPtScaleSmear"); - ATH_CHECK(m_MuonIntHighTSmearTool.setProperty("release", m_release.value())); - ATH_CHECK(m_MuonIntHighTSmearTool.setProperty("OutputLevel", msg().level())); - ATH_CHECK(m_MuonIntHighTSmearTool.retrieve()); - + if (m_MuonIntScaleSmearTool.empty()) { + m_MuonIntScaleSmearTool.setTypeAndName("CP::MuonCalibIntScaleSmearTool/MCaST_ScaleSmear"); + ATH_CHECK(m_MuonIntScaleSmearTool.setProperty("release", m_release.value())); + ATH_CHECK(m_MuonIntScaleSmearTool.setProperty("systematicScheme", m_sysScheme.value())); + ATH_CHECK(m_MuonIntScaleSmearTool.setProperty("doDirectCBCalib", m_doDirectCBCalib.value())); + ATH_CHECK(m_MuonIntScaleSmearTool.setProperty("OutputLevel", msg().level())); + ATH_CHECK(m_MuonIntScaleSmearTool.retrieve()); + } + /// Create the high pT tool + if (m_extra_highpt_smearing || m_2stations_highpt_smearing) { + if (m_MuonIntHighTSmearTool.empty()) { + m_MuonIntHighTSmearTool.setTypeAndName("CP::MuonCalibIntHighpTSmearTool/MCaST_highPtScaleSmear"); + ATH_CHECK(m_MuonIntHighTSmearTool.setProperty("release", m_release.value())); + ATH_CHECK(m_MuonIntHighTSmearTool.setProperty("OutputLevel", msg().level())); + } + ATH_CHECK(m_MuonIntHighTSmearTool.retrieve()); + } if (!applySystematicVariation(SystematicSet())) { ATH_MSG_ERROR("Unable to run with no systematic"); @@ -251,8 +263,7 @@ namespace CP { SystematicSet result = m_MuonIntSagittaTool->affectingSystematics(); result.insert(m_MuonIntScaleSmearTool->affectingSystematics()); - result.insert(m_MuonIntHighTSmearTool->affectingSystematics()); - + if (!m_MuonIntHighTSmearTool.empty()) result.insert(m_MuonIntHighTSmearTool->affectingSystematics()); return result; } @@ -267,9 +278,10 @@ namespace CP code = m_MuonIntScaleSmearTool->applySystematicVariation(systConfig); if(code != StatusCode::SUCCESS) return code; - code = m_MuonIntHighTSmearTool->applySystematicVariation(systConfig); - if(code != StatusCode::SUCCESS) return code; - + if (!m_MuonIntHighTSmearTool.empty()){ + code = m_MuonIntHighTSmearTool->applySystematicVariation(systConfig); + if(code != StatusCode::SUCCESS) return code; + } return code; } @@ -498,15 +510,15 @@ namespace CP static const SG::AuxElement::Accessor<unsigned int> acc_rnd("RandomRunNumber"); // I've copied the run number ranges from SUSYTools // https://gitlab.cern.ch/atlas/athena/blob/21.2/PhysicsAnalysis/SUSYPhys/SUSYTools/Root/SUSYObjDef_xAOD.cxx#L2438 - static const unsigned int last_run_16 = 320000; - static const unsigned int last_run_17 = 342000; - static const unsigned int last_run_18 = 364485; - static const unsigned int last_run_22 = 999999; + constexpr unsigned int last_run_16 = 320000; + constexpr unsigned int last_run_17 = 342000; + constexpr unsigned int last_run_18 = 364485; + constexpr unsigned int last_run_22 = 999999; - static const std::vector<int> MCperiods1516{284500}; - static const std::vector<int> MCperiods17{300000, 304000, 305000}; - static const std::vector<int> MCperiods18{310000}; - static const std::vector<int> MCperiods22{330000, 410000}; + static const std::set<int> MCperiods1516{284500}; + static const std::set<int> MCperiods17{300000, 304000, 305000}; + static const std::set<int> MCperiods18{310000}; + static const std::set<int> MCperiods22{330000, 410000}; SG::ReadHandle<xAOD::EventInfo> evtInfo(m_eventInfo); @@ -524,18 +536,18 @@ namespace CP } // Check the Monte carlo if (!isData && (!m_useRndRun || !acc_rnd.isAvailable(*evtInfo))) { - if (std::find(MCperiods1516.begin(), MCperiods1516.end(), run) != MCperiods1516.end()) { + if (MCperiods1516.count(run)) { ATH_MSG_DEBUG("The current run " << run << " corresponds to data mc20a / data15-16"); return MCP::DataYear::Data16; - } else if (std::find(MCperiods17.begin(), MCperiods17.end(), run) != MCperiods17.end()) { + } else if (MCperiods17.count(run)) { ATH_MSG_DEBUG("The current run " << run << " corresponds to data mc20d / data17"); return MCP::DataYear::Data17; - } else if (std::find(MCperiods18.begin(), MCperiods18.end(), run) != MCperiods18.end()) { + } else if (MCperiods18.count(run)) { ATH_MSG_DEBUG("The current run " << run << " corresponds to data mc20e / data18"); return MCP::DataYear::Data18; - } else if (std::find(MCperiods22.begin(), MCperiods22.end(), run) != MCperiods22.end()) { + } else if (MCperiods22.count(run)) { ATH_MSG_DEBUG("The current run " << run << " corresponds to data mc21a / data22"); - return MCP::DataYear::Data18; + return MCP::DataYear::Data22; } } diff --git a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/python/MCastCfg.py b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/python/MCastCfg.py new file mode 100644 index 0000000000000000000000000000000000000000..e7079d239cec62ca0aa601a9cc78da2f95613e61 --- /dev/null +++ b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/python/MCastCfg.py @@ -0,0 +1,42 @@ +# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration + +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from AthenaConfiguration.ComponentFactory import CompFactory +from AthenaConfiguration.Enums import LHCPeriod +### Example of configuration of the Muon Momentum corrections tool +### https://gitlab.cern.ch/atlas/athena/-/blob/master/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/MuonMomentumCorrections/MuonCalibTool.h +### For the official MCP recommendations please consult https://twiki.cern.ch/twiki/bin/view/AtlasProtected/MCPAnalysisGuidelinesR22 +def setupMCastToolCfg(flags, name="MuonMomentumCorrections", **kwargs): + acc = ComponentAccumulator() + kwargs.setdefault("IsRun3Geo", flags.GeoModel.Run >= LHCPeriod.Run3 ) + from MuonSelectionTool.MuonSelectorToolsConfig import MuonSelectionToolCfg + kwargs.setdefault("MuonSelectionTool", acc.popToolsAndMerge(MuonSelectionToolCfg(flags, + MaxEta=2.7, + MuQuality=1))) + the_tool = CompFactory.CP.MuonCalibTool(name, **kwargs) + acc.setPrivateTools(the_tool) + return acc + +def setupCalibratedMuonProviderCfg(flags, name="CalibratedMuonProvider", **kwargs): + acc = ComponentAccumulator() + ### prw tool configuration + if "prwTool" in kwargs: + kwargs.setdefault( "useRndRunNumber", True) + useRndNumber = kwargs["useRndRunNumber"] if "useRndRunNumber" in kwargs else False + kwargs.setdefault("Tool", acc.popToolsAndMerge(setupMCastToolCfg(flags, + useRandomRunNumber=useRndNumber))) + + the_alg = CompFactory.CP.CalibratedMuonsProvider(name,**kwargs) + acc.addEventAlgo(the_alg, primary = True) + return acc +def setupCalibratedTracksProviderCfg(flags, name="CalibratedMuonTracksProvider", **kwargs): + acc = ComponentAccumulator() + if "prwTool" in kwargs: + kwargs.setdefault( "useRndRunNumber", True) + useRndNumber = kwargs["useRndRunNumber"] if "useRndRunNumber" in kwargs else False + kwargs.setdefault("Tool", acc.popToolsAndMerge(setupMCastToolCfg(flags, + useRandomRunNumber=useRndNumber))) + + the_alg = CompFactory.CP.CalibratedTracksProvider(name,**kwargs) + acc.addEventAlgo(the_alg, primary = True) + return acc \ No newline at end of file diff --git a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/share/CalibrationExample_jobOptions.py b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/share/CalibrationExample_jobOptions.py deleted file mode 100644 index 8731f9f8d141aee79051a28baa34a285e05483e0..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/share/CalibrationExample_jobOptions.py +++ /dev/null @@ -1,16 +0,0 @@ -# Set up the file reading: -FNAME = "/afs/cern.ch/atlas/project/PAT/xAODs/r5591/mc14_8TeV.117050.PowhegPythia_P2011C_ttbar.recon.AOD.e1727_s1933_s1911_r5591/AOD.01494882._111853.pool.root.1" -import AthenaPoolCnvSvc.ReadAthenaPool -ServiceMgr.EventSelector.InputCollections = [ FNAME ] - -algseq = CfgMgr.AthSequencer("AthAlgSeq") - -# Add the MCP tool - -#THIS IS THE EXAMPLE: -ToolSvc += CfgMgr.CP__MuonCalibrationAndSmearingTool("MCPTool") -algseq += CfgMgr.CP__CalibratedMuonsProvider(Input="Muons",Output="CalibratedMuons",Tool=ToolSvc.MCPTool,OutputLevel=VERBOSE) -#END OF EXAMPLE - -theApp.EvtMax = 5 - diff --git a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/share/MCAST_jobOptions.py b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/share/MCAST_jobOptions.py deleted file mode 100644 index 9516b4827e07012332bbeceb8a6ceb47489dd654..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/share/MCAST_jobOptions.py +++ /dev/null @@ -1,27 +0,0 @@ -path = '/data/atlas/atlasdata/artoni/mcp/tests/mc16_13TeV.301026.PowhegPythia8EvtGen_AZNLOCTEQ6L1_DYmumu_1000M1250.deriv.DAOD_EXOT0.e3649_s3126_r9364_p3654' -files = [os.path.join(path, f) for f in os.listdir(path)] - -import AthenaPoolCnvSvc.ReadAthenaPool -ServiceMgr.EventSelector.InputCollections = files - -# Access the algorithm sequence: -from AthenaCommon.AlgSequence import AlgSequence -theJob = AlgSequence() - -# Add the test algorithm: -from MuonMomentumCorrections.MuonMomentumCorrectionsConf import CP__TestMCASTTool -alg = CP__TestMCASTTool() -#alg.MuonCalibrationAndSmearingTool.FilesPath = '/home/artoni/MuonCombinedPerformance/atlas-mcp/MaintainMuonMomentumCorrections/run/temporary_config_files/' -#alg.MuonCalibrationAndSmearingTool.Release = 'Recs2019_05_30' -alg.MuonCalibrationAndSmearingTool.OutputLevel = INFO -alg.MuonCalibrationAndSmearingTool.AddExtraDecorations = True -alg.MuonCalibrationAndSmearingTool.doExtraSmearing = True -alg.MuonCalibrationAndSmearingTool.do2StationsHighPt = False -alg.OutputLevel = INFO -theJob += alg - -# Do some additional tweaking: -from AthenaCommon.AppMgr import theApp -theApp.EvtMax = -1 -ServiceMgr.MessageSvc.OutputLevel = INFO -ServiceMgr.MessageSvc.defaultLimit = 1000000 diff --git a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/share/Setup1_jobOptions.py b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/share/Setup1_jobOptions.py deleted file mode 100644 index 05722669294094fbbe399dc3ba1ec00974d97715..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/share/Setup1_jobOptions.py +++ /dev/null @@ -1,32 +0,0 @@ -path = '/data/atlassmallfiles/users/artoni/mcp/mc16_13TeV.301030.PowhegPythia8EvtGen_AZNLOCTEQ6L1_DYmumu_2000M2250.deriv.DAOD_MUON1.e3649_s3126_r10751_p4062' -files = [os.path.join(path, f) for f in os.listdir(path)] - -import AthenaPoolCnvSvc.ReadAthenaPool -ServiceMgr.EventSelector.InputCollections = files - -# Access the algorithm sequence: -from AthenaCommon.AlgSequence import AlgSequence -theJob = AlgSequence() - -# Add the test algorithm: -from MuonMomentumCorrections.MuonMomentumCorrectionsConf import CP__TestMCASTTool -alg = CP__TestMCASTTool() -alg.MuonCalibrationAndSmearingTool.OutputLevel = VERBOSE -alg.MuonCalibrationAndSmearingTool.AddExtraDecorations = True -alg.MuonCalibrationAndSmearingTool.doExtraSmearing = False -alg.MuonCalibrationAndSmearingTool.do2StationsHighPt = False -alg.MuonCalibrationAndSmearingTool.SagittaRelease = 'sagittaBiasDataAll_03_02_19_Data17' -alg.MuonCalibrationAndSmearingTool.Year = 'Data17' -alg.MuonCalibrationAndSmearingTool.StatComb = False -alg.MuonCalibrationAndSmearingTool.SagittaCorr = True -alg.MuonCalibrationAndSmearingTool.doSagittaMCDistortion = False -alg.MuonCalibrationAndSmearingTool.SagittaCorrPhaseSpace = True -alg.Output = 'Output_Setup1.root' -alg.OutputLevel = INFO -theJob += alg - -# Do some additional tweaking: -from AthenaCommon.AppMgr import theApp -theApp.EvtMax = 10 -ServiceMgr.MessageSvc.OutputLevel = INFO -ServiceMgr.MessageSvc.defaultLimit = 1000000 diff --git a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/share/Setup2_jobOptions.py b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/share/Setup2_jobOptions.py deleted file mode 100644 index eb095578c061c15665e39b0c0a9a56973cc3c57d..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/share/Setup2_jobOptions.py +++ /dev/null @@ -1,32 +0,0 @@ -path = '/data/atlassmallfiles/users/artoni/mcp/mc16_13TeV.361107.PowhegPythia8EvtGen_AZNLOCTEQ6L1_Zmumu.deriv.DAOD_MUON6.e3601_s3126_r10201_p4029' -files = [os.path.join(path, f) for f in os.listdir(path)] - -import AthenaPoolCnvSvc.ReadAthenaPool -ServiceMgr.EventSelector.InputCollections = files - -# Access the algorithm sequence: -from AthenaCommon.AlgSequence import AlgSequence -theJob = AlgSequence() - -# Add the test algorithm: -from MuonMomentumCorrections.MuonMomentumCorrectionsConf import CP__TestMCASTTool -alg = CP__TestMCASTTool() -alg.MuonCalibrationAndSmearingTool.OutputLevel = INFO -alg.MuonCalibrationAndSmearingTool.AddExtraDecorations = True -alg.MuonCalibrationAndSmearingTool.doExtraSmearing = False -alg.MuonCalibrationAndSmearingTool.do2StationsHighPt = False -alg.MuonCalibrationAndSmearingTool.SagittaRelease = 'sagittaBiasDataAll_03_02_19_Data17' -alg.MuonCalibrationAndSmearingTool.Year = 'Data17' -alg.MuonCalibrationAndSmearingTool.StatComb = False -alg.MuonCalibrationAndSmearingTool.SagittaCorr = False -alg.MuonCalibrationAndSmearingTool.doSagittaMCDistortion = True -alg.MuonCalibrationAndSmearingTool.SagittaCorrPhaseSpace = False -alg.OutputLevel = INFO -alg.Output = 'Output_Setup2.root' -theJob += alg - -# Do some additional tweaking: -from AthenaCommon.AppMgr import theApp -theApp.EvtMax = 10 -ServiceMgr.MessageSvc.OutputLevel = INFO -ServiceMgr.MessageSvc.defaultLimit = 1000000 diff --git a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/src/CalibratedMuonsProvider.cxx b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/src/CalibratedMuonsProvider.cxx index 262fbf8987462924840891157e1261fba440ab3f..415f280b50360d751e4e84aea1567177793e929b 100644 --- a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/src/CalibratedMuonsProvider.cxx +++ b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/src/CalibratedMuonsProvider.cxx @@ -16,6 +16,11 @@ namespace CP { ATH_CHECK(m_eventInfo.initialize()); ATH_CHECK(m_inputKey.initialize()); ATH_CHECK(m_outputKey.initialize()); + /// + m_ptDecorKeys.emplace_back(m_outputKey.key() + ".InnerDetectorPt"); + m_ptDecorKeys.emplace_back(m_outputKey.key() + ".MuonSpectrometerPt"); + ATH_CHECK(m_ptDecorKeys.initialize()); + ATH_CHECK(m_tool.retrieve()); if (!m_prwTool.empty()) { m_useRndNumber = true; @@ -63,7 +68,7 @@ namespace CP { ATH_MSG_DEBUG(" New pt=" << iParticle->pt()); } SG::WriteHandle<xAOD::MuonContainer> writeHandle{m_outputKey, ctx}; - ATH_CHECK(writeHandle.record(std::move(output.first), std::move(output.second))); + ATH_CHECK(writeHandle.recordNonConst(std::move(output.first), std::move(output.second))); // Return gracefully: return StatusCode::SUCCESS; } diff --git a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/src/CalibratedMuonsProvider.h b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/src/CalibratedMuonsProvider.h index 1044a5a9377fda3c0fe7a7a9a84e9f70d5eafb79..5c40df5283ac4e5425fc6bc40517cf3850e63ed1 100644 --- a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/src/CalibratedMuonsProvider.h +++ b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/src/CalibratedMuonsProvider.h @@ -12,6 +12,7 @@ #include "MuonAnalysisInterfaces/IMuonCalibrationAndSmearingTool.h" #include "StoreGate/ReadHandleKey.h" #include "StoreGate/WriteHandleKey.h" +#include "StoreGate/WriteDecorHandleKeyArray.h" #include "xAODEventInfo/EventInfo.h" #include "xAODMuon/MuonContainer.h" @@ -35,6 +36,8 @@ namespace CP { SG::ReadHandleKey<xAOD::MuonContainer> m_inputKey{this, "Input", "Muons", " Name of the muon container to calibrate"}; SG::WriteHandleKey<xAOD::MuonContainer> m_outputKey{this, "Output", "CalibratedMuons", "Name of the final container written to storegate"}; + /// Additionally declare the two decorations made by MCAST + SG::WriteDecorHandleKeyArray<xAOD::MuonContainer> m_ptDecorKeys{this, "DecorationKeys", {}}; /// Muon calibration tool ToolHandle<IMuonCalibrationAndSmearingTool> m_tool{this, "Tool", ""}; diff --git a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/src/CalibratedTracksProvider.cxx b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/src/CalibratedTracksProvider.cxx index 961e84ec17e7f5c39789b7174648ab8f152be444..1811b837f7783ac41a35a58788889eb0ba5dba04 100644 --- a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/src/CalibratedTracksProvider.cxx +++ b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/src/CalibratedTracksProvider.cxx @@ -64,7 +64,7 @@ namespace CP { ATH_MSG_VERBOSE("New pt=" << iParticle->pt()); } SG::WriteHandle<xAOD::TrackParticleContainer> writeHandle{m_outputKey, ctx}; - ATH_CHECK(writeHandle.record(std::move(output.first), std::move(output.second))); + ATH_CHECK(writeHandle.recordNonConst(std::move(output.first), std::move(output.second))); // Return gracefully: return StatusCode::SUCCESS;