EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FitStatus.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file 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 
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  }
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 
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