Fill multiple histograms with different functions and automatic binning.
Illustrates merging with the power-of-two autobin algorithm
Processing /mnt/build/workspace/root-makedoc-v614/rootspi/rdoc/src/v6-14-00-patches/tutorials/hist/fillhistosauto2p.C...
OBJ: TStatistic min = -0.38361 +- 0.185 RMS = 0.5851 N = 10
OBJ: TStatistic max = 6.277 +- 0.1104 RMS = 0.349 N = 10
OBJ: TStatistic dif = 6.6606 +- 0.1849 RMS = 0.58476 N = 10
OBJ: TStatistic mean = 2.9938 +- 0.009987 RMS = 0.031583 N = 10
OBJ: TStatistic rms = 1.0037 +- 0.006958 RMS = 0.022003 N = 10
ent: 10010
TH1.Print Name = myh0, Entries= 10010, Total sum= 10004
TH1.Print Name = myhref, Entries= 10010, Total sum= 10006
TF1 *gam =
new TF1(
"gam",
"1/(1+0.1*x*0.1*x)", -100., 100.);
TF1 *gam1 =
new TF1(
"gam",
"1/(1+0.1*x*0.1*x)", -1., .25);
TF1 *iga =
new TF1(
"inv gam",
"1.-1/(1+0.1*x*0.1*x)", -100., 100.);
TF1 *iga1 =
new TF1(
"inv gam",
"1.-1/(1+0.1*x*0.1*x)", -.5, 1.);
void fillhistosauto2p(unsigned opt = 1, unsigned n = 1001)
{
auto href =
new TH1D(
"myhref",
"current", 50, 0., -1.);
href->SetBuffer(bsize);
auto href2 =
new TH1D(
"myhref",
"Auto P2, sequential", 50, 0., -1.);
href2->SetBuffer(bsize);
for (
UInt_t j = 0; j < nh; ++j) {
auto hw =
new TH1D(hname.
Data(),
"Auto P2, merged", nbins, 0., -1.);
hw->SetBuffer(bsize);
switch (opt) {
case 1: xx = rndm.
Gaus(3, 1);
break;
case 2: xx = rndm.
Rndm() * 100. - 50.;
break;
default: xx = rndm.
Gaus(0, 1);
}
if (buffering) {
if (xx > xma)
xma = xx;
if (xx < xmi)
xmi = xx;
xw.Fill(xx);
}
hw->Fill(xx);
href->Fill(xx);
href2->Fill(xx);
if (!hw->GetBuffer()) {
}
}
x.Fill(xmi);
y.Fill(xma);
d.Fill(xma - xmi);
a.Fill(xw.GetMean());
r.Fill(xw.GetRMS());
}
x.Print();
y.Print();
d.Print();
a.Print();
r.Print();
return;
if (
gROOT->GetListOfCanvases()->FindObject(
"c3"))
delete gROOT->GetListOfCanvases()->FindObject(
"c3");
href2->StatOverflows();
href->StatOverflows();
std::cout <<
" ent: " << h0->
GetEntries() <<
"\n";
href->Print();
delete hlist;
delete href;
delete href2;
delete h0;
}
- Date
- November 2017
- Author
- Gerardo Ganis
Definition in file fillhistosauto2p.C.