Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
CorrFit3DCFMultiDim.cxx
1/*
2 * CorrFit3DCFMultiDim.cxx
3 *
4 * Created on: 18 maj 2020
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9
10#include "CorrFit3DCFMultiDim.h"
11
12#include "CorrFit.h"
13#include "CorrFitFunctor.h"
14#include "CorrFitInfo.h"
15#include "Cout.h"
16#include "Femto3DCF.h"
17#include "Minimizer.h"
18
19#include <Rtypes.h>
20#include <RtypesCore.h>
21#include <TH1.h>
22#include <TString.h>
23#include <iostream>
24#include <string>
25
26//#define _MULTIDIM_DEBUG_
27
28
29namespace Hal {
31 Double_t pars[3];
32 pars[0] = fTempParamsEval[RoutID()];
33 pars[1] = fTempParamsEval[RsideID()];
34 pars[2] = fTempParamsEval[RlongID()];
35 fData = fFunctor->GetData(pars);
36 }
37
38 Double_t CorrFit3DCFMultiDim::CalculateCF(const Double_t* /*x*/, const Double_t* params) const {
40 Double_t bin = (fBinX - 1) * fFunctorXbins * fFunctorYbins + (fBinY - 1) * fFunctorYbins + fBinZ - 1;
41 Double_t num = fData->Get(bin) - 1.0;
42 if (TMath::IsNaN(num)) num = 0;
43 return params[NormID()] * (1.0 + num * params[LambdaID()]);
44 }
45
46 CorrFit3DCFMultiDim::CorrFit3DCFMultiDim(Int_t params) : CorrFit3DCF(params) { fMinAlgo = EMinAlgo::kHalScan; }
47
48 void CorrFit3DCFMultiDim::SetFunctor(CorrFitFunctor* functor) {
49 fFunctor = functor;
50 SetAutoLimits();
51 }
52
53 void CorrFit3DCFMultiDim::SetFunctorFromMap(TString filename) {
54 fFunctor = new CorrFitFunctor(filename);
55 SetAutoLimits();
56 }
57
58 void CorrFit3DCFMultiDim::SetAutoLimits() {
59 TString name;
60 Double_t min, max;
61 Int_t points;
62 // get out
63#ifdef _MULTIDIM_DEBUG_
64 std::cout << "SET AUTO LIMITS" << std::endl;
65#endif
66 for (int i = 0; i < fFunctor->GetNParams(); i++) {
67 name = fFunctor->GetParameterName(i);
68 fFunctor->GetParameterConfig(name, min, max, points);
69 fParameters[i].SetIsDiscrete(kTRUE);
70 fParameters[i].SetMapRange(min, max, points);
71 SetParLimits(i, min, max);
72 }
73#ifdef _MULTIDIM_DEBUG_
74 std::cout << "AUTO DONE" << std::endl;
75#endif
76 }
77
78 CorrFit3DCFMultiDim::~CorrFit3DCFMultiDim() {
79 if (fFunctor) delete fFunctor;
80 }
81
83 if (alg == kHalScan || alg == kHalAnt) {
84 if (alg == kHalAnt) { std::cout << "Smart scan" << std::endl; }
86 } else {
87 Cout::Text("This class supports correctly only Minimizer", "L", kYellow);
88 }
89 }
90
92 std::cout << "PREPARING MINIMIZER" << GetParametersNo() << std::endl;
94 for (int i = 0; i < GetParametersNo(); i++) {
95 std::string par_name = GetParameterName(i).Data();
96 if (!IsParFixed(i)) { // fixed parameters will be configured later
97 TString name = par_name;
98 Double_t Min, Max;
99 Int_t points;
100 if (fFunctor->GetParameterConfig(name, Min, Max, points)) {
101 Double_t step_size = (Max - Min) / (Double_t(points - 1));
102 if (points == 0) step_size = 0;
103#ifdef _MULTIDIM_DEBUG_
104 std::cout << "SET MAP STEPS " << par_name << "\t" << Min << " " << Max << " " << points << " "
105 << " " << step_size << std::endl;
106#endif
107 std::string Name = name.Data();
108 min->SetLimitedVariable(i, Name, 0.5 * (Min + Max), step_size, Min, Max);
109 } else {
110#ifdef _MULTIDIM_DEBUG_
111 std::cout << "SET FREE STEPS " << par_name << "\t" << GetParMin(i) << " " << GetParMax(i) << " " << points << " "
112 << " " << 0.01 << std::endl;
113#endif
114 min->SetLimitedVariable(i, par_name, 0.5 * (GetParMin(i) + GetParMax(i)), 0.01, GetParMin(i), GetParMax(i));
115 }
116 min->SetVariableLimits(i, GetParMin(i), GetParMax(i));
117 } else {
118#ifdef _MULTIDIM_DEBUG_
119 std::cout << "SET FIXED " << par_name << "\t" << GetParMin(i) << " " << GetParMax(i) << std::endl;
120#endif
121 min->SetLimitedVariable(i, par_name, GetParMin(i), 1, GetParMin(i), GetParMin(i));
122 min->SetFixedVariable(i, par_name, GetParMin(i));
123 }
124 }
125 std::cout << "PREPARING MINIMIZER DONE !" << std::endl;
126 }
127
130 CorrFitInfo* info = fFunctor->GetInfo();
131 Femto3DCF* cf = dynamic_cast<Femto3DCF*>(info->GetCf());
132 if (cf == nullptr) { Cout::PrintInfo("Cannot find 3DCF in CorrFitInfo !", EInfo::kCriticalError); }
133 Femto3DCF* thisCf = (Femto3DCF*) fCF;
134 if (thisCf->GetFrame() != cf->GetFrame()) { Cout::PrintInfo("CorrFitInfo incompatible frames !", EInfo::kCriticalError); }
135 TH3* testThis = (TH3*) thisCf->GetNum();
136 TH3* testMap = (TH3*) cf->GetNum();
137 if (!Hal::Std::AreSimilar(testThis, testMap, kFALSE)) {
138 Cout::PrintInfo("CorrFitInfo incompatible histograms in CorrFitInfo and Femto3DCF !", EInfo::kError);
139 }
140 fFunctorXbins = testThis->GetXaxis()->GetNbins();
141 fFunctorYbins = testThis->GetYaxis()->GetNbins();
142 }
143} // namespace Hal
T Get(Int_t i) const
Definition Array.h:97
virtual Double_t CalculateCF(const Double_t *x, const Double_t *params) const
virtual void SetMinimizer(EMinAlgo alg)
virtual void PrepareHalMinimizer() const
virtual void RecalculateFunction() const
Int_t RsideID() const
Int_t LambdaID() const
Int_t RoutID() const
Int_t RlongID() const
Int_t NormID() const
virtual void Check()
Bool_t GetParameterConfig(TString name, Double_t &min, Double_t &max, Int_t &npoints) const
Int_t GetParametersNo() const
Definition CorrFit.h:269
TString GetParameterName(Int_t no) const
Definition CorrFit.h:280
Double_t GetParMax(Int_t par) const
Definition CorrFit.cxx:136
Double_t GetParMin(Int_t par) const
Definition CorrFit.cxx:131
Double_t * fTempParamsEval
Definition CorrFit.h:109
void SetParLimits(Int_t par, Double_t min, Double_t max)
Definition CorrFit.cxx:102
std::vector< FitParam > fParameters
Definition CorrFit.h:103
virtual void SetMinimizer(EMinAlgo alg)
Definition CorrFit.h:286
Bool_t IsParFixed(Int_t par) const
Definition CorrFit.cxx:121
static void Text(TString text, TString option="L", Color_t color=-1)
Definition Cout.cxx:92
static void PrintInfo(TString text, Hal::EInfo status)
Definition Cout.cxx:370
Femto::EKinematics GetFrame() const
Definition Femto3DCF.h:67
virtual bool SetFixedVariable(unsigned int ivar, const std::string &name, double val)
Definition Minimizer.cxx:40
virtual bool SetVariableLimits(unsigned int ivar, double lower, double upper)
Definition Minimizer.cxx:48
static Minimizer * Instance()
virtual bool SetLimitedVariable(unsigned int ivar, const std::string &name, double val, double points, double lower, double upper)
Definition Minimizer.cxx:61