[ROOT] trouble with TFile in compiled code

From: Jean-Pierre Ernenwein (rnenwein@in2p3.fr)
Date: Mon Apr 08 2002 - 19:24:53 MEST


Hello all


I have a very simple class with a TFile and a TTree, I would like to
use it to fill an histogram, but when I try to access this histogramm, I
have
segmentation violation (call to NEH() method) :

class Run : public TNamed 
{
 private:
  TH1F     *fh;
 public:
  Run()
  {
    TFile  f("essai.root");
    TTree* t=(TTree*)f.Get("essait"); 
    Float_t x;
    t->SetBranchAddress("X",&x);
    fh=new TH1F("essai","essai",100,0.,1.);
    for (Int_t i=0; i<t->GetEntries();i++) 
    {            
          t->GetEntry(i); fh->Fill(x);	      	 
    }  
    cout <<  fh->GetEntries() << endl;   
  };    
  virtual ~Run();  
  Stat_t NEH(){return fh->GetEntries();};
 
  ClassDef(Run,1)
}; 


in root I have :

root [0] gSystem->Load("libess.so");
root [1] Run a;                     
100
root [2] a.NEH();                   
<TCanvas::MakeDefCanvas>: created default TCanvas with name c1
Error: Symbol nan is not defined in current scope  FILE: LINE:0
*** Interpreter error recovered ***

 *** Break *** segmentation violation


(I don't ask for a plot)
the problem is similar in all last root versions

has someone an answer

BR



           Jean-Pierre Ernenwein, GRPHE
	   Universite de Haute Alsace, IUT Mulhouse, dept SGM / IReS Strasbourg
	   Tel: 03 89 33 75 56 (IUT) / 03 88 10 66 19 ou 66 77 (IReS) 
           Portable : 06 89 26 40 46



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:48 MET