ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
DerivationFramework
DerivationFrameworkEGamma
src
EGSelectionToolWrapper.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// Author: Giovanni Marchiori (giovanni.marchiori@cern.ch)
6
//
7
8
#include "
DerivationFrameworkEGamma/EGSelectionToolWrapper.h
"
9
#include "
PATCore/AcceptData.h
"
10
#include "
xAODBase/IParticleContainer.h
"
11
#include "
xAODBase/IParticleHelpers.h
"
12
#include "
xAODEgamma/EgammaContainer.h
"
13
#include "
xAODEgamma/Electron.h
"
14
#include "
xAODEgamma/Photon.h
"
15
16
namespace
DerivationFramework
{
17
18
StatusCode
19
EGSelectionToolWrapper::initialize
()
20
{
21
ATH_CHECK
(
m_tool
.retrieve());
22
23
ATH_CHECK
(
m_ContainerName
.initialize());
24
ATH_CHECK
(
m_fudgedContainerName
.initialize(!
m_fudgedContainerName
.empty()));
25
26
ATH_CHECK
(
m_decoratorPass
.initialize());
27
ATH_CHECK
(
m_decoratorIsEM
.initialize());
28
29
return
StatusCode::SUCCESS;
30
}
31
32
StatusCode
33
EGSelectionToolWrapper::addBranches
(
const
EventContext& ctx)
const
34
{
35
// retrieve container
36
SG::ReadHandle<xAOD::EgammaContainer>
particles;
37
if
(!
m_fudgedContainerName
.empty()){
38
SG::ReadHandle<xAOD::EgammaContainer>
fudged{
m_fudgedContainerName
, ctx };
39
particles = std::move(fudged);
40
}
else
{
41
SG::ReadHandle<xAOD::EgammaContainer>
egammas{
m_ContainerName
, ctx };
42
particles = std::move(egammas);
43
}
44
45
// Decorators
46
SG::WriteDecorHandle<xAOD::EgammaContainer, char>
decoratorPass{
47
m_decoratorPass
, ctx
48
};
49
SG::WriteDecorHandle<xAOD::EgammaContainer, unsigned int>
decoratorIsEM{
50
m_decoratorIsEM
, ctx
51
};
52
53
for
(
const
auto
&
egamma
: *particles) {
54
// compute the output of the selector with the fudged object
55
asg::AcceptData
theAccept(
m_tool
->accept(ctx,
egamma
));
56
// this should work for both the
57
// cut-based and the LH selectors
58
unsigned
int
isEM =
59
static_cast<
unsigned
int
>
(theAccept.
getCutResultInvertedBitSet
()
60
.to_ulong());
61
62
// decorate the original object
63
const
xAOD::IParticle
* original =
m_fudgedContainerName
.empty() ?
64
egamma
:
xAOD::getOriginalObject
(*
egamma
);
65
if
(
m_cut
==
""
) {
66
bool
pass_selection =
static_cast<
bool
>
(theAccept);
67
decoratorPass(*original) = pass_selection ? 1 : 0;
68
}
else
{
69
decoratorPass(*original) = theAccept.
getCutResult
(
m_cut
) ? 1 : 0;
70
}
71
decoratorIsEM(*original) = isEM;
72
}
73
74
return
StatusCode::SUCCESS;
75
}
76
}
AcceptData.h
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
EGSelectionToolWrapper.h
EgammaContainer.h
Electron.h
Photon.h
IParticleHelpers.h
DerivationFramework::EGSelectionToolWrapper::initialize
virtual StatusCode initialize() override final
Definition
EGSelectionToolWrapper.cxx:19
DerivationFramework::EGSelectionToolWrapper::m_tool
ToolHandle< IAsgEGammaIsEMSelector > m_tool
Definition
EGSelectionToolWrapper.h:35
DerivationFramework::EGSelectionToolWrapper::m_cut
Gaudi::Property< std::string > m_cut
Definition
EGSelectionToolWrapper.h:52
DerivationFramework::EGSelectionToolWrapper::m_decoratorIsEM
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_decoratorIsEM
Definition
EGSelectionToolWrapper.h:50
DerivationFramework::EGSelectionToolWrapper::m_ContainerName
SG::ReadHandleKey< xAOD::EgammaContainer > m_ContainerName
Definition
EGSelectionToolWrapper.h:42
DerivationFramework::EGSelectionToolWrapper::m_decoratorPass
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_decoratorPass
Definition
EGSelectionToolWrapper.h:48
DerivationFramework::EGSelectionToolWrapper::m_fudgedContainerName
SG::ReadHandleKey< xAOD::EgammaContainer > m_fudgedContainerName
Definition
EGSelectionToolWrapper.h:44
DerivationFramework::EGSelectionToolWrapper::addBranches
virtual StatusCode addBranches(const EventContext &ctx) const override final
Definition
EGSelectionToolWrapper.cxx:33
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition
StoreGate/StoreGate/WriteDecorHandle.h:100
asg::AcceptData
Definition
AcceptData.h:31
asg::AcceptData::getCutResultInvertedBitSet
std::bitset< NBITS > getCutResultInvertedBitSet() const
Get an inverted bitset of the cut result.
Definition
AcceptData.h:120
asg::AcceptData::getCutResult
bool getCutResult(std::string_view cutName) const
Get the result of a cut, based on the cut name (safer).
Definition
AcceptData.h:99
egamma
elec/gamma data class.
Definition
egamma.h:59
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition
Event/xAOD/xAODBase/xAODBase/IParticle.h:41
DerivationFramework
THE reconstruction tool.
Definition
CascadeTools.h:16
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition
PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
xAOD::getOriginalObject
const IParticle * getOriginalObject(const IParticle ©)
This function can be used to conveniently get a pointer back to the original object from which a copy...
Definition
IParticleHelpers.cxx:140
IParticleContainer.h
Generated on
for ATLAS Offline Software by
1.17.0