Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Track.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Track.h
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 = nullptr);
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  void createMeasurements(const TrackCand& trackCand, const MeasurementFactory<genfit::AbsMeasurement>& factory);
107 
108  TrackPoint* getPoint(int id) const;
109  const std::vector< genfit::TrackPoint* > & getPoints() const {return trackPoints_;}
110  unsigned int getNumPoints() const {return trackPoints_.size();}
111 
112  TrackPoint* getPointWithMeasurement(int id) const;
113  const std::vector< genfit::TrackPoint* > & getPointsWithMeasurement() const {return trackPointsWithMeasurement_;}
114  unsigned int getNumPointsWithMeasurement() const {return trackPointsWithMeasurement_.size();}
115 
116  TrackPoint* getPointWithMeasurementAndFitterInfo(int id, const AbsTrackRep* rep = nullptr) const;
117  TrackPoint* getPointWithFitterInfo(int id, const AbsTrackRep* rep = nullptr) const;
118 
128  const MeasuredStateOnPlane& getFittedState(int id = 0, const AbsTrackRep* rep = nullptr, bool biased = true) const;
129 
130  AbsTrackRep* getTrackRep(int id) const {return trackReps_.at(id);}
132  const std::vector<genfit::AbsTrackRep*>& getTrackReps() const {return trackReps_;}
133  unsigned int getNumReps() const {return trackReps_.size();}
134 
136  int getIdForRep(const AbsTrackRep* rep) const;
137 
146  unsigned int getCardinalRepId() const {return cardinalRep_;}
147 
149  int getMcTrackId() const {return mcTrackId_;}
150 
152  bool hasFitStatus(const AbsTrackRep* rep = nullptr) const;
154  FitStatus* getFitStatus(const AbsTrackRep* rep = nullptr) const {if (rep == nullptr) rep = getCardinalRep(); return fitStatuses_.at(rep);}
155 
157  bool hasKalmanFitStatus(const AbsTrackRep* rep = nullptr) const;
159  KalmanFitStatus* getKalmanFitStatus(const AbsTrackRep* rep = nullptr) const;
160 
161  void setFitStatus(FitStatus* fitStatus, const AbsTrackRep* rep);
162 
163  double getTimeSeed() const {return timeSeed_;}
164  void setTimeSeed(double time) {timeSeed_ = time;}
165 
166  const TVectorD& getStateSeed() const {return stateSeed_;}
167  void setStateSeed(const TVectorD& s) {stateSeed_.ResizeTo(s); stateSeed_ = s;}
168  void setStateSeed(const TVector3& pos, const TVector3& mom);
169 
170  const TMatrixDSym& getCovSeed() const {return covSeed_;}
171  void setCovSeed(const TMatrixDSym& c) {covSeed_.ResizeTo(c); covSeed_ = c;}
172 
174  void setMcTrackId(int i) {mcTrackId_ = i;}
175 
183  void insertPoint(TrackPoint* point, int id = -1);
184 
192  void insertPoints(std::vector<genfit::TrackPoint*> points, int id = -1);
193 
194  void deletePoint(int id);
195 
197  void insertMeasurement(AbsMeasurement* measurement, int id = -1);
198 
209  void mergeTrack(const Track* other, int id = -1);
210 
211  void addTrackRep(AbsTrackRep* trackRep);
212 
214  void deleteTrackRep(int id);
215 
216  void setCardinalRep(int id);
218  void determineCardinalRep();
219 
225  bool sort();
226 
229  bool udpateSeed(int id = 0, AbsTrackRep* rep = nullptr, bool biased = true);
230 
232  void reverseTrackPoints();
233 
235  void reverseMomSeed() {
236  stateSeed_(3) *= -1; stateSeed_(4) *= -1; stateSeed_(5) *= -1;
237  }
238 
240  void switchPDGSigns(AbsTrackRep* rep = nullptr);
241 
243 
248  void reverseTrack();
249 
250 
251  void deleteForwardInfo(int startId = 0, int endId = -1, const AbsTrackRep* rep = nullptr); // delete in range [startId, endId]. If rep == nullptr, delete for ALL reps, otherwise only for rep.
252  void deleteBackwardInfo(int startId = 0, int endId = -1, const AbsTrackRep* rep = nullptr); // delete in range [startId, endId]. If rep == nullptr, delete for ALL reps, otherwise only for rep.
253  void deleteReferenceInfo(int startId = 0, int endId = -1, const AbsTrackRep* rep = nullptr); // delete in range [startId, endId]. If rep == nullptr, delete for ALL reps, otherwise only for rep.
254  void deleteMeasurementInfo(int startId = 0, int endId = -1, const AbsTrackRep* rep = nullptr); // delete in range [startId, endId]. If rep == nullptr, delete for ALL reps, otherwise only for rep.
255  void deleteFitterInfo(int startId = 0, int endId = -1, const AbsTrackRep* rep = nullptr); // delete in range [startId, endId]. If rep == nullptr, delete for ALL reps, otherwise only for rep.
256 
258  double getTrackLen(AbsTrackRep* rep = nullptr, int startId = 0, int endId = -1) const;
260  double getTOF(AbsTrackRep* rep = nullptr, int startId = 0, int endId = -1) const;
261 
269  void deleteFittedState(const genfit::AbsTrackRep* rep);
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  void checkConsistency() const;
303 
304  private:
305 
306  void trackHasChanged();
307 
309 
310  std::vector<AbsTrackRep*> trackReps_; // Ownership
311  unsigned int cardinalRep_; // THE selected rep, default = 0;
312 
313  std::vector<TrackPoint*> trackPoints_; // Ownership
314  std::vector<TrackPoint*> trackPointsWithMeasurement_;
315 
316  std::map< const AbsTrackRep*, FitStatus* > fitStatuses_; // Ownership over FitStatus*
317 
319  double timeSeed_;
320  TVectorD stateSeed_; // 6D: position, momentum
321  TMatrixDSym covSeed_; // 6D
322 
323 
324  public:
325  ClassDef(Track,3)
326  // Class version history:
327  // ver 3: introduces timeSeed_
328 };
329 
330 } /* End of namespace genfit */
333 #endif // genfit_Track_h