RE: reading ntuple

From: Philippe Canal <pcanal_at_fnal.gov>
Date: Wed, 06 Apr 2005 15:34:56 -0500


Hi Claus,

> cout << "et " << et[0] << endl; //works fine when loading whole tree

This problaby means that Empt is actually a variable size array. You also have to read the branch that holds the size of the array for this to work properly.

Cheers,
Philippe.

-----Original Message-----
From: owner-roottalk_at_pcroot.cern.ch [mailto:owner-roottalk_at_pcroot.cern.ch] On Behalf Of Claus Horn
Sent: Monday, April 04, 2005 10:46 AM
To: roottalk_at_pcroot.cern.ch
Subject: [ROOT] reading ntuple

Dear ROOTers,

consider the folowing test program:

  TFile f("susygenerated.root");
  TTree * t = f.Get("h1");
  Int_t run(0);
  Float_t et[4] = { 0,0,0,0 };

  t->SetBranchAddress("Empt",et);
  t->SetBranchAddress("Runnr",&run);

  TBranch * b = t->GetBranch("Empt");
  TBranch * b2 = t->GetBranch("Runnr");

  b2->GetEntry(22);
  cout << "run " << run << endl; //works fine for non array

  b->GetEntry(22);
  cout << "et " << et[0] << endl; //DOES NOT WORK, GIVES ALLWAY 0

  t->GetEntry(22);
  cout << "et " << et[0] << endl; //works fine when loading whole tree

Do I have to do something different when I want to do branch->GetEntry() for an array?

cherrs,

Claus Received on Wed Apr 06 2005 - 22:34:22 MEST

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:06 MET