TCutg graphics editor polygon draw issue

Dear Folks

I have a ROOT application which uses
TCutG* cutg=(TCutG*)gPad->WaitPrimitive(“CUTG”,“CutG”);
in a canvas with a single 2D histogram so that I can use the graphics editor to draw a polygon with left mouse clicks, and close it with a double click or a left mouse click near the start point.
I find the polygon closes prematurely unless I draw a really large one.
The behaviour seems independent of the binning, but it is worse when used on a divided canvas.
Sometimes however, it works OK, but I have not been able to make it work to reliably draw small polygon ROIs.
Apart from this problem, the cut works quite OK when looping over events in the nTuple.

Suggestions welcome.

Best regards
Simon

Do you have a small reproducer so we can test it ?

Dear all,
the att macro works for me on root 6.05.02, U 14.04.03
Cheers
Otto
wait_tcutg.C (991 Bytes)

Dear Folks

Yes … the macro works … but we are not sufficiently successful for a compiled application.

The data file is here:

/afs/cern.ch/work/d/daquser/public/bl4sresults/root/1442696982complete.root

Best regards
Simon
Makefile.C (2.11 KB)
MyClass2015_17.h (13.9 KB)
test.cpp (7.07 KB)

Dear Folks

When I use this source file … applying the TCutg technology to another 2D histogram … it works quite fine … and I don’t see really any reason why it works in this case and not in the previous case.

Best regards
Simon
test-2.cpp (7.52 KB)

Dear all,
I can reproduce Simons issue with my example macro.
The problem is in TCreatePromitives::Polyline.
The condition for “Terminate polyline” is calculated from
user coordinates instead of Pixels, so if the cut has all points more then 0.007
apart it works otherwise not.
Note the whole range of the X an Y axis of Target_pos is only -0.005 - 0.005

TCreatePrimitives.cxx, line 615:

            fgPolyLine->GetPoint(fgPolyLine->GetN()-3, xold, yold);
            xnew = gPad->PadtoX(gPad->AbsPixeltoX(pxnew));
            ynew = gPad->PadtoY(gPad->AbsPixeltoY(pynew));
            dp = TMath::Abs(xnew-xold) +TMath::Abs(ynew-yold);
            if (dp < 0.007) {
            //  finish polyline

I think this needs to be fixed.

Cheers
Otto

Thanks Otto,

I’ll look at it.

Olivier

Dear Folks,

Yes … a colleague of mine looking at this also found the degree of zoom was affecting the alacrity of ROOT to close the polygon.

Thanks.

Best regards
Simon

HI Otto.
I just tried your macro. It is not clear to me to see the premature ending…

sorry, my post was too terse:
I modified the macro to use Simons histogram, both now in attachment
Cheers
Otto
target_pos.root (14.1 KB)
wait_tcutg.C (1.04 KB)

Thanks Otto,
I see it now… It takes 3 points and stop.
Cheers,
Olivier

Hi Otto,

I checked the part of TCreatePrimitives.cxx you pointed. You are right that hardcoded value “0.07” is the problem. I need now to find the best way to fix it.

Olivier

The problem is now fixed in the master. Thanks for reporting.