#include "Riostream.h" void basic() { ifstream in; in.open("all_h130before_out.txt"); Float_t x,y,z; char tag[2]; Int_t nlines = 0; TFile *f = new TFile("all_h130before_66_rect.root","RECREATE"); TH2F *h1 = new TH2F("h2","xy distribution",6,0,6,6,0,6); TNtuple *ntuple = new TNtuple("ntuple","data from ascii file","x:y:z"); while (1) { cout << "read a line"<> x >> y >> z ; if (!in.good()) break; h1->Fill(x,y); ntuple->Fill(x,y,z); nlines++; } printf(" found %d points\n",nlines); in.close(); f->Write(); } void sammon() { ifstream in; in.open("QG.sam"); Float_t x,y,pos; // char tag[2]; Int_t nlines = 0; TFile *f = new TFile("sammon_66_rect.root","RECREATE"); TH2F *h2 = new TH2F("h2","xy distribution",24,-6,6,24,-6,6); TNtuple *sammon = new TNtuple("sammon","Map structure","x:y:pos"); while (1) { pos = nlines; cout << "read a line"<> x >> y ; if (!in.good()) break; h2->Fill(x,y); sammon->Fill(x,y,pos); nlines++; } printf(" found %d points\n",nlines); in.close(); f->Write(); }