TH4D test page


TH4D is a 3+1 dimension histogram to provide GetRandom4(x, y, z, u) function.
Essentially it's a 3-dim histogram derived from TH3D but equips extra-dimension in each bin, in this case, one-dimension TH1DEX derived from TH1D. You can use any function of TH3D like Fill(x,y,z) or GetRandom3(x,y,z) while equivalent functions of 4D are Fill(x,y,z,u) or GetRandom4(x,y,z,u), respectively.
To access the 4th dimension at (x, y, z), call

h4->GetExtraDimensionPtr(h4->TH3::FindBin(x, y, z)); // h4: TH4D object ptr

then you will get a pointer to TH1DEX object.

Technical notations

Source code

Test scripts


Test histograms of TH4D

Fill test

Plot of Fill(x, y, z, t),
x = 0.9 // costheta y = gRandom->Gaus(90,. 20) // zenith z = gRandom->Gaus(180, 20) // azimuth t = gRandom->Gaus(y/3, 5) // time

3D hist (xz)

3D hist (yz)

time hist at
(0.9, 85, 180), (0.9, 90. 180)
(0.9, 95, 180), (0.9, 100, 180)


GetRandom4(x, y, z, t) test

Call GetRandom4(x, y, z, t) with referense TH4D (above plots), and fill them into new TH4D hist.

new hist: 3D hist (xz)

new hist: 3D hist (yz)

new hist: time hist at
(0.9, 85, 180), (0.9, 90. 180)
(0.9, 95, 180), (0.9, 100, 180)