Can someone explain what to me seems like an inconsistency in the behavior of root?
{
TH1F* h = new TH1F("hhhh", "hhhh", 10, 0, 0);
TH1F* j = new TH1F("jjjj", "jjjj", 10, 0, 0);
j->SetName("qqqq");
Double_t a[10];
Double_t b[10];
TGraph*g = new TGraph(10, a, b);
g->SetName("gggg");
}
Now I run invoke root with this script. I understand and/or accept the behavior of the histograms and their availability in the interpreter by either the variable reference or their named value. I notice that when I rename “jjjj” to “qqqq” that gROOT can find “qqqq”. Why is it that gROOT can’t find “g” or “gggg” but “g” is available in this session?
I suppose that my somewhat aimless meanderings are behind this one question: How do I get TGraphs to behave in the interpreter like histograms? (I want to make many TGraphs and SetName to varying strings to access them on the command line. If I write them to a root file I can get them by name like “gggg” but I don’t want to have to do that intermediate writing).
[mwoods ~] $ root roottest.cc
root [0]
Processing roottest.cc...
root [1] h
(class TH1F*)0x7f9ddaa6e380
root [2] hhhh
(class TH1F*)0x7f9ddaa6e380
root [3] j
(class TH1F*)0x7f9ddaa6ea50
root [4] jjjj
Error: Symbol jjjj is not defined in current scope (tmpfile):1:
*** Interpreter error recovered ***
root [5] qqqq
(class TH1F*)0x7f9ddaa6ea50
root [6] g
(class TGraph*)0x7f9ddaa79480
root [7] gggg
Error: Symbol gggg is not defined in current scope (tmpfile):1:
*** Interpreter error recovered ***
root [8] .ls
OBJ: TH1F hhhh hhhh : 0 at: 0x7f9ddaa6e380
OBJ: TH1F qqqq jjjj : 0 at: 0x7f9ddaa6ea50
root [9] gROOT->Get("hhhh")
(class TObject*)0x7fb4d1a6e4d0
root [10] gROOT->Get("h")
(class TObject*)0x0
root [11] gROOT->Get("qqqq")
(class TObject*)0x7fb4d1a6eba0
root [12] gROOT->Get("gggg")
(class TObject*)0x0
root [13]