LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
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<stdexcept> // std::logic_error
28 #include<vector>
29 #include<list>
30 #include<iostream>
31 
32 #include "TMatrixT.h"
33 #include "TVector3.h"
34 
36 
37 //class genf::GFAbsRecoHit;
38 
39 namespace genf {
40 
41 
42 
85 class GFAbsTrackRep : public TObject{
86 
87  /*----- Data members -----*/
88  protected:
90  unsigned int fDimension;
91 
93  TMatrixT<Double_t> fState;
94 
96  TMatrixT<Double_t> fCov;
97 
99  double fChiSqu;
100  unsigned int fNdf;
101 
105  bool fInverted;
106 
108  TMatrixT<Double_t> fFirstState;
109  TMatrixT<Double_t> fFirstCov;
110 
111  TMatrixT<Double_t> fLastState;
112  TMatrixT<Double_t> fLastCov;
115 
116  // detector plane where the track parameters are given
118 
119 
120 
121  public:
122  virtual GFAbsTrackRep* clone() const = 0;
123 
124  virtual GFAbsTrackRep* prototype() const = 0;
125 
127  /* ! There is a default implementation in GFAbsTrackRep.cxx which just drops
128  the predicted covaraiance. If your trackrep has a way to extrapolate
129  without giving a correct cov (that would be faster probably), please
130  overwrite it.
131  */
132  virtual double extrapolate(const GFDetPlane& plane, TMatrixT<Double_t>& statePred);
133 
134 
135  public:
136 
137  GFAbsTrackRep();
138  GFAbsTrackRep(int);
139  virtual ~GFAbsTrackRep();
140 
141 
143  /* ! There is an empty implementation of this method in GFAbsTrackRep.cxx,
144  which will just abort with an error message. One can overwrite this
145  method if one wishes to implement a track representation, which should
146  have this feature. An example of an experiment in which you would not
147  need this feature would be track fitting (not so much vertexing) in
148  an experiment with only planar trackers like silicons or planar wire
149  chambers and such. An example where you would need it, would be a TPC
150  where you have to fit the track to space points, or other drift chambers
151  with complicated hit topology.
152  */
153  virtual void extrapolateToPoint(const TVector3& point,
154  TVector3& poca,
155  TVector3& normVec);
156 
158 
165  virtual void extrapolateToLine(const TVector3& point1,
166  const TVector3& point2,
167  TVector3& poca,
168  TVector3& normVec,
169  TVector3& poca_onwire);
170 
171 
173 
177  virtual void stepalong(double h);
178 
180 
183  virtual double extrapolate(const GFDetPlane& plane,
184  TMatrixT<Double_t>& statePred,
185  TMatrixT<Double_t>& covPred)=0;
186 
188 
191  double extrapolate(const GFDetPlane& plane);
192 
194  unsigned int getDim() const {return fDimension;}
195 
196  virtual void Print(std::ostream& out = std::cout) const;
197 
198  const TMatrixT<Double_t>& getState() const { return fState; }
199  const TMatrixT<Double_t>& getCov() const { return fCov; }
200 
201  double getStateElem(int i) const {return fState(i,0);}
202  double getCovElem(int i, int j) const {return fCov(i,j);}
203 
204 
205 
206  virtual TVector3 getPos(const GFDetPlane& pl)=0;
207  virtual TVector3 getMom(const GFDetPlane& pl)=0;
208 
209  virtual void getPosMom(const GFDetPlane& pl,TVector3& pos,TVector3& mom)=0;
210 
212 
216  virtual void getPosMomCov(const GFDetPlane& pl,TVector3& pos,TVector3& mom,TMatrixT<Double_t>& cov);
217 
218  virtual double getCharge()const =0;
219 
220  TVector3 getPos() {return getPos(fRefPlane);}
221  TVector3 getMom() {return getMom(fRefPlane);}
222 
223  void getPosMomCov(TVector3& pos,TVector3& mom,TMatrixT<Double_t>& c){
224  getPosMomCov(fRefPlane,pos,mom,c);
225  }
226 
227  inline TMatrixT<Double_t> getFirstState() const {
228  return fFirstState;
229  }
230  inline TMatrixT<Double_t> getFirstCov() const {
231  return fFirstCov;
232  }
233  inline GFDetPlane getFirstPlane() const {
234  return fFirstPlane;
235  }
236  inline TMatrixT<Double_t> getLastState() const {
237  return fLastState;
238  }
239  inline TMatrixT<Double_t> getLastCov() const {
240  return fLastCov;
241  }
242  inline GFDetPlane getLastPlane() const {
243  return fLastPlane;
244  }
245  inline double getChiSqu() const {
246  return fChiSqu;
247  }
249  inline double getRedChiSqu() const {
250  if(getNDF()>0) return getChiSqu()/getNDF();
251  return 0;
252  }
253  inline unsigned int getNDF() const {
254  if(fNdf>getDim()) return fNdf-getDim();
255  return 0;
256  }
257 
258  virtual void setData(const TMatrixT<Double_t>& st, const GFDetPlane& pl, const TMatrixT<Double_t>* cov=NULL){
259  fState=st;
260  fRefPlane=pl;
261  if(cov!=NULL) fCov=*cov;
262  }
263  inline void setCov(const TMatrixT<Double_t>& aCov) {
264  fCov=aCov;
265  }
266  inline void setFirstState(const TMatrixT<Double_t>& aState) {
267  fFirstState = aState;
268  }
269  inline void setFirstCov(const TMatrixT<Double_t>& aCov) {
270  fFirstCov = aCov;
271  }
272  inline void setFirstPlane(const GFDetPlane& aPlane) {
273  fFirstPlane = aPlane;;
274  }
275  inline void setLastState(const TMatrixT<Double_t>& aState) {
276  fLastState = aState;
277  }
278  inline void setLastCov(const TMatrixT<Double_t>& aCov) {
279  fLastCov = aCov;
280  }
281  inline void setLastPlane(const GFDetPlane& aPlane) {
282  fLastPlane = aPlane;;
283  }
284 
285  const GFDetPlane& getReferencePlane() const {return fRefPlane;}
286 
287  inline void setChiSqu(double aChiSqu) {
288  fChiSqu = aChiSqu;
289  }
290  inline void setNDF(unsigned int n) {
291  fNdf = n;
292  }
293  inline void addChiSqu(double aChiSqu) {
294  fChiSqu += aChiSqu;
295  }
296  inline void addNDF(unsigned int n) {
297  fNdf += n;
298  }
299  inline void setStatusFlag(int _val) {
300  fStatusFlag = _val;
301  }
302 
303  virtual void switchDirection() = 0;
304 
306  bool setInverted(bool f=true){fInverted=f; return true;}
307 
308  inline bool getStatusFlag() {
309  return fStatusFlag;
310  }
311 
312  virtual void reset();
313 
314  private:
315  void Abort(std::string method);
316 
317  virtual void Print(Option_t*) const
318  { throw std::logic_error(std::string(__func__) + "::Print(Option_t*) not available"); }
319 
320 
321  //ClassDef(GFAbsTrackRep,3)
322 
323 };
324 
325 } // namespace genf
326 
327 #endif
328 
unsigned int getNDF() const
void setNDF(unsigned int n)
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.
bool fInverted
specifies the direction of flight of the particle
const GFDetPlane & getReferencePlane() const
TMatrixT< Double_t > getLastCov() const
virtual GFAbsTrackRep * clone() const =0
GFDetPlane getLastPlane() const
TMatrixT< Double_t > getLastState() const
virtual void stepalong(double h)
make step of h cm along the track
TMatrixT< Double_t > getFirstCov() const
Generic Interface to magnetic fields in GENFIT.
void setLastCov(const TMatrixT< Double_t > &aCov)
double fChiSqu
chiSqu of the track fit
Definition: GFAbsTrackRep.h:99
virtual void reset()
void setFirstPlane(const GFDetPlane &aPlane)
unsigned int fDimension
Dimensionality of track representation.
Definition: GFAbsTrackRep.h:90
const TMatrixT< Double_t > & getState() const
GFDetPlane fFirstPlane
virtual void getPosMomCov(const GFDetPlane &pl, TVector3 &pos, TVector3 &mom, TMatrixT< Double_t > &cov)
method which gets position, momentum and 6x6 covariance matrix
GFDetPlane getFirstPlane() const
Base Class for genfit track representations. Defines interface for track parameterizations.
Definition: GFAbsTrackRep.h:85
void setCov(const TMatrixT< Double_t > &aCov)
virtual void Print(Option_t *) const
void setChiSqu(double aChiSqu)
TFile f
Definition: plotHisto.C:6
TMatrixT< Double_t > fCov
The covariance matrix.
Definition: GFAbsTrackRep.h:96
void addNDF(unsigned int n)
double getCovElem(int i, int j) const
void getPosMomCov(TVector3 &pos, TVector3 &mom, TMatrixT< Double_t > &c)
virtual void setData(const TMatrixT< Double_t > &st, const GFDetPlane &pl, const TMatrixT< Double_t > *cov=NULL)
virtual GFAbsTrackRep * prototype() const =0
TMatrixT< Double_t > fFirstCov
void addChiSqu(double aChiSqu)
bool setInverted(bool f=true)
Deprecated. Should be removed soon.
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 double extrapolate(const GFDetPlane &plane, TMatrixT< Double_t > &statePred)
returns the tracklength spanned in this extrapolation
void Abort(std::string method)
TMatrixT< Double_t > getFirstState() const
virtual double getCharge() const =0
TMatrixT< Double_t > fLastState
TMatrixT< Double_t > fLastCov
const TMatrixT< Double_t > & getCov() const
void setFirstCov(const TMatrixT< Double_t > &aCov)
void setLastPlane(const GFDetPlane &aPlane)
TMatrixT< Double_t > fFirstState
state, cov and plane for first and last point in fit
void setLastState(const TMatrixT< Double_t > &aState)
int fStatusFlag
status of track representation: 0 means everything&#39;s OK
double getStateElem(int i) const
void setStatusFlag(int _val)
Char_t n[5]
TMatrixT< Double_t > fState
The vector of track parameters.
Definition: GFAbsTrackRep.h:93
void setFirstState(const TMatrixT< Double_t > &aState)
double getChiSqu() const
unsigned int getDim() const
returns dimension of state vector
virtual void switchDirection()=0
double getRedChiSqu() const
returns chi2/ndf
virtual void getPosMom(const GFDetPlane &pl, TVector3 &pos, TVector3 &mom)=0
virtual void Print(std::ostream &out=std::cout) const