10#include "CorrFitMask3D.h"
21 Bool_t CorrFitMask3D::Init() {
23 for (
int i = 1; i < (int) fRawMask.size() - 1; i++) {
24 for (
int j = 1; j < (int) fRawMask[0].size() - 1; j++) {
25 for (
int k = 1; k < (int) fRawMask[0][0].size() - 1; k++) {
26 if (fRawMask[i][j][k]) fActiveBins++;
33 Bool_t CorrFitMask3D::AreCompatible(TObject* cf)
const {
34 auto func =
dynamic_cast<Femto3DCF*
>(cf);
35 if (!func)
return kFALSE;
37 TString opts[3] = {
"x",
"y",
"z"};
38 for (
int i = 0; i < 3; i++) {
40 Double_t minim, maxim;
41 Std::GetAxisPar(*func->GetNum(), bins, minim, maxim, opts[i]);
42 if (fBins[i] != bins)
return kFALSE;
43 if (fMin[i] != minim)
return kFALSE;
44 if (fMax[i] != maxim)
return kFALSE;
50 CorrFitMask3D::CorrFitMask3D(Int_t binsX,
68 fRawMask.resize(fBins[0] + 2);
69 for (
auto& i : fRawMask) {
70 i.resize(fBins[1] + 2);
72 j.resize(fBins[2] + 2);
77 void CorrFitMask3D::ApplyRange(Double_t minX,
85 double min[3] = {minX, minY, minZ};
86 double max[3] = {maxX, maxY, maxZ};
87 for (
int i = 0; i < 3; i++) {
88 Double_t binW = 1.0 / ((fMax[i] - fMin[i]) / double(fBins[i]));
89 low[i] = (min[i] - fMin[i]) * binW;
90 high[i] = (max[i] - fMin[i]) * binW;
91 if (low[i] < 0) low[i] = 1;
92 if (high[i] > fBins[i] + 1) high[i] = fBins[i] + 1;
95 for (
int i = low[0]; i <= high[0]; i++) {
96 for (
int j = low[1]; j <= high[1]; j++) {
97 for (
int k = low[2]; k <= high[2]; k++) {
98 fRawMask[i][j][k] =
true;
103 for (
int i = 0; i < (int) fRawMask.size(); i++) {
104 for (
int j = 0; j < (int) fRawMask[0].size(); j++) {
105 for (
int k = 0; k < (int) fRawMask[0][0].size(); k++) {
106 if (i < low[0]) fRawMask[i][j][k] =
false;
107 if (i > high[0]) fRawMask[i][j][k] =
false;
108 if (j < low[1]) fRawMask[i][j][k] =
false;
109 if (j > high[1]) fRawMask[i][j][k] =
false;
110 if (k < low[2]) fRawMask[i][j][k] =
false;
111 if (k > high[2]) fRawMask[i][j][k] =
false;
118 void CorrFitMask3D::SetBin(Int_t binX, Int_t binY, Int_t binZ, Bool_t state) { fRawMask[binX][binY][binZ] = state; }
120 void CorrFitMask3D::Reset(Bool_t state) {
121 for (
int i = 0; i < (int) fRawMask.size(); i++) {
122 for (
int j = 0; j < (int) fRawMask[0].size(); j++) {
123 for (
int k = 0; k < (int) fRawMask[0][0].size(); k++) {
124 fRawMask[i][j][k] = state;
130 void CorrFitMask3D::ApplyThreshold(
const TH1& h, Double_t threshold) {
131 for (
int i = 1; i <= h.GetNbinsX(); i++) {
132 for (
int j = 1; j <= h.GetNbinsY(); j++) {
133 for (
int k = 1; k <= h.GetNbinsZ(); k++) {
134 if (h.GetBinContent(i, j, k) <= threshold) { fRawMask[i][j][k] =
false; }
140 void CorrFitMask3D::ApplyMask(EFitExtraMask mask, Bool_t additive) {
141 Array_3<Short_t> map;
142 map.MakeBigger(GetNbinsX() + 1, GetNbinsY() + 1, GetNbinsZ() + 1);
143 for (
int i = 0; i <= GetNbinsX() + 1; i++) {
144 for (
int j = 0; j <= GetNbinsY() + 1; j++) {
145 for (
int k = 0; k <= GetNbinsZ() + 1; k++) {
146 map[i][j][k] =
false;
151 for (
int i = 0; i <= GetNbinsX() + 1; i++) {
152 for (
int j = 0; j <= GetNbinsY() + 1; j++) {
153 for (
int k = 0; k <= GetNbinsZ() + 1; k++) {
155 if (map[i][j][k]) fRawMask[i][j][k] =
true;
157 if (!map[i][j][k]) fRawMask[i][j][k] =
false;
164 void CorrFitMask3D::CalcMap(Array_3<Short_t>& map, EFitExtraMask mask) {
165 if (mask == EFitExtraMask::kSlice) {
166 CalculateSliceBins(map);
167 }
else if (mask == EFitExtraMask::kDiagonalSlice || mask == EFitExtraMask::kDiagonalSliceIgnored) {
168 CalculateDiagonalBins(map, mask);
169 }
else if (mask == EFitExtraMask::kUltraDiagonalSlice || mask == EFitExtraMask::kUltraDiagonalSliceIgnored) {
170 CalculateUltradiagonalBins(map, mask);
174 void CorrFitMask3D::CalculateDiagonalBins(Array_3<Short_t>& map, EFitExtraMask mask) {
175 Int_t nBinX = GetNbinsX();
176 Int_t nBinY = GetNbinsY();
177 Int_t nBinZ = GetNbinsZ();
179 Int_t middle_x = 1 + int(nBinX * (x - fMin[0]) / (fMax[0] - fMin[0]));
182 CalculateSliceBins(map);
184 if (nBinX != nBinY || nBinY != nBinZ) {
186 "CorrFit3DCF::CalculateDiagonalBins cannot use cross bins, different number of bins in 3D, switch to slice",
"M", kRed);
191 if (middle_x != 1 || mask == EFitExtraMask::kDiagonalSliceIgnored) {
192 for (
int i = 1; i <= nBinX; i++) {
194 Int_t b = nBinX - i + 1;
203 for (
int i = 1; i <= nBinX; i++) {
211 void CorrFitMask3D::CalculateUltradiagonalBins(Array_3<Short_t>& map, EFitExtraMask mask) {
212 Int_t nBinX = GetNbinsX();
213 Int_t nBinY = GetNbinsY();
214 Int_t nBinZ = GetNbinsZ();
216 Int_t middle_x = 1 + int(nBinX * (x - fMin[0]) / (fMax[0] - fMin[0]));
217 Int_t middle_y = 1 + int(nBinX * (x - fMin[1]) / (fMax[1] - fMin[1]));
218 Int_t middle_z = 1 + int(nBinX * (x - fMin[2]) / (fMax[2] - fMin[2]));
219 CalculateSliceBins(map);
221 if (nBinX != nBinY || nBinY != nBinZ) {
223 "CorrFit3DCF::CalculateUltradiagonalBins cannot use cross bins, different number of bins in 3D, switch to slice",
230 if (middle_x != 1 || mask == EFitExtraMask::kUltraDiagonalSliceIgnored) {
231 for (
int i = 1; i <= nBinX; i++) {
233 Int_t b = nBinX - i + 1;
240 map[middle_x][a][a] =
true;
241 map[middle_x][a][b] =
true;
242 map[a][middle_y][a] =
true;
243 map[a][middle_y][b] =
true;
244 map[a][a][middle_z] =
true;
245 map[a][b][middle_z] =
true;
248 for (
int i = 1; i <= nBinX; i++) {
254 map[middle_x][a][a] =
true;
255 map[a][middle_y][a] =
true;
256 map[a][a][middle_z] =
true;
261 void CorrFitMask3D::CalculateSliceBins(Array_3<Short_t>& map) {
262 Int_t nBinX = GetNbinsX();
263 Int_t nBinY = GetNbinsY();
264 Int_t nBinZ = GetNbinsZ();
266 Int_t middle_x = 1 + int(nBinX * (x - fMin[0]) / (fMax[0] - fMin[0]));
267 Int_t middle_y = 1 + int(nBinX * (x - fMin[1]) / (fMax[1] - fMin[1]));
268 Int_t middle_z = 1 + int(nBinX * (x - fMin[2]) / (fMax[2] - fMin[2]));
269 for (
int i = 1; i <= nBinX; i++) {
270 map[i][middle_y][middle_z] =
true;
272 for (
int j = 1; j <= nBinY; j++) {
273 map[middle_x][j][middle_z] =
true;
275 for (
int k = 1; k <= nBinZ; k++) {
276 map[middle_x][middle_y][k] =
true;
static void Text(TString text, TString option="L", Color_t color=-1)