ATLAS Offline Software
Loading...
Searching...
No Matches
AsgPriorityDecorationAlg.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
9
10
11namespace CP
12{
13
15{
16 if (m_priorityDecoration.empty())
17 {
18 ANA_MSG_ERROR ("Priority decoration name should not be empty.");
19 return StatusCode::FAILURE;
20 }
21
22 if (m_priorities.size() != m_preselections.size())
23 {
24 ANA_MSG_ERROR ("Preselections and priority values need to be of the same size.");
25 return StatusCode::FAILURE;
26 }
27
28 if (!std::is_sorted(std::rbegin(m_priorities.value()), std::rend(m_priorities.value())))
29 {
30 ANA_MSG_ERROR ("Priorities need to be provided in reverse order.");
31 return StatusCode::FAILURE;
32 }
33
34 m_priorityDecorator = std::make_unique<SG::Decorator<char> > (m_priorityDecoration);
35
38 ANA_CHECK (m_systematicsList.initialize());
39
40 return StatusCode::SUCCESS;
41}
42
43
44
46{
47 for (const auto& sys : m_systematicsList.systematicsVector())
48 {
49 const xAOD::IParticleContainer *particles{};
50 ANA_CHECK(m_particlesHandle.retrieve(particles, sys));
51
52 for (const xAOD::IParticle *particle : *particles)
53 {
54 bool passed{};
55 for (size_t i{}; i < m_preselections.size(); i++)
56 {
57 if (m_preselections.at(i).getBool (*particle, sys))
58 {
59 (*m_priorityDecorator)(*particle) = m_priorities[i];
60 passed = true;
61 break;
62 }
63 }
64
65 // decorate default priority
66 if (!passed)
67 {
68 (*m_priorityDecorator)(*particle) = 0;
69 }
70 }
71 }
72 return StatusCode::SUCCESS;
73}
74
75} // namespace CP
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
#define ANA_CHECK(EXP)
check whether the given expression was successful
bool passed(DecisionID id, const DecisionIDContainer &)
checks if required decision ID is in the set of IDs in the container
Gaudi::Property< std::vector< int > > m_priorities
the values of the priorities
SysListHandle m_systematicsList
the systematics list we run
virtual StatusCode execute() override
virtual StatusCode initialize() override
SysReadSelectionHandleArray m_preselections
the preselection we apply to our input
std::unique_ptr< const SG::Decorator< char > > m_priorityDecorator
the accessor for m_priorityDecoration
Gaudi::Property< std::string > m_priorityDecoration
the decoration for the priority
SysReadHandle< xAOD::IParticleContainer > m_particlesHandle
particles container handle
Class providing the definition of the 4-vector interface.
Select isolated Photons, Electrons and Muons.
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.