ATLAS Offline Software
InnerDetector
InDetValidation
InDetPhysValMonitoring
src
CachedGetAssocTruth.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
11
#include "
CachedGetAssocTruth.h
"
12
#include "
xAODTruth/TruthParticleContainer.h
"
13
#include "
AthContainers/ConstAccessor.h
"
14
15
namespace
IDPVM
{
16
void
17
CachedGetAssocTruth::clear
() {
18
m_cache
.clear();
19
}
20
21
const
xAOD::TruthParticle
*
22
CachedGetAssocTruth::getTruth
(
const
xAOD::TrackParticle
* trackParticle) {
23
if
(not trackParticle) {
24
return
nullptr
;
25
}
26
auto
pCache =
m_cache
.find(trackParticle);
27
if
(pCache !=
m_cache
.end()) {
28
return
pCache->second;
29
}
30
using
ElementTruthLink_t =
ElementLink<xAOD::TruthParticleContainer>
;
31
const
xAOD::TruthParticle
*
result
(
nullptr
);
32
static
const
SG::ConstAccessor<ElementTruthLink_t>
truthParticleLinkAcc(
"truthParticleLink"
);
33
// 0. is there any truth?
34
if
(truthParticleLinkAcc.
isAvailable
(*trackParticle)) {
35
// 1. ..then get link
36
const
ElementTruthLink_t ptruthContainer = truthParticleLinkAcc(*trackParticle);
37
if
(ptruthContainer.isValid()) {
38
result
= *ptruthContainer;
39
}
40
}
41
m_cache
[trackParticle] =
result
;
42
return
result
;
43
}
44
45
const
xAOD::TruthParticle
*
46
CachedGetAssocTruth::operator ()
(
const
xAOD::TrackParticle
* trackParticle) {
47
return
getTruth
(trackParticle);
48
}
49
50
}
IDPVM
Class to retrieve associated truth from a track, implementing a cached response.
Definition:
InDetPhysValMonitoringTool.h:55
get_generator_info.result
result
Definition:
get_generator_info.py:21
IDPVM::CachedGetAssocTruth::clear
void clear()
clear the cache
Definition:
CachedGetAssocTruth.cxx:17
TruthParticleContainer.h
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition:
ConstAccessor.h:55
CachedGetAssocTruth.h
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition:
TruthParticle_v1.h:37
IDPVM::CachedGetAssocTruth::getTruth
const xAOD::TruthParticle * getTruth(const xAOD::TrackParticle *const trackParticle)
Definition:
CachedGetAssocTruth.cxx:22
ElementLink
ElementLink implementation for ROOT usage.
Definition:
AthLinks/ElementLink.h:121
IDPVM::CachedGetAssocTruth::operator()
const xAOD::TruthParticle * operator()(const xAOD::TrackParticle *trackParticle)
Get the associated truth particle, given a track particle.
Definition:
CachedGetAssocTruth.cxx:46
SG::ConstAccessor::isAvailable
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition:
TrackParticle_v1.h:43
ConstAccessor.h
Helper class to provide constant type-safe access to aux data.
IDPVM::CachedGetAssocTruth::m_cache
std::unordered_map< const xAOD::TrackParticle *, const xAOD::TruthParticle * > m_cache
private cache container; map or unordered_map could be used
Definition:
CachedGetAssocTruth.h:37
Generated on Thu Nov 7 2024 21:11:03 for ATLAS Offline Software by
1.8.18