Re: I/O problems?

From: Fons Rademakers (rdm)
Date: Sun Aug 10 1997 - 01:25:20 MEST


Hi Daniel,

   don't use .reset to reset the interpreter environment. As
Valery explained before .reset is a "pure" CINT command that will
wipe the CINT environment without paying attention to ROOT. Afterwards
ROOT tries to access objects that have been deleted by CINT. A better
way to clean the environment (both ROOT and CINT) is to use gROOT->Reset().

Cheers, Fons.

> 
> Hi!
> I've read <A HREF="http://root.cern.ch/root/roottalk/0676.html">
> Marc Mueller's question</A>. I tried about the same, and I failed
> too.  But if I create the 'ifstream' class with 'new', it seems to work,
> while I don't want to reset the interpreter with the '.reset' command.
> My macro is:
> 
> {
> gROOT->LoadMacro("fstream.h");
> TCanvas *c = new TCanvas("c", "The Hello Canvas", 400, 400);
> const Int_t NSLICES=512; 
> Int_t h;
> Int_t value;
> TH1D *histogram[NSLICES]; 
> Text_t hname[100];  
> for(h=0;h<NSLICES;h++)  // creating histogram array
> {
>   sprintf(hname,"h_%i",h);
>   histogram[h]=new TH1D(hname,hname,71,109.5,170.5);
> }  
> ifstream *input_file=new ifstream("data");
> while(1)   // fill histograms
> {
>   *input_file>>h>>value;
>   if(input_file->eof()) break;
>   histogram[h]->Fill(value);
> }
> return;
> }
> 
> 
> After running this macro I can draw the histograms in the command line:
> histogram[100]->Draw();
> But if I say  '.reset' I get the following message:
> 
>  *** Break *** segmentation violation
> 
> ( 0)  0xc0d3ede0   StackTrace__11TUnixSystemFv + 0x28
> [/afs/cern.ch/na49/library/local/ROOT/root/lib/libUnix.sl]
> ( 1)  0xc0d3d8e8   DispatchSignals__11TUnixSystemF8ESignals + 0x150
> [/afs/cern.ch/na49/library/local/ROOT/root/lib/libUnix.sl]
> ( 2)  0xc0d3c5c0   SigHandler__F8ESignals + 0x28
> [/afs/cern.ch/na49/library/local/ROOT/root/lib/libUnix.sl]
> ( 3)  0xc0d407f8   sighandler__Fi + 0x58
> [/afs/cern.ch/na49/library/local/ROOT/root/lib/libUnix.sl]
> ( 4)  0xc012f2e0   _sigreturn  [/usr/lib/libc.1]
> 
> and so on. What's wrong with this macro?
> Thanks 
>    Daniel
> 
> 
> 


-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland          Phone: +41 22 7679248
E-Mail: Fons.Rademakers@cern.ch              Fax:   +41 22 7677910



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:26:20 MET