Thanks Philippe, I should have remembered, I'm using ROOT v3.01/06 on an Intel PC running Red Hat 6.2. Yes, Glen's codes run fine when run as macros in an interactive session, but simply cutting and pasting them into a very simplistic C++ code like: #include<iostream.h> #include<iomanip.h> #include<fstream.h> #include<stdio.h> #include <stdlib.h> #include<math.h> //ROOT Headers #include "TROOT.h" #include "TFile.h" #include "TNetFile.h" #include "TRandom.h" #include "TTree.h" #include "TBranch.h" #include "TClonesArray.h" #include "TStopwatch.h" int main(int argc, char **argv) { Float_t na[10][10]; TFile file("adc.root"); TTree *tree = new TTree("tree"); 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]); } return 0; } This doesn't compile. The problem seems to be with the line: TTree *tree = new TTree("tree"); This doesn't appear in Glen's code, but something like this appears to be neccessary in a C++ program otherwise the compiler complains about 'tree' being undefined in the next line, i.e. leaving this line out produces: twodread.C: In function `int main(int, char **)': twodread.C:25: `tree' undeclared (first use this function) on compilation. Equally, using a line like TTree *tree = (TTree*)file->Get("tree") as used in the examples of reading trees in the manual doesn't compile properly either. Hope this makes things clearer, Thanks, Ben Morgan. -- ------------------------------------------------------------------------------- Mr. Ben Morgan Postgraduate Student University of Sheffield Department of Physics & Astronomy Hicks Building Hounsfield Road Sheffield S3 7RH -------------------------------------------------------------------------------
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:08 MET