ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
IDPVM::CachedGetAssocTruth Class Reference

#include <CachedGetAssocTruth.h>

Collaboration diagram for IDPVM::CachedGetAssocTruth:

Public Member Functions

 CachedGetAssocTruth ()=default
 
CachedGetAssocTruthoperator= (CachedGetAssocTruth &&)=default
 
 CachedGetAssocTruth (CachedGetAssocTruth &&)=default
 
 ~CachedGetAssocTruth ()=default
 
CachedGetAssocTruthoperator= (const CachedGetAssocTruth &)=delete
 copy and assignment are not possible More...
 
 CachedGetAssocTruth (const CachedGetAssocTruth &)=delete
 
void clear ()
 clear the cache More...
 
const xAOD::TruthParticleoperator() (const xAOD::TrackParticle *trackParticle)
 Get the associated truth particle, given a track particle. More...
 
const xAOD::TruthParticlegetTruth (const xAOD::TrackParticle *const trackParticle)
 

Private Attributes

std::unordered_map< const xAOD::TrackParticle *, const xAOD::TruthParticle * > m_cache
 private cache container; map or unordered_map could be used More...
 

Detailed Description

Definition at line 21 of file CachedGetAssocTruth.h.

Constructor & Destructor Documentation

◆ CachedGetAssocTruth() [1/3]

IDPVM::CachedGetAssocTruth::CachedGetAssocTruth ( )
default

◆ CachedGetAssocTruth() [2/3]

IDPVM::CachedGetAssocTruth::CachedGetAssocTruth ( CachedGetAssocTruth &&  )
default

◆ ~CachedGetAssocTruth()

IDPVM::CachedGetAssocTruth::~CachedGetAssocTruth ( )
default

◆ CachedGetAssocTruth() [3/3]

IDPVM::CachedGetAssocTruth::CachedGetAssocTruth ( const CachedGetAssocTruth )
delete

Member Function Documentation

◆ clear()

void IDPVM::CachedGetAssocTruth::clear ( )

clear the cache

Definition at line 17 of file CachedGetAssocTruth.cxx.

17  {
18  m_cache.clear();
19  }

◆ getTruth()

const xAOD::TruthParticle * IDPVM::CachedGetAssocTruth::getTruth ( const xAOD::TrackParticle *const  trackParticle)

Definition at line 22 of file CachedGetAssocTruth.cxx.

22  {
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  }

◆ operator()()

const xAOD::TruthParticle * IDPVM::CachedGetAssocTruth::operator() ( const xAOD::TrackParticle trackParticle)

Get the associated truth particle, given a track particle.

Definition at line 46 of file CachedGetAssocTruth.cxx.

46  {
47  return getTruth(trackParticle);
48  }

◆ operator=() [1/2]

CachedGetAssocTruth& IDPVM::CachedGetAssocTruth::operator= ( CachedGetAssocTruth &&  )
default

◆ operator=() [2/2]

CachedGetAssocTruth& IDPVM::CachedGetAssocTruth::operator= ( const CachedGetAssocTruth )
delete

copy and assignment are not possible

Member Data Documentation

◆ m_cache

std::unordered_map<const xAOD::TrackParticle*, const xAOD::TruthParticle*> IDPVM::CachedGetAssocTruth::m_cache
private

private cache container; map or unordered_map could be used

Definition at line 37 of file CachedGetAssocTruth.h.


The documentation for this class was generated from the following files:
get_generator_info.result
result
Definition: get_generator_info.py:21
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:54
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:41
IDPVM::CachedGetAssocTruth::getTruth
const xAOD::TruthParticle * getTruth(const xAOD::TrackParticle *const trackParticle)
Definition: CachedGetAssocTruth.cxx:22
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