FairRoot/PandaRoot
Functions
GFTools Namespace Reference

Namespace for various tools, mainly smoothing. More...

Functions

TMatrixT< double > getSmoothedPos (GFTrack *trk, unsigned int irep, unsigned int ihit)
 Get smoothed track position in plane coordinates. More...
 
TMatrixT< double > getSmoothedCov (GFTrack *trk, unsigned int irep, unsigned int ihit)
 Get smoothed track covariance in plane coordinates. More...
 
bool getSmoothedData (GFTrack *trk, unsigned int irep, unsigned int ihit, TMatrixT< double > &smoothed_state, TMatrixT< double > &smoothed_cov)
 Get smoothed state vector and state covariance. More...
 
bool getSmoothedData (GFTrack *trk, unsigned int irep, unsigned int ihit, TMatrixT< double > &smoothed_state, TMatrixT< double > &smoothed_cov, GFDetPlane &smoothing_plane)
 Get smoothed state vector, state covariance and smoothing plane. More...
 
bool getSmoothedData (GFTrack *trk, unsigned int irep, unsigned int ihit, TMatrixT< double > &smoothed_state, TMatrixT< double > &smoothed_cov, GFDetPlane &smoothing_plane, TMatrixT< double > &auxInfo)
 Get smoothed state vector, state covariance and smoothing plane. More...
 
GFDetPlane getSmoothingPlane (GFTrack *trk, unsigned int irep, unsigned int ihit)
 Get smoothing plane. More...
 
bool getBiasedSmoothedData (GFTrack *trk, unsigned int irep, unsigned int ihit, TMatrixT< double > &smoothed_state, TMatrixT< double > &smoothed_cov)
 Get biased smoothed state vector and state covariance. More...
 
bool getBiasedSmoothedData (GFTrack *trk, unsigned int irep, unsigned int ihit, TMatrixT< double > &smoothed_state, TMatrixT< double > &smoothed_cov, GFDetPlane &smoothing_plane)
 Get biased smoothed state vector, state covariance and smoothing plane. More...
 
bool getBiasedSmoothedData (GFTrack *trk, unsigned int irep, unsigned int ihit, TMatrixT< double > &smoothed_state, TMatrixT< double > &smoothed_cov, GFDetPlane &smoothing_plane, TMatrixT< double > &auxInfo)
 Get biased smoothed state vector, state covariance and smoothing plane. More...
 
TMatrixT< double > getBiasedSmoothedPos (GFTrack *trk, unsigned int irep, unsigned int ihit)
 Get biased smoothed track position in plane coordinates. More...
 
TMatrixT< double > getBiasedSmoothedCov (GFTrack *trk, unsigned int irep, unsigned int ihit)
 Get biased smoothed track covariance in plane coordinates. More...
 
void invertMatrix (const TMatrixT< double > &mat, TMatrixT< double > &inv)
 Invert a matrix, throwing GFException when inversion fails. More...
 
double getSmoothedChiSqu (GFTrack *const trk, unsigned int irep, unsigned int ihit)
 Get smoothed chi2 for a specific hit (ihit). More...
 

Detailed Description

Namespace for various tools, mainly smoothing.

The GFTools namespace contains various functions, most of which er intended to be used with the smoothing feature of the Kalman filter. These functions allow to extract the smoothed information for any track which was fitted with smoothing enabled.

Function Documentation

TMatrixT< double > GFTools::getBiasedSmoothedCov ( GFTrack trk,
unsigned int  irep,
unsigned int  ihit 
)

Get biased smoothed track covariance in plane coordinates.

Definition at line 57 of file GFTools.cxx.

References getBiasedSmoothedData(), GFTrack::getHit(), GFAbsRecoHit::getHMatrix(), and GFTrack::getTrackRep().

57  {
58 
59  TMatrixT<double> smoothed_state;
60  TMatrixT<double> smoothed_cov;
61  GFDetPlane pl;
62 
63  GFTools::getBiasedSmoothedData(trk, irep, ihit, smoothed_state, smoothed_cov, pl);
64  TMatrixT<double> H = trk->getHit(ihit)->getHMatrix(trk->getTrackRep(irep));
65 
66  TMatrixT<double> cov_tmp(smoothed_cov,TMatrixT<double>::kMultTranspose,H);
67  TMatrixT<double> cov(H,TMatrixT<double>::kMult,cov_tmp);
68 
69  return cov;
70 
71 }
bool getBiasedSmoothedData(GFTrack *trk, unsigned int irep, unsigned int ihit, TMatrixT< double > &smoothed_state, TMatrixT< double > &smoothed_cov)
Get biased smoothed state vector and state covariance.
Definition: GFTools.cxx:81
Detector plane genfit geometry class.
Definition: GFDetPlane.h:59
virtual TMatrixT< double > getHMatrix(const GFAbsTrackRep *stateVector)=0
Get transformation matrix. Transformation between hit coordinates and track representation coordinate...
GFAbsTrackRep * getTrackRep(int id) const
Accessor for track representations.
Definition: GFTrack.h:186
GFAbsRecoHit * getHit(int id) const
Definition: GFTrack.h:144
bool GFTools::getBiasedSmoothedData ( GFTrack trk,
unsigned int  irep,
unsigned int  ihit,
TMatrixT< double > &  smoothed_state,
TMatrixT< double > &  smoothed_cov 
)

Get biased smoothed state vector and state covariance.

Definition at line 81 of file GFTools.cxx.

Referenced by getBiasedSmoothedCov(), getBiasedSmoothedData(), getBiasedSmoothedPos(), and getSmoothedChiSqu().

81  {
82 
83  GFDetPlane pl;
84  TMatrixT<double> auxInfo;
85  return GFTools::getBiasedSmoothedData(trk, irep, ihit, smoothed_state, smoothed_cov, pl, auxInfo);
86 
87 }
bool getBiasedSmoothedData(GFTrack *trk, unsigned int irep, unsigned int ihit, TMatrixT< double > &smoothed_state, TMatrixT< double > &smoothed_cov)
Get biased smoothed state vector and state covariance.
Definition: GFTools.cxx:81
Detector plane genfit geometry class.
Definition: GFDetPlane.h:59
bool GFTools::getBiasedSmoothedData ( GFTrack trk,
unsigned int  irep,
unsigned int  ihit,
TMatrixT< double > &  smoothed_state,
TMatrixT< double > &  smoothed_cov,
GFDetPlane smoothing_plane 
)

Get biased smoothed state vector, state covariance and smoothing plane.

The smoothed data returned by this function includes the detector plane in which the data is calculated.

Definition at line 96 of file GFTools.cxx.

References getBiasedSmoothedData().

96  {
97 
98  TMatrixT<double> auxInfo;
99  return GFTools::getBiasedSmoothedData(trk, irep, ihit, smoothed_state, smoothed_cov, smoothing_plane, auxInfo);
100 
101 }
bool getBiasedSmoothedData(GFTrack *trk, unsigned int irep, unsigned int ihit, TMatrixT< double > &smoothed_state, TMatrixT< double > &smoothed_cov)
Get biased smoothed state vector and state covariance.
Definition: GFTools.cxx:81
bool GFTools::getBiasedSmoothedData ( GFTrack trk,
unsigned int  irep,
unsigned int  ihit,
TMatrixT< double > &  smoothed_state,
TMatrixT< double > &  smoothed_cov,
GFDetPlane smoothing_plane,
TMatrixT< double > &  auxInfo 
)

Get biased smoothed state vector, state covariance and smoothing plane.

The smoothed data returned by this function includes the detector plane in which the data is calculated as well as the auxillary information for this plane.

Definition at line 216 of file GFTools.cxx.

References GFAbsTrackRep::clone(), GFAbsTrackRep::extrapolate(), GFTrack::getBK(), GFBookkeeping::getDetPlane(), GFBookkeeping::getMatrix(), GFTrack::getNumHits(), GFTrack::getSmoothing(), GFTrack::getTrackRep(), GFAbsTrackRep::hasAuxInfo(), invertMatrix(), and GFAbsTrackRep::setData().

216  {
217 
218  if(!trk->getSmoothing()) {
219  std::cout << "Trying to get smoothed hit coordinates from a track without smoothing! Aborting..." << std::endl;
220  TMatrixT<double> failed(1,1);
221  return false;
222  }
223 
224  if(ihit >= trk->getNumHits()) {
225  std::cout << "Hit number out of bounds while trying to get smoothed hit coordinates! Aborting..." <<std::endl;
226  TMatrixT<double> failed(1,1);
227  failed(0,0) = 0;
228  return false;
229  }
230 
231  TMatrixT<double> bUpSt;
232  TMatrixT<double> bUpCov;
233  TMatrixT<double> bAuxInfo;
234  TMatrixT<double>* bAuxInfoP;
235  GFDetPlane bPl;
236 
237  GFAbsTrackRep* rep = trk->getTrackRep(irep)->clone();
238 
239  if(trk->getTrackRep(irep)->hasAuxInfo()) {
240  trk->getBK(irep)->getMatrix("fAuxInfo",ihit,auxInfo);
241  }
242 
243  if(ihit == 0) {
244  trk->getBK(irep)->getMatrix("bUpSt",ihit,smoothed_state);
245  trk->getBK(irep)->getMatrix("bUpCov",ihit,smoothed_cov);
246  trk->getBK(irep)->getDetPlane("bPl",ihit,smoothing_plane);
247  return true;
248  }
249 
250  if(ihit == trk->getNumHits()-1) {
251  trk->getBK(irep)->getMatrix("fUpSt",ihit,smoothed_state);
252  trk->getBK(irep)->getMatrix("fUpCov",ihit,smoothed_cov);
253  trk->getBK(irep)->getDetPlane("fPl",ihit,smoothing_plane);
254  return true;
255  }
256 
257  TMatrixT<double> fSt;
258  TMatrixT<double> fCov;
259 
260  trk->getBK(irep)->getMatrix("fUpSt",ihit,fSt);
261  trk->getBK(irep)->getMatrix("fUpCov",ihit,fCov);
262  trk->getBK(irep)->getMatrix("bUpSt",ihit+1,bUpSt);
263  trk->getBK(irep)->getMatrix("bUpCov",ihit+1,bUpCov);
264  if(trk->getTrackRep(irep)->hasAuxInfo()) {
265  trk->getBK(irep)->getMatrix("bAuxInfo",ihit+1,bAuxInfo);
266  bAuxInfoP = &bAuxInfo;
267  } else {
268  bAuxInfoP = NULL;
269  }
270  trk->getBK(irep)->getDetPlane("fPl",ihit,smoothing_plane);
271  trk->getBK(irep)->getDetPlane("bPl",ihit+1,bPl);
272 
273 
274  TMatrixT<double> bSt;
275  TMatrixT<double> bCov;
276 
277  if(bUpSt.GetNrows() == 0) return false;
278 
279  rep->setData(bUpSt,bPl,&bUpCov,bAuxInfoP);
280  rep->extrapolate(smoothing_plane,bSt,bCov);
281 
282  delete rep;
283 
284  TMatrixT<double> fCovInvert;
285  TMatrixT<double> bCovInvert;
286 
287  GFTools::invertMatrix(fCov, fCovInvert);
288  GFTools::invertMatrix(bCov, bCovInvert);
289 
290  GFTools::invertMatrix(fCovInvert + bCovInvert, smoothed_cov);
291 
292  smoothed_state.ResizeTo(smoothed_cov * (fCovInvert*fSt + bCovInvert*bSt));
293  smoothed_state = smoothed_cov * (fCovInvert*fSt + bCovInvert*bSt);
294 
295  return true;
296 
297 }
Base Class for genfit track representations. Defines interface for track parameterizations.
Definition: GFAbsTrackRep.h:80
GFBookkeeping * getBK(int index=-1)
get GFBookKeeping object for particular track rep (default is cardinal rep)
Definition: GFTrack.h:326
unsigned int getNumHits() const
Definition: GFTrack.h:148
Detector plane genfit geometry class.
Definition: GFDetPlane.h:59
bool getSmoothing()
Read back if smoothing is/was turned on or off for this track.
Definition: GFTrack.h:405
bool getDetPlane(std::string key, unsigned int index, GFDetPlane &pl)
void invertMatrix(const TMatrixT< double > &mat, TMatrixT< double > &inv)
Invert a matrix, throwing GFException when inversion fails.
Definition: GFTools.cxx:334
virtual bool hasAuxInfo()
See if the track representation has auxillary information stored.
virtual double extrapolate(const GFDetPlane &plane, TMatrixT< double > &statePred)
returns the tracklength spanned in this extrapolation
GFAbsTrackRep * getTrackRep(int id) const
Accessor for track representations.
Definition: GFTrack.h:186
bool getMatrix(std::string key, unsigned int index, TMatrixT< double > &mat)
virtual void setData(const TMatrixT< double > &st, const GFDetPlane &pl, const TMatrixT< double > *cov=NULL, const TMatrixT< double > *aux=NULL)
Puts the track representation in a given state.
virtual GFAbsTrackRep * clone() const =0
TMatrixT< double > GFTools::getBiasedSmoothedPos ( GFTrack trk,
unsigned int  irep,
unsigned int  ihit 
)

Get biased smoothed track position in plane coordinates.

Definition at line 22 of file GFTools.cxx.

References getBiasedSmoothedData(), GFTrack::getHit(), GFAbsRecoHit::getHMatrix(), GFTrack::getTrackRep(), and pos.

22  {
23 
24 TMatrixT<double> smoothed_state;
25  TMatrixT<double> smoothed_cov;
26  TMatrixT<double> pos;
27 
28  if(GFTools::getBiasedSmoothedData(trk, irep, ihit, smoothed_state, smoothed_cov)) {
29 
30  TMatrixT<double> H = trk->getHit(ihit)->getHMatrix(trk->getTrackRep(irep));
31  H.Print();smoothed_state.Print();
32  TMatrixT<double> pos_tmp(H * smoothed_state);
33  pos.ResizeTo(pos_tmp);
34  pos = pos_tmp;
35 
36  }
37  return pos;
38 
39 }
TVector3 pos
bool getBiasedSmoothedData(GFTrack *trk, unsigned int irep, unsigned int ihit, TMatrixT< double > &smoothed_state, TMatrixT< double > &smoothed_cov)
Get biased smoothed state vector and state covariance.
Definition: GFTools.cxx:81
virtual TMatrixT< double > getHMatrix(const GFAbsTrackRep *stateVector)=0
Get transformation matrix. Transformation between hit coordinates and track representation coordinate...
GFAbsTrackRep * getTrackRep(int id) const
Accessor for track representations.
Definition: GFTrack.h:186
GFAbsRecoHit * getHit(int id) const
Definition: GFTrack.h:144
double GFTools::getSmoothedChiSqu ( GFTrack *const  trk,
unsigned int  irep,
unsigned int  ihit 
)

Get smoothed chi2 for a specific hit (ihit).

This function calculates a smoothed chi2 value for a specific hit from the the so called "biased" smoothed state vector and covariance matrix. If many values from different tracks in the same layer are calculated they should be chi2 distributed with dim(m) degree of freedom, where m is the measurement vector of the hit. So for a pixel detector that measures x and y dim(m) will be 2.

Definition at line 358 of file GFTools.cxx.

References getBiasedSmoothedData(), GFTrack::getHit(), GFAbsRecoHit::getHMatrix(), GFAbsRecoHit::getRawHitCoord(), GFAbsRecoHit::getRawHitCov(), GFTrack::getTrackRep(), invertMatrix(), m, pos, R, and res.

358  {
359  TMatrixT<double> smoothed_state;
360  TMatrixT<double> smoothed_cov;
361  GFTools::getBiasedSmoothedData(trk, irep, ihit, smoothed_state, smoothed_cov);
362  TMatrixT<double> H = trk->getHit(ihit)->getHMatrix(trk->getTrackRep(irep));
363  TMatrixT<double> HT(TMatrixT<double>::kTransposed, H);
364  TMatrixT<double> pos = H * smoothed_state;
365  TMatrixT<double> m = trk->getHit(ihit)->getRawHitCoord(); //measurement of hit
366  TMatrixT<double> V = trk->getHit(ihit)->getRawHitCov(); //covariance matrix of hit
367  TMatrixT<double> res = m - pos;
368  TMatrixT<double> resT(TMatrixT<double>::kTransposed, res);
369  TMatrixT<double> R = V - H*smoothed_cov*HT;
370  TMatrixT<double> invR;
371  invertMatrix(R,invR);
372  TMatrixT<double> smoothedChiSqu = resT*invR*res;
373  return smoothedChiSqu[0][0];
374 }
TVector3 pos
bool getBiasedSmoothedData(GFTrack *trk, unsigned int irep, unsigned int ihit, TMatrixT< double > &smoothed_state, TMatrixT< double > &smoothed_cov)
Get biased smoothed state vector and state covariance.
Definition: GFTools.cxx:81
Int_t res
Definition: anadigi.C:166
__m128 m
Definition: P4_F32vec4.h:28
void invertMatrix(const TMatrixT< double > &mat, TMatrixT< double > &inv)
Invert a matrix, throwing GFException when inversion fails.
Definition: GFTools.cxx:334
virtual TMatrixT< double > getHMatrix(const GFAbsTrackRep *stateVector)=0
Get transformation matrix. Transformation between hit coordinates and track representation coordinate...
TMatrixT< double > getRawHitCoord() const
Get raw hit coordinates.
Definition: GFAbsRecoHit.h:158
GFAbsTrackRep * getTrackRep(int id) const
Accessor for track representations.
Definition: GFTrack.h:186
GFAbsRecoHit * getHit(int id) const
Definition: GFTrack.h:144
TMatrixT< double > getRawHitCov() const
Get raw hit covariances.
Definition: GFAbsRecoHit.h:153
Double_t R
Definition: checkhelixhit.C:61
TMatrixT< double > GFTools::getSmoothedCov ( GFTrack trk,
unsigned int  irep,
unsigned int  ihit 
)

Get smoothed track covariance in plane coordinates.

Definition at line 41 of file GFTools.cxx.

References GFTrack::getHit(), GFAbsRecoHit::getHMatrix(), getSmoothedData(), and GFTrack::getTrackRep().

41  {
42 
43  TMatrixT<double> smoothed_state;
44  TMatrixT<double> smoothed_cov;
45  GFDetPlane pl;
46 
47  GFTools::getSmoothedData(trk, irep, ihit, smoothed_state, smoothed_cov, pl);
48  TMatrixT<double> H = trk->getHit(ihit)->getHMatrix(trk->getTrackRep(irep));
49 
50  TMatrixT<double> cov_tmp(smoothed_cov,TMatrixT<double>::kMultTranspose,H);
51  TMatrixT<double> cov(H,TMatrixT<double>::kMult,cov_tmp);
52 
53  return cov;
54 
55 }
Detector plane genfit geometry class.
Definition: GFDetPlane.h:59
bool getSmoothedData(GFTrack *trk, unsigned int irep, unsigned int ihit, TMatrixT< double > &smoothed_state, TMatrixT< double > &smoothed_cov)
Get smoothed state vector and state covariance.
Definition: GFTools.cxx:73
virtual TMatrixT< double > getHMatrix(const GFAbsTrackRep *stateVector)=0
Get transformation matrix. Transformation between hit coordinates and track representation coordinate...
GFAbsTrackRep * getTrackRep(int id) const
Accessor for track representations.
Definition: GFTrack.h:186
GFAbsRecoHit * getHit(int id) const
Definition: GFTrack.h:144
bool GFTools::getSmoothedData ( GFTrack trk,
unsigned int  irep,
unsigned int  ihit,
TMatrixT< double > &  smoothed_state,
TMatrixT< double > &  smoothed_cov 
)

Get smoothed state vector and state covariance.

Definition at line 73 of file GFTools.cxx.

Referenced by getSmoothedCov(), getSmoothedData(), and getSmoothedPos().

73  {
74 
75  GFDetPlane pl;
76  TMatrixT<double> auxInfo;
77  return GFTools::getSmoothedData(trk, irep, ihit, smoothed_state, smoothed_cov, pl, auxInfo);
78 
79 }
Detector plane genfit geometry class.
Definition: GFDetPlane.h:59
bool getSmoothedData(GFTrack *trk, unsigned int irep, unsigned int ihit, TMatrixT< double > &smoothed_state, TMatrixT< double > &smoothed_cov)
Get smoothed state vector and state covariance.
Definition: GFTools.cxx:73
bool GFTools::getSmoothedData ( GFTrack trk,
unsigned int  irep,
unsigned int  ihit,
TMatrixT< double > &  smoothed_state,
TMatrixT< double > &  smoothed_cov,
GFDetPlane smoothing_plane 
)

Get smoothed state vector, state covariance and smoothing plane.

The smoothed data returned by this function includes the detector plane in which the data is calculated.

Definition at line 89 of file GFTools.cxx.

References getSmoothedData().

89  {
90 
91  TMatrixT<double> auxInfo;
92  return GFTools::getSmoothedData(trk, irep, ihit, smoothed_state, smoothed_cov, smoothing_plane, auxInfo);
93 
94 }
bool getSmoothedData(GFTrack *trk, unsigned int irep, unsigned int ihit, TMatrixT< double > &smoothed_state, TMatrixT< double > &smoothed_cov)
Get smoothed state vector and state covariance.
Definition: GFTools.cxx:73
bool GFTools::getSmoothedData ( GFTrack trk,
unsigned int  irep,
unsigned int  ihit,
TMatrixT< double > &  smoothed_state,
TMatrixT< double > &  smoothed_cov,
GFDetPlane smoothing_plane,
TMatrixT< double > &  auxInfo 
)

Get smoothed state vector, state covariance and smoothing plane.

The smoothed data returned by this function includes the detector plane in which the data is calculated as well as the auxillary information for this plane. The smoothed covariance matrix at hit i is:

\[ C_{k,\mbox{smooth}} = (C_{k,k-1,\rightarrow}^{-1}+C_{k,k+1,\leftarrow}^{-1})^{-1}. \\ \]

The smoothed state vector at hit i is:

\[ x_{k,\mbox{smooth}} = C_{k,\mbox{smooth}} \cdot ((C_{k,k-1,\rightarrow}^{-1}\cdot x_{k,k-1,\rightarrow} + C_{k,k+1,\leftarrow}^{-1}\cdot x_{k,k+1,\leftarrow}) \]

The index k,k-1 denotes that the state vector or covariance matrix contains the information of all hits 1,2,....,k-1 and is extrapolated to hit k. The arrow pointing to the right indicates that the information is saved during the forward fit. The index k,k+1 indicates the the state vector or covariance matrix contains the information of all hits N,N-1,...,k+1 and is extrapolated to hit k. The left-poiting arrow indicates that the information is saved during the backward fit.

Definition at line 103 of file GFTools.cxx.

References GFAbsTrackRep::clone(), GFAbsTrackRep::extrapolate(), GFTrack::getBK(), GFBookkeeping::getDetPlane(), GFBookkeeping::getMatrix(), GFTrack::getNumHits(), GFTrack::getSmoothing(), GFTrack::getTrackRep(), GFAbsTrackRep::hasAuxInfo(), invertMatrix(), and GFAbsTrackRep::setData().

103  {
104 
105  if(!trk->getSmoothing()) {
106  std::cout << "Trying to get smoothed hit coordinates from a track without smoothing! Aborting..." << std::endl;
107  TMatrixT<double> failed(1,1);
108  return false;
109  }
110 
111  if(ihit >= trk->getNumHits()) {
112  std::cout << "Hit number out of bounds while trying to get smoothed hit coordinates! Aborting..." <<std::endl;
113  TMatrixT<double> failed(1,1);
114  failed(0,0) = 0;
115  return false;
116  }
117 
118  TMatrixT<double> fUpSt;
119  TMatrixT<double> fUpCov;
120  TMatrixT<double> fAuxInfo;
121  TMatrixT<double>* fAuxInfoP;
122  TMatrixT<double> bUpSt;
123  TMatrixT<double> bUpCov;
124  TMatrixT<double> bAuxInfo;
125  TMatrixT<double>* bAuxInfoP;
126 
127  GFDetPlane fPl;
128  GFDetPlane bPl;
129 
130  GFAbsTrackRep* rep = trk->getTrackRep(irep)->clone();
131 
132  if(trk->getTrackRep(irep)->hasAuxInfo()) {
133  trk->getBK(irep)->getMatrix("fAuxInfo",ihit,auxInfo);
134  }
135 
136  if(ihit == 0) {
137  trk->getBK(irep)->getMatrix("bUpSt",ihit+1,bUpSt);
138  trk->getBK(irep)->getMatrix("bUpCov",ihit+1,bUpCov);
139  trk->getBK(irep)->getDetPlane("fPl",ihit,smoothing_plane);
140  trk->getBK(irep)->getDetPlane("bPl",ihit+1,bPl);
141  if(trk->getTrackRep(irep)->hasAuxInfo()) {
142  trk->getBK(irep)->getMatrix("bAuxInfo",ihit+1,bAuxInfo);
143  bAuxInfoP = &bAuxInfo;
144  } else {
145  bAuxInfoP = NULL;
146  }
147  if(bUpSt.GetNrows() == 0) return false;
148  rep->setData(bUpSt,bPl,&bUpCov,bAuxInfoP);
149  rep->extrapolate(smoothing_plane,smoothed_state,smoothed_cov);
150  return true;
151  }
152 
153  if(ihit == trk->getNumHits()-1) {
154  trk->getBK(irep)->getMatrix("fUpSt",ihit-1,fUpSt);
155  trk->getBK(irep)->getMatrix("fUpCov",ihit-1,fUpCov);
156  trk->getBK(irep)->getDetPlane("fPl",ihit-1,fPl);
157  trk->getBK(irep)->getDetPlane("fPl",ihit,smoothing_plane);
158  if(trk->getTrackRep(irep)->hasAuxInfo()) {
159  trk->getBK(irep)->getMatrix("fAuxInfo",ihit-1,fAuxInfo);
160  fAuxInfoP = &fAuxInfo;
161  } else {
162  fAuxInfoP = NULL;
163  }
164  if(fUpSt.GetNrows() == 0) return false;
165  rep->setData(fUpSt,fPl,&fUpCov,fAuxInfoP);
166  rep->extrapolate(smoothing_plane,smoothed_state,smoothed_cov);
167  return true;
168  }
169 
170  trk->getBK(irep)->getMatrix("fUpSt",ihit-1,fUpSt);
171  trk->getBK(irep)->getMatrix("fUpCov",ihit-1,fUpCov);
172  trk->getBK(irep)->getMatrix("bUpSt",ihit+1,bUpSt);
173  trk->getBK(irep)->getMatrix("bUpCov",ihit+1,bUpCov);
174  if(trk->getTrackRep(irep)->hasAuxInfo()) {
175  trk->getBK(irep)->getMatrix("fAuxInfo",ihit-1,fAuxInfo);
176  trk->getBK(irep)->getMatrix("bAuxInfo",ihit+1,bAuxInfo);
177  fAuxInfoP = &fAuxInfo;
178  bAuxInfoP = &bAuxInfo;
179  } else {
180  fAuxInfoP = bAuxInfoP = NULL;
181  }
182  trk->getBK(irep)->getDetPlane("fPl",ihit-1,fPl);
183  trk->getBK(irep)->getDetPlane("fPl",ihit,smoothing_plane);
184  trk->getBK(irep)->getDetPlane("bPl",ihit+1,bPl);
185 
186 
187  TMatrixT<double> fSt;
188  TMatrixT<double> fCov;
189  TMatrixT<double> bSt;
190  TMatrixT<double> bCov;
191 
192  if(fUpSt.GetNrows() == 0 || bUpSt.GetNrows() == 0) return false;
193 
194  rep->setData(fUpSt,fPl,&fUpCov,fAuxInfoP);
195  rep->extrapolate(smoothing_plane,fSt,fCov);
196  rep->setData(bUpSt,bPl,&bUpCov,bAuxInfoP);
197  rep->extrapolate(smoothing_plane,bSt,bCov);
198 
199  delete rep;
200 
201  TMatrixT<double> fCovInvert;
202  TMatrixT<double> bCovInvert;
203 
204  GFTools::invertMatrix(fCov, fCovInvert);
205  GFTools::invertMatrix(bCov, bCovInvert);
206 
207  GFTools::invertMatrix(fCovInvert + bCovInvert, smoothed_cov);
208 
209  smoothed_state.ResizeTo(smoothed_cov * (fCovInvert*fSt + bCovInvert*bSt));
210  smoothed_state = smoothed_cov * (fCovInvert*fSt + bCovInvert*bSt);
211 
212  return true;
213 
214 }
Base Class for genfit track representations. Defines interface for track parameterizations.
Definition: GFAbsTrackRep.h:80
GFBookkeeping * getBK(int index=-1)
get GFBookKeeping object for particular track rep (default is cardinal rep)
Definition: GFTrack.h:326
unsigned int getNumHits() const
Definition: GFTrack.h:148
Detector plane genfit geometry class.
Definition: GFDetPlane.h:59
bool getSmoothing()
Read back if smoothing is/was turned on or off for this track.
Definition: GFTrack.h:405
bool getDetPlane(std::string key, unsigned int index, GFDetPlane &pl)
void invertMatrix(const TMatrixT< double > &mat, TMatrixT< double > &inv)
Invert a matrix, throwing GFException when inversion fails.
Definition: GFTools.cxx:334
virtual bool hasAuxInfo()
See if the track representation has auxillary information stored.
virtual double extrapolate(const GFDetPlane &plane, TMatrixT< double > &statePred)
returns the tracklength spanned in this extrapolation
GFAbsTrackRep * getTrackRep(int id) const
Accessor for track representations.
Definition: GFTrack.h:186
bool getMatrix(std::string key, unsigned int index, TMatrixT< double > &mat)
virtual void setData(const TMatrixT< double > &st, const GFDetPlane &pl, const TMatrixT< double > *cov=NULL, const TMatrixT< double > *aux=NULL)
Puts the track representation in a given state.
virtual GFAbsTrackRep * clone() const =0
TMatrixT< double > GFTools::getSmoothedPos ( GFTrack trk,
unsigned int  irep,
unsigned int  ihit 
)

Get smoothed track position in plane coordinates.

Definition at line 4 of file GFTools.cxx.

References GFTrack::getHit(), GFAbsRecoHit::getHMatrix(), getSmoothedData(), GFTrack::getTrackRep(), and pos.

Referenced by GFDaf::calcWeights().

4  {
5 
6  TMatrixT<double> smoothed_state;
7  TMatrixT<double> smoothed_cov;
8  TMatrixT<double> pos;
9 
10  if(GFTools::getSmoothedData(trk, irep, ihit, smoothed_state, smoothed_cov)) {
11 
12  TMatrixT<double> H = trk->getHit(ihit)->getHMatrix(trk->getTrackRep(irep));
13  TMatrixT<double> pos_tmp(H * smoothed_state);
14  pos.ResizeTo(pos_tmp);
15  pos = pos_tmp;
16 
17  }
18  return pos;
19 
20 }
TVector3 pos
bool getSmoothedData(GFTrack *trk, unsigned int irep, unsigned int ihit, TMatrixT< double > &smoothed_state, TMatrixT< double > &smoothed_cov)
Get smoothed state vector and state covariance.
Definition: GFTools.cxx:73
virtual TMatrixT< double > getHMatrix(const GFAbsTrackRep *stateVector)=0
Get transformation matrix. Transformation between hit coordinates and track representation coordinate...
GFAbsTrackRep * getTrackRep(int id) const
Accessor for track representations.
Definition: GFTrack.h:186
GFAbsRecoHit * getHit(int id) const
Definition: GFTrack.h:144
GFDetPlane GFTools::getSmoothingPlane ( GFTrack trk,
unsigned int  irep,
unsigned int  ihit 
)

Get smoothing plane.

Definition at line 299 of file GFTools.cxx.

References GFTrack::getBK(), and GFBookkeeping::getDetPlane().

299  {
300 
301  GFDetPlane pl;
302  trk->getBK(irep)->getDetPlane("fPl",ihit,pl);
303  return pl;
304 
305 }
GFBookkeeping * getBK(int index=-1)
get GFBookKeeping object for particular track rep (default is cardinal rep)
Definition: GFTrack.h:326
Detector plane genfit geometry class.
Definition: GFDetPlane.h:59
bool getDetPlane(std::string key, unsigned int index, GFDetPlane &pl)
void GFTools::invertMatrix ( const TMatrixT< double > &  mat,
TMatrixT< double > &  inv 
)

Invert a matrix, throwing GFException when inversion fails.

Definition at line 334 of file GFTools.cxx.

References GFException::setFatal(), and status.

Referenced by GFKalman::calcGain(), GFDaf::calcWeights(), GFKalman::chi2Increment(), getBiasedSmoothedData(), GFDafHit::getHitCov(), getSmoothedChiSqu(), and getSmoothedData().

334  {
335  inv.ResizeTo(mat);
336  bool status = 0;
337  TDecompSVD invertAlgo(mat);
338 
339  // check if numerical limits are reached (i.e at least one entry < 1E-100 and/or at least one entry > 1E100)
340  if (!(mat<1.E100) || !(mat>-1.E100)){
341  GFException e("cannot invert matrix GFTools::invertMatrix(), entries too big (>1E100)",
342  __LINE__,__FILE__);
343  e.setFatal();
344  throw e;
345  }
346 
347  invertAlgo.SetTol(1E-50); //this is a hack because a tolerance of 1E-22 does not make any sense for doubles only for floats
348 
349  inv = invertAlgo.Invert(status);
350  if(status == 0){
351  GFException e("cannot invert matrix GFTools::invertMatrix(), status = 0",
352  __LINE__,__FILE__);
353  e.setFatal();
354  throw e;
355  }
356 }
Exception class for error handling in GENFIT (provides storage for diagnostic information) ...
Definition: GFException.h:45
int status[10]
Definition: f_Init.h:28