ATLAS Offline Software
VxSecVertexInfo.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 /****************************************
6 
7  VxSecVertexInfo.h - Description
8  -------------------
9 
10  begin: March 2007
11  authors: CSC vertexing note group members :-)
12  work started by: Giacinto Piacquadio (University of Freiburg)
13  e-mail: giacinto.piacquadio@physik.uni-freiburg.de
14  changes: new!
15 
16  April 2014: Replace Trk::VxCandidate by xAOD::Vertex
17 ********************************************/
18 
20 #include <ostream>
21 
22 namespace Trk {
23 
24  VxSecVertexInfo::VxSecVertexInfo(): m_SVOwnership(false) {}
25 
26  VxSecVertexInfo::VxSecVertexInfo(std::vector<xAOD::Vertex*> vertices): m_vertices(std::move(vertices)), m_SVOwnership(false) {
27 
28  }
29 
30  VxSecVertexInfo::~VxSecVertexInfo() {
31  std::vector<xAOD::Vertex*>::const_iterator verticesBegin=m_vertices.begin();
32  std::vector<xAOD::Vertex*>::const_iterator verticesEnd=m_vertices.end();
33 
34  if(m_SVOwnership){ // Delete vertices only if ownership is set explicitly
35  for (std::vector<xAOD::Vertex*>::const_iterator verticesIter=verticesBegin;
36  verticesIter!=verticesEnd;++verticesIter) {
37  xAOD::Vertex* myCandidate=*verticesIter;
38  if (myCandidate!=nullptr) {
39  delete myCandidate;
40  } else {
41  std::cout << " Warning in VxSecVertexInfo: tried to delete a zero pointer --> Inconsistency found. " << std::endl;
42  }
43  }
44  }
45  }
46 
47  VxSecVertexInfo::VxSecVertexInfo(const VxSecVertexInfo & rhs) {
48 
49  std::vector<xAOD::Vertex*>::const_iterator verticesBegin=rhs.m_vertices.begin();
50  std::vector<xAOD::Vertex*>::const_iterator verticesEnd=rhs.m_vertices.end();
51 
52  for (std::vector<xAOD::Vertex*>::const_iterator verticesIter=verticesBegin;
53  verticesIter!=verticesEnd;++verticesIter) {
54  xAOD::Vertex* myCandidate=*verticesIter;
55  if (myCandidate!=nullptr) {
56  m_vertices.push_back(new xAOD::Vertex(*myCandidate));
57  } else {
58  std::cout << " Warning in VxSecVertexInfo: tried in copy constructor to copy over a zero pointer Vertex " << std::endl;
59  }
60  }
61  m_SVOwnership=false;
62  }
63 
64  VxSecVertexInfo& VxSecVertexInfo::operator= (const VxSecVertexInfo & rhs) {
65 
66  if (this!=&rhs) {
67 
68  m_vertices.clear();
69 
70  std::vector<xAOD::Vertex*>::const_iterator verticesBegin=rhs.m_vertices.begin();
71  std::vector<xAOD::Vertex*>::const_iterator verticesEnd=rhs.m_vertices.end();
72 
73  for (std::vector<xAOD::Vertex*>::const_iterator verticesIter=verticesBegin;
74  verticesIter!=verticesEnd;++verticesIter) {
75  xAOD::Vertex* myCandidate=*verticesIter;
76  if (myCandidate!=nullptr) {
77  m_vertices.push_back(new xAOD::Vertex(*myCandidate));
78  } else {
79  std::cout << " Warning in VxSecVertexInfo: tried in copy constructor to copy over a zero pointer Vertex " << std::endl;
80  }
81  }
82  m_SVOwnership=false;
83  }
84  return *this;
85  }
86 
87 
88  const std::vector<xAOD::Vertex*> & VxSecVertexInfo::vertices() const {
89  return m_vertices;
90  }
91 
92  void VxSecVertexInfo::setVertices(const std::vector<xAOD::Vertex*> & vertices) {
93  m_vertices=vertices;
94  }
95 
96 }//end namespace Trk
Trk::VxSecVertexInfo::VxSecVertexInfo
VxSecVertexInfo()
Definition: VxSecVertexInfo.cxx:36
VxSecVertexInfo.h
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42