Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
CorrFit3DCFPainter.cxx
1/*
2 * CorrFit3DCFPainter.cxx
3 *
4 * Created on: 24 lip 2024
5 * Author: daniel
6 */
7
8#include "CorrFit3DCFPainter.h"
9
10#include <RtypesCore.h>
11#include <TString.h>
12#include <TVirtualPad.h>
13#include <vector>
14
15#include "CorrFit.h"
16#include "CorrFit3DCF.h"
17#include "CorrFitFunc.h"
18#include "CorrFitFunc3D.h"
19#include "Cout.h"
20#include "Femto3DCF.h"
21#include "Femto3DCFPainter.h"
22#include "Painter.h"
23
24
25namespace Hal {
26
27 void CorrFit3DCFPainter::UpdateParameters() {
28 auto func = (CorrFit3DCF*) fFittedFunc;
29 for (int i = 0; i < fFittedFunc->GetParametersNo(); i++) {
30 func->fTempParamsEval[i] = func->GetParameter(i);
31 }
32 func->ParametersChanged();
33 for (auto vec : fFunctions) {
34 for (auto fx : vec) {
35 if (fx) func->CopyParamsToTF1(fx, kTRUE, kTRUE);
36 }
37 }
38 }
39
40 TF1* CorrFit3DCFPainter::GetDrawableFunc(TString opt) {
41 if (!fFittedFunc) return nullptr;
42 return ((CorrFit3DCF*) fFittedFunc)->GetDrawableFunc(opt);
43 }
44
45 void CorrFit3DCFPainter::MakeFunctions() {
46 auto addSingle = [&](TString opt) {
47 std::vector<TF1*> vec;
48 if (opt == "") {
49 vec.push_back(nullptr);
50 return vec;
51 }
52 auto th = GetDrawableFunc(opt);
53 vec.push_back(th);
54 return vec;
55 };
56 switch (fDrawOpt) {
57 case 1: {
58 fFunctions.push_back(addSingle("x"));
59 fFunctions.push_back(addSingle("y"));
60 fFunctions.push_back(addSingle("z"));
61 fFunctions.push_back(addSingle(""));
62 } break;
63 case 2: {
64 fFunctions.push_back(addSingle("x"));
65 fFunctions.push_back(addSingle("y"));
66 fFunctions.push_back(addSingle("z"));
67
68 fFunctions.push_back(addSingle("xy++"));
69 fFunctions.push_back(addSingle("xz++"));
70 fFunctions.push_back(addSingle("yz++"));
71
72 fFunctions.push_back(addSingle("xyz+++"));
73 // fFunctions.push_back(addSingle("xz+-"));
74 // fFunctions.push_back(addSingle("yz+-"));
75
76 } break;
77 case 3: {
78 fFunctions.push_back(addSingle("x"));
79 fFunctions.push_back(addSingle("y"));
80 fFunctions.push_back(addSingle("z"));
81 fFunctions.push_back(addSingle(""));
82
83 fFunctions.push_back(addSingle("xy++"));
84 fFunctions.push_back(addSingle("xy+-"));
85 fFunctions.push_back(addSingle("yz++"));
86 fFunctions.push_back(addSingle(""));
87
88 fFunctions.push_back(addSingle("yz+-"));
89 fFunctions.push_back(addSingle("xz++"));
90 fFunctions.push_back(addSingle("xz+-"));
91 fFunctions.push_back(addSingle(""));
92
93 fFunctions.push_back(addSingle("xyz+++"));
94 fFunctions.push_back(addSingle("xyz+-+"));
95 fFunctions.push_back(addSingle("xyz+--"));
96 fFunctions.push_back(addSingle("xyz++-"));
97 } break;
98 case 4: {
99 fFunctions.push_back(addSingle("xy"));
100 fFunctions.push_back(addSingle("xz"));
101 fFunctions.push_back(addSingle("yz"));
102 } break;
103 case 5: {
104 fFunctions.push_back(addSingle("xy"));
105 fFunctions.push_back(addSingle("xz"));
106 fFunctions.push_back(addSingle("yz"));
107 } break;
108 }
109 }
110
111 CorrFit3DCFPainter::CorrFit3DCFPainter(CorrFit3DCF* fit, Femto3DCF* cf) : CorrFitPainter(fit), fCF(cf) {
112 fCFPainter = (Femto3DCFPainter*) fCF->GetPainter();
113 if (fCFPainter) fCFPainter->AddPainter(this);
114 fLegendPos[0] = 0.05;
115 fLegendPos[1] = 0.05;
116 fLegendPos[2] = 0.95;
117 fLegendPos[3] = 0.95;
118 }
119
120 CorrFit3DCFPainter::~CorrFit3DCFPainter() {}
121
122 void CorrFit3DCFPainter::InnerPaint() {
123 fCFPainter = (Femto3DCFPainter*) fCF->GetPainter();
124 TString opt = fCFPainter->GetOptionForCorrFit();
125 if (opt.EqualTo("")) {
126 Hal::Cout::PrintInfo(Form("%s %i not supported options for drawing histogram, corrfit cannot adapt", __FILE__, __LINE__),
127 EInfo::kCriticalError);
128 }
129 if (opt.EqualTo("fit1")) fDrawOpt = 1;
130 if (opt.EqualTo("fit2")) fDrawOpt = 2;
131 if (opt.EqualTo("fit3")) fDrawOpt = 3;
132 if (opt.EqualTo("fit4")) fDrawOpt = 4;
133 if (opt.EqualTo("fit5")) fDrawOpt = 5;
134 switch (fDrawOpt) {
135 case 1: {
136 fLegendPad = GetPad(4);
137 fDefFuncDrawOpt = "SAME";
138 } break;
139 case 2: {
140 fLegendPad = GetPad(9);
141 fDefFuncDrawOpt = "SAME";
142 } break;
143 case 3: {
144 fLegendPad = GetPad(4);
145 fDefFuncDrawOpt = "SAME";
146 } break;
147 case 4: {
148 fLegendPad = GetPad(4);
149 fDefFuncDrawOpt = "SAME";
150 } break;
151 case 5: {
152 fLegendPad = GetPad(4);
153 fDefFuncDrawOpt = "surf+same";
154 } break;
155 }
156 CorrFitPainter::InnerPaint();
157 }
158
159 void CorrFit3DCFPainter::DrawFunctions() {
160 if (fDrawOpt != 5) {
161 CorrFitPainter::DrawFunctions();
162 return;
163 }
164 LockPad();
165 int count = 1;
166 auto painter3d = (Femto3DCFPainter*) fCF->GetPainter();
167 std::pair<Double_t, Double_t> range;
168 if (painter3d) { range = painter3d->GetMinMax(); }
169 for (auto padfunc : fFunctions) {
170 GotoPad(count++);
171 for (auto func : padfunc) {
172 if (func) {
173 func->SetMinimum(range.first);
174 func->SetMaximum(range.second);
175 func->Draw(fDefFuncDrawOpt);
176 }
177 }
178 }
179 UnlockPad();
180 }
181
182} /* namespace Hal */
Int_t GetParametersNo() const
Definition CorrFit.h:269
static void PrintInfo(TString text, Hal::EInfo status)
Definition Cout.cxx:370