Intersection of rectangle with a ring

Dear ROOTers,

I want to determine the fraction of an area of a ring intersecting with a rectangle. The ring can have different radia.

My first attempt was to build a TGeoCompositeShape from intersection of a box and a tube, but this doesn’t suit my needs, since what I actually need is just a number, which gives me the fraction of the area of the ring contained in my rectangle.

I also tried to check if random points inside the ring are contained in the rectangle. This works, but it is very slow.

Could you please advice me, which is the most suitable method to use in this case?

Thank you in advance,


we don’t have in ROOT method for this special case. You will have to perform yourself the geometric calculation of the intersected area taking into account all the possible cases.
Eventually, I would use random points to check your calculations

Best Regards