Re: 2d Histograms

From: Rene Brun <brun_at_pcroot.cern.ch>
Date: Sat, 2 Apr 2005 00:15:33 +0200 (MEST)


Hi Jorge,

See the short example below

Rene Brun

void haddn() {

   const Int_t nh = 4;
   TH1F *h[nh];
   for (Int_t i=0;i<nh;i++) {

      char name[10];
      sprintf(name,"h%d",i);
      h[i] = new TH1F(name,name,100,-3,3);
      h[i]->FillRandom("gaus",1000*(i+1));
   }
   TH1F *result = (TH1F*)h[0]->Clone("result");    for (Int_t i=1;i<nh;i++) {

      result->Add(h[i],1.1*i);
   }
   result->Draw();
}

On Fri, 1 Apr 2005, Jorge
A.
Benitez wrote:

> Hello,
> I have some root file with 2D Histograms, I got to read and Draw the
> Histograms but now I wanna do some operations with them, and I haven't
> been able to do any ...
> I want to to create something like
> hist4= Constant1*hist1+Constant2*hist2+... + Constant4*Hist4
> Any body have some ideas? I read the manual and it says you can add
> multiply histograms, but I didn't find how, is this feature also
> available for 2D histos?
> Thank you I appreciate any help,
>
> Jorge A.
>
> Here is part of the code I'm using to read the histograms.
>
> TH2F* hist1;
> hist1=(TH2F*)d_plots->Get("LEtaUJetEta_pp");
> plot2dHistogram(hist1,"Beni","Eta lepton","Eta jet",-4.,4.,-4.,4.);
> TH2F* hist2;
> hist2=(TH2F*)d_plots->Get("LEtaUJetEta_pp");
> plot2dHistogram(hist2,"Beni","Eta lepton","Eta jet",-4.,4.,-4.,4.);
>
>
Received on Sat Apr 02 2005 - 00:15:37 MEST

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:06 MET