GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
TGRSIFit.h
Go to the documentation of this file.
1#ifndef TGRSIFIT_H
2#define TGRSIFIT_H
3
4/** \addtogroup Fitting Fitting & Analysis
5 * @{
6 */
7#include <utility>
8
9#include "TGRSIFunctions.h"
10#include "TObject.h"
11#include "TH1.h"
12#include "TF1.h"
13#include "TList.h"
14#include "TFitResult.h"
15#include "TFitResultPtr.h"
16#include "TRandom.h"
17#include "TSpectrum.h"
18#include "TVirtualFitter.h"
19#include "TMath.h"
20#include "TNamed.h"
21#include "TROOT.h"
22#include "TRef.h"
23#include "TString.h"
24#include "Globals.h"
25
26class TGRSIFit : public TF1 {
27public:
28 ~TGRSIFit();
29
30protected:
31 TGRSIFit();
32 TGRSIFit(const char* name, const char* formula, Double_t xmin = 0, Double_t xmax = 1) : TF1(name, formula, xmin, xmax) { Clear(); }
33 TGRSIFit(const char* name, Double_t xmin, Double_t xmax, Int_t npar) : TF1(name, xmin, xmax, npar) { Clear(); }
34 TGRSIFit(const char* name, const ROOT::Math::ParamFunctor& func, Double_t xmin = 0, Double_t xmax = 1, Int_t npar = 0) : TF1(name, func, xmin, xmax, npar) { Clear(); }
35 template <class PtrObj, typename MemFn>
36 TGRSIFit(const char* name, const PtrObj& pointer, MemFn memFn, Double_t xmin, Double_t xmax, Int_t npar, const char* class_name, const char* fcn_name)
37 : TF1(name, pointer, memFn, xmin, xmax, npar, class_name, fcn_name)
38 {
39 Clear();
40 }
41
42 TGRSIFit(const TGRSIFit& copy);
43
44 TGRSIFit(TGRSIFit&&) noexcept = default;
45 TGRSIFit& operator=(const TGRSIFit&) = default;
46 TGRSIFit& operator=(TGRSIFit&&) noexcept = default;
47
48public:
49 void Copy(TObject& obj) const override;
50 // Every fit object should have to initialize parameters and have a fit method defined.
51 virtual Bool_t InitParams(TH1*) = 0;
52 Bool_t IsGoodFit() const { return fGoodFitFlag; }
53 virtual void SetHist(TH1* hist)
54 {
55 fHist = hist;
56 } // fHistogram is a member of TF1. I'm not sure this does anything proper right now
57 virtual TH1* GetHist() const { return dynamic_cast<TH1*>(fHist.GetObject()); }
58 static const char* GetDefaultFitType() { return fDefaultFitType.Data(); }
59 static void SetDefaultFitType(const char* fitType) { fDefaultFitType = fitType; }
60
61 // These are only to be called in the Dtor of classes to protect from ROOT's insane garbage collection system
62 // They can be called anywhere though as long as new classes are carefully destructed.
63 Bool_t AddToGlobalList(Bool_t yes = kTRUE) override;
64 static Bool_t AddToGlobalList(TF1* func, Bool_t yes = kTRUE);
65
66protected:
67 Bool_t IsInitialized() const { return fInitFlag; }
68 void SetInitialized(Bool_t flag = true) { fInitFlag = flag; }
69 void GoodFit(Bool_t flag = true) { fGoodFitFlag = flag; }
70
71private:
72 Bool_t fInitFlag{false};
73 Bool_t fGoodFitFlag{false}; // This doesn't do anything yet
74 TRef fHist;
75 static TString fDefaultFitType;
76
77public:
78 void Print(Option_t* opt = "") const override;
79 void Clear(Option_t* opt = "") override;
80 virtual void ClearParameters(Option_t* opt = "");
81 virtual void CopyParameters(TF1* copy) const;
82
83 /// \cond CLASSIMP
84 ClassDefOverride(TGRSIFit, 0) // NOLINT(readability-else-after-return)
85 /// \endcond
86};
87/*! @} */
88#endif
TH1D * hist
Definition UserFillObj.h:3
TGRSIFit(TGRSIFit &&) noexcept=default
virtual void ClearParameters(Option_t *opt="")
Definition TGRSIFit.cxx:43
TGRSIFit(const char *name, const ROOT::Math::ParamFunctor &func, Double_t xmin=0, Double_t xmax=1, Int_t npar=0)
Definition TGRSIFit.h:34
Bool_t fInitFlag
Definition TGRSIFit.h:72
TGRSIFit(const char *name, const PtrObj &pointer, MemFn memFn, Double_t xmin, Double_t xmax, Int_t npar, const char *class_name, const char *fcn_name)
Definition TGRSIFit.h:36
Bool_t AddToGlobalList(Bool_t yes=kTRUE) override
Definition TGRSIFit.cxx:62
virtual void SetHist(TH1 *hist)
Definition TGRSIFit.h:53
void Clear(Option_t *opt="") override
Definition TGRSIFit.cxx:36
Bool_t IsGoodFit() const
Definition TGRSIFit.h:52
static const char * GetDefaultFitType()
Definition TGRSIFit.h:58
virtual void CopyParameters(TF1 *copy) const
Definition TGRSIFit.cxx:50
static TString fDefaultFitType
Definition TGRSIFit.h:75
Bool_t IsInitialized() const
Definition TGRSIFit.h:67
Bool_t fGoodFitFlag
Definition TGRSIFit.h:73
void GoodFit(Bool_t flag=true)
Definition TGRSIFit.h:69
void SetInitialized(Bool_t flag=true)
Definition TGRSIFit.h:68
virtual Bool_t InitParams(TH1 *)=0
TGRSIFit(const char *name, const char *formula, Double_t xmin=0, Double_t xmax=1)
Definition TGRSIFit.h:32
TRef fHist
Definition TGRSIFit.h:74
TGRSIFit(const char *name, Double_t xmin, Double_t xmax, Int_t npar)
Definition TGRSIFit.h:33
void Copy(TObject &obj) const override
Definition TGRSIFit.cxx:20
virtual TH1 * GetHist() const
Definition TGRSIFit.h:57
static void SetDefaultFitType(const char *fitType)
Definition TGRSIFit.h:59
void Print(Option_t *opt="") const override
Definition TGRSIFit.cxx:27