Error: Symbol not defined in current scope

I’m having trouble getting a histogram from an existing file. Files attached. Running ROOT 5.34.00 on Windows 7.
I keep trying a few work arounds, but each execution fails with one of two errors:

root [0] .X viewspectra.C --> Reading bin edges : Check Number of Resonances: 67 Root File name: Mo97_2010_10ns_820_920_120keV_resonances_BGm.root resonance0038.75eV/Egamma_0038.75eV_Mcl2 Error: non class,struct,union object Eg[j][k] used with . or -> C:\Users\Carrie\Documents\Working\viewspectra.C(62) *** Interpreter error recovered ***
or

root [0] .X viewspectra.C --> Reading bin edges : Check Number of Resonances: 67 Root File name: Mo97_2010_10ns_820_920_120keV_resonances_BGm.root resonance0038.75eV/Egamma_0038.75eV_Mcl2 Error: Symbol Eg[j][k] is not defined in current scope C:\Users\Carrie\Documents\Working\viewspectra.C(61) Error: Failed to evaluate Eg[j][k]->GetXaxis Error: Failed to evaluate Eg[j][k]->GetXaxis->FindBin(Qgate1) *** Interpreter error recovered ***

I’ve tried using both full paths to the histogram and using directory navigation…oddly enough with a cd() to the directory name and then gDirectory->ls() I can see all the correct TKeys. I’ve also tried accessing different histograms, with the same errors. As far as I can tell, my sprintf() statements are producing the correct file and histogram names. Any help or suggestions would be appreciated.

TDirectoryFile* resonance0038.75eV resonance0038.75eV KEY: TH1F multiplicity_0038.75eV;1 Multiplicity Distribution KEY: TH1F gammas_0038.75eV_Mcl2;1 Gamma Spectra M=2 [MeV] KEY: TH1F Esum_0038.75eV_Mcl_2;1 Esum Spectra M=2 [MeV] KEY: TH1F gammas_0038.75eV_Mcl3;1 Gamma Spectra M=3 [MeV] KEY: TH1F Esum_0038.75eV_Mcl_3;1 Esum Spectra M=3 [MeV] KEY: TH1F gammas_0038.75eV_Mcl4;1 Gamma Spectra M=4 [MeV] KEY: TH1F Esum_0038.75eV_Mcl_4;1 Esum Spectra M=4 [MeV] KEY: TH1F gammas_0038.75eV_Mcl5;1 Gamma Spectra M=5 [MeV] KEY: TH1F Esum_0038.75eV_Mcl_5;1 Esum Spectra M=5 [MeV] KEY: TH1F gammas_0038.75eV_Mcl6;1 Gamma Spectra M=6 [MeV] KEY: TH1F Esum_0038.75eV_Mcl_6;1 Esum Spectra M=6 [MeV] KEY: TH1F gammas_0038.75eV_Mcl7;1 Gamma Spectra M=7 [MeV] KEY: TH1F Esum_0038.75eV_Mcl_7;1 Esum Spectra M=7 [MeV] KEY: TH1F Egamma_0038.75eV_Mcl2;1 Egamma in multiplicity 002, BG subtracted KEY: TH1F Egamma_0038.75eV_Mcl3;1 Egamma in multiplicity 003, BG subtracted KEY: TH1F Egamma_0038.75eV_Mcl4;1 Egamma in multiplicity 004, BG subtracted KEY: TH1F Egamma_0038.75eV_Mcl5;1 Egamma in multiplicity 005, BG subtracted KEY: TH1D m_raw_38.8eV;1 KEY: TH1D m_final_38.8eV;1 root [3]

-CLW
viewspectra.C (3.29 KB)
justbinedges.txt (1.79 KB)
Mo97_2010_10ns_820_920_120keV_resonances_BGm.root (1.93 MB)

In order to find source code bugs, always try to compile your code (even if you plan to use it as an interpreted macro) using something like: `root-config --cxx --cflags` -O2 -W -Wall -c viewspectra.C or, what’s even easier, try to precompile it using ACLiC: root [0] .L viewspectra.C++
viewspectra.C (3.33 KB)