10#include "CorrFitFunctor.h"
12#include "CorrFitInfo.h"
16#include <RtypesCore.h>
23 CorrFitFunctor::CorrFitFunctor(TString map_file) :
24 fMapFile(map_file), fInfo(nullptr), fSetup(), fChain(nullptr), fFile(nullptr), fParams(0), fData(nullptr) {
25 fFile =
new TFile(fMapFile);
26 fChain = (TTree*) fFile->Get(
"map");
27 fInfo = (CorrFitInfo*) fFile->Get(
"Info");
28 fChain->SetBranchAddress(
"data", &fData);
29 fSetup = fInfo->GetSetup();
30 fParams = fSetup.GetNParams();
31 fDimsArray = fSetup.GetDimensions();
32 fPosArray.resize(fSetup.GetNParams());
35 Bool_t CorrFitFunctor::GetParameterConfig(TString name, Double_t& min, Double_t& max, Int_t& point)
const {
37 for (
int i = 0; i < fSetup.GetNParams(); i++) {
38 if (fSetup.GetParName(i) == name) {
43 if (paramId == -1)
return kFALSE;
44 min = fSetup.GetMin(paramId);
45 max = fSetup.GetMax(paramId);
46 name = fSetup.GetParName(paramId);
47 point = fSetup.GetNPoints(paramId);
51 Int_t CorrFitFunctor::GetNParams()
const {
return fInfo->GetSetup().GetNParams(); }
53 void CorrFitFunctor::PrintInfo() {
54 Cout::Text(
"CorrFitFunctor",
"M", kWhite);
55 fInfo->GetCf()->Print();
56 Cout::Text(
"Params conf",
"L", kWhite);
57 Cout::Database({
"Name",
"Steps",
"Nmin",
"Nmax"});
58 for (
int i = 0; i < fSetup.GetNParams(); i++) {
59 TString steps = Form(
"%i", fSetup.GetNSteps(i));
60 TString min = Form(
"%4.3f", fSetup.GetMin(i));
61 TString max = Form(
"%4.3f", fSetup.GetMax(i));
62 Cout::Database({fSetup.GetParName(i), steps, min, max});
66 Array_1<Float_t>* CorrFitFunctor::GetData(Double_t* params) {
69 for (
int i = 0; i < fSetup.GetNParams(); i++) {
70 Double_t par = params[i];
71 Double_t dif = par - fSetup.GetMin(i);
72 Double_t stepSize = fSetup.GetStepSize(i);
73 Int_t bin = dif / stepSize;
74 if (stepSize == 0) bin = 0;
80 entry_val = Hal::Std::MultiToOneDimIndex(fDimsArray, fPosArray);
81 fChain->GetEntry(entry_val);
85 CorrFitFunctor::~CorrFitFunctor() {
86 if (fFile) { fFile->Close(); }