Bug in TGraph2D drawing routine?

Greetings,

I collect points for a TGraph2D from a tree as follows:

    TGraph2D *grexp = new TGraph2D();
    TFile *f = new TFile(fnames[i]);
    TTree *t = (TTree *) f->Get("limit");

    Float_t deltaNLL, par1, par2;
    Int_t nexp=0;

    t->SetBranchAddress("deltaNLL", &deltaNLL);
    t->SetBranchAddress(par1name, &par1);
    t->SetBranchAddress(par2name, &par2);

    for (size_t j = 0, n = t->GetEntries(); j < n; ++j) {
      t->GetEntry(j);
      grexp->SetPoint(nexp++,par1,par2,2*deltaNLL);
    }

Immediately after reading the tree in I print the contents of the graph out:

  double *x = grexp->GetX();
  double *y = grexp->GetY();
  double *z = grexp->GetZ();

  for(int i=0; i<grexp->GetN(); i++)
    printf ("%d\t%f\t%f\t%f\n",i,x[i],y[i],z[i]);

Immediately after this I draw the graph:

  TCanvas *canv = new TCanvas("tester","tester",500,500);
  grexp->Draw("TRI");

The result is attached. It gives me exactly what I expect.


BUT: If I then click on the canvas and change the draw option to “SURF3”, I get the second result posted, which seems to indicate there are points on the x=y line with the z value equal to zero (I verified this in log scale). However, the printed contents of the graph show NO SUCH points exist in the graph.


Why is the TGraph drawing routine adding these spurious points? I need to make contour plots of the surface shown, and that draw option also exhibits the same spurious zeroes.

Thanks for any help with this,
-P. Dudero

Can you post a running script demonstrating the problem ?

Yes, here is an attached script and the file that I used to generate the plots in the original post. At the root prompt, simply type ".x tester.C(“tester.root”). It spits out the contents of the graph after loading it, and draws the plot with SURF3. One can change the draw option after the fact to “TRI”, although it takes a few minutes to draw with 10k points.

Thanks for looking into it,
-P.D.
tester.C (1.15 KB)
tester.root (86.1 KB)

Your macro gives me the attached plot. Looks fine.

What version of root are you using? I get this when I log in:

  *******************************************
  *                                         *
  *        W E L C O M E  to  R O O T       *
  *                                         *
  *   Version   5.34/03   27 October 2012   *
  *                                         *
  *  You are welcome to visit our Web site  *
  *          http://root.cern.ch            *
  *                                         *
  *******************************************

ROOT 5.34/03 (branches/v5-34-00-patches@46829, De 07 2012, 11:04:00 on linuxx8664gcc)

CINT/ROOT C/C++ Interpreter version 5.18.00, July 2, 2010

This is the version of root bundled with the CMS version of software I’m using. I take it that you are using a newer version that doesn’t exhibit this problem.

  *******************************************
  *                                         *
  *        W E L C O M E  to  R O O T       *
  *                                         *
  *   Version   5.34/17  24 February 2014   *
  *                                         *
  *  You are welcome to visit our Web site  *
  *          http://root.cern.ch            *
  *                                         *
  *******************************************

ROOT 5.34/17 (heads/v5-34-00-patches@v5-34-17-6-g759116d, Feb 25 2014, 16:50:27 on macosx64)

CINT/ROOT C/C++ Interpreter version 5.18.00, July 2, 2010
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] 

On Mac

Confirmed, the problem must have been fixed somewhere between 5.34.03 and 5.34.17, although it’s not obvious from the patch release notes which fix did it…
Thanks,
-P.D.

Yes, several fixes have been done in that area.