I have a .root file with histograms containing “/” in their name. I referred to this link:
https://root-forum.cern.ch/t/how-to-draw-an-object-with-special-characters-in-its-name/28248
but this is for TObject and I am not able use it for TH1
I have a .root file with histograms containing “/” in their name. I referred to this link:
https://root-forum.cern.ch/t/how-to-draw-an-object-with-special-characters-in-its-name/28248
but this is for TObject and I am not able use it for TH1
It’s clearer if you include some code that you have tried.
void fit()
{ gStyle->SetOptStat(0);
TFile *f11 = new TFile("digitrootobjects.root","read");
// f11->ls();
// get the list of keys
TList *list = (TList *)f11->GetListOfKeys();
TH1F *h1 = (TH1F *)list->FindObject("Cluster/ClsAmpCh");
// TH1F *h1 = ((TKey *)key)->ReadObj();
h1->Draw();
}
Does this work?
TH1F *h1 = (TH1F *)list->FindObject(Form("%s","Cluster/ClsAmpCh"));
(by the way, make sure “Cluster/” is really part of the name of the histo, and not a directory).
It is indeed name of the histo and the command gives an empty canvas.
Try
void fit()
{
gStyle->SetOptStat(0);
TFile *f11 = new TFile("digitrootobjects.root","read");
TH1F *h1 = (TH1F*)f11->FindObjectAny("Cluster/ClsAmpCh");
h1->Draw();
}
Thanks
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.