Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
FemtoCFPainter.cxx
1/*
2 * FemtoFuncPainter.cxx
3 *
4 * Created on: 22 lip 2024
5 * Author: daniel
6 */
7
8#include "FemtoCFPainter.h"
9
10#include "Std.h"
11
12#include <iostream>
13
14#include <TCanvas.h>
15#include <TH1.h>
16
17namespace Hal {
18 const int FemtoCFPainter::kNumBit = 8;
19 const int FemtoCFPainter::kDenBit = 9;
20 const int FemtoCFPainter::kCFBit = 10;
21 const int FemtoCFPainter::kHideTitles = 11;
22
23 void FemtoCFPainter::DeleteHistograms() {
24 for (auto& x : fHistograms) {
25 for (auto y : x)
26 if (y) delete y;
27 }
28 fHistograms.clear();
29 }
30
31
32 void FemtoCFPainter::ScaleHistograms() {
33 for (auto& x : fHistograms) {
34 for (auto y : x)
35 if (y) y->Scale(fScale);
36 }
37 fDrawScale = fScale * fDrawScale;
38 }
39
40 void FemtoCFPainter::Rescale(Double_t newScale) {
41 if (newScale == 0) return;
42 fScale = newScale / fDrawScale;
43 }
44
45 void FemtoCFPainter::DrawHistograms() {
46 LockPad();
47 int count = 0;
48 for (auto i : fHistograms) {
49 GotoPad(++count);
50 for (auto j : i) {
51 if (j) {
52 if (CheckOpt(kHideTitles)) j->SetTitle("");
53 j->SetStats(0);
54 j->Draw(fDefDrawFlag);
55 }
56 }
57 }
58 UnlockPad();
59 }
60
61 FemtoCFPainter::~FemtoCFPainter() { DeleteHistograms(); }
62
64 LockPad();
65 DeleteHistograms();
66 MakeHistograms();
67 ScaleHistograms();
68 DrawHistograms();
71 UnlockPad();
72 }
73
75 LockPad();
76 if (fOptionsChanged) {
77 DeleteHistograms();
78 MakeHistograms();
79 ScaleHistograms();
80 } else if (fScale != 1)
81 ScaleHistograms();
84 UnlockPad();
85 }
86
87 TH1* FemtoCFPainter::CloneHist(TH1* h) const {
88 TH1* copy = (TH1*) h->Clone();
89 h->SetName(Form("%i", Hal::Std::anonymCounter++));
90 copy->SetDirectory(nullptr);
91 copy->SetStats(0);
92 copy->SetObjectStat(kFALSE);
93 return copy;
94 }
95
96 ULong64_t FemtoCFPainter::PrepBitTemplate(std::initializer_list<int> temps) const {
97 ULong64_t res = 0;
98 auto vec = Hal::Std::GetVector(temps);
99 for (auto i : vec)
100 SETBIT(res, i);
101 return res;
102 }
103
104 Bool_t FemtoCFPainter::AreSimiliar(ULong64_t current, ULong64_t pattern) const { return pattern == current & pattern; }
105
106 ULong64_t FemtoCFPainter::SetOptionInternal(TString opt, ULong64_t newOpts) {
107 if (Hal::Std::FindParam(opt, "num", kTRUE)) { SETBIT(newOpts, kNumBit); }
108 if (Hal::Std::FindParam(opt, "den", kTRUE)) { SETBIT(newOpts, kDenBit); }
109 if (Hal::Std::FindParam(opt, "tit", kTRUE)) { SETBIT(newOpts, kHideTitles); }
110 if (Hal::Std::FindParam(opt, "fit", kTRUE)) {
111 CLRBIT(newOpts, kDenBit);
112 CLRBIT(newOpts, kNumBit);
113 }
114 auto ranges = Hal::Std::FindBrackets(opt, kTRUE, kTRUE);
115 for (auto range : ranges) {
116 std::vector<double> res;
117 auto foundx = GetPatterns(range, "x", res);
118 auto foundy = GetPatterns(range, "y", res);
119 if (res.size() == 2 && foundx) {
120 fRangeX[0] = res[0];
121 fRangeX[1] = res[1];
122 }
123 if (res.size() == 2 && foundy) {
124 fRangeY[0] = res[0];
125 fRangeY[1] = res[1];
126 }
127 }
128 if (!TESTBIT(newOpts, kNumBit) && !TESTBIT(newOpts, kDenBit)) { SETBIT(newOpts, kCFBit); }
129 return newOpts;
130 }
131
132 std::pair<Double_t, Double_t> FemtoCFPainter::GetMinMax(Int_t x, Int_t y) const {
133 std::pair<Double_t, Double_t> res;
134 if (fHistograms.size() < x + 1) return res;
135 if (fHistograms[x].size() < y + 1) return res;
136 auto h = fHistograms[x][y];
137 if (!h) return res;
138 res.first = h->GetMinimum();
139 res.second = h->GetMaximum();
140 return res;
141 }
142
143} // namespace Hal
std::pair< Double_t, Double_t > GetMinMax(Int_t x=0, Int_t y=0) const
virtual void InnerRepaint()
virtual void InnerPaint()
Bool_t AreSimiliar(ULong64_t current, ULong64_t pattern) const
virtual ULong64_t SetOptionInternal(TString opt, ULong64_t prev=0)
virtual void InnerPaint()
Definition Painter.h:176
void UnlockPad()
Definition Painter.cxx:182
void LockPad()
Definition Painter.cxx:180
Bool_t CheckOpt(Int_t opt) const
Definition Painter.h:79
virtual void OptionsApplied()
Definition Painter.h:101
virtual void InnerRepaint()
Definition Painter.h:172
Bool_t fOptionsChanged
Definition Painter.h:68
void GotoPad(Int_t no, Int_t canvasNo=0)
Definition Painter.cxx:187
Bool_t GetPatterns(TString opt, TString flag, std::vector< double > &vals) const
Definition Painter.cxx:161