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 namespace genfit {
30 
45 struct PruneFlags {
46  PruneFlags();
47  void reset();
49  void setFlags(Option_t *option = "");
51  bool hasFlags(Option_t *option = "CFLWRMIU") const;
53  bool isPruned() const;
54 
55  void Print(const Option_t * = "") const;
56 
57  private:
58  enum fields { C = 1 << 0, F = 1 << 1, L = 1 << 2, W = 1 << 3, R = 1 << 4, M = 1 << 5, I = 1 << 6, U = 1 << 7 };
59 
60  int value; // bitfield composed from above. ROOT cannot deal with
61  // bitfield notation, so this is done manually.
62 
63  // No ClassDef here. Update FitStatus version number when changing this.
64 };
65 
70 class FitStatus {
71 
72  public:
74  : isFitted_(false), isFitConvergedFully_(false), isFitConvergedPartially_(false), nFailedPoints_(0), trackHasChanged_(false), pruneFlags_(), charge_(0), chi2_(-1e99),
75  ndf_(-1e99)
76  {
77  ;
78  }
79 
80  virtual ~FitStatus(){};
81 
82  virtual FitStatus *clone() const { return new FitStatus(*this); }
83 
85  bool isFitted() const { return isFitted_; }
87 
96  bool isFitConverged(bool inAllPoints = true) const
97  {
98  if (inAllPoints)
99  return isFitConvergedFully_;
100  return isFitConvergedPartially_;
101  }
102  bool isFitConvergedFully() const { return isFitConvergedFully_; }
103  bool isFitConvergedPartially() const { return isFitConvergedPartially_; }
104  int getNFailedPoints() const { return nFailedPoints_; }
106  bool hasTrackChanged() const { return trackHasChanged_; }
108  bool isTrackPruned() const { return pruneFlags_.isPruned(); }
110  double getCharge() const { return charge_; }
112  double getChi2() const { return chi2_; }
114  double getNdf() const { return ndf_; }
120  virtual double getPVal() const { return std::max(0., ROOT::Math::chisquared_cdf_c(chi2_, ndf_)); }
121 
122  void setIsFitted(bool fitted = true) { isFitted_ = fitted; }
123  void setIsFitConvergedFully(bool fitConverged = true) { isFitConvergedFully_ = fitConverged; }
124  void setIsFitConvergedPartially(bool fitConverged = true) { isFitConvergedPartially_ = fitConverged; }
125  void setNFailedPoints(int nFailedPoints) { nFailedPoints_ = nFailedPoints; }
126  void setHasTrackChanged(bool trackChanged = true) { trackHasChanged_ = trackChanged; }
127  void setCharge(double charge) { charge_ = charge; }
128 
129  PruneFlags &getPruneFlags() { return pruneFlags_; }
130 
131  void setChi2(const double &chi2) { chi2_ = chi2; }
132  void setNdf(const double &ndf) { ndf_ = ndf; }
133 
134  virtual void Print(const Option_t * = "") const;
135 
136  protected:
138  bool isFitted_;
150  double charge_;
151 
154  double chi2_;
155  double ndf_;
156 
157  ClassDef(FitStatus, 3);
158 };
159 
160 } /* End of namespace genfit */
163 #endif // genfit_FitStatus_h
virtual ~FitStatus()
Definition: FitStatus.h:80
void setChi2(const double &chi2)
Definition: FitStatus.h:131
int nFailedPoints_
Number of failed TrackPoints.
Definition: FitStatus.h:144
bool isPruned() const
check if any of the flags is set
bool hasFlags(Option_t *option="CFLWRMIU") const
check if all the given flags are set
void setIsFitConvergedFully(bool fitConverged=true)
Definition: FitStatus.h:123
bool isTrackPruned() const
Has the track been pruned after the fit?
Definition: FitStatus.h:108
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:140
Class where important numbers and properties of a fit can be stored.
Definition: FitStatus.h:70
Info which information has been pruned from the Track.
Definition: FitStatus.h:45
PruneFlags pruneFlags_
Prune flags.
Definition: FitStatus.h:148
bool trackHasChanged_
has anything in the Track been changed since the fit? -> fit isn&#39;t valid anymore
Definition: FitStatus.h:146
bool hasTrackChanged() const
Has anything in the Track been changed since the fit?
Definition: FitStatus.h:106
int getNFailedPoints() const
Definition: FitStatus.h:104
void setIsFitConvergedPartially(bool fitConverged=true)
Definition: FitStatus.h:124
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:25
void setIsFitted(bool fitted=true)
Definition: FitStatus.h:122
double getCharge() const
Get the fitted charge.
Definition: FitStatus.h:110
void setNFailedPoints(int nFailedPoints)
Definition: FitStatus.h:125
PruneFlags & getPruneFlags()
Definition: FitStatus.h:129
bool isFitConverged(bool inAllPoints=true) const
Did the fit converge (in all Points or only partially)?
Definition: FitStatus.h:96
virtual FitStatus * clone() const
Definition: FitStatus.h:82
bool isFitted_
has the track been fitted?
Definition: FitStatus.h:138
bool isFitted() const
Has the track been fitted?
Definition: FitStatus.h:85
void Print(const Option_t *="") const
bool isFitConvergedPartially() const
Definition: FitStatus.h:103
virtual double getPVal() const
Get the p value of the fit.
Definition: FitStatus.h:120
bool isFitConvergedFully() const
Definition: FitStatus.h:102
void setHasTrackChanged(bool trackChanged=true)
Definition: FitStatus.h:126
double getNdf() const
Get the degrees of freedom of the fit.
Definition: FitStatus.h:114
bool isFitConvergedPartially_
did the fit converge with a subset of all TrackPoints?
Definition: FitStatus.h:142
void setCharge(double charge)
Definition: FitStatus.h:127
void setNdf(const double &ndf)
Definition: FitStatus.h:132
double getChi2() const
Get chi^2 of the fit.
Definition: FitStatus.h:112
double charge_
fitted charge
Definition: FitStatus.h:150
Matrix inversion tools.
Definition: AbsBField.h:28