Re: [ROOT] TTree bugs/changes?

From: Glen R. Salo (gsalo@mrcstl.com)
Date: Mon Feb 11 2002 - 01:27:01 MET


Hi Rene,

Thanks for the fix -- the technical support for ROOT has been great! 
However, I still seem to have a problem with my case number 2 as shown
below.

root [0] TFile f("junk.root","recreate");
root [1] TTree *t = new TTree("tree data","T");
root [2] Float_t x;
root [3] t->Branch("x",&x,"x/F");
root [4] x=2;
root [5] t->Fill();
root [6] t->Write();
root [7] f.ls();
TFile**         junk.root
 TFile*         junk.root

root [8] f.Map();
20020210/183340  At:64        N=84        TFile
20020210/183340  At:148       N=368       TTree          CX = 34.38
20020210/183340  At:516       N=1         END

The TTree t does not appear with f.ls() but is included in the f.Map().
If the name of the TTree is changed to "treedata" (i.e., no space) then
all works fine.  Likewise, if the Write() is replaced with Write("t"),
the TTree appears in the file, but it is not listed in memory, i.e.,

root [7] f.ls();
TFile**         junk.root
 TFile*         junk.root
  KEY: TTree    t;1     T

Is this the intended behavior?  Should I not use spaces in the TTree name?

Thanks again for all of your help and support,

Glen

On 10-Feb-2002 Rene Brun wrote:
> Hi Glen
> Problem now fixed in CVS
> 
> Rene Brun
> 
> 
> On Fri, 8 Feb 2002, Glen R. Salo wrote:
> 
>> Hi,
>> 
>> Changes in the way TTree works has broken some of my code.  The changes
>> are given below.  Are these intended changes?  I am using the very
>> latest
>> CVS updates on a RedHat 7.2 linux machine with a completely fresh
>> recompile.
>> 
>> 1.  TTree::SetDirectory(0) does not seem to remove the tree from the
>>     current directory.  Using the following script (and tree1.root from
>>     the tutorials directory), I get: 
>>     {
>>       TFile f("tree1.root");
>>       TTree *t1 = (TTree *)f.Get("t1");
>>       t1->SetDirectory(0);
>>       gDirectory->ls();
>>       f.Close();
>>       t1->Scan();
>>       delete t1;
>>     }
>> 
>>     TFile**         tree1.root
>>      TFile*         tree1.root
>>       OBJ: TTree    t1      a simple Tree with simple variables : 0
>>       KEY: TTree    t1;1    a simple Tree with simple variables
>> 
>>      *** Break *** segmentation violation
>> 
>>     This did not use to happen in an earlier version (3.01/07) of ROOT.
>> 
>> 2.  When naming a TTree, it seems that the first argument cannot
>> contain a
>>     space as illustrated with the following script.  Is this
>>     the intended behavior?
>> 
>>     {
>>       TFile f("junk.root","recreate");
>>       TTree *t = new TTree("tree data","T");
>>       Float_t x;
>>       t->Branch("x",&x,"x/F");
>>       x=2;
>>       t->Fill();
>>       t->Write();
>>       f.ls();
>>       f.Close();
>>     }
>> 
>>     Produces:
>> 
>>     TFile**         junk.root
>>      TFile*         junk.root
>> 
>> 
>> Thanks for your help.
>> 
>> 
>> Glen
>> 



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