PandaRoot
GFAbsTrackRep.h
Go to the documentation of this file.
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 
34 #include "GFDetPlane.h"
35 
36 class GFAbsRecoHit;
37 
80 class GFAbsTrackRep : public TObject {
81 
82  /*----- Data members -----*/
83  protected:
85  unsigned int fDimension;
86 
88  TMatrixT<double> fState;
89 
91  TMatrixT<double> fCov;
92 
94  double fChiSqu;
95  unsigned int fNdf;
96 
100  bool fInverted;
101 
103  TMatrixT<double> fFirstState;
104  TMatrixT<double> fFirstCov;
105 
106  TMatrixT<double> fLastState;
107  TMatrixT<double> fLastCov;
110 
111  // detector plane where the track parameters are given
113 
114  public:
115  virtual GFAbsTrackRep *clone() const = 0;
116 
117  virtual GFAbsTrackRep *prototype() const = 0;
118 
120 
125  virtual double extrapolate(const GFDetPlane &plane, TMatrixT<double> &statePred);
126 
127  public:
128  GFAbsTrackRep();
129  GFAbsTrackRep(int);
130  virtual ~GFAbsTrackRep();
131 
133 
143  virtual void extrapolateToPoint(const TVector3 &point, TVector3 &poca, TVector3 &normVec);
144 
146 
153  virtual void extrapolateToLine(const TVector3 &point1, const TVector3 &point2, TVector3 &poca, TVector3 &normVec, TVector3 &poca_onwire);
154 
156 
160  virtual double stepalong(double h, TVector3 &point, TVector3 &dir);
161 
163 
166  virtual double extrapolate(const GFDetPlane &plane, TMatrixT<double> &statePred, TMatrixT<double> &covPred) = 0;
167 
169 
172  double extrapolate(const GFDetPlane &plane);
173 
175  unsigned int getDim() const { return fDimension; }
176 
177  virtual void Print() const;
178 
179  inline TMatrixT<double> getState() const { return fState; }
180  inline TMatrixT<double> getCov() const { return fCov; }
181 
182  double getStateElem(int i) const { return fState(i, 0); }
183  double getCovElem(int i, int j) const { return fCov(i, j); }
184 
185  virtual TVector3 getPos(const GFDetPlane &pl) = 0;
186  virtual TVector3 getMom(const GFDetPlane &pl) = 0;
187  virtual void getPosMom(const GFDetPlane &pl, TVector3 &pos, TVector3 &mom) = 0;
188 
190 
194  virtual void getPosMomCov(const GFDetPlane &pl, TVector3 &pos, TVector3 &mom, TMatrixT<double> &cov);
195 
196  virtual double getCharge() const = 0;
197 
198  TVector3 getPos() { return getPos(fRefPlane); }
199  TVector3 getMom() { return getMom(fRefPlane); }
200  void getPosMomCov(TVector3 &pos, TVector3 &mom, TMatrixT<double> &c) { getPosMomCov(fRefPlane, pos, mom, c); }
201 
202  inline TMatrixT<double> getFirstState() const { return fFirstState; }
203  inline TMatrixT<double> getFirstCov() const { return fFirstCov; }
204  inline GFDetPlane getFirstPlane() const { return fFirstPlane; }
205  inline TMatrixT<double> getLastState() const { return fLastState; }
206  inline TMatrixT<double> getLastCov() const { return fLastCov; }
207  inline GFDetPlane getLastPlane() const { return fLastPlane; }
208  inline double getChiSqu() const { return fChiSqu; }
210  inline double getRedChiSqu() const
211  {
212  if (getNDF() > 0)
213  return getChiSqu() / getNDF();
214  return 0;
215  }
216  inline unsigned int getNDF() const
217  {
218  if (fNdf > getDim())
219  return fNdf - getDim();
220  return 0;
221  }
233  virtual void setData(const TMatrixT<double> &st, const GFDetPlane &pl, const TMatrixT<double> *cov = nullptr, const TMatrixT<double> *aux = nullptr)
234  {
235  fState = st;
236  fRefPlane = pl;
237  if (cov != nullptr)
238  fCov = *cov;
239  if (aux != nullptr) {
240  ;
241  }
242  }
243  inline void setCov(const TMatrixT<double> &aCov) { fCov = aCov; }
244  inline void setFirstState(const TMatrixT<double> &aState) { fFirstState = aState; }
245  inline void setFirstCov(const TMatrixT<double> &aCov) { fFirstCov = aCov; }
246  inline void setFirstPlane(const GFDetPlane &aPlane)
247  {
248  fFirstPlane = aPlane;
249  ;
250  }
251  inline void setLastState(const TMatrixT<double> &aState) { fLastState = aState; }
252  inline void setLastCov(const TMatrixT<double> &aCov) { fLastCov = aCov; }
253  inline void setLastPlane(const GFDetPlane &aPlane)
254  {
255  fLastPlane = aPlane;
256  ;
257  }
258 
259  const GFDetPlane &getReferencePlane() const { return fRefPlane; }
260 
261  inline void setChiSqu(double aChiSqu) { fChiSqu = aChiSqu; }
262  inline void setNDF(unsigned int n) { fNdf = n; }
263  inline void addChiSqu(double aChiSqu) { fChiSqu += aChiSqu; }
264  inline void addNDF(unsigned int n) { fNdf += n; }
265  inline void setStatusFlag(int _val) { fStatusFlag = _val; }
266 
267  virtual void switchDirection() = 0;
268 
270  bool setInverted(bool f = true)
271  {
272  fInverted = f;
273  return true;
274  }
275 
276  inline bool getStatusFlag() { return fStatusFlag; }
277 
278  virtual void reset();
279 
285  virtual bool hasAuxInfo() { return false; }
286 
296  virtual const TMatrixT<double> *getAuxInfo(const GFDetPlane &)
297  { //(const GFDetPlane& pl)
298  return nullptr;
299  }
300 
301  private:
302  void Abort(std::string method);
303 
304  ClassDef(GFAbsTrackRep, 3)
305 };
306 
307 #endif
308 
TVector3 getMom()
virtual void extrapolateToLine(const TVector3 &point1, const TVector3 &point2, TVector3 &poca, TVector3 &normVec, TVector3 &poca_onwire)
This method extrapolates to the point of closest approach to a line.
virtual double stepalong(double h, TVector3 &point, TVector3 &dir)
make step of h cm along the track
Base Class for genfit track representations. Defines interface for track parameterizations.
Definition: GFAbsTrackRep.h:80
unsigned int getDim() const
returns dimension of state vector
void addNDF(unsigned int n)
void setFirstState(const TMatrixT< double > &aState)
Detector plane genfit geometry class.
Definition: GFDetPlane.h:58
virtual void Print() const
virtual void getPosMom(const GFDetPlane &pl, TVector3 &pos, TVector3 &mom)=0
virtual ~GFAbsTrackRep()
TMatrixT< double > fLastState
void setFirstPlane(const GFDetPlane &aPlane)
TMatrixT< double > getCov() const
TMatrixT< double > getState() const
bool setInverted(bool f=true)
Deprecated. Should be removed soon.
TMatrixT< double > fFirstCov
TMatrixT< double > getLastCov() const
GFDetPlane getLastPlane() const
virtual void getPosMomCov(const GFDetPlane &pl, TVector3 &pos, TVector3 &mom, TMatrixT< double > &cov)
method which gets position, momentum and 6x6 covariance matrix
unsigned int i
Definition: P4_F32vec4.h:21
virtual void setData(const TMatrixT< double > &st, const GFDetPlane &pl, const TMatrixT< double > *cov=nullptr, const TMatrixT< double > *aux=nullptr)
Puts the track representation in a given state.
double getStateElem(int i) const
unsigned int fDimension
Dimensionality of track representation.
Definition: GFAbsTrackRep.h:85
unsigned int fNdf
Definition: GFAbsTrackRep.h:95
TMatrixT< double > fFirstState
state, cov and plane for first and last point in fit
virtual GFAbsTrackRep * prototype() const =0
unsigned int getNDF() const
GFDetPlane getFirstPlane() const
void setCov(const TMatrixT< double > &aCov)
virtual const TMatrixT< double > * getAuxInfo(const GFDetPlane &)
Get auxillary information from the track representation.
bool getStatusFlag()
void setLastPlane(const GFDetPlane &aPlane)
virtual bool hasAuxInfo()
See if the track representation has auxillary information stored.
virtual void reset()
void setLastCov(const TMatrixT< double > &aCov)
TMatrixT< double > getLastState() const
bool fInverted
specifies the direction of flight of the particle
GFDetPlane fFirstPlane
void addChiSqu(double aChiSqu)
GFDetPlane fRefPlane
TVector3 getPos()
virtual double extrapolate(const GFDetPlane &plane, TMatrixT< double > &statePred)
returns the tracklength spanned in this extrapolation
TMatrixT< double > getFirstCov() const
Base Class for representing a Hit in GENFIT.
Definition: GFAbsRecoHit.h:71
GFDetPlane fLastPlane
double getRedChiSqu() const
returns chi2/ndf
double getChiSqu() const
void setNDF(unsigned int n)
void setChiSqu(double aChiSqu)
double getCovElem(int i, int j) const
int fStatusFlag
status of track representation: 0 means everything&#39;s OK
Definition: GFAbsTrackRep.h:98
void setFirstCov(const TMatrixT< double > &aCov)
float f
Definition: P4_F32vec4.h:20
void setLastState(const TMatrixT< double > &aState)
void setStatusFlag(int _val)
const GFDetPlane & getReferencePlane() const
TMatrixT< double > fState
The vector of track parameters.
Definition: GFAbsTrackRep.h:88
double fChiSqu
chiSqu of the track fit
Definition: GFAbsTrackRep.h:94
virtual void extrapolateToPoint(const TVector3 &point, TVector3 &poca, TVector3 &normVec)
This method is to extrapolate the track to point of closest approach to a point in space...
virtual void switchDirection()=0
TMatrixT< double > fLastCov
virtual GFAbsTrackRep * clone() const =0
void getPosMomCov(TVector3 &pos, TVector3 &mom, TMatrixT< double > &c)
virtual double getCharge() const =0
TMatrixT< double > getFirstState() const
TMatrixT< double > fCov
The covariance matrix.
Definition: GFAbsTrackRep.h:91