ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
Algorithms
AsgAnalysisAlgorithms
Root
CopyNominalSelectionAlg.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
9
//
10
// includes
11
//
12
13
#include <
AsgAnalysisAlgorithms/CopyNominalSelectionAlg.h
>
14
15
//
16
// method implementations
17
//
18
19
namespace
CP
20
{
21
StatusCode CopyNominalSelectionAlg ::
22
initialize ()
23
{
24
ANA_CHECK
(
m_particlesHandle
.initialize (
m_systematicsList
));
25
ANA_CHECK
(
m_preselection
.initialize (
m_systematicsList
,
m_particlesHandle
,
SG::AllowEmpty
));
26
ANA_CHECK
(
m_selectionHandle
.initialize (
m_systematicsList
,
m_particlesHandle
));
27
ANA_CHECK
(
m_systematicsList
.initialize());
28
29
bool
hasNominal =
false
;
30
for
(
const
auto
& sys :
m_systematicsList
.systematicsVector())
31
hasNominal |= sys.empty();
32
if
(!hasNominal) {
33
ANA_MSG_ERROR
(
"nominal systematic not in systematics list, cannot copy nominal selection"
);
34
return
StatusCode::FAILURE;
35
}
36
37
ANA_CHECK
(
makeSelectionReadAccessor
(
m_selectionHandle
.getSelection(),
m_readAccessor
));
38
ANA_CHECK
(
m_readAccessor
->fillSystematics (
m_systematicsList
.service(),
m_systematicsList
.systematicsVector(),
m_particlesHandle
));
39
40
return
StatusCode::SUCCESS;
41
}
42
43
44
45
StatusCode CopyNominalSelectionAlg ::
46
execute (
const
EventContext& ctx)
47
{
48
static
const
SystematicSet
emptySys;
49
const
xAOD::IParticleContainer
*nominal =
nullptr
;
50
ANA_CHECK
(
m_particlesHandle
.retrieve (nominal, emptySys, ctx));
51
52
for
(
const
auto
& sys :
m_systematicsList
.systematicsVector())
53
{
54
if
(sys.empty())
continue
;
55
56
const
xAOD::IParticleContainer
*particles =
nullptr
;
57
ANA_CHECK
(
m_particlesHandle
.retrieve (particles, sys, ctx));
58
if
(particles->size() != nominal->
size
())
59
{
60
ANA_MSG_ERROR
(
"systematic container "
<< sys.name() <<
" has a different number "
61
"of objects than nominal, can't copy selections!"
);
62
return
StatusCode::FAILURE;
63
}
64
65
for
(std::size_t
index
= 0u;
index
!= particles->size(); ++
index
)
66
{
67
const
xAOD::IParticle
*particle = particles->at (
index
);
68
if
(
m_preselection
.getBool (*particle, sys))
69
{
70
bool
passedNominal =
m_readAccessor
->getBool (*nominal->
at
(
index
), &emptySys);
71
m_selectionHandle
.setBool (*particle, passedNominal, sys);
72
}
73
else
74
{
75
m_selectionHandle
.setBool (*particle,
false
, sys);
76
}
77
}
78
}
79
80
return
StatusCode::SUCCESS;
81
}
82
}
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
CopyNominalSelectionAlg.h
CP::CopyNominalSelectionAlg::m_preselection
SysReadSelectionHandle m_preselection
the preselection we apply to our input
Definition
CopyNominalSelectionAlg.h:64
CP::CopyNominalSelectionAlg::m_selectionHandle
SysWriteSelectionHandle m_selectionHandle
the decoration for the asg selection
Definition
CopyNominalSelectionAlg.h:69
CP::CopyNominalSelectionAlg::m_particlesHandle
SysReadHandle< xAOD::IParticleContainer > m_particlesHandle
the particle continer we run on
Definition
CopyNominalSelectionAlg.h:59
CP::CopyNominalSelectionAlg::m_readAccessor
std::unique_ptr< ISelectionReadAccessor > m_readAccessor
the accessor we use
Definition
CopyNominalSelectionAlg.h:74
CP::CopyNominalSelectionAlg::m_systematicsList
SysListHandle m_systematicsList
the systematics list we run
Definition
CopyNominalSelectionAlg.h:55
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition
SystematicSet.h:31
DataVector::at
const T * at(size_type n) const
Access an element, as an rvalue.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
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:27
CP::makeSelectionReadAccessor
StatusCode makeSelectionReadAccessor(const std::string &expr, std::unique_ptr< ISelectionReadAccessor > &accessor, bool defaultToChar)
make the ISelectionReadAccessor for the given name
Definition
ISelectionAccessor.cxx:53
SG::AllowEmpty
@ AllowEmpty
Definition
StoreGate/StoreGate/VarHandleKey.h:29
index
Definition
index.py:1
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