ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
Algorithms
AsgAnalysisAlgorithms
Root
AsgUnionSelectionAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
7
//
8
// includes
9
//
10
11
#include <
AsgAnalysisAlgorithms/AsgUnionSelectionAlg.h
>
12
13
#include <
xAODBase/IParticle.h
>
14
15
#include <algorithm>
16
17
//
18
// method implementations
19
//
20
21
namespace
CP
22
{
23
24
StatusCode AsgUnionSelectionAlg ::
25
initialize ()
26
{
27
if
(
m_selectionDecoration
.empty())
28
{
29
ANA_MSG_ERROR
(
"Selection decoration can not be empty."
);
30
return
StatusCode::FAILURE;
31
}
32
33
ANA_CHECK
(
makeSelectionWriteAccessor
(
m_selectionDecoration
,
m_selectionAccessor
));
34
35
ANA_CHECK
(
m_particlesHandle
.initialize(
m_systematicsList
));
36
ANA_CHECK
(
m_preselection
.initialize (
m_systematicsList
,
m_particlesHandle
));
37
ANA_CHECK
(
m_systematicsList
.initialize());
38
39
return
StatusCode::SUCCESS;
40
}
41
42
43
44
StatusCode AsgUnionSelectionAlg ::
45
execute (
const
EventContext& ctx)
46
{
47
std::vector<bool> selections;
48
49
// first loop through systematics and define if particle passes each of them
50
for
(
const
auto
& sys :
m_systematicsList
.systematicsVector())
51
{
52
const
xAOD::IParticleContainer
*particles{};
53
ANA_CHECK
(
m_particlesHandle
.retrieve (particles, sys, ctx));
54
55
if
(selections.empty())
56
{
57
selections.resize(particles->size(),
false
);
58
}
59
else
if
(selections.size() != particles->size())
60
{
61
ANA_MSG_ERROR
(
"All input containers should have the same size."
);
62
return
StatusCode::FAILURE;
63
}
64
65
for
(
size_t
i{}; i < particles->size(); i++)
66
{
67
selections[i] = selections[i] ||
m_preselection
.getBool (*(*particles)[i], sys);
68
}
69
}
70
71
// Now decorate the selection decoration
72
// Looping over systematics is needed to ensure all containers are processed
73
std::vector<const xAOD::IParticleContainer*> decorated;
74
for
(
const
auto
& sys :
m_systematicsList
.systematicsVector())
75
{
76
const
xAOD::IParticleContainer
*particles{};
77
ANA_CHECK
(
m_particlesHandle
.retrieve (particles, sys, ctx));
78
79
if
(std::find (decorated.begin(), decorated.end(), particles) != decorated.end())
80
continue
;
81
decorated.push_back (particles);
82
83
for
(
size_t
i{}; i < particles->size(); i++)
84
{
85
m_selectionAccessor
->setBool (*(*particles)[i], selections[i]);
86
}
87
}
88
89
return
StatusCode::SUCCESS;
90
}
91
92
}
// namespace CP
AsgUnionSelectionAlg.h
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg,...)
Macro printing error messages.
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:295
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:325
IParticle.h
CP::AsgUnionSelectionAlg::m_preselection
SysReadSelectionHandle m_preselection
the preselection we apply to our input
Definition
AsgUnionSelectionAlg.h:45
CP::AsgUnionSelectionAlg::m_selectionDecoration
Gaudi::Property< std::string > m_selectionDecoration
the decoration of the selection
Definition
AsgUnionSelectionAlg.h:50
CP::AsgUnionSelectionAlg::m_selectionAccessor
std::unique_ptr< ISelectionWriteAccessor > m_selectionAccessor
the accessor for m_selectionDecoration
Definition
AsgUnionSelectionAlg.h:54
CP::AsgUnionSelectionAlg::m_systematicsList
SysListHandle m_systematicsList
the systematics list we run and have containers
Definition
AsgUnionSelectionAlg.h:36
CP::AsgUnionSelectionAlg::m_particlesHandle
SysReadHandle< xAOD::IParticleContainer > m_particlesHandle
the particle continer we run on
Definition
AsgUnionSelectionAlg.h:40
CP
Select isolated Photons, Electrons and Muons.
Definition
Control/xAODRootAccess/xAODRootAccess/TEvent.h:27
CP::makeSelectionWriteAccessor
StatusCode makeSelectionWriteAccessor(const std::string &name, std::unique_ptr< ISelectionWriteAccessor > &accessor, bool defaultToChar)
Produces a simple ISelectionWriteAccessor accessing the given decoration.
Definition
ISelectionAccessor.cxx:169
xAOD::IParticleContainer
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.
Definition
xAOD/xAODBase/xAODBase/IParticleContainer.h:32
Generated on
for ATLAS Offline Software by
1.17.0