It looks like a 1D histogram with 10 bins . The only missing parameters are the low and upper limits. The lower limits is negative and the upper posisbitve but that’s all what you said. See the TH1D constructor here: ROOT: TH1D Class Reference
There is several way to do a “mapping” from the 2D array in a 1D array…
You can avoid this “mapping” and fill directly the 1D histogram from the 2D array
but here again there is several ways … can you clarify how the lines and columns should be combined ?
Hello couet,
Yes, I want the lines and columns to be combined this way:
array[][] :low phi = -3, upper phi = 0 (Negative side = 3 bins) and low phi = 0, upper phi = 3 (Positive side = 3 bins)
:low pt = -0.25, upper pt = 0 (Negative side = 30 bins) and low pt = 0, upper pt = 0.25 (positive side = 30 bins)
The above 2D is what I want to map to 1D or fill directly into 1D histogram from the above 2D array above as you mentioned above. Is this clear?
If not clear, could you help me with any code that maps 2D array to 1D array and finally draws a 1D histogram or any code that directly fill the 1D histogram from the 2D array? Thank you…
Then you loop on the1D histogram bins, compute the value v (from the array) to be put in each bin. Use SetBinContent to fill the h1 bins. The pseudo code is:
double v;
for (int i =1, i<= number_of_bins; i++) {
... compute v from the 2D array
h1->SetBinContent(i, v);
}