Dear Rooters, I am trying to figure out how to read a single element, row, or column of data from 2D array in a TTree without reading the entire array for each event. As shown in the example below, I can read any element from the array I wish, but by using the command b->GetEvent(i), the entire array is read. Is there a way to avoid reading the entire event/array? Macro to create sample data set. { gROOT->Reset(); Float_t adc[10][10]; TFile *file=new TFile("adc.root","RECREATE"); TTree *tree=new TTree("tree","Testing still"); tree->Branch("adc",adc,"adc[10][10]/F"); for (Int_t k=0; k<150; k++) { for(Int_t j=0; j<10; j++) { for(Int_t i=0; i<10; i++) adc[i][j]=k*100+j*10+i; } tree->Fill(); } tree->Write(); tree->Print(); file->Close(); } Macro to read a element [1][1] from each event of the data set. { gROOT->Reset(); Float_t na[10][10]; TFile file("adc.root"); TBranch *b = tree->GetBranch("adc"); TLeaf *l = b->GetLeaf("adc"); tree->SetBranchAddress("adc",&na); for (Int_t i=0; i<150; i++) { b->GetEvent(i); printf("na[1][1] = %f, ",na[1][1]); } }
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:29 MET