ATLAS Offline Software
Loading...
Searching...
No Matches
Vertex_v1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6// System include(s):
7#include <cmath>
8
9// EDM include(s):
12
13// Local include(s):
16
17namespace xAOD {
18
20 : SG::AuxElement(),
21 m_position(),
22 m_covariance() {
23
24 }
25
30 //copy aux store content (only the stuffs already loaded in memory!)
31 this->makePrivateStore( other );
32 }
33
35
36 // Check if anything needs to be done:
37 if( this == &tp ) {
38 return *this;
39 }
40
41 // If the object doesn't have an auxiliary store yet, make a private
42 // one for it:
43 if( ( ! hasStore() ) && ( ! container() ) ) {
45 }
46
47 // copy the cache
48 m_position = tp.m_position;
49 m_covariance = tp.m_covariance;
50
51 // Now let the base class copy the auxiliary contents:
53
54 // Return the object:
55 return *this;
56 }
57
58 Type::ObjectType Vertex_v1::type() const {
59
60 return Type::Vertex;
61 }
62
64 //
65 // Implementation of the primitive accessors
66
70 AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( Vertex_v1, float, time, setTime )
71 AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( Vertex_v1, float, timeResolution, setTimeResolution )
72 AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( Vertex_v1, uint8_t, hasValidTime, setHasValidTime )
73
75 covariance, setCovariance )
76
77 //
79
81 // Implementation of the Eigen functions
82 //
83
84 const Amg::Vector3D& Vertex_v1::position() const {
85
86 // Cache the position if necessary:
87 if( ! m_position.isValid() ) {
88 Amg::Vector3D tmpPosition;
89 tmpPosition( 0 ) = x();
90 tmpPosition( 1 ) = y();
91 tmpPosition( 2 ) = z();
92 m_position.set(tmpPosition);
93 }
94
95 // Return the object:
96 return *(m_position.ptr());
97 }
98
99 void Vertex_v1::setPosition( const Amg::Vector3D& position ) {
100
101 // Set the primitive variables using the simple functions:
102 setX( position( 0 ) );
103 setY( position( 1 ) );
104 setZ( position( 2 ) );
105 // Reset the cache
106 // This will enforce float precision level on the values of
107 // m_position. The effect of this float conversion has been
108 // discussed in ATLASRECTS-7671
110 }
111
112 const AmgSymMatrix(3)& Vertex_v1::covariancePosition() const {
113
114 // Cache the covariance matrix if necessary:
115 if( ! m_covariance.isValid() ) {
116 // The matrix is now cached:
117 AmgSymMatrix(3) tmpCovariance;
118 Amg::expand(covariance().begin(),covariance().end(),tmpCovariance);
119 m_covariance.set(tmpCovariance);
120 }
121 // Return the cached object:
122 return *(m_covariance.ptr());
123 }
124
125 void Vertex_v1::setCovariancePosition( const AmgSymMatrix(3)& cov ) {
126
127 // The to-be persistent variable:
128 std::vector< float > vec;
129 Amg::compress(cov,vec);
130
131 // Set the persistent variable:
133 // This will enforce float precision level on the values of
134 // m_covariance. The effect of this float conversion has been
135 // discussed in ATLASRECTS-7671
137 }
138
139 //
141
143 //
144 // Implementation of the fit quality functions
145 //
146
147 AUXSTORE_PRIMITIVE_GETTER( Vertex_v1, float, chiSquared )
148 AUXSTORE_PRIMITIVE_GETTER( Vertex_v1, float, numberDoF )
149
151
152 static const Accessor< float > acc1( "chiSquared" );
153 static const Accessor< float > acc2( "numberDoF" );
154 acc1( *this ) = chiSquared;
155 acc2( *this ) = numberDoF;
156
157 return;
158 }
159
160 //
162
164 vertexType )
166 vertexType, setVertexType )
167
168#ifndef XAOD_ANALYSIS
171 vxVertAcc( "vxTrackAtVertex" );
172
181 std::vector< Trk::VxTrackAtVertex >& Vertex_v1::vxTrackAtVertex() {
182
183 return vxVertAcc( *this );
184 }
185
197 const std::vector< Trk::VxTrackAtVertex >&
199
200 return vxVertAcc( *this );
201 }
202
210
211 return vxVertAcc.isAvailable( *this );
212 }
213#endif // not XAOD_ANALYSIS
214
216 //
217 // Implementation of the track particle handling functions
218 //
219
222 trackAcc( "trackParticleLinks" );
225 weightTrackAcc( "trackWeights" );
226
229 neutralAcc( "neutralParticleLinks" );
232 weightNeutralAcc( "neutralWeights" );
233
236 trackParticleLinks,
237 setTrackParticleLinks )
238 AUXSTORE_OBJECT_SETTER_AND_GETTER( Vertex_v1, std::vector< float >,
239 trackWeights, setTrackWeights )
240
242 Vertex_v1::NeutralParticleLinks_t,
243 neutralParticleLinks,
244 setNeutralParticleLinks )
246 neutralWeights, setNeutralWeights )
247
248
250
251 if( ! trackAcc.isAvailable( *this ) ) {
252 return nullptr;
253 }
254 if( ( trackAcc( *this ).size() <= i ) ||
255 ( ! trackAcc( *this )[ i ].isValid() ) ) {
256 return nullptr;
257 }
258
259 return ( *( trackAcc( *this )[ i ] ) );
260 }
261
262 float Vertex_v1::trackWeight( size_t i ) const {
263
264 if( weightTrackAcc( *this ).size() <= i ) {
265 return -1.0;
266 }
267 return weightTrackAcc( *this )[ i ];
268 }
269
271
272 if( ! trackAcc.isAvailable( *this ) ) {
273 return 0;
274 }
275
276 return trackAcc( *this ).size();
277 }
278
279
281
282 if( ! neutralAcc.isAvailable( *this ) ) {
283 return nullptr;
284 }
285 if( ( neutralAcc( *this ).size() <= i ) ||
286 ( ! neutralAcc( *this )[ i ].isValid() ) ) {
287 return nullptr;
288 }
289
290 return ( *( neutralAcc( *this )[ i ] ) );
291 }
292
293 float Vertex_v1::neutralWeight( size_t i ) const {
294
295 if( weightNeutralAcc( *this ).size() <= i ) {
296 return -1.0;
297 }
298 return weightNeutralAcc( *this )[ i ];
299 }
300
302
303 if( ! neutralAcc.isAvailable( *this ) ) {
304 return 0;
305 }
306
307 return neutralAcc( *this ).size();
308 }
309
310
311
312
313 void
315 float weight ) {
316
317 trackAcc( *this ).push_back( tr );
318 weightTrackAcc( *this ).push_back( weight );
319 return;
320 }
321
322 void
324 float weight ) {
325
326 neutralAcc( *this ).push_back( tr );
327 weightNeutralAcc( *this ).push_back( weight );
328 return;
329 }
330
332
333 trackAcc( *this ).clear();
334 weightTrackAcc( *this ).clear();
335 return;
336 }
337
339
340 neutralAcc( *this ).clear();
341 weightNeutralAcc( *this ).clear();
342 return;
343 }
344
345 /*
346 * Reset the cache
347 */
349 m_position.reset();
350 m_covariance.reset();
351 return;
352 }
353
354} // 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_PRIMITIVE_GETTER_WITH_CAST(CL, PERSTYPE, TRANSTYPE, NAME)
Macro creating a getter function with a type conversion.
#define AUXSTORE_PRIMITIVE_GETTER(CL, TYPE, NAME)
Macro creating the reader function for a primitive auxiliary property.
#define AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(CL, TYPE, NAME, SETTER)
Macro creating the accessors of primitive auxiliary properties.
#define AUXSTORE_OBJECT_SETTER_AND_GETTER(CL, TYPE, NAME, SETTER)
Macro creating the accessors of complex auxiliary properties.
std::vector< size_t > vec
#define AmgSymMatrix(dim)
Eigen::Matrix< double, 3, 1 > Vector3D
#define y
#define x
#define z
void reset()
Reset the value to invalid.
const T * ptr() const
Return a pointer to the cached value.
void set(const T &val) const
Set the value, assuming it is currently invalid.
bool isValid() const
Test to see if the value is valid.
void makePrivateStore()
Create a new (empty) private store for this object.
AuxElement & operator=(const AuxElement &other)
Assignment.
bool hasStore() const
Return true if this object has an associated store.
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
const SG::AuxVectorData * container() const
Return the container holding this element.
AuxElement()
Default constructor.
Class describing a Vertex.
Definition Vertex_v1.h:42
void clearNeutrals()
Remove all neutrals from the vertex.
size_t nNeutralParticles() const
Get the number of neutrals associated with this vertex.
size_t nTrackParticles() const
Get the number of tracks associated with this vertex.
void clearTracks()
Remove all tracks from the vertex.
const NeutralParticle * neutralParticle(size_t i) const
Get the pointer to a given neutral that was used in vertex reco.
CxxUtils::CachedValue< Amg::Vector3D > m_position
Cached position of the vertex.
Definition Vertex_v1.h:191
void setCovariancePosition(const AmgSymMatrix(3)&covariancePosition)
Sets the vertex covariance matrix.
Vertex_v1()
Default constructor.
Definition Vertex_v1.cxx:19
Vertex_v1 & operator=(const Vertex_v1 &tp)
Assignment operator. This can involve creating and copying an Auxilary store, and so should be used s...
Definition Vertex_v1.cxx:34
void addTrackAtVertex(const ElementLink< TrackParticleContainer > &tr, float weight=1.0)
Add a new track to the vertex.
CxxUtils::CachedValue< AmgSymMatrix(3)> m_covariance
Cached covariance of the vertex.
Definition Vertex_v1.h:193
void setZ(float value)
Sets the z position.
void addNeutralAtVertex(const ElementLink< NeutralParticleContainer > &tr, float weight=1.0)
Add a new neutral to the vertex.
const TrackParticle * trackParticle(size_t i) const
Get the pointer to a given track that was used in vertex reco.
std::vector< ElementLink< xAOD::TrackParticleContainer > > TrackParticleLinks_t
Type for the associated track particles.
Definition Vertex_v1.h:128
void resetCache()
Reset the internal cache of the object.
void setX(float value)
Sets the x position.
float neutralWeight(size_t i) const
Get the weight of a given neutral in the vertex reconstruction.
void setY(float value)
Sets the y position.
Type::ObjectType type() const
A little helper function for identifying the type in template code.
Definition Vertex_v1.cxx:58
void setCovariance(const std::vector< float > &value)
Sets the covariance matrix as a simple vector of values.
float numberDoF() const
Returns the number of degrees of freedom of the vertex fit as float.
void setPosition(const Amg::Vector3D &position)
Sets the 3-position.
bool vxTrackAtVertexAvailable() const
Check if VxTrackAtVertices are attached to the object.
float chiSquared() const
Returns the of the vertex fit as float.
std::vector< Trk::VxTrackAtVertex > & vxTrackAtVertex()
Non-const access to the VxTrackAtVertex vector.
void setFitQuality(float chiSquared, float numberDoF)
Set the 'Fit Quality' information.
const Amg::Vector3D & position() const
Returns the 3-pos.
const std::vector< float > & covariance() const
Returns the covariance matrix as a simple vector of values.
float trackWeight(size_t i) const
Get the weight of a given track in the vertex reconstruction.
Definition of ATLAS Math & Geometry primitives (Amg)
void compress(const AmgSymMatrix(N) &covMatrix, std::vector< float > &vec)
void expand(std::vector< float >::const_iterator it, std::vector< float >::const_iterator, AmgSymMatrix(N) &covMatrix)
Eigen::Matrix< double, 3, 1 > Vector3D
Forward declaration.
STL namespace.
A convenience namespace to make the client code easier to understand.
VertexType
Vertex types.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
setStrategy setMatchFlag ElementLink< TrackParticleContainer >
static const SG::AuxElement::Accessor< Vertex_v1::TrackParticleLinks_t > trackAcc("trackParticleLinks")
Accessor for the track links.
AUXSTORE_PRIMITIVE_SETTER_WITH_CAST(CompositeParticle_v1, float, double, px, setPx) AUXSTORE_PRIMITIVE_SETTER_WITH_CAST(CompositeParticle_v1
setTrackWeights neutralWeights
NeutralParticle_v1 NeutralParticle
Reference the current persistent version:
TrackParticle_v1 TrackParticle
Reference the current persistent version:
static const SG::AuxElement::Accessor< std::vector< float > > weightTrackAcc("trackWeights")
Accessor for the track weights.
static const SG::AuxElement::Accessor< std::vector< float > > weightNeutralAcc("neutralWeights")
Accessor for the neutral weights.
static const SG::AuxElement::Accessor< Vertex_v1::NeutralParticleLinks_t > neutralAcc("neutralParticleLinks")
Accessor for the neutral links.
AUXSTORE_OBJECT_SETTER_AND_GETTER(CaloRings_v1, RingSetLinks, ringSetLinks, setRingSetLinks) unsigned CaloRings_v1
static setVertexType const SG::AuxElement::Accessor< std::vector< Trk::VxTrackAtVertex > > vxVertAcc("vxTrackAtVertex")
Helper object for implementing the vxTrackAtVertex functions.