EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrackCand.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TrackCand.h
1 /* Copyright 2008-2010, Technische Universitaet Muenchen,
2  Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch
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  */
22 #ifndef genfit_TrackCand_h
23 #define genfit_TrackCand_h
24 
25 #include "TrackCandHit.h"
26 
27 #include <vector>
28 #include <set>
29 #include <assert.h>
30 
31 #include <TObject.h>
32 #include <TVector3.h>
33 #include <TVectorD.h>
34 #include <TMatrixD.h>
35 #include <TMatrixDSym.h>
36 #include <TDatabasePDG.h>
37 
38 #include <cmath>
39 
40 
41 namespace genfit {
42 
69 class TrackCand : public TObject {
70 
71 
72  public:
73 
74 
75  // Constructors/Destructors ---------
76  TrackCand();
77  ~TrackCand();
78 
80  TrackCand( const TrackCand& other );
83  void swap(TrackCand& other); // nothrow
84 
86  friend bool operator== (const TrackCand& lhs, const TrackCand& rhs);
87  friend bool operator!= (const TrackCand& lhs, const TrackCand& rhs) {return !(lhs == rhs);}
88 
89  static bool compareTrackCandHits(const TrackCandHit* lhs, const TrackCandHit* rhs) {return (*lhs < *rhs);} // operator< defined in TrackCandHit.h
90 
91  // Accessors -----------------------
92  TrackCandHit* getHit(int i) const;
93 
95  void getHit(int i, int& detId, int& hitId) const;
96 
98  void getHit(int i, int& detId, int& hitId, double& sortingParameter) const;
99 
101  void getHitWithPlane(int i, int& detId, int& hitId, int& planeId) const;
102 
103  unsigned int getNHits() const {return hits_.size();}
104 
110  std::vector<int> getHitIDs(int detId = -2) const;
111 
113  std::vector<int> getDetIDs() const;
115  std::vector<double> getSortingParameters() const;
116  std::set<int> getUniqueDetIDs() const;
117 
119  int getMcTrackId() const {return mcTrackId_;}
120 
122  double getTimeSeed() const { return time_; }
123 
125  TVector3 getPosSeed() const {return TVector3(state6D_(0), state6D_(1), state6D_(2));}
126 
128  TVector3 getMomSeed() const {return TVector3(state6D_(3), state6D_(4), state6D_(5));}
129 
131  const TMatrixDSym& getCovSeed() const {return cov6D_;}
132 
134  const TVectorD& getStateSeed() const {return state6D_;}
135 
136  double getChargeSeed() const {return q_;}
137 
139  int getPdgCode() const {return pdg_;}
140 
142  bool hitInTrack(int detId, int hitId) const;
143 
144  // Modifiers -----------------------
145 
146  void addHit(int detId, int hitId, int planeId = -1, double sortingParameter = 0);
147 
148  void addHit(TrackCandHit* hit) {hits_.push_back(hit);}
149 
151  void setMcTrackId(int i) {mcTrackId_ = i;}
152 
154  void setPdgCode(int pdgCode);
155 
157  void append(const TrackCand&);
158 
160  void sortHits();
161 
162  void sortHits(const std::vector<unsigned int>& indices);
163 
164  // Operations ----------------------
166  void reset();
167 
169  void Print(const Option_t* = "") const ;
170 
172  void setTimeSeed(double time) { time_ = time; }
173 
175  void setCovSeed(const TMatrixDSym& cov6D) {cov6D_ = cov6D; /* always 6D, no need to resize */}
176 
180  void set6DSeed(const TVectorD& state6D, const double charge);
181 
184  void set6DSeedAndPdgCode(const TVectorD& state6D, const int pdgCode);
185 
189  void setPosMomSeed(const TVector3& pos, const TVector3& mom, const double charge);
190 
193  void setPosMomSeedAndPdgCode(const TVector3& pos, const TVector3& mom, const int pdgCode);
194 
201  void setTime6DSeed(double time, const TVectorD& state6D, const double charge);
202 
207  void setTime6DSeedAndPdgCode(double time, const TVectorD& state6D, const int pdgCode);
208 
214  void setTimePosMomSeed(double time, const TVector3& pos, const TVector3& mom,
215  const double charge);
216 
221  void setTimePosMomSeedAndPdgCode(double time, const TVector3& pos,
222  const TVector3& mom, const int pdgCode);
223 
224 
225  private:
226 
227  // Private Data Members ------------
228  std::vector<TrackCandHit*> hits_; //->
229 
231  int pdg_;
233  double time_;
234  TVectorD state6D_;
235  TMatrixDSym cov6D_;
236  double q_;
239  public:
240 
241  ClassDef(TrackCand,2)
242  // Version history:
243  // ver 2: keep track of time in state (schema evolution rule added).
244 };
245 
246 } /* End of namespace genfit */
249 #endif // genfit_TrackCand_h