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