[ROOT] reading a tree

From: Munir Uzzaman (munir@ucrhi3.ucr.edu)
Date: Tue Oct 31 2000 - 20:55:19 MET


Hi Rooters!

I was trying to read (and draw from) a tree which has members named
"event", "ptot" and many more. when i try to read them in the following
way:

-------------------------------------------------------------------
{
TChain t("trktree");   
t->Add("/scratch3/munir/mini/run09666tree2.root");
TH1F *pid1 = new TH1F("pid1","ptot", 100,0,10);
TH1F *pid2 = new TH1F("pid2","events", 200,3000,5000);
t->Draw("ptot >> pid1");
t->Draw("event >> pid2");
} 
___________________________________________________________________
things work fine. 

BUT, when i do the following 
------------------------------------------------------------------
{
Float_t ptot,event;
TFile *f = new TFile("/scratch3/munir/mini/run09666tree2.root");
TTree *trktree = (TTree *) f->Get("trktree");
TH1F *pid1 = new TH1F("pid1","ptot", 100,0,10);
TH1F *pid2 = new TH1F("pid2","events", 200,3000,5000);

Int_t nrow = trktree->GetEntries();
for (Int_t i =0; i < nrow; i++)
{
  trktree->GetEntry(i);
  trktree->SetBranchAddress("event", &event);
  trktree->SetBranchAddress("ptot", &ptot);
  pid1->Fill(ptot);
  pid2->Fill(event);
}
}
----------------------------------------------------------------------
ptot is ok, BUT ALL ENTRIES FOR "event" ARE 0!!!

I really have no clue why is this happening. I'd really appreciate if
anyone could point me where i am commiting mistake.

Regards,

-munir
 -----------------------------------------------------------------------------
                               M. MUNIRuzzaman
 ------------------------------------------------------------------------------
 Graduate Student         |email:                     |Phone:
 Department of Physics    |munir@bnl.gov              |(909)-787-7401
 University of California |                           |(909)-276-4703(Home)
 Riverside, CA 92521      |web:                       |
 USA                      |www.phenix.bnl.gov/~munir  |
 ------------------------------------------------------------------------------



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