How to read data from ascii file into an array?

Hi, all:

I would like to know in RooFit, how to read the data from an ascii file into an array? In ascii/txt file, there are lots of lines. Each line has one number. Thanks in advance.

Hi

(Sorry for the late reply - I just returned from vacation )

You can read in ascii files into a RooDataSet using the RooDataSet::read()
method.

RooRealVar x(“x”,“x”,-10,10) ;
RooDataSet* data = RooDataSet::read(“file.txt”,x) ;

Note that any file entry with a number that does not fit in the range of (x[-10,10] in the
above example), will be excluded from the dataset. An addtional “v” argument to read()
will print more information on events being rejected.

Wouter

Hi,

Something related to this:
Can I use RooDataSet to import data from an ascii file, where I have one column as data and another as errors on corresponding data point… in short I have columns X, Y and errY.

How do I do it?

with regards,
Nikhil

1 Like

Actually, from the ascii file
which has 16 columns separated by a \tab and some lines have a “#” and must be ignored (but I would like that the number of columns be unknown), I need to select 3 (later 5) columns
and create 3 (later 5) arrays (all the same size but undetermined).
Let say, x, y1 and y2 (no limit associated).
I will need to display these arrays (x,y1) or (x, y2), and also use them
for fitting with a complex function which I have to build.
Which call should I use? vector?