Allό to everyone!
I am trying to reproduce a simple spectrum, by loading an ascii file(with only one column) and creating the relevant histogram.
I am using Rene Brun’s code, but it doesn’t seem to be working in my case.
The code I am using is
[code]#include "Riostream.h"
void basic() {
// 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
TString dir = gSystem->UnixPathName(gInterpreter->GetCurrentMacroName());
dir.ReplaceAll(“basic.C”,"");
dir.ReplaceAll("/./","/");
ifstream in;
in.open(Form("%sD800M655.dat",dir.Data()));
Float_t x;
Int_t nlines = 0;
TFile *f = new TFile(“D800M655.root”,“RECREATE”);
TH1F *h1 = new TH1F(“h1”,“x distribution”,100,-4,4);
TNtuple *ntuple = new TNtuple(“ntuple”,“data from ascii file”,“x”);
while (1) {
in >> x;
if (!in.good()) break;
if (nlines < 5) printf(“x=%8f”,x);
h1->Fill(x);
ntuple->Fill(x);
nlines++;
}
printf(" found %d points\n",nlines);
in.close();
f->Write();
}
[/code]
Running this script produces the message
found 0 points
Any ideas on what may be wrong?
Thanks a lot in advance!