ATLAS Offline Software
Loading...
Searching...
No Matches
TrackParticleBase.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
8
11
12#include "GaudiKernel/MsgStream.h"
13
14//#define DEBUG_CTOR_DTOR
15
16namespace Trk
17{
18// Constructor 0
24 m_trackSummary(nullptr),
25 m_fitQuality(nullptr),
27 {
28 #ifdef DEBUG_CTOR_DTOR
29 std::cout<<"TrackParticleBase blank ctr :"<<this<<std::endl;
30 #endif
31 }
32
35 const TrackParticleOrigin trkPrtOrigin,
36 const VxCandidate* vxCandidate,
37 const TrackSummary* trkSummary,
38 std::vector<const TrackParameters*>& parameters,
39 const TrackParameters* definingParameter,
41 :
43 m_trackParticleOrigin( trkPrtOrigin ),
45 m_trackParameters( parameters ),
46 m_trackSummary( trkSummary ),
48 {
49 #ifdef DEBUG_CTOR_DTOR
50 std::cout<<"TrackParticleBase ctr :"<<this<<std::endl;
51 #endif
52
53 // if no vxCandidate set, then trkPrtOrigin should be NoVtx
54 assert ((vxCandidate!=nullptr)||(trkPrtOrigin==NoVtx));
55
56 // Defining parameter is always last.
57 m_trackParameters.push_back(definingParameter);
58
59 // establish element links
60 if (trk!=nullptr)
61 {
62 m_originalTrack.setElement(trk);
63 m_trackInfo = trk->info();
64 }
65 if (vxCandidate!=nullptr) { m_elVxCandidate.setElement(vxCandidate);
66}
67 }
68
70 const TrackParticleOrigin trkPrtOrigin,
71 const ElementLink<VxContainer>& vxCandidate,
72 std::unique_ptr<Trk::TrackSummary> trkSummary,
73 std::vector<const Trk::TrackParameters*>&& parameters,
74 std::unique_ptr<Trk::FitQuality> fitQuality,
75 const TrackInfo& info)
76 :
77 m_originalTrack(trackLink),
78 m_trackParticleOrigin( trkPrtOrigin ),
79 m_elVxCandidate(vxCandidate),
80 m_trackParameters( std::move(parameters) ),
81 m_trackSummary( trkSummary.release() ),
84 {
85 // if no vxCandidate set, then trkPrtOrigin should be NoVtx
86 assert (!vxCandidate.isDefault() || trkPrtOrigin==NoVtx);
87 }
88
93 :
98 m_trackSummary( (rhs.m_trackSummary) ? new TrackSummary(*(rhs.m_trackSummary)) : nullptr ),
99 m_fitQuality( (rhs.m_fitQuality) ? new FitQuality(*(rhs.m_fitQuality)) : nullptr ),
101 {
102
103 #ifdef DEBUG_CTOR_DTOR
104 std::cout<<"TrackParticleBase copy ctr :"<<this<<std::endl;
105 #endif
106
107 std::vector<const TrackParameters*>::const_iterator it = rhs.m_trackParameters.begin();
108 std::vector<const TrackParameters*>::const_iterator itEnd = rhs.m_trackParameters.end();
109 for (; it!=itEnd; ++it) { m_trackParameters.push_back( (*it)->clone() );
110}
111 }
112
117 {
118 if (this!=&rhs)
119 {
120 // only delete objects where these two pointers point to
121 // the other pointers point to objects in storegate
122 if (m_trackSummary!=nullptr) { delete m_trackSummary; m_trackSummary = nullptr; }
123 if (m_fitQuality !=nullptr) { delete m_fitQuality ; m_fitQuality = nullptr; }
124 std::vector<const TrackParameters*>::const_iterator it = m_trackParameters.begin();
125 std::vector<const TrackParameters*>::const_iterator itEnd = m_trackParameters.end();
126 for (; it!=itEnd; ++it) { delete (*it);
127 }
128
132
133 //the following are owned, and so must be copied.
134 m_trackSummary = (rhs.m_trackSummary) ? new TrackSummary(*(rhs.m_trackSummary)) : nullptr;
135 m_fitQuality = (rhs.m_fitQuality) ? new FitQuality(*(rhs.m_fitQuality)) : nullptr;
137
138 it = rhs.m_trackParameters.begin();
139 itEnd = rhs.m_trackParameters.end();
140 for (; it!=itEnd; ++it) { m_trackParameters.push_back( (*it)->clone() );
141 }
142 }
143 return *this;
144 }
145
148 {
149 if (this != &rhs) {
150 delete m_trackSummary;
151 m_trackSummary = rhs.m_trackSummary;
152 rhs.m_trackSummary = nullptr;
153
154 delete m_fitQuality;
155 m_fitQuality = rhs.m_fitQuality;
156 rhs.m_fitQuality = nullptr;
157
158 for (const TrackParameters* p : m_trackParameters) {
159 delete p;
160 }
161
162 m_trackParameters = std::move(rhs.m_trackParameters);
163
164 m_originalTrack = rhs.m_originalTrack;
165 m_trackParticleOrigin = rhs.m_trackParticleOrigin;
166 m_elVxCandidate = rhs.m_elVxCandidate;
167
168 m_trackInfo = rhs.m_trackInfo;
169 }
170 return *this;
171 }
172
177 #ifdef DEBUG_CTOR_DTOR
178 std::cout<<"TrackParticleBase dtor :"<<this<<std::endl;
179 #endif
180 std::vector<const TrackParameters*>::const_iterator it = m_trackParameters.begin();
181 std::vector<const TrackParameters*>::const_iterator itEnd = m_trackParameters.end();
182 for (; it!=itEnd; ++it) { delete (*it);
183}
184 if (m_trackSummary!=nullptr) { delete m_trackSummary;
185}
186 if (m_fitQuality !=nullptr) { delete m_fitQuality;
187}
188 }
189
190 MsgStream& TrackParticleBase::dump( MsgStream& sl ) const
191 {
192 // DO NOT specificy an output level like MSG::VERBOSE (should be done by the caller)
193 sl << "Printing TrackParticle. OriginType: " << this->particleOriginType() << endmsg;
194 if (this->trackElementLink()->isValid())
195 {
196 sl << "The ElementLink<TrackCollection> is valid." << endmsg;
197 } else
198 {
199 sl << "The ElementLink<TrackCollection> is NOT valid." << endmsg;
200 }
201 if ( this->fitQuality() !=nullptr ) { sl << * ( this->fitQuality() ) <<endmsg;
202}
203 if ( this->trackSummary() !=nullptr ) { sl << * ( this->trackSummary() ) <<endmsg;
204}
205 // vertex EL should alwasy be there as it is in ESD and AOD
206 if ( this->reconstructedVertex() !=nullptr ) { sl << ( this->reconstructedVertex()->recVertex() ) <<endmsg;
207}
208 const std::vector<const TrackParameters*> trackParameters = this->trackParameters();
209 sl << "TrackParticle has " << trackParameters.size() << " track parameters. Printing them:" << endmsg;
210 for (const auto *trackParameter : trackParameters)
211 {
212 sl << (*trackParameter) << endmsg;
213 }
214 sl<<"TrackInfo inherited from original Track comes below:"<<endmsg;
215 sl<<m_trackInfo.dumpInfo();
216 return sl;
217 }
218
219 std::ostream& TrackParticleBase::dump( std::ostream& sl ) const
220 {
221 sl << "Printing TrackParticle. OriginType: " << this->particleOriginType() << std::endl;
222 if (this->trackElementLink()->isValid())
223 {
224 sl << "The ElementLink<TrackCollection> is valid." << std::endl;
225 } else
226 {
227 sl << "The ElementLink<TrackCollection> is NOT valid." << std::endl;
228 }
229 if ( this->fitQuality() !=nullptr ) { sl << * ( this->fitQuality() ) <<std::endl;
230}
231 if ( this->trackSummary() !=nullptr ) { sl << * ( this->trackSummary() ) <<std::endl;
232}
233 // vertex EL should alwasy be there as it is in ESD and AOD
234 if ( this->reconstructedVertex() !=nullptr ) { sl << ( this->reconstructedVertex()->recVertex() ) <<std::endl;
235}
236 const std::vector<const TrackParameters*> trackParameters = this->trackParameters();
237 sl << "TrackParticle has " << trackParameters.size() << " track parameters. Printing them:" << std::endl;
238 for (const auto *trackParameter : trackParameters)
239 {
240 sl << (*trackParameter) << std::endl;
241 }
242 sl<<"TrackInfo inherited from original Track comes below:"<<std::endl;
243 sl<<m_trackInfo.dumpInfo();
244 return sl;
245 }
246
247 MsgStream& operator << ( MsgStream& sl, const TrackParticleBase& trackParticleBase)
248 {
249 trackParticleBase.dump(sl);
250 return sl;
251 }
252
253 std::ostream& operator << ( std::ostream& sl, const TrackParticleBase& trackParticleBase)
254 {
255 trackParticleBase.dump(sl);
256 return sl;
257 }
258}
#define endmsg
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
Definition AtlasPID.h:878
bool isDefault() const
Test to see if this link is in the default state.
Class to represent and store fit qualities from track reconstruction in terms of and number of degre...
Definition FitQuality.h:97
Contains information about the 'fitter' of this track.
TrackParticleBase & operator=(const TrackParticleBase &)
Assignement operator.
const TrackSummary * m_trackSummary
the summary of this TrackParticle.
const ElementLink< TrackCollection > * trackElementLink() const
Return the ElementLink to the Track.
const FitQuality * m_fitQuality
the fit quality of this TrackParticle.
const FitQuality * fitQuality() const
accessor function for FitQuality.
ElementLink< TrackCollection > m_originalTrack
ElementLink to the Track used to create this TrackParticleBase object Before writing to disk,...
virtual MsgStream & dump(MsgStream &out) const
Dump methods to be used by the overloaded stream operator (inheritance!)
const TrackSummary * trackSummary() const
accessor function for TrackSummary.
TrackParticleBase()
Constructor 0 standard constructor which sets everything to 0, needed for persistency.
TrackInfo m_trackInfo
This is a class which stores the identity of where the track was created, fitted,...
virtual ~TrackParticleBase()
Destructor.
const std::vector< const TrackParameters * > & trackParameters() const
Returns the track parameters.
TrackParticleOrigin m_trackParticleOrigin
specifies the origin type of the particle (prim.vertex, ...)
const VxCandidate * reconstructedVertex() const
Get a pointer to the primary vertex.
TrackParticleOrigin particleOriginType() const
Get the particle origin type.
std::vector< const TrackParameters * > m_trackParameters
DataVector of TrackParameters stored inside this TrackParticle.
const TrackInfo & info() const
returns the info of the track.
ElementLink< VxContainer > m_elVxCandidate
ElementLink to a VxCandidate.
A summary of the information contained by a track.
const TrackInfo & info() const
Returns a const ref to info of a const tracks.
const Trk::RecVertex & recVertex(void) const
Returns a reference to reconstructed vertex.
static std::string release
Definition computils.h:50
Ensure that the ATLAS eigen extensions are properly loaded.
@ NoVtx
Dummy vertex, TrackParticle was not used in vertex fit.
Definition VertexType.h:26
MsgStream & operator<<(MsgStream &sl, const AlignModule &alignModule)
overload of << operator for MsgStream for debug output
VertexType TrackParticleOrigin
ParametersBase< TrackParametersDim, Charged > TrackParameters
STL namespace.