ATLAS Offline Software
Loading...
Searching...
No Matches
PhysicsAnalysis
DerivationFramework
DerivationFrameworkTools
src
AsgSelectionToolWrapper.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// Author: James Catmore (james.catmore@cern.ch)
6
7
#include "
DerivationFrameworkTools/AsgSelectionToolWrapper.h
"
8
#include "
PATCore/AcceptData.h
"
9
#include "
StoreGate/ReadHandle.h
"
10
#include "
StoreGate/WriteDecorHandle.h
"
11
12
13
namespace
DerivationFramework
{
14
15
StatusCode
AsgSelectionToolWrapper::initialize
() {
16
ATH_CHECK
(
m_tool
.retrieve());
17
ATH_CHECK
(
m_containerKey
.initialize());
18
ATH_CHECK
(
m_decorKey
.initialize());
19
return
StatusCode::SUCCESS;
20
}
21
22
23
24
StatusCode
AsgSelectionToolWrapper::addBranches
(
const
EventContext& ctx)
const
25
{
26
// retrieve container
27
28
SG::WriteDecorHandle<xAOD::IParticleContainer, char>
decorator (
m_decorKey
, ctx);
29
if
( ! decorator.isValid() ) {
30
ATH_MSG_ERROR
(
"Couldn't retrieve IParticles with key: "
<<
m_containerKey
.fullKey() );
31
return
StatusCode::FAILURE;
32
}
33
34
// Write mask for each element and record to SG for subsequent selection
35
for
(
const
xAOD::IParticle
* part : *decorator) {
36
auto
theAccept =
m_tool
->accept(part);
// asg::AcceptData or TAccept
37
if
(
m_cut
.empty()){
38
decorator(*part) =
true
&& theAccept;
39
}
else
{
40
decorator(*part) =
true
&& theAccept.getCutResult(
m_cut
);
41
}
42
}
43
44
return
StatusCode::SUCCESS;
45
}
46
}
AcceptData.h
AsgSelectionToolWrapper.h
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ReadHandle.h
Handle class for reading from StoreGate.
WriteDecorHandle.h
Handle class for adding a decoration to an object.
DerivationFramework::AsgSelectionToolWrapper::m_containerKey
SG::ReadHandleKey< xAOD::IParticleContainer > m_containerKey
Definition
AsgSelectionToolWrapper.h:29
DerivationFramework::AsgSelectionToolWrapper::addBranches
virtual StatusCode addBranches(const EventContext &ctx) const override final
Definition
AsgSelectionToolWrapper.cxx:24
DerivationFramework::AsgSelectionToolWrapper::m_decorKey
SG::WriteDecorHandleKey< xAOD::IParticleContainer > m_decorKey
Definition
AsgSelectionToolWrapper.h:30
DerivationFramework::AsgSelectionToolWrapper::m_cut
Gaudi::Property< std::string > m_cut
Definition
AsgSelectionToolWrapper.h:28
DerivationFramework::AsgSelectionToolWrapper::m_tool
PublicToolHandle< IAsgSelectionTool > m_tool
Definition
AsgSelectionToolWrapper.h:27
DerivationFramework::AsgSelectionToolWrapper::initialize
virtual StatusCode initialize() override final
Definition
AsgSelectionToolWrapper.cxx:15
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition
StoreGate/StoreGate/WriteDecorHandle.h:100
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition
Event/xAOD/xAODBase/xAODBase/IParticle.h:41
DerivationFramework
THE reconstruction tool.
Definition
ParticleSortingAlg.h:24
Generated on
for ATLAS Offline Software by
1.14.0