Problem when use RooDateSet read ascii

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()
 RooRealVar x("x", "x", 0, 2.2794);
 RooDataSet *data = RooDataSet::read("u_1e5.txt",x);

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

 TCanvas *c1 = new TCanvas("rf102_dataimport", "rf102_dataimport", 1000, 800);


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

[#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)

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,

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