Conversion of 2D histogram into a 1D array

I have a 2D histogram with total bins on x = 40, on y = 72. As this histo is 2D, I want to make it 1D by sequencing all the bins 1-after-1. One row will be advanced by the second row (appending row after row), there will be no columns.

How can I do it?
Thankyou :slight_smile:
PS: These all are bin numbers.


for (int ix = 1; ix <= 40; ix++)
  for (int iy = 1; iy <= 72; iy++)
    std::cout << ((ix - 1) * 72 + iy - 1) << " : "
              << YourTH2->GetBinContent(ix, iy) << std::endl;

What will this give, numbers of entities stored in the bin or data stored at each specific point inside the bin?

It will return the content of the bin ix,iy . Which is the number of time this cell (bin) was hit by the Fill method (if the weight of each call to Fill was 1. (default)).

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.