Fill TH2F with several TH1F

I have a lot of similar TH1F. They represent the spectrum of a decay at different time. I want to see the peak shift because of the temperature increase in the afternoon.

How can I put the TH1Fs in one TH2F? Now I do:

TH2F *h2 = new TH2F("h2","h2",N_BIN,0.,N_BIN,N_FILE,0.,N_FILE);

for (unsigned int j=0;j<filename.size();++j)
    {
	TH1F *h;
	int tvivo, treal, ch_lo, ch_hi;
	get_data_from_file(filename[j].c_str(),tvivo,treal,ch_lo,ch_hi,h);
        for(int i=0;i<=N_BIN;++i)
            h2->Fill(i,j,h->GetBinContent(i));
    }

but it’s extremely slow. the function get_data_from_file take the data from a filename[j] and create a TH1F called h.

there is some tecnical problem (I can’t modify my previous message), the last two row in the code:

	for(int i=0;i<N_BIN>Fill(i,j,h->GetBinContent(i));

When posting your code, click on “Disable HTML in this post”,
therwise your code will be truncated, or post your code as an attachment

Rene

Hi
I have a problem. I have created a 1D histogram with fMaya_Si_E_x10_cal[i] (attachment) and now I want to plot a 2D histogram with fMaya_Si_E_x10_cal [i] in the y-axis and the number of Silicon detectors in the x-axis. In my case I have 20 Silicons. How can I do that? I want to plot them in a single histogram.
AlphaSi10x.h (11.1 KB)
AlphaSi10x.C (2.69 KB)

Hi,

The easiest is that you update Loop to also create the TH2F as appropriate.

Cheers,
Philippe.