ATLAS Offline Software
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 
12 
13 namespace xAOD {
14 
16  const std::string& name,
17  const IInterface* parent)
19 {
20  declareInterface<ITruthParticlesInConeTool>(this);
21 }
22 
23 
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 
37 TruthParticlesInConeTool::getTable(const EventContext& ctx) const
38 {
40  if (rh.isValid()) {
41  return &*rh;
42  }
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);
53  return wh.put(std::move(lut), true);
54 }
55 
56 bool
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
xAOD::TruthParticlesInConeTool::getTable
const LookUpTable * getTable(const EventContext &ctx) const
Definition: TruthParticlesInConeTool.cxx:37
xAOD::name
name
Definition: TriggerMenuJson_v1.cxx:29
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
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
TruthParticlesInConeTool.h
xAOD::TruthParticlesInConeTool::TruthParticlesInConeTool
TruthParticlesInConeTool(const std::string &type, const std::string &name, const IInterface *parent)
constructor
Definition: TruthParticlesInConeTool.cxx:15
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
python.TurnDataReader.dr
dr
Definition: TurnDataReader.py:112
ITkPixEncoding::lut
constexpr auto lut(Generator &&f)
Definition: ITkPixQCoreEncodingLUT.h:19
xAOD::phi
setEt phi
Definition: TrigEMCluster_v1.cxx:29
xAOD::TruthParticlesInConeTool::m_truthParticleLocation
SG::ReadHandleKey< TruthParticleContainer > m_truthParticleLocation
Truth Particle collection name.
Definition: TruthParticlesInConeTool.h:50
xAOD::TruthParticlesInConeTool::m_LookUpTableCacheWrite
SG::WriteHandleKey< LookUpTable > m_LookUpTableCacheWrite
Definition: TruthParticlesInConeTool.h:57
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
xAOD::TruthParticlesInConeTool::m_LookUpTableCacheRead
SG::ReadHandleKey< LookUpTable > m_LookUpTableCacheRead
Definition: TruthParticlesInConeTool.h:56
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
test_pyathena.parent
parent
Definition: test_pyathena.py:15
parseDir.wh
wh
Definition: parseDir.py:46
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
merge.output
output
Definition: merge.py:17
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
xAOD::IParticlesLookUpTable
2D look up table for iParticles
Definition: IParticlesLookUpTable.h:17
AthAlgTool
Definition: AthAlgTool.h:26
xAOD::TruthParticlesInConeTool::initialize
virtual StatusCode initialize() override final
initialize
Definition: TruthParticlesInConeTool.cxx:25