Belle II Software  release-08-01-10
FitStatus.h
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 
84  FitStatus() :
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)
107  return isFitConvergedFully_;
109  }
110  bool isFitConvergedFully() const {return isFitConvergedFully_;}
111  bool isFitConvergedPartially() const {return isFitConvergedPartially_;}
112  int getNFailedPoints() const {return nFailedPoints_;}
114  bool hasTrackChanged() const {return trackHasChanged_;}
116  bool isTrackPruned() const {return pruneFlags_.isPruned();}
118  double getCharge() const {return charge_;}
120  double getChi2() const {return chi2_;}
122  double getNdf() const {return ndf_;}
128  virtual double getPVal() const {return std::max(0.,ROOT::Math::chisquared_cdf_c(chi2_, ndf_));}
129 
130  void setIsFitted(bool fitted = true) {isFitted_ = fitted;}
131  void setIsFitConvergedFully(bool fitConverged = true) {isFitConvergedFully_ = fitConverged;}
132  void setIsFitConvergedPartially(bool fitConverged = true) {isFitConvergedPartially_ = fitConverged;}
133  void setNFailedPoints(int nFailedPoints) {nFailedPoints_ = nFailedPoints;}
134  void setHasTrackChanged(bool trackChanged = true) {trackHasChanged_ = trackChanged;}
135  void setCharge(double charge) {charge_ = charge;}
136 
137  PruneFlags& getPruneFlags() {return pruneFlags_;}
138 
139  void setChi2(const double& chi2) {chi2_ = chi2;}
140  void setNdf(const double& ndf) {ndf_ = ndf;}
141 
142  virtual void Print(const Option_t* = "") const;
143 
144  protected:
145 
147  bool isFitted_;
159  double charge_;
160 
163  double chi2_;
164  double ndf_;
165 
166  ClassDef(FitStatus, 3);
167 };
168 
169 } /* End of namespace genfit */
172 #endif // genfit_FitStatus_h
double R
typedef autogenerated by FFTW
Class where important numbers and properties of a fit can be stored.
Definition: FitStatus.h:80
PruneFlags pruneFlags_
Prune flags.
Definition: FitStatus.h:157
bool trackHasChanged_
has anything in the Track been changed since the fit? -> fit isn't valid anymore
Definition: FitStatus.h:155
bool isFitConverged(bool inAllPoints=true) const
Did the fit converge (in all Points or only partially)?
Definition: FitStatus.h:105
bool isFitConvergedPartially_
did the fit converge with a subset of all TrackPoints?
Definition: FitStatus.h:151
virtual double getPVal() const
Get the p value of the fit.
Definition: FitStatus.h:128
bool isFitted_
has the track been fitted?
Definition: FitStatus.h:147
double getChi2() const
Get chi^2 of the fit.
Definition: FitStatus.h:120
double charge_
fitted charge
Definition: FitStatus.h:159
double getCharge() const
Get the fitted charge.
Definition: FitStatus.h:118
bool isFitted() const
Has the track been fitted?
Definition: FitStatus.h:94
double chi2_
These are provided for the sake of the fitter, and their interpretation may vary.
Definition: FitStatus.h:163
bool isTrackPruned() const
Has the track been pruned after the fit?
Definition: FitStatus.h:116
bool hasTrackChanged() const
Has anything in the Track been changed since the fit?
Definition: FitStatus.h:114
bool isFitConvergedFully_
did the fit converge with all TrackPoints?
Definition: FitStatus.h:149
int nFailedPoints_
Number of failed TrackPoints.
Definition: FitStatus.h:153
double getNdf() const
Get the degrees of freedom of the fit.
Definition: FitStatus.h:122
double charge(int pdgCode)
Returns electric charge of a particle with given pdg code.
Definition: EvtPDLUtil.cc:44
Defines for I/O streams used for error and debug printing.
Info which information has been pruned from the Track.
Definition: FitStatus.h:47
bool isPruned() const
check if any of the flags is set
Definition: FitStatus.cc:68
void setFlags(Option_t *option="")
does not reset! If a flag is already true and is not in opt, it will stay true.
Definition: FitStatus.cc:38
bool hasFlags(Option_t *option="CFLWRMIU") const
check if all the given flags are set
Definition: FitStatus.cc:53