I am attempting to gate on a TCutG but I can’t get it to ever test true when I use the IsInside method. Please let me know if more information is needed other than what is below…
Load points reads in the picked points of the polygon from a file given the detector number.
The program then scrolls through a large event file, event by event, and uses the cut.
if(csIFast>5 && csISlow>5 && siFront>5 && cut1.IsInside(csIFast,csISlow))
{
printf("cut 1 passed\n");
hCsITestSlowVsFastFull[csIId-1]->Fill(csIFast,csISlow);
fSiCounter[siId]++;
}
I don’t know if this makes it any more clear…?
That does not really help as we cannot see what the cut points are. I suspect you are outside the cut. Can you draw the cut and save it in a “.C” file from the File/SaveAs menu ?
It does work with how you showed it. I even got it to go through a scatter plot and only pick out the points that are inside the cut. I still can’t get it to work in my other program- but at least now I know I’m using TCutG correctly. Thanks!
I noticed in the above “C file” that the first and last points in the cut are the same. I had been trying to add points to TCutG objects and when I drew them they would never complete the polygon. That is until i added the last line in my code example below
For clarity the cpntsz array is two dimensional, one for each x-y coordinate. The last line sets the final point of the TCutG equal to the first. This apparently signifies closeure as the IsInside() function doesn’t work properly without this!