Re: Dividing/Multiplying TProfile Histograms

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Mon, 29 Oct 2007 21:11:11 +0100


see example below

Rene Brun

void pprof() {

   TProfile *p1 = new TProfile("p1","",100,-3,3);
   TProfile *p2 = new TProfile("p2","",100,-3,3);
   TProfile *p3 = new TProfile("p3","",100,-3,3);
   TRandom3 r;
   for (Int_t i=0;i<10000;i++) {
      double r1 = r.Gaus(0,1);
      double r2 = r.Gaus(0,1);
      double ry = r1*r1+r2*r2;
      p1->Fill(r1,ry);
      p2->Fill(r2,ry);
      p3->Fill(r1,r1+ry);

   }
   p2->Divide(p3);
   TH1D *h1 = p1->ProjectionX();
   TH1D *h2 = p2->ProjectionX();
   h1->Multiply(h2);
   TCanvas *c1 = new TCanvas("c1","c1",600,800);
   c1->Divide(1,3);
   c1->cd(1); p1->Draw();
   c1->cd(2); p2->Draw();
   c1->cd(3); h1->Draw();

}

Deepak Kar wrote:
> Hi,
>
> I am working with three TProfile histograms, I want to divide
> histogram 2 by histogram 3, get the bin by bin ratio and multiply
> histogram 1 (bin by bin) by the ratios obtained earlier. I tried to
> use
> hist2.Divide(hist3)
> but then if I try hist1.Multiply(hist2)
> I end up with
> Error in <TProfile::Multiply>: Multiplication of profile histograms
> not implemented
>
> I am sure there must be a better way to implement this. Please help.
> Thanks a lot.
> Deepak
>
> P.S - I am using Root version 4.00/08 in CDFSOFT 6.1.4.
>
>
Received on Mon Oct 29 2007 - 21:11:32 CET

This archive was generated by hypermail 2.2.0 : Tue Oct 30 2007 - 11:50:01 CET