PandaRoot
Track.h
Go to the documentation of this file.
1 /* Copyright 2008-2010, Technische Universitaet Muenchen,
2  Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch & Tobias Schlüter
3 
4  This file is part of GENFIT.
5 
6  GENFIT is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published
8  by the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  GENFIT is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with GENFIT. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
24 #ifndef genfit_Track_h
25 #define genfit_Track_h
26 
27 #include "AbsTrackRep.h"
28 #include "FitStatus.h"
29 #include "MeasurementFactory.h"
30 #include "TrackCand.h"
31 #include "TrackPoint.h"
32 
33 #include <vector>
34 #include <TObject.h>
35 #include <TVectorD.h>
36 
37 namespace genfit {
38 
39 class KalmanFitStatus;
40 
45  public:
49  bool operator()(const TrackPoint *lhs, const TrackPoint *rhs) const { return lhs->getSortingParameter() < rhs->getSortingParameter(); }
50 };
51 
67 class Track : public TObject {
68 
69  public:
70  Track();
71 
88  Track(const TrackCand &trackCand, const MeasurementFactory<genfit::AbsMeasurement> &factory, AbsTrackRep *rep = nullptr);
89 
90  Track(AbsTrackRep *trackRep, const TVectorD &stateSeed);
91  Track(AbsTrackRep *trackRep, const TVector3 &posSeed, const TVector3 &momSeed);
92  Track(AbsTrackRep *trackRep, const TVectorD &stateSeed, const TMatrixDSym &covSeed);
93 
94  Track(const Track &); // copy constructor
95  Track &operator=(Track); // assignment operator
96  void swap(Track &other); // nothrow
97 
98  virtual ~Track();
99  virtual void Clear(Option_t * = "");
100 
101  TrackPoint *getPoint(int id) const;
102  const std::vector<genfit::TrackPoint *> &getPoints() const { return trackPoints_; }
103  unsigned int getNumPoints() const { return trackPoints_.size(); }
104 
105  TrackPoint *getPointWithMeasurement(int id) const;
106  const std::vector<genfit::TrackPoint *> &getPointsWithMeasurement() const { return trackPointsWithMeasurement_; }
107  unsigned int getNumPointsWithMeasurement() const { return trackPointsWithMeasurement_.size(); }
108 
109  TrackPoint *getPointWithMeasurementAndFitterInfo(int id, const AbsTrackRep *rep) const;
110  TrackPoint *getPointWithFitterInfo(int id, const AbsTrackRep *rep = nullptr) const;
111 
121  const MeasuredStateOnPlane &getFittedState(int id = 0, const AbsTrackRep *rep = nullptr, bool biased = true) const;
122 
123  AbsTrackRep *getTrackRep(int id) const { return trackReps_.at(id); }
124  unsigned int getNumReps() const { return trackReps_.size(); }
125 
127  int getIdForRep(const AbsTrackRep *rep) const;
128 
136  AbsTrackRep *getCardinalRep() const { return trackReps_.at(cardinalRep_); }
137  unsigned int getCardinalRepId() const { return cardinalRep_; }
138 
140  int getMcTrackId() const { return mcTrackId_; }
141 
143  bool hasFitStatus(const AbsTrackRep *rep = nullptr) const;
145  FitStatus *getFitStatus(const AbsTrackRep *rep = nullptr) const
146  {
147  if (rep == nullptr)
148  rep = getCardinalRep();
149  return fitStatuses_.at(rep);
150  }
151 
153  bool hasKalmanFitStatus(const AbsTrackRep *rep = nullptr) const;
155  KalmanFitStatus *getKalmanFitStatus(const AbsTrackRep *rep = nullptr) const;
156 
157  void setFitStatus(FitStatus *fitStatus, const AbsTrackRep *rep);
158 
159  double getTimeSeed() const { return timeSeed_; }
160  void setTimeSeed(double time) { timeSeed_ = time; }
161 
162  const TVectorD &getStateSeed() const { return stateSeed_; }
163  void setStateSeed(const TVectorD &s)
164  {
165  stateSeed_.ResizeTo(s);
166  stateSeed_ = s;
167  }
168  void setStateSeed(const TVector3 &pos, const TVector3 &mom);
169 
170  const TMatrixDSym &getCovSeed() const { return covSeed_; }
171  void setCovSeed(const TMatrixDSym &c)
172  {
173  covSeed_.ResizeTo(c);
174  covSeed_ = c;
175  }
176 
178  void setMcTrackId(int i) { mcTrackId_ = i; }
179 
187  void insertPoint(TrackPoint *point, int id = -1);
188 
196  void insertPoints(std::vector<genfit::TrackPoint *> points, int id = -1);
197 
198  void deletePoint(int id);
199 
201  void insertMeasurement(AbsMeasurement *measurement, int id = -1);
202 
211  void mergeTrack(const Track *other, int id = -1);
212 
213  void addTrackRep(AbsTrackRep *trackRep);
214 
216  void deleteTrackRep(int id);
217 
218  void setCardinalRep(int id);
220  void determineCardinalRep();
221 
227  bool sort();
228 
231  bool udpateSeed(int id = 0, AbsTrackRep *rep = nullptr, bool biased = true);
232 
234  void reverseTrackPoints();
235 
238  {
239  stateSeed_(3) *= -1;
240  stateSeed_(4) *= -1;
241  stateSeed_(5) *= -1;
242  }
243 
245  void switchPDGSigns(AbsTrackRep *rep = nullptr);
246 
248 
253  void reverseTrack();
254 
255  void deleteForwardInfo(int startId = 0, int endId = -1,
256  const AbsTrackRep *rep = nullptr); // delete in range [startId, endId]. If rep == nullptr, delete for ALL reps, otherwise only for rep.
257  void deleteBackwardInfo(int startId = 0, int endId = -1,
258  const AbsTrackRep *rep = nullptr); // delete in range [startId, endId]. If rep == nullptr, delete for ALL reps, otherwise only for rep.
259  void deleteReferenceInfo(int startId = 0, int endId = -1,
260  const AbsTrackRep *rep = nullptr); // delete in range [startId, endId]. If rep == nullptr, delete for ALL reps, otherwise only for rep.
261  void deleteMeasurementInfo(int startId = 0, int endId = -1,
262  const AbsTrackRep *rep = nullptr); // delete in range [startId, endId]. If rep == nullptr, delete for ALL reps, otherwise only for rep.
263  void deleteFitterInfo(int startId = 0, int endId = -1,
264  const AbsTrackRep *rep = nullptr); // delete in range [startId, endId]. If rep == nullptr, delete for ALL reps, otherwise only for rep.
265 
267  double getTrackLen(AbsTrackRep *rep = nullptr, int startId = 0, int endId = -1) const;
269  double getTOF(AbsTrackRep *rep = nullptr, int startId = 0, int endId = -1) const;
270 
272 
278  TrackCand *constructTrackCand() const;
279 
282  void fixWeights(AbsTrackRep *rep = nullptr, int startId = 0, int endId = -1);
283 
298  void prune(const Option_t * = "CFLWRMIU");
299 
300  void Print(const Option_t * = "") const;
301 
302  bool checkConsistency() const;
303 
304  private:
305  void trackHasChanged();
306 
307  void fillPointsWithMeasurement();
308 
309  std::vector<AbsTrackRep *> trackReps_; // Ownership
310  unsigned int cardinalRep_; // THE selected rep, default = 0;
311 
312  std::vector<TrackPoint *> trackPoints_; // Ownership
313  std::vector<TrackPoint *> trackPointsWithMeasurement_;
314 
315  std::map<const AbsTrackRep *, FitStatus *> fitStatuses_; // Ownership over FitStatus*
316 
317  int mcTrackId_;
318  double timeSeed_;
319  TVectorD stateSeed_; // 6D: position, momentum
320  TMatrixDSym covSeed_; // 6D
321 
322  public:
323  ClassDef(Track, 3)
324  // Class version history:
325  // ver 3: introduces timeSeed_
326 };
327 
328 } /* End of namespace genfit */
331 #endif // genfit_Track_h
Track candidate – seed values and indices.
Definition: TrackCand.h:68
void setMcTrackId(int i)
Set the MCT track id, for MC simulations.
Definition: Track.h:178
void setStateSeed(const TVectorD &s)
Definition: Track.h:163
const std::vector< genfit::TrackPoint * > & getPoints() const
Definition: Track.h:102
Class where important numbers and properties of a fit can be stored.
Definition: FitStatus.h:70
Collection of TrackPoint objects, AbsTrackRep objects and FitStatus objects.
Definition: Track.h:67
double getSortingParameter() const
Definition: TrackPoint.h:84
const std::vector< genfit::TrackPoint * > & getPointsWithMeasurement() const
Definition: Track.h:106
bool operator()(const TrackPoint *lhs, const TrackPoint *rhs) const
Definition: Track.h:49
Abstract base class for a track representation.
Definition: AbsTrackRep.h:62
Helper class for TrackPoint sorting, used in Track::sort().
Definition: Track.h:44
StateOnPlane with additional covariance matrix.
unsigned int getNumReps() const
Definition: Track.h:124
double getTimeSeed() const
Definition: Track.h:159
unsigned int i
Definition: P4_F32vec4.h:21
int getMcTrackId() const
Get the MCT track id, for MC simulations - default value = -1.
Definition: Track.h:140
FitStatus for use with AbsKalmanFitter implementations.
void setTimeSeed(double time)
Definition: Track.h:160
unsigned int getNumPointsWithMeasurement() const
Definition: Track.h:107
const TMatrixDSym & getCovSeed() const
Definition: Track.h:170
void reverseMomSeed()
Flip direction of momentum seed.
Definition: Track.h:237
unsigned int getCardinalRepId() const
Definition: Track.h:137
void setCovSeed(const TMatrixDSym &c)
Definition: Track.h:171
Object containing AbsMeasurement and AbsFitterInfo objects.
Definition: TrackPoint.h:49
unsigned int getNumPoints() const
Definition: Track.h:103
const TVectorD & getStateSeed() const
Definition: Track.h:162
AbsTrackRep * getCardinalRep() const
Get cardinal track representation.
Definition: Track.h:136
Contains the measurement and covariance in raw detector coordinates.
AbsTrackRep * getTrackRep(int id) const
Definition: Track.h:123
FitStatus * getFitStatus(const AbsTrackRep *rep=nullptr) const
Get FitStatus for a AbsTrackRep. Per default, return FitStatus for cardinalRep.
Definition: Track.h:145
Matrix inversion tools.
Definition: AbsBField.h:28