Skip to content
Snippets Groups Projects
Commit bacf417a authored by Johannes Elmsheuser's avatar Johannes Elmsheuser
Browse files

Merge branch 'asg/met' into 'master'

CP algs: Merge MetMakerAlg and MetSystematicsAlg due to dependencies

See merge request atlas/athena!39398
parents 3c804347 2eea2b83
No related branches found
No related tags found
No related merge requests found
Showing with 39 additions and 143 deletions
...@@ -11,6 +11,5 @@ ...@@ -11,6 +11,5 @@
#include <MetAnalysisAlgorithms/MetBuilderAlg.h> #include <MetAnalysisAlgorithms/MetBuilderAlg.h>
#include <MetAnalysisAlgorithms/MetMakerAlg.h> #include <MetAnalysisAlgorithms/MetMakerAlg.h>
#include <MetAnalysisAlgorithms/MetSignificanceAlg.h> #include <MetAnalysisAlgorithms/MetSignificanceAlg.h>
#include <MetAnalysisAlgorithms/MetSystematicsAlg.h>
#endif #endif
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <SystematicsHandles/SysWriteHandle.h> #include <SystematicsHandles/SysWriteHandle.h>
#include <SystematicsHandles/SysListHandle.h> #include <SystematicsHandles/SysListHandle.h>
#include <METInterface/IMETMaker.h> #include <METInterface/IMETMaker.h>
#include <METInterface/IMETSystematicsTool.h>
#include <xAODBase/IParticleContainer.h> #include <xAODBase/IParticleContainer.h>
#include <xAODMissingET/MissingETContainer.h> #include <xAODMissingET/MissingETContainer.h>
...@@ -47,10 +48,14 @@ namespace CP ...@@ -47,10 +48,14 @@ namespace CP
/// \brief the smearing tool /// \brief the maker tool
private: private:
ToolHandle<IMETMaker> m_makerTool; ToolHandle<IMETMaker> m_makerTool;
/// \brief the systematics tool
private:
ToolHandle<IMETSystematicsTool> m_systematicsTool;
/// \brief the name of the core MissingETContainer /// \brief the name of the core MissingETContainer
private: private:
std::string m_metCoreName; std::string m_metCoreName;
......
/*
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
...@@ -3,6 +3,5 @@ ...@@ -3,6 +3,5 @@
<class name="CP::MetBuilderAlg" /> <class name="CP::MetBuilderAlg" />
<class name="CP::MetMakerAlg" /> <class name="CP::MetMakerAlg" />
<class name="CP::MetSignificanceAlg" /> <class name="CP::MetSignificanceAlg" />
<class name="CP::MetSystematicsAlg" />
</lcgdict> </lcgdict>
...@@ -26,8 +26,10 @@ namespace CP ...@@ -26,8 +26,10 @@ namespace CP
ISvcLocator* pSvcLocator) ISvcLocator* pSvcLocator)
: AnaAlgorithm (name, pSvcLocator) : AnaAlgorithm (name, pSvcLocator)
, m_makerTool ("METMaker", this) , m_makerTool ("METMaker", this)
, m_systematicsTool ("", this)
{ {
declareProperty ("makerTool", m_makerTool, "the METMaker tool we apply"); 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 ("metCore", m_metCoreName, "the name of the core MissingETContainer");
declareProperty ("metAssociation", m_metAssociationName, "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"); declareProperty ("electronsKey", m_electronsKey, "the key for the electrons");
...@@ -46,6 +48,7 @@ namespace CP ...@@ -46,6 +48,7 @@ namespace CP
initialize () initialize ()
{ {
ANA_CHECK (m_makerTool.retrieve()); ANA_CHECK (m_makerTool.retrieve());
for (auto* handle : {&m_electronsHandle, &m_photonsHandle, for (auto* handle : {&m_electronsHandle, &m_photonsHandle,
&m_muonsHandle, &m_tausHandle, &m_invisHandle}) { &m_muonsHandle, &m_tausHandle, &m_invisHandle}) {
if (*handle) { if (*handle) {
...@@ -54,6 +57,13 @@ namespace CP ...@@ -54,6 +57,13 @@ namespace CP
} }
m_systematicsList.addHandle (m_jetsHandle); m_systematicsList.addHandle (m_jetsHandle);
m_systematicsList.addHandle (m_metHandle); 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()); ANA_CHECK (m_systematicsList.initialize());
return StatusCode::SUCCESS; return StatusCode::SUCCESS;
...@@ -122,6 +132,25 @@ namespace CP ...@@ -122,6 +132,25 @@ namespace CP
ANA_CHECK (m_makerTool->rebuildJetMET (m_jetsKey, m_softTermKey, met.get(), jets, metcore, &metHelper, m_doJetJVT)); 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)); ANA_CHECK (m_metHandle.record (std::move (met), std::move (aux), sys));
return StatusCode::SUCCESS; return StatusCode::SUCCESS;
}); });
......
/*
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;
});
}
}
...@@ -6,8 +6,8 @@ from AnaAlgorithm.DualUseConfig import createAlgorithm, addPrivateTool ...@@ -6,8 +6,8 @@ from AnaAlgorithm.DualUseConfig import createAlgorithm, addPrivateTool
def makeMetAnalysisSequence( dataType, metSuffix, def makeMetAnalysisSequence( dataType, metSuffix,
postfix = '', postfix = '',
useFJVT = True, useFJVT = False,
treatPUJets = True ): treatPUJets = False ):
"""Create a met analysis algorithm sequence """Create a met analysis algorithm sequence
After creating the sequence object, it needs to be configured with a call After creating the sequence object, it needs to be configured with a call
...@@ -60,6 +60,8 @@ def makeMetAnalysisSequence( dataType, metSuffix, ...@@ -60,6 +60,8 @@ def makeMetAnalysisSequence( dataType, metSuffix,
alg.makerTool.DoPFlow = 'PFlow' in metSuffix alg.makerTool.DoPFlow = 'PFlow' in metSuffix
if useFJVT: if useFJVT:
alg.makerTool.JetRejectionDec = 'passFJVT' alg.makerTool.JetRejectionDec = 'passFJVT'
if dataType != "data" :
addPrivateTool( alg, 'systematicsTool', 'met::METSystematicsTool' )
alg.metCore = 'MET_Core_' + metSuffix alg.metCore = 'MET_Core_' + metSuffix
alg.metAssociation = 'METAssoc_' + metSuffix alg.metAssociation = 'METAssoc_' + metSuffix
seq.append( alg, seq.append( alg,
...@@ -72,13 +74,6 @@ def makeMetAnalysisSequence( dataType, metSuffix, ...@@ -72,13 +74,6 @@ def makeMetAnalysisSequence( dataType, metSuffix,
outputPropName = 'met', outputPropName = 'met',
affectingSystematics = '(^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: # Set up the met builder algorithm:
alg = createAlgorithm( 'CP::MetBuilderAlg', 'MetBuilderAlg' + postfix ) alg = createAlgorithm( 'CP::MetBuilderAlg', 'MetBuilderAlg' + postfix )
seq.append( alg, inputPropName = 'met' ) seq.append( alg, inputPropName = 'met' )
......
...@@ -3,10 +3,8 @@ ...@@ -3,10 +3,8 @@
#include <MetAnalysisAlgorithms/MetBuilderAlg.h> #include <MetAnalysisAlgorithms/MetBuilderAlg.h>
#include <MetAnalysisAlgorithms/MetMakerAlg.h> #include <MetAnalysisAlgorithms/MetMakerAlg.h>
#include <MetAnalysisAlgorithms/MetSignificanceAlg.h> #include <MetAnalysisAlgorithms/MetSignificanceAlg.h>
#include <MetAnalysisAlgorithms/MetSystematicsAlg.h>
DECLARE_COMPONENT (CP::MetBuilderAlg) DECLARE_COMPONENT (CP::MetBuilderAlg)
DECLARE_COMPONENT (CP::MetMakerAlg) DECLARE_COMPONENT (CP::MetMakerAlg)
DECLARE_COMPONENT (CP::MetSignificanceAlg) DECLARE_COMPONENT (CP::MetSignificanceAlg)
DECLARE_COMPONENT (CP::MetSystematicsAlg)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment