ROOT Version: 6.32.04
Platform: WSL2 Ubuntu
Hello! I am unable to draw my TGraph. Brief context of the script: I extract histograms from a ROOT file and plot their means with respect to another array. Gist of the code is below.
// Reading roots
TFile *input_1 = new TFile("study1.root", "READ");
TFile *input_2 = new TFile("study2.root", "READ");
.
.
// Extracting hists
TH1F *hist_1 = (TH1F*)input_1->Get("hist_xx");
TH1F *hist_2 = (TH1F*)input_2->Get("hist_xx");
.
.
// Normalising
hist_1->Scale(1.0/hist_1->Integral());
hist_2->Scale(1.0/hist_2->Integral());
.
.
// Define arrays
double var1[] = {1, 2, 3, 4, 5};
double var2[] = {hist_1->GetMean(), hist_2->GetMean(), ... };
// Define graph
TGraph* graph = new TGraph(sizeof(var1)/sizeof(var1[0]), var1, var2);
// Create canvas
TCanvas* cv = new TCanvas("cv", "Running of var2", 1600, 800);
// Draw
graph ->Draw("AP");
}
I have checked if the histograms are empty; printing out the arrays gives correct values. Hence, I believe it is something to do with my TGraph handling? Highly appreciate an input. Thank you!