[ROOT] segv when chaining ntuples

From: Colin Bernet (bernet@kph.uni-mainz.de)
Date: Wed Apr 05 2000 - 11:25:52 MEST


Hello Rooters,

I hope somebody can help me, cause I've been working on this
segmentation violation for a few days now !
The code below should read a TFile containing a TNtuple (1st key) and a
TH2F. If the ntuple is found, it is chained. All objects are stored in a
TList.

TROOT root("QuikPlot", "QuikPlot");

int main(int argc, char **argv)
{
  TApplication theApp("App", &argc, argv);

  TChain *fNtuple=NULL;
  const TString tntStr("TNtuple");
  TList *fObjectsInFile=new TList();

  TString filename("/data/Colin/Root_Monitoring/Tfiles/7389.root");

  TFile temp(filename,"READ","Temporary File");

  TIter next(temp.GetListOfKeys());
  TKey *key;

  while (key = (TKey*) next()){

    fObjectsInFile->Add(key->ReadObj());                       <=== A

    cout<<key->GetName()<<endl;
    if(tntStr.CompareTo(key->GetClassName()) == 0){
      fNtuple = new TChain(key->GetName());                   <=== B
      cout << "Test Message: added ntuple in " << filename << " to
chain" <<endl;
    }
  }
  theApp.Run();
  return 0;
}

I get the segv in line A only if line B is executed....
I have root 2.22/10, redhat 5.1 egcs 1.1.1, and absolutely no clue !

cheers,

                Colin



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:22 MET