diff --git a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithms/AsgSelectionAlg.h b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithms/AsgSelectionAlg.h index fb606c908dc14428f014db3d3e4f8bb28b4a6cbf..ac3c498ad9e1450d898b7b2fadae1e9ee2048e4d 100644 --- a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithms/AsgSelectionAlg.h +++ b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithms/AsgSelectionAlg.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration */ /// @author Nils Krumnack @@ -9,6 +9,7 @@ #ifndef ASG_ANALYSIS_ALGORITHMS__ASG_SELECTION_ALG_H #define ASG_ANALYSIS_ALGORITHMS__ASG_SELECTION_ALG_H +#include <AsgTools/ToolStore.h> #include <AnaAlgorithm/AnaAlgorithm.h> #include <PATCore/IAsgSelectionTool.h> #include <SelectionHelpers/SysReadSelectionHandle.h> @@ -60,6 +61,10 @@ namespace CP private: ToolHandle<IAsgSelectionTool> m_selectionTool; + /// \brief alternative way of retrieving the selection tool + private: + std::string m_selectionToolByName; + /// \brief the smearing tool cast to an ISystematicsTool /// /// Normally selection tools don't have systematics, but I believe diff --git a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/Root/AsgSelectionAlg.cxx b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/Root/AsgSelectionAlg.cxx index 161b9e67bbdc24e78d5b366a06d592dbea4f1980..f233335c09e708e94a600cf4694d6e441f3b5635 100644 --- a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/Root/AsgSelectionAlg.cxx +++ b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/Root/AsgSelectionAlg.cxx @@ -25,8 +25,10 @@ namespace CP ISvcLocator* pSvcLocator) : AnaAlgorithm (name, pSvcLocator) , m_selectionTool ("", this) + , m_selectionToolByName ("") { declareProperty ("selectionTool", m_selectionTool, "the selection tool we apply"); + declareProperty ("selectionToolByName", m_selectionToolByName, "the name of the selection tool to retrieve, if not passed directly"); } @@ -41,7 +43,16 @@ namespace CP if (m_systematicsTool) ANA_CHECK (m_systematicsList.addSystematics (*m_systematicsTool)); } - + else if (!m_selectionToolByName.empty()) + { + if (asg::ToolStore::contains<IAsgSelectionTool>(m_selectionToolByName)) { + m_selectionTool = asg::ToolStore::get<IAsgSelectionTool>(m_selectionToolByName); + m_systematicsTool = dynamic_cast<ISystematicsTool*>(&*m_selectionTool); + if (m_systematicsTool) + ANA_CHECK (m_systematicsList.addSystematics (*m_systematicsTool)); + } + } + ANA_CHECK (m_particlesHandle.initialize (m_systematicsList)); ANA_CHECK (m_preselection.initialize (m_systematicsList, m_particlesHandle, SG::AllowEmpty)); ANA_CHECK (m_selectionHandle.initialize (m_systematicsList, m_particlesHandle)); diff --git a/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/python/TauAnalysisConfig.py b/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/python/TauAnalysisConfig.py index 01491adf0a5e58849c7033269493c4395662dd4d..0be90648820f665cb5e05dacf2d0284e5f8ffe9c 100644 --- a/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/python/TauAnalysisConfig.py +++ b/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/python/TauAnalysisConfig.py @@ -38,6 +38,7 @@ class TauCalibrationConfig (ConfigBlock): # Set up the tau 4-momentum smearing algorithm: alg = config.createAlgorithm( 'CP::TauSmearingAlg', 'TauSmearingAlg' + postfix ) config.addPrivateTool( 'smearingTool', 'TauAnalysisTools::TauSmearingTool' ) + alg.smearingTool.isAFII = config.dataType() == 'afii' alg.taus = config.readName (self.containerName) alg.tausOut = config.copyName (self.containerName) alg.preselection = config.getPreselection (self.containerName, '') @@ -87,15 +88,15 @@ class TauWorkingPointConfig (ConfigBlock) : "VeryLoose, NoID, Baseline") inputfile = nameFormat.format(self.quality.lower()) - # Setup the tau selection tool + # Setup the tau selection tool: common for both the selection algorithm + # and the efficiency corrections tool (scale factors) selectionTool = config.createPublicTool( 'TauAnalysisTools::TauSelectionTool', 'TauSelectionTool' + postfix) selectionTool.ConfigPath = inputfile # Set up the algorithm selecting taus: alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'TauSelectionAlg' + postfix ) - config.addPrivateTool( 'selectionTool', 'TauAnalysisTools::TauSelectionTool' ) - alg.selectionTool.ConfigPath = inputfile + alg.selectionToolByName = selectionTool.getName() alg.selectionDecoration = 'selected_tau' + selectionPostfix + ',as_bits' alg.particles = config.readName (self.containerName) alg.preselection = config.getPreselection (self.containerName, self.selectionName) @@ -119,6 +120,7 @@ class TauWorkingPointConfig (ConfigBlock) : 'TauAnalysisTools::TauEfficiencyCorrectionsTool' ) alg.efficiencyCorrectionsTool.TauSelectionTool = '%s/%s' % \ ( selectionTool.getType(), selectionTool.getName() ) + alg.efficiencyCorrectionsTool.isAFII = config.dataType() == 'afii' alg.scaleFactorDecoration = 'tau_effSF' + selectionPostfix + '_%SYS%' alg.outOfValidity = 2 #silent alg.outOfValidityDeco = 'bad_eff' + selectionPostfix @@ -139,7 +141,6 @@ def makeTauCalibrationConfig( seq, containerName, postfix = None, between the working points. Keyword arguments: - dataType -- The data type to run on ("data", "mc" or "afii") postfix -- a postfix to apply to decorations and algorithm names. this is mostly used/needed when using this sequence with multiple working points to ensure all @@ -163,7 +164,6 @@ def makeTauWorkingPointConfig( seq, containerName, workingPoint, postfix, """Create tau analysis algorithms for a single working point Keyword arguments: - dataType -- The data type to run on ("data", "mc" or "afii") legacyRecommendations -- use legacy tau BDT and electron veto recommendations postfix -- a postfix to apply to decorations and algorithm names. this is mostly used/needed when using this