I am facing a rather weird problem, when importing an ascii file into root. The file has the following format
9.998780E-01 0.000000E+00
1.999630 0.000000E+00
2.999390 0.000000E+00
3.999150 0.000000E+00
4.998900 0.000000E+00
5.998660 0.000000E+00
6.998410 0.000000E+00
7.998170 0.000000E+00
8.997920 0.000000E+00
9.997680 0.000000E+00
10.997400 0.000000E+00
11.997200 0.000000E+00
12.996900 0.000000E+00
13.996700 0.000000E+00
14.996500 0.000000E+00
15.996200 0.000000E+00
16.996000 0.000000E+00
17.995701 0.000000E+00
18.995501 0.000000E+00
19.995199 0.000000E+00
20.995001 0.000000E+00
21.994801 0.000000E+00
22.994499 0.000000E+00
23.994301 0.000000E+00
I am using the following simple code to draw a histogram.
[code]#include “Riostream.h”
void HistogramFromAscii(char * file_c){
TString file(file_c);
gROOT->SetStyle(“Plain”);
gStyle->SetOptStat(1111);
gStyle->SetOptFit(1111);
TCanvas *c = new TCanvas(“c”, “c”);
c->SetFillColor(5);
c->SetFrameFillColor(10);
TString dir = gSystem->UnixPathName(gInterpreter->GetCurrentMacroName());
dir.ReplaceAll(“HistogramFromAscii.C”,"");
dir.ReplaceAll("/./","/");
ifstream in;
in.open(TString::Format("%s%s.dat",dir.Data(),file.Data()));
Float_t x,y;
Int_t nlines = 0;
Int_t channels=4096;
//TFile *f = new TFile(“HistogramFromAscii.root”,“RECREATE”);
TH1F *h1 = new TH1F(“h1”,“Histogram From Ascii”,channels,1,channels);
//TNtuple *ntuple = new TNtuple(“ntuple”,“data from ascii file”,“x:y:z”);
while (1) {
in >> x >> y;
if (!in.good()) break;
if (nlines < 5) printf(“x=%8f, y=%8f\n”,x,y);
h1->Fill(x,y);
//ntuple->Fill(x,y,z);
nlines++;
}
printf(“Found %d points\n”,nlines);
in.close();
h1->SetLineColor(6);
h1->Draw();
/**h1->SetBins(h1->GetNbinsX(), 0, 1024);
c->Update();
h1->Draw();
h1->Rebin(4);
TString histfilename =TString::Format("%s_Rebined.dat",file.Data());
SingleExportAscii(h1,histfilename);*/
//c->SetLogy();
//c->SaveAs(“alpha_in_Si.pdf”);
}[/code]
The output canvas is the following
I thought that it is very weird, therefore I imported the same file into other software, for instance qtiplot or simNRA and the plot is very different
QTIplot
Why is this happening? What can I do to fix it? Thank you very much in advance!
FC2500.dat (115 KB)