ATLAS Offline Software
EventDecoratorAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 
8 //
9 // includes
10 //
12 
13 // /// Anonymous namespace for helpers
14 // namespace {
15 // const static SG::ConstAuxElement::ConstAccessor<unsigned int> accRRN("RandomRunNumber");
16 // const static SG::ConstAuxElement::Decorator<unsigned int> decRRN("RandomRunNumber");
17 // const static SG::ConstAuxElement::Decorator<unsigned int> decRLBN("RandomLumiBlockNumber");
18 // const static SG::ConstAuxElement::Decorator<uint64_t> decHash("PRWHash");
19 // }
20 
21 //
22 // method implementations
23 //
24 
25 namespace CP
26 {
27 
29  initialize ()
30  {
31  for (auto& [name, value] : m_uint32Decorations)
32  {
33  ANA_MSG_INFO ("Adding uint32_t decoration " << name << " with value " << value << " to EventInfo");
34  m_decFunctions.push_back([dec = SG::AuxElement::Decorator<uint32_t>(name), value](const xAOD::EventInfo& ei) { dec(ei) = value; });
35  }
36 
39  return StatusCode::SUCCESS;
40  }
41 
42 
43 
45  execute ()
46  {
47  // Take care of the weight (which is the only thing depending on systematics)
48  for (const auto& sys : m_systematicsList.systematicsVector())
49  {
50  const xAOD::EventInfo* systEvtInfo = nullptr;
51  ANA_CHECK( m_eventInfoHandle.retrieve(systEvtInfo, sys));
52  for (const auto& decFunc : m_decFunctions)
53  {
54  decFunc(*systEvtInfo);
55  }
56  };
57  return StatusCode::SUCCESS;
58  }
59 }
CP::EventDecoratorAlg::initialize
StatusCode initialize() override
Definition: EventDecoratorAlg.cxx:29
athena.value
value
Definition: athena.py:124
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
CP::EventDecoratorAlg::m_eventInfoHandle
CP::SysReadHandle< xAOD::EventInfo > m_eventInfoHandle
the name of the event info object
Definition: EventDecoratorAlg.h:40
CP::SysListHandle::systematicsVector
const std::vector< CP::SystematicSet > & systematicsVector() const
the list of systematics to loop over
Definition: SysListHandle.cxx:96
EventDecoratorAlg.h
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
CP::SysListHandle::initialize
::StatusCode initialize()
intialize this property
Definition: SysListHandle.cxx:69
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:59
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ANA_MSG_INFO
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:290
CP::EventDecoratorAlg::m_systematicsList
SysListHandle m_systematicsList
the systematics list we run
Definition: EventDecoratorAlg.h:37
CP::EventDecoratorAlg::m_uint32Decorations
Gaudi::Property< std::map< std::string, uint32_t > > m_uint32Decorations
the uint32_t decorations to add
Definition: EventDecoratorAlg.h:43
CP::EventDecoratorAlg::m_decFunctions
std::vector< std::function< void(const xAOD::EventInfo &)> > m_decFunctions
the functions to add decorations
Definition: EventDecoratorAlg.h:46
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
CP::EventDecoratorAlg::execute
StatusCode execute() override
Definition: EventDecoratorAlg.cxx:45