From 10bcdabffeb54f1508ce2d319ac46f941abd28d7 Mon Sep 17 00:00:00 2001 From: Makayla Vessella <makayla.vessella@cern.ch> Date: Fri, 14 Mar 2025 00:02:08 +0100 Subject: [PATCH 1/6] add mc23 tracking fake rate+eff and prevent misconfigured instances of truthtrackfiltertool --- .../InDetTrackTruthFilterTool.h | 4 +-- .../Root/InDetTrackTruthFilterTool.cxx | 26 +++++++++++++++++-- .../InDetTrackSystematicsToolsConfig.py | 14 ++++++++++ 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/InDetTrackTruthFilterTool.h b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/InDetTrackTruthFilterTool.h index 7a39ef623efe..ba59306ddae3 100644 --- a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/InDetTrackTruthFilterTool.h +++ b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/InDetTrackTruthFilterTool.h @@ -81,8 +81,8 @@ namespace InDet { float m_fPrim = 1.; float m_fSec = 1.; - float m_fFakeLoose = 0.10; - float m_fFakeTight = 1.00; // this method breaks down for uncertainties > 1.00 (as was present in previous iterations) + float m_fFakeLoose = -1.0; //default values that will not allow tool to continue if not configured properly + float m_fFakeTight = -1.0; float m_fPU = 1.; float m_fFrag = 1.; float m_fFromC = 1.; diff --git a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/Root/InDetTrackTruthFilterTool.cxx b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/Root/InDetTrackTruthFilterTool.cxx index fce30013cabc..1dfd74a3eaca 100644 --- a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/Root/InDetTrackTruthFilterTool.cxx +++ b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/Root/InDetTrackTruthFilterTool.cxx @@ -64,14 +64,36 @@ namespace InDet { declareProperty("trkEffSystScale", m_trkEffSystScale); declareProperty("doLRTSystematics", m_doLRTSystematics); - declareProperty("calibFileNomEff", m_calibFileNomEff = "InDetTrackSystematicsTools/CalibData_22.0_2022-v00/TrackingRecommendations_prelim_rel22.root"); - declareProperty("calibFileLRTEff", m_calibFileLRTEff = "InDetTrackSystematicsTools/CalibData_22.0_2022-v00/TrackingRecommendations_prelim_rel22.root"); + declareProperty("calibFileNomEff", m_calibFileNomEff); + declareProperty("calibFileLRTEff", m_calibFileLRTEff); } StatusCode InDetTrackTruthFilterTool::initialize() { m_rnd = std::make_unique<TRandom3>(m_seed); + bool anyEffSystActive = isActive(TRK_EFF_LOOSE_GLOBAL) || isActive(TRK_EFF_LOOSE_IBL) || isActive(TRK_EFF_LOOSE_PP0) || + isActive(TRK_EFF_LOOSE_PHYSMODEL) || isActive(TRK_EFF_TIGHT_GLOBAL) || isActive(TRK_EFF_TIGHT_IBL) || + isActive(TRK_EFF_TIGHT_PP0) || isActive(TRK_EFF_TIGHT_PHYSMODEL) || + (m_doLRTSystematics && (isActive(TRK_EFF_LARGED0_GLOBAL) || isActive(TRK_EFF_LARGED0_IBL) || + isActive(TRK_EFF_LARGED0_PP0) || isActive(TRK_EFF_LARGED0_PHYSMODEL))); + + bool anyFakeRateActive = isActive(TRK_FAKE_RATE_LOOSE) || isActive(TRK_FAKE_RATE_TIGHT); + + if (anyEffSystActive) { + if (m_calibFileNomEff.empty() || (m_doLRTSystematics && m_calibFileLRTEff.empty())) { + ATH_MSG_ERROR("No calibration file for requested track efficiency set. You may be running an unsupported datataking period, please contact Tracking CP if you believe this message is in error."); + return StatusCode::FAILURE; + } + } + + if (anyFakeRateActive) { + if (m_fFakeLoose == -1.0 && m_fFakeTight == -1.0) { + ATH_MSG_ERROR("Requested fake rate is unavailable. You may be running an unsupported datataking period, please contact Tracking CP if you believe this message is in error."); + return StatusCode::FAILURE; + } + } + ATH_CHECK ( initTrkEffSystHistogram( m_trkEffSystScale, m_trkEffHistLooseGlobal, m_calibFileNomEff, diff --git a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/python/InDetTrackSystematicsToolsConfig.py b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/python/InDetTrackSystematicsToolsConfig.py index 37854067a34f..c16569056333 100644 --- a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/python/InDetTrackSystematicsToolsConfig.py +++ b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/python/InDetTrackSystematicsToolsConfig.py @@ -21,6 +21,20 @@ def InDetTrackTruthFilterToolCfg(flags, name="InDetTrackTruthFilterTool", **kwar if "trackOriginTool" not in kwargs: kwargs.setdefault("trackOriginTool", acc.popToolsAndMerge( InDetTrackTruthOriginToolCfg(flags))) + + from AthenaConfiguration.Enums import LHCPeriod + # Run 3 recommendations (MC23) + if flags.GeoModel.Run == LHCPeriod.Run3: + kwargs.setdefault("calibFileNomEff", "InDetTrackSystematicsTools/CalibData_22.0_2022-v00/TrackingRecommendations_prelim_rel22.root") + kwargs.setdefault("calibFileLRTEff", "InDetTrackSystematicsTools/CalibData_22.0_2022-v00/TrackingRecommendations_prelim_rel22.root") + kwargs.setdefault("fFakeLoose", 0.40) + kwargs.setdefault("fFakeTight", 1.00) + # Run 2 recommendations (MC20) + elif flags.GeoModel.Run == LHCPeriod.Run2: + kwargs.setdefault("calibFileNomEff", "InDetTrackSystematicsTools/CalibData_22.0_2020-v00/TrackingRecommendations_prelim_rel22.root") + kwargs.setdefault("calibFileLRTEff", "InDetTrackSystematicsTools/CalibData_22.0_2020-v00/TrackingRecommendations_prelim_rel22.root") + kwargs.setdefault("fFakeLoose", 0.10) + kwargs.setdefault("fFakeTight", 1.00) acc.setPrivateTools( CompFactory.InDet.InDetTrackTruthFilterTool(name, **kwargs)) -- GitLab From c6f71b5b9a3ccb69f1c14652a050fab606362951 Mon Sep 17 00:00:00 2001 From: Makayla Vessella <makayla.vessella@cern.ch> Date: Fri, 14 Mar 2025 18:15:08 +0100 Subject: [PATCH 2/6] only configure mc23a --- .../python/InDetTrackSystematicsToolsConfig.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/python/InDetTrackSystematicsToolsConfig.py b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/python/InDetTrackSystematicsToolsConfig.py index c16569056333..cb8161008864 100644 --- a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/python/InDetTrackSystematicsToolsConfig.py +++ b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/python/InDetTrackSystematicsToolsConfig.py @@ -2,6 +2,7 @@ # Configuration of InDetTrackSystematicsTools package from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator from AthenaConfiguration.ComponentFactory import CompFactory +from Campaigns.Utils import Campaign def InDetTrackTruthOriginToolCfg(flags, name="InDetTrackTruthOriginTool", **kwargs): acc = ComponentAccumulator() @@ -23,12 +24,13 @@ def InDetTrackTruthFilterToolCfg(flags, name="InDetTrackTruthFilterTool", **kwar InDetTrackTruthOriginToolCfg(flags))) from AthenaConfiguration.Enums import LHCPeriod - # Run 3 recommendations (MC23) + # 2022 recommendations (MC23a) if flags.GeoModel.Run == LHCPeriod.Run3: - kwargs.setdefault("calibFileNomEff", "InDetTrackSystematicsTools/CalibData_22.0_2022-v00/TrackingRecommendations_prelim_rel22.root") - kwargs.setdefault("calibFileLRTEff", "InDetTrackSystematicsTools/CalibData_22.0_2022-v00/TrackingRecommendations_prelim_rel22.root") - kwargs.setdefault("fFakeLoose", 0.40) - kwargs.setdefault("fFakeTight", 1.00) + if flags.Input.MCCampaign == Campaign.MC23a: + kwargs.setdefault("calibFileNomEff", "InDetTrackSystematicsTools/CalibData_22.0_2022-v00/TrackingRecommendations_prelim_rel22.root") + kwargs.setdefault("calibFileLRTEff", "InDetTrackSystematicsTools/CalibData_22.0_2022-v00/TrackingRecommendations_prelim_rel22.root") + kwargs.setdefault("fFakeLoose", 0.40) + kwargs.setdefault("fFakeTight", 1.00) # Run 2 recommendations (MC20) elif flags.GeoModel.Run == LHCPeriod.Run2: kwargs.setdefault("calibFileNomEff", "InDetTrackSystematicsTools/CalibData_22.0_2020-v00/TrackingRecommendations_prelim_rel22.root") -- GitLab From 707fc76e80b5c5bee096b258b2b22db31d7a6d74 Mon Sep 17 00:00:00 2001 From: Makayla Vessella <makayla.vessella@cern.ch> Date: Thu, 20 Mar 2025 19:21:18 +0100 Subject: [PATCH 3/6] update LRT rec path and remove outdated content from tracking systematic tools --- .../IInDetTrackTruthFilterTool.h | 6 +- .../InDetTrackSystematics.h | 16 +- .../InDetTrackTruthFilterTool.h | 15 +- .../InclusiveTrackFilterTool.h | 4 +- .../Root/InDetTrackTruthFilterTool.cxx | 188 ++---------------- .../Root/InclusiveTrackFilterTool.cxx | 6 +- .../InDetTrackSystematicsToolsConfig.py | 16 +- 7 files changed, 48 insertions(+), 203 deletions(-) diff --git a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/IInDetTrackTruthFilterTool.h b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/IInDetTrackTruthFilterTool.h index c64c78e1a758..80699eaa7450 100644 --- a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/IInDetTrackTruthFilterTool.h +++ b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/IInDetTrackTruthFilterTool.h @@ -31,13 +31,9 @@ namespace InDet { virtual StatusCode initialize() = 0; virtual void prepare() = 0; // not sure if/why this function is necessary - felix - // "standard" accept method - if appropriate systematic is activated, will call mu-dependent version (below) using mu value from EventInfo, otherwise will use truth info + // standard accept method to determine if a track should be kept or not virtual bool accept(const xAOD::TrackParticle* track) const = 0; - // This is a version of the accept method that takes a value of mu (i.e. mean interactions per crossing) in order to calculate a probability that a givent track at that mu is a fake, - // and so should be considered for being dropped for the fake systematic variation - this version does not rely on truth information - virtual bool accept(const xAOD::TrackParticle* track, float mu) const = 0; - // implement the CP::ISystematicTool interface /// returns: whether the tool is affected by the systematic diff --git a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/InDetTrackSystematics.h b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/InDetTrackSystematics.h index dcaaf3918387..c84e8dd28ee1 100644 --- a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/InDetTrackSystematics.h +++ b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/InDetTrackSystematics.h @@ -25,7 +25,7 @@ namespace InDet { TRK_BIAS_D0_WM, TRK_BIAS_Z0_WM, TRK_BIAS_QOVERP_SAGITTA_WM, - // a (currently 30%) uncertainty in the fake rate - this needs to be updated for Loose vs. TightPrimary + // uncertainties in the fake rate for Loose and TightPrimary TRK_FAKE_RATE_LOOSE, TRK_FAKE_RATE_TIGHT, // uncertainties in the efficiency for two cut levels, "Loose" and "TightPrimary" @@ -39,15 +39,15 @@ namespace InDet { TRK_EFF_TIGHT_PP0, TRK_EFF_TIGHT_PHYSMODEL, TRK_EFF_LARGED0_GLOBAL, - TRK_EFF_LARGED0_IBL, - TRK_EFF_LARGED0_PP0, - TRK_EFF_LARGED0_PHYSMODEL, // uncertainty for tracking efficiency in jets TRK_EFF_LOOSE_TIDE, // uncertainties for tracking fake rates in jets TRK_FAKE_RATE_TIGHT_TIDE, TRK_FAKE_RATE_LOOSE_TIDE, - TRK_FAKE_RATE_LOOSE_ROBUST + // combined efficiency systematics for use in downstream objects such as secondary vertexing ONLY + // this is not an additional systematic, but rather a replacement for the standard efficiencies in objects where four variations are prohibitive + TRK_EFF_LOOSE_COMBINED, + TRK_EFF_TIGHT_COMBINED, }; // without getting too crafty with macros, this map needs to be maintained with the enum above @@ -78,12 +78,10 @@ namespace InDet { DEF_SYST( EFF_TIGHT_PHYSMODEL ), DEF_SYST( EFF_LOOSE_TIDE ), DEF_SYST( EFF_LARGED0_GLOBAL ), - DEF_SYST( EFF_LARGED0_IBL ), - DEF_SYST( EFF_LARGED0_PP0 ), - DEF_SYST( EFF_LARGED0_PHYSMODEL ), DEF_SYST( FAKE_RATE_TIGHT_TIDE ), DEF_SYST( FAKE_RATE_LOOSE_TIDE ), - DEF_SYST( FAKE_RATE_LOOSE_ROBUST ) + DEF_SYST( EFF_LOOSE_COMBINED ), + DEF_SYST( EFF_TIGHT_COMBINED ), #undef DEF_SYST }; diff --git a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/InDetTrackTruthFilterTool.h b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/InDetTrackTruthFilterTool.h index ba59306ddae3..c8c8a8d700da 100644 --- a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/InDetTrackTruthFilterTool.h +++ b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/InDetTrackTruthFilterTool.h @@ -50,13 +50,9 @@ namespace InDet { // right now this returns a bool; if we want to implement the ASG selection tool interface then this will need to change to a TAccept - // "standard" accept method - if appropriate systematic is activated, will call mu-dependent version (below) using mu value from EventInfo, otherwise will use truth info + // accept method to determine if a track should be kept or not virtual bool accept(const xAOD::TrackParticle* track) const override; - // This is a version of the accept method that takes a value of mu (i.e. mean interactions per crossing) in order to calculate a probability that a givent track at that mu is a fake, - // and so should be considered for being dropped for the fake systematic variation - this version does not rely on truth information - virtual bool accept(const xAOD::TrackParticle* track, float mu) const override; - /// returns: whether the tool is affected by the systematic virtual bool isAffectedBySystematic( const CP::SystematicVariation& ) const override; /// returns: list of systematics this tool can be affected by @@ -73,8 +69,6 @@ namespace InDet { StatusCode initTrkEffSystHistogram(float scale, TH2 *&histogram, std::string rootFileName, std::string histogramName) const; float getFractionDropped(float fDefault, const TH2 *histogram, float x, float y, bool xAxisIspT = true) const; - float pseudoFakeProbability(const xAOD::TrackParticle* track, float mu) const; - bool dropPseudoFake(float prob) const; int m_seed = 0; std::unique_ptr<TRandom3> m_rnd; //! @@ -88,11 +82,9 @@ namespace InDet { float m_fFromC = 1.; float m_fFromB = 1.; float m_trkEffSystScale = 1.; - bool m_doLRTSystematics = false; TH2 *m_fPrimHistogram = nullptr; TH2 *m_fSecHistogram = nullptr; - //TH2 *m_fFakeHistogram = nullptr; TH2 *m_fPUHistogram = nullptr; TH2 *m_fFragHistogram = nullptr; TH2 *m_fFromCHistogram = nullptr; @@ -107,16 +99,11 @@ namespace InDet { TH2* m_trkEffHistTightIBL = nullptr; TH2* m_trkEffHistTightPP0 = nullptr; TH2* m_trkEffHistTightPhysModel = nullptr; - TH2* m_trkEffHistLRTGlobal = nullptr; - TH2* m_trkEffHistLRTIBL = nullptr; - TH2* m_trkEffHistLRTPP0 = nullptr; - TH2* m_trkEffHistLRTPhysModel = nullptr; std::unordered_map<std::string, TH2*> m_histMap; // allow the user to configure which calibration files to use if desired std::string m_calibFileNomEff; - std::string m_calibFileLRTEff; ToolHandle< IInDetTrackTruthOriginTool > m_trackOriginTool; diff --git a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/InclusiveTrackFilterTool.h b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/InclusiveTrackFilterTool.h index b25974cbf32c..e0c80183806d 100644 --- a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/InclusiveTrackFilterTool.h +++ b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/InclusiveTrackFilterTool.h @@ -71,10 +71,10 @@ namespace InDet { Gaudi::Property<float> m_trkEffSystScale{this, "trkEffSystScale", 1.0, "Option to scale the effect of the systematic (default 1)"}; // Property: path to the root file containing the LRT efficiency histogram (note: uses PathResolver) - Gaudi::Property<std::string> m_calibFileLRTEff{this, "calibFileLRTEff", "InDetTrackSystematicsTools/CalibData_24.0_2023-v00/LargeD0TrackingRecommendations_20230824.root", "File containing the efficiency histogram (expert only)"}; + Gaudi::Property<std::string> m_calibFileLRTEff; // Property: name of the efficiency histogram in m_calibFileLRTEff - Gaudi::Property<std::string> m_calibHistLRTEff{this, "calibHistLRTEff", "OneMinusRatioEfficiencyVSRadiusOfFirstHitEta_Nominal", "Name of the efficiency histogram (expert only)"}; + Gaudi::Property<std::string> m_calibHistLRTEff; std::unique_ptr<TRandom3> m_rnd = nullptr; //! diff --git a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/Root/InDetTrackTruthFilterTool.cxx b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/Root/InDetTrackTruthFilterTool.cxx index 1dfd74a3eaca..32b0d67bd1d1 100644 --- a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/Root/InDetTrackTruthFilterTool.cxx +++ b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/Root/InDetTrackTruthFilterTool.cxx @@ -33,11 +33,8 @@ namespace InDet { InDet::TrackSystematicMap.at(TRK_EFF_TIGHT_IBL), InDet::TrackSystematicMap.at(TRK_EFF_TIGHT_PP0), InDet::TrackSystematicMap.at(TRK_EFF_TIGHT_PHYSMODEL), - InDet::TrackSystematicMap.at(TRK_FAKE_RATE_LOOSE_ROBUST), - InDet::TrackSystematicMap.at(TRK_EFF_LARGED0_GLOBAL), - InDet::TrackSystematicMap.at(TRK_EFF_LARGED0_IBL), - InDet::TrackSystematicMap.at(TRK_EFF_LARGED0_PP0), - InDet::TrackSystematicMap.at(TRK_EFF_LARGED0_PHYSMODEL), + InDet::TrackSystematicMap.at(TRK_EFF_LOOSE_COMBINED), //combined systematics are to be used in downstream objects such as secondary vertexing ONLY + InDet::TrackSystematicMap.at(TRK_EFF_TIGHT_COMBINED), //they are not an "additional" systematic, but rather a replacement for the standard efficiencies where four variations are prohibitive }; InDetTrackTruthFilterTool::InDetTrackTruthFilterTool(const std::string& name) : @@ -62,10 +59,7 @@ namespace InDet { declareProperty("fFromC", m_fFromC); declareProperty("fFromB", m_fFromB); declareProperty("trkEffSystScale", m_trkEffSystScale); - declareProperty("doLRTSystematics", m_doLRTSystematics); - declareProperty("calibFileNomEff", m_calibFileNomEff); - declareProperty("calibFileLRTEff", m_calibFileLRTEff); } StatusCode InDetTrackTruthFilterTool::initialize() { @@ -74,14 +68,12 @@ namespace InDet { bool anyEffSystActive = isActive(TRK_EFF_LOOSE_GLOBAL) || isActive(TRK_EFF_LOOSE_IBL) || isActive(TRK_EFF_LOOSE_PP0) || isActive(TRK_EFF_LOOSE_PHYSMODEL) || isActive(TRK_EFF_TIGHT_GLOBAL) || isActive(TRK_EFF_TIGHT_IBL) || - isActive(TRK_EFF_TIGHT_PP0) || isActive(TRK_EFF_TIGHT_PHYSMODEL) || - (m_doLRTSystematics && (isActive(TRK_EFF_LARGED0_GLOBAL) || isActive(TRK_EFF_LARGED0_IBL) || - isActive(TRK_EFF_LARGED0_PP0) || isActive(TRK_EFF_LARGED0_PHYSMODEL))); + isActive(TRK_EFF_TIGHT_PP0) || isActive(TRK_EFF_TIGHT_PHYSMODEL ) || isActive(TRK_EFF_LOOSE_COMBINED) || isActive(TRK_EFF_TIGHT_COMBINED); bool anyFakeRateActive = isActive(TRK_FAKE_RATE_LOOSE) || isActive(TRK_FAKE_RATE_TIGHT); if (anyEffSystActive) { - if (m_calibFileNomEff.empty() || (m_doLRTSystematics && m_calibFileLRTEff.empty())) { + if (m_calibFileNomEff.empty()) { ATH_MSG_ERROR("No calibration file for requested track efficiency set. You may be running an unsupported datataking period, please contact Tracking CP if you believe this message is in error."); return StatusCode::FAILURE; } @@ -129,26 +121,6 @@ namespace InDet { ATH_MSG_INFO( "Using for nominal track efficiency the calibration file " << PathResolverFindCalibFile(m_calibFileNomEff) ); - if(m_doLRTSystematics) { - ATH_CHECK ( initTrkEffSystHistogram( m_trkEffSystScale, - m_trkEffHistLRTGlobal, - m_calibFileLRTEff, - "OneMinusRatioEfficiencyVSEtaProdR_AfterRebinning_NominalVSp5Overall_LRT") ); - ATH_CHECK ( initTrkEffSystHistogram( m_trkEffSystScale, - m_trkEffHistLRTIBL, - m_calibFileLRTEff, - "OneMinusRatioEfficiencyVSEtaProdR_AfterRebinning_NominalVSp10IBL_LRT") ); - ATH_CHECK ( initTrkEffSystHistogram( m_trkEffSystScale, - m_trkEffHistLRTPP0, - m_calibFileLRTEff, - "OneMinusRatioEfficiencyVSEtaProdR_AfterRebinning_NominalVSp25PP0_LRT") ); - ATH_CHECK ( initTrkEffSystHistogram( m_trkEffSystScale, - m_trkEffHistLRTPhysModel, - m_calibFileLRTEff, - "OneMinusRatioEfficiencyVSEtaProdR_AfterRebinning_NominalVSQGSP_LRT") ); - ATH_MSG_INFO( "Using for LRT track efficiency the calibration file " << PathResolverFindCalibFile(m_calibFileLRTEff) ); - } - m_histMap = { {"TRK_EFF_LOOSE_GLOBAL", m_trkEffHistLooseGlobal}, {"TRK_EFF_LOOSE_IBL", m_trkEffHistLooseIBL}, @@ -172,7 +144,6 @@ namespace InDet { delete m_fPrimHistogram; delete m_fSecHistogram; - //delete m_fFakeHistogram; delete m_fPUHistogram; delete m_fFragHistogram; delete m_fFromCHistogram; @@ -185,16 +156,9 @@ namespace InDet { delete m_trkEffHistTightIBL; delete m_trkEffHistTightPP0; delete m_trkEffHistTightPhysModel; - if(m_doLRTSystematics) { - delete m_trkEffHistLRTGlobal; - delete m_trkEffHistLRTIBL; - delete m_trkEffHistLRTPP0; - delete m_trkEffHistLRTPhysModel; - } m_fPrimHistogram = nullptr; m_fSecHistogram = nullptr; - // m_fFakeHistogram = nullptr; m_fPUHistogram = nullptr; m_fFragHistogram = nullptr; m_fFromCHistogram = nullptr; @@ -207,28 +171,6 @@ namespace InDet { m_trkEffHistTightIBL = nullptr; m_trkEffHistTightPP0 = nullptr; m_trkEffHistTightPhysModel = nullptr; - m_trkEffHistLRTGlobal = nullptr; - m_trkEffHistLRTIBL = nullptr; - m_trkEffHistLRTPP0 = nullptr; - m_trkEffHistLRTPhysModel = nullptr; - } - - bool InDetTrackTruthFilterTool::accept(const xAOD::TrackParticle* track, float mu) const { - - // this is only really useful if you are using the "robust" systematic version, otherwise the mu set can't do anything - if(isActive( TRK_FAKE_RATE_LOOSE_ROBUST )){ - - // calcuate probability for this to be a fake, and then roll random numbers to decide if it is one, and if it should not be accepted - float fakeProb = pseudoFakeProbability(track,mu); - if(dropPseudoFake(fakeProb)) return false; - - // otherwise, pass the track - return true; - - } else { - ATH_MSG_ERROR("User-specified mu value cannot be applied due to using wrong systematic version - select TRK_FAKE_RATE_LOOSE_ROBUST is you want to use this"); - return true; // if you're not using the robust version, do nothing - } } bool InDetTrackTruthFilterTool::accept(const xAOD::TrackParticle* track) const { @@ -236,19 +178,6 @@ namespace InDet { float pt = track->pt(); float eta = track->eta(); - // Do robust version without using truth first if selected, as this is relatively decoupled from the rest - if(isActive( TRK_FAKE_RATE_LOOSE_ROBUST )) { - const xAOD::EventInfo* ei = 0; - float mu = 20; // sensible mu default - if ( ! evtStore()->retrieve( ei , "EventInfo" ).isSuccess() ) { // this will check data vs. MC and run number. - throw std::runtime_error("Error in InDetTrackTruthFilterTool::accept - failed to retrieve EventInfo."); - } - mu = ei->averageInteractionsPerCrossing(); - - if (not accept(track,mu)) return false; - } - // now, back to using truth... - int origin = m_trackOriginTool->getTrackOrigin(track); // we unimplemented histograms for these, so only flat defaults will be used. @@ -272,7 +201,7 @@ namespace InDet { throw std::runtime_error( "Both Loose and TightPrimary versions of fake rate systematic are set." ); } if ( isActiveLoose ) { - //float fFake = getFractionDropped(m_fFake, m_fFakeHistogram, pt, eta); // there is no fake-rate histogram - just a flat uncertainty + // there is no fake-rate histogram - just a flat uncertainty if(m_rnd->Uniform(0, 1) < m_fFakeLoose) return false; } if ( isActiveTight ) { @@ -313,44 +242,21 @@ namespace InDet { float fTrkEffSyst = getFractionDropped(1, m_trkEffHistTightPhysModel, pt, eta); if(m_rnd->Uniform(0, 1) < fTrkEffSyst) return false; } - } - if(m_doLRTSystematics) { - static const SG::ConstAccessor<ElementLink< xAOD::TruthParticleContainer > > - truthParticleLinkAcc ("truthParticleLink"); - const ElementLink< xAOD::TruthParticleContainer > &truthParticleLink = - truthParticleLinkAcc (*track); - if(truthParticleLink.isValid()) { - const xAOD::TruthParticle *truthParticle = *truthParticleLink; - double eta = truthParticle->eta(); - - static const SG::ConstAccessor<ElementLink< xAOD::TruthVertexContainer > > - prodVtxLinkAcc ("prodVtxLink"); - const ElementLink< xAOD::TruthVertexContainer > &truthVertexLink = - prodVtxLinkAcc (*truthParticle); - if(truthVertexLink.isValid()) { - const xAOD::TruthVertex *truthVertex = *truthVertexLink; - double prodR = truthVertex->perp(); - if ( isActive( TRK_EFF_LARGED0_GLOBAL ) ) { - float fTrkEffSyst = getFractionDropped(1.0, m_trkEffHistLRTGlobal, eta, prodR, false); - if(m_rnd->Uniform(0, 1) < fTrkEffSyst) return false; - } - - if ( isActive( TRK_EFF_LARGED0_IBL ) ) { - float fTrkEffSyst = getFractionDropped(1.0, m_trkEffHistLRTIBL, eta, prodR, false); - if(m_rnd->Uniform(0, 1) < fTrkEffSyst) return false; - } - - if ( isActive( TRK_EFF_LARGED0_PP0 ) ) { - float fTrkEffSyst = getFractionDropped(1.0, m_trkEffHistLRTPP0, eta, prodR, false); - if(m_rnd->Uniform(0, 1) < fTrkEffSyst) return false; - } - - if ( isActive( TRK_EFF_LARGED0_PHYSMODEL ) ) { - float fTrkEffSyst = getFractionDropped(1.0, m_trkEffHistLRTPhysModel, eta, prodR, false); - if(m_rnd->Uniform(0, 1) < fTrkEffSyst) return false; - } - } + // combined systematics represent the sum in quadrature of the individual systematics + if ( isActive( TRK_EFF_LOOSE_COMBINED ) ) { + float fTrkEffSyst = sqrt( pow(getFractionDropped(1, m_trkEffHistLooseGlobal, pt, eta), 2) + + pow(getFractionDropped(1, m_trkEffHistLooseIBL, pt, eta), 2) + + pow(getFractionDropped(1, m_trkEffHistLoosePP0, pt, eta), 2) + + pow(getFractionDropped(1, m_trkEffHistLoosePhysModel, pt, eta), 2) ); + if(m_rnd->Uniform(0, 1) < fTrkEffSyst) return false; + } + if ( isActive( TRK_EFF_TIGHT_COMBINED ) ) { + float fTrkEffSyst = sqrt( pow(getFractionDropped(1, m_trkEffHistTightGlobal, pt, eta), 2) + + pow(getFractionDropped(1, m_trkEffHistTightIBL, pt, eta), 2) + + pow(getFractionDropped(1, m_trkEffHistTightPP0, pt, eta), 2) + + pow(getFractionDropped(1, m_trkEffHistTightPhysModel, pt, eta), 2) ); + if(m_rnd->Uniform(0, 1) < fTrkEffSyst) return false; } } @@ -424,62 +330,6 @@ namespace InDet { return hist->GetBinContent(hist->FindBin(pt, track->eta())); } - // this is where the calculation of the fake probability is done if you are not using truth info to determine whether a track is fake - - float InDetTrackTruthFilterTool::pseudoFakeProbability(const xAOD::TrackParticle* track, float mu) const { - - float pt = track->pt(); - float d0 = track->d0(); - - // make a function to determine which tracks we will classify as fake, parameters determined from fit to full-truth MC16e ttbar - float fakeProb = 0.01; - // this is the mu dependence part - if(mu>20) { - float p0 = 0.008645; - float p1 = 0.0001114; - float p2 = 9.299e-6; - fakeProb = p0 + (p1*mu) + (p2*mu*mu); - } - - // now we add the pT term - float pTcorr = 0.02; - if(pt<50000) { - float p0 = 0.02; - float p1 = -3.564; - float p2 = -0.0005982; - float param = p1 + (p2 * pt); - pTcorr = p0 + std::exp(param); - } - - fakeProb*=pTcorr; - - float d0corr = 1; - d0corr = std::tanh(std::abs(d0)); - - fakeProb*=d0corr; - - // multiply by empirical ad hoc rescaling factor - // to give correct overall probability - fakeProb*=309.602; - - return fakeProb; - - } - - bool InDetTrackTruthFilterTool::dropPseudoFake(float prob) const { - - bool isFake = false; - if(m_rnd->Uniform(0, 1) < prob) isFake=true; - - // Now, if we've decided if this is a fake, we apply the uncertainty - if(isFake){ - if(m_rnd->Uniform(0, 1) < m_fFakeLoose) return true; // drop this track - } - - return false; - - } - bool InDetTrackTruthFilterTool::isAffectedBySystematic( const CP::SystematicVariation& syst ) const { return InDetTrackSystematicsTool::isAffectedBySystematic( syst ); diff --git a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/Root/InclusiveTrackFilterTool.cxx b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/Root/InclusiveTrackFilterTool.cxx index b0a838b1b6ce..8925697bd9a3 100644 --- a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/Root/InclusiveTrackFilterTool.cxx +++ b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/Root/InclusiveTrackFilterTool.cxx @@ -23,9 +23,13 @@ namespace InDet { StatusCode InclusiveTrackFilterTool::initialize() { - m_rnd = std::make_unique<TRandom3>(m_seed); + if (m_calibFileLRTEff.empty()) { + ATH_MSG_ERROR("No calibration file for requested LRT track efficiency set. You may be running an unsupported datataking period, please contact Tracking CP if you believe this message is in error."); + return StatusCode::FAILURE; + } + TH2* trkLRTEff_tmp = nullptr; ATH_CHECK( initObject<TH2>( trkLRTEff_tmp, m_calibFileLRTEff, diff --git a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/python/InDetTrackSystematicsToolsConfig.py b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/python/InDetTrackSystematicsToolsConfig.py index cb8161008864..b68b71cb66cc 100644 --- a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/python/InDetTrackSystematicsToolsConfig.py +++ b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/python/InDetTrackSystematicsToolsConfig.py @@ -28,13 +28,11 @@ def InDetTrackTruthFilterToolCfg(flags, name="InDetTrackTruthFilterTool", **kwar if flags.GeoModel.Run == LHCPeriod.Run3: if flags.Input.MCCampaign == Campaign.MC23a: kwargs.setdefault("calibFileNomEff", "InDetTrackSystematicsTools/CalibData_22.0_2022-v00/TrackingRecommendations_prelim_rel22.root") - kwargs.setdefault("calibFileLRTEff", "InDetTrackSystematicsTools/CalibData_22.0_2022-v00/TrackingRecommendations_prelim_rel22.root") kwargs.setdefault("fFakeLoose", 0.40) kwargs.setdefault("fFakeTight", 1.00) # Run 2 recommendations (MC20) elif flags.GeoModel.Run == LHCPeriod.Run2: - kwargs.setdefault("calibFileNomEff", "InDetTrackSystematicsTools/CalibData_22.0_2020-v00/TrackingRecommendations_prelim_rel22.root") - kwargs.setdefault("calibFileLRTEff", "InDetTrackSystematicsTools/CalibData_22.0_2020-v00/TrackingRecommendations_prelim_rel22.root") + kwargs.setdefault("calibFileNomEff", "InDetTrackSystematicsTools/CalibData_22.0_2022-v00/TrackingRecommendations_prelim_rel22.root") kwargs.setdefault("fFakeLoose", 0.10) kwargs.setdefault("fFakeTight", 1.00) @@ -62,6 +60,18 @@ def JetTrackFilterToolCfg(flags, name="JetTrackFilterTool", **kwargs): def InclusiveTrackFilterToolCfg(flags, name="InclusiveTrackFilterTool", **kwargs): acc = ComponentAccumulator() + + from AthenaConfiguration.Enums import LHCPeriod + # 2022 recommendations (MC23a) + if flags.GeoModel.Run == LHCPeriod.Run3: + if flags.Input.MCCampaign == Campaign.MC23a: + kwargs.setdefault("calibFileLRTEff", "InDetTrackSystematicsTools/CalibData_25.2_2025-v00/LargeD0TrackingRecommendations_mc23a.root") + kwargs.setdefault("calibHistLRTEff", "OneMinusRatioEfficiencyVSRadiusOfFirstHitEta_Nominal") + # Run 2 recommendations (MC20) + elif flags.GeoModel.Run == LHCPeriod.Run2: + kwargs.setdefault("calibFileLRTEff", "InDetTrackSystematicsTools/CalibData_24.0_2023-v00/LargeD0TrackingRecommendations_20230824.root") + kwargs.setdefault("calibHistLRTEff", "OneMinusRatioEfficiencyVSRadiusOfFirstHitEta_Nominal") + acc.setPrivateTools( CompFactory.InDet.InclusiveTrackFilterTool(name, **kwargs)) return acc -- GitLab From 34ef16e098251db0a38f6c480fcb9a50a1cf4f8f Mon Sep 17 00:00:00 2001 From: Makayla Vessella <makayla.vessella@cern.ch> Date: Fri, 21 Mar 2025 01:14:38 +0100 Subject: [PATCH 4/6] address threads and update to Gaudi::property --- .../InDetTrackTruthFilterTool.h | 33 +++++++++---------- .../InclusiveTrackFilterTool.h | 4 +-- .../Root/InDetTrackTruthFilterTool.cxx | 31 ++++++++--------- .../InDetTrackSystematicsToolsConfig.py | 11 +++++-- 4 files changed, 40 insertions(+), 39 deletions(-) diff --git a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/InDetTrackTruthFilterTool.h b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/InDetTrackTruthFilterTool.h index c8c8a8d700da..2c05b74fd47c 100644 --- a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/InDetTrackTruthFilterTool.h +++ b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/InDetTrackTruthFilterTool.h @@ -7,6 +7,7 @@ #define INDETTRACKSYSTEMATICSTOOLS_INDETTRACKTRUTHFILTERTOOL_H #include "InDetTrackSystematicsTools/IInDetTrackTruthFilterTool.h" +#include "InDetTrackSystematicsTools/IInDetTrackTruthOriginTool.h" #include "AsgTools/AsgTool.h" #include "AsgTools/ToolHandle.h" #include "PATInterfaces/SystematicVariation.h" @@ -22,8 +23,6 @@ class TFile; namespace InDet { - class IInDetTrackTruthOriginTool; - /// @class InDetTrackTruthFilterTool /// This class selects tracks based on their truth origin /// @author Remi Zaidan (remi.zaidan@cern.ch) @@ -70,18 +69,20 @@ namespace InDet { StatusCode initTrkEffSystHistogram(float scale, TH2 *&histogram, std::string rootFileName, std::string histogramName) const; float getFractionDropped(float fDefault, const TH2 *histogram, float x, float y, bool xAxisIspT = true) const; - int m_seed = 0; + ToolHandle< IInDetTrackTruthOriginTool > m_trackOriginTool{this, "trackOriginTool", "InDet::InDetTrackTruthOriginTool", "Tool to get the truth origin of a track"}; + + Gaudi::Property<int> m_seed{this, "Seed", 0, "Random seed"}; std::unique_ptr<TRandom3> m_rnd; //! - float m_fPrim = 1.; - float m_fSec = 1.; - float m_fFakeLoose = -1.0; //default values that will not allow tool to continue if not configured properly - float m_fFakeTight = -1.0; - float m_fPU = 1.; - float m_fFrag = 1.; - float m_fFromC = 1.; - float m_fFromB = 1.; - float m_trkEffSystScale = 1.; + Gaudi::Property<float> m_fPrim{this, "Prim", 1.0, "Primary fraction"}; + Gaudi::Property<float> m_fSec{this, "Sec", 1.0, "Secondary fraction"}; + Gaudi::Property<float> m_fFakeLoose{this, "FakeLoose", -1.0, "Fake loose fraction"}; + Gaudi::Property<float> m_fFakeTight{this, "FakeTight", -1.0, "Fake tight fraction"}; + Gaudi::Property<float> m_fPU{this, "PU", 1.0, "Pile-up fraction"}; + Gaudi::Property<float> m_fFrag{this, "Frag", 1.0, "Fragmentation fraction"}; + Gaudi::Property<float> m_fFromC{this, "FromC", 1.0, "From C fraction"}; + Gaudi::Property<float> m_fFromB{this, "FromB", 1.0, "From B fraction"}; + Gaudi::Property<float> m_trkEffSystScale{this, "TrkEffSystScale", 1.0, "Track efficiency systematic scale"}; TH2 *m_fPrimHistogram = nullptr; TH2 *m_fSecHistogram = nullptr; @@ -90,7 +91,6 @@ namespace InDet { TH2 *m_fFromCHistogram = nullptr; TH2 *m_fFromBHistogram = nullptr; - TH2* m_trkEffHistLooseGlobal = nullptr; TH2* m_trkEffHistLooseIBL = nullptr; TH2* m_trkEffHistLoosePP0 = nullptr; @@ -103,12 +103,9 @@ namespace InDet { std::unordered_map<std::string, TH2*> m_histMap; // allow the user to configure which calibration files to use if desired - std::string m_calibFileNomEff; - - ToolHandle< IInDetTrackTruthOriginTool > m_trackOriginTool; - + Gaudi::Property<std::string> m_calibFileNomEff{this, "CalibFileNomEff", "", "Calibration file for nominal efficiency"}; -}; // class InDetTrackTruthFilterTool + }; // class InDetTrackTruthFilterTool } // namespace InDet diff --git a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/InclusiveTrackFilterTool.h b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/InclusiveTrackFilterTool.h index e0c80183806d..4f629a8375b5 100644 --- a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/InclusiveTrackFilterTool.h +++ b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/InclusiveTrackFilterTool.h @@ -71,10 +71,10 @@ namespace InDet { Gaudi::Property<float> m_trkEffSystScale{this, "trkEffSystScale", 1.0, "Option to scale the effect of the systematic (default 1)"}; // Property: path to the root file containing the LRT efficiency histogram (note: uses PathResolver) - Gaudi::Property<std::string> m_calibFileLRTEff; + Gaudi::Property<std::string> m_calibFileLRTEff{this, "calibFileLRTEff", "", "File containing the efficiency histogram (expert only)"}; // Property: name of the efficiency histogram in m_calibFileLRTEff - Gaudi::Property<std::string> m_calibHistLRTEff; + Gaudi::Property<std::string> m_calibHistLRTEff{this, "calibHistLRTEff", "OneMinusRatioEfficiencyVSRadiusOfFirstHitEta_Nominal", "Name of the efficiency histogram (expert only)"}; std::unique_ptr<TRandom3> m_rnd = nullptr; //! diff --git a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/Root/InDetTrackTruthFilterTool.cxx b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/Root/InDetTrackTruthFilterTool.cxx index 32b0d67bd1d1..f187a42df708 100644 --- a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/Root/InDetTrackTruthFilterTool.cxx +++ b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/Root/InDetTrackTruthFilterTool.cxx @@ -39,31 +39,30 @@ namespace InDet { InDetTrackTruthFilterTool::InDetTrackTruthFilterTool(const std::string& name) : InDetTrackSystematicsTool(name), - m_trackOriginTool("InDet::InDetTrackTruthOriginTool", this) + m_trackOriginTool(this, "trackOriginTool", "InDet::InDetTrackTruthOriginTool/InDetTrackTruthOriginTool", "Tool to get the truth origin of a track"), + m_seed(this, "Seed", 0, "Random seed"), + m_fPrim(this, "fPrim", 0.0, "Primary fraction"), + m_fSec(this, "fSec", 0.0, "Secondary fraction"), + m_fFakeLoose(this, "fFakeLoose", -1.0, "Fake loose fraction"), + m_fFakeTight(this, "fFakeTight", -1.0, "Fake tight fraction"), + m_fPU(this, "fPU", 0.0, "Pileup fraction"), + m_fFrag(this, "fFrag", 0.0, "Fragmentation fraction"), + m_fFromC(this, "fFromC", 0.0, "From C fraction"), + m_fFromB(this, "fFromB", 0.0, "From B fraction"), + m_trkEffSystScale(this, "trkEffSystScale", 1.0, "Track efficiency systematic scale"), + m_calibFileNomEff(this, "calibFileNomEff", "", "Calibration file for nominal efficiency") { #ifndef XAOD_STANDALONE declareInterface<IInDetTrackTruthFilterTool>(this); #endif - declareProperty("trackOriginTool", m_trackOriginTool); - - declareProperty("Seed", m_seed); - - declareProperty("fPrim", m_fPrim); - declareProperty("fSec", m_fSec); - declareProperty("fFakeLoose", m_fFakeLoose); - declareProperty("fFakeTight", m_fFakeTight); - declareProperty("fPU", m_fPU); - declareProperty("fFrag", m_fFrag); - declareProperty("fFromC", m_fFromC); - declareProperty("fFromB", m_fFromB); - declareProperty("trkEffSystScale", m_trkEffSystScale); - declareProperty("calibFileNomEff", m_calibFileNomEff); } StatusCode InDetTrackTruthFilterTool::initialize() { + ATH_CHECK ( m_trackOriginTool.retrieve() ); + m_rnd = std::make_unique<TRandom3>(m_seed); bool anyEffSystActive = isActive(TRK_EFF_LOOSE_GLOBAL) || isActive(TRK_EFF_LOOSE_IBL) || isActive(TRK_EFF_LOOSE_PP0) || @@ -132,8 +131,6 @@ namespace InDet { {"TRK_EFF_TIGHT_PHYSMODEL", m_trkEffHistTightPhysModel} }; - ATH_CHECK ( m_trackOriginTool.retrieve() ); - ATH_CHECK ( InDetTrackSystematicsTool::initialize() ); return StatusCode::SUCCESS; diff --git a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/python/InDetTrackSystematicsToolsConfig.py b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/python/InDetTrackSystematicsToolsConfig.py index b68b71cb66cc..fdb4a3517f51 100644 --- a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/python/InDetTrackSystematicsToolsConfig.py +++ b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/python/InDetTrackSystematicsToolsConfig.py @@ -3,6 +3,7 @@ from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator from AthenaConfiguration.ComponentFactory import CompFactory from Campaigns.Utils import Campaign +from AthenaCommon.Logging import logging def InDetTrackTruthOriginToolCfg(flags, name="InDetTrackTruthOriginTool", **kwargs): acc = ComponentAccumulator() @@ -19,6 +20,8 @@ def InDetTrackTruthOriginToolCfg(flags, name="InDetTrackTruthOriginTool", **kwar def InDetTrackTruthFilterToolCfg(flags, name="InDetTrackTruthFilterTool", **kwargs): acc = ComponentAccumulator() + log = logging.getLogger("InDetTrackTruthFilterToolCfg") + if "trackOriginTool" not in kwargs: kwargs.setdefault("trackOriginTool", acc.popToolsAndMerge( InDetTrackTruthOriginToolCfg(flags))) @@ -35,6 +38,8 @@ def InDetTrackTruthFilterToolCfg(flags, name="InDetTrackTruthFilterTool", **kwar kwargs.setdefault("calibFileNomEff", "InDetTrackSystematicsTools/CalibData_22.0_2022-v00/TrackingRecommendations_prelim_rel22.root") kwargs.setdefault("fFakeLoose", 0.10) kwargs.setdefault("fFakeTight", 1.00) + else: + log.warning("InDetTrackTruthFilterTool: Recommendations not yet available for this campaign! Please check the configuration and contact Tracking CP if you believe this message is in error.") acc.setPrivateTools( CompFactory.InDet.InDetTrackTruthFilterTool(name, **kwargs)) @@ -61,16 +66,18 @@ def JetTrackFilterToolCfg(flags, name="JetTrackFilterTool", **kwargs): def InclusiveTrackFilterToolCfg(flags, name="InclusiveTrackFilterTool", **kwargs): acc = ComponentAccumulator() + log = logging.getLogger("InclusiveTrackFilterToolCfg") + from AthenaConfiguration.Enums import LHCPeriod # 2022 recommendations (MC23a) if flags.GeoModel.Run == LHCPeriod.Run3: if flags.Input.MCCampaign == Campaign.MC23a: kwargs.setdefault("calibFileLRTEff", "InDetTrackSystematicsTools/CalibData_25.2_2025-v00/LargeD0TrackingRecommendations_mc23a.root") - kwargs.setdefault("calibHistLRTEff", "OneMinusRatioEfficiencyVSRadiusOfFirstHitEta_Nominal") # Run 2 recommendations (MC20) elif flags.GeoModel.Run == LHCPeriod.Run2: kwargs.setdefault("calibFileLRTEff", "InDetTrackSystematicsTools/CalibData_24.0_2023-v00/LargeD0TrackingRecommendations_20230824.root") - kwargs.setdefault("calibHistLRTEff", "OneMinusRatioEfficiencyVSRadiusOfFirstHitEta_Nominal") + else: + log.warning("InclusiveTrackFilterTool: Recommendations not yet available for this campaign! Please check the configuration and contact Tracking CP if you believe this message is in error.") acc.setPrivateTools( CompFactory.InDet.InclusiveTrackFilterTool(name, **kwargs)) -- GitLab From 4f85eeb612b577abf6177460dd706d07039feab2 Mon Sep 17 00:00:00 2001 From: Makayla Vessella <makayla.vessella@cern.ch> Date: Fri, 21 Mar 2025 02:26:52 +0100 Subject: [PATCH 5/6] further remove deprecated properties --- .../InDetTrackTruthFilterTool.h | 21 ++-------- .../Root/InDetTrackTruthFilterTool.cxx | 42 +------------------ 2 files changed, 6 insertions(+), 57 deletions(-) diff --git a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/InDetTrackTruthFilterTool.h b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/InDetTrackTruthFilterTool.h index 2c05b74fd47c..c495c6802ac2 100644 --- a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/InDetTrackTruthFilterTool.h +++ b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/InDetTrackTruthFilterTool.h @@ -74,22 +74,9 @@ namespace InDet { Gaudi::Property<int> m_seed{this, "Seed", 0, "Random seed"}; std::unique_ptr<TRandom3> m_rnd; //! - Gaudi::Property<float> m_fPrim{this, "Prim", 1.0, "Primary fraction"}; - Gaudi::Property<float> m_fSec{this, "Sec", 1.0, "Secondary fraction"}; - Gaudi::Property<float> m_fFakeLoose{this, "FakeLoose", -1.0, "Fake loose fraction"}; - Gaudi::Property<float> m_fFakeTight{this, "FakeTight", -1.0, "Fake tight fraction"}; - Gaudi::Property<float> m_fPU{this, "PU", 1.0, "Pile-up fraction"}; - Gaudi::Property<float> m_fFrag{this, "Frag", 1.0, "Fragmentation fraction"}; - Gaudi::Property<float> m_fFromC{this, "FromC", 1.0, "From C fraction"}; - Gaudi::Property<float> m_fFromB{this, "FromB", 1.0, "From B fraction"}; - Gaudi::Property<float> m_trkEffSystScale{this, "TrkEffSystScale", 1.0, "Track efficiency systematic scale"}; - - TH2 *m_fPrimHistogram = nullptr; - TH2 *m_fSecHistogram = nullptr; - TH2 *m_fPUHistogram = nullptr; - TH2 *m_fFragHistogram = nullptr; - TH2 *m_fFromCHistogram = nullptr; - TH2 *m_fFromBHistogram = nullptr; + Gaudi::Property<float> m_fFakeLoose{this, "fFakeLoose", -1.0, "Fake loose fraction"}; + Gaudi::Property<float> m_fFakeTight{this, "fFakeTight", -1.0, "Fake tight fraction"}; + Gaudi::Property<float> m_trkEffSystScale{this, "trkEffSystScale", 1.0, "Track efficiency systematic scale"}; TH2* m_trkEffHistLooseGlobal = nullptr; TH2* m_trkEffHistLooseIBL = nullptr; @@ -103,7 +90,7 @@ namespace InDet { std::unordered_map<std::string, TH2*> m_histMap; // allow the user to configure which calibration files to use if desired - Gaudi::Property<std::string> m_calibFileNomEff{this, "CalibFileNomEff", "", "Calibration file for nominal efficiency"}; + Gaudi::Property<std::string> m_calibFileNomEff{this, "calibFileNomEff", "", "Calibration file for nominal efficiency"}; }; // class InDetTrackTruthFilterTool diff --git a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/Root/InDetTrackTruthFilterTool.cxx b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/Root/InDetTrackTruthFilterTool.cxx index f187a42df708..cf5b814a4795 100644 --- a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/Root/InDetTrackTruthFilterTool.cxx +++ b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/Root/InDetTrackTruthFilterTool.cxx @@ -38,19 +38,7 @@ namespace InDet { }; InDetTrackTruthFilterTool::InDetTrackTruthFilterTool(const std::string& name) : - InDetTrackSystematicsTool(name), - m_trackOriginTool(this, "trackOriginTool", "InDet::InDetTrackTruthOriginTool/InDetTrackTruthOriginTool", "Tool to get the truth origin of a track"), - m_seed(this, "Seed", 0, "Random seed"), - m_fPrim(this, "fPrim", 0.0, "Primary fraction"), - m_fSec(this, "fSec", 0.0, "Secondary fraction"), - m_fFakeLoose(this, "fFakeLoose", -1.0, "Fake loose fraction"), - m_fFakeTight(this, "fFakeTight", -1.0, "Fake tight fraction"), - m_fPU(this, "fPU", 0.0, "Pileup fraction"), - m_fFrag(this, "fFrag", 0.0, "Fragmentation fraction"), - m_fFromC(this, "fFromC", 0.0, "From C fraction"), - m_fFromB(this, "fFromB", 0.0, "From B fraction"), - m_trkEffSystScale(this, "trkEffSystScale", 1.0, "Track efficiency systematic scale"), - m_calibFileNomEff(this, "calibFileNomEff", "", "Calibration file for nominal efficiency") + InDetTrackSystematicsTool(name) { #ifndef XAOD_STANDALONE @@ -139,12 +127,6 @@ namespace InDet { InDetTrackTruthFilterTool::~InDetTrackTruthFilterTool() { - delete m_fPrimHistogram; - delete m_fSecHistogram; - delete m_fPUHistogram; - delete m_fFragHistogram; - delete m_fFromCHistogram; - delete m_fFromBHistogram; delete m_trkEffHistLooseGlobal; delete m_trkEffHistLooseIBL; delete m_trkEffHistLoosePP0; @@ -153,13 +135,7 @@ namespace InDet { delete m_trkEffHistTightIBL; delete m_trkEffHistTightPP0; delete m_trkEffHistTightPhysModel; - - m_fPrimHistogram = nullptr; - m_fSecHistogram = nullptr; - m_fPUHistogram = nullptr; - m_fFragHistogram = nullptr; - m_fFromCHistogram = nullptr; - m_fFromBHistogram = nullptr; + m_trkEffHistLooseGlobal = nullptr; m_trkEffHistLooseIBL = nullptr; m_trkEffHistLoosePP0 = nullptr; @@ -177,20 +153,6 @@ namespace InDet { int origin = m_trackOriginTool->getTrackOrigin(track); - // we unimplemented histograms for these, so only flat defaults will be used. - float fPrim = getFractionDropped(m_fPrim, m_fPrimHistogram, pt, eta); - if(InDet::TrkOrigin::isPrimary(origin) && m_rnd->Uniform(0, 1) > fPrim) return false; - float fSec = getFractionDropped(m_fSec, m_fSecHistogram, pt, eta); - if(InDet::TrkOrigin::isSecondary(origin) && m_rnd->Uniform(0, 1) > fSec) return false; - float fPU = getFractionDropped(m_fPU, m_fPUHistogram, pt, eta); - if(InDet::TrkOrigin::isPileup(origin) && m_rnd->Uniform(0, 1) > fPU) return false; - float fFrag = getFractionDropped(m_fFrag, m_fFragHistogram, pt, eta); - if(InDet::TrkOrigin::isFragmentation(origin) && m_rnd->Uniform(0, 1) > fFrag) return false; - float fFromC = getFractionDropped(m_fFromC, m_fFromCHistogram, pt, eta); - if(InDet::TrkOrigin::isFromD(origin) && m_rnd->Uniform(0, 1) > fFromC) return false; - float fFromB = getFractionDropped(m_fFromB, m_fFromBHistogram, pt, eta); - if(InDet::TrkOrigin::isFromB(origin) && m_rnd->Uniform(0, 1) > fFromB) return false; - if ( InDet::TrkOrigin::isFake(origin) ) { bool isActiveLoose = isActive( TRK_FAKE_RATE_LOOSE ); bool isActiveTight = isActive( TRK_FAKE_RATE_TIGHT ); -- GitLab From 163adff08b2b01b8ab6b68c781c2b1f463c32998 Mon Sep 17 00:00:00 2001 From: Makayla Vessella <makayla.vessella@cern.ch> Date: Fri, 21 Mar 2025 14:02:32 +0000 Subject: [PATCH 6/6] Add property header for AB --- .../InDetTrackSystematicsTools/InDetTrackTruthFilterTool.h | 1 + 1 file changed, 1 insertion(+) diff --git a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/InDetTrackTruthFilterTool.h b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/InDetTrackTruthFilterTool.h index c495c6802ac2..2b8b7b0a1323 100644 --- a/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/InDetTrackTruthFilterTool.h +++ b/PhysicsAnalysis/TrackingID/InDetTrackSystematicsTools/InDetTrackSystematicsTools/InDetTrackTruthFilterTool.h @@ -10,6 +10,7 @@ #include "InDetTrackSystematicsTools/IInDetTrackTruthOriginTool.h" #include "AsgTools/AsgTool.h" #include "AsgTools/ToolHandle.h" +#include "AsgTools/PropertyWrapper.h" #include "PATInterfaces/SystematicVariation.h" #include "PATInterfaces/SystematicSet.h" #include "InDetTrackSystematicsTools/InDetTrackSystematicsTool.h" -- GitLab