Hi! I’ve a data file (see attachment data2.txt) first culomun is a mean energy of primary particle of cosmic ray, culomn 2 is the error of the energy, from culomn 3 to culomn 10 I’ve density of particles (photons, electrons, muons and hadrons) @10m and @100 m.
- To plot the data in 4 canvas(so I’ll copy the macro 4 times), each canvas will have 2 graph , where on x-axis
there there is the energy (culomn a) and y-axis the particle density (in one graph @10m and other @100m); for example in the first canvas I need to plot culomn a with culomns c and d, in the second canvas I’ve to plot culomn a with culomns e and f etc.
- To fit the 2 graphs;
- To print in the statistical box on the canvas the fit result parameters and chi square value.
I wrote the macro (see multigraph.c) but
- I don’t know how to set that culomn 2 is the energy error;
- the macro doens’t work because
a) this is the plot (I dont’have the graphs, the fit, the tiles, and the statistical box)
b)I’ve the errors:
dati2.txt (1.92 KB)
multigraph.C (1.84 KB)
I suggest to reduce the problem to the parsing of the input and the creation of a single graph. Once this is achieved, we can move to the multigraph.
A good set of hints and concrete code showing how to parse ascii files can be found here: linuxquestions.org/questions … -c-422806/
First of all, your data file is in Unicode format (should be ASCII)
Then, try with the modified code and data file below, and look at the documentation of TGraph::TGraph(const char *filename, const char *format, Option_t *option)
dati3.txt (973 Bytes)multigraph.C (1.8 KB)
Hi Danilo, I’m reading the link…but it looks like a bit difficult for me…because I don’t know the C very well…
Hi Bertrand, I’ve just seen your reply…now I look your code and the documentation
Hi Bertrand and thanks! I saw your code, I tried it and it works! I modified somthings to have the title, axis titles and the fit in the legend (See attachment test.c), this is the result
i just don’t know how to set error bars from the file…
test.c (2.81 KB)
To set the errors, you have two options. First option: When reading the data file in the constructor, see
TGraphErrors::TGraphErrors(const char *filename, const char *format, Option_t *option)
Second option: Afterwards, for each point, see
TGraphErrors::SetPointError(Int_t i, Double_t ex, Double_t ey)
Hi Bellenot! I looked the link and it works writing for example
where culomns 1-9 are x and all the y and culomns 10-18 are error_x and all errors_y!