ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
RecoTools
ParticlesInConeTools
src
TruthParticlesInConeTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
// TruthParticlesInConeTool
7
//
8
// (c) ATLAS software
10
11
#include "
TruthParticlesInConeTool.h
"
12
13
namespace
xAOD
{
14
15
TruthParticlesInConeTool::TruthParticlesInConeTool
(
const
std::string&
type
,
16
const
std::string&
name
,
17
const
IInterface* parent)
18
:
AthAlgTool
(
type
,
name
, parent)
19
{
20
declareInterface<ITruthParticlesInConeTool>(
this
);
21
}
22
23
24
StatusCode
25
TruthParticlesInConeTool::initialize
()
26
{
27
ATH_CHECK
(
m_truthParticleLocation
.initialize());
28
const
std::string tableName =
name
() +
"LookUpTable"
;
29
m_LookUpTableCacheRead
= tableName;
30
m_LookUpTableCacheWrite
= tableName;
31
ATH_CHECK
(
m_LookUpTableCacheRead
.initialize());
32
ATH_CHECK
(
m_LookUpTableCacheWrite
.initialize());
33
return
StatusCode::SUCCESS;
34
}
35
36
const
TruthParticlesInConeTool::LookUpTable
*
37
TruthParticlesInConeTool::getTable
(
const
EventContext& ctx)
const
38
{
39
SG::ReadHandle<LookUpTable>
rh(
m_LookUpTableCacheRead
, ctx);
40
if
(rh.
isValid
()) {
41
return
&*rh;
42
}
43
SG::ReadHandle<TruthParticleContainer>
truthParticles(
m_truthParticleLocation
,
44
ctx);
45
if
(!truthParticles.
isValid
()) {
46
ATH_MSG_ERROR
(
"Could not open a TruthParticle container with key "
47
<<
m_truthParticleLocation
.key());
48
return
nullptr
;
49
}
50
auto
lut = std::make_unique<LookUpTable>();
51
lut->init(*truthParticles);
52
SG::WriteHandle<LookUpTable>
wh(
m_LookUpTableCacheWrite
, ctx);
53
return
wh.put(std::move(lut),
true
);
54
}
55
56
bool
57
TruthParticlesInConeTool::particlesInCone
(
58
const
EventContext& ctx,
59
float
eta
,
60
float
phi
,
61
float
dr,
62
std::vector<const TruthParticle*>& output)
const
63
{
65
const
LookUpTable
* lut =
getTable
(ctx);
66
return
lut->iParticlesInCone(
eta
,
phi
, dr, output);
67
}
68
}
// end of namespace
eta
Scalar eta() const
pseudorapidity method
Definition
AmgMatrixBasePlugin.h:83
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:47
TruthParticlesInConeTool.h
AthAlgTool::AthAlgTool
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Definition
AthAlgTool.cxx:16
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
xAOD::TruthParticlesInConeTool::m_LookUpTableCacheWrite
SG::WriteHandleKey< LookUpTable > m_LookUpTableCacheWrite
Definition
TruthParticlesInConeTool.h:57
xAOD::TruthParticlesInConeTool::TruthParticlesInConeTool
TruthParticlesInConeTool(const std::string &type, const std::string &name, const IInterface *parent)
constructor
Definition
TruthParticlesInConeTool.cxx:15
xAOD::TruthParticlesInConeTool::getTable
const LookUpTable * getTable(const EventContext &ctx) const
Definition
TruthParticlesInConeTool.cxx:37
xAOD::TruthParticlesInConeTool::m_truthParticleLocation
SG::ReadHandleKey< TruthParticleContainer > m_truthParticleLocation
Truth Particle collection name.
Definition
TruthParticlesInConeTool.h:50
xAOD::TruthParticlesInConeTool::particlesInCone
virtual bool particlesInCone(const EventContext &ctx, float eta, float phi, float dr, std::vector< const TruthParticle * > &output) const override final
ITruthParticlesInConeTool interface.
Definition
TruthParticlesInConeTool.cxx:57
xAOD::TruthParticlesInConeTool::m_LookUpTableCacheRead
SG::ReadHandleKey< LookUpTable > m_LookUpTableCacheRead
Definition
TruthParticlesInConeTool.h:56
xAOD::TruthParticlesInConeTool::LookUpTable
IParticlesLookUpTable< TruthParticle > LookUpTable
Definition
TruthParticlesInConeTool.h:43
xAOD::TruthParticlesInConeTool::initialize
virtual StatusCode initialize() override final
initialize
Definition
TruthParticlesInConeTool.cxx:25
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition
ICaloAffectedTool.h:24
xAOD::name
name
Definition
TriggerMenuJson_v1.cxx:29
xAOD::phi
setEt phi
Definition
TrigEMCluster_v1.cxx:29
type
Generated on
for ATLAS Offline Software by
1.17.0