ATLAS Offline Software
TruthEventBase_v1.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // $Id: TruthEventBase_v1.cxx 622193 2014-10-16 16:08:34Z krasznaa $
6 
7 // EDM include(s):
9 
10 // Local include(s):
12 
13 namespace xAOD {
14 
16  : SG::AuxElement() {
17 
18  }
19 
21  // Implementation of the truth particle accessor functions
22 
25  truthParticleLinks,
26  setTruthParticleLinks )
27 
28 
30  truthParticleLinksAcc( "truthParticleLinks" );
31 
32  size_t TruthEventBase_v1::nTruthParticles() const {
33 
34  // If the variable is not available, we don't have any truth particles
35  // associated...
36  if( ! truthParticleLinksAcc.isAvailable( *this ) ) {
37  return 0;
38  }
39 
40  // Return the size of the vector:
41  return truthParticleLinksAcc( *this ).size();
42  }
43 
46 
47  return truthParticleLinksAcc( *this ).at( index );
48  }
49 
51 
52  // Check if the variable is available:
53  if( ! truthParticleLinksAcc.isAvailable( *this ) ) {
54  return nullptr;
55  }
56 
57  // Check if the link is valid:
58  const TruthParticleLinks_t& links = truthParticleLinksAcc( *this );
59  if( ! links[ index ].isValid() ) {
60  return nullptr;
61  }
62 
63  // Return the de-referenced link:
64  return *( links[ index ] );
65  }
66 
67  void
69 
70  truthParticleLinksAcc( *this ).push_back( link );
71  return;
72  }
73 
75 
76  truthParticleLinksAcc( *this ).clear();
77  return;
78  }
79 
81 
83  // Implementation of the truth vertex accessor functions
84 
87  truthVertexLinks,
88  setTruthVertexLinks )
89 
90 
92  truthVertexLinksAcc( "truthVertexLinks" );
93 
94  size_t TruthEventBase_v1::nTruthVertices() const {
95 
96  // If the variable is not available, we don't have any truth particles
97  // associated...
98  if( ! truthVertexLinksAcc.isAvailable( *this ) ) {
99  return 0;
100  }
101 
102  // Return the size of the vector:
103  return truthVertexLinksAcc( *this ).size();
104  }
105 
108 
109  return truthVertexLinksAcc( *this ).at(index);
110  }
111 
113 
114  // Check if the variable is available:
115  if( ! truthVertexLinksAcc.isAvailable( *this ) ) {
116  return nullptr;
117  }
118 
119  // Check if the link is valid:
120  const TruthVertexLinks_t& links = truthVertexLinksAcc( *this );
121  if( ! links[ index ].isValid() ) {
122  return nullptr;
123  }
124 
125  // Return the de-referenced link:
126  return *( links[ index ] );
127  }
128 
130 
131  truthVertexLinksAcc( *this ).push_back( link );
132  return;
133  }
134 
136 
137  truthVertexLinksAcc( *this ).clear();
138  return;
139  }
140 
142 
144 
145  // Prepare the truth particle links for writing:
146  if( truthParticleLinksAcc.isAvailableWritable( *this ) ) {
148  truthParticleLinksAcc( *this ).begin();
150  truthParticleLinksAcc( *this ).end();
151  for( ; itr != end; ++itr ) {
152  itr->toPersistent();
153  }
154  }
155 
156  // Prepare the truth vertex links for writing:
157  if( truthVertexLinksAcc.isAvailableWritable( *this ) ) {
159  truthVertexLinksAcc( *this ).begin();
161  truthVertexLinksAcc( *this ).end();
162  for( ; itr != end; ++itr ) {
163  itr->toPersistent();
164  }
165  }
166 
167  return;
168  }
169 
170 } // namespace xAOD
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
xAOD::TruthEventBase_v1::toPersistent
void toPersistent()
Function making sure that the object is ready for persistification.
Definition: TruthEventBase_v1.cxx:143
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
xAOD::TruthEventBase_v1::TruthEventBase_v1
TruthEventBase_v1()
Default constructor.
Definition: TruthEventBase_v1.cxx:15
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:66
AuxStoreAccessorMacros.h
index
Definition: index.py:1
xAOD::TruthEventBase_v1::truthParticle
const TruthParticle * truthParticle(size_t index) const
Get a pointer to one of the truth particles.
Definition: TruthEventBase_v1.cxx:50
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
isValid
bool isValid(const T &p)
Definition: AtlasPID.h:214
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
xAOD::TruthEventBase_v1::addTruthParticleLink
void addTruthParticleLink(const TruthParticleLink_t &plink)
Add one truth particle.
Definition: TruthEventBase_v1.cxx:68
SG::IAuxElement::index
size_t index() const
Return the index of this element within its container.
DMTest::links
links
Definition: CLinks_v1.cxx:22
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:41
xAOD::TruthEventBase_v1::truthParticleLink
const TruthParticleLink_t & truthParticleLink(size_t index) const
Get the link to one of the truth particles.
Definition: TruthEventBase_v1.cxx:45
xAOD::TruthEventBase_v1::truthVertexLink
const TruthVertexLink_t & truthVertexLink(size_t index) const
Get the link to one of the truth vertices.
Definition: TruthEventBase_v1.cxx:107
xAOD::TruthEventBase_v1::clearTruthParticleLinks
void clearTruthParticleLinks()
Remove all truth particles.
Definition: TruthEventBase_v1.cxx:74
xAOD::TruthEventBase_v1::TruthVertexLinks_t
std::vector< TruthVertexLink_t > TruthVertexLinks_t
Type of the truth particle links vector.
Definition: TruthEventBase_v1.h:75
xAOD::TruthEventBase_v1
Base class describing a pile-up or signal truth event in the MC record.
Definition: TruthEventBase_v1.h:36
xAOD::TruthVertex_v1
Class describing a truth vertex in the MC record.
Definition: TruthVertex_v1.h:41
xAOD::TruthEventBase_v1::nTruthParticles
size_t nTruthParticles() const
Get the number of truth particles.
xAOD::TruthEventBase_v1::TruthParticleLink_t
ElementLink< TruthParticleContainer > TruthParticleLink_t
Type of a single truth particle link.
Definition: TruthEventBase_v1.h:48
xAOD::TruthEventBase_v1::nTruthVertices
size_t nTruthVertices() const
Get the number of truth vertices.
xAOD::TruthEventBase_v1::clearTruthVertexLinks
void clearTruthVertexLinks()
Remove all truth vertices.
Definition: TruthEventBase_v1.cxx:135
xAOD::TruthEventBase_v1::TruthVertexLink_t
ElementLink< TruthVertexContainer > TruthVertexLink_t
Type of a single truth vertex link.
Definition: TruthEventBase_v1.h:73
xAOD::TruthEventBase_v1::addTruthVertexLink
void addTruthVertexLink(const TruthVertexLink_t &vlink)
Add one truth vertex.
Definition: TruthEventBase_v1.cxx:129
xAOD::TruthEventBase_v1::truthVertex
const TruthVertex * truthVertex(size_t index) const
Get a pointer to one of the truth vertices.
Definition: TruthEventBase_v1.cxx:112
TruthEventBase_v1.h
xAOD::TruthEventBase_v1::TruthParticleLinks_t
std::vector< TruthParticleLink_t > TruthParticleLinks_t
Type of the truth particle links vector.
Definition: TruthEventBase_v1.h:50
xAOD::AUXSTORE_OBJECT_SETTER_AND_GETTER
AUXSTORE_OBJECT_SETTER_AND_GETTER(CaloRings_v1, RingSetLinks, ringSetLinks, setRingSetLinks) unsigned CaloRings_v1
Definition: CaloRings_v1.cxx:27