#include "Riostream.h" void proton() { // 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 //Author: Rene Brun // read file $ROOTSYS/tutorials/tree/basic.dat // this file has 3 columns of float data ifstream in; in.open("input.dat"); Float_t x,y; Int_t nlines = 0; TFile *f = new TFile("output.root","RECREATE"); TH1F *h1 = new TH1F("h1","ptot distribution",100,0,2); TH2F *h2 = new TH2F("h2","p vs. theta",100,0,80,100,0,2); TNtuple *ntuple = new TNtuple("ntuple","from reduced hddm","ptot:theta"); while (1) { in >> x >> y; if (!in.good()) break; if (nlines < 5) printf("x=%8f, y=%8f\n",x,y); h1->Fill(x); h2->Fill(y,x); ntuple->Fill(x,y); nlines++; } printf(" found %d points\n",nlines); in.close(); f->Write(); }