Special characters in histogram name

Hi all,

I’m retrieving some histograms (TH1F) from a root file (hist-scale.root) by simply doing:


The problem is that some of the histos have special characters and white space in the name, so for example if the name of the histo is “cut_flow_central” it works while if it is “cut_flow_name=‘nominal’ combine=‘none’ nominal id=‘0’” it doesn’t work.

I know that it’s not the best thing to have such names but I was wondering wheter it is possible to retrieve them avoiding to change by hand the names (histograms are the output of a previous program so it is a bit more complicated).

Thanks a lot!

root.cern.ch/how/how-draw-objec … s-its-name

Maybe it’s a stupid question, but does it have to be as complicated as shown in the link?

I just tested “Get” and it worked just fine. So what (if anything) is wrong with the following?

$ root               
root [0] auto f = unique_ptr<TFile>(TFile::Open("/tmp/x.root", "recreate"))
(std::unique_ptr<TFile, default_delete<TFile> > &) @0x7fc277f85060
root [1] TH1F("cut_flow_name='nominal' combine='none' nominal id='0'", "Title Test", 100, 0, 100).Write()
(Int_t) 351
root [2] .q

$ root -l /tmp/x.root
root [0] 
Attaching file /tmp/x.root as _file0...
(TFile *) 0x526e1c0
root [1] auto h = dynamic_cast<TH1*>(_file0->Get("cut_flow_name='nominal' combine='none' nominal id='0'"))
(TH1 *) 0x53a3aa0
root [2] h->GetTitle()
(const char *) "Title Test"
root [3] .q

The link shows the extreme case where some characters cannot be even typed.