ATLAS Offline Software
AsgPriorityDecorationAlg.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 
9 
10 
11 namespace 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::AuxElement::Decorator<char> > (m_priorityDecoration);
35 
39 
40  return StatusCode::SUCCESS;
41 }
42 
43 
44 
46 {
47  for (const auto& sys : m_systematicsList.systematicsVector())
48  {
51 
52  for (const xAOD::IParticle *particle : *particles)
53  {
54  bool passed{};
55  for (size_t i{}; i < m_preselections.size(); i++)
56  {
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
CP::AsgPriorityDecorationAlg::m_preselections
SysReadSelectionHandleArray m_preselections
the preselection we apply to our input
Definition: AsgPriorityDecorationAlg.h:37
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
CP::AsgPriorityDecorationAlg::initialize
virtual StatusCode initialize() override
Definition: AsgPriorityDecorationAlg.cxx:14
TrigCompositeUtils::passed
bool passed(DecisionID id, const DecisionIDContainer &idSet)
checks if required decision ID is in the set of IDs in the container
Definition: TrigCompositeUtilsRoot.cxx:117
CP::AsgPriorityDecorationAlg::m_priorities
Gaudi::Property< std::vector< int > > m_priorities
the values of the priorities
Definition: AsgPriorityDecorationAlg.h:47
CP::SysHandleArray::initialize
StatusCode initialize(Args &&...args)
Create and initialize all the sub-handles.
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::AsgPriorityDecorationAlg::m_particlesHandle
SysReadHandle< xAOD::IParticleContainer > m_particlesHandle
particles container handle
Definition: AsgPriorityDecorationAlg.h:42
CP::SysListHandle::systematicsVector
const std::vector< CP::SystematicSet > & systematicsVector() const
the list of systematics to loop over
Definition: SysListHandle.cxx:96
CP::AsgPriorityDecorationAlg::execute
virtual StatusCode execute() override
Definition: AsgPriorityDecorationAlg.cxx:45
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
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
CP::SysReadSelectionHandle::getBool
bool getBool(const SG::AuxElement &element, const CP::SystematicSet &sys) const
get the selection as a bool
CP::AsgPriorityDecorationAlg::m_systematicsList
SysListHandle m_systematicsList
the systematics list we run
Definition: AsgPriorityDecorationAlg.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CP::AsgPriorityDecorationAlg::m_priorityDecorator
std::unique_ptr< const SG::AuxElement::Decorator< char > > m_priorityDecorator
the accessor for m_priorityDecoration
Definition: AsgPriorityDecorationAlg.h:55
CP::SysHandleArray::size
std::size_t size() const noexcept
The number of defined handles.
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
LArG4FSStartPointFilter.particles
list particles
Definition: LArG4FSStartPointFilter.py:84
CP::SysHandleArray::at
HANDLE & at(std::size_t idx)
Retrieve the handle at the specified index.
CP::AsgPriorityDecorationAlg::m_priorityDecoration
Gaudi::Property< std::string > m_priorityDecoration
the decoration for the priority
Definition: AsgPriorityDecorationAlg.h:51
AsgPriorityDecorationAlg.h