diff --git a/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/MetAnalysisAlgorithms/MetAnalysisAlgorithmsDict.h b/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/MetAnalysisAlgorithms/MetAnalysisAlgorithmsDict.h index 751f56e8171afc57f916267267c5cc3ffb60dc2f..06f150d36f6feea8d8b4e33c9b5c5fd5bf959d01 100644 --- a/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/MetAnalysisAlgorithms/MetAnalysisAlgorithmsDict.h +++ b/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/MetAnalysisAlgorithms/MetAnalysisAlgorithmsDict.h @@ -11,6 +11,5 @@ #include <MetAnalysisAlgorithms/MetBuilderAlg.h> #include <MetAnalysisAlgorithms/MetMakerAlg.h> #include <MetAnalysisAlgorithms/MetSignificanceAlg.h> -#include <MetAnalysisAlgorithms/MetSystematicsAlg.h> #endif diff --git a/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/MetAnalysisAlgorithms/MetMakerAlg.h b/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/MetAnalysisAlgorithms/MetMakerAlg.h index da7cab77319412a73a3100b56b4b5b4f7a43882d..7bf2b28ef695af5a800f2f5625e25439f53a99d0 100644 --- a/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/MetAnalysisAlgorithms/MetMakerAlg.h +++ b/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/MetAnalysisAlgorithms/MetMakerAlg.h @@ -14,6 +14,7 @@ #include <SystematicsHandles/SysWriteHandle.h> #include <SystematicsHandles/SysListHandle.h> #include <METInterface/IMETMaker.h> +#include <METInterface/IMETSystematicsTool.h> #include <xAODBase/IParticleContainer.h> #include <xAODMissingET/MissingETContainer.h> @@ -47,10 +48,14 @@ namespace CP - /// \brief the smearing tool + /// \brief the maker tool private: ToolHandle<IMETMaker> m_makerTool; + /// \brief the systematics tool + private: + ToolHandle<IMETSystematicsTool> m_systematicsTool; + /// \brief the name of the core MissingETContainer private: std::string m_metCoreName; diff --git a/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/MetAnalysisAlgorithms/MetSystematicsAlg.h b/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/MetAnalysisAlgorithms/MetSystematicsAlg.h deleted file mode 100644 index cba1d161ef4467072008872141b653956d32489b..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/MetAnalysisAlgorithms/MetSystematicsAlg.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration -*/ - -/// @author Nils Krumnack - - - -#ifndef MET_ANALYSIS_ALGORITHMS__MET_SYSTEMATICS_ALG_H -#define MET_ANALYSIS_ALGORITHMS__MET_SYSTEMATICS_ALG_H - -#include <AnaAlgorithm/AnaAlgorithm.h> -#include <SystematicsHandles/SysCopyHandle.h> -#include <SystematicsHandles/SysListHandle.h> -#include <METInterface/IMETSystematicsTool.h> -#include <xAODMissingET/MissingETContainer.h> - -namespace CP -{ - /// \brief an algorithm for calling \ref IMetCalibrationAndSmearingTool - - class MetSystematicsAlg final : public EL::AnaAlgorithm - { - /// \brief the standard constructor - public: - MetSystematicsAlg (const std::string& name, - ISvcLocator* pSvcLocator); - - - public: - StatusCode initialize () override; - - public: - StatusCode execute () override; - - - - /// \brief the smearing tool - private: - ToolHandle<IMETSystematicsTool> m_systematicsTool; - - /// \brief the systematics list we run - private: - SysListHandle m_systematicsList {this}; - - /// \brief the met collection we run on - private: - SysCopyHandle<xAOD::MissingETContainer> m_metHandle { - this, "met", "MissingET_%SYS%", "the met collection we run on"}; - - /// \brief the key for the soft term - private: - std::string m_softTerm {"PVSoftTrk"}; - }; -} - -#endif diff --git a/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/MetAnalysisAlgorithms/selection.xml b/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/MetAnalysisAlgorithms/selection.xml index c83c888c5044aabdc2ad83858b67ec1222229d77..fc4f787b3d677aa2ab605602d5d5a4a0ab11b4c5 100644 --- a/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/MetAnalysisAlgorithms/selection.xml +++ b/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/MetAnalysisAlgorithms/selection.xml @@ -3,6 +3,5 @@ <class name="CP::MetBuilderAlg" /> <class name="CP::MetMakerAlg" /> <class name="CP::MetSignificanceAlg" /> - <class name="CP::MetSystematicsAlg" /> </lcgdict> diff --git a/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/Root/MetMakerAlg.cxx b/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/Root/MetMakerAlg.cxx index c5e0191f2e24906412c46369447e5436c00ba90f..e6b9c054e30cf7f5953e031ccfb8b32c4052fa1d 100644 --- a/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/Root/MetMakerAlg.cxx +++ b/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/Root/MetMakerAlg.cxx @@ -26,8 +26,10 @@ namespace CP ISvcLocator* pSvcLocator) : AnaAlgorithm (name, pSvcLocator) , m_makerTool ("METMaker", this) + , m_systematicsTool ("", this) { declareProperty ("makerTool", m_makerTool, "the METMaker tool we apply"); + declareProperty ("systematicsTool", m_systematicsTool, "the systematics tool we apply"); declareProperty ("metCore", m_metCoreName, "the name of the core MissingETContainer"); declareProperty ("metAssociation", m_metAssociationName, "the name of the core MissingETContainer"); declareProperty ("electronsKey", m_electronsKey, "the key for the electrons"); @@ -46,6 +48,7 @@ namespace CP initialize () { ANA_CHECK (m_makerTool.retrieve()); + for (auto* handle : {&m_electronsHandle, &m_photonsHandle, &m_muonsHandle, &m_tausHandle, &m_invisHandle}) { if (*handle) { @@ -54,6 +57,13 @@ namespace CP } m_systematicsList.addHandle (m_jetsHandle); m_systematicsList.addHandle (m_metHandle); + + if (!m_systematicsTool.empty()) + { + ANA_CHECK (m_systematicsTool.retrieve()); + ANA_CHECK (m_systematicsList.addAffectingSystematics (m_systematicsTool->affectingSystematics())); + } + ANA_CHECK (m_systematicsList.initialize()); return StatusCode::SUCCESS; @@ -122,6 +132,25 @@ namespace CP ANA_CHECK (m_makerTool->rebuildJetMET (m_jetsKey, m_softTermKey, met.get(), jets, metcore, &metHelper, m_doJetJVT)); } + // Systematics + if (!m_systematicsTool.empty()) + { + ANA_CHECK (m_systematicsTool->applySystematicVariation (sys)); + + xAOD::MissingET *softTerm = (*met)[m_softTermKey]; + if (softTerm == nullptr) + { + ANA_MSG_ERROR ("failed to find MET soft-term \"" << m_softTermKey << "\""); + return StatusCode::FAILURE; + } + + // This returns a `CorrectionCode`, so in principle this could + // return an `OutOfValidity` result, but I have no idea what + // that would mean or how to handle it, so I'm implicitly + // converting it into a `FAILURE` instead. + ANA_CHECK (m_systematicsTool->applyCorrection (*softTerm, &metHelper)); + } + ANA_CHECK (m_metHandle.record (std::move (met), std::move (aux), sys)); return StatusCode::SUCCESS; }); diff --git a/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/Root/MetSystematicsAlg.cxx b/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/Root/MetSystematicsAlg.cxx deleted file mode 100644 index 1e255b6581d66bc07cda3bfc34b1b94bc59cff90..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/Root/MetSystematicsAlg.cxx +++ /dev/null @@ -1,72 +0,0 @@ -/* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration -*/ - -/// @author Nils Krumnack - - - -// -// includes -// - -#include <MetAnalysisAlgorithms/MetSystematicsAlg.h> - -#include <xAODMissingET/MissingETAuxContainer.h> - -// -// method implementations -// - -namespace CP -{ - MetSystematicsAlg :: - MetSystematicsAlg (const std::string& name, - ISvcLocator* pSvcLocator) - : AnaAlgorithm (name, pSvcLocator) - , m_systematicsTool ("met::METSystematicsTool", this) - { - declareProperty ("systematicsTool", m_systematicsTool, "the systematics tool we apply"); - declareProperty ("softTerm", m_softTerm, "the key for the soft term"); - } - - - - StatusCode MetSystematicsAlg :: - initialize () - { - ANA_CHECK (m_systematicsTool.retrieve()); - m_systematicsList.addHandle (m_metHandle); - ANA_CHECK (m_systematicsList.addAffectingSystematics (m_systematicsTool->affectingSystematics())); - ANA_CHECK (m_systematicsList.initialize()); - return StatusCode::SUCCESS; - } - - - - StatusCode MetSystematicsAlg :: - execute () - { - return m_systematicsList.foreach ([&] (const CP::SystematicSet& sys) -> StatusCode { - ANA_CHECK (m_systematicsTool->applySystematicVariation (sys)); - - xAOD::MissingETContainer *met {}; - ANA_CHECK (m_metHandle.getCopy (met, sys)); - - xAOD::MissingET *softTerm = (*met)[m_softTerm]; - if (softTerm == nullptr) - { - ANA_MSG_ERROR ("failed to find MET soft-term \"" << m_softTerm << "\""); - return StatusCode::FAILURE; - } - - // This returns a `CorrectionCode`, so in principle this could - // return an `OutOfValidity` result, but I have no idea what - // that would mean or how to handle it, so I'm implicitly - // converting it into a `FAILURE` instead. - ANA_CHECK (m_systematicsTool->applyCorrection (*softTerm)); - - return StatusCode::SUCCESS; - }); - } -} diff --git a/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/python/MetAnalysisSequence.py b/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/python/MetAnalysisSequence.py index a20926c5c835ec62b6471c6ea8c1027b3ebcd6b2..aeb244ea391ac58209941b3226e1de8999871fb8 100644 --- a/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/python/MetAnalysisSequence.py +++ b/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/python/MetAnalysisSequence.py @@ -6,8 +6,8 @@ from AnaAlgorithm.DualUseConfig import createAlgorithm, addPrivateTool def makeMetAnalysisSequence( dataType, metSuffix, postfix = '', - useFJVT = True, - treatPUJets = True ): + useFJVT = False, + treatPUJets = False ): """Create a met analysis algorithm sequence After creating the sequence object, it needs to be configured with a call @@ -60,6 +60,8 @@ def makeMetAnalysisSequence( dataType, metSuffix, alg.makerTool.DoPFlow = 'PFlow' in metSuffix if useFJVT: alg.makerTool.JetRejectionDec = 'passFJVT' + if dataType != "data" : + addPrivateTool( alg, 'systematicsTool', 'met::METSystematicsTool' ) alg.metCore = 'MET_Core_' + metSuffix alg.metAssociation = 'METAssoc_' + metSuffix seq.append( alg, @@ -72,13 +74,6 @@ def makeMetAnalysisSequence( dataType, metSuffix, outputPropName = 'met', affectingSystematics = '(^MET_.*)' ) - if dataType != "data" : - alg = createAlgorithm( 'CP::MetSystematicsAlg', 'MetSystematicsAlg' + postfix ) - addPrivateTool( alg, 'systematicsTool', 'met::METSystematicsTool' ) - seq.append( alg, inputPropName = 'met', - affectingSystematics = '(^MET_.*)' ) - pass - # Set up the met builder algorithm: alg = createAlgorithm( 'CP::MetBuilderAlg', 'MetBuilderAlg' + postfix ) seq.append( alg, inputPropName = 'met' ) diff --git a/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/src/components/MetAnalysisAlgorithms_entries.cxx b/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/src/components/MetAnalysisAlgorithms_entries.cxx index 7e058bc2cb473822da377afd10e96924bca6bde5..566a3a6924a2759e414fcfaab3b985793242f99b 100644 --- a/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/src/components/MetAnalysisAlgorithms_entries.cxx +++ b/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/src/components/MetAnalysisAlgorithms_entries.cxx @@ -3,10 +3,8 @@ #include <MetAnalysisAlgorithms/MetBuilderAlg.h> #include <MetAnalysisAlgorithms/MetMakerAlg.h> #include <MetAnalysisAlgorithms/MetSignificanceAlg.h> -#include <MetAnalysisAlgorithms/MetSystematicsAlg.h> DECLARE_COMPONENT (CP::MetBuilderAlg) DECLARE_COMPONENT (CP::MetMakerAlg) DECLARE_COMPONENT (CP::MetSignificanceAlg) -DECLARE_COMPONENT (CP::MetSystematicsAlg)