8#include "CorrelationHisto.h"
16#include <TVirtualPad.h>
22 fNParams(nParams), fNTest(TMath::Abs(nTest)), fAutoFill(kTRUE) {}
24 void CorrelationHisto::ConfigParam(Int_t par, Int_t bins, Double_t min, Double_t max, TString name) {
33 auto vec = Hal::Std::GetVector(i);
40 void CorrelationHisto::Fill(std::vector<Double_t> params) {
41 if (params.size() != fNParams)
return;
45 if (fTestValues.size() < fNTest) {
47 fTestValues.push_back(params);
61 for (
int i = 0; i < fNParams; i++) {
63 for (
int j = i; j < fNParams; j++) {
65 fHistograms[count++]->Fill(x, y);
70 void CorrelationHisto::Initialize() {
71 fNHistograms = (fNParams + 1) * fNParams / 2;
72 fHistograms =
new TH2D*[fNHistograms];
74 for (
int i = 0; i < fNParams; i++) {
75 for (
int j = i; j < fNParams; j++) {
77 TString title = Form(
"SB_%i", count);
78 fHistograms[count - 1] =
new TH2D(title,
80 fAxesConf[i].GetNBins(),
81 fAxesConf[i].GetMin(),
82 fAxesConf[i].GetMax(),
83 fAxesConf[j].GetNBins(),
84 fAxesConf[j].GetMin(),
85 fAxesConf[j].GetMax());
86 fHistograms[count - 1]->GetXaxis()->SetTitle(fAxesConf[i].GetName());
87 fHistograms[count - 1]->GetYaxis()->SetTitle(fAxesConf[j].GetName());
88 fHistograms[count - 1]->GetXaxis()->CenterTitle();
89 fHistograms[count - 1]->GetYaxis()->CenterTitle();
94 void CorrelationHisto::AutoInitialize() {
96 for (
int par = 0; par < fNParams; par++) {
97 double mini = 1E+9, maxi = 1E-9, av, sum = 0;
99 for (
unsigned int ent = 0; ent < fNTest; ent++) {
100 double j = fTestValues[ent][par];
102 mini = TMath::Min(mini, j);
103 maxi = TMath::Max(maxi, j);
107 for (
unsigned int ent = 0; ent < fNTest; ent++) {
108 double j = fTestValues[ent][par];
109 rms += (av - j) * (av - j);
111 rms = TMath::Sqrt(rms / n);
112 mini = TMath::Min(mini, av - rms * 4.0);
113 maxi = TMath::Max(maxi, av + rms * 4.0);
118 for (
auto i : fTestValues) {
124 void CorrelationHisto::FillUnchecked(std::vector<Double_t> params) {
126 for (
int i = 0; i < fNParams; i++) {
127 double x = params[i];
128 for (
int j = i; j < fNParams; j++) {
129 double y = params[j];
130 fHistograms[count++]->Fill(x, y);
135 void CorrelationHisto::Draw(Option_t* ) {
136 TCanvas* c =
new TCanvas();
137 auto pads = Hal::Std::GetGridPad(fNParams, fNParams, 0.124, 0.124);
139 for (
int i = 0; i < fNParams; i++) {
140 for (
int j = i; j < fNParams; j++) {
142 fHistograms[count++]->Draw(
"col");
147 CorrelationHisto::~CorrelationHisto() {
149 for (
int i = 0; i < fNHistograms; i++) {
150 delete fHistograms[i];
152 delete[] fHistograms;
CorrelationHisto(Int_t nParams=1, Int_t nTest=1000)