PandaRoot
FitStatus.h
Go to the documentation of this file.
1 //****************************************************************************
2 //* This file is part of PandaRoot. *
3 //* *
4 //* PandaRoot is distributed under the terms of the *
5 //* GNU General Public License (GPL) version 3, *
6 //* copied verbatim in the file "LICENSE". *
7 //* *
8 //* Copyright (C) 2006 - 2024 FAIR GmbH and copyright holders of PandaRoot *
9 //* The copyright holders are listed in the file "COPYRIGHTHOLDERS". *
10 //* The authors are listed in the file "AUTHORS". *
11 //****************************************************************************
12 
13 /* Copyright 2008-2010, Technische Universitaet Muenchen,
14  Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch & Tobias Schlüter
15 
16  This file is part of GENFIT.
17 
18  GENFIT is free software: you can redistribute it and/or modify
19  it under the terms of the GNU Lesser General Public License as published
20  by the Free Software Foundation, either version 3 of the License, or
21  (at your option) any later version.
22 
23  GENFIT is distributed in the hope that it will be useful,
24  but WITHOUT ANY WARRANTY; without even the implied warranty of
25  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26  GNU Lesser General Public License for more details.
27 
28  You should have received a copy of the GNU Lesser General Public License
29  along with GENFIT. If not, see <http://www.gnu.org/licenses/>.
30 */
35 #ifndef genfit_FitStatus_h
36 #define genfit_FitStatus_h
37 
38 #include <Rtypes.h>
39 #include <Math/ProbFuncMathCore.h>
40 
41 namespace genfit {
42 
57 struct PruneFlags {
58  PruneFlags();
59  void reset();
61  void setFlags(Option_t *option = "");
63  bool hasFlags(Option_t *option = "CFLWRMIU") const;
65  bool isPruned() const;
66 
67  void Print(const Option_t * = "") const;
68 
69  private:
70  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 };
71 
72  int value; // bitfield composed from above. ROOT cannot deal with
73  // bitfield notation, so this is done manually.
74 
75  // No ClassDef here. Update FitStatus version number when changing this.
76 };
77 
82 class FitStatus {
83 
84  public:
86  : isFitted_(false), isFitConvergedFully_(false), isFitConvergedPartially_(false), nFailedPoints_(0), trackHasChanged_(false), pruneFlags_(), charge_(0), chi2_(-1e99),
87  ndf_(-1e99)
88  {
89  ;
90  }
91 
92  virtual ~FitStatus(){};
93 
94  virtual FitStatus *clone() const { return new FitStatus(*this); }
95 
97  bool isFitted() const { return isFitted_; }
99 
108  bool isFitConverged(bool inAllPoints = true) const
109  {
110  if (inAllPoints)
111  return isFitConvergedFully_;
112  return isFitConvergedPartially_;
113  }
114  bool isFitConvergedFully() const { return isFitConvergedFully_; }
115  bool isFitConvergedPartially() const { return isFitConvergedPartially_; }
116  int getNFailedPoints() const { return nFailedPoints_; }
118  bool hasTrackChanged() const { return trackHasChanged_; }
120  bool isTrackPruned() const { return pruneFlags_.isPruned(); }
122  double getCharge() const { return charge_; }
124  double getChi2() const { return chi2_; }
126  double getNdf() const { return ndf_; }
132  virtual double getPVal() const { return std::max(0., ROOT::Math::chisquared_cdf_c(chi2_, ndf_)); }
133 
134  void setIsFitted(bool fitted = true) { isFitted_ = fitted; }
135  void setIsFitConvergedFully(bool fitConverged = true) { isFitConvergedFully_ = fitConverged; }
136  void setIsFitConvergedPartially(bool fitConverged = true) { isFitConvergedPartially_ = fitConverged; }
137  void setNFailedPoints(int nFailedPoints) { nFailedPoints_ = nFailedPoints; }
138  void setHasTrackChanged(bool trackChanged = true) { trackHasChanged_ = trackChanged; }
139  void setCharge(double charge) { charge_ = charge; }
140 
141  PruneFlags &getPruneFlags() { return pruneFlags_; }
142 
143  void setChi2(const double &chi2) { chi2_ = chi2; }
144  void setNdf(const double &ndf) { ndf_ = ndf; }
145 
146  virtual void Print(const Option_t * = "") const;
147 
148  protected:
150  bool isFitted_;
162  double charge_;
163 
166  double chi2_;
167  double ndf_;
168 
169  ClassDef(FitStatus, 3);
170 };
171 
172 } /* End of namespace genfit */
175 #endif // genfit_FitStatus_h
virtual ~FitStatus()
Definition: FitStatus.h:92
void setChi2(const double &chi2)
Definition: FitStatus.h:143
int nFailedPoints_
Number of failed TrackPoints.
Definition: FitStatus.h:156
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:135
bool isTrackPruned() const
Has the track been pruned after the fit?
Definition: FitStatus.h:120
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:152
Class where important numbers and properties of a fit can be stored.
Definition: FitStatus.h:82
Info which information has been pruned from the Track.
Definition: FitStatus.h:57
PruneFlags pruneFlags_
Prune flags.
Definition: FitStatus.h:160
bool trackHasChanged_
has anything in the Track been changed since the fit? -> fit isn&#39;t valid anymore
Definition: FitStatus.h:158
bool hasTrackChanged() const
Has anything in the Track been changed since the fit?
Definition: FitStatus.h:118
int getNFailedPoints() const
Definition: FitStatus.h:116
void setIsFitConvergedPartially(bool fitConverged=true)
Definition: FitStatus.h:136
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:37
void setIsFitted(bool fitted=true)
Definition: FitStatus.h:134
double getCharge() const
Get the fitted charge.
Definition: FitStatus.h:122
void setNFailedPoints(int nFailedPoints)
Definition: FitStatus.h:137
PruneFlags & getPruneFlags()
Definition: FitStatus.h:141
bool isFitConverged(bool inAllPoints=true) const
Did the fit converge (in all Points or only partially)?
Definition: FitStatus.h:108
virtual FitStatus * clone() const
Definition: FitStatus.h:94
bool isFitted_
has the track been fitted?
Definition: FitStatus.h:150
bool isFitted() const
Has the track been fitted?
Definition: FitStatus.h:97
void Print(const Option_t *="") const
bool isFitConvergedPartially() const
Definition: FitStatus.h:115
virtual double getPVal() const
Get the p value of the fit.
Definition: FitStatus.h:132
bool isFitConvergedFully() const
Definition: FitStatus.h:114
void setHasTrackChanged(bool trackChanged=true)
Definition: FitStatus.h:138
double getNdf() const
Get the degrees of freedom of the fit.
Definition: FitStatus.h:126
bool isFitConvergedPartially_
did the fit converge with a subset of all TrackPoints?
Definition: FitStatus.h:154
void setCharge(double charge)
Definition: FitStatus.h:139
void setNdf(const double &ndf)
Definition: FitStatus.h:144
double getChi2() const
Get chi^2 of the fit.
Definition: FitStatus.h:124
double charge_
fitted charge
Definition: FitStatus.h:162
Matrix inversion tools.
Definition: AbsBField.h:40