Re: Combining several 1d histograms into a single 2d histogram

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Fri, 27 Jan 2006 19:14:24 +0100 (MET)


see example below

Rene Brun

void h12() {

    TRandom r;
    TH1F *h1[5];
    for (Int_t i=0;i<5;i++) {

       h1[i] = new TH1F(Form("h1%d",i),"test",100,0,100);     }
    for (Int_t j=0;j<10000;j++) {

       for (Int_t i=0;i<5;i++) {
          h1[i]->Fill(r.Gaus(40+5*i,1.1*(i+1)));
       }

    }
    TH2F *h2 = new TH2F("h2","eta vs Pt",100,0,100,5,0,5);     for (Int_t i=0;i<5;i++) {
       for (Int_t j=0;j<100;j++) {
          h2->SetBinContent(j+1,i+1,h1[i]->GetBinContent(j+1));
       }

    }
    TCanvas *c1 = new TCanvas("c1","c1",10,10,800,1000);     c1->Divide(1,5);
    for (Int_t i=0;i<5;i++) {
       c1->cd(i+1);
       h1[i]->Draw();

    }
    c1->cd(5);
    h2->Draw("box");
}

On Fri, 27
Jan
2006, Venkatesh Kaushik wrote:

> Hi All,
> I have 5 1d histograms. They are efficiencies that I
> have determined. For example, I have pT as a
> function of detector eta. There are 5 detector eta
> regions. So I have 5 1d histograms. I want to merge
> them into a single 2d histogram of pT vs detector eta.
> Is there a way to merge several 1d histograms into
> a single 2d histogram?
>
> My question is rather basic, but this is the best I could
> describe.
> Thank you in advance for your inputs.
> Venkatesh
>
Received on Fri Jan 27 2006 - 19:14:31 MET

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:57 MET