FairRoot/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 
38 namespace genfit {
39 
40 class KalmanFitStatus;
41 
46  public:
50  bool operator() (const TrackPoint* lhs, const TrackPoint* rhs) const {
51  return lhs->getSortingParameter() < rhs->getSortingParameter();
52  }
53 };
54 
55 
71 class Track : public TObject {
72 
73  public:
74 
75  Track();
76 
93  Track(const TrackCand& trackCand, const MeasurementFactory<genfit::AbsMeasurement>& factory, AbsTrackRep* rep = NULL);
94 
95  Track(AbsTrackRep* trackRep, const TVectorD& stateSeed);
96  Track(AbsTrackRep* trackRep, const TVector3& posSeed, const TVector3& momSeed);
97  Track(AbsTrackRep* trackRep, const TVectorD& stateSeed, const TMatrixDSym& covSeed);
98 
99  Track(const Track&); // copy constructor
100  Track& operator=(Track); // assignment operator
101  void swap(Track& other); // nothrow
102 
103  virtual ~Track();
104  virtual void Clear(Option_t* = "");
105 
106  TrackPoint* getPoint(int id) const;
107  const std::vector< genfit::TrackPoint* > & getPoints() const {return trackPoints_;}
108  unsigned int getNumPoints() const {return trackPoints_.size();}
109 
110  TrackPoint* getPointWithMeasurement(int id) const;
111  const std::vector< genfit::TrackPoint* > & getPointsWithMeasurement() const {return trackPointsWithMeasurement_;}
112  unsigned int getNumPointsWithMeasurement() const {return trackPointsWithMeasurement_.size();}
113 
115  TrackPoint* getPointWithFitterInfo(int id, const AbsTrackRep* rep = NULL) const;
116 
126  const MeasuredStateOnPlane& getFittedState(int id = 0, const AbsTrackRep* rep = NULL, bool biased = true) const;
127 
128  AbsTrackRep* getTrackRep(int id) const {return trackReps_.at(id);}
129  unsigned int getNumReps() const {return trackReps_.size();}
130 
132  int getIdForRep(const AbsTrackRep* rep) const;
133 
142  unsigned int getCardinalRepId() const {return cardinalRep_;}
143 
145  int getMcTrackId() const {return mcTrackId_;}
146 
148  bool hasFitStatus(const AbsTrackRep* rep = NULL) const;
150  FitStatus* getFitStatus(const AbsTrackRep* rep = NULL) const {if (rep == NULL) rep = getCardinalRep(); return fitStatuses_.at(rep);}
151 
153  bool hasKalmanFitStatus(const AbsTrackRep* rep = NULL) const;
155  KalmanFitStatus* getKalmanFitStatus(const AbsTrackRep* rep = NULL) 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) {stateSeed_.ResizeTo(s); stateSeed_ = s;}
164  void setStateSeed(const TVector3& pos, const TVector3& mom);
165 
166  const TMatrixDSym& getCovSeed() const {return covSeed_;}
167  void setCovSeed(const TMatrixDSym& c) {covSeed_.ResizeTo(c); covSeed_ = c;}
168 
170  void setMcTrackId(int i) {mcTrackId_ = i;}
171 
179  void insertPoint(TrackPoint* point, int id = -1);
180 
188  void insertPoints(std::vector<genfit::TrackPoint*> points, int id = -1);
189 
190  void deletePoint(int id);
191 
193  void insertMeasurement(AbsMeasurement* measurement, int id = -1);
194 
203  void mergeTrack(const Track* other, int id = -1);
204 
205  void addTrackRep(AbsTrackRep* trackRep);
206 
208  void deleteTrackRep(int id);
209 
210  void setCardinalRep(int id);
212  void determineCardinalRep();
213 
219  bool sort();
220 
223  bool udpateSeed(int id = 0, AbsTrackRep* rep = NULL, bool biased = true);
224 
226  void reverseTrackPoints();
227 
229  void reverseMomSeed() {
230  stateSeed_(3) *= -1; stateSeed_(4) *= -1; stateSeed_(5) *= -1;
231  }
232 
234  void switchPDGSigns(AbsTrackRep* rep = NULL);
235 
237 
242  void reverseTrack();
243 
244 
245  void deleteForwardInfo(int startId = 0, int endId = -1, const AbsTrackRep* rep = NULL); // delete in range [startId, endId]. If rep == NULL, delete for ALL reps, otherwise only for rep.
246  void deleteBackwardInfo(int startId = 0, int endId = -1, const AbsTrackRep* rep = NULL); // delete in range [startId, endId]. If rep == NULL, delete for ALL reps, otherwise only for rep.
247  void deleteReferenceInfo(int startId = 0, int endId = -1, const AbsTrackRep* rep = NULL); // delete in range [startId, endId]. If rep == NULL, delete for ALL reps, otherwise only for rep.
248  void deleteMeasurementInfo(int startId = 0, int endId = -1, const AbsTrackRep* rep = NULL); // delete in range [startId, endId]. If rep == NULL, delete for ALL reps, otherwise only for rep.
249  void deleteFitterInfo(int startId = 0, int endId = -1, const AbsTrackRep* rep = NULL); // delete in range [startId, endId]. If rep == NULL, delete for ALL reps, otherwise only for rep.
250 
252  double getTrackLen(AbsTrackRep* rep = NULL, int startId = 0, int endId = -1) const;
254  double getTOF(AbsTrackRep* rep = NULL, int startId = 0, int endId = -1) const;
255 
257 
263  TrackCand* constructTrackCand() const;
264 
267  void fixWeights(AbsTrackRep* rep = NULL, int startId = 0, int endId = -1);
268 
283  void prune(const Option_t* = "CFLWRMIU");
284 
285  void Print(const Option_t* = "") const;
286 
287  bool checkConsistency() const;
288 
289  private:
290 
291  void trackHasChanged();
292 
294 
295  std::vector<AbsTrackRep*> trackReps_; // Ownership
296  unsigned int cardinalRep_; // THE selected rep, default = 0;
297 
298  std::vector<TrackPoint*> trackPoints_; // Ownership
299  std::vector<TrackPoint*> trackPointsWithMeasurement_;
300 
301  std::map< const AbsTrackRep*, FitStatus* > fitStatuses_; // Ownership over FitStatus*
302 
304  double timeSeed_;
305  TVectorD stateSeed_; // 6D: position, momentum
306  TMatrixDSym covSeed_; // 6D
307 
308 
309  public:
310  ClassDef(Track,3)
311  // Class version history:
312  // ver 3: introduces timeSeed_
313 };
314 
315 } /* End of namespace genfit */
318 #endif // genfit_Track_h
Track candidate – seed values and indices.
Definition: TrackCand.h:69
int getMcTrackId() const
Get the MCT track id, for MC simulations - default value = -1.
Definition: Track.h:145
TVector3 pos
std::map< const AbsTrackRep *, FitStatus * > fitStatuses_
helper
Definition: Track.h:301
unsigned int getNumReps() const
Definition: Track.h:129
void fillPointsWithMeasurement()
void Print(const Option_t *="") const
bool checkConsistency() const
bool hasKalmanFitStatus(const AbsTrackRep *rep=NULL) const
Check if track has a KalmanFitStatus for given AbsTrackRep. Per default, check for cardinal rep...
KalmanFitStatus * getKalmanFitStatus(const AbsTrackRep *rep=NULL) const
If FitStatus is a KalmanFitStatus, return it. Otherwise return NULL.
double getTrackLen(AbsTrackRep *rep=NULL, int startId=0, int endId=-1) const
get TrackLength between to trackPoints (if NULL, for cardinal rep)
void determineCardinalRep()
See with which AbsTrackRep the track was fitted best (converged fit w/ smallest chi2) and set the car...
void setMcTrackId(int i)
Set the MCT track id, for MC simulations.
Definition: Track.h:170
void mergeTrack(const Track *other, int id=-1)
Merge two tracks.
std::vector< TrackPoint * > trackPoints_
Definition: Track.h:298
void setStateSeed(const TVectorD &s)
Definition: Track.h:163
Int_t i
Definition: run_full.C:25
const TVectorD & getStateSeed() const
Definition: Track.h:162
void trackHasChanged()
double getTOF(AbsTrackRep *rep=NULL, int startId=0, int endId=-1) const
get time of flight in ns between to trackPoints (if NULL, for cardinal rep)
Class where important numbers and properties of a fit can be stored.
Definition: FitStatus.h:80
TrackPoint * getPointWithMeasurement(int id) const
double timeSeed_
Definition: Track.h:304
virtual ~Track()
Collection of TrackPoint objects, AbsTrackRep objects and FitStatus objects.
Definition: Track.h:71
TLorentzVector s
Definition: Pnd2DStar.C:50
bool operator()(const TrackPoint *lhs, const TrackPoint *rhs) const
Definition: Track.h:50
const std::vector< genfit::TrackPoint * > & getPointsWithMeasurement() const
Definition: Track.h:111
Abstract base class for a track representation.
Definition: AbsTrackRep.h:66
TMatrixDSym covSeed_
Definition: Track.h:306
Helper class for TrackPoint sorting, used in Track::sort().
Definition: Track.h:45
StateOnPlane with additional covariance matrix.
std::vector< TrackPoint * > trackPointsWithMeasurement_
Definition: Track.h:299
unsigned int getNumPointsWithMeasurement() const
Definition: Track.h:112
Track & operator=(Track)
unsigned int cardinalRep_
Definition: Track.h:296
Double_t mom
Definition: plot_dirc.C:14
void switchPDGSigns(AbsTrackRep *rep=NULL)
Switch the pdg signs of specified rep (of all reps if rep == NULL).
double getSortingParameter() const
Definition: TrackPoint.h:88
void deleteTrackRep(int id)
Delete a AbsTrackRep and all corresponding AbsFitterInfo objects in every TrackPoint.
TrackPoint * getPointWithMeasurementAndFitterInfo(int id, const AbsTrackRep *rep) const
double getTimeSeed() const
Definition: Track.h:159
TrackPoint * getPointWithFitterInfo(int id, const AbsTrackRep *rep=NULL) const
void reverseTrackPoints()
Flip the ordering of the TrackPoints.
void deletePoint(int id)
FitStatus for use with AbsKalmanFitter implementations.
void reverseTrack()
Make track ready to be fitted in reverse direction.
void deleteMeasurementInfo(int startId=0, int endId=-1, const AbsTrackRep *rep=NULL)
void deleteFitterInfo(int startId=0, int endId=-1, const AbsTrackRep *rep=NULL)
FitStatus * getFitStatus(const AbsTrackRep *rep=NULL) const
Get FitStatus for a AbsTrackRep. Per default, return FitStatus for cardinalRep.
Definition: Track.h:150
void insertMeasurement(AbsMeasurement *measurement, int id=-1)
Creates a new TrackPoint containing the measurement, and adds it to the track.
const std::vector< genfit::TrackPoint * > & getPoints() const
Definition: Track.h:107
void setTimeSeed(double time)
Definition: Track.h:160
unsigned int getNumPoints() const
Definition: Track.h:108
void deleteForwardInfo(int startId=0, int endId=-1, const AbsTrackRep *rep=NULL)
void setCardinalRep(int id)
void reverseMomSeed()
Flip direction of momentum seed.
Definition: Track.h:229
TVectorD stateSeed_
Definition: Track.h:305
void setCovSeed(const TMatrixDSym &c)
Definition: Track.h:167
Object containing AbsMeasurement and AbsFitterInfo objects.
Definition: TrackPoint.h:50
AbsTrackRep * getCardinalRep() const
Get cardinal track representation.
Definition: Track.h:141
void addTrackRep(AbsTrackRep *trackRep)
AbsTrackRep * getTrackRep(int id) const
Definition: Track.h:128
void insertPoint(TrackPoint *point, int id=-1)
Insert TrackPoint BEFORE TrackPoint with position id, if id &gt;= 0.
unsigned int getCardinalRepId() const
Definition: Track.h:142
TrackCand * constructTrackCand() const
Construct a new TrackCand containing the hit IDs of the measurements.
void deleteReferenceInfo(int startId=0, int endId=-1, const AbsTrackRep *rep=NULL)
int getIdForRep(const AbsTrackRep *rep) const
This is used when streaming TrackPoints.
std::vector< AbsTrackRep * > trackReps_
Definition: Track.h:295
TrackPoint * getPoint(int id) const
bool sort()
Sort TrackPoint and according to their sorting parameters.
int mcTrackId_
Definition: Track.h:303
bool udpateSeed(int id=0, AbsTrackRep *rep=NULL, bool biased=true)
const TMatrixDSym & getCovSeed() const
Definition: Track.h:166
void insertPoints(std::vector< genfit::TrackPoint * > points, int id=-1)
Insert TrackPoints BEFORE TrackPoint with position id, if id &gt;= 0.
void fixWeights(AbsTrackRep *rep=NULL, int startId=0, int endId=-1)
Contains the measurement and covariance in raw detector coordinates.
void setFitStatus(FitStatus *fitStatus, const AbsTrackRep *rep)
const MeasuredStateOnPlane & getFittedState(int id=0, const AbsTrackRep *rep=NULL, bool biased=true) const
Shortcut to get FittedStates.
void swap(Track &other)
bool hasFitStatus(const AbsTrackRep *rep=NULL) const
Check if track has a FitStatus for given AbsTrackRep. Per default, check for cardinal rep...
virtual void Clear(Option_t *="")
PndSdsMCPoint * point
Definition: anaLmdCluster.C:72
void deleteBackwardInfo(int startId=0, int endId=-1, const AbsTrackRep *rep=NULL)
void prune(const Option_t *="CFLWRMIU")
Delete unneeded information from the Track.