[ROOT] TH2F::GetBinContent overwrite argument?

From: Fedor Ratnikov (ratnikov@fnal.gov)
Date: Fri Jun 01 2001 - 04:48:07 MEST


Hi,
I faced the strange behavior.
Assuming two 2D histograms
h_ptshouldervsn_eff and h_ptshouldervsn
are defined, I run the function (2deff.C file):

void twodeff ()
{
  h_ptshouldervsn_eff.Reset ();
  int in = 0;
  for (; in < 3; in++) {
    double sum = 0.;
    int ip = 3;
    while (--ip >= 0) {
      printf ("before: ip %d in %d sum %f\n", ip, in, sum);
       sum += h_ptshouldervsn.GetBinContent(ip, in);
       printf ("after: ip %d in %d sum %f\n",
        ip, in, sum);
       h_ptshouldervsn_eff.SetBinContent(ip, in, sum);
    }
  }
}

.root [16] .L 2deff.C
root [17] twodeff()

It results to infinite loop:

...
after: ip 0 in 0 sum 0.000000
before: ip 2 in 1 sum 0.000000
after: ip 2 in 0 sum 0.000000
before: ip 1 in 0 sum 0.000000
after: ip 1 in 0 sum 0.000000
before: ip 0 in 0 sum 0.000000
after: ip 0 in 0 sum 0.000000
before: ip 2 in 1 sum 0.000000
after: ip 2 in 0 sum 0.000000
before: ip 1 in 0 sum 0.000000
after: ip 1 in 0 sum 0.000000
...

I conclude that GetBinContent overwrites second
argument. Why?

                  Thanks, Fedor.


root [17] twodeff() --
MS318(CDF/Rutgers) Fermilab, Batavia, IL 60510 USA
Tel.:+1(630)840-8435           Fax:+1(630)840-6315



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:47 MET