Glsurf2z option adding a TCutG

Dear Root support

I would like to ask if it would be possible to draw a TProfile2D with the glsurf2z option adding a TCutG?

I attach a file, TestExample.cxx, to explain my problem.

I have a TProfile2D filled with height measurements of the surface of detector which is a trapeze. So the bins which are outside this trapeze area are empty.

I aim to a representation of the surface restricted to the trapeze area.

I managed to do this with a Draw(“surf2z [aTCutG]”) where the aTCutG is defining the frontier of the area of interest.

But when the TProfile2D binning is very dense, the result is not so nice looking.

So I decided to draw using OpenGL with a Draw(“glsurf2z [aTCutG]”). I get a beautiful surface rendering but the TCutG is clearly not taken into account.

The attached code contains 2 draw lines at the very end:

-with the pTProfile2D->Draw(“surf2z [aTCutG]”) line I get the attached file A.png: the rendering is not so nice but the TCutG is active

-with the pTProfile2D->Draw(“glsurf2z [aTCutG]”) line I get the attached file B.png: the rendering is nice but the TCutG is inactive

Would it be possible to have the TCutG active when using glsurf2z?

                  Many Thanks
                             A Bientot

TestExample.cxx.gz (485 KB)

Well, even if we implement this cut, it will not be any better than non-gl case, we still will cut on the level of square bins/triangles - I mean we’ll end up with the same “saw teeth”-like edges.

With a TCutG, the edges would be at least clearly visible. This gives a better feeling of the surface topography that I am looking for, better than the puzzling “cliffs” around the surface that one obtains without a TCutG (as on the B.png I sent)

Actually I am looking for a rendering similar to what one obtains with a TGraph2D with the TRI option, so using Delaunay triangles, as shown on the attached C.png file on which the mesh representing the surface appears nicely. However I got trouble with Delaunay triangularization of TGraph2D when data are numerous.

Then a TProfile2D seems a more convenient choice although the rendering becomes not so nice when the data are hyper dense. This latter problem is solved using gl views. Aside the edges definition issue that could be handled separately I think, the only unsatisfactory feature which remains is then the empty bins treatment, i.e the “cliffs” that could be cut-off with a TCutG.

This has been improved . A new triangulation code has been put in root6

Dear Olivier

Even with a more robust Delaunay triangularization of TGraph2D, there is still a problem with large data set since there is no “gltri2z” drawing option, i.e option tri2z for OpenGL view similar to glsurf2z.

For a large number of points, I can’t stay with the “tri1z” option, used for he plot C.png I sent. As shown on the attached D.png, the mesh gets completely black.

So I have to move to the “tri2z” option. But then I get a picture as the attached E.png. It has the same rendering issue than the B.png file I sent (a TProfile2D with the “surf2” option).

It would be perfect to solve this problem going to OpenGL and then to get something similar to the A.png I sent, for the surface but with the “cliffs” absent from the start. But there is no “gltri2z” option.

So actually, I would like to ask if it would be possible to draw a TProfile2D with the “glsurf2z” option adding a TCutG or a TGraph2D with an option “gltri2z” similar to “glsurf2z”?

Many Thanks
A Bientot

Can you post your macro using TGraph2D showing the problem ?
Note also we will look at the “holes” issue with normal surface plots.

I attach the code for theTGraph2D. At the very end you have 2 draws, one with tri1z the other with tri2z with which you get respectively the attached F.png and G.png files. There are ~12K points. The execution is very very long.

I found TGraph2D convenient for moderate size samples although in V5 I get sometimes strange things such as indeed holes or bizarre triangles. But I need it when I need to interpolate between data which are not evenly distributed. For large samples for which I can average on a regular grid, I found TProfile2D more convenient as well as faster and more robust.

p_TGraph2D_Meas.cxx (631 KB)

With the latest root version it takes 2 seconds on Mac … does not seems that long…

$ time root -q p_TGraph2D_Meas.cxx
root [0] 
Processing p_TGraph2D_Meas.cxx...

real	0m2.611s
user	0m2.232s
sys	0m0.357s

Actually the holes we can see in your fist macro is due to the fact you have SetCanvas Prefer GL on … if you remove it the plot is fine.

It may be a matter of taste but even improved as you did, I do not find that the result “tri2z” option is satisfactory. The roughness of the surface is as erased. The same is true for the “surf2z” option.

The improvement of the rendering I am seeking for is illustrated by the difference between the 2 attached files, the H.png file which is obtained with the “surf2z” option and the I.png file which is obtained with the “glsurf2z”.

Therefore do you think that it would be possible to have a “gltri2z” option?

As I said I would be happy to have the possibility to have a TCutG active when added to the existing “glsurf2z” option.

There is no plans right not to extend glsurf2. May be you can submit a Jira request to make sure it is not forget.

Unfortunately I can not submit a Jira request.
I can log into Jira but I am told that I “do not have permission to create issues in this project”.


Many Thanks