Read data from an ascii file and create a root file with an histogram and an ntuple.
See a variant of this macro in basic2.C.
void basic() {
ifstream in;
in.open(
Form(
"%sbasic.dat",dir.
Data()));
TH1F h1(
"h1",
"x distribution",100,-4,4);
TNtuple ntuple(
"ntuple",
"data from ascii file",
"x:y:z");
while (1) {
if (!in.good()) break;
if (nlines < 5) printf("x=%8f, y=%8f, z=%8f\n",x,y,z);
h1.Fill(x);
nlines++;
}
printf(" found %d points\n",nlines);
in.close();
}
- Author
- Rene Brun
Definition in file basic.C.