ATLAS Offline Software
Loading...
Searching...
No Matches
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
13namespace xAOD {
14
19
21 // Implementation of the truth particle accessor functions
22
25 truthParticleLinks,
26 setTruthParticleLinks )
27
28
30 truthParticleLinksAcc( "truthParticleLinks" );
31
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
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 ) ) {
147 TruthParticleLinks_t::iterator itr =
148 truthParticleLinksAcc( *this ).begin();
149 TruthParticleLinks_t::iterator end =
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 ) ) {
158 TruthVertexLinks_t::iterator itr =
159 truthVertexLinksAcc( *this ).begin();
160 TruthVertexLinks_t::iterator end =
161 truthVertexLinksAcc( *this ).end();
162 for( ; itr != end; ++itr ) {
163 itr->toPersistent();
164 }
165 }
166
167 return;
168 }
169
170} // namespace xAOD
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
Definition AtlasPID.h:878
#define AUXSTORE_OBJECT_SETTER_AND_GETTER(CL, TYPE, NAME, SETTER)
Macro creating the accessors of complex auxiliary properties.
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
AuxElement()
Default constructor.
Base class describing a pile-up or signal truth event in the MC record.
void clearTruthParticleLinks()
Remove all truth particles.
const TruthParticle * truthParticle(size_t index) const
Get a pointer to one of the truth particles.
ElementLink< TruthParticleContainer > TruthParticleLink_t
Type of a single truth particle link.
ElementLink< TruthVertexContainer > TruthVertexLink_t
Type of a single truth vertex link.
size_t nTruthParticles() const
Get the number of truth particles.
TruthEventBase_v1()
Default constructor.
const TruthVertex * truthVertex(size_t index) const
Get a pointer to one of the truth vertices.
const TruthVertexLink_t & truthVertexLink(size_t index) const
Get the link to one of the truth vertices.
void addTruthVertexLink(const TruthVertexLink_t &vlink)
Add one truth vertex.
void toPersistent()
Function making sure that the object is ready for persistification.
std::vector< TruthVertexLink_t > TruthVertexLinks_t
Type of the truth particle links vector.
std::vector< TruthParticleLink_t > TruthParticleLinks_t
Type of the truth particle links vector.
void addTruthParticleLink(const TruthParticleLink_t &plink)
Add one truth particle.
const TruthParticleLink_t & truthParticleLink(size_t index) const
Get the link to one of the truth particles.
void clearTruthVertexLinks()
Remove all truth vertices.
size_t nTruthVertices() const
Get the number of truth vertices.
Forward declaration.
Definition index.py:1
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
TruthVertex_v1 TruthVertex
Typedef to implementation.
Definition TruthVertex.h:15
TruthParticle_v1 TruthParticle
Typedef to implementation.