7#include <unordered_map>
19 SystObjectLinkerAlg ::SystObjectLinkerAlg(
const std::string &
name,
20 ISvcLocator *pSvcLocator)
26 StatusCode SystObjectLinkerAlg ::initialize()
40 return StatusCode::SUCCESS;
43 StatusCode SystObjectLinkerAlg ::execute(
const EventContext&)
const
50 std::unordered_map<std::size_t, const xAOD::IParticleContainer*> systhash_to_container;
53 size_t nominal_hash{SIZE_MAX};
62 if(sys.name().empty()) {nominal_hash = sys.hash();}
66 if (sys_container->
empty()) {
67 ATH_MSG_DEBUG(
"Container for systematic variation '" << sys.name() <<
"' was empty.");
68 systhash_to_container.insert({sys.hash(),
nullptr});
77 systhash_to_container.insert({sys.hash(), full_container});
78 if(full_container == sys_container) {
79 ATH_MSG_VERBOSE(
"The unfiltered container and the input container are the same.");
81 ATH_MSG_DEBUG(
"Read in container with " << sys_container->
size() <<
" elements.");
82 ATH_MSG_DEBUG(
"Traced back to unfiltered container with " << full_container->
size() <<
" elements.");
86 if(nominal_hash==SIZE_MAX) {
88 return StatusCode::FAILURE;
94 if(nom_cont==
nullptr) {
95 ATH_MSG_DEBUG(
"Unable to retrieve the nominal container, will have to assume there are no relevant objects");
96 return StatusCode::SUCCESS;
101 if(sys.hash()==nominal_hash) {
continue;}
103 if(var_cont==
nullptr) {
104 ATH_MSG_ERROR(
"Cannot decorate syst '" << sys.name() <<
"' for obj " << nom_obj->index());
105 ATH_MSG_ERROR(
"Likely the systematics input container was empty after filtering.");
107 return StatusCode::FAILURE;
113 ATH_MSG_VERBOSE(
"Nominal object with pt " << std::setprecision(3) << nom_obj->pt()/1e3 <<
" GeV linked to");
114 ATH_MSG_VERBOSE(
" '" << sys.name() <<
"' varied object with pt " << std::setprecision(3) << var_obj->
pt()/1e3 <<
" GeV.");
118 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
DataVector adapter that acts like it holds const pointers.
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.
size_t index() const
Return the index of this element within its container.
Helper class to provide type-safe access to aux data.
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.
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.