I am also curios why this bash file doesn’t work.
#!/bin/bash
yourPath=“PATH/”
root -l ${yourPath}plots.root -e “new TBrowser”
TFile *file = TFile::Open("${yourPath}plots.root");
if (!file) {
std::cerr << "Error: Could not open plots.root" << std::endl;
return 1;
}
TGraph *graph1 = (TGraph*)file->Get("mg0");
TGraph *graph2 = (TGraph*)file->Get("mg1");
TCanvas *c1 = new TCanvas("c1", "Graph 1", 800, 600);
graph1->Draw("AL");
TCanvas *c2 = new TCanvas("c2", "Graph 2", 800, 600);
graph2->Draw("AL");
ferhue
February 6, 2024, 8:24pm
22
You can use graph- write instead of canvas write, and then use Draw option “same” in TBrowser when double clicking. This way they will all be added to the same canvas.
There is no way to show them without clicking. Apart from writing another script.
ferhue
February 6, 2024, 8:27pm
23
You are mixing bash and C++.
Instead, create a macro called openPlots.cpp and there you put the C++ code where you open the TFile.
From bash just remove the new Tbrowser stuff and just call root openPlots.cpp -l
Worked. Thank you so much.