RE: [ROOT] Question about modular ntuples.

From: Philippe Canal (pcanal@popgtw.fnal.gov)
Date: Thu Oct 26 2000 - 20:31:12 MEST


Hi Susana,

After reviewing your macro I noticed the following:

The histogram you create have very large ranges (they all set to cover
from 0 to 10000).  Some of the variables in your tree have ranges much
smaller.  From example MET_met varies only from 0 to 30.  The consequence
is that the histrogram you create only has 1 bin filled up (the first one).
Since you also are using a large number of bins (1000), the width of the
bin is minimal.  Thus in that case, you histogram is proper but resumed to
a single line that was overlapping the axis line!

Also in your macro, only the variable MET_met and L2CalJet_NclusT were properly
set up.  The interface that you are using on top of ROOT (HepTuple), bunch up
together all the variable of a 'block' into a single branch.  In your case
all the L2CalJet_XXX are in one branch and all the MET_XXX are in an other.

In order to properly set up the reading of your file you need to pass the address
of struct containing all the variables of a block.  For example you need to define:

  struct {
     Float_t         met;
     Float_t         sumet;
     Float_t         xsum;
     Float_t         ysum;
  } MET;
  ....
  t->SetBranchAddress("MET",&MET);
  ....
  met_b3->Fill(MET.met);

Better yet, instead of using MakeCode to create a stub, use MakeClass.
MakeCode does NOT produce proper code for this type of ROOT files.

Philippe.

> -----Original Message-----
> From: owner-roottalk@pcroot.cern.ch
> [mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Susana Cabrera
> Sent: Wednesday, October 25, 2000 4:55 PM
> To: roottalk@pcroot.cern.ch
> Subject: [ROOT] Question about modular ntuples.
> 
> 
> 
> 	Hello,
> 	I am trying to write a CINT program to read some
> 	blocks of my ntuple, here I send to you an example of the booking
> 	of two blocks of this ntuple. 
> 
>   if(_L2_process.value()==true) {
> 
>     _ntuple=&_manager->ntuple("MyNtuple",1);
>     _ntuple->setColumnWise();
>     _ntuple->setDiskResident();
> 
>     _ntuple->columnAt("L2CalJet::NclusT",&_nclusL2Jet,(Int4)1);
>     _ntuple->span("L2CalJet::NclusT",0,_n2clst);
>     _ntuple->columnAt("L2CalJet::sumEtT",&_sumEtL1,(Float4)0.);
> 
>   }
> 
>   if(_Met_process.value()==true) {
>     _ntuple->columnAt("MET::met",&_uncorrMet,(Float4)0.);
>     _ntuple->columnAt("MET::xsum",&_xSum,(Float4)0.);
>     _ntuple->columnAt("MET::ysum",&_ySum,(Float4)0.);
>     _ntuple->columnAt("MET::sumet",&_sumEt,(Float4)0.);
>   }
>   
> 	I can have a look to the leaves. I start clicking on different
> buttons. Finally the canvas appear in the screen without problems.
> 	TFile f("stnmaker.root")
> 	TBrowser b
> 
> 
> 	However, when I try to use the autogenerated code (equivalent of
> PAW's UWFUNC) in my CINT program:
> 
> TFile *file = new TFile("ntuple.root","READ","RUN-II")
> TTree *t;
> file->cd("MyDirectory");
> t = (TTree*)gDirectory->Get("Myntuple");
> t->MakeClass("MyAna")	
> 
> I introduce the next declarations following a similar syntax
> than in MyAna:
> 
> //Declaration of leaves types
>    Int_t           L2CalJet_NclusT;
>    Float_t         L2CalJet_sumEtT;
>    Float_t         MET_met;
>    Float_t         MET_sumet;
>    Float_t         MET_xsum;
>    Float_t         MET_ysum;
> 
> // List of branches
>    TBranch        *b_L2CalJet;
>    TBranch        *b_MET;
> // Set branch addresses
>    t->SetBranchAddress("L2CalJet",&L2CalJet_NclusT);
>    t->SetBranchAddress("MET",&MET_met);
> 
> 
> When I try to access to the information in the branches
> with my loop I can not get the information of the leaves,
> for example, the variable MET_met is always zero.
> 
> 
> void MetAnal() {
>    Int_t nbytes = 0;
>    Int_t i;
> 
> // ...........loop over entries..................
> 
>    Int_t nentries = chain->GetEntries();
>    printf("Total number of entries in chain = %d\n",nentries);
>    for (i=0; i<nentries;i++) {
>      if(i % 1000 ==0) printf("analysed:%d\n",i);
>      nbytes += chain.GetEvent(i);
>      cout << MET_met <<endl;
>    }
> }
> 
> 		Thanks for your help,
> 			Susana Cabrera.
> 
> **************************************************************
> *    Susana Cabrera Urban          cabrera@cdfsga.fnal.gov   *
> *                                                            *
> *    Fermilab                      Tf:  (630)840-5003        *
> *    P.O. Box 500, MS 318          Fax: (630)840-2968        *
> *    Batavia, IL 60510                                       *
> *    U.S.A.                                                  *
> **************************************************************
> 
> 
> 



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:36 MET