ATLAS Offline Software
SysTruthWeightAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 //
8 // includes
9 //
10 
11 // EDM include(s):
13 
14 // Local include(s):
16 
17 //
18 // method implementations
19 //
20 
21 namespace CP
22 {
23 SysTruthWeightAlg::SysTruthWeightAlg(const std::string &name, ISvcLocator *pSvcLocator)
24  : AnaAlgorithm(name, pSvcLocator), m_sysTruthWeightTool("PMGTools::PMGHFProductionFractionTool", this)
25 {
26  // The truth particle container
27  declareProperty("TruthParticleContainer", m_truthParticleContainer = "TruthParticles");
28 
29  // The production fraction rw tool
30  declareProperty("sysTruthWeightTool", m_sysTruthWeightTool);
31 }
32 
34 {
35  if (m_decoration.empty())
36  {
37  ANA_MSG_ERROR("no decoration name set");
38  return StatusCode::FAILURE;
39  }
40 
41  ANA_CHECK(m_sysTruthWeightTool.retrieve());
46 
47  return StatusCode::SUCCESS;
48 }
49 
51 {
52 
53  // Retreive the truth particles container
54  const xAOD::TruthParticleContainer *truthParticles = nullptr;
56 
57  for (const auto &sys : m_systematicsList.systematicsVector())
58  {
59  const xAOD::EventInfo *eventInfo = nullptr;
60  ANA_CHECK(m_eventInfoHandle.retrieve(eventInfo, sys));
61 
62  m_decoration.set(*eventInfo, m_sysTruthWeightTool->getSysWeight(truthParticles, sys), sys);
63  }
64 
65  // return
66  return StatusCode::SUCCESS;
67 }
68 } // namespace CP
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
CP::SysWriteDecorHandle::set
void set(const SG::AuxElement &object, const T &value, const CP::SystematicSet &sys) const
set the object decoration for the given systematic
CP::SysTruthWeightAlg::execute
StatusCode execute() override
Definition: SysTruthWeightAlg.cxx:50
TruthParticleContainer.h
CP::SysListHandle::addSystematics
StatusCode addSystematics(const CP::SystematicSet &recommended, const CP::SystematicSet &affecting)
register a set of affecting variables for the current algorithm (usually obtained from an CP::ISystem...
Definition: SysListHandle.cxx:48
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
CP::SysTruthWeightAlg::m_decoration
SysWriteDecorHandle< float > m_decoration
the decoration for the truth weights
Definition: SysTruthWeightAlg.h:51
CP::SysListHandle::systematicsVector
const std::vector< CP::SystematicSet > & systematicsVector() const
the list of systematics to loop over
Definition: SysListHandle.cxx:96
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:49
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
CP::SysListHandle::initialize
::StatusCode initialize()
intialize this property
Definition: SysListHandle.cxx:69
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CP::SysWriteDecorHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle, const ISysHandleBase &objectHandle)
initialize this handle
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition: AthCommonDataStore.h:145
CP::SysTruthWeightAlg::m_truthParticleContainer
std::string m_truthParticleContainer
the truth particle container to use for the calculation
Definition: SysTruthWeightAlg.h:34
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
CP::SysTruthWeightAlg::SysTruthWeightAlg
SysTruthWeightAlg(const std::string &name, ISvcLocator *pSvcLocator)
the standard constructor
Definition: SysTruthWeightAlg.cxx:23
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
CP::SysWriteDecorHandle::empty
virtual bool empty() const noexcept override
whether we have a name configured
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
CP::SysTruthWeightAlg::m_sysTruthWeightTool
ToolHandle< PMGTools::ISysTruthWeightTool > m_sysTruthWeightTool
the tool
Definition: SysTruthWeightAlg.h:38
CP::SysTruthWeightAlg::initialize
StatusCode initialize() override
Definition: SysTruthWeightAlg.cxx:33
CP::SysTruthWeightAlg::m_eventInfoHandle
SysReadHandle< xAOD::EventInfo > m_eventInfoHandle
the event collection we run on
Definition: SysTruthWeightAlg.h:46
SysTruthWeightAlg.h
CP::SysTruthWeightAlg::m_systematicsList
SysListHandle m_systematicsList
the systematics list we run
Definition: SysTruthWeightAlg.h:42
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30