Hello all,
I have a code reading a ROOT file, and plotting a 2d histogram with hits. The code works well, and I can save the histograms. But I cannot seem to visualize the graphs. The canvas always pops up empty.
I’m sure I’m missing something basic, but cannot find out the issue. Any help would be more than welcome Thank you in advance!
#include <TROOT.h>
#include <TH2D.h>
#include <TMath.h>
#include <TStyle.h>
#include <TCanvas.h>
#include <TSystem.h>
#include <ROOT/RDataFrame.hxx>
#include "tools.hxx"
#include "style_config.C"
TCanvas* doseCanvas = nullptr;
TCanvas* electronEkin = nullptr;
TCanvas* gammaEkin = nullptr;
void data_analysis()
{
ROOT::EnableImplicitMT();
Int_t Nx = 20;
Int_t Ny = 20;
Int_t NoEvents = 500000;
TString file = "Data/Sr90_34cm.root";
// Dose data
ROOT::RDataFrame doseData("tiles", file);
auto df2 = doseData.Define("ix", "(int)(copyNo/20)")
.Define("iy", "(int)(copyNo%20)");
auto h2 = df2.Histo2D({"dose2d", "Total dose per tile;ix;iy",
Nx, -0.5, Nx-0.5, Ny, -0.5, Ny-0.5 },
"ix", "iy", "dose");
gROOT->SetBatch(kFALSE);
gStyle->SetOptStat(0);
gStyle->SetNumberContours(255);
doseCanvas = new TCanvas("doseCanvas", "Dose Map", 900, 720);
doseCanvas->SetRightMargin(0.16);
doseCanvas->cd();
h2->GetZaxis()->SetTitle("Dose [krad]");
h2->Draw("COLZ");
doseCanvas->Modified();
doseCanvas->Update();
}
ROOT Version: 6.34
Platform: Ubuntu 24.04, Conda environment
Compiler: GCC