Also, I wanted to plot a topographical contour as N(3rd column) = f(pz,pt) bins with pz along the horizontal and pt the vertical.
Can anyone please help me ?
If you create a TNuple or a TTree using ReadFile as I mentioned before. You will then have a tree with 3 columns pz pt and POT. If you want to see pz vs pt you then do:
I have 1d histogram and I have saved it with “.root” extension. If I zoom it on the x axis to study a particular region, it does not look good unless I increase the bin size. But doing the analysis of ~1hr everytime just to change the x axis range and bin size does not make much sense. How can I change the bin size from the root file?
ps: I know I can change it from the .C file, but I was just curious if I can do it from the root file also as it is much easier.
It is not a matter of “.root file” or “.C file”. We are talking about a 1D histogram here. You create it in a macro (the .C file) and save it for later use in a “.root” file. Once saved in a .root file (a TFile) you cannot change the booking parameters (limits, bin size etc…) like you would do at creation time in the ROOT macro. When you zoom a histogram on the X axis, you will reach a zoom level where there is only a few bins displayed and, at the extreme, only one. I do not understand how “increasing the bin size” would help. It is the opposite I would say. Can you provide some concret example ?
Hello, I would like to kindly ask a question in extension to this.
I would like to access the bin center for each x (pz_bins) and y (pT_bins).
Also, plot the value(here : stats_error) with a different marker style for different value range. I have searched in the past questions but couldn’t find what I exactly want.
I have attached the plot which I attempts along with the code (ask.C (3.2 KB) ) .
As seen from the plot, it stores the value in all the bins. I would like to store only in the bin center of (pz,pT).
If you could help me I would be very grateful.
Statistical error/uncertainty ( stats_error[] in my code ask.C (3.2 KB) ) on measurement of the number of pions in (pz,pT) phase space varies from 0 to 10 (or more) percentage.
I wanted to plot them using different marker style i.e, < 2.5 % (as dot) , between 2.5% and 5% (as circle) and >5% (as plus) in (pz,pT) bins.
I’m sorry if my explanation is not clear.(Please kindly correct me if I’m wrong)
for “he_a/b/c”, you only want the marker at the corresponding bin; then we just need any value in the bin (the value is not important), to plot the marker. Maybe something like this:
for i in x bins {
for j in y bins {
he -> setbincontent(i,j,error); // so the values are shown as colour
if (error < 2.5%) he_a -> setbincontent(i,j,1);
else if (error < 5%) he_b -> setbincontent(i,j,1);
else he_c -> setbincontent(i,j,1);
}
}
// set the marker styles you want for a, b, c:
he_a->SetMarkerStyle(...);
he_b->SetMarkerStyle(...);
he_c...
// draw
he->Draw("colz");
he_a->Draw("same");
he_b->Draw("same");
he_c->Draw("same");
But, for this case "i " will be 0.30 , 0.5, 0.62, …and so on while “j” will be 0.00, 0.10, 0.20 …(if I’m not wrong).
I would want my “i” to be the center of 0.30 and 0.50, 0.50 and 0.62 , 0.62 and … and “j” to be center of "0.00 and 0.10, 0.10 and 0.20, and so on.
I think this works when a histogram is stored in a root file.
you mean like this?
for ( int k = 1; k<=n_pz_bins; k++)
for ( int l = 1; l <= n_pT_bins; l++)
he->SetBinContent(k, l, stats_error[((k - 1) * n_pT_bins + (l - 1))]);
double x = ((TAxis*)he->GetXaxis())->GetBinCenter(k);
double y = ((TAxis*)he->GetYaxis())->GetBinCenter(l);
I see, the markers are not drawn at the bin centres. I don’t know if there’s an option to fix that, but one workaround coule be the “text” option, which is centred; since this shows the value of the bin, and you need 3 markers, you could use values of 1, 0 and -1 in the SetBinContent lines, instead of 1 (for a, b, and c, resp.), then draw with he_a->Draw("same,text"); and so on.
(or use GetBinCenter on “he” and define new histos for a/b/c with these new bins)