00001 #include "Riostream.h"
00002 void basic() {
00003
00004
00005
00006
00007
00008
00009
00010 TString dir = gSystem->UnixPathName(gInterpreter->GetCurrentMacroName());
00011 dir.ReplaceAll("basic.C","");
00012 dir.ReplaceAll("/./","/");
00013 ifstream in;
00014 in.open(Form("%sbasic.dat",dir.Data()));
00015
00016 Float_t x,y,z;
00017 Int_t nlines = 0;
00018 TFile *f = new TFile("basic.root","RECREATE");
00019 TH1F *h1 = new TH1F("h1","x distribution",100,-4,4);
00020 TNtuple *ntuple = new TNtuple("ntuple","data from ascii file","x:y:z");
00021
00022 while (1) {
00023 in >> x >> y >> z;
00024 if (!in.good()) break;
00025 if (nlines < 5) printf("x=%8f, y=%8f, z=%8f\n",x,y,z);
00026 h1->Fill(x);
00027 ntuple->Fill(x,y,z);
00028 nlines++;
00029 }
00030 printf(" found %d points\n",nlines);
00031
00032 in.close();
00033
00034 f->Write();
00035 }