pdupre
June 19, 2019, 12:14pm
1
Hello,
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?
Thank
ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided
couet
June 19, 2019, 12:27pm
2
This was answered several in several ways on this forum. Try to search the forum. Some possible answers could be:
dperego,
This question should be asked on a C++ forum (see link below). C++ can handle this easily and I’ve included a link to a page where I frequent often as reference.
For each line you will need to search for the delimiter or the eos character.
I don’t have any code to show you, but it is easy enough to find on the web.
Dave
cplusplus.com/reference/string/
cboard.cprogramming.com/forumdisplay.php?f=3
Dear Developers,
I am trying to plot 4th column of “inputs.lhco” file and when i run “input.c” file i get following error
"Error in : unexpected character or eof found "
Kindly help me in solving this issue.
Thanks.
Regards,
Nab
nab.zip (1.1 MB)
Step 1: Check the documentation http://root.cern.ch/root/html/TGraph.html#TGraph:TGraph@10
Step 2: There is a hint on how to extract specific columns only.
root [3] TGraph g1("test.txt", "%lg %lg")
root [4] TGraph g2("test.txt", "%lg %*lg %lg")
root [5] TGraph g3("test.txt", "%lg %*lg %*lg %lg")
etc …
pdupre
June 19, 2019, 12:30pm
3
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!
couet
June 19, 2019, 12:46pm
4
pdupre:
Can I have an example?
$ root
------------------------------------------------------------
| Welcome to ROOT 6.19/01 https://root.cern |
| (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
Axel
June 19, 2019, 1:40pm
5
@couet can you reproduce this? If so we need to fix the manual - but I’m surprised by this error…
couet
June 19, 2019, 1:59pm
6
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.
pdupre
June 19, 2019, 2:29pm
7
Sure,
fedora 28
I can reproduce the error from the interpertor
root
couet
June 19, 2019, 2:41pm
8
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) ;
couet
June 19, 2019, 2:44pm
9
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 ?
Axel
June 19, 2019, 2:50pm
10
And thanks, @pdupre for noting the issue with the users guide, we’ll have to fix that. I opened https://sft.its.cern.ch/jira/browse/ROOT-10195 for that
pdupre
June 19, 2019, 2:57pm
11
It is correct.
You are right, sorry for that.
pdupre
June 19, 2019, 3:36pm
12
Yes,
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
Axel
June 20, 2019, 2:32pm
13
@StephanH do we have a nice tutorial for the use of RooDataSet?
Sure,
the tutorials are here:
https://root.cern.ch/doc/master/group__tutorial__roofit.html
Or in $ROOTSYS/tutorials/roofit
Basic importing: rf102
– Trees
– Histograms
– Read ascii
Importing from Trees with multiple categories / applying cuts: rf401
Manipulating datasets: rf402
system
Closed
July 4, 2019, 4:06pm
15
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
couet
September 18, 2019, 3:36pm
16
A version of the roofit guide fixing the copy/paste problem as been uploaded here:
https://sft.its.cern.ch/jira/browse/ROOT-10195 we will update the official link soon.
Axel
September 18, 2019, 3:55pm
17