ATLAS Offline Software
VxCandidate.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /***************************************************************************
6  VxCandidate.cxx - Description
7  -------------------
8  begin : Autumn 2003
9  authors : Andreas Wildauer (CERN PH-ATC), Fredrik Akesson (CERN PH-ATC)
10  email : andreas.wildauer@cern.ch, fredrik.akesson@cern.ch
11 
12  ***************************************************************************/
13 
14 #include "VxVertex/VxCandidate.h"
15 #include "GaudiKernel/MsgStream.h"
17 
18 namespace Trk {
19 
21  : Trk::ObjectCounter<Trk::VxCandidate>()
22  , m_vertexType(Trk::NotSpecified)
23  , m_recVertex()
24  , m_vxTrackAtVertex()
25 {
26 }
27 
28 VxCandidate::VxCandidate(const Trk::RecVertex& recVertex,
29  const std::vector<Trk::VxTrackAtVertex*>& vxTrackAtVertex)
30 
32  , m_vertexType(Trk::NotSpecified)
33  , m_recVertex(recVertex)
34  , m_vxTrackAtVertex(vxTrackAtVertex)
35 {
36 }
37 
38 VxCandidate::VxCandidate(Trk::RecVertex&& recVertex,
39  std::vector<Trk::VxTrackAtVertex*>&& vxTrackAtVertex)
41  , m_vertexType(Trk::NotSpecified)
42  , m_recVertex(std::move(recVertex))
43  , m_vxTrackAtVertex(std::move(vxTrackAtVertex))
44 {
45 }
46 
49  , m_vertexType(rhs.m_vertexType)
50  , m_recVertex(rhs.m_recVertex)
51  , m_vxTrackAtVertex(std::vector<Trk::VxTrackAtVertex*>())
52 {
53  for (auto* itr : rhs.m_vxTrackAtVertex) {
54  m_vxTrackAtVertex.push_back(itr->clone());
55  }
56 } // end of copy-constructor
57 
58 VxCandidate&
59 VxCandidate::operator=(const VxCandidate& rhs)
60 {
61  if (this != &rhs) {
62  m_recVertex = rhs.m_recVertex;
63  m_vertexType = rhs.m_vertexType;
64  // delete objects where pointers pointed to
65  // (otherwise -> memory leak)
66  for (auto& i : m_vxTrackAtVertex) {
67  delete i;
68  }
69  // and clear the vector
70  m_vxTrackAtVertex.clear();
71  for (auto* itr : rhs.m_vxTrackAtVertex) {
72  m_vxTrackAtVertex.push_back(itr->clone());
73  }
74  }
75  return *this;
76 }
77 
78 VxCandidate&
79 VxCandidate::operator=(VxCandidate&& rhs) noexcept
80 {
81  if (this != &rhs) {
82  m_recVertex = std::move(rhs.m_recVertex);
83  m_vertexType = rhs.m_vertexType;
84  for (Trk::VxTrackAtVertex* tav : m_vxTrackAtVertex)
85  delete tav;
86  m_vxTrackAtVertex = std::move(rhs.m_vxTrackAtVertex);
87  }
88  return *this;
89 }
90 
92 {
93  for (auto& i : m_vxTrackAtVertex) {
94  delete i;
95  }
96 }
97 
98 MsgStream&
99 VxCandidate::dump(MsgStream& sl) const
100 {
101  sl << "Printing Trk::VxCandidate of type: " << m_vertexType << endmsg;
102  sl << m_recVertex << endmsg;
103  sl << "Tracks used in the vertex fit: " << m_vxTrackAtVertex.size() << endmsg;
104  for (unsigned i = 0; i < m_vxTrackAtVertex.size(); i++) {
105  sl << "Track " << i + 1 << " " << *(m_vxTrackAtVertex[i]);
106  }
107  return sl;
108 }
109 
110 std::ostream&
111 VxCandidate::dump(std::ostream& sl) const
112 {
113  sl << "Printing Trk::VxCandidate of type: " << m_vertexType << std::endl;
114  sl << m_recVertex << std::endl;
115  sl << "Tracks used in the vertex fit: " << m_vxTrackAtVertex.size() << std::endl;
116  for (unsigned i = 0; i < m_vxTrackAtVertex.size(); i++) {
117  sl << "Track " << i + 1 << " " << *(m_vxTrackAtVertex[i]);
118  }
119  return sl;
120 }
121 
122 MsgStream&
123 operator<<(MsgStream& sl, const VxCandidate& sf)
124 {
125  return sf.dump(sl);
126 }
127 
128 std::ostream&
129 operator<<(std::ostream& sl, const VxCandidate& sf)
130 {
131  return sf.dump(sl);
132 }
133 
134 } // end of namespace
Trk::VxTrackAtVertex
The VxTrackAtVertex is a common class for all present TrkVertexFitters The VxTrackAtVertex is designe...
Definition: VxTrackAtVertex.h:77
Trk::VxCandidate::m_vertexType
Trk::VertexType m_vertexType
Definition: VxCandidate.h:96
Trk::VxCandidate::operator=
VxCandidate & operator=(const VxCandidate &)
Definition: VxCandidate.cxx:66
Trk::ObjectCounter
Helper to enable counting number of instantiations in debug builds.
Definition: TrkObjectCounter.h:18
Trk::RecVertex
Trk::RecVertex inherits from Trk::Vertex.
Definition: RecVertex.h:44
Trk::VxCandidate::VxCandidate
VxCandidate()
Default constructor for persistency.
Definition: VxCandidate.cxx:27
Trk::VxCandidate::m_recVertex
Trk::RecVertex m_recVertex
Definition: VxCandidate.h:99
lumiFormat.i
int i
Definition: lumiFormat.py:85
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
vector
Definition: MultiHisto.h:13
Trk::NotSpecified
@ NotSpecified
this is the default
Definition: VertexType.h:36
Trk::VxCandidate::m_vxTrackAtVertex
std::vector< Trk::VxTrackAtVertex * > m_vxTrackAtVertex
Definition: VxCandidate.h:102
Trk::VxCandidate::dump
virtual MsgStream & dump(MsgStream &sl) const
Output Method for MsgStream, to be overloaded by child classes.
Definition: VxCandidate.cxx:106
VxTrackAtVertex.h
VxCandidate.h
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Trk::VxCandidate::~VxCandidate
virtual ~VxCandidate()
Virtual destructor, copy-constructor and assignement operator.
Definition: VxCandidate.cxx:98
mapkey::sf
@ sf
Definition: TElectronEfficiencyCorrectionTool.cxx:38
Trk::operator<<
MsgStream & operator<<(MsgStream &sl, const AlignModule &alignModule)
overload of << operator for MsgStream for debug output
Definition: AlignModule.cxx:204
Trk::VxCandidate
Definition: VxCandidate.h:27
xAOD::VxType::NotSpecified
@ NotSpecified
Default value, no explicit type set.
Definition: TrackingPrimitives.h:577