7#include <unordered_map>
18 SystObjectLinkerAlg ::SystObjectLinkerAlg(
const std::string &
name,
19 ISvcLocator *pSvcLocator)
25 StatusCode SystObjectLinkerAlg ::initialize()
39 return StatusCode::SUCCESS;
42 StatusCode SystObjectLinkerAlg ::execute(
const EventContext&)
const
49 std::unordered_map<std::size_t, const xAOD::IParticleContainer*> systhash_to_container;
52 size_t nominal_hash{SIZE_MAX};
61 if(sys.name().empty()) {nominal_hash = sys.hash();}
65 if (sys_container->
empty()) {
66 ATH_MSG_DEBUG(
"Container for systematic variation '" << sys.name() <<
"' was empty.");
67 systhash_to_container.insert({sys.hash(),
nullptr});
76 systhash_to_container.insert({sys.hash(), full_container});
77 if(full_container == sys_container) {
78 ATH_MSG_VERBOSE(
"The unfiltered container and the input container are the same.");
80 ATH_MSG_DEBUG(
"Read in container with " << sys_container->
size() <<
" elements.");
81 ATH_MSG_DEBUG(
"Traced back to unfiltered container with " << full_container->
size() <<
" elements.");
85 if(nominal_hash==SIZE_MAX) {
87 return StatusCode::FAILURE;
93 if(nom_cont==
nullptr) {
94 ATH_MSG_DEBUG(
"Unable to retrieve the nominal container, will have to assume there are no relevant objects");
95 return StatusCode::SUCCESS;
100 if(sys.hash()==nominal_hash) {
continue;}
102 if(var_cont==
nullptr) {
103 ATH_MSG_ERROR(
"Cannot decorate syst '" << sys.name() <<
"' for obj " << nom_obj->index());
104 ATH_MSG_ERROR(
"Likely the systematics input container was empty after filtering.");
106 return StatusCode::FAILURE;
112 ATH_MSG_VERBOSE(
"Nominal object with pt " << std::setprecision(3) << nom_obj->pt()/1e3 <<
" GeV linked to");
113 ATH_MSG_VERBOSE(
" '" << sys.name() <<
"' varied object with pt " << std::setprecision(3) << var_obj->
pt()/1e3 <<
" GeV.");
117 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
ElementLink< xAOD::IParticleContainer > iplink_t
static const SG::Decorator< iplink_t > dec_nominalObject("nominalObjectLink")
CP::SysReadHandle< xAOD::IParticleContainer > m_inputHandle
Setup syst-aware input container handles.
CP::SysListHandle m_systematicsList
We use default finalize() – this is for cleanup, and we don't do any.
CP::SysWriteDecorHandle< ElementLink< xAOD::IParticleContainer > > m_syst_link_decor
Setup sys-aware output decorations.
const T * front() const
Access the first element in the collection as an rvalue.
size_type size() const noexcept
Returns the number of elements in the collection.
bool empty() const noexcept
Returns true if the collection is empty.
AnaReentrantAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
constructor with parameters
ElementLink implementation for ROOT usage.
Class providing the definition of the 4-vector interface.
virtual double pt() const =0
The transverse momentum ( ) of the particle.
Select isolated Photons, Electrons and Muons.
ElementLink< xAOD::IParticleContainer > iplink_t
This module defines the arguments passed from the BATCH driver to the BATCH worker.
SG::Decorator< T, ALLOC > Decorator
Helper class to provide type-safe access to aux data, specialized for JaggedVecElt.
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.