I would like to draw the TH1Ds all into a new canvas and save them. I’ve tried c->GetObject("muon", histoMuon); but it says that there is “no member named GetObject in TCanvas”.
TString filename = "file.root";
TFile* file = TFile::Open(filename);
TCanvas* c = (TCanvas*) file->Get("c2");
c->ls();
c->Draw();
TH1D *measurement = (TH1D*)c->GetPrimitive("measurement");
TH1D *Muons = (TH1D*)c->GetPrimitive("Muons");
(...etc...)
(...change to another canvas)
measurement->Draw();
(...etc...)
Note that if you want to draw the histos in the same “original” canvas (“c”), you should get them all before drawing them, since drawing will clear the canvas (unless you use “same”).
I somehow get the error that null passed to a callee that requires a non-null argument [-Wnonnull], especially when I’m plotting the Muons and innerPbShielding_Pb210 TH1Ds. Any idea why?