TrackPar.cxx
Go to the documentation of this file.
1 // TrackPar class for defining tracks in garsoft and providing algorithms separate from the Track data product
2 // Tom Junk, July 2018
3 // change from slope parameter to lambda December 6, 2018
4 
5 #include "Reco/TrackPar.h"
6 #include "TMath.h"
8 #include "Geometry/GeometryGAr.h"
9 
10 namespace gar
11 {
12  namespace rec
13  {
14 
15  TrackPar::TrackPar(Track const &t, bool reversed) // constructor from Track data product
16  {
17  fNTPCClusters = t.NHits();
18  if (!reversed)
19  {
20  fXBeg = t.Vertex()[0];
21  fXEnd = t.End()[0];
22  for (size_t i=0; i<5; ++i)
23  {
25  fTrackParametersEnd[i] = t.TrackParEnd()[i];
26  }
33  }
34  else
35  {
36  fXEnd = t.Vertex()[0];
37  fXBeg = t.End()[0];
38  for (size_t i=0; i<5; ++i)
39  {
40  fTrackParametersEnd[i] = t.TrackParBeg()[i];
42  }
49  }
50  CalcCenter();
51  }
52 
53  //--------------------------------------------------------------------
54 
55  TrackPar::TrackPar(const float lengthforwards, // constructor from parameters
56  const float lengthbackwards,
57  const size_t nTPCClusters,
58  const float xbeg, // x location at beginning of track in cm
59  const float *trackparbeg, // y, z, curvature, phi, lambda -- 5-parameter track (cm, cm, cm-1, radians, radians)
60  const float *covmatbeg, // covariance matrix at beginning of track -- symmetric 5x5
61  const float chisqforward, // chisquared of forwards fit
62  const float xend, // x location at end of track
63  const float *trackparend, // y, z, curvature, phi, lambda -- 5-parameter track (cm, cm, cm-1, radians, radians)
64  const float *covmatend, // covariance matrix at beginning of track -- symmetric 5x5
65  const float chisqbackward, // chisquared of backwards fit
66  const double time) // timestamp
67  {
68  fNTPCClusters = nTPCClusters;
69  fLengthForwards = lengthforwards;
70  fLengthBackwards = lengthbackwards;
71  fXBeg = xbeg;
72  fXEnd = xend;
73  for (size_t i=0; i<5; ++i)
74  {
75  fTrackParametersBegin[i] = trackparbeg[i];
76  fTrackParametersEnd[i] = trackparend[i];
77  }
78  for (size_t i=0; i<25; ++i)
79  {
80  fCovMatBeg[i] = covmatbeg[i];
81  fCovMatEnd[i] = covmatend[i];
82  }
83  fChisquaredForwards = chisqforward;
84  fChisquaredBackwards = chisqbackward;
85  fTime = time;
86  CalcCenter();
87  }
88 
89  //--------------------------------------------------------------------
90 
92  {
93  if (fTrackParametersBegin[2] != 0)
94  {
95  float phi = fTrackParametersBegin[3];
96  float r = 1.0/fTrackParametersBegin[2];
97  fZCentBeg = fTrackParametersBegin[1] - r*TMath::Sin(phi);
98  fYCentBeg = fTrackParametersBegin[0] + r*TMath::Cos(phi);
99  fBegCentValid = true;
100  }
101  else
102  {
103  fBegCentValid = false;
104  }
105  if (fTrackParametersEnd[2] != 0)
106  {
107  float phi = fTrackParametersEnd[3];
108  float r = 1.0/fTrackParametersEnd[2];
109  fZCentEnd = fTrackParametersEnd[1] - r*TMath::Sin(phi);
110  fYCentEnd = fTrackParametersEnd[0] + r*TMath::Cos(phi);
111  fEndCentValid = true;
112  }
113  else
114  {
115  fEndCentValid = false;
116  }
117  }
118 
119  //--------------------------------------------------------------------
120 
122  {
123  return fTrackParametersBegin;
124  }
125 
126  const float *TrackPar::getTrackParametersEnd() const
127  {
128  return fTrackParametersEnd;
129  }
130 
131  const float *TrackPar::getCovMatBeg() const
132  {
133  return fCovMatBeg;
134  }
135 
136  const float *TrackPar::getCovMatEnd() const
137  {
138  return fCovMatEnd;
139  }
140 
141 
142  float TrackPar::getYCentBeg() const
143  {
144  return fYCentBeg;
145  }
146 
147  float TrackPar::getZCentBeg() const
148  {
149  return fZCentBeg;
150  }
151 
152  float TrackPar::getYCentEnd() const
153  {
154  return fYCentEnd;
155  }
156 
157  float TrackPar::getZCentEnd() const
158  {
159  return fZCentEnd;
160  }
161 
163  {
164  return fBegCentValid;
165  }
166 
168  {
169  return fEndCentValid;
170  }
171 
173  {
174  return fNTPCClusters;
175  }
176 
178  {
179  return fLengthForwards;
180  }
181 
183  {
184  return fLengthBackwards;
185  }
186 
188  {
189  return fChisquaredForwards;
190  }
191 
193  {
194  return fChisquaredBackwards;
195  }
196 
197  float TrackPar::getXBeg() const
198  {
199  return fXBeg;
200  }
201 
202  float TrackPar::getXEnd() const
203  {
204  return fXEnd;
205  }
206 
207  double TrackPar::getTime() const
208  {
209  return fTime;
210  }
211 
212 
213 
214  void TrackPar::setNTPCClusters(const size_t nTPCClusters)
215  {
216  fNTPCClusters = nTPCClusters;
217  }
218 
219  void TrackPar::setTrackParametersBegin(const float *tparbeg)
220  {
221  for (size_t i=0; i<5; ++i)
222  {
223  fTrackParametersBegin[i] = tparbeg[i];
224  }
225  }
226 
227  void TrackPar::setTrackParametersEnd(const float *tparend)
228  {
229  for (size_t i=0; i<5; ++i)
230  {
231  fTrackParametersEnd[i] = tparend[i];
232  }
233  }
234 
235  void TrackPar::setCovMatBeg(const float *covmatbeg)
236  {
237  for (size_t i=0; i<25; ++i)
238  {
239  fCovMatBeg[i] = covmatbeg[i];
240  }
241  }
242 
243  void TrackPar::setCovMatEnd(const float *covmatend)
244  {
245  for (size_t i=0; i<25; ++i)
246  {
247  fCovMatEnd[i] = covmatend[i];
248  }
249  }
250 
251  void TrackPar::setLengthForwards(const float lengthforwards)
252  {
253  fLengthForwards = lengthforwards;
254  }
255 
256  void TrackPar::setLengthBackwards(const float lengthbackwards)
257  {
258  fLengthBackwards = lengthbackwards;
259  }
260 
261  void TrackPar::setChisqForwards(const float chisqforwards)
262  {
263  fChisquaredForwards = chisqforwards;
264  }
265 
266  void TrackPar::setChisqBackwards(const float chisqbackwards)
267  {
268  fChisquaredBackwards = chisqbackwards;
269  }
270 
271  void TrackPar::setXBeg(const float xbeg)
272  {
273  fXBeg = xbeg;
274  }
275 
276  void TrackPar::setXEnd(const float xend)
277  {
278  fXEnd = xend;
279  }
280 
281  void TrackPar::setTime(const double time)
282  {
283  fTime = time;
284  }
285 
286 
287  //--------------------------------------------------------------------
288 
289  // We couldn't make a constructor of Track that takes TrackPar, but we can
290  // create a track data product from what we have here.
291 
293  {
294 
298  fXBeg,
300  fCovMatBeg,
302  fXEnd,
304  fCovMatEnd,
306  fTime
307  );
308  }
309 
310  TVector3 TrackPar::getXYZBeg() const
311  {
313  return result;
314  }
315 
316  TVector3 TrackPar::getXYZEnd() const
317  {
319  return result;
320  }
321 
322 
323  } // namespace rec
324 
325 } // namespace gar
void setNTPCClusters(const size_t nTPCClusters)
Definition: TrackPar.cxx:214
void setLengthForwards(const float lengthforwards)
Definition: TrackPar.cxx:251
float fChisquaredBackwards
Definition: TrackPar.h:91
float fTrackParametersBegin[5]
Definition: TrackPar.h:87
rec
Definition: tracks.py:88
float getYCentBeg() const
Definition: TrackPar.cxx:142
static QCString result
const float * TrackParBeg() const
Definition: Track.h:151
float fCovMatBeg[25]
Definition: TrackPar.h:94
void setCovMatBeg(const float *covmatbeg)
Definition: TrackPar.cxx:235
const float * getCovMatEnd() const
Definition: TrackPar.cxx:136
float fLengthForwards
Definition: TrackPar.h:92
const float * getCovMatBeg() const
Definition: TrackPar.cxx:131
const float * getTrackParametersEnd() const
Definition: TrackPar.cxx:126
float fLengthBackwards
Definition: TrackPar.h:93
void setLengthBackwards(const float lengthbackwards)
Definition: TrackPar.cxx:256
float const & LengthBackward() const
Definition: Track.h:145
bool getEndCentValid() const
Definition: TrackPar.cxx:167
float const & ChisqBackward() const
Definition: Track.h:149
TVector3 getXYZEnd() const
Definition: TrackPar.cxx:316
float fTrackParametersEnd[5]
Definition: TrackPar.h:89
TVector3 getXYZBeg() const
Definition: TrackPar.cxx:310
void setTrackParametersBegin(const float *tparbeg)
Definition: TrackPar.cxx:219
float const & LengthForward() const
Definition: Track.h:144
const float * Vertex() const
Definition: Track.h:139
float fChisquaredForwards
Definition: TrackPar.h:90
float getXBeg() const
Definition: TrackPar.cxx:197
void setXEnd(const float xend)
Definition: TrackPar.cxx:276
void setTrackParametersEnd(const float *tparend)
Definition: TrackPar.cxx:227
float getYCentEnd() const
Definition: TrackPar.cxx:152
const float * TrackParEnd() const
Definition: Track.h:152
float getChisqBackwards() const
Definition: TrackPar.cxx:192
void setChisqBackwards(const float chisqbackwards)
Definition: TrackPar.cxx:266
float const & ChisqForward() const
Definition: Track.h:148
float fCovMatEnd[25]
Definition: TrackPar.h:95
const float * End() const
Definition: Track.h:140
gar::rec::Track CreateTrack()
Definition: TrackPar.cxx:292
float getZCentBeg() const
Definition: TrackPar.cxx:147
double getTime() const
Definition: TrackPar.cxx:207
size_t getNTPCClusters() const
Definition: TrackPar.cxx:172
General GArSoft Utilities.
float getLengthBackwards() const
Definition: TrackPar.cxx:182
void setCovMatEnd(const float *covmatend)
Definition: TrackPar.cxx:243
bool getBegCentValid() const
Definition: TrackPar.cxx:162
float getLengthForwards() const
Definition: TrackPar.cxx:177
void setXBeg(const float xbeg)
Definition: TrackPar.cxx:271
size_t fNTPCClusters
Definition: TrackPar.h:85
float getXEnd() const
Definition: TrackPar.cxx:202
float getChisqForwards() const
Definition: TrackPar.cxx:187
size_t const & NHits() const
Definition: Track.h:150
TrackCollectionProxyElement< TrackCollProxy > Track
Proxy to an element of a proxy collection of recob::Track objects.
Definition: Track.h:1036
const float * getTrackParametersBegin() const
Definition: TrackPar.cxx:121
void setChisqForwards(const float chisqforwards)
Definition: TrackPar.cxx:261
void CovMatBegSymmetric(float *cmb) const
Definition: Track.cxx:246
art framework interface to geometry description
void CovMatEndSymmetric(float *cme) const
Definition: Track.cxx:257
void setTime(const double time)
Definition: TrackPar.cxx:281
float getZCentEnd() const
Definition: TrackPar.cxx:157