ATLAS Offline Software
SelectedTracksInJet.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /***************************************************************************
6  SelectedTracksInJet.cxx - Description
7  -------------------
8  begin : Jan 2008
9  authors : Giacinto Piacquadio (University of Freiburg)
10  Christian Weiser (University of Freiburg)
11  e-mails: giacinto.piacquadio@physik.uni-freiburg.de)
12  christian.weiser@cern.ch
13  changes: new!
14 
15  (C) Atlas Collaboration 2008
16 
17  More information contained in the header file
18 
19  ***************************************************************************/
20 
22 
23 namespace Trk {
24 
26 
27 
29  {
32 
33  for (std::vector<const ITrackLink*>::iterator trackIter=trackBegin;
34  trackIter!=trackEnd;++trackIter)
35  {
36  if (*trackIter!=0)
37  {
38  delete *trackIter;
39  *trackIter=0;
40  }
41  }
42 
43  trackBegin=m_secondaryTrackLinks.begin();
44  trackEnd=m_secondaryTrackLinks.end();
45 
46  for (std::vector<const ITrackLink*>::iterator trackIter=trackBegin;
47  trackIter!=trackEnd;++trackIter)
48  {
49  if (*trackIter!=0)
50  {
51  delete *trackIter;
52  *trackIter=0;
53  }
54  }
55  }
56 
57  SelectedTracksInJet::SelectedTracksInJet(std::vector<const ITrackLink*> & primaryTrackLinks,
58  std::vector<const ITrackLink*> & secondaryTrackLinks)
59  : m_primaryTrackLinks(primaryTrackLinks),
60  m_secondaryTrackLinks(secondaryTrackLinks)
61  {}
62 
63  SelectedTracksInJet::SelectedTracksInJet(const SelectedTracksInJet& rhs)
64  {
65 
66  std::vector<const ITrackLink*>::const_iterator trackBegin=rhs.m_primaryTrackLinks.begin();
67  std::vector<const ITrackLink*>::const_iterator trackEnd=rhs.m_primaryTrackLinks.end();
68 
69  for (std::vector<const ITrackLink*>::const_iterator trackIter=trackBegin;
70  trackIter!=trackEnd;++trackIter)
71  {
72  if (*trackIter!=nullptr)
73  {
74  m_primaryTrackLinks.push_back((*trackIter)->clone());
75  }
76  }
77 
78  trackBegin=rhs.m_secondaryTrackLinks.begin();
79  trackEnd=rhs.m_secondaryTrackLinks.end();
80 
81  for (std::vector<const ITrackLink*>::const_iterator trackIter=trackBegin;
82  trackIter!=trackEnd;++trackIter)
83  {
84  if (*trackIter!=nullptr)
85  {
86  m_secondaryTrackLinks.push_back((*trackIter)->clone());
87  }
88  }
89  }
90 
91  SelectedTracksInJet & SelectedTracksInJet::operator= (const SelectedTracksInJet & rhs)
92  {
93  if (this!=&rhs)
94  {
95  // delete first all preceding data
96  for (const ITrackLink* l : m_primaryTrackLinks) {
97  delete l;
98  }
99  m_primaryTrackLinks.clear();
100  for (const ITrackLink* l : m_secondaryTrackLinks) {
101  delete l;
102  }
103  m_secondaryTrackLinks.clear();
104 
105  for (const ITrackLink* l : rhs.m_primaryTrackLinks) {
106  if (l) {
107  m_primaryTrackLinks.push_back(l->clone());
108  }
109  }
110  for (const ITrackLink* l : rhs.m_secondaryTrackLinks) {
111  if (l) {
112  m_secondaryTrackLinks.push_back(l->clone());
113  }
114  }
115 
116  }
117  return *this;
118  }
119 
120 
121  void SelectedTracksInJet::setPrimaryTrackLinks(std::vector<const ITrackLink*> & primaryTrackLinks)
122  {
125 
126  for (std::vector<const ITrackLink*>::iterator trackIter=trackBegin;
127  trackIter!=trackEnd;++trackIter)
128  {
129  if (*trackIter!=0)
130  {
131  delete *trackIter;
132  }
133  }
134  m_primaryTrackLinks=primaryTrackLinks;
135  }
136 
137  void SelectedTracksInJet::setSecondaryTrackLinks(std::vector<const ITrackLink*> & secondaryTracLinks)
138  {
141 
142  for (std::vector<const ITrackLink*>::iterator trackIter=trackBegin;
143  trackIter!=trackEnd;++trackIter)
144  {
145  if (*trackIter!=0)
146  {
147  delete *trackIter;
148  }
149  }
150  m_secondaryTrackLinks=secondaryTracLinks;
151  }
152 
153  const std::vector<const ITrackLink*> & SelectedTracksInJet::getPrimaryTrackLinks() const
154  {
155  return m_primaryTrackLinks;
156  }
157 
158  const std::vector<const ITrackLink*> & SelectedTracksInJet::getSecondaryTrackLinks() const
159  {
160  return m_secondaryTrackLinks;
161  }
162 
163 }//end namespace Trk
164 
165 
166 
167 
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
Trk::SelectedTracksInJet::setPrimaryTrackLinks
void setPrimaryTrackLinks(std::vector< const ITrackLink * > &primaryTrackLinks)
Set the primary tracks (takes ownership of pointers)
Definition: SelectedTracksInJet.cxx:135
Trk::SelectedTracksInJet::getSecondaryTrackLinks
const std::vector< const ITrackLink * > & getSecondaryTrackLinks() const
Get the secondary tracks (please do not delete the pointers)
Definition: SelectedTracksInJet.cxx:172
Trk::SelectedTracksInJet::SelectedTracksInJet
SelectedTracksInJet()
Default constructor, if called initializes a VxVertexOnJetAxis with all data members set to 0.
SelectedTracksInJet.h
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
Trk::SelectedTracksInJet::getPrimaryTrackLinks
const std::vector< const ITrackLink * > & getPrimaryTrackLinks() const
Get the priamry tracks (please do not delete the pointers)
Definition: SelectedTracksInJet.cxx:167
Trk::SelectedTracksInJet::m_secondaryTrackLinks
std::vector< const ITrackLink * > m_secondaryTrackLinks
Definition: SelectedTracksInJet.h:136
Trk::SelectedTracksInJet::setSecondaryTrackLinks
void setSecondaryTrackLinks(std::vector< const ITrackLink * > &secondaryTracLinks)
Set the secondary tracks (takes ownership of pointers)
Definition: SelectedTracksInJet.cxx:151
Trk::SelectedTracksInJet::~SelectedTracksInJet
~SelectedTracksInJet()
Destructor.
Definition: SelectedTracksInJet.cxx:42
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Trk::SelectedTracksInJet::m_primaryTrackLinks
std::vector< const ITrackLink * > m_primaryTrackLinks
Definition: SelectedTracksInJet.h:135
Trk::SelectedTracksInJet::operator=
SelectedTracksInJet & operator=(const SelectedTracksInJet &)
Definition: SelectedTracksInJet.cxx:105