QwAnalysis
QwTrack.cc
Go to the documentation of this file.
1 #include "QwTrack.h"
3 
4 /**
5  * Default constructor
6  */
8 {
9  // Initialize
10  Initialize();
11 }
12 
13 /**
14  * Constructor with front and back partial track
15  * @param front Front partial track
16  * @param back Back partial track
17  */
19 {
20  // Initialize
21  Initialize();
22 
23  // Null pointer
24  if (front == 0 || back == 0) return;
25 
26  if (front->GetPackage() == back->GetPackage())
27  SetPackage(front->GetPackage());
28 
29  // Copy tracks
30  fFront = new QwPartialTrack(front);
31  fBack = new QwPartialTrack(back);
32 
33  // Add partial tracks
34  AddPartialTrack(front);
35  AddPartialTrack(back);
36 }
37 
38 /**
39  * Copy constructor by reference
40  * @param that Original track
41  */
43 : VQwTrackingElement(that)
44 {
45  // Initialize
46  Initialize();
47 
48  *this = that;
49 
50  // Copy tracks
51  fFront = new QwPartialTrack(that.fFront);
52  fBack = new QwPartialTrack(that.fBack);
53 }
54 
55 /**
56  * Copy constructor from pointer
57  * @param that Original track
58  */
60 : VQwTrackingElement(*that)
61 {
62  // Initialize
63  Initialize();
64 
65  // Null pointer
66  if (that == 0) return;
67 
68  *this = *that;
69 
70  // Copy tracks
71  if (that->fFront) fFront = new QwPartialTrack(that->fFront);
72  if (that->fBack) fBack = new QwPartialTrack(that->fBack);
73 }
74 
75 /**
76  * Virtual destructor
77  */
79 {
80  // Delete objects
81  if (fFront) delete fFront;
82  if (fBack) delete fBack;
83 
85 }
86 
87 /**
88  * Assignment operator
89  * @param that Original track
90  */
92 {
93  if (this == &that) return *this;
94 
96 
97  fPhi = that.fPhi;
98  fTheta = that.fTheta;
99  fVertexZ = that.fVertexZ;
100  fVertexR = that.fVertexR;
101 
102  fChi = that.fChi;
103  fMomentum = that.fMomentum;
104 
107 
114 
121 
124 
127 
130 
134 
138 
139  // Copy partial tracks
142 
143  return *this;
144 }
145 
146 /**
147  * Initialization
148  */
150 {
151  // Initialize the members;
152  fChi = 0.0;
153  fMomentum = 0.0;
154 
155  // Initialize all pointers
156  fFront = 0;
157  fBack = 0;
158 }
159 
160 
161 
162 // Create a new QwPartialTrack
164 {
165  QwPartialTrack* partialtrack = new QwPartialTrack();
166  AddPartialTrack(partialtrack);
167  return partialtrack;
168 }
169 
170 // Add an existing QwPartialTrack
171 void QwTrack::AddPartialTrack(const QwPartialTrack* partialtrack)
172 {
173  fQwPartialTracks.push_back(new QwPartialTrack(partialtrack));
175 }
176 
177 // Add a list of partial tracks
178 void QwTrack::AddPartialTrackList(const std::vector<QwPartialTrack*> &partialtracklist)
179 {
180  for (std::vector<QwPartialTrack*>::const_iterator partialtrack = partialtracklist.begin();
181  partialtrack != partialtracklist.end(); partialtrack++)
182  AddPartialTrack(*partialtrack);
183 }
184 
185 // Clear the local TClonesArray of partial tracks
186 void QwTrack::ClearPartialTracks(Option_t *option)
187 {
188  for (size_t i = 0; i < fQwPartialTracks.size(); i++) {
189  QwPartialTrack* tl = fQwPartialTracks.at(i);
190  delete tl;
191  }
192  fQwPartialTracks.clear();
193  fNQwPartialTracks = 0;
194 }
195 
196 // Delete the static TClonesArray of partial tracks
197 void QwTrack::ResetPartialTracks(Option_t *option)
198 {
200 }
201 
202 // Print the partial tracks
203 void QwTrack::PrintPartialTracks(Option_t *option) const
204 {
205  for (std::vector<QwPartialTrack*>::const_iterator partialtrack = fQwPartialTracks.begin();
206  partialtrack != fQwPartialTracks.end(); partialtrack++) {
207  QwMessage << **partialtrack << QwLog::endl;
208  }
209 }
210 
211 
212 /**
213  * Output stream operator overloading
214  */
215 std::ostream& operator<< (std::ostream& stream, const QwTrack& t)
216 {
217  stream << "track: ";
218  stream << "(" << t.GetRegion() << "/" << "?UD"[t.GetPackage()] << ") ";
219  stream << "Start: " << t.fStartPosition << "/" << t.fStartDirection << std::endl;
220  stream << "End (goal): " << t.fEndPositionGoal << "/" << t.fEndDirectionGoal << std::endl;
221  stream << "End (actual): " << t.fEndPositionActual << "/" << t.fEndDirectionActual << std::endl;
222  return stream;
223 }
double fDirectionYoff
Difference in Y momentum at matching plane.
Definition: QwTrack.h:115
#define QwMessage
Predefined log drain for regular messages.
Definition: QwLog.h:50
double fChi
Combined chi, i.e. the sum of the chi for front and back partial track.
Definition: QwTrack.h:99
int fIterationsRungeKutta
Number of iterations in Runge-Kutta method.
Definition: QwTrack.h:103
double fDirectionThetaoff
Difference in momentum polar angle at matching plane.
Definition: QwTrack.h:118
std::ostream & operator<<(std::ostream &out, const QwColor &color)
Output stream operator which uses the enum-to-escape-code mapping.
Definition: QwColor.h:153
double fPositionPhioff
Difference in azimuthal angle phi at matching plane.
Definition: QwTrack.h:111
int fIterationsRK4
Number of iterations using Runge-Kutta 4th order.
Definition: QwTrack.h:132
int fIterationsNewton
Number of iterations in Newton&#39;s method.
Definition: QwTrack.h:102
QwTrack & operator=(const QwTrack &that)
Assignment operator.
Definition: QwTrack.cc:91
TVector3 fStartPosition
Position and direction before and after swimming.
Definition: QwTrack.h:123
TVector3 fEndPositionActualRK4
Actual position of track at back plane using Runge-Kutta 4th order.
Definition: QwTrack.h:133
TVector3 fDirectionDiff
Difference in momentum at matching plane.
Definition: QwTrack.h:113
void SetPackage(EQwDetectorPackage package)
Set the package.
double fDirectionPhioff
Difference in momentum azimuthal angle at matching plane.
Definition: QwTrack.h:117
Definition of the track class.
double fPositionRoff
Difference in radial position at matching plane.
Definition: QwTrack.h:110
EQwRegionID GetRegion() const
Get the region.
virtual ~QwTrack()
Virtual destructor.
Definition: QwTrack.cc:78
TVector3 fEndDirectionActual
Actual direction of track at back plane.
Definition: QwTrack.h:130
TVector3 fStartDirection
Start direction of front track.
Definition: QwTrack.h:124
void ResetPartialTracks(Option_t *option="")
Definition: QwTrack.cc:197
VQwTrackingElement & operator=(const VQwTrackingElement &that)
Assignment operator.
QwTrack()
Default constructor.
Definition: QwTrack.cc:7
Int_t fNQwPartialTracks
Number of partial tracks in this track.
Definition: QwTrack.h:35
TVector3 fEndPositionActual
Actual position of track at back plane.
Definition: QwTrack.h:129
Contains the complete track as a concatenation of partial tracks.
Definition: QwTrack.h:30
double fDirectionXoff
Difference in X momentum at matching plane.
Definition: QwTrack.h:114
QwPartialTrack * CreateNewPartialTrack()
Definition: QwTrack.cc:163
double fDirectionZoff
Difference in Z momentum at matching plane.
Definition: QwTrack.h:116
TVector3 fEndPositionActualRKF45
Actual position of track at back plane using Runge-Kutta-Fehlberg.
Definition: QwTrack.h:137
void PrintPartialTracks(Option_t *option="") const
Definition: QwTrack.cc:203
void Initialize()
Initialization.
Definition: QwTrack.cc:149
TVector3 fPositionDiff
Matching of front and back track position and direction at matching plane.
Definition: QwTrack.h:107
void AddPartialTrack(const QwPartialTrack *partialtrack)
Definition: QwTrack.cc:171
void AddPartialTrackList(const std::vector< QwPartialTrack * > &partialtracklist)
Definition: QwTrack.cc:178
TVector3 fEndDirectionGoal
Goal direction of back track.
Definition: QwTrack.h:127
double fPhi
Quantities determined from front partial track.
Definition: QwTrack.h:93
QwPartialTrack * fBack
Back partial track.
Definition: QwTrack.h:148
int fIterationsRKF45
Number of iterations using Runge-Kutta-Fehlberg.
Definition: QwTrack.h:136
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
TVector3 fEndPositionGoal
Goal position of back track.
Definition: QwTrack.h:126
double fPositionXoff
Difference in X position at matching plane.
Definition: QwTrack.h:108
QwPartialTrack * fFront
Front partial track.
Definition: QwTrack.h:147
ClassImp(QwF1TDC)
TVector3 fEndDirectionActualRK4
Actual direction of track at back plane using Runge-Kutta 4th order.
Definition: QwTrack.h:134
double fPositionYoff
Difference in Y position at matching plane.
Definition: QwTrack.h:109
TVector3 fEndDirectionActualRKF45
Actual direction of track at back plane using Runge-Kutta-Fehlberg.
Definition: QwTrack.h:138
double fPositionThetaoff
Difference in polar angle theta at matching plane.
Definition: QwTrack.h:112
double fTheta
Polar angle theta of track at primary vertex.
Definition: QwTrack.h:94
std::vector< QwPartialTrack * > fQwPartialTracks
List of partial tracks in this track.
Definition: QwTrack.h:37
double fMomentum
Spectrometer momentum.
Definition: QwTrack.h:100
double fVertexZ
Primary vertex position in longitudinal direction.
Definition: QwTrack.h:95
Contains the straight part of a track in one region only.
void ClearPartialTracks(Option_t *option="")
Definition: QwTrack.cc:186
double fVertexR
Primary vertex position in transverse direction.
Definition: QwTrack.h:96
EQwDetectorPackage GetPackage() const
Get the package.
Virtual base class for all tracking elements.