GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
TGRSIFit.cxx
Go to the documentation of this file.
1#include "TGRSIFit.h"
2
3#include "TROOT.h"
4
6
11
12TGRSIFit::TGRSIFit(const TGRSIFit& copy) : TF1(copy)
13{
14 copy.Copy(*this);
15}
16
21
22void TGRSIFit::Copy(TObject& obj) const
23{
24 static_cast<TGRSIFit&>(obj).fInitFlag = fInitFlag;
25 static_cast<TGRSIFit&>(obj).fGoodFitFlag = fGoodFitFlag;
26 TF1::Copy(obj);
27}
28
29void TGRSIFit::Print(Option_t* opt) const
30{
31 if(strchr(opt, '+') != nullptr) {
32 std::cout << "Params Init: " << (fInitFlag ? "true" : "false") << std::endl
33 << "Good Fit: " << (fGoodFitFlag ? "true" : "false") << std::endl;
34 TNamed::Print(opt);
35 }
36}
37
38void TGRSIFit::Clear(Option_t*)
39{
40 fInitFlag = false;
41 fGoodFitFlag = false;
42 fDefaultFitType.Clear();
43}
44
46{
47 for(int i = 0; i < GetNpar(); ++i) {
48 SetParameter(i, 0);
49 }
50}
51
52void TGRSIFit::CopyParameters(TF1* copy) const
53{
54 if(copy == nullptr) {
55 return;
56 }
57 for(int i = 0; i < GetNpar(); ++i) {
58 if(copy->GetNpar() > i) {
59 copy->SetParameter(i, GetParameter(i));
60 }
61 }
62}
63
64Bool_t TGRSIFit::AddToGlobalList(Bool_t yes)
65{
66 // Add to global list of functions (gROOT->GetListOfFunctions() )
67 // return previous status (true of functions was already in the list false if not)
68 if(!gROOT) {
69 return false;
70 }
71
72 if(yes) {
73 if(gROOT->GetListOfFunctions()->FindObject(this) != nullptr) {
74 return true;
75 }
76 gROOT->GetListOfFunctions()->Add(this);
77 // do I need to delete previous one with the same name ???
78 // TF1* old = static_cast<TF1*>( gROOT->GetListOfFunctions()->FindObject(GetName()) );
79 // if (old) gROOT->GetListOfFunctions()->Remove(old);
80 return false;
81 }
82 // if previous status was on and now is off
83 TF1* old = static_cast<TF1*>(gROOT->GetListOfFunctions()->FindObject(this));
84 if(old == nullptr) {
85 // Warning("AddToGlobalList","Function is supposed to be in the global list but it is not present");
86 return false;
87 }
88 gROOT->GetListOfFunctions()->Remove(this);
89 return true;
90}
91
92Bool_t TGRSIFit::AddToGlobalList(TF1* func, Bool_t yes)
93{
94 // Add to global list of functions (gROOT->GetListOfFunctions() )
95 // return previous status (true of functions was already in the list false if not)
96
97 if(!gROOT) {
98 return false;
99 }
100
101 if(yes) {
102 if(gROOT->GetListOfFunctions()->FindObject(func) != nullptr) {
103 return true;
104 }
105 gROOT->GetListOfFunctions()->Add(func);
106 // do I need to delete previous one with the same name ???
107 // TF1* old = static_cast<TF1*>( gROOT->GetListOfFunctions()->FindObject(GetName()) );
108 // if(old) gROOT->GetListOfFunctions()->Remove(old);
109 return false;
110 }
111 // if previous status was on and now is off
112 TF1* old = static_cast<TF1*>(gROOT->GetListOfFunctions()->FindObject(func));
113 if(old == nullptr) {
114 // func->Warning("AddToGlobalList","Function is supposed to be in the global list but it is not present");
115 return false;
116 }
117 gROOT->GetListOfFunctions()->Remove(func);
118 return true;
119
120 return true;
121}
virtual void ClearParameters(Option_t *opt="")
Definition TGRSIFit.cxx:45
Bool_t fInitFlag
Definition TGRSIFit.h:61
Bool_t AddToGlobalList(Bool_t yes=kTRUE) override
Definition TGRSIFit.cxx:64
void Clear(Option_t *opt="") override
Definition TGRSIFit.cxx:38
virtual void CopyParameters(TF1 *copy) const
Definition TGRSIFit.cxx:52
static TString fDefaultFitType
Definition TGRSIFit.h:64
Bool_t fGoodFitFlag
Definition TGRSIFit.h:62
void Copy(TObject &obj) const override
Definition TGRSIFit.cxx:22
void Print(Option_t *opt="") const override
Definition TGRSIFit.cxx:29