Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
CorrFitMapGroupConfig.cxx
1/*
2 * CorrFitMapGroupConfig2.cxx
3 *
4 * Created on: 27 lut 2024
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9#include "CorrFitMapGroupConfig.h"
10
11#include "Cout.h"
12
13namespace Hal {
14 CorrFitMapGroupConfig::CorrFitMapGroupConfig() : fBins(100), fMin(0), fMax(100) {
15 fStep = (fMax - fMin) / Double_t(fBins);
16 fStep = 1.0 / fStep;
17 SetName("CorrFitMapGroup");
18 }
19
20 void CorrFitMapGroupConfig::SetAxis(Int_t bins, Double_t min, Double_t max) {
21 fBins = bins;
22 if (fMin < 0) {
23 fMin = 0;
24 if (fBins % 2 == 1) { Cout::PrintInfo("CorrFitMapGroupConfig::SetAxis odd number of CF bins detected!", EInfo::kError); }
25 fBins = fBins / 2;
26 }
27 fMin = min;
28 fMax = max;
29 fStep = (fMax - fMin) / Double_t(fBins);
30 fStep = 1.0 / fStep;
31 }
32
33 Bool_t CorrFitMapGroupConfig::GroupByLong() const {
34 if (fMode == 1) return kTRUE;
35 return kFALSE;
36 }
37
38 Bool_t CorrFitMapGroupConfig::GroupByKStar() const { return !GroupByLong(); }
39
40 Int_t CorrFitMapGroupConfig::GetBin(const FemtoPair* pair) const {
41 Double_t val = TMath::Abs(pair->GetT());
42 if (fMode == 1) { // long
43 val = TMath::Abs(pair->GetZ());
44 }
45 Int_t bin = (val - fMin) * fStep;
46 if (bin >= fBins) return -1;
47 return bin;
48 }
49
50 void CorrFitMapGroupConfig::Add(const Object* pack) {
51 auto* data = dynamic_cast<const CorrFitMapGroupConfig*>(pack);
52 if (!data) {
53 Hal::Cout::PrintInfo("Cannot add CorrFitMapGroupConfig", EInfo::kError);
54 return;
55 }
56 auto printError = []() { Hal::Cout::PrintInfo("Cannot add CorrFitMapGroupConfig", EInfo::kError); };
57
58 if (fMode != data->fMode) { printError(); }
59 if (fBins != data->fBins) { printError(); };
60 if (fMin != data->fMin) { printError(); }
61 }
62
63 std::vector<TString> CorrFitMapGroupConfig::GetBranchesByValue(Double_t min, Double_t max, Bool_t signal) const {
64 if (min == max && fMin != fMax) { return GetBranchesByValue(fMin, fMax, signal); }
65 Int_t lowBin = (fMin - min) * fStep;
66 Int_t highBin = (fMax - min) * fStep;
67 std::vector<TString> result;
68 TString pattern = "FemtoBackground_%i";
69 if (signal) { pattern = "FemtoSignal_%i"; }
70 for (int i = lowBin; i < highBin; i++) {
71 TString name = Form(pattern, i);
72 result.push_back(name);
73 }
74 return result;
75 }
76
77 std::vector<TString> CorrFitMapGroupConfig::GetBranchesByIndex(Int_t min, Int_t max, Bool_t signal) const {
78 std::vector<TString> result;
79 TString pattern = "FemtoBackground_%i";
80 if (signal) { pattern = "FemtoSignal_%i"; }
81 for (int i = min; i < max; i++) {
82 TString name = Form(pattern, i);
83 result.push_back(name);
84 }
85 return result;
86 }
87
88} /* namespace Hal */
static void PrintInfo(TString text, Hal::EInfo status)
Definition Cout.cxx:370