FairRoot/PandaRoot
Public Member Functions | Private Member Functions | Private Attributes | List of all members
GFDaf Class Reference

Determinstic Annealing Filter (DAF) implementation. More...

#include <GFDaf.h>

Inheritance diagram for GFDaf:
GFKalman

Public Member Functions

 GFDaf ()
 
 ~GFDaf ()
 
void processTrack (GFTrack *trk)
 Process a track using the DAF. More...
 
const std::vector< std::vector
< std::vector< double > > > 
getWeights ()
 Return the weights present after the track was processed. More...
 
void setProbCut (double prob_cut)
 Set the probabilty cut for the weight calculation for the hits. More...
 
void setBetas (double b1, double b2, double b3=-1., double b4=-1., double b5=-1., double b6=-1., double b7=-1., double b8=-1., double b9=-1., double b10=-1.)
 Configure the annealing scheme. More...
 

Private Member Functions

std::vector< GFDafHit * > initHitsWeights (GFTrack *trk)
 Initialize the GFDafHit and their weights before the fit. More...
 
std::vector< std::vector
< double > > 
calcWeights (GFTrack *trk, double beta)
 Calculate the weights for the next fitting pass. More...
 
void copySmoothing (GFTrack *source, GFTrack *target, int target_ire)
 Copy the smoothing matrices from the source track to the target. More...
 
void operator() (GFTrack *track)
 Operator for use with STL. More...
 
void operator() (std::pair< int, GFTrack * > tr)
 Operator for use with STL. More...
 
void setLazy (Int_t)
 Switch lazy error handling. More...
 
void setNumIterations (Int_t i)
 Set number of iterations for Kalman Filter. More...
 
void fittingPass (GFTrack *, int dir)
 Performs fit on a GFTrack beginning with the current hit. More...
 
double getChi2Hit (GFAbsRecoHit *, GFAbsTrackRep *)
 Calculates chi2 of a given hit with respect to a given track representation. More...
 
void setInitialDirection (int d)
 Sets the inital direction of the track fit (1 for inner to outer, or -1 for outer to inner). The standard is 1 and is set in the ctor. More...
 
void setBlowUpFactor (double f)
 Set the blowup factor (see blowUpCovs() ) More...
 

Private Attributes

std::vector< std::vector
< std::vector< double > > > 
fWeights
 
std::vector< double > fBeta
 
std::map< int, double > fchi2Cuts
 

Detailed Description

Determinstic Annealing Filter (DAF) implementation.

Author
Christian Höppner (Technische Universität München, original author)
Karl Bicker (Technische Universität München)

The DAF is an iterative Kalman filter with annealing. It is capable of fitting tracks which are contaminated with noise hits. The algorithm is taken from the references R. Fruehwirth & A. Strandlie, Computer Physics Communications 120 (1999) 197-214 and CERN thesis: Dissertation by Matthias Winkler.

Definition at line 46 of file GFDaf.h.

Constructor & Destructor Documentation

GFDaf::GFDaf ( )

Definition at line 21 of file GFDaf.cxx.

References setBetas(), GFKalman::setNumIterations(), and setProbCut().

21  : GFKalman::GFKalman() {
22 
23  setBetas(81.,8.,4.,1.,1.,1.);
24  setProbCut(0.01);
25 
27 
28 };
void setProbCut(double prob_cut)
Set the probabilty cut for the weight calculation for the hits.
Definition: GFDaf.cxx:143
GFKalman()
Definition: GFKalman.cxx:36
void setBetas(double b1, double b2, double b3=-1., double b4=-1., double b5=-1., double b6=-1., double b7=-1., double b8=-1., double b9=-1., double b10=-1.)
Configure the annealing scheme.
Definition: GFDaf.cxx:174
void setNumIterations(Int_t i)
Set number of iterations for Kalman Filter.
Definition: GFKalman.h:86
GFDaf::~GFDaf ( )
inline

Definition at line 50 of file GFDaf.h.

50 { };

Member Function Documentation

std::vector< std::vector< double > > GFDaf::calcWeights ( GFTrack trk,
double  beta 
)
private

Calculate the weights for the next fitting pass.

Definition at line 80 of file GFDaf.cxx.

References exp(), fchi2Cuts, GFAbsRecoHit::getDetPlane(), GFDafHit::getHit(), GFTrack::getHit(), GFAbsRecoHit::getHitCoord(), GFAbsRecoHit::getHitCov(), GFDafHit::getNumHits(), GFTrack::getNumHits(), GFTools::getSmoothedPos(), GFTrack::getTrackRep(), i, GFException::info(), GFTools::invertMatrix(), m, phi, Pi, sqrt(), and GFException::what().

Referenced by processTrack().

80  {
81 
82  std::vector<std::vector<double> > ret_val;
83 
84  for(unsigned int i=0; i<trk->getNumHits(); i++) {
85 
86  GFDafHit* eff_hit = static_cast<GFDafHit*>(trk->getHit(i));
87  std::vector<double> phi;
88  double phi_sum = 0;
89  double phi_cut = 0;
90 
91  std::vector<double> weights;
92 
93  TMatrixT<double> x_smoo(GFTools::getSmoothedPos(trk, 0, i));
94  if(x_smoo.GetNrows() == 0) {
95  weights.assign(eff_hit->getNumHits(),0.5);
96  std::cout<<"Assumed weight 0.5!!"<<std::endl;
97  ret_val.push_back(weights);
98  continue;
99  }
100 
101  for(unsigned int j=0; j<eff_hit->getNumHits(); j++) {
102  GFAbsRecoHit* real_hit = eff_hit->getHit(j);
103  GFDetPlane pl;
104  try{
105  pl = real_hit->getDetPlane(trk->getTrackRep(0));
106  } catch(GFException& e) {
107  std::cerr<<e.what();
108  e.info();
109  }
110  TMatrixT<double> m(real_hit->getHitCoord(pl));
111  TMatrixT<double> V( beta * real_hit->getHitCov(pl));
112  TMatrixT<double> resid(m - x_smoo);
113  TMatrixT<double> resid_T(resid);
114  resid_T.T();
115  double detV = V.Determinant();
116  TMatrixT<double> Vinv;
117  GFTools::invertMatrix(V,Vinv);
118 
119  phi.push_back((1./(pow(2.*TMath::Pi(),V.GetNrows()/2.)*sqrt(detV)))*exp(-0.5*(resid_T * Vinv * resid)[0][0]));
120  phi_sum += phi.at(j);
121 
122  double cutVal = fchi2Cuts[V.GetNrows()];
123  assert(cutVal>1.E-6);
124  phi_cut += 1./(2.*TMath::Pi()*sqrt(detV))*exp(-0.5*cutVal/beta);
125 
126  }
127 
128  for(unsigned int j=0; j<eff_hit->getNumHits(); j++) {
129 
130 //std::cout<<"Calculated weight (beta = "<<beta<<", hit "<<i<<") "<<phi.at(j)<<"/("<<phi_sum<<"+"<<phi_cut<<") = "<<phi.at(j)/(phi_sum+phi_cut)<<std::endl;
131  weights.push_back(phi.at(j)/(phi_sum+phi_cut));
132 
133  }
134 
135  ret_val.push_back(weights);
136 
137  }
138 
139  return ret_val;
140 
141 };
unsigned int getNumHits()
Get the number of hits in the GFDafHit.
Definition: GFDafHit.h:121
unsigned int getNumHits() const
Definition: GFTrack.h:148
friend F32vec4 exp(const F32vec4 &a)
Definition: P4_F32vec4.h:109
Int_t i
Definition: run_full.C:25
__m128 m
Definition: P4_F32vec4.h:28
Detector plane genfit geometry class.
Definition: GFDetPlane.h:59
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
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 &quot;std::cerr &lt;&lt; e.what();&quot; ...
Definition: GFException.cxx:47
std::map< int, double > fchi2Cuts
Definition: GFDaf.h:101
GFAbsRecoHit * getHit(unsigned int ihit)
Get at hit from the GFDafHit.
Definition: GFDafHit.cxx:32
TMatrixT< double > getSmoothedPos(GFTrack *trk, unsigned int irep, unsigned int ihit)
Get smoothed track position in plane coordinates.
Definition: GFTools.cxx:4
Wrapper class for use with GFDaf.
Definition: GFDafHit.h:40
void invertMatrix(const TMatrixT< double > &mat, TMatrixT< double > &inv)
Invert a matrix, throwing GFException when inversion fails.
Definition: GFTools.cxx:334
virtual TMatrixT< double > getHitCov(const GFDetPlane &)=0
Get hit covariances in a specific detector plane.
void info()
print information in the exception object
Definition: GFException.cxx:52
Base Class for representing a Hit in GENFIT.
Definition: GFAbsRecoHit.h:73
GFAbsTrackRep * getTrackRep(int id) const
Accessor for track representations.
Definition: GFTrack.h:186
Exception class for error handling in GENFIT (provides storage for diagnostic information) ...
Definition: GFException.h:45
GFAbsRecoHit * getHit(int id) const
Definition: GFTrack.h:144
Double_t Pi
virtual TMatrixT< double > getHitCoord(const GFDetPlane &)=0
Get hit coordinates in a specific detector plane.
void GFDaf::copySmoothing ( GFTrack source,
GFTrack target,
int  target_ire 
)
private

Copy the smoothing matrices from the source track to the target.

Definition at line 238 of file GFDaf.cxx.

References GFBookkeeping::bookGFDetPlanes(), GFBookkeeping::bookMatrices(), GFTrack::getBK(), GFBookkeeping::getDetPlane(), GFTrack::getHit(), GFBookkeeping::getMatrix(), GFBookkeeping::getMatrixKeys(), GFDafHit::getNumHits(), GFTrack::getNumHits(), GFTrack::getNumReps(), GFTrack::getTrackRep(), GFAbsTrackRep::hasAuxInfo(), i, GFBookkeeping::setDetPlane(), GFBookkeeping::setMatrix(), and GFBookkeeping::setNhits().

Referenced by processTrack().

238  {
239 
240  for(unsigned int i=0; i<target->getNumReps(); i++) {
241 
242  std::vector<std::string> mat_keys = target->getBK(i)->getMatrixKeys();
243  bool already_there = false;
244  for(unsigned int j=0; j<mat_keys.size(); j++) {
245  if(mat_keys.at(j) == "fUpSt") already_there = true;
246  }
247  if(already_there) continue;
248 
249  target->getBK(i)->setNhits(target->getNumHits());
250  target->getBK(i)->bookMatrices("fUpSt");
251  target->getBK(i)->bookMatrices("fUpCov");
252  target->getBK(i)->bookMatrices("bUpSt");
253  target->getBK(i)->bookMatrices("bUpCov");
254  target->getBK(i)->bookGFDetPlanes("fPl");
255  target->getBK(i)->bookGFDetPlanes("bPl");
256  if(target->getTrackRep(i)->hasAuxInfo()) {
257  target->getBK(i)->bookMatrices("fAuxInfo");
258  target->getBK(i)->bookMatrices("bAuxInfo");
259  }
260  }
261 
262  int hit_count = 0;
263 
264  for(unsigned int pl_i=0; pl_i<source->getNumHits(); pl_i++) {
265 
266  GFDafHit* eff_hit = static_cast<GFDafHit*>(source->getHit(pl_i));
267 
268  for(unsigned int hit_i=0; hit_i<eff_hit->getNumHits(); hit_i++) {
269 
270  TMatrixT<double> fUpSt, fUpCov, bUpSt, bUpCov, fAuxInfo, bAuxInfo;
271  GFDetPlane fPl, bPl;
272 
273  source->getBK(0)->getMatrix("fUpSt",hit_i,fUpSt);
274  source->getBK(0)->getMatrix("fUpCov",hit_i,fUpCov);
275  source->getBK(0)->getDetPlane("fPl",hit_i,fPl);
276  source->getBK(0)->getMatrix("bUpSt",hit_i,bUpSt);
277  source->getBK(0)->getMatrix("bUpCov",hit_i,bUpCov);
278  source->getBK(0)->getDetPlane("bPl",hit_i,bPl);
279 
280  if(source->getTrackRep(0)->hasAuxInfo()) {
281  source->getBK(0)->getMatrix("fAuxInfo",hit_i,fAuxInfo);
282  source->getBK(0)->getMatrix("bAuxInfo",hit_i,bAuxInfo);
283  target->getBK(target_irep)->setMatrix("fAuxInfo",hit_count,fAuxInfo);
284  target->getBK(target_irep)->setMatrix("bAuxInfo",hit_count,bAuxInfo);
285  }
286 
287  target->getBK(target_irep)->setMatrix("fUpSt",hit_count,fUpSt);
288  target->getBK(target_irep)->setMatrix("fUpCov",hit_count,fUpCov);
289  target->getBK(target_irep)->setDetPlane("fPl",hit_count,fPl);
290  target->getBK(target_irep)->setMatrix("bUpSt",hit_count,bUpSt);
291  target->getBK(target_irep)->setMatrix("bUpCov",hit_count,bUpCov);
292  target->getBK(target_irep)->setDetPlane("bPl",hit_count,bPl);
293 
294  hit_count++;
295 
296  }
297 
298  }
299 
300 }
GFBookkeeping * getBK(int index=-1)
get GFBookKeeping object for particular track rep (default is cardinal rep)
Definition: GFTrack.h:326
unsigned int getNumHits()
Get the number of hits in the GFDafHit.
Definition: GFDafHit.h:121
unsigned int getNumHits() const
Definition: GFTrack.h:148
Int_t i
Definition: run_full.C:25
Detector plane genfit geometry class.
Definition: GFDetPlane.h:59
bool getDetPlane(std::string key, unsigned int index, GFDetPlane &pl)
void bookGFDetPlanes(std::string key)
unsigned int getNumReps() const
Get number of track represenatations.
Definition: GFTrack.h:192
Wrapper class for use with GFDaf.
Definition: GFDafHit.h:40
virtual bool hasAuxInfo()
See if the track representation has auxillary information stored.
void setDetPlane(std::string key, unsigned int index, const GFDetPlane &pl)
void setNhits(int n)
Definition: GFBookkeeping.h:50
std::vector< std::string > getMatrixKeys()
GFAbsTrackRep * getTrackRep(int id) const
Accessor for track representations.
Definition: GFTrack.h:186
void setMatrix(std::string key, unsigned int index, const TMatrixT< double > &mat)
void bookMatrices(std::string key)
bool getMatrix(std::string key, unsigned int index, TMatrixT< double > &mat)
GFAbsRecoHit * getHit(int id) const
Definition: GFTrack.h:144
void GFKalman::fittingPass ( GFTrack trk,
int  dir 
)
inherited

Performs fit on a GFTrack beginning with the current hit.

Definition at line 133 of file GFKalman.cxx.

References GFTrack::addFailedHit(), GFBookkeeping::clearFailedHits(), GFTrack::getBK(), GFTrack::getNextHitToFit(), GFTrack::getNumHits(), GFTrack::getNumReps(), GFAbsTrackRep::getStatusFlag(), GFTrack::getTrackRep(), GFException::info(), GFException::isFatal(), nhits, GFKalman::processHit(), GFAbsTrackRep::setChiSqu(), GFAbsTrackRep::setNDF(), GFTrack::setNextHitToFit(), GFAbsTrackRep::setStatusFlag(), and GFException::what().

Referenced by GFKalman::processTrack().

133  {
134  //loop over hits
135  unsigned int nhits=trk->getNumHits();
136  unsigned int starthit=trk->getNextHitToFit();
137 
138  int nreps=trk->getNumReps();
139  int ihit=(int)starthit;
140 
141  for(int irep=0; irep<nreps; ++irep) {
142  GFAbsTrackRep* arep=trk->getTrackRep(irep);
143  if(arep->getStatusFlag()==0) {
144  //clear chi2 sum and ndf sum in track reps
145  arep->setChiSqu(0.);
146  arep->setNDF(0);
147  //clear failedHits and outliers
148  trk->getBK(irep)->clearFailedHits();
149  }
150  }
151 
152  while((ihit<(int)nhits && direction==1) || (ihit>-1 && direction==-1)){
153  // GFAbsRecoHit* ahit=trk->getHit(ihit);
154  // loop over reps
155  for(int irep=0; irep<nreps; ++irep){
156  GFAbsTrackRep* arep=trk->getTrackRep(irep);
157  if(arep->getStatusFlag()==0) {
158  try {
159  processHit(trk,ihit,irep,direction);
160  }
161  catch(GFException& e) {
162  trk->addFailedHit(irep,ihit);
163  std::cerr << e.what();
164  e.info();
165  if(e.isFatal()) {
166  arep->setStatusFlag(1);
167  continue; // go to next rep immediately
168  }
169  }
170  }
171  }// end loop over reps
172  ihit+=direction;
173  }// end loop over hits
174  trk->setNextHitToFit(ihit-2*direction);
175  //trk->printGFBookkeeping();
176 }
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
void addFailedHit(unsigned int irep, unsigned int id)
Definition: GFTrack.h:284
unsigned int getNumHits() const
Definition: GFTrack.h:148
unsigned int getNextHitToFit() const
Accessor for fNextHitToFit.
Definition: GFTrack.h:178
virtual const char * what() const
standard error message handling for exceptions. use like &quot;std::cerr &lt;&lt; e.what();&quot; ...
Definition: GFException.cxx:47
unsigned int getNumReps() const
Get number of track represenatations.
Definition: GFTrack.h:192
bool getStatusFlag()
bool isFatal()
get fatal flag.
Definition: GFException.h:79
void info()
print information in the exception object
Definition: GFException.cxx:52
GFAbsTrackRep * getTrackRep(int id) const
Accessor for track representations.
Definition: GFTrack.h:186
void setNDF(unsigned int n)
void setChiSqu(double aChiSqu)
Exception class for error handling in GENFIT (provides storage for diagnostic information) ...
Definition: GFException.h:45
void processHit(GFTrack *, int, int, int)
One Kalman step.
Definition: GFKalman.cxx:240
void setStatusFlag(int _val)
void clearFailedHits()
void setNextHitToFit(unsigned int i)
Set next hit to be used in a fit.
Definition: GFTrack.h:182
double GFKalman::getChi2Hit ( GFAbsRecoHit hit,
GFAbsTrackRep rep 
)
inherited

Calculates chi2 of a given hit with respect to a given track representation.

Definition at line 215 of file GFKalman.cxx.

References GFKalman::chi2Increment(), GFAbsTrackRep::extrapolate(), GFAbsRecoHit::getDetPlane(), GFAbsTrackRep::getDim(), GFAbsRecoHit::getHitCov(), GFAbsRecoHit::getHMatrix(), r, and GFAbsRecoHit::residualVector().

216 {
217  // get prototypes for matrices
218  int repDim=rep->getDim();
219  TMatrixT<double> state(repDim,1);
220  TMatrixT<double> cov(repDim,repDim);;
221  GFDetPlane pl=hit->getDetPlane(rep);
222  rep->extrapolate(pl,state,cov);
223 
224 
225  TMatrixT<double> H = hit->getHMatrix(rep);
226  // get hit covariances
227  TMatrixT<double> V=hit->getHitCov(pl);
228 
229  TMatrixT<double> r=hit->residualVector(rep,state,pl);
230  assert(r.GetNrows()>0);
231 
232  //this is where chi2 is calculated
233  double chi2 = chi2Increment(r,H,cov,V);
234 
235  return chi2/r.GetNrows();
236 }
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
Definition: GFKalman.cxx:178
virtual TMatrixT< double > residualVector(const GFAbsTrackRep *stateVector, const TMatrixT< double > &state, const GFDetPlane &d)
Calculate residual with respect to a track representation.
Definition: GFAbsRecoHit.h:142
double r
Definition: RiemannTest.C:14
Detector plane genfit geometry class.
Definition: GFDetPlane.h:59
virtual const GFDetPlane & getDetPlane(GFAbsTrackRep *)=0
Get detector plane for a given track representation.
unsigned int getDim() const
returns dimension of state vector
virtual TMatrixT< double > getHMatrix(const GFAbsTrackRep *stateVector)=0
Get transformation matrix. Transformation between hit coordinates and track representation coordinate...
virtual TMatrixT< double > getHitCov(const GFDetPlane &)=0
Get hit covariances in a specific detector plane.
virtual double extrapolate(const GFDetPlane &plane, TMatrixT< double > &statePred)
returns the tracklength spanned in this extrapolation
const std::vector<std::vector<std::vector<double> > > GFDaf::getWeights ( )
inline

Return the weights present after the track was processed.

The DAF uses special effective hits defined in the class GFDafHit. A GFDafHit is a wrappe class and contains all the real hits from one plane. The structure of the return vector of getWeights allows to reconstruct in what way the hits were grouped: the outermost vector represents the track representation, there is one entry per track representation. The middle vector represents the effective hits, and the innermost vector contains the real hits contained in the corresponding effective hit.

Definition at line 66 of file GFDaf.h.

References fWeights.

66 { return fWeights; };
std::vector< std::vector< std::vector< double > > > fWeights
Definition: GFDaf.h:99
std::vector< GFDafHit * > GFDaf::initHitsWeights ( GFTrack trk)
private

Initialize the GFDafHit and their weights before the fit.

Definition at line 203 of file GFDaf.cxx.

References fWeights, GFTrack::getHit(), GFTrack::getHitsByPlane(), GFTrack::getNumReps(), hits, and i.

Referenced by processTrack().

203  {
204 
205  std::vector< std::vector<int>* > planes;
206  trk->getHitsByPlane(planes);
207  int nPlanes = planes.size();
208 
209  std::vector<GFDafHit*> eff_hits;
210 
211  for(int i=0; i<nPlanes; i++) {
212 
213  std::vector<GFAbsRecoHit*> hits;
214 
215  for(unsigned int j=0; j<planes.at(i)->size(); j++) {
216  hits.push_back(trk->getHit(planes.at(i)->at(j)) );
217  }
218 
219  GFDafHit* eff_hit = new GFDafHit(hits);
220  eff_hits.push_back(eff_hit);
221 
222  }
223 
224  for(unsigned int i=0; i<trk->getNumReps(); i++) {
225  std::vector<std::vector<double> > rep_weights;
226  for(unsigned int j=0; j<eff_hits.size(); j++) {
227  std::vector<double> single_weights;
228  single_weights.assign(eff_hits.at(j)->getNumHits(),1.);
229  rep_weights.push_back(single_weights);
230  }
231  fWeights.push_back(rep_weights);
232  }
233 
234  return eff_hits;
235 
236 }
Int_t i
Definition: run_full.C:25
void getHitsByPlane(std::vector< std::vector< int > * > &retVal)
Definition: GFTrack.cxx:227
unsigned int getNumReps() const
Get number of track represenatations.
Definition: GFTrack.h:192
Wrapper class for use with GFDaf.
Definition: GFDafHit.h:40
std::vector< std::vector< std::vector< double > > > fWeights
Definition: GFDaf.h:99
GFAbsRecoHit * getHit(int id) const
Definition: GFTrack.h:144
CbmHit * hits[nHits]
Definition: RiemannTest.C:19
void GFKalman::operator() ( GFTrack track)
inlineinherited

Operator for use with STL.

This operator allows to use the std::foreach algorithm with an STL container o GFTrack* objects.

Definition at line 65 of file GFKalman.h.

References GFKalman::processTrack().

65 {processTrack(track);}
void processTrack(GFTrack *trk)
Performs fit on a GFTrack.
Definition: GFKalman.cxx:40
void GFKalman::operator() ( std::pair< int, GFTrack * >  tr)
inlineinherited

Operator for use with STL.

This operator allows to use the std::foreach algorithm with an STL container o GFTrack* objects.

Definition at line 72 of file GFKalman.h.

References GFKalman::processTrack().

72 {processTrack(tr.second);}
void processTrack(GFTrack *trk)
Performs fit on a GFTrack.
Definition: GFKalman.cxx:40
void GFDaf::processTrack ( GFTrack trk)

Process a track using the DAF.

Definition at line 30 of file GFDaf.cxx.

References GFTrack::addHit(), GFTrack::addTrackRep(), calcWeights(), copySmoothing(), fBeta, fWeights, GFTrack::getHit(), GFTrack::getNumHits(), GFTrack::getNumReps(), GFTrack::getSmoothing(), GFAbsTrackRep::getStatusFlag(), GFTrack::getTrackRep(), hit, i, GFException::info(), initHitsWeights(), GFKalman::processTrack(), GFTrack::releaseTrackReps(), GFDafHit::setBlowUp(), GFTrack::setSmoothing(), GFAbsTrackRep::setStatusFlag(), GFDafHit::setWeights(), and GFException::what().

Referenced by PndRecoDafFit::Fit().

30  {
31 
32  std::vector<GFDafHit*> eff_hits = initHitsWeights(trk);
33 
34  GFTrack* mini_trk = new GFTrack();
35 
36  for(unsigned int j=0; j<eff_hits.size(); j++) mini_trk->addHit(eff_hits.at(j));
37 
38  mini_trk->setSmoothing();
39 
40  for(unsigned int i=0; i<trk->getNumReps(); i++) {
41 
42  if(trk->getTrackRep(i)->getStatusFlag()!=0) continue;
43 
44  mini_trk->addTrackRep(trk->getTrackRep(i));
45 
46  for(unsigned int iBeta=0; iBeta<fBeta.size(); iBeta++) {
47 
48  for(unsigned int j=0; j<mini_trk->getNumHits(); j++) {
49  GFDafHit* hit = static_cast<GFDafHit*>(mini_trk->getHit(j));
50  hit->setWeights(fWeights.at(i).at(j));
51  hit->setBlowUp(fBeta.at(iBeta));
52  }
53 
54  GFKalman::processTrack(mini_trk);
55 
56  if(mini_trk->getTrackRep(0)->getStatusFlag() != 0) break;
57 
58  if(iBeta != fBeta.size()-1 )
59  try{
60  fWeights.at(i) = calcWeights(mini_trk, fBeta.at(iBeta));
61  } catch(GFException& e) {
62  std::cerr<<e.what();
63  e.info();
64  mini_trk->getTrackRep(0)->setStatusFlag(1);
65  break;
66  }
67 
68  }
69 
70  if(trk->getSmoothing()) copySmoothing(mini_trk, trk, i);
71 
72  mini_trk->releaseTrackReps();
73 
74  }
75 
76  delete mini_trk;
77 
78 };
std::vector< GFDafHit * > initHitsWeights(GFTrack *trk)
Initialize the GFDafHit and their weights before the fit.
Definition: GFDaf.cxx:203
unsigned int getNumHits() const
Definition: GFTrack.h:148
Int_t i
Definition: run_full.C:25
void addHit(GFAbsRecoHit *theHit)
deprecated!
Definition: GFTrack.h:291
Track object for genfit. genfit algorithms work on these objects.
Definition: GFTrack.h:60
bool getSmoothing()
Read back if smoothing is/was turned on or off for this track.
Definition: GFTrack.h:405
void setSmoothing(bool smooth=true)
Switch smoothing on or off for this track.
Definition: GFTrack.h:401
virtual const char * what() const
standard error message handling for exceptions. use like &quot;std::cerr &lt;&lt; e.what();&quot; ...
Definition: GFException.cxx:47
void setWeights(std::vector< double > weights)
Set the weights.
Definition: GFDafHit.cxx:46
std::vector< std::vector< double > > calcWeights(GFTrack *trk, double beta)
Calculate the weights for the next fitting pass.
Definition: GFDaf.cxx:80
unsigned int getNumReps() const
Get number of track represenatations.
Definition: GFTrack.h:192
Wrapper class for use with GFDaf.
Definition: GFDafHit.h:40
void setBlowUp(double blow_up)
Set the blow up factor for the covariance matrices.
Definition: GFDafHit.cxx:38
bool getStatusFlag()
std::vector< std::vector< std::vector< double > > > fWeights
Definition: GFDaf.h:99
void copySmoothing(GFTrack *source, GFTrack *target, int target_ire)
Copy the smoothing matrices from the source track to the target.
Definition: GFDaf.cxx:238
void processTrack(GFTrack *trk)
Performs fit on a GFTrack.
Definition: GFKalman.cxx:40
void info()
print information in the exception object
Definition: GFException.cxx:52
GFAbsTrackRep * getTrackRep(int id) const
Accessor for track representations.
Definition: GFTrack.h:186
void releaseTrackReps()
Clear TrackRep vector. Note that the Reps will not be deleted!
Definition: GFTrack.h:174
void addTrackRep(GFAbsTrackRep *theTrackRep)
Add track represenation.
Definition: GFTrack.h:318
Exception class for error handling in GENFIT (provides storage for diagnostic information) ...
Definition: GFException.h:45
GFAbsRecoHit * getHit(int id) const
Definition: GFTrack.h:144
std::vector< double > fBeta
Definition: GFDaf.h:100
void setStatusFlag(int _val)
PndSdsMCPoint * hit
Definition: anasim.C:70
void GFDaf::setBetas ( double  b1,
double  b2,
double  b3 = -1.,
double  b4 = -1.,
double  b5 = -1.,
double  b6 = -1.,
double  b7 = -1.,
double  b8 = -1.,
double  b9 = -1.,
double  b10 = -1. 
)

Configure the annealing scheme.

In the current implementation you need to provide at least two temperatures. The maximum would ten tempertatures.

Definition at line 174 of file GFDaf.cxx.

References fBeta.

Referenced by GFDaf().

174  {
175  assert(b1>0);fBeta.push_back(b1);
176  assert(b2>0 && b2<=b1);fBeta.push_back(b2);
177  if(b3>=0.) {
178  assert(b3<=b2);fBeta.push_back(b3);
179  if(b4>=0.) {
180  assert(b4<=b3);fBeta.push_back(b4);
181  if(b5>=0.) {
182  assert(b5<=b4);fBeta.push_back(b5);
183  if(b6>=0.) {
184  assert(b6<=b5);fBeta.push_back(b6);
185  if(b7>=0.) {
186  assert(b7<=b6);fBeta.push_back(b7);
187  if(b8>=0.) {
188  assert(b8<=b7);fBeta.push_back(b8);
189  if(b9>=0.) {
190  assert(b9<=b8);fBeta.push_back(b9);
191  if(b10>=0.) {
192  assert(b10<=b9);fBeta.push_back(b10);
193  }
194  }
195  }
196  }
197  }
198  }
199  }
200  }
201 }
std::vector< double > fBeta
Definition: GFDaf.h:100
void GFKalman::setBlowUpFactor ( double  f)
inlineinherited

Set the blowup factor (see blowUpCovs() )

Definition at line 111 of file GFKalman.h.

References f, and GFKalman::fBlowUpFactor.

111 {fBlowUpFactor=f;}
double fBlowUpFactor
Definition: GFKalman.h:147
TFile * f
Definition: bump_analys.C:12
void GFKalman::setInitialDirection ( int  d)
inlineinherited

Sets the inital direction of the track fit (1 for inner to outer, or -1 for outer to inner). The standard is 1 and is set in the ctor.

Definition at line 107 of file GFKalman.h.

References d, and GFKalman::fInitialDirection.

int fInitialDirection
Definition: GFKalman.h:145
TObjArray * d
void GFKalman::setLazy ( Int_t  )
inlineinherited

Switch lazy error handling.

This is a historically left-over method and shall be deleted some time

Definition at line 80 of file GFKalman.h.

80 {std::cerr<<"Using outdates setLazy method of class GFKalman:"<<std::endl;}
void GFKalman::setNumIterations ( Int_t  i)
inlineinherited

Set number of iterations for Kalman Filter.

One iteration is one forward pass plus one backward pass

Definition at line 86 of file GFKalman.h.

References GFKalman::fNumIt, and i.

Referenced by PndHypDKalmanTask::Exec(), PndLmdKalmanTask::Exec(), GFDaf(), and PndRecoKalmanFit::Init().

86 {fNumIt=i;}
Int_t i
Definition: run_full.C:25
Int_t fNumIt
Definition: GFKalman.h:146
void GFDaf::setProbCut ( double  prob_cut)

Set the probabilty cut for the weight calculation for the hits.

Currently supported are the values 0.01 0.005, and 0.001. The corresponding chi2 cuts for different hits dimensionalities are hardcoded in the implementation because I did not yet figure out how to calculate them. Please feel very welcome to change the implementtion if you know how to do it.

Definition at line 143 of file GFDaf.cxx.

References fabs(), fchi2Cuts, and GFException::setFatal().

Referenced by GFDaf().

143  {
144 
145  if(fabs(val-0.01)<1.E-10){
146  fchi2Cuts[1] = 6.63;
147  fchi2Cuts[2] = 9.21;
148  fchi2Cuts[3] = 11.34;
149  fchi2Cuts[4] = 13.23;
150  fchi2Cuts[5] = 15.09;
151  }
152  else if(fabs(val-0.005)<1.E-10){
153  fchi2Cuts[1] = 7.88;
154  fchi2Cuts[2] = 10.60;
155  fchi2Cuts[3] = 12.84;
156  fchi2Cuts[4] = 14.86;
157  fchi2Cuts[5] = 16.75;
158  }
159  else if(fabs(val-0.001)<1.E-10){
160  fchi2Cuts[1] = 10.83;
161  fchi2Cuts[2] = 13.82;
162  fchi2Cuts[3] = 16.27;
163  fchi2Cuts[4] = 18.47;
164  fchi2Cuts[5] = 20.51;
165  }
166  else{
167  GFException exc("GFDafsetProbCut() value is not supported",__LINE__,__FILE__);
168  exc.setFatal();
169  throw exc;
170  }
171 
172 }
Double_t val[nBoxes][nFEBox]
Definition: createCalib.C:11
std::map< int, double > fchi2Cuts
Definition: GFDaf.h:101
friend F32vec4 fabs(const F32vec4 &a)
Definition: P4_F32vec4.h:47
Exception class for error handling in GENFIT (provides storage for diagnostic information) ...
Definition: GFException.h:45

Member Data Documentation

std::vector<double> GFDaf::fBeta
private

Definition at line 100 of file GFDaf.h.

Referenced by processTrack(), and setBetas().

std::map<int,double> GFDaf::fchi2Cuts
private

Definition at line 101 of file GFDaf.h.

Referenced by calcWeights(), and setProbCut().

std::vector<std::vector<std::vector<double> > > GFDaf::fWeights
private

Definition at line 99 of file GFDaf.h.

Referenced by getWeights(), initHitsWeights(), and processTrack().


The documentation for this class was generated from the following files: