"Error: Input must have at least three input vertices" when using TGraph2D.Set/GetHistogram()

Hi, I’m trying too use the TGraph2D machinery to do some interpolation of limits between signal mass points.

I’m however having trouble with the TGraph2D SetHistogram and GetHistogram methods, which seem to give an error which are hard to predict, avoid or understand

Here is a minimal example:


import ROOT as r

r.gROOT.SetBatch()

tg2d = r.TGraph2D()
tg2d.SetPoint(0, 0, 15,  0.839787)
tg2d.SetPoint(1, 1, 15,  0.580189)
tg2d.SetPoint(2, 2, 15,  0.411187)
tg2d.SetPoint(3, 3, 15,  0.291935)
tg2d.SetPoint(4, 4, 15,  0.219857)
tg2d.SetPoint(5, 5, 15,  0.164679)
tg2d.SetPoint(6, 6, 15,  0.125312)
tg2d.SetPoint(7, 7, 15,  0.096826)
tg2d.SetPoint(8, 8, 15,  0.075591)
tg2d.SetPoint(9, 9, 15,  0.059545)
tg2d.SetPoint(10, 0, 25,  0.893365)
tg2d.SetPoint(11, 1, 25,  0.638939)
tg2d.SetPoint(12, 2, 25,  0.466021)
tg2d.SetPoint(13, 3, 25,  0.346704)
tg2d.SetPoint(14, 4, 25,  0.261537)
tg2d.SetPoint(15, 5, 25,  0.200040)
tg2d.SetPoint(16, 6, 25,  0.155290)
tg2d.SetPoint(17, 7, 25,  0.121716)
tg2d.SetPoint(18, 8, 25,  0.096585)
tg2d.SetPoint(19, 9, 25,  0.077194)
tg2d.SetPoint(20, 0, 40,  0.912303)
tg2d.SetPoint(21, 1, 40,  0.691364)
tg2d.SetPoint(22, 2, 40,  0.530575)
tg2d.SetPoint(23, 3, 40,  0.411135)
tg2d.SetPoint(24, 4, 40,  0.315267)
tg2d.SetPoint(25, 5, 40,  0.253945)
tg2d.SetPoint(26, 6, 40,  0.205771)
tg2d.SetPoint(27, 7, 40,  0.158833)
tg2d.SetPoint(28, 8, 40,  0.130464)
tg2d.SetPoint(29, 9, 40,  0.105571)
tg2d.SetPoint(30, 0, 5,  1.062490)
tg2d.SetPoint(31, 1, 5,  0.724660)
tg2d.SetPoint(32, 2, 5,  0.509060)
tg2d.SetPoint(33, 3, 5,  0.358593)
tg2d.SetPoint(34, 4, 5,  0.262988)
tg2d.SetPoint(35, 5, 5,  0.200273)
tg2d.SetPoint(36, 6, 5,  0.149098)
tg2d.SetPoint(37, 7, 5,  0.116918)
tg2d.SetPoint(38, 8, 5,  0.089035)
tg2d.SetPoint(39, 9, 5,  0.069918)
tg2d.SetPoint(40, 0, 8,  0.998991)
tg2d.SetPoint(41, 1, 8,  0.663852)
tg2d.SetPoint(42, 2, 8,  0.454952)
tg2d.SetPoint(43, 3, 8,  0.319274)
tg2d.SetPoint(44, 4, 8,  0.230208)
tg2d.SetPoint(45, 5, 8,  0.168748)
tg2d.SetPoint(46, 6, 8,  0.123537)
tg2d.SetPoint(47, 7, 8,  0.093696)
tg2d.SetPoint(48, 8, 8,  0.071963)
tg2d.SetPoint(49, 9, 8,  0.056097)


htmp = r.TH2F("ht", "", 40, 0, 10,40, 5, 40)
#tg2d.SetHistogram(htmp) # uncommenting this line gives error

h = tg2d.GetHistogram("")

canvas = r.TCanvas("c","c", 500, 500)
h.Draw("colz")

The code runs OK as above, but uncommenting the #tg2d.SetHistogram(htmp) line gives

Error:  Input must have at least three input vertices.

and occasionally causes a seg fault.

The histogram which I am setting seems perfectly reasonable to me… is there anything I am doing wrong here? What is this error warning against? I could not figure out where in the source code this error is thrown, so it’s not clear to me what is being done wrong.

_ROOT Version:_ROOT Version: 6.22/00
Platform: CC7
Compiler: PyRoot


Yes there is an issue with SetHistogram() which I do not understand for the time being.

I simplified the reproducer to:

{
   auto tg2d = new TGraph2D();

   tg2d->SetPoint(0, 0, 15,  0.839787);
   tg2d->SetPoint(1, 1, 15,  0.580189);
   tg2d->SetPoint(2, 2, 15,  0.411187);
   tg2d->SetPoint(3, 3, 15,  0.291935);
   tg2d->SetPoint(4, 4, 15,  0.219857);
   tg2d->SetPoint(5, 5, 15,  0.164679);
   tg2d->SetPoint(6, 6, 15,  0.125312);
   tg2d->SetPoint(7, 7, 15,  0.096826);
   tg2d->SetPoint(8, 8, 15,  0.075591);
   tg2d->SetPoint(9, 9, 15,  0.059545);
   tg2d->SetPoint(10, 0, 25,  0.893365);

   auto htmp = new TH2D("ht", "ht", 40, 0, 10,40, 5, 40);
   tg2d->SetHistogram(htmp);
   tg2d->Draw("colz");
}

My first guess is that the “htmp” got “garbage collected” in python.
Actually, the “htmp” should be a “TH2D”, not “TH2F”, and one should also make sure that it is not owned by any directory.

But then, it seems like @couet reproduced this in C++ too, so I think this excludes a garbage collection problem?

with TH2D it is the same

I do not find any solution for the time being.
If you can avoid calling SetHistogram() that will be the best.
May be you can fill a Github issue with this problem so we do not forget it.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.