Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | Static Public Member Functions | Private Attributes | Static 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)
 

Static Public Member Functions

static void neededTrackParticleDecorations (std::vector< std::string > &decorations)
 

Private Attributes

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

Static Private Attributes

static const std::string s_trackParticleLinkDecorationName
 

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 29 of file CachedGetAssocTruth.cxx.

29  {
30  if (not trackParticle) {
31  return nullptr;
32  }
33  auto pCache = m_cache.find(trackParticle);
34  if (pCache != m_cache.end()) {
35  return pCache->second;
36  }
37  using ElementTruthLink_t = ElementLink<xAOD::TruthParticleContainer>;
38  const xAOD::TruthParticle* result(nullptr);
40  // 0. is there any truth?
41  if (truthParticleLinkAcc.isAvailable(*trackParticle)) {
42  // 1. ..then get link
43  const ElementTruthLink_t ptruthContainer = truthParticleLinkAcc(*trackParticle);
44  if (ptruthContainer.isValid()) {
45  result = *ptruthContainer;
46  }
47  }
48  m_cache[trackParticle] = result;
49  return result;
50  }

◆ neededTrackParticleDecorations()

void IDPVM::CachedGetAssocTruth::neededTrackParticleDecorations ( std::vector< std::string > &  decorations)
static

Definition at line 23 of file CachedGetAssocTruth.cxx.

23  {
24  if (std::find(decorations.begin(),decorations.end(),s_trackParticleLinkDecorationName) == decorations.end()) {
25  decorations.push_back(s_trackParticleLinkDecorationName);
26  }
27  }

◆ operator()()

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

Get the associated truth particle, given a track particle.

Definition at line 53 of file CachedGetAssocTruth.cxx.

53  {
54  return getTruth(trackParticle);
55  }

◆ 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 39 of file CachedGetAssocTruth.h.

◆ s_trackParticleLinkDecorationName

const std::string IDPVM::CachedGetAssocTruth::s_trackParticleLinkDecorationName
staticprivate

Definition at line 40 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
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
IDPVM::CachedGetAssocTruth::s_trackParticleLinkDecorationName
static const std::string s_trackParticleLinkDecorationName
Definition: CachedGetAssocTruth.h:40
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
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:29
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:39