FairRoot/PandaRoot
FitStatus.h
Go to the documentation of this file.
1 /* Copyright 2008-2010, Technische Universitaet Muenchen,
2  Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch & Tobias Schlüter
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 */
23 #ifndef genfit_FitStatus_h
24 #define genfit_FitStatus_h
25 
26 #include <Rtypes.h>
27 #include <Math/ProbFuncMathCore.h>
28 
29 
30 namespace genfit {
31 
32 
47 struct PruneFlags {
48  PruneFlags();
49  void reset();
51  void setFlags(Option_t* option = "");
53  bool hasFlags(Option_t* option = "CFLWRMIU") const;
55  bool isPruned() const;
56 
57  void Print(const Option_t* = "") const;
58 
59 private:
60  enum fields { C = 1 << 0,
61  F = 1 << 1,
62  L = 1 << 2,
63  W = 1 << 3,
64  R = 1 << 4,
65  M = 1 << 5,
66  I = 1 << 6,
67  U = 1 << 7 };
68 
69  int value; // bitfield composed from above. ROOT cannot deal with
70  // bitfield notation, so this is done manually.
71 
72  // No ClassDef here. Update FitStatus version number when changing this.
73 };
74 
75 
80 class FitStatus {
81 
82  public:
83 
86  trackHasChanged_(false), pruneFlags_(), charge_(0), chi2_(-1e99), ndf_(-1e99)
87  {;}
88 
89  virtual ~FitStatus() {};
90 
91  virtual FitStatus* clone() const {return new FitStatus(*this);}
92 
94  bool isFitted() const {return isFitted_;}
96 
105  bool isFitConverged(bool inAllPoints = true) const {
106  if (inAllPoints) return isFitConvergedFully_; return isFitConvergedPartially_;
107  }
110  int getNFailedPoints() const {return nFailedPoints_;}
112  bool hasTrackChanged() const {return trackHasChanged_;}
114  bool isTrackPruned() const {return pruneFlags_.isPruned();}
116  double getCharge() const {return charge_;}
118  double getChi2() const {return chi2_;}
120  double getNdf() const {return ndf_;}
126  virtual double getPVal() const {return std::max(0.,ROOT::Math::chisquared_cdf_c(chi2_, ndf_));}
127 
128  void setIsFitted(bool fitted = true) {isFitted_ = fitted;}
129  void setIsFitConvergedFully(bool fitConverged = true) {isFitConvergedFully_ = fitConverged;}
130  void setIsFitConvergedPartially(bool fitConverged = true) {isFitConvergedPartially_ = fitConverged;}
131  void setNFailedPoints(int nFailedPoints) {nFailedPoints_ = nFailedPoints;}
132  void setHasTrackChanged(bool trackChanged = true) {trackHasChanged_ = trackChanged;}
133  void setCharge(double charge) {charge_ = charge;}
134 
136 
137  void setChi2(const double& chi2) {chi2_ = chi2;}
138  void setNdf(const double& ndf) {ndf_ = ndf;}
139 
140  virtual void Print(const Option_t* = "") const;
141 
142  protected:
143 
145  bool isFitted_;
157  double charge_;
158 
161  double chi2_;
162  double ndf_;
163 
164  ClassDef(FitStatus, 3);
165 };
166 
167 } /* End of namespace genfit */
170 #endif // genfit_FitStatus_h
virtual ~FitStatus()
Definition: FitStatus.h:89
void setChi2(const double &chi2)
Definition: FitStatus.h:137
int nFailedPoints_
Number of failed TrackPoints.
Definition: FitStatus.h:151
void Print(const Option_t *="") const
bool isFitConvergedPartially() const
Definition: FitStatus.h:109
void setIsFitConvergedFully(bool fitConverged=true)
Definition: FitStatus.h:129
void setFlags(Option_t *option="")
does not reset! If a flag is already true and is not in opt, it will stay true.
bool isFitConvergedFully_
did the fit converge with all TrackPoints?
Definition: FitStatus.h:147
Class where important numbers and properties of a fit can be stored.
Definition: FitStatus.h:80
Info which information has been pruned from the Track.
Definition: FitStatus.h:47
double getChi2() const
Get chi^2 of the fit.
Definition: FitStatus.h:118
PruneFlags pruneFlags_
Prune flags.
Definition: FitStatus.h:155
bool trackHasChanged_
has anything in the Track been changed since the fit? -&gt; fit isn&#39;t valid anymore
Definition: FitStatus.h:153
ClassDef(FitStatus, 3)
void setIsFitConvergedPartially(bool fitConverged=true)
Definition: FitStatus.h:130
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:26
void setIsFitted(bool fitted=true)
Definition: FitStatus.h:128
bool hasTrackChanged() const
Has anything in the Track been changed since the fit?
Definition: FitStatus.h:112
virtual void Print(const Option_t *="") const
double getNdf() const
Get the degrees of freedom of the fit.
Definition: FitStatus.h:120
void setNFailedPoints(int nFailedPoints)
Definition: FitStatus.h:131
PruneFlags & getPruneFlags()
Definition: FitStatus.h:135
bool isFitConverged(bool inAllPoints=true) const
Did the fit converge (in all Points or only partially)?
Definition: FitStatus.h:105
bool isFitConvergedFully() const
Definition: FitStatus.h:108
virtual double getPVal() const
Get the p value of the fit.
Definition: FitStatus.h:126
bool isFitted_
has the track been fitted?
Definition: FitStatus.h:145
virtual FitStatus * clone() const
Definition: FitStatus.h:91
int getNFailedPoints() const
Definition: FitStatus.h:110
bool isPruned() const
check if any of the flags is set
bool isTrackPruned() const
Has the track been pruned after the fit?
Definition: FitStatus.h:114
void setHasTrackChanged(bool trackChanged=true)
Definition: FitStatus.h:132
bool hasFlags(Option_t *option="CFLWRMIU") const
check if all the given flags are set
bool isFitConvergedPartially_
did the fit converge with a subset of all TrackPoints?
Definition: FitStatus.h:149
void setCharge(double charge)
Definition: FitStatus.h:133
void setNdf(const double &ndf)
Definition: FitStatus.h:138
double charge_
fitted charge
Definition: FitStatus.h:157
double getCharge() const
Get the fitted charge.
Definition: FitStatus.h:116
bool isFitted() const
Has the track been fitted?
Definition: FitStatus.h:94