ATLAS Offline Software
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 
7 #include "VxVertex/VxCandidate.h"
8 
11 
12 #include "GaudiKernel/MsgStream.h"
13 
14 //#define DEBUG_CTOR_DTOR
15 
16 namespace Trk
17 {
18 // Constructor 0
20  m_originalTrack(),
21  m_trackParticleOrigin(NoVtx),
22  m_elVxCandidate(),
23  m_trackParameters(0),
24  m_trackSummary(nullptr),
25  m_fitQuality(nullptr),
26  m_trackInfo()
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,
40  const FitQuality* fitQuality)
41  :
42  m_originalTrack(),
43  m_trackParticleOrigin( trkPrtOrigin ),
44  m_elVxCandidate(),
45  m_trackParameters( parameters ),
46  m_trackSummary( trkSummary ),
47  m_fitQuality(fitQuality)
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  {
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() ),
82  m_fitQuality(fitQuality.release()),
83  m_trackInfo (info)
84  {
85  // if no vxCandidate set, then trkPrtOrigin should be NoVtx
86  assert (!vxCandidate.isDefault() || trkPrtOrigin==NoVtx);
87  }
88 
93  :
94  m_originalTrack(rhs.m_originalTrack),
95  m_trackParticleOrigin(rhs.m_trackParticleOrigin),
96  m_elVxCandidate(rhs.m_elVxCandidate),
97  m_trackParameters(),
98  m_trackSummary( (rhs.m_trackSummary) ? new TrackSummary(*(rhs.m_trackSummary)) : nullptr ),
99  m_fitQuality( (rhs.m_fitQuality) ? new FitQuality(*(rhs.m_fitQuality)) : nullptr ),
100  m_trackInfo(rhs.m_trackInfo)
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;
136  m_trackInfo = rhs.m_trackInfo;
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 }
grepfile.info
info
Definition: grepfile.py:38
Trk::TrackParticleBase::particleOriginType
TrackParticleOrigin particleOriginType() const
Get the particle origin type.
Definition: TrackParticleBase.h:235
Trk::TrackParticleBase::operator=
TrackParticleBase & operator=(const TrackParticleBase &)
Assignement operator.
Definition: TrackParticleBase.cxx:116
Trk::TrackInfo
Contains information about the 'fitter' of this track.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/TrackInfo.h:32
Trk::VxCandidate::recVertex
const Trk::RecVertex & recVertex(void) const
Returns a reference to reconstructed vertex.
Definition: VxCandidate.h:132
Trk::Track::info
const TrackInfo & info() const
Returns a const ref to info of a const tracks.
TrackParticleBase.h
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
Trk::VertexType
VertexType
Definition: VertexType.h:25
Trk::TrackParticleBase::trackSummary
const TrackSummary * trackSummary() const
accessor function for TrackSummary.
Definition: TrackParticleBase.h:247
skel.it
it
Definition: skel.GENtoEVGEN.py:396
Trk::TrackParticleBase::dump
virtual MsgStream & dump(MsgStream &out) const
Dump methods to be used by the overloaded stream operator (inheritance!)
Definition: TrackParticleBase.cxx:190
isValid
bool isValid(const T &p)
Definition: AtlasPID.h:225
ParamDefs.h
Trk::TrackParticleBase
Definition: TrackParticleBase.h:41
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
Trk::TrackParticleBase::~TrackParticleBase
virtual ~TrackParticleBase()
Destructor.
Definition: TrackParticleBase.cxx:176
Trk::NoVtx
@ NoVtx
Dummy vertex, TrackParticle was not used in vertex fit.
Definition: VertexType.h:26
Trk::TrackParticleBase::trackElementLink
const ElementLink< TrackCollection > * trackElementLink() const
Return the ElementLink to the Track.
Definition: TrackParticleBase.h:230
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
Trk::TrackParticleBase::m_elVxCandidate
ElementLink< VxContainer > m_elVxCandidate
ElementLink to a VxCandidate.
Definition: TrackParticleBase.h:170
Trk::TrackParticleBase::TrackParticleBase
TrackParticleBase()
Constructor 0 standard constructor which sets everything to 0, needed for persistency.
Definition: TrackParticleBase.cxx:19
Trk::TrackParticleBase::fitQuality
const FitQuality * fitQuality() const
accessor function for FitQuality.
Definition: TrackParticleBase.h:259
Trk::FitQuality
Class to represent and store fit qualities from track reconstruction in terms of and number of degre...
Definition: FitQuality.h:97
TrackSummary.h
Trk::ParametersBase
Definition: ParametersBase.h:55
VxCandidate.h
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
python.EventInfoMgtInit.release
release
Definition: EventInfoMgtInit.py:24
Trk::TrackParticleBase::reconstructedVertex
const VxCandidate * reconstructedVertex() const
Get a pointer to the primary vertex.
Definition: TrackParticleBase.h:215
Trk::TrackSummary
A summary of the information contained by a track.
Definition: Tracking/TrkEvent/TrkTrackSummary/TrkTrackSummary/TrackSummary.h:287
Trk::TrackParticleBase::trackParameters
const std::vector< const TrackParameters * > & trackParameters() const
Returns the track parameters.
Definition: TrackParticleBase.h:243
Trk::TrackInfo::dumpInfo
std::string dumpInfo() const
Returns a string with the name of the fitter of this track (i.e.
Definition: Tracking/TrkEvent/TrkTrack/src/TrackInfo.cxx:45
SG::GenericElementLinkBase::isDefault
bool isDefault() const
Test to see if this link is in the default state.
Trk::TrackParticleBase::m_fitQuality
const FitQuality * m_fitQuality
the fit quality of this TrackParticle.
Definition: TrackParticleBase.h:179
Trk::GsfMeasurementUpdator::fitQuality
FitQualityOnSurface fitQuality(const MultiComponentState &, const MeasurementBase &)
Method for determining the chi2 of the multi-component state and the number of degrees of freedom.
Definition: GsfMeasurementUpdator.cxx:845
Trk::TrackParticleBase::m_trackInfo
TrackInfo m_trackInfo
This is a class which stores the identity of where the track was created, fitted,...
Definition: TrackParticleBase.h:186
Trk::TrackParticleBase::m_trackParameters
std::vector< const TrackParameters * > m_trackParameters
DataVector of TrackParameters stored inside this TrackParticle.
Definition: TrackParticleBase.h:173
Trk::TrackParticleBase::m_trackSummary
const TrackSummary * m_trackSummary
the summary of this TrackParticle.
Definition: TrackParticleBase.h:176
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
Trk::TrackParticleBase::m_originalTrack
ElementLink< TrackCollection > m_originalTrack
ElementLink to the Track used to create this TrackParticleBase object Before writing to disk,...
Definition: TrackParticleBase.h:164
physics_parameters.parameters
parameters
Definition: physics_parameters.py:144
Track
Definition: TriggerChamberClusterOnTrackCreator.h:21
FitQuality.h
Trk::TrackParticleBase::m_trackParticleOrigin
TrackParticleOrigin m_trackParticleOrigin
specifies the origin type of the particle (prim.vertex, ...)
Definition: TrackParticleBase.h:167
xAOD::TrackSummary
TrackSummary_v1 TrackSummary
Definition: Event/xAOD/xAODTracking/xAODTracking/TrackSummary.h:10
python.Dumpers.FitQuality
FitQuality
Definition: Dumpers.py:63