ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
glvox1.C
Go to the documentation of this file.
1 // This macro demonstrates how to use "glcol" option for TH3.
2 // Author: Timur Pocheptsov
3 
4 void glvox1()
5 {
6  //Create and fill TH3.
7  const UInt_t nX = 30;
8  const Double_t xMin = -1., xMax = 1., xStep = (xMax - xMin) / (nX - 1);
9 
10  const UInt_t nY = 30;
11  const Double_t yMin = -1., yMax = 1., yStep = (yMax - yMin) / (nY - 1);
12 
13  const UInt_t nZ = 30;
14  const Double_t zMin = -1., zMax = 1., zStep = (zMax - zMin) / (nZ - 1);
15 
16  TH3F *hist = new TH3F("glvoxel", "glvoxel", 30, -1., 1., 30, -1., 1., 30, -1., 1.);
17 
18  //Fill the histogram to create a "sphere".
19  for (UInt_t i = 0; i < nZ; ++i) {
20  const Double_t z = zMin + i * zStep;
21 
22  for (UInt_t j = 0; j < nY; ++j) {
23  const Double_t y = yMin + j * yStep;
24 
25  for (UInt_t k = 0; k < nX; ++k) {
26  const Double_t x = xMin + k * xStep;
27 
28  const Double_t val = 1. - (x * x + y * y + z * z);
29  hist->SetBinContent(k + 1, j + 1, i + 1, val);
30  }
31  }
32  }
33 
35  gStyle->SetPalette(1);
36 
37  hist->Draw("glcol");
38 }
3-D histogram with a float per channel (see TH1 documentation)}
Definition: TH3.h:272
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content.
Definition: TH3.cxx:3495
R__EXTERN TStyle * gStyle
Definition: TStyle.h:423
Double_t x[n]
Definition: legend1.C:17
Float_t z[5]
Definition: Ifit.C:16
void SetCanvasPreferGL(Bool_t prefer=kTRUE)
Definition: TStyle.h:337
virtual void Draw(Option_t *option="")
Draw this histogram with options.
Definition: TH1.cxx:2878
unsigned int UInt_t
Definition: RtypesCore.h:42
double Double_t
Definition: RtypesCore.h:55
Double_t y[n]
Definition: legend1.C:17
void glvox1()
Definition: glvox1.C:4
void SetPalette(Int_t ncolors=kBird, Int_t *colors=0, Float_t alpha=1.)
See TColor::SetPalette.
Definition: TStyle.cxx:1445