ATLAS Offline Software
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 
17 namespace xAOD {
18 
20  : SG::AuxElement(),
21  m_position(),
22  m_covariance() {
23 
24  }
25 
27  : SG::AuxElement(other),
28  m_position( other.m_position ),
29  m_covariance( other.m_covariance ){
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 
59 
60  return Type::Vertex;
61  }
62 
64  //
65  // Implementation of the primitive accessors
66 
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
109  m_position.reset();
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 
126 
127  // The to-be persistent variable:
128  std::vector< float > vec;
130 
131  // Set the persistent variable:
132  setCovariance( vec );
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 
150  void Vertex_v1::setFitQuality( float chiSquared, float numberDoF ) {
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 
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 
249  const TrackParticle* Vertex_v1::trackParticle( size_t i ) const {
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 
270  size_t Vertex_v1::nTrackParticles() const {
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();
351  return;
352  }
353 
354 } // namespace xAOD
xAOD::AUXSTORE_PRIMITIVE_SETTER_AND_GETTER
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(BTagging_v1, float, IP2D_pb, setIP2D_pb) AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(BTagging_v1
CxxUtils::CachedValue::reset
void reset()
Reset the value to invalid.
xAOD::Vertex_v1::setPosition
void setPosition(const Amg::Vector3D &position)
Sets the 3-position.
CxxUtils::CachedValue::ptr
const T * ptr() const
Return a pointer to the cached value.
xAOD::Vertex_v1::nTrackParticles
size_t nTrackParticles() const
Get the number of tracks associated with this vertex.
Definition: Vertex_v1.cxx:270
xAOD::Vertex_v1::AmgSymMatrix
const AmgSymMatrix(3) &covariancePosition() const
Returns the vertex covariance matrix.
Amg::compress
void compress(const AmgSymMatrix(N) &covMatrix, std::vector< float > &vec)
Definition: EventPrimitivesHelpers.h:56
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
xAOD::Vertex
Vertex_v1 Vertex
Define the latest version of the vertex class.
Definition: Event/xAOD/xAODTracking/xAODTracking/Vertex.h:16
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:575
xAOD::Vertex_v1::Vertex_v1
Vertex_v1()
Default constructor.
Definition: Vertex_v1.cxx:19
SG::Accessor< float >
AuxStoreAccessorMacros.h
CxxUtils::CachedValue::isValid
bool isValid() const
Test to see if the value is valid.
EventPrimitivesHelpers.h
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
xAOD::Vertex_v1::clearNeutrals
void clearNeutrals()
Remove all neutrals from the vertex.
Definition: Vertex_v1.cxx:338
plotBeamSpotVxVal.cov
cov
Definition: plotBeamSpotVxVal.py:201
ParticleTest.tp
tp
Definition: ParticleTest.py:25
xAOD::other
@ other
Definition: TrackingPrimitives.h:509
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
xAOD::Vertex_v1::position
const Amg::Vector3D & position() const
Returns the 3-pos.
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
atn_test_sgProducerConsumerDataPool_jobOptions.end
end
Definition: atn_test_sgProducerConsumerDataPool_jobOptions.py:25
xAOD::Vertex_v1::m_position
CxxUtils::CachedValue< Amg::Vector3D > m_position
Cached position of the vertex.
Definition: Vertex_v1.h:191
isValid
bool isValid(const T &p)
Definition: AtlasPID.h:214
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:562
xAOD::Vertex_v1::setX
void setX(float value)
Sets the x position.
x
#define x
xAOD::Vertex_v1::setCovariance
void setCovariance(const std::vector< float > &value)
Sets the covariance matrix as a simple vector of values.
Amg::expand
void expand(std::vector< float >::const_iterator it, std::vector< float >::const_iterator, AmgSymMatrix(N) &covMatrix)
Definition: EventPrimitivesHelpers.h:75
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:200
xAOD::VxType::VertexType
VertexType
Vertex types.
Definition: TrackingPrimitives.h:569
CxxUtils::vec
typename vecDetail::vec_typedef< T, N >::type vec
Define a nice alias for the vectorized type.
Definition: vec.h:207
xAOD::Vertex_v1::addTrackAtVertex
void addTrackAtVertex(const ElementLink< TrackParticleContainer > &tr, float weight=1.0)
Add a new track to the vertex.
Definition: Vertex_v1.cxx:314
xAOD::Vertex_v1::setZ
void setZ(float value)
Sets the z position.
xAOD::AUXSTORE_PRIMITIVE_SETTER_WITH_CAST
AUXSTORE_PRIMITIVE_SETTER_WITH_CAST(CompositeParticle_v1, float, double, px, setPx) AUXSTORE_PRIMITIVE_SETTER_WITH_CAST(CompositeParticle_v1
xAOD::trackWeights
trackWeights
Definition: Vertex_v1.cxx:239
xAOD::Vertex_v1::setY
void setY(float value)
Sets the y position.
lumiFormat.i
int i
Definition: lumiFormat.py:92
z
#define z
vector
Definition: MultiHisto.h:13
python.CaloBCIDAvgAlgConfig.acc1
def acc1
Definition: CaloBCIDAvgAlgConfig.py:48
xAOD::AUXSTORE_PRIMITIVE_GETTER_WITH_CAST
AUXSTORE_PRIMITIVE_GETTER_WITH_CAST(Muon_v1, uint8_t, Muon_v1::EnergyLossType, energyLossType) AUXSTORE_PRIMITIVE_SETTER_WITH_CAST(Muon_v1
python.CaloBCIDAvgAlgConfig.acc2
def acc2
Definition: CaloBCIDAvgAlgConfig.py:58
xAOD::TauHelpers::trackParticleLinks
std::vector< ElementLink< xAOD::TrackParticleContainer > > trackParticleLinks(const xAOD::TauJet *tau, xAOD::TauJetParameters::TauTrackFlag flag=xAOD::TauJetParameters::TauTrackFlag::classifiedCharged)
Definition: TauxAODHelpers.cxx:22
xAOD::Vertex_v1::TrackParticleLinks_t
std::vector< ElementLink< xAOD::TrackParticleContainer > > TrackParticleLinks_t
Type for the associated track particles.
Definition: Vertex_v1.h:128
xAOD::Vertex_v1::clearTracks
void clearTracks()
Remove all tracks from the vertex.
Definition: Vertex_v1.cxx:331
xAOD::Vertex_v1::neutralParticle
const NeutralParticle * neutralParticle(size_t i) const
Get the pointer to a given neutral that was used in vertex reco.
Definition: Vertex_v1.cxx:280
Vertex_v1.h
Amg
Definition of ATLAS Math & Geometry primitives (Amg)
Definition: AmgStringHelpers.h:19
xAOD::Vertex_v1::operator=
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
xAOD::vertexType
vertexType
Definition: Vertex_v1.cxx:166
SG::AuxElement::makePrivateStore
void makePrivateStore()
Create a new (empty) private store for this object.
Definition: AuxElement.cxx:172
xAOD::Vertex_v1::trackWeight
float trackWeight(size_t i) const
Get the weight of a given track in the vertex reconstruction.
Definition: Vertex_v1.cxx:262
CxxUtils::CachedValue::set
void set(const T &val) const
Set the value, assuming it is currently invalid.
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
SG::AuxElement::operator=
AuxElement & operator=(const AuxElement &other)
Assignment.
xAOD::Vertex_v1::nNeutralParticles
size_t nNeutralParticles() const
Get the number of neutrals associated with this vertex.
Definition: Vertex_v1.cxx:301
SG::AuxElement::hasStore
bool hasStore() const
Return true if this object has an associated store.
Definition: AuxElement.cxx:355
xAOD::Vertex_v1::covariance
const std::vector< float > & covariance() const
Returns the covariance matrix as a simple vector of values.
xAOD::Vertex_v1::addNeutralAtVertex
void addNeutralAtVertex(const ElementLink< NeutralParticleContainer > &tr, float weight=1.0)
Add a new neutral to the vertex.
Definition: Vertex_v1.cxx:323
y
#define y
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
xAOD::Vertex_v1::resetCache
void resetCache()
Reset the internal cache of the object.
Definition: Vertex_v1.cxx:348
AUXSTORE_PRIMITIVE_GETTER
#define AUXSTORE_PRIMITIVE_GETTER(CL, TYPE, NAME)
Macro creating the reader function for a primitive auxiliary property.
Definition: AuxStoreAccessorMacros.h:59
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
SG::AuxElement::container
const SG::AuxVectorData * container() const
Return the container holding this element.
xAOD::Vertex_v1::vxTrackAtVertex
std::vector< Trk::VxTrackAtVertex > & vxTrackAtVertex()
Non-const access to the VxTrackAtVertex vector.
Definition: Vertex_v1.cxx:181
xAOD::NeutralParticle_v1
Class describing a NeutralParticle.
Definition: NeutralParticle_v1.h:40
xAODType::ObjectType
ObjectType
Type of objects that have a representation in the xAOD EDM.
Definition: ObjectType.h:32
xAOD::Vertex_v1::m_covariance
CxxUtils::CachedValue< AmgSymMatrix(3)> m_covariance
Cached covariance of the vertex.
Definition: Vertex_v1.h:193
xAOD::Vertex_v1::vxTrackAtVertexAvailable
bool vxTrackAtVertexAvailable() const
Check if VxTrackAtVertices are attached to the object.
Definition: Vertex_v1.cxx:209
xAOD::Vertex_v1::setCovariancePosition
void setCovariancePosition(const AmgSymMatrix(3)&covariancePosition)
Sets the vertex covariance matrix.
xAOD::neutralWeights
setTrackWeights neutralWeights
Definition: Vertex_v1.cxx:246
TrackParticleContainer.h
xAOD::AmgSymMatrix
AmgSymMatrix(N) toEigen(const ConstMatrixMap< N > &xAODmat)
Definition: MeasurementDefs.h:86
xAOD::Vertex_v1::neutralWeight
float neutralWeight(size_t i) const
Get the weight of a given neutral in the vertex reconstruction.
Definition: Vertex_v1.cxx:293
xAOD::AUXSTORE_OBJECT_SETTER_AND_GETTER
AUXSTORE_OBJECT_SETTER_AND_GETTER(CaloRings_v1, RingSetLinks, ringSetLinks, setRingSetLinks) unsigned CaloRings_v1
Definition: CaloRings_v1.cxx:27
xAOD::Vertex_v1::type
Type::ObjectType type() const
A little helper function for identifying the type in template code.
Definition: Vertex_v1.cxx:58