I am not sure if this is already known or expected behaviour but I decided to report it here anyway.
I am working with the results of a 2D likelihood scan stored in a ROOT file. The idea is simple, for each value of r_{1} (our first variable, x-axis) and r_{2} (the second variable, y-axis) we have the -2\Delta log L value. We want to plot the likelihood values as a function of x and y. To do so, we read the values from a ROOT file and create a TGraph2D using the commands:
import ROOT
ff = ROOT.TFile.Open("test.root") # same ROOT file for the two cases
limit = ff.Get("limit")
r_1 = "r_1"
r_2 = "r_2"
whatToDraw = ROOT.Form(f"{r_1}:{r_2}:2*deltaNLL")
n = limit.Draw(whatToDraw,"1", "colz")
graphScan = ROOT.TGraph2D(n,limit.GetV1(),limit.GetV2(),limit.GetV3())
The code is simple. However, we obtain completely different results when we run it using ROOT 6.30/04 and 6.32/06. The expected (and correct) result is the one from the ROOT 6.30/04 version. I show the results below.
I hope this is helpful for anyone since I spent sometime trying to understand what was going on there.
Bests,
Sergio.
Thanks for the report: it’s useful for us.
Can you confirm that the data read out from the file is the same?
Can you share the input file with us so that we can reproduce?
I see the difference between master and 6.30 it seems the TTree::Draw command gives the same output on both versions. I am investigating further why the TGraph2D one is different.
In November 2023 we changed the triangulation package. We now use CDT. It looks like in your particular case the result it gives is different from the previous one (triangles.c, we can not use it anymore because of license issues). Until now we didn’t have problems (all the tests are fine). I need to investigate why it gives you a such different result. The very old package (before triangles.c) is still available under the option OLD.
graphScan.Draw("old colz")
It gives the same result with both root versions. I am investigating CDT now.
I have identified the problem. The triangulation algorithm can sometimes encounter issues when the dataset contains multiple instances of the same point. In your case, the dataset has a total of 1997 points, of which 1000 are identical to (1,1,0).
The following version of your code ensures that only one instance of (1,1,0) is included. With this modification, it works as expected:
{
auto ff = new TFile("higgsCombine_limits_2D_25_2D.root");
int n = limit->Draw("r_LL:r_TT:2*deltaNLL","1", "COL");
double *x = limit->GetV1();
double *y = limit->GetV2();
double *z = limit->GetV3();
auto graphScan = new TGraph2D();
graphScan->AddPoint(1.,1.,0.);
for (int i=0; i<n; i++) {
if (x[i]==1. && y[i]==1. && z[i]==0.) continue;
graphScan->AddPoint(x[i], y[i], z[i]);
}
graphScan->Draw("COLZ");
}
This PR implements TGraph2D::RemoveDuplicates. Once merged your code could be:
{
auto ff = new TFile("higgsCombine_limits_2D_25_2D.root");
int n = limit->Draw("r_LL:r_TT:2*deltaNLL","1", "COL");
auto graphScan = new TGraph2D(n,limit->GetV1(),limit->GetV2(),limit->GetV3());
graphScan->RemoveDuplicates();
graphScan->Draw("COLZ");
}