Hello, in order to read histograms by their titles rather than by their names I use a derived class TMyFile, base class: TFile, in which I have defined a member-function (TList *histolist is initialized in the constructor as histolist = GetListOfKeys()): // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> TH1 *TMyFile::get1dimHistoByTitle(TString Title) { TH1 *out = 0; bool foundit; TObject *objbuff; TH1 *h1dimbuff; TKey *listkey; TClass *clinfo; TString clname, htitle; TIter nextentry(histolist); while(listkey = (TKey *)nextentry()) { objbuff = Get(listkey->GetName()); // -- here occasional segmentation fault -- <=== clinfo = objbuff->IsA(); h1dimbuff = (TH1 *)objbuff; htitle = TString(h1dimbuff -> GetTitle()); clname = TString(clinfo -> GetName()); if(foundit = htitle.Contains(Name) && clname.Contains("TH1")) break; } if(foundit) { out = (TH1 *)objbuff; cout << "Found " << out->GetTitle() << endl; } else cout << "Could not find " << Name << endl; return out; } // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Applying it to the same root-files with the same macros, it works smoothly under root 3.00/06, but it crashes (obviously after the line indicated in the source-code) in its second call under 3.01/06 and 3.02/06. I do not understand this behaviour, because in the case of faulty code I would expect crashes in all versions. The totally analogous member-function // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> TH2 *TMyFile::get2dimHistoByTitle(TString Title) { TH2 *out = 0; bool foundit; TObject *objbuff; TH1 *h1dimbuff; TKey *listkey; TClass *clinfo; TString clname, htitle; TIter nextentry(histolist); while(listkey = (TKey *)nextentry()) { objbuff = Get(listkey->GetName()); clinfo = objbuff->IsA(); h1dimbuff = (TH1 *)objbuff; htitle = TString(h1dimbuff -> GetTitle()); clname = TString(clinfo -> GetName()); if(foundit = htitle.Contains(Name) && clname.Contains("TH2")) break; } if(foundit) { out = (TH2 *)objbuff; cout << "Found " << out->GetTitle() << endl; } else cout << "Could not find " << Name << endl; return out; } // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< generates no segmentation-faults. I have compiled all versons from source-code for the target linuxsuse6. Thanks for hints, Kay -- Kay Ulbrich Institut fuer Strahlen- und Kernphysik, Universitaet Bonn Nussallee 14-16 / D-53115 Bonn / Deutschland Tel.: 0228-73-1768 / E-Post: ulbrich@iskp.uni-bonn.de
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:06 MET