The TFile is read because command “f4->ls()” correctly lists the content of the file.
But I get the error:
Error: illegal pointer to class object gX 0x0 1675 print.C:224:
*** Interpreter error recovered ***
I really don’t understand what’s the reason, I don’t see any difference from the working code and the not workin one. Maybe it’s stupid, but could it be the length of the key?
So I copied and pasted the name of the TGraphErrors many times copying it from the output of f4->ls() command.
Precisely, it shows:
[b] KEY: TGraphErrors Ar:CO_{2}:CF_{4} 45:15:40
Thr20-Lat15;1 Ar:CO_{2}:CF_{4} 45:15:40
Thr20-Lat15[/b]
I noticed that the key is printed on two lines, separated in between “45:15:40” and " - Thr".
I checked the TString that gives such name: there’s no newline there.
If I correctly understood this code, I have to set
obj_name = “ThisIsMyGraphsName” ;
In this way I get the same error, because I have to write manually the name of the TGraphErrors.
Anyway I have mixed it with another idea.
This is a bit tricky, but I used the following code:
// get the list of keys
TList *list = (TList *)f4->GetListOfKeys();
if (!list) {
std::cout << "Cannot get the list of TKeys! Aborting..." << std::endl;
return;
}
TObject *obj;
TListIter *it = new TListIter(list,kIterForward);
TString GrName;
while ((obj = it->Next()))
{
TString title = obj->GetTitle();
if ( title.BeginsWith("Ar:CO_{2}:CF_{4}") && title.EndsWith("Thr20-Lat14"))
GrName = obj->GetTitle();
}
cout << GrName << endl;
The Title printed on screen is:
Ar:CO_{2}:CF_{4} 45:15:40
yes your graph names are more like graph titles … you should make a difference … the name is the handle you use to access them so, if there is some control characters in it (I suspect “:” might be one) then you cannot access it by name.