ATLAS Offline Software
Loading...
Searching...
No Matches
AsgUnionSelectionAlg.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// includes
9//
10
12
13#include <xAODBase/IParticle.h>
14
15//
16// method implementations
17//
18
19namespace CP
20{
21
22 StatusCode AsgUnionSelectionAlg ::
23 initialize ()
24 {
25 if (m_selectionDecoration.empty())
26 {
27 ANA_MSG_ERROR("Selection decoration can not be empty.");
28 return StatusCode::FAILURE;
29 }
30
32
35 ANA_CHECK (m_systematicsList.initialize());
36
37 return StatusCode::SUCCESS;
38 }
39
40
41
42 StatusCode AsgUnionSelectionAlg ::
43 execute ()
44 {
45 std::vector<bool> selections;
46
47 // first loop through systematics and define if particle passes each of them
48 for (const auto& sys : m_systematicsList.systematicsVector())
49 {
50 const xAOD::IParticleContainer *particles{};
51 ANA_CHECK (m_particlesHandle.retrieve (particles, sys));
52
53 if (selections.empty())
54 {
55 selections.resize(particles->size(), false);
56 }
57 else if (selections.size() != particles->size())
58 {
59 ANA_MSG_ERROR("All input containers should have the same size.");
60 return StatusCode::FAILURE;
61 }
62
63 for (size_t i{}; i < particles->size(); i++)
64 {
65 selections[i] = selections[i] || m_preselection.getBool (*particles->at(i), sys);
66 }
67 }
68
69 // Now decorate the selection decoration
70 // Looping over systematics is needed to ensure all containers are processed
71 for (const auto& sys : m_systematicsList.systematicsVector())
72 {
73 const xAOD::IParticleContainer *particles{};
74 ANA_CHECK (m_particlesHandle.retrieve (particles, sys));
75
76 for (size_t i{}; i < particles->size(); i++)
77 {
78 m_selectionAccessor->setBool (*particles->at(i), selections[i]);
79 }
80 }
81
82 return StatusCode::SUCCESS;
83 }
84
85} // namespace CP
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
#define ANA_CHECK(EXP)
check whether the given expression was successful
SysReadSelectionHandle m_preselection
the preselection we apply to our input
Gaudi::Property< std::string > m_selectionDecoration
the decoration of the selection
std::unique_ptr< ISelectionWriteAccessor > m_selectionAccessor
the accessor for m_selectionDecoration
SysListHandle m_systematicsList
the systematics list we run and have containers
SysReadHandle< xAOD::IParticleContainer > m_particlesHandle
the particle continer we run on
Select isolated Photons, Electrons and Muons.
StatusCode makeSelectionWriteAccessor(const std::string &name, std::unique_ptr< ISelectionWriteAccessor > &accessor, bool defaultToChar)
Produces a simple ISelectionWriteAccessor accessing the given decoration.
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.