Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
FemtoSHCFPainter.cxx
1/*
2 * FemtoSHCFPainter.cxx
3 *
4 * Created on: 22 lip 2024
5 * Author: daniel
6 */
7
8#include "FemtoSHCFPainter.h"
9
10#include <RtypesCore.h>
11#include <TAttMarker.h>
12#include <TAxis.h>
13#include <TH1.h>
14#include <TRandom.h>
15#include <TVirtualPad.h>
16#include <initializer_list>
17#include <vector>
18
19#include "Cout.h"
20#include "FemtoSHCF.h"
21#include "HistoStyle.h"
22#include "PadStyle.h"
23#include "Std.h"
24#include "StdHist.h"
25#include "StdString.h"
26
27namespace Hal {
28 const int FemtoSHCFPainter::kReBit = 16;
29 const int FemtoSHCFPainter::kImBit = 17;
30 const int FemtoSHCFPainter::kShortBit = 18;
31 const int FemtoSHCFPainter::kSepBit = 19;
32
33 ULong64_t FemtoSHCFPainter::SetOptionInternal(TString opts, ULong64_t newFlags) {
34 newFlags = FemtoCFPainter::SetOptionInternal(opts, newFlags);
35 ContitionalPattern(opts, "re", newFlags, kReBit, kTRUE);
36 ContitionalPattern(opts, "im", newFlags, kImBit, kTRUE);
37 std::vector<double> yrange;
38 GetPatterns(opts, "y", yrange);
39 fRangesYY = yrange;
40 if (!TESTBIT(newFlags, kNumBit) && TESTBIT(newFlags, kDenBit)) { SETBIT(newFlags, kCFBit); }
41 if (Hal::Std::FindParam(opts, "fit", kTRUE)) {
42 SETBIT(newFlags, kCFBit);
43 CLRBIT(newFlags, kDenBit);
44 CLRBIT(newFlags, kNumBit);
45 }
46 if (Hal::Std::FindParam(opts, "sep", kTRUE)) SETBIT(newFlags, kSepBit);
47 if (!CheckOpt(kReBit) && !CheckOpt(kImBit)) {
48 SETBIT(newFlags, kReBit);
49 SETBIT(newFlags, kImBit);
50 }
51 if (Hal::Std::FindParam(opts, "short", kTRUE)) SETBIT(newFlags, kShortBit);
52 return newFlags;
53 }
54
55 FemtoSHCFPainter::FemtoSHCFPainter(Hal::FemtoSHCF* cf) : FemtoCFPainter(), fSHCF(cf) {
56 Hal::PadStyle style(0.045, 0.045, 0.025, 0.025);
57 SetGlobalPadStyle(style);
58 }
59
60 std::pair<TH1*, TH1*> FemtoSHCFPainter::GetNewHistPair(Int_t l, Int_t m) {
61 std::pair<TH1*, TH1*> res(nullptr, nullptr);
62 if (CheckOpt(kNumBit)) { // return numerators
63 if (CheckOpt(kImBit) && !CheckOpt(kReBit)) { // only imag
64 res.first = fSHCF->GetNumIm(l, m);
65 } else if (!CheckOpt(kImBit) && CheckOpt(kReBit)) { // only real
66 res.first = fSHCF->GetNumRe(l, m);
67 } else { // im + real
68 res.first = fSHCF->GetNumRe(l, m);
69 res.second = fSHCF->GetNumIm(l, m);
70 }
71 } else if (CheckOpt(kDenBit)) { // return denominators
72 if (CheckOpt(kImBit) && !CheckOpt(kReBit)) { // only imag
73 res.first = fSHCF->GetDenIm(l, m);
74 } else if (!CheckOpt(kImBit) && CheckOpt(kReBit)) { // only real
75 res.first = fSHCF->GetDenRe(l, m);
76 } else { // im + real
77 res.first = fSHCF->GetDenRe(l, m);
78 res.second = fSHCF->GetDenIm(l, m);
79 }
80 } else { // return cf's
81 if (CheckOpt(kImBit) && !CheckOpt(kReBit)) { // only imag
82 res.first = fSHCF->GetCFIm(l, m);
83 } else if (!CheckOpt(kImBit) && CheckOpt(kReBit)) { // only real
84 res.first = fSHCF->GetCFRe(l, m);
85 } else { // im + real
86 res.first = fSHCF->GetCFRe(l, m);
87 res.second = fSHCF->GetCFIm(l, m);
88 }
89 }
90 if (res.first) {
91 res.first = CloneHist(res.first);
92 Hal::Std::CopyHistProp(*fSHCF->GetNum(), *res.first, "!tit");
93 if (res.first) SetHistRanges(res.first, l);
94 }
95 if (res.second) {
96 res.second = CloneHist(res.second);
97 Hal::Std::CopyHistProp(*fSHCF->GetNum(), *res.second, "!tit");
98 if (res.second) SetHistRanges(res.second, l);
99 }
100 // fix colors
101 if (CheckOpt(kImBit) && !CheckOpt(kReBit)) { // only imag
102 Hal::Std::SetColor(*res.first, fColorIm);
103 } else if (!CheckOpt(kImBit) && CheckOpt(kReBit)) { // only real
104 Hal::Std::SetColor(*res.first, fColorRe);
105 } else { // im + real
106 Hal::Std::SetColor(*res.second, fColorIm);
107 Hal::Std::SetColor(*res.first, fColorRe);
108 }
109
110 return res;
111 }
112
113 void FemtoSHCFPainter::SetHistRanges(TH1* hist, Int_t l) {
114 hist->SetMinimum(0);
115 double max = hist->GetBinContent(hist->GetMaximumBin());
116 double min = hist->GetBinContent(hist->GetMinimumBin());
117 if (min < 0) {
118 hist->SetMinimum(-1);
119 } else {
120 hist->SetMinimum(0);
121 }
122 if (fRangesYY.size() == 4) {
123 if (l == 0) {
124 hist->SetMinimum(fRangesYY[0]);
125 hist->SetMaximum(fRangesYY[1]);
126 } else {
127 hist->SetMinimum(fRangesYY[2]);
128 hist->SetMaximum(fRangesYY[3]);
129 }
130 }
131 if (max < 1) { hist->SetMaximum(1); }
132 // if (fRangesX[0[] == 2) { hist->GetXaxis()->SetRangeUser(fRangesX[0], fRangesX[1]); }
133 }
134
135 void FemtoSHCFPainter::MakeHistograms() {
136 fColorIm = fSHCF->fColIm;
137 fColorRe = fSHCF->fColRe;
138 int lx = fSHCF->GetLMax();
139 Hal::Std::ResizeVector2D(fHistograms, (lx + 1) * (lx + 1), 2);
140 for (auto x : fHistograms)
141 for (auto& y : x)
142 y = nullptr;
143 for (int l = 0; l <= fSHCF->GetLMax(); l++) {
144 for (int m = -l; m <= l; m++) {
145 auto histos = GetNewHistPair(l, m);
146 int padid = fSHCF->fLmVals.GetPadId(l, m) - 1;
147 if (fRangesYY.size() == 4) {
148 if (l == 0 && histos.first) {
149 histos.first->SetMinimum(fRangesYY[0]);
150 histos.first->SetMaximum(fRangesYY[1]);
151 } else {
152 if (histos.first) {
153 histos.first->SetMinimum(fRangesYY[2]);
154 histos.first->SetMaximum(fRangesYY[3]);
155 }
156 if (histos.second) {
157 histos.second->SetMinimum(fRangesYY[2]);
158 histos.second->SetMaximum(fRangesYY[3]);
159 }
160 }
161 }
162 fHistograms[padid][0] = histos.first;
163 fHistograms[padid][1] = histos.second;
164 if (CheckOpt(kSepBit) && m >= 0) fHistograms[padid][1] = nullptr;
165 if (CheckOpt(kSepBit) && m < 0) fHistograms[padid][0] = nullptr;
166 if (CheckOpt(kShortBit) && m < 0) {
167 fHistograms[padid][0] = nullptr;
168 fHistograms[padid][1] = nullptr;
169 }
170 if (histos.first && !fHistograms[padid][0]) delete histos.first;
171 if (histos.second && !fHistograms[padid][1]) delete histos.second;
172 }
173 }
174 }
175
176 void FemtoSHCFPainter::AddHistograms(TH1* re, TH1* im) {
177 std::vector<TH1*> pairHist;
178 pairHist.push_back(re);
179 pairHist.push_back(im);
180 fHistograms.push_back(pairHist);
181 }
182
184 Int_t padsNo = GetPadsNo();
185 Int_t req = (fSHCF->GetLMax() + 1) * (fSHCF->GetLMax() + 1);
186 if (padsNo != req) return kFALSE;
187 return kTRUE;
188 }
189
191 if (CheckOpt(kShortBit)) { return "fit1"; }
192 if (CheckOpt(kSepBit)) { return "fit3"; }
193 return "fit2";
194 }
195
196 void FemtoSHCFPainter::ScaleHistograms() {
197 FemtoCFPainter::ScaleHistograms();
198 int count = 0;
199 for (auto x : fHistograms) {
200 for (auto y : x) {
201 if (y && fRangesYY.size() == 4) {
202 int step = 0;
203 if (count != 0) step = 2;
204 y->SetMinimum(fRangesYY[step]);
205 y->SetMaximum(fRangesYY[step + 1]);
206 }
207 count++;
208 }
209 }
210 }
211
213 Int_t req = (fSHCF->GetLMax() + 1) * (fSHCF->GetLMax() + 1);
214 MakeCanvasPads(TMath::Sqrt(req), TMath::Sqrt(req));
215 }
216
217} // namespace Hal
virtual ULong64_t SetOptionInternal(TString opt, ULong64_t prev=0)
virtual TString GetOptionForCorrFit() const
virtual ULong64_t SetOptionInternal(TString opts, ULong64_t prev=0)
virtual void MakePadsAndCanvases()
TH1D * GetCFRe(int el, int em) const
TH1D * GetNumRe(int el, int em) const
TH1D * GetDenRe(int el, int em) const
TH1D * GetNumIm(int el, int em) const
TH1D * GetDenIm(int el, int em) const
TH1D * GetCFIm(int el, int em) const
Int_t GetLMax() const
Definition FemtoSHCF.h:306
Int_t GetPadId(Int_t l, Int_t m) const
Bool_t CheckOpt(Int_t opt) const
Definition Painter.h:79
void MakeCanvasPads(Int_t x=1, Int_t y=1, Int_t canvasNo=0)
Definition Painter.cxx:70
Int_t GetPadsNo(Int_t canvasNo=0) const
Definition Painter.h:148
void ContitionalPattern(TString &option, TString pattern, ULong64_t &drawOpt, Int_t bit, Bool_t remove=kTRUE) const
Definition Painter.cxx:174
Bool_t GetPatterns(TString opt, TString flag, std::vector< double > &vals) const
Definition Painter.cxx:161