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 Private Member Functions | Private Attributes | List of all members
DerivationFramework::TruthLinkRepointTool Class Reference

#include <TruthLinkRepointTool.h>

Inheritance diagram for DerivationFramework::TruthLinkRepointTool:
Collaboration diagram for DerivationFramework::TruthLinkRepointTool:

Public Member Functions

 TruthLinkRepointTool (const std::string &t, const std::string &n, const IInterface *p)
 
 ~TruthLinkRepointTool ()
 
virtual StatusCode addBranches () const override final
 
virtual StatusCode initialize () override final
 

Static Private Member Functions

static int find_match (const xAOD::TruthParticle *p, const xAOD::TruthParticleContainer *c)
 

Private Attributes

SG::ReadHandleKey< xAOD::IParticleContainerm_recoKey
 Parameter: input collection key. More...
 
Gaudi::Property< std::string > m_decOutput
 Parameter: output decoration. More...
 
SG::ReadHandleKeyArray< xAOD::TruthParticleContainerm_targetKeys {this, "TargetCollections", {"TruthMuons","TruthPhotons","TruthElectrons"}, "Name of target truth collections"}
 Parameter: target collection. More...
 
SG::WriteDecorHandleKey< xAOD::IParticleContainerm_decorKey {this, "TargetDecorKeys", "", "Will be overwritten during initialize"}
 

Detailed Description

Definition at line 23 of file TruthLinkRepointTool.h.

Constructor & Destructor Documentation

◆ TruthLinkRepointTool()

DerivationFramework::TruthLinkRepointTool::TruthLinkRepointTool ( const std::string &  t,
const std::string &  n,
const IInterface *  p 
)

Definition at line 24 of file TruthLinkRepointTool.cxx.

26  :
27  base_class(t,n,p) {
28 }

◆ ~TruthLinkRepointTool()

DerivationFramework::TruthLinkRepointTool::~TruthLinkRepointTool ( )
default

Member Function Documentation

◆ addBranches()

StatusCode DerivationFramework::TruthLinkRepointTool::addBranches ( ) const
finaloverridevirtual

Definition at line 45 of file TruthLinkRepointTool.cxx.

45  {
46  const EventContext& ctx = Gaudi::Hive::currentContext();
47  // Retrieve the truth collections
48  std::vector<const xAOD::TruthParticleContainer*> targets{};
49  targets.reserve(m_targetKeys.size());
50 
52  output_decorator (m_decorKey, ctx);
53 
56  if (!readHandle.isValid()) {
57  ATH_MSG_FATAL("Failed to retrieve "<<key.fullKey());
58  return StatusCode::FAILURE;
59  }
60  targets.emplace_back(readHandle.cptr());
61  }
62 
63 
65  if (!inputCont.isValid()) {
66  ATH_MSG_FATAL("Failed to retrive "<<m_recoKey.fullKey());
67  return StatusCode::FAILURE;
68  }
69  for ( const xAOD::IParticle* input : *inputCont) {
71  output_decorator(*input) = ElementLink<xAOD::TruthParticleContainer>{};
72  for (const xAOD::TruthParticleContainer* target : targets) {
73  int index = find_match(truthPart, target);
74 
75  if (index >=0) output_decorator(*input) = ElementLink<xAOD::TruthParticleContainer>(*target, index);
76 
77  }
78  }
79 
80  return StatusCode::SUCCESS;
81 }

◆ find_match()

int DerivationFramework::TruthLinkRepointTool::find_match ( const xAOD::TruthParticle p,
const xAOD::TruthParticleContainer c 
)
staticprivate

Definition at line 84 of file TruthLinkRepointTool.cxx.

85 {
86  // See if it's already gone
87  if (!p) return -1;
88  // Look through the mini-collection
89  for (int i=0;i<int(c->size());++i){
90  if (c->at(i) && HepMC::is_same_particle(p,c->at(i))) return i;
91  }
92  // Note: just fine if it wasn't in the mini-collection
93  return -1;
94 }

◆ initialize()

StatusCode DerivationFramework::TruthLinkRepointTool::initialize ( )
finaloverridevirtual

Definition at line 29 of file TruthLinkRepointTool.cxx.

29  {
30  ATH_CHECK(m_recoKey.initialize());
31  if (m_decOutput.value().empty()) {
32  ATH_MSG_FATAL("Please enter a a valid output decorator");
33  return StatusCode::FAILURE;
34  }
35  ATH_CHECK(m_targetKeys.initialize());
36  m_decorKey = m_recoKey.key() + "." + m_decOutput;
37  ATH_CHECK(m_decorKey.initialize());
38  return StatusCode::SUCCESS;
39 }

Member Data Documentation

◆ m_decorKey

SG::WriteDecorHandleKey<xAOD::IParticleContainer> DerivationFramework::TruthLinkRepointTool::m_decorKey {this, "TargetDecorKeys", "", "Will be overwritten during initialize"}
private

Definition at line 40 of file TruthLinkRepointTool.h.

◆ m_decOutput

Gaudi::Property<std::string> DerivationFramework::TruthLinkRepointTool::m_decOutput
private
Initial value:
{this, "OutputDecoration",
"TruthLink", "Name of the output decoration on the reco object"}

Parameter: output decoration.

Definition at line 35 of file TruthLinkRepointTool.h.

◆ m_recoKey

SG::ReadHandleKey<xAOD::IParticleContainer> DerivationFramework::TruthLinkRepointTool::m_recoKey
private
Initial value:
{this,"RecoCollection", "Muons",
"Name of reco collection for decoration"}

Parameter: input collection key.

Definition at line 32 of file TruthLinkRepointTool.h.

◆ m_targetKeys

SG::ReadHandleKeyArray<xAOD::TruthParticleContainer> DerivationFramework::TruthLinkRepointTool::m_targetKeys {this, "TargetCollections", {"TruthMuons","TruthPhotons","TruthElectrons"}, "Name of target truth collections"}
private

Parameter: target collection.

Definition at line 38 of file TruthLinkRepointTool.h.


The documentation for this class was generated from the following files:
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
SG::ReadHandle< xAOD::TruthParticleContainer >
index
Definition: index.py:1
DerivationFramework::TruthLinkRepointTool::m_targetKeys
SG::ReadHandleKeyArray< xAOD::TruthParticleContainer > m_targetKeys
Parameter: target collection.
Definition: TruthLinkRepointTool.h:38
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
SG::ReadHandleKey< xAOD::TruthParticleContainer >
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
HepMC::is_same_particle
bool is_same_particle(const T1 &p1, const T2 &p2)
Method to establish if two particles in the GenEvent actually represent the same particle.
Definition: MagicNumbers.h:367
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:731
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:37
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:100
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DerivationFramework::TruthLinkRepointTool::find_match
static int find_match(const xAOD::TruthParticle *p, const xAOD::TruthParticleContainer *c)
Definition: TruthLinkRepointTool.cxx:84
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
xAOD::TruthHelpers::getTruthParticle
const xAOD::TruthParticle * getTruthParticle(const xAOD::IParticle &p)
Return the truthParticle associated to the given IParticle (if any)
Definition: xAODTruthHelpers.cxx:25
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
DerivationFramework::TruthLinkRepointTool::m_decorKey
SG::WriteDecorHandleKey< xAOD::IParticleContainer > m_decorKey
Definition: TruthLinkRepointTool.h:40
copySelective.target
string target
Definition: copySelective.py:37
DerivationFramework::TruthLinkRepointTool::m_decOutput
Gaudi::Property< std::string > m_decOutput
Parameter: output decoration.
Definition: TruthLinkRepointTool.h:35
DerivationFramework::TruthLinkRepointTool::m_recoKey
SG::ReadHandleKey< xAOD::IParticleContainer > m_recoKey
Parameter: input collection key.
Definition: TruthLinkRepointTool.h:32
python.compressB64.c
def c
Definition: compressB64.py:93
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37