Dot density maps

Would be great to visualize dot-density maps like discussed in this blog:

1 Like

I think we traditionally use either scatter or box plots for this, overlaying multiple histograms to represent the different classes. What would be (ideally physics) use cases for this, that would benefit from not using scatter or box plots?

To do that with ROOT I would use something like:

ntuple->Draw("px:pz:pz","","col");

if you need a map in background we can draw it with a TH2Poly like the one used in the last ROOT workshop (for the ROOT download stats).

What is requested is the (random) filling of an irregular shaped object (TPolyLineShape ?, no documentation or TGeoPolygon ?) with scatter.

Unless I am misunderstanding the picture, this is exactly what TH2Poly is.

Dear Oiver,

Yes TH2Poly seems to fit the bill … but dot density maybe not.

Looking over the documentation, I read that for efficiency a grid/partition is used
to decide whether a point is inside the polygon shape or not.
If later this polygon shape is filled with a solid color, I see no problem. If I
plot scatter points, noticeably inconsistencies will appear around the edges.
If one makes the raster fine enough it will disappear bu t so does the advantage
of the raster.

I would think that determining whether a point is inside a polygon shape is solved
in a detector geometry package.

For me this request is closed.

Time permitting I will see if I can import/understand “census shape files” and start
experimenting with TH2Poly.

-Eddy

Eddy,

TH2Poly bins are filled like any normal TH2. To find which bin has to be incremented the IsInside method is used. The partitioning is use before calling IsInside to speed up by a huge factor the bin search. Then the histogram drawing is similar to any TH2. The exact position of each individual points is of course lost. The “scatter plot” is produced by a number of random points in each bin. To have a real scatter plot with the exact positions, the drawing should be done from a tree. The drawing can be superimposed on a map (an empty TH2Poly for instance).

O.

Hi Olivier,

My understanding is that the decision whether the point is inside/outside the shape is done by the grid/raster . THis
will lead for a scatter plot to “rectangular. block” effects around
the boundary.

-Eddy

No … not at all . The grid is a partitioning to speed up the the search in the bins. It avoid looking at all the bins. Imagine the following small example:
A grid 2x2 on top of 2000 bins. Each bin is attached to one of the 4 cells. When Fill is called with (x,y) we first looked in with cell of the 2x2 grid it falls. Then we call IsInside only on the bins attached to this cell. If, in that case, we have roughly 500 bins attached to each cell we end up calling IsInside only on 500 polygons instead of 2000. IsInside is then very precise to determine if (x,y) is in the bin or not (Bresenham algorithm)
So there is no “rectangular block” effect

Sorry, that sounds right, just could not deduce this from the documentation: use the grid/cells to limit the search of the bins
on which the IsInside is done.

I will revisit that doc to make it more clear.