This macro demonstrates how to use "glcol" option for TH3 and how to create user defined TRANSFER FUNCTION: transfer function maps bin value to voxel's opacity.
codomain is [0, 1] (1. - non-transparent, 0.5 is semitransparent, etc.) To pass transparency function into painting algorithm, you have to:
- Create TF1 object (with symbolic expression like "0.5 * (sin(x) + 1)":
...
TF1 * tf =
new TF1(
"TransferFunction",
"0.5 * (sin(x) + 1)", -10., 10.);
...
IMPORTANT, the name of TF1 object MUST be "TransferFunction".
- Add this function into a hist's list of functions:
...
TList * lof = hist->GetListOfFunctions();
if (lof) lof->Add(tf);
...
It's also possible to use your own function and pass it into TF1, please read TF1 documentation to learn how.
This macro is to be compiled: TF1 is extremely slow with interpreted function as an argument.
namespace {
{
return 0.008;
return 0.015;
return 0.02;
return 0.03;
return 0.04;
return 0.05;
}
}
void glvox2()
{
const Double_t xMin = -1., xMax = 1., xStep = (xMax - xMin) / (nX - 1);
const Double_t yMin = -1., yMax = 1., yStep = (yMax - yMin) / (nY - 1);
const Double_t zMin = -1., zMax = 1., zStep = (zMax - zMin) / (nZ - 1);
TH3F *hist =
new TH3F(
"glvoxel",
"glvoxel", nX, -1., 1., nY, -1., 1., nZ, -1., 1.);
for (
UInt_t i = 0; i < nZ; ++i) {
for (
UInt_t j = 0; j < nY; ++j) {
for (
UInt_t k = 0; k < nX; ++k) {
}
}
}
if (lf) {
TF1 * tf =
new TF1(
"TransferFunction", my_transfer_function, -2., 1.);
}
}
R__EXTERN TStyle * gStyle
void Draw(Option_t *option="") override
Draw this histogram with options.
TList * GetListOfFunctions() const
3-D histogram with a float per channel (see TH1 documentation)
void SetBinContent(Int_t bin, Double_t content) override
Set bin content.
void Add(TObject *obj) override
void SetCanvasPreferGL(Bool_t prefer=kTRUE)
- Author
- Timur Pocheptsov
Definition in file glvox2.C.