Problem when use RooDateSet read ascii

Hi,
I am using RooDataSet::read() to read in data from ascii files (u_1e5.txt).
My txt has only one column of data------x;

I want to achieve the unbinned read data and plot, but it seems to be wrong.
Here is my code:

#include "RooRealVar.h"
#include "RooDataSet.h"
#include "RooConstVar.h"
#include "TCanvas.h"
#include "TAxis.h"
#include "RooPlot.h"
#include "RooWorkspace.h"
#include "TFile.h"

using namespace RooFit;

void readexample()
{
 gSystem->Load("libRooFit");
 RooRealVar x("x", "x", 0, 2.2794);
 RooDataSet *data = RooDataSet::read("u_1e5.txt",x);

 RooPlot *xframe = x.frame(Title("Unbinned data"));
 data->plotOn(xframe);

 TCanvas *c1 = new TCanvas("rf102_dataimport", "rf102_dataimport", 1000, 800);
 gPad->SetLeftMargin(0.15);
 xframe->GetYaxis()->SetTitleOffset(1.4);
 xframe->Draw();

}

The result is

u_1e5.txt (1.7 MB)
Best wishes,
… Chen

I get the graph below on ROOT 6.22-02; maybe you need to update to a more recent version, or there is something wrong with the data file you used (not the same you posted here?).

root [0] .x readexample.C

RooFit v3.60 -- Developed by Wouter Verkerke and David Kirkby
                Copyright (C) 2000-2013 NIKHEF, University of California & Stanford University
                All rights reserved, please read http://roofit.sourceforge.net/license.txt

[#1] INFO:DataHandling -- RooDataSet::read: reading file u_1e5.txt
[#0] ERROR:DataHandling -- RooDataSet::read(static): read error at line 100001
[#1] INFO:DataHandling -- RooDataSet::read: read 100000 events (ignored 0 out of range events)

Hi,
thank you very much.
The wrong is related to the my ascii file.
Now I update my file, my code works well.
Thank you again. :grinning:

Best wishes,
…CHEN

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.