EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GFAbsTrackRep.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file GFAbsTrackRep.h
1 /* Copyright 2008-2010, Technische Universitaet Muenchen,
2  Authors: Christian Hoeppner & Sebastian Neubert
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 GFABSTRACKREP_H
25 #define GFABSTRACKREP_H
26 
27 #include<vector>
28 #include<list>
29 #include<iostream>
30 
31 #include "TMatrixT.h"
32 #include "TVector3.h"
33 #include "TMath.h"
34 
35 #include "GFDetPlane.h"
36 
37 class GFAbsRecoHit;
38 
81 class GFAbsTrackRep : public TObject{
82 
83  /*----- Data members -----*/
84  protected:
86  unsigned int fDimension;
87 
89  TMatrixT<double> fState;
90 
92  TMatrixT<double> fCov;
93 
95  double fChiSqu;
97  unsigned int fNdf;
98 
102  bool fInverted;
103 
105  TMatrixT<double> fFirstState;
106  TMatrixT<double> fFirstCov;
107 
108  TMatrixT<double> fLastState;
109  TMatrixT<double> fLastCov;
112 
113  // detector plane where the track parameters are given
115 
116  double fXX0;
117 
118 
119  public:
120  virtual GFAbsTrackRep* clone() const = 0;
121 
122  virtual GFAbsTrackRep* prototype() const = 0;
123 
125 
131  virtual double extrapolate(const GFDetPlane& plane, TMatrixT<double>& statePred);
132 
133 
134  public:
135 
136  GFAbsTrackRep();
137  GFAbsTrackRep(int);
138  virtual ~GFAbsTrackRep();
139 
140 
142 
153  virtual void extrapolateToPoint(const TVector3& point,
154  TVector3& poca,
155  TVector3& normVec);
156 
158 
166  virtual void extrapolateToLine(const TVector3& point1,
167  const TVector3& point2,
168  TVector3& poca,
169  TVector3& normVec,
170  TVector3& poca_onwire);
171 
172 
174 
179  virtual double stepalong(double h,
180  TVector3& point,
181  TVector3& dir);
182 
184 
187  virtual double extrapolate(const GFDetPlane& plane,
188  TMatrixT<double>& statePred,
189  TMatrixT<double>& covPred)=0;
190 
192 
195  double extrapolate(const GFDetPlane& plane);
196 
198  unsigned int getDim() const {return fDimension;}
199 
200  virtual void Print(const Option_t* = "") const;
201 
202  inline TMatrixT<double> getState() const {
203  return fState;
204  }
205  inline TMatrixT<double> getCov() const {
206  return fCov;
207  }
208 
209  double getStateElem(int i) const {return fState(i,0);}
210  double getCovElem(int i, int j) const {return fCov(i,j);}
211 
212 
213 
214  virtual TVector3 getPos(const GFDetPlane& pl)=0;
215  virtual TVector3 getMom(const GFDetPlane& pl)=0;
216  virtual void getPosMom(const GFDetPlane& pl,TVector3& pos,TVector3& mom)=0;
217 
219 
223  virtual void getPosMomCov(const GFDetPlane& pl,TVector3& pos,TVector3& mom,TMatrixT<double>& cov);
224 
225  virtual double getCharge()const =0;
226 
228 
231  virtual int getPDG();
232 
233  TVector3 getPos() {return getPos(fRefPlane);}
234  TVector3 getMom() {return getMom(fRefPlane);}
235  void getPosMomCov(TVector3& pos,TVector3& mom,TMatrixT<double>& c){
236  getPosMomCov(fRefPlane,pos,mom,c);
237  }
238 
239  inline TMatrixT<double> getFirstState() const {
240  return fFirstState;
241  }
242  inline TMatrixT<double> getFirstCov() const {
243  return fFirstCov;
244  }
245  inline GFDetPlane getFirstPlane() const {
246  return fFirstPlane;
247  }
248  inline TMatrixT<double> getLastState() const {
249  return fLastState;
250  }
251  inline TMatrixT<double> getLastCov() const {
252  return fLastCov;
253  }
254  inline GFDetPlane getLastPlane() const {
255  return fLastPlane;
256  }
257  inline double getChiSqu() const {
258  return fChiSqu;
259  }
260  inline double getForwardChiSqu() const {
261  return fForwardChiSqu;
262  }
264  inline double getRedChiSqu() const {
265  if(getNDF()>0) return getChiSqu()/getNDF();
266  return 0;
267  }
268  // returns p-value
269  inline double getPVal() const {
270  return TMath::Prob(getChiSqu(), getNDF());
271  }
272  inline unsigned int getNDF() const {
273  if(fNdf>getDim()) return fNdf-getDim();
274  return 0;
275  }
279  inline double getXX0() const {
280  return fXX0;
281  }
293  virtual void setData(const TMatrixT<double>& st, const GFDetPlane& pl, const TMatrixT<double>* cov=NULL, const TMatrixT<double>* aux=NULL){
294  fState=st;
295  fRefPlane=pl;
296  if(cov!=NULL) fCov=*cov;
297  static_cast<void>(aux);
298  }
299  inline void setCov(const TMatrixT<double>& aCov) {
300  fCov=aCov;
301  }
302  inline void setFirstState(const TMatrixT<double>& aState) {
303  fFirstState = aState;
304  }
305  inline void setFirstCov(const TMatrixT<double>& aCov) {
306  fFirstCov = aCov;
307  }
308  inline void setFirstPlane(const GFDetPlane& aPlane) {
309  fFirstPlane = aPlane;;
310  }
311  inline void setLastState(const TMatrixT<double>& aState) {
312  fLastState = aState;
313  }
314  inline void setLastCov(const TMatrixT<double>& aCov) {
315  fLastCov = aCov;
316  }
317  inline void setLastPlane(const GFDetPlane& aPlane) {
318  fLastPlane = aPlane;;
319  }
320 
322 
326  virtual void setPosMomCov(const TVector3& pos, const TVector3& mom, const TMatrixT<double>& cov);
327 
328  const GFDetPlane& getReferencePlane() const {return fRefPlane;}
329 
330  inline void setChiSqu(double aChiSqu) {
331  fChiSqu = aChiSqu;
332  }
333  inline void setForwardChiSqu(double aChiSqu) {
334  fForwardChiSqu = aChiSqu;
335  }
336  inline void setNDF(unsigned int n) {
337  fNdf = n;
338  }
339  inline void addChiSqu(double aChiSqu) {
340  fChiSqu += aChiSqu;
341  }
342  inline void addForwardChiSqu(double aChiSqu) {
343  fForwardChiSqu += aChiSqu;
344  }
345  inline void addNDF(unsigned int n) {
346  fNdf += n;
347  }
348  inline void setStatusFlag(int _val) {
349  fStatusFlag = _val;
350  }
351 
352  virtual void switchDirection() = 0;
353 
355  bool setInverted(bool f=true){fInverted=f; return true;}
356 
357  inline bool getStatusFlag() {
358  return fStatusFlag;
359  }
360 
361  virtual void reset();
362 
368  virtual bool hasAuxInfo() {
369  return false;
370  }
371 
381  virtual const TMatrixT<double>* getAuxInfo(const GFDetPlane&) {
382  return NULL;
383  }
384 
385 
386  void resetXX0() {
387  fXX0 = 0.;
388  }
389 
390  private:
391  void Abort(std::string method);
392 
393 
394  ClassDef(GFAbsTrackRep,4)
395 
396 };
397 
398 #endif
399