Re: h2root question

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue Jul 28 1998 - 16:06:37 MEST


lijowski@cosray2.wustl.edu wrote:
> 
>   Hello,
> 
>   Below is output from the h2root program which converting RW HBOOK
>   ntuple into root ntuple. Each event consists of 39 entries.
> 
>  Converting directory //example
>  Converting RWN with ID= 9000, nentries = 1018414
> AutoSave Tree:h9000 after 1.00007e+08 bytes written
> TFile Writing Name=make_cris_ntuple.root.0 Title=HBOOK file: make_cris_ntuple.rz.0 converted to ROOT
> TFile**         make_cris_ntuple.root.0 HBOOK file: make_cris_ntuple.rz.0 converted to ROOT
>  TFile*         make_cris_ntuple.root.0 HBOOK file: make_cris_ntuple.rz.0 converted to ROOT
>   KEY: TTree    h9000;2 CRIS
>   KEY: TTree    h9000;1 CRIS
> 
>  Reading of the converted ntuple with a macro
> {
>    //  read HBOOK generated ntuple and print number of entries
> 
>    gROOT->Reset();
> 
>    gBenchmark->Start("test_root_ntuple");
>    //
>    // Connect CRIS ROOT ntuple demonstration file generated by h2root
>    // from make_cris_ntuple.rz file
>    TFile *f1 = new TFile("/data3/users/lijowski/make_cris_ntuple.root.0");
>    f1 -> ls();
> 
> // connect a tree to an ntuple in the input file
>    TTree *t9000 = (TTree*)f1 -> Get("h9000;1");
>    t9000 -> Print();
> 
>    Int_t  Noevents = t9000 -> GetEntries();
>    printf(" No of Events %d\n", Noevents);
> 
>    gBenchmark->Show("test_root_ntuple");
> }
>  shows number of entries in the root ntuple to be equal to 636543.
> 
>   Is data lost during the conversion process or is it something else?
> 

During the h2root conversion, Root automatically saves the Tree
header everytime you write 100 Mbytes of data. In your case,
you get two cycles.
In your reading program, you should not specify a cycle number
when you get the Tree header from the file. By specifying cycle 1
you read the status of your Tree after 100 Mbytes of data.
Simply do:
  TTree *t9000 = (TTree*)f1->Get("h9000");

Rene Brun



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