Newbye: read data


I need to fit data with a complex way. Before I need to read my data (ascii file with multiple columns). How can I start?
I would like to browse the ascii file and select it, and then select the 3 columns that I need to have in 3 arrays.
How can these?


ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided

This was answered several in several ways on this forum. Try to search the forum. Some possible answers could be:

etc …

Can I have an example?
Going to the manual:

I tried:

TTree* tree = (TTree*) gDirectory->Get(atree) ;

but I get an error:

OOT_prompt_0:1:24: error: cannot initialize an array element of type 'void *' with an rvalue of type 'TDirectory *&(*)()'
TTree* tree = (TTree*) gDirectory->Get(atree) ;

I is not a real starting!

$ root
  | Welcome to ROOT 6.19/01         |
  |                               (c) 1995-2019, The ROOT Team |
  | Built for macosx64 on Jun 19 2019, 06:42:38                |
  | From heads/master@v6-19-01-223-g2d06c7712f                 |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |

root [0] TGraphErrors gr("ExampleData.txt");
root [1] gr.Fit("pol3");
 FCN=4.07452 FROM MIGRAD    STATUS=CONVERGED     225 CALLS         226 TOTAL
                     EDM=1.40431e-06    STRATEGY= 1      ERROR MATRIX ACCURATE 
  EXT PARAMETER                                   STEP         FIRST   
  NO.   NAME      VALUE            ERROR          SIZE      DERIVATIVE 
   1  p0           1.74961e+00   9.89681e-01   4.90833e-05   8.07365e-03
   2  p1          -2.34364e+00   1.92118e+00   3.35040e-05   1.87432e-02
   3  p2           1.03847e+00   1.24847e+00   1.89434e-05   4.31488e-02
   4  p3          -5.34380e-02   2.74820e-01   9.60121e-06   9.23138e-02
root [2] gr.Draw()
Info in <TCanvas::MakeDefCanvas>:  created default TCanvas with name c1
root [3] 


$ cat ExampleData.txt 
# x    y    ex    ey
  1.   0.4  0.1   0.05
  1.3  0.3  0.05  0.1
  1.7  0.5  0.15  0.1
  1.9  0.7  0.05  0.1
  2.3  1.3  0.07  0.1
  2.9  1.5  0.2   0.1

@couet can you reproduce this? If so we need to fix the manual - but I’m surprised by this error…

The Roofit doc says:

TTree* tree = (TTree*) gDirectory->Get("atree") ;

and that’s fine:

root [0] TTree* tree = (TTree*) gDirectory->Get("atree") ;
root [1] 

But if you do a blind copy/paste from the pdf doc to the terminal the quotes around “atree” vanish and you get the error @pdupre gets.


fedora 28

I can reproduce the error from the interpertor


Can you copy/paste here the exact command you typed and errors you get ? seems to me you have copy/pasted the command from the pdf file to the terminal and you get the error you posted because the quotes are missing.
If I do that on Mac I also get these errors.

if I copy/paste from the doc, the quotes are missing and I also get:

root [1] TTree* tree = (TTree*) gDirectory->Get(atree) ;
ROOT_prompt_1:1:24: error: cannot initialize an array element of type 'void *' with an rvalue of type 'TDirectory *&(*)()'
TTree* tree = (TTree*) gDirectory->Get(atree) ;

We are now far from your initial question which was “how to read an ascii file and fit”… see the example I posted. Does it answer your question ?

And thanks, @pdupre for noting the issue with the users guide, we’ll have to fix that. I opened for that

It is correct.

You are right, sorry for that.


I am making slow progresses.

Actually, I am look for an example with RooDataSet

It seems that it needs an additional library for the interpreter

@StephanH do we have a nice tutorial for the use of RooDataSet?

the tutorials are here:
Or in $ROOTSYS/tutorials/roofit

  • Basic importing: rf102
    – Trees
    – Histograms
    – Read ascii
  • Importing from Trees with multiple categories / applying cuts: rf401
  • Manipulating datasets: rf402

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

A version of the roofit guide fixing the copy/paste problem as been uploaded here: we will update the official link soon.

…and I’ve updated the copy served from

Thanks, @couet !