TProfile::SetBin* and GetBin* not working to "fill" prof.his

Dear all.

I explain first the SITUATION.

There’s a function f=f(i,j), i,j integers. For a j fixed value in a set { j }, I have TProfile histograms of f vs i, let’s call it hprof_j.

The binning is the same for all hprof_j: same number of bins, nBins_i, and same extreme values in i-axis, i_min and i_max, so we have the same bin number associated with the same value in i-axis for all hprof_j.

Those hprof_j is the information I have.

Now, if we imagine an j-axis perperdicular to i-axis, we can vizualise a TProfile2d, with f vs (i,j). I would like to do two things:

a) Define a TProfile2d, hprof2d, with the same number of bins in i-axis, nBins_i, and same extreme values in i-axis, i_min and i_max, and with nBins_j and j_min, j_max in j-axis.

b) In a loop over j, get the BinEntries, BinContents and BinErrors (in this order) from hprof_j at a given i value in i-axis (another internal loop here over bins in i-axis), and then set the same content, entries and errors for the bin at the coordinate (i,j) ----> f vs (i,j)

c) At the end of the routine, there should be a TProfile2d that for j fixed, gives an identical TProfile as the hprof_j.

  1. This is the most important thing I’d like to do: I’d like to obtain a set of hprof_i, so that for a i fixed value, I have a TProfile, f vs j.

a) Define a TProfile, hprof_i, i fixed value, with nBins_j and j_min, j_max.

b) Something like this: to have a vector of all hprof_j. Loop over j, take a hprof_j and get BinEntries, BinContents and BinErrors at i value in i-axis of hprof_j, and then set those values for bin at value j in j-axis of hprof_i just defined.

c) End up with set of hprof_i, f vs j.

Now, the PROBLEM:

Just to try out the TProfile::GetBinEntries(), TProfile::GetBinContent(), TProfile::GetBinError(), TProfile::SetBinEntries(), TProfile::SetBinContent(), TProfile::SetBinError(), I created a TProfile hprof which I filled and then created an empty one, hprof2.

The idea is to make hprof2 the exact profile hist. than hprof by using the SetBin* and GetBin* methods. However, it does not work.

The problem here, is that I just have as information the BinContent, BinError and BinEntries from the hprof_j’s, but I do not have the actual entries values with which hprof_j were filled, so I cannot use TProfile::Fill() to fill hprof_i’s just respecting coordinates.

Any ideas?

I attach a macro that illustrates the problem.

Thanks in advance!!!
example.C (2.36 KB)