Hi HP, You can do: TClonesArray *arr =0; tree->SetBranchAddress("T", &arr); tree->SetBranchStatus("*",0); tree->SetBranchStatus("f1",1); tree->SetBranchStatus("f2",1); //then in the loop (see below tree->GetEntry(i); or TClonesArray *arr =0; tree->SetBranchAddress("T", &arr); TBranch *bf1 = tree->GetBranch("f1"); TBranch *bf2 = tree->GetBranch("f2"); //then in the loop for (Int_t ev = 0;ev<nentries;ev++) { bf1->GetEntry(i); bf2->GetEntry(i); Int_t n = arr->GetEntriesFast(); for (Int_t i=0;i<n;i++) { Class *c = (Class*)arr->At(i); hist->Fill(c->f1); } } Rene Brun On Fri, 6 Dec 2002, HP Wei wrote: > I have a tree with one branch ("T") into which I populate with > TClonesArray of objects of class CL: > > Class CL : public TObject { > public: > double f1; > double f2; > int f3; > int f4; > > .... > }; > > The split is set to 1 when the tree is filled with data. > > Now, I want to read data from the resulting root file. > As in the tcl.C example, I do the following: > TClonesArray *arr =0; > tree->SetBranchAddress("T", &arr); > tree->GetEvent(event_number); > > This will extract data for f1, f2, f3, and f3... (all data fields defined > in class CL.) > > Suppose I want only f1, and f2. > What is the best way ? > > --HP > >
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:22 MET