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-2024 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
//
16
// method implementations
17
//
18
19
namespace
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
31
ANA_CHECK
(
makeSelectionWriteAccessor
(
m_selectionDecoration
,
m_selectionAccessor
));
32
33
ANA_CHECK
(
m_particlesHandle
.initialize(
m_systematicsList
));
34
ANA_CHECK
(
m_preselection
.initialize (
m_systematicsList
,
m_particlesHandle
));
35
ANA_CHECK
(
m_systematicsList
.initialize());
36
37
return
StatusCode::SUCCESS;
38
}
39
40
41
42
StatusCode AsgUnionSelectionAlg ::
43
execute (
const
EventContext& ctx)
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, ctx));
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, ctx));
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
AsgUnionSelectionAlg.h
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
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