Hi Colin,
The TChain constructor changes the current directory.
You must set the current dir after the creation of TChain.
fNtuple = new TChain(key->GetName()); <=== B
temp.cd(); <======
Rene Brun
Colin Bernet wrote:
>
> 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