PandaRoot
Track.h
Go to the documentation of this file.
1 //****************************************************************************
2 //* This file is part of PandaRoot. *
3 //* *
4 //* PandaRoot is distributed under the terms of the *
5 //* GNU General Public License (GPL) version 3, *
6 //* copied verbatim in the file "LICENSE". *
7 //* *
8 //* Copyright (C) 2006 - 2024 FAIR GmbH and copyright holders of PandaRoot *
9 //* The copyright holders are listed in the file "COPYRIGHTHOLDERS". *
10 //* The authors are listed in the file "AUTHORS". *
11 //****************************************************************************
12 
13 /* Copyright 2008-2010, Technische Universitaet Muenchen,
14  Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch & Tobias Schlüter
15 
16  This file is part of GENFIT.
17 
18  GENFIT is free software: you can redistribute it and/or modify
19  it under the terms of the GNU Lesser General Public License as published
20  by the Free Software Foundation, either version 3 of the License, or
21  (at your option) any later version.
22 
23  GENFIT is distributed in the hope that it will be useful,
24  but WITHOUT ANY WARRANTY; without even the implied warranty of
25  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26  GNU Lesser General Public License for more details.
27 
28  You should have received a copy of the GNU Lesser General Public License
29  along with GENFIT. If not, see <http://www.gnu.org/licenses/>.
30 */
31 
36 #ifndef genfit_Track_h
37 #define genfit_Track_h
38 
39 #include "AbsTrackRep.h"
40 #include "FitStatus.h"
41 #include "MeasurementFactory.h"
42 #include "TrackCand.h"
43 #include "TrackPoint.h"
44 
45 #include <vector>
46 #include <TObject.h>
47 #include <TVectorD.h>
48 
49 namespace genfit {
50 
51 class KalmanFitStatus;
52 
57  public:
61  bool operator()(const TrackPoint *lhs, const TrackPoint *rhs) const { return lhs->getSortingParameter() < rhs->getSortingParameter(); }
62 };
63 
79 class Track : public TObject {
80 
81  public:
82  Track();
83 
100  Track(const TrackCand &trackCand, const MeasurementFactory<genfit::AbsMeasurement> &factory, AbsTrackRep *rep = nullptr);
101 
102  Track(AbsTrackRep *trackRep, const TVectorD &stateSeed);
103  Track(AbsTrackRep *trackRep, const TVector3 &posSeed, const TVector3 &momSeed);
104  Track(AbsTrackRep *trackRep, const TVectorD &stateSeed, const TMatrixDSym &covSeed);
105 
106  Track(const Track &); // copy constructor
107  Track &operator=(Track); // assignment operator
108  void swap(Track &other); // nothrow
109 
110  virtual ~Track();
111  virtual void Clear(Option_t * = "");
112 
113  TrackPoint *getPoint(int id) const;
114  const std::vector<genfit::TrackPoint *> &getPoints() const { return trackPoints_; }
115  unsigned int getNumPoints() const { return trackPoints_.size(); }
116 
117  TrackPoint *getPointWithMeasurement(int id) const;
118  const std::vector<genfit::TrackPoint *> &getPointsWithMeasurement() const { return trackPointsWithMeasurement_; }
119  unsigned int getNumPointsWithMeasurement() const { return trackPointsWithMeasurement_.size(); }
120 
121  TrackPoint *getPointWithMeasurementAndFitterInfo(int id, const AbsTrackRep *rep) const;
122  TrackPoint *getPointWithFitterInfo(int id, const AbsTrackRep *rep = nullptr) const;
123 
133  const MeasuredStateOnPlane &getFittedState(int id = 0, const AbsTrackRep *rep = nullptr, bool biased = true) const;
134 
135  AbsTrackRep *getTrackRep(int id) const { return trackReps_.at(id); }
136  unsigned int getNumReps() const { return trackReps_.size(); }
137 
139  int getIdForRep(const AbsTrackRep *rep) const;
140 
148  AbsTrackRep *getCardinalRep() const { return trackReps_.at(cardinalRep_); }
149  unsigned int getCardinalRepId() const { return cardinalRep_; }
150 
152  int getMcTrackId() const { return mcTrackId_; }
153 
155  bool hasFitStatus(const AbsTrackRep *rep = nullptr) const;
157  FitStatus *getFitStatus(const AbsTrackRep *rep = nullptr) const
158  {
159  if (rep == nullptr)
160  rep = getCardinalRep();
161  return fitStatuses_.at(rep);
162  }
163 
165  bool hasKalmanFitStatus(const AbsTrackRep *rep = nullptr) const;
167  KalmanFitStatus *getKalmanFitStatus(const AbsTrackRep *rep = nullptr) const;
168 
169  void setFitStatus(FitStatus *fitStatus, const AbsTrackRep *rep);
170 
171  double getTimeSeed() const { return timeSeed_; }
172  void setTimeSeed(double time) { timeSeed_ = time; }
173 
174  const TVectorD &getStateSeed() const { return stateSeed_; }
175  void setStateSeed(const TVectorD &s)
176  {
177  stateSeed_.ResizeTo(s);
178  stateSeed_ = s;
179  }
180  void setStateSeed(const TVector3 &pos, const TVector3 &mom);
181 
182  const TMatrixDSym &getCovSeed() const { return covSeed_; }
183  void setCovSeed(const TMatrixDSym &c)
184  {
185  covSeed_.ResizeTo(c);
186  covSeed_ = c;
187  }
188 
190  void setMcTrackId(int i) { mcTrackId_ = i; }
191 
199  void insertPoint(TrackPoint *point, int id = -1);
200 
208  void insertPoints(std::vector<genfit::TrackPoint *> points, int id = -1);
209 
210  void deletePoint(int id);
211 
213  void insertMeasurement(AbsMeasurement *measurement, int id = -1);
214 
223  void mergeTrack(const Track *other, int id = -1);
224 
225  void addTrackRep(AbsTrackRep *trackRep);
226 
228  void deleteTrackRep(int id);
229 
230  void setCardinalRep(int id);
232  void determineCardinalRep();
233 
239  bool sort();
240 
243  bool udpateSeed(int id = 0, AbsTrackRep *rep = nullptr, bool biased = true);
244 
246  void reverseTrackPoints();
247 
250  {
251  stateSeed_(3) *= -1;
252  stateSeed_(4) *= -1;
253  stateSeed_(5) *= -1;
254  }
255 
257  void switchPDGSigns(AbsTrackRep *rep = nullptr);
258 
260 
265  void reverseTrack();
266 
267  void deleteForwardInfo(int startId = 0, int endId = -1,
268  const AbsTrackRep *rep = nullptr); // delete in range [startId, endId]. If rep == nullptr, delete for ALL reps, otherwise only for rep.
269  void deleteBackwardInfo(int startId = 0, int endId = -1,
270  const AbsTrackRep *rep = nullptr); // delete in range [startId, endId]. If rep == nullptr, delete for ALL reps, otherwise only for rep.
271  void deleteReferenceInfo(int startId = 0, int endId = -1,
272  const AbsTrackRep *rep = nullptr); // delete in range [startId, endId]. If rep == nullptr, delete for ALL reps, otherwise only for rep.
273  void deleteMeasurementInfo(int startId = 0, int endId = -1,
274  const AbsTrackRep *rep = nullptr); // delete in range [startId, endId]. If rep == nullptr, delete for ALL reps, otherwise only for rep.
275  void deleteFitterInfo(int startId = 0, int endId = -1,
276  const AbsTrackRep *rep = nullptr); // delete in range [startId, endId]. If rep == nullptr, delete for ALL reps, otherwise only for rep.
277 
279  double getTrackLen(AbsTrackRep *rep = nullptr, int startId = 0, int endId = -1) const;
281  double getTOF(AbsTrackRep *rep = nullptr, int startId = 0, int endId = -1) const;
282 
284 
290  TrackCand *constructTrackCand() const;
291 
294  void fixWeights(AbsTrackRep *rep = nullptr, int startId = 0, int endId = -1);
295 
310  void prune(const Option_t * = "CFLWRMIU");
311 
312  void Print(const Option_t * = "") const;
313 
314  bool checkConsistency() const;
315 
316  private:
317  void trackHasChanged();
318 
319  void fillPointsWithMeasurement();
320 
321  std::vector<AbsTrackRep *> trackReps_; // Ownership
322  unsigned int cardinalRep_; // THE selected rep, default = 0;
323 
324  std::vector<TrackPoint *> trackPoints_; // Ownership
325  std::vector<TrackPoint *> trackPointsWithMeasurement_;
326 
327  std::map<const AbsTrackRep *, FitStatus *> fitStatuses_; // Ownership over FitStatus*
328 
329  int mcTrackId_;
330  double timeSeed_;
331  TVectorD stateSeed_; // 6D: position, momentum
332  TMatrixDSym covSeed_; // 6D
333 
334  public:
335  ClassDef(Track, 3)
336  // Class version history:
337  // ver 3: introduces timeSeed_
338 };
339 
340 } /* End of namespace genfit */
343 #endif // genfit_Track_h
Track candidate – seed values and indices.
Definition: TrackCand.h:80
void setMcTrackId(int i)
Set the MCT track id, for MC simulations.
Definition: Track.h:190
void setStateSeed(const TVectorD &s)
Definition: Track.h:175
const std::vector< genfit::TrackPoint * > & getPoints() const
Definition: Track.h:114
Class where important numbers and properties of a fit can be stored.
Definition: FitStatus.h:82
Collection of TrackPoint objects, AbsTrackRep objects and FitStatus objects.
Definition: Track.h:79
double getSortingParameter() const
Definition: TrackPoint.h:96
const std::vector< genfit::TrackPoint * > & getPointsWithMeasurement() const
Definition: Track.h:118
bool operator()(const TrackPoint *lhs, const TrackPoint *rhs) const
Definition: Track.h:61
Abstract base class for a track representation.
Definition: AbsTrackRep.h:74
Helper class for TrackPoint sorting, used in Track::sort().
Definition: Track.h:56
StateOnPlane with additional covariance matrix.
unsigned int getNumReps() const
Definition: Track.h:136
double getTimeSeed() const
Definition: Track.h:171
unsigned int i
Definition: P4_F32vec4.h:33
int getMcTrackId() const
Get the MCT track id, for MC simulations - default value = -1.
Definition: Track.h:152
FitStatus for use with AbsKalmanFitter implementations.
void setTimeSeed(double time)
Definition: Track.h:172
unsigned int getNumPointsWithMeasurement() const
Definition: Track.h:119
const TMatrixDSym & getCovSeed() const
Definition: Track.h:182
void reverseMomSeed()
Flip direction of momentum seed.
Definition: Track.h:249
unsigned int getCardinalRepId() const
Definition: Track.h:149
void setCovSeed(const TMatrixDSym &c)
Definition: Track.h:183
Object containing AbsMeasurement and AbsFitterInfo objects.
Definition: TrackPoint.h:61
unsigned int getNumPoints() const
Definition: Track.h:115
const TVectorD & getStateSeed() const
Definition: Track.h:174
AbsTrackRep * getCardinalRep() const
Get cardinal track representation.
Definition: Track.h:148
Contains the measurement and covariance in raw detector coordinates.
AbsTrackRep * getTrackRep(int id) const
Definition: Track.h:135
FitStatus * getFitStatus(const AbsTrackRep *rep=nullptr) const
Get FitStatus for a AbsTrackRep. Per default, return FitStatus for cardinalRep.
Definition: Track.h:157
Matrix inversion tools.
Definition: AbsBField.h:40