I would like to draw a set slices of a TH3D in a 3D view. In other words: I would like to have a 3D coordinate systems and at several z positions, I would like to add planes in which TH2s with option “colz” are drawn. The TH2s should show only the content of the TH3 with the given z of the plane.
I know how to get the corresponding TH2. For example, to get the plane at bin z=50, I could do:
But I have no idea how to draw this TH2D in a plane with z=50 in a 3D coordinate system.
Do you have an idea how to do this?
Not easy to do. There is not direct option to do that.
I also thought about the following trick: One might copy the TH3D into a new one, but only fill the bins in the selected slices. Then, one could draw the new, filtered TH3D with option “BOX2Z”. But then, one would have to make sure that the scaling of the boxes is chosen such that they all have the same size, namely exactly the voxel size without any gap. Is there a way to achieve this?
I found this post. Here, it was supposed to use an TNtuple with four entries: x,y,z,val. Then, one draws the tuple with option “col” or “colz” as
Unfortunately, for me (root version 6.20.00), only the first point of the ntuple is drawn and its fourth component determines its color. If I enter only
then I get a TPolyMarker3D with all points, but they of course all have the same color.
Yes the colour is mapper on the fourth variable.
You can define Z=a constant
I see how this is done in this post. Unfortunately this not really what I want because the markers do not form a nice surface.
I found that using OpenGL is heading in the right direction. It looks like I want to do the exact same thing as here. I found a way that is very close to want I want:
If hist is my TH3F*, I do
hist->SetMinimum(max+1); //do not show any bins
Now, I can move slices through the volume on which cuts are shown in colors.There are only three things missing:
- I would like to set the positions of the planes programmatically
- I would like to add more than only one slice per axis
- I need the color palette that was used to create the cuts
Do you have any ideas how to this this?
I do not think you can do these things with the current implementation.
some coding will be required.
An other way would be to use the option BOX2 on a TH3
I already considered BOX2. But the problem is, that I don’t want to have the gaps between the entries which is a result of the scaling of the box size. I there a way to fix the box size to the size of the 3D bins while still maintaining the color scale?
No, the boxes are proportional to the content. Have you looked at the OpenGL tutorials ? and the GL related options ?