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