Hello, I’ve this Root macro to read an ascii file and to fill aTH3F histogram. scorelemma.cpp (4.6 KB)
The first time I tried it by reading data from this file (just an example file…data aren’t good!)
boxMesh_1.txt (1.8 MB)
and it worked (i.e. the macro reads the lines and I get the plot as you can see here
Now I produced the good files (i.e. good data) by Geant4, for example this one boxMesh_1.txt (147.2 KB)
then I’ve to plot these data. I used this macro to do it, but I’ve a problem, i.e. the macro reads only the last line infinity times as you can see here
Thank you @moneta it worked, but I noticed a problem in the plot.
The data in the txt file are
first culomn z axis
second culomn phi axis
third culomn Radius axis
Fourth culomn Released energy
The values of z,phi,r axis are binned, i.e. I dived the z axis in 10 bins, the R axis in 300 bins and the phi axis in 1 bin, then the phi value is only 0.
When I plot the data in the TH3F I get this image
and you see in the plots looks like that I’ve many events (i.e. the coulor is yellow) when phi=[0.9-1]…but it’s impossible, because in the file I’ve just phi=0, then I should have released energy only at phi=0.
I setted the bin in the Root macro in this way
TH3F *hscoring = new TH3F("hscoring","Released energy",300,0.,300.,1,0.,1.,10,0.,10.);
Hi,
I think what you see is an effect of the projection.
But if you have only one bin in phi, it is useless to create or plot a 3D histogram, but use or convertt to a 2D histogram for plotting.
Do for example:
The error is something else. Probably you are using gPad when is a nullptr. Just do : if (gPad) gPad->Modified()
The 2D plot looks fine for me. It is what you get from the data. If you don’t like you have different options for showing 2d plots. See the THistpainter documentation