Number of segments in a TEllipse

Hi,

I am trying to use a TEllipse to display a track on top of a TH2. I noticed that the ellipse is drawn with 8 segments most of the time, even though sometimes it appears to be smooth.
I am creating these TEllipse at the beginning of a loop, drawing them, and then deleting the object at the end of the loop. So they all go through the same few steps.

I have seen here that this matter is not unknown. So I’d like to know if a fix has been implemented since this discussion occurred, but also if anyone has an explanation on why the TEllipse is most of the time made of 8 segments, and sometimes, for no apparent reason, smooth. It also does not seem to rely on the size of the TEllipse.

Thanks for your help!
Cheers,
Tristan



ROOT Version: 6.20.04.07

Hi Tristan,

Thanks for your post.
First of all, I’d like to suggest to try out version 6.30.04, the latest stable of ROOT and report back: version 6.20 is quite old and many new features and fixes entered the code base since then!
In case more expertise is needed to discuss this matter, I add our expert, @couet , in the loop.

Cheers,
D

Hi Danilo,

Thanks for the answer. The ROOT version I use is the one set in my collaboration’s software, so I have no control over that. I doubt they’d be willing to go through the troubles of upgrading just to have more segments in an ellipse! If this “bug”, so to speak, has been fixed since this version, that’s great, and please let me know.

Anyway, I’d still be interested in a workaround that would do the trick for the ROOT version I have to use.

Cheers,
Tristan

The code to paint the ellipses in your root version (6.20) is the same as in 6.30 (except an added check that gPad exists). The relevant lines are:

    //set number of points approximatively proportional to the ellipse circumference
   Double_t circ = kPI*(r1+r2)*(phi2-phi1)/360;
   Int_t n = (Int_t)(np*circ/((gPad->GetX2()-gPad->GetX1())+(gPad->GetY2()-gPad->GetY1())));
   if (n < 8) n= 8;
   if (n > np) n = np;

Even if you are by chance at the limit between 8 or more points, I think the difference should not be as dramatic as you show especially seeing that the second and third ellipses are not so different in size. Maybe you are somehow drawing on (very) different coordinates and GetX2, etc. are resulting in very different values? Can you show the code used to obtain the plots above? It would be best to see all the code (all pads and things you are also drawing), but reduce it to the minimum that still shows the issue.

It would take me a bit of time to extract an MWE, but what I can tell already is that only one TH2 is created outside of the loop and is Reset() at the beginning of each iteration, so the range of drawing remains the same for each event drawn. Is it what you were referring to, for the different coordinates?

I tried to reproduce your problem with the following:

root [0] TCanvas c;
root [1] gPad->DrawFrame(-10000,-10000,2000,2000)
(TH1F *) 0x7fae960c0700
root [2] TEllipse *ellipse = new TEllipse(-6138.252,-115.7894,1257.163,1089.474,0,360,0);
root [3] ellipse->Draw()
root [4] 

But for me it is working fine.

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