ATLAS Offline Software
Loading...
Searching...
No Matches
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
21namespace CP
22{
23SysTruthWeightAlg::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
45 ANA_CHECK(m_systematicsList.initialize());
46
47 return StatusCode::SUCCESS;
48}
49
51{
52
53 // Retreive the truth particles container
54 const xAOD::TruthParticleContainer *truthParticles = nullptr;
55 ANA_CHECK(evtStore()->retrieve(truthParticles, m_truthParticleContainer));
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
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
#define ANA_CHECK(EXP)
check whether the given expression was successful
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
std::string m_truthParticleContainer
the truth particle container to use for the calculation
SysTruthWeightAlg(const std::string &name, ISvcLocator *pSvcLocator)
the standard constructor
ToolHandle< PMGTools::ISysTruthWeightTool > m_sysTruthWeightTool
the tool
StatusCode initialize() override
StatusCode execute() override
SysListHandle m_systematicsList
the systematics list we run
SysWriteDecorHandle< float > m_decoration
the decoration for the truth weights
SysReadHandle< xAOD::EventInfo > m_eventInfoHandle
the event collection we run on
AnaAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
constructor with parameters
Select isolated Photons, Electrons and Muons.
EventInfo_v1 EventInfo
Definition of the latest event info version.
TruthParticleContainer_v1 TruthParticleContainer
Declare the latest version of the truth particle container.