Safinaz
1
Hi
I have two text files that root can not read , i use TGraph class by termianl , and
the files are right on the directory root installed on :
TGraph *t= new TGraph(“plot.txt”);
t->Draw();
when i type that the TCanvas open empty or when i open them from the browser.
the first file is plot.txt generated by calchep package and the second file
are just a list of points (x,y).
Thanks,
S.
pamputt
2
Hi, could you attach your two text files here. Just to check if something is wrond with these files.
couet
3
Can you tried :
(in the most recent ROOT versions t->Draw(); works now)
Safinaz
4
I tried : t->Draw(“alp”); but it gave error : illegal number of points (0)
The sample of the first file : " it’s generated by Calchep and its extenstion is .txt"
#type 0 %curve
#title
#xName
#xMin 3.900000E+03
#xMax 1.189000E+04
#xDim 800
#yName Cross section [pb]
#— GNUPLOT section —
#GNUPLOT set key off
#GNUPLOT set title ’ '
#GNUPLOT set xlabel ‘’
#GNUPLOT set ylabel ‘Cross section [pb]’
#GNUPLOT plot[3900:11890] ‘plot_1.txt’ using (3900 +$0*10):1 w l
#— PAW section —
#PAW TITLE ’ '
#PAW vector/Create X1(800)
#PAW sigma X1=ARRAY(800,3900#11890)
#PAW vector/Create Y1(800)
#PAW vector/Read Y1 ‘plot_1.txt’ ’ ’ ‘OC’ ‘-/#/’
#PAW GRAPH 800 X1 Y1
#— starting of data —
#— F —
0.000000E+00
0.000000E+00
1.925100E+00
2.712700E+00
3.310500E+00
3.809000E+00
4.243400E+00
4.631800E+00
4.985100E+00
5.310400E+00
5.612600E+00
The sample of the second file is :
5.0000E+00 1.0000E+01
1.5000E+01 3.2000E+01
2.5000E+01 5.4000E+01
3.5000E+01 5.6000E+01
4.5000E+01 7.1000E+01
5.5000E+01 6.4000E+01
6.5000E+01 7.1000E+01
7.5000E+01 6.3000E+01
8.5000E+01 7.1000E+01
9.5000E+01 7.9000E+01
So can root get these formats …
Thanks,
S.
couet
5
The 2nd format works for me:
$ cat a.txt
5.0000E+00 1.0000E+01
1.5000E+01 3.2000E+01
2.5000E+01 5.4000E+01
3.5000E+01 5.6000E+01
4.5000E+01 7.1000E+01
5.5000E+01 6.4000E+01
6.5000E+01 7.1000E+01
7.5000E+01 6.3000E+01
8.5000E+01 7.1000E+01
9.5000E+01 7.9000E+01
root [0] TGraph *t= new TGraph("a.txt");
root [1] t->Print()
x[0]=5, y[0]=10
x[1]=15, y[1]=32
x[2]=25, y[2]=54
x[3]=35, y[3]=56
x[4]=45, y[4]=71
x[5]=55, y[5]=64
x[6]=65, y[6]=71
x[7]=75, y[7]=63
x[8]=85, y[8]=71
x[9]=95, y[9]=79
root [2] t->Draw("AL");
Info in <TCanvas::MakeDefCanvas>: created default TCanvas with name c1
root [3]
pamputt
6
The error comes from the fact that there is only one column in your file. What do you want to plot? TGraph cannot guess what is the second column.
couet
7
Yes the first format is completely wrong. I did not try, even. The 2nd one with 2 columns is fine.
Safinaz
8
Hi,
It’s working thanks
, for the first format I can just get it as a form of x and y.
Bests,
S.