Problems drawing histogram because of @ symbol

Hello, I’ve this root file made by compass software.
When I try to open the histograms in Energy TDirectory, as for example
I get error related to the @ in the histogram name (but I didn’t set the name…compass did it).


How drawing it?
HcompassR_run_1167_20240206_164918.root (136.3 KB)


Thanks for posting this question: it’s an interesting one.

ROOT, at the prompt, allows to use names of objects written in an open TFile as if they were C++ variable names: this is a nice feature, which allows to comfortably explore files.

However, the name of an object in a file is not necessarily a valid C++ variable name, as you pointed out. In this cases, the aforementioned “shortcut” cannot be used and the full TFile API enters the game. In your case you can do:

auto myHist = myfile.Get<TH1D>("_R_EnergyCH0@V1724_1113");

I hope this helps,

Hi Danilo,
thank you for your clarification!

My job and pleasure :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.