Histograms filled and drawn in a loop.
Simple example illustrating how to use the C++ interpreter to fill histograms in a loop and show the graphics results
{
TCanvas *
c1 =
new TCanvas(
"c1",
"Live update of histograms", 200, 10, 600, 400);
auto *
total =
new TH1D(
"total",
"This is the total distribution", 100, -4, 4);
auto *
main =
new TH1D(
"main",
"Main contributor", 100, -4, 4);
auto *
s1 =
new TH1D(
"s1",
"This is the first signal", 100, -4, 4);
auto *
s2 =
new TH1D(
"s2",
"This is the second signal", 100, -4, 4);
total->SetMarkerStyle(21);
total->SetMarkerSize(0.7);
for (int i = 0; i < 10000; i++) {
float xs1 =
rng.Gaus(-0.5, 0.5);
float xs2 =
rng.Landau(1, 0.15);
}
slider->SetRange(0., 1. * i / 10000.);
}
}
}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
static unsigned int total
1-D histogram with a double per channel (see TH1 documentation)
Random number generator class based on M.
A specialized TPad including a TSliderBox object.
- Date
- November 2024
- Author
- Rene Brun
Definition in file hist007_TH1_liveupdate.C.