TH2Poly::Scale

Dear users,

I was trying to scale TH2Poly histogram, but it didn’t work, and gave a warning

For my local needs I just implemented scale method in a TH2Poly class itself
by

void TH2Poly::Scale( double c1 )
{
  for( int i = 0; i < this->GetNumberOfBins(); i++ )
    {
      this->SetBinContent(i+1, c1*this->GetBinContent(i+1));
    }
}

but this is very uneducated way, and it doesnt take option*, also there might be potential
mistakes in this, that I don’t understand.

I just relay this info, you might want at some point implement this in TH2Poly.

Rafo

You ask a question about “scale” but the error message you sent is about “Add”.

What you did to scale the bins looks ok … I just wondered if that makes sense when all the
bins might have a different shape…

To be checked with Lorenzo.

Thank you Couet for answer,

Yes it is a message about TH2Poly::Add(…), but
since in the scale method there is a call to Add, and also
looks like the addition is also not implemented, therefore
Scale was not working also.

//======From Reference guide===============

Bool_t TH2Poly::Add(const TH1 *, const TH1 *, Double_t, Double_t)
{
   // Replace contents of this histogram by the addition of h1 and h2.

   Warning("Add","Not implement for TH2Poly");
   return kFALSE;
}

Depending on the particular task there might be a need for Scale,
particularly in my case I needed to scale it by a Luminosity to estimate rates
for a particular process.

Rafo

Actually, which ROOT version are you using ? it seems that Add is implemented in 5.34:

root.cern.ch/root/html534/src/TH … tml#XdastB

My root version is also 5.34,

Yes, that particular method is implemented,
but there are 3 Add methods. Other two are not implemented according
to the documentation( lines 330 and 340) of the same link root.cern.ch/root/html534/src/TH … tml#XdastB.

Rafo

Ok I just wanted to check we are speaking about the same version.
I will see if we can add “Scale”.

Thank you!

Done in 5.34 and Trunk.