33 #define COVEXC "cov_is_zero"
46 for(
int i=0;
i<nreps;
i++) {
49 bool already_there =
false;
50 for(
unsigned int j=0; j<mat_keys.size(); j++) {
51 if(mat_keys.at(j) ==
"fUpSt") already_there =
true;
53 if(already_there)
continue;
70 assert(direction==1 || direction==-1);
77 for(
int ipass=0; ipass<2*
fNumIt; ipass++){
90 for(
int i=0;
i<nreps; ++
i){
101 for(
int i=0;
i<nreps; ++
i){
112 if(direction==1) direction=-1;
123 for(
int i=0;
i<nreps; ++
i){
139 int ihit=(int)starthit;
141 for(
int irep=0; irep<nreps; ++irep) {
152 while((ihit<(
int)nhits && direction==1) || (ihit>-1 && direction==-1)){
155 for(
int irep=0; irep<nreps; ++irep){
163 std::cerr << e.
what();
179 const TMatrixT<double>& cov,
const TMatrixT<double>& V){
182 TMatrixT<double>
R(V);
183 TMatrixT<double> covsum1(cov,TMatrixT<double>::kMultTranspose,H);
184 TMatrixT<double> covsum(H,TMatrixT<double>::kMult,covsum1);
189 TMatrixT<double> Rinv;
193 TMatrixT<double> residTranspose(r);
195 TMatrixT<double> chisq=residTranspose*(Rinv*
r);
196 assert(chisq.GetNoElements()==1);
198 if(TMath::IsNaN(chisq[0][0])){
201 std::vector< TMatrixT<double> > matrices;
202 matrices.push_back(r);
203 matrices.push_back(V);
204 matrices.push_back(R);
205 matrices.push_back(cov);
219 TMatrixT<double> state(repDim,1);
220 TMatrixT<double> cov(repDim,repDim);;
230 assert(r.GetNrows()>0);
235 return chi2/r.GetNrows();
245 int repDim = rep->
getDim();
246 TMatrixT<double> state(repDim,1);
247 TMatrixT<double> cov(repDim,repDim);;
269 if(cov[0][0]<1.E-50){
279 TMatrixT<double> Gain(
calcGain(cov,V,H));
304 int ndf = r.GetNrows();
328 const TMatrixT<double>& HitCov,
329 const TMatrixT<double>& H){
332 TMatrixT<double> covsum1(cov,TMatrixT<double>::kMultTranspose,H);
333 TMatrixT<double> covsum(H,TMatrixT<double>::kMult,covsum1);
338 TMatrixT<double> covsumInv;
342 TMatrixT<double> gain1(H,TMatrixT<double>::kTransposeMult,covsumInv);
343 TMatrixT<double> gain(cov,TMatrixT<double>::kMult,gain1);
double chi2Increment(const TMatrixT< double > &r, const TMatrixT< double > &H, const TMatrixT< double > &cov, const TMatrixT< double > &V)
this returns the reduced chi2 increment for a hit
Base Class for genfit track representations. Defines interface for track parameterizations.
GFBookkeeping * getBK(int index=-1)
get GFBookKeeping object for particular track rep (default is cardinal rep)
const GFDetPlane & getReferencePlane() const
void addFailedHit(unsigned int irep, unsigned int id)
void addNDF(unsigned int n)
unsigned int getNumHits() const
virtual TMatrixT< double > residualVector(const GFAbsTrackRep *stateVector, const TMatrixT< double > &state, const GFDetPlane &d)
Calculate residual with respect to a track representation.
TMatrixT< double > calcGain(const TMatrixT< double > &cov, const TMatrixT< double > &HitCov, const TMatrixT< double > &H)
Calculate Kalman Gain.
TMatrixT< double > getState() const
unsigned int getNextHitToFit() const
Accessor for fNextHitToFit.
Detector plane genfit geometry class.
Track object for genfit. genfit algorithms work on these objects.
bool getSmoothing()
Read back if smoothing is/was turned on or off for this track.
virtual const GFDetPlane & getDetPlane(GFAbsTrackRep *)=0
Get detector plane for a given track representation.
virtual const char * what() const
standard error message handling for exceptions. use like "std::cerr << e.what();" ...
void fittingPass(GFTrack *, int dir)
Performs fit on a GFTrack beginning with the current hit.
void bookGFDetPlanes(std::string key)
unsigned int getNumReps() const
Get number of track represenatations.
unsigned int getDim() const
returns dimension of state vector
virtual const TMatrixT< double > * getAuxInfo(const GFDetPlane &)
Get auxillary information from the track representation.
virtual bool hasAuxInfo()
See if the track representation has auxillary information stored.
virtual TMatrixT< double > getHMatrix(const GFAbsTrackRep *stateVector)=0
Get transformation matrix. Transformation between hit coordinates and track representation coordinate...
void blowUpCovs(double blowUpFactor)
this is needed to blow up the covariance matrix before a fitting pass drops off-diagonal elements and...
void setRepAtHit(unsigned int irep, int ihit)
set the hit index at which plane,state&cov of rep irep is defined
void setDetPlane(std::string key, unsigned int index, const GFDetPlane &pl)
void clearRepAtHit()
clear the hit indices at which plane,state&cov of reps are defined
bool isFatal()
get fatal flag.
std::vector< std::string > getMatrixKeys()
void addChiSqu(double aChiSqu)
virtual TMatrixT< double > getHitCov(const GFDetPlane &)=0
Get hit covariances in a specific detector plane.
int getRepAtHit(unsigned int irep)
get the hit index at which plane,state&cov of rep irep is defined
void setMatrices(std::string, const std::vector< TMatrixT< double > > &)
set list of matrices with description
void processTrack(GFTrack *trk)
Performs fit on a GFTrack.
virtual double extrapolate(const GFDetPlane &plane, TMatrixT< double > &statePred)
returns the tracklength spanned in this extrapolation
void info()
print information in the exception object
Base Class for representing a Hit in GENFIT.
GFAbsTrackRep * getTrackRep(int id) const
Accessor for track representations.
void setNDF(unsigned int n)
void setMatrix(std::string key, unsigned int index, const TMatrixT< double > &mat)
void bookMatrices(std::string key)
void setChiSqu(double aChiSqu)
void blowUpCovs(GFTrack *trk)
this is needed to blow up the covariance matrix before a fitting pass drops off-diagonal elements and...
Exception class for error handling in GENFIT (provides storage for diagnostic information) ...
GFAbsRecoHit * getHit(int id) const
void processHit(GFTrack *, int, int, int)
One Kalman step.
void setStatusFlag(int _val)
double getChi2Hit(GFAbsRecoHit *, GFAbsTrackRep *)
Calculates chi2 of a given hit with respect to a given track representation.
void setFatal(bool b=true)
set fatal flag. if this is true, the fit stops for this current track repr.
void switchDirection(GFTrack *trk)
Used to switch between forward and backward filtering.
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 void switchDirection()=0
void setNextHitToFit(unsigned int i)
Set next hit to be used in a fit.
TMatrixT< double > getCov() const