599enum EInconsistencyBits {
600 kFullyConsistent = 0,
601 kDifferentLabels =
BIT(0),
602 kDifferentBinLimits =
BIT(1),
603 kDifferentAxisLimits =
BIT(2),
604 kDifferentNumberOfBins =
BIT(3),
605 kDifferentDimensions =
BIT(4)
701 if (nbins <= 0) {
Warning(
"TH1",
"nbins is <=0 - set to nbins = 1"); nbins = 1; }
723 if (nbins <= 0) {
Warning(
"TH1",
"nbins is <=0 - set to nbins = 1"); nbins = 1; }
745 if (nbins <= 0) {
Warning(
"TH1",
"nbins is <=0 - set to nbins = 1"); nbins = 1; }
764 Draw(
b ?
b->GetDrawOption() :
"");
829 Error(
"Add",
"Attempt to add a non-existing function");
849 for (
Int_t i = 0; i < 10; ++i)
s1[i] = 0;
855 Int_t bin, binx, biny, binz;
860 for (binz = 0; binz < ncellsz; ++binz) {
862 for (biny = 0; biny < ncellsy; ++biny) {
864 for (binx = 0; binx < ncellsx; ++binx) {
868 bin = binx + ncellsx * (biny + ncellsy * binz);
887 if (inconsistency & kDifferentDimensions) {
889 Info(
name,
"Histograms have different dimensions - trying to use TH1::Merge");
891 Error(
name,
"Histograms have different dimensions");
893 }
else if (inconsistency & kDifferentNumberOfBins) {
895 Info(
name,
"Histograms have different number of bins - trying to use TH1::Merge");
897 Error(
name,
"Histograms have different number of bins");
899 }
else if (inconsistency & kDifferentAxisLimits) {
901 Info(
name,
"Histograms have different axis limits - trying to use TH1::Merge");
903 Warning(
name,
"Histograms have different axis limits");
904 }
else if (inconsistency & kDifferentBinLimits) {
906 Info(
name,
"Histograms have different bin limits - trying to use TH1::Merge");
908 Warning(
name,
"Histograms have different bin limits");
909 }
else if (inconsistency & kDifferentLabels) {
912 Info(
name,
"Histograms have different labels - trying to use TH1::Merge");
914 Info(
name,
"Histograms have different labels");
917 return inconsistency;
957 Error(
"Add",
"Attempt to add a non-existing histogram");
964 bool useMerge =
false;
968 if(inconsistency >= kDifferentNumberOfBins && !considerMerge) {
972 if(inconsistency > kFullyConsistent) {
973 useMerge = considerMerge;
978 l.Add(
const_cast<TH1*
>(
h1));
1021 if (e1sq) w1 = 1. / e1sq;
1026 double sf = (s2[0] != 0) ? s2[1]/s2[0] : 1;
1030 if (e2sq) w2 = 1. / e2sq;
1035 double sf = (
s1[0] != 0) ?
s1[1]/
s1[0] : 1;
1040 double y = (w1*
y1 + w2*
y2)/(w1 + w2);
1043 double err2 = 1./(w1 + w2);
1044 if (err2 < 1.E-200) err2 = 0;
1060 if (i == 1)
s1[i] +=
c1*
c1*s2[i];
1061 else s1[i] +=
c1*s2[i];
1108 Error(
"Add",
"Attempt to add a non-existing histogram");
1116 if (
h1 == h2 &&
c2 < 0) {
c2 = 0; normWidth =
kTRUE;}
1119 bool useMerge =
false;
1128 if(inconsistency >= kDifferentNumberOfBins && !considerMerge) {
1132 if(inconsistency > kFullyConsistent) {
1133 useMerge = considerMerge;
1139 l.Add(
const_cast<TH1*
>(
h1));
1140 l.Add(
const_cast<TH1*
>(h2));
1162 Bool_t resetStats = (
c1*
c2 < 0) || normWidth;
1169 if (i == 1) s3[i] =
c1*
c1*
s1[i] +
c2*
c2*s2[i];
1171 else s3[i] =
c1*
s1[i] +
c2*s2[i];
1187 Int_t bin, binx, biny, binz;
1188 for (binz = 0; binz < nbinsz; ++binz) {
1190 for (biny = 0; biny < nbinsy; ++biny) {
1192 for (binx = 0; binx < nbinsx; ++binx) {
1194 bin =
GetBin(binx, biny, binz);
1210 Double_t e2sq = h2->GetBinErrorSqUnchecked(i);
1215 if (e1sq) w1 = 1./ e1sq;
1219 double sf = (
s1[0] != 0) ?
s1[1]/
s1[0] : 1;
1223 if (e2sq) w2 = 1./ e2sq;
1224 else if (h2->fSumw2.fN) {
1227 double sf = (s2[0] != 0) ? s2[1]/s2[0] : 1;
1232 double y = (w1*
y1 + w2*
y2)/(w1 + w2);
1235 double err2 = 1./(w1 + w2);
1236 if (err2 < 1.E-200) err2 = 0;
1312 return ((next &&
x > 0.) || (!next &&
x <= 0.)) ? std::ldexp(std::copysign(1., f2), nn)
1313 : std::ldexp(std::copysign(1., f2), --nn);
1326 return (
Int_t)std::ldexp(1., nn);
1366 Double_t rr = (xhma - xhmi) / (xma - xmi);
1376 Int_t nbup = (xhma - xma) / bw;
1379 if (nbup != nbside) {
1381 xhma -= bw * (nbup - nbside);
1382 nb -= (nbup - nbside);
1386 Int_t nblw = (xmi - xhmi) / bw;
1389 if (nblw != nbside) {
1391 xhmi += bw * (nblw - nbside);
1392 nb -= (nblw - nbside);
1422 if (nbentries == 0) {
1432 if (nbentries < 0 && action == 0)
return 0;
1435 if (nbentries < 0) {
1436 nbentries = -nbentries;
1448 for (
Int_t i=0;i<nbentries;i++) {
1451 if (!std::isfinite(
x))
continue;
1460 "inconsistency found by power-of-2 autobin algorithm: fallback to standard method");
1478 DoFillN(nbentries,&buffer[2],&buffer[1],2);
1512 if (nbentries < 0) {
1515 nbentries = -nbentries;
1547 if ( h2Array->
fN != fN ) {
1551 for (
int i = 0; i < fN; ++i ) {
1582 for (
int i = 1; i <= a1->
GetNbins(); ++i) {
1585 if (label1 != label2) {
1614 ::Info(
"CheckEqualAxes",
"Axes have different number of bins : nbin1 = %d nbin2 = %d",a1->
GetNbins(),a2->
GetNbins() );
1618 ::Info(
"CheckEqualAxes",
"Axes have different limits");
1622 ::Info(
"CheckEqualAxes",
"Axes have different bin limits");
1628 ::Info(
"CheckEqualAxes",
"Axes have different labels");
1643 Int_t nbins1 = lastBin1-firstBin1 + 1;
1651 if (firstBin2 < lastBin2) {
1653 nbins2 = lastBin1-firstBin1 + 1;
1658 if (nbins1 != nbins2 ) {
1659 ::Info(
"CheckConsistentSubAxes",
"Axes have different number of bins");
1667 ::Info(
"CheckConsistentSubAxes",
"Axes have different limits");
1679 if (
h1 == h2)
return kFullyConsistent;
1682 return kDifferentDimensions;
1692 if (nbinsx != h2->GetNbinsX() ||
1693 (dim > 1 && nbinsy != h2->GetNbinsY()) ||
1694 (dim > 2 && nbinsz != h2->GetNbinsZ()) ) {
1695 return kDifferentNumberOfBins;
1704 if (!ret)
return kDifferentAxisLimits;
1710 if (!ret)
return kDifferentBinLimits;
1713 if ( !
h1->
IsEmpty() && !h2->IsEmpty() ) {
1717 if (!ret)
return kDifferentLabels;
1720 return kFullyConsistent;
2013 Int_t ndf = 0, igood = 0;
2021 printf(
"Chi2 = %f, Prob = %g, NDF = %d, igood = %d\n", chi2,prob,ndf,igood);
2024 if (ndf == 0)
return 0;
2072 Int_t i_start, i_end;
2073 Int_t j_start, j_end;
2074 Int_t k_start, k_end;
2088 const TAxis *xaxis2 = h2->GetXaxis();
2090 const TAxis *yaxis2 = h2->GetYaxis();
2092 const TAxis *zaxis2 = h2->GetZaxis();
2103 Error(
"Chi2TestX",
"Histograms have different dimensions.");
2108 if (nbinx1 != nbinx2) {
2109 Error(
"Chi2TestX",
"different number of x channels");
2111 if (nbiny1 != nbiny2) {
2112 Error(
"Chi2TestX",
"different number of y channels");
2114 if (nbinz1 != nbinz2) {
2115 Error(
"Chi2TestX",
"different number of z channels");
2119 i_start = j_start = k_start = 1;
2150 ndf = (i_end - i_start + 1) * (j_end - j_start + 1) * (k_end - k_start + 1) - 1;
2157 if (scaledHistogram && !comparisonUU) {
2158 Info(
"Chi2TestX",
"NORM option should be used together with UU option. It is ignored");
2165 Double_t effEntries1 = (s[1] ? s[0] * s[0] / s[1] : 0.0);
2169 Double_t effEntries2 = (s[1] ? s[0] * s[0] / s[1] : 0.0);
2171 if (!comparisonUU && !comparisonUW && !comparisonWW ) {
2173 if (
TMath::Abs(sumBinContent1 - effEntries1) < 1) {
2174 if (
TMath::Abs(sumBinContent2 - effEntries2) < 1) comparisonUU =
true;
2175 else comparisonUW =
true;
2177 else comparisonWW =
true;
2181 if (
TMath::Abs(sumBinContent1 - effEntries1) >= 1) {
2182 Warning(
"Chi2TestX",
"First histogram is not unweighted and option UW has been requested");
2185 if ( (!scaledHistogram && comparisonUU) ) {
2186 if ( (
TMath::Abs(sumBinContent1 - effEntries1) >= 1) || (
TMath::Abs(sumBinContent2 - effEntries2) >= 1) ) {
2187 Warning(
"Chi2TestX",
"Both histograms are not unweighted and option UU has been requested");
2193 if (comparisonUU && scaledHistogram) {
2194 for (
Int_t i = i_start; i <= i_end; ++i) {
2195 for (
Int_t j = j_start; j <= j_end; ++j) {
2196 for (
Int_t k = k_start; k <= k_end; ++k) {
2201 Double_t cnt2 = h2->RetrieveBinContent(bin);
2203 Double_t e2sq = h2->GetBinErrorSqUnchecked(bin);
2205 if (e1sq > 0.0) cnt1 =
TMath::Floor(cnt1 * cnt1 / e1sq + 0.5);
2208 if (e2sq > 0.0) cnt2 =
TMath::Floor(cnt2 * cnt2 / e2sq + 0.5);
2219 if (sumw1 <= 0.0 || sumw2 <= 0.0) {
2220 Error(
"Chi2TestX",
"Cannot use option NORM when one histogram has all zero errors");
2225 for (
Int_t i = i_start; i <= i_end; ++i) {
2226 for (
Int_t j = j_start; j <= j_end; ++j) {
2227 for (
Int_t k = k_start; k <= k_end; ++k) {
2232 sum2 += h2->RetrieveBinContent(bin);
2235 if ( comparisonUW || comparisonWW ) sumw2 += h2->GetBinErrorSqUnchecked(bin);
2241 if (sum1 == 0.0 || sum2 == 0.0) {
2242 Error(
"Chi2TestX",
"one histogram is empty");
2246 if ( comparisonWW && ( sumw1 <= 0.0 && sumw2 <= 0.0 ) ){
2247 Error(
"Chi2TestX",
"Hist1 and Hist2 have both all zero errors\n");
2257 for (
Int_t i = i_start; i <= i_end; ++i) {
2258 for (
Int_t j = j_start; j <= j_end; ++j) {
2259 for (
Int_t k = k_start; k <= k_end; ++k) {
2264 Double_t cnt2 = h2->RetrieveBinContent(bin);
2266 if (scaledHistogram) {
2269 Double_t e2sq = h2->GetBinErrorSqUnchecked(bin);
2271 if (e1sq > 0) cnt1 =
TMath::Floor(cnt1 * cnt1 / e1sq + 0.5);
2274 if (e2sq > 0) cnt2 =
TMath::Floor(cnt2 * cnt2 / e2sq + 0.5);
2278 if (
Int_t(cnt1) == 0 &&
Int_t(cnt2) == 0) --ndf;
2285 if (res) res[i - i_start] = (cnt1 - nexp1) /
TMath::Sqrt(nexp1);
2294 Double_t delta = sum2 * cnt1 - sum1 * cnt2;
2295 chi2 += delta * delta / cntsum;
2300 chi2 /= sum1 * sum2;
2305 Info(
"Chi2TestX",
"There is a bin in h1 with less than 1 event.\n");
2309 Info(
"Chi2TestX",
"There is a bin in h2 with less than 1 event.\n");
2320 if ( comparisonUW ) {
2321 for (
Int_t i = i_start; i <= i_end; ++i) {
2322 for (
Int_t j = j_start; j <= j_end; ++j) {
2323 for (
Int_t k = k_start; k <= k_end; ++k) {
2328 Double_t cnt2 = h2->RetrieveBinContent(bin);
2329 Double_t e2sq = h2->GetBinErrorSqUnchecked(bin);
2332 if (cnt1 * cnt1 == 0 && cnt2 * cnt2 == 0) {
2338 if (cnt2 * cnt2 == 0 && e2sq == 0) {
2342 e2sq = sumw2 / sum2;
2347 Error(
"Chi2TestX",
"Hist2 has in bin (%d,%d,%d) zero content and zero errors\n", i, j, k);
2353 if (e2sq > 0 && cnt2 * cnt2 / e2sq < 10)
n++;
2355 Double_t var1 = sum2 * cnt2 - sum1 * e2sq;
2356 Double_t var2 = var1 * var1 + 4. * sum2 * sum2 * cnt1 * e2sq;
2361 while (var1 * var1 + cnt1 == 0 || var1 + var2 == 0) {
2364 var1 = sum2 * cnt2 - sum1 * e2sq;
2365 var2 = var1 * var1 + 4. * sum2 * sum2 * cnt1 * e2sq;
2369 while (var1 + var2 == 0) {
2372 var1 = sum2 * cnt2 - sum1 * e2sq;
2373 var2 = var1 * var1 + 4. * sum2 * sum2 * cnt1 * e2sq;
2374 while (var1 * var1 + cnt1 == 0 || var1 + var2 == 0) {
2377 var1 = sum2 * cnt2 - sum1 * e2sq;
2378 var2 = var1 * var1 + 4. * sum2 * sum2 * cnt1 * e2sq;
2383 Double_t probb = (var1 + var2) / (2. * sum2 * sum2);
2391 chi2 += delta1 * delta1 / nexp1;
2394 chi2 += delta2 * delta2 / e2sq;
2399 Double_t temp1 = sum2 * e2sq / var2;
2400 Double_t temp2 = 1.0 + (sum1 * e2sq - sum2 * cnt2) / var2;
2401 temp2 = temp1 * temp1 * sum1 * probb * (1.0 - probb) + temp2 * temp2 * e2sq / 4.0;
2414 Info(
"Chi2TestX",
"There is a bin in h1 with less than 1 event.\n");
2418 Info(
"Chi2TestX",
"There is a bin in h2 with less than 10 effective events.\n");
2428 for (
Int_t i = i_start; i <= i_end; ++i) {
2429 for (
Int_t j = j_start; j <= j_end; ++j) {
2430 for (
Int_t k = k_start; k <= k_end; ++k) {
2434 Double_t cnt2 = h2->RetrieveBinContent(bin);
2436 Double_t e2sq = h2->GetBinErrorSqUnchecked(bin);
2440 if (cnt1 * cnt1 == 0 && cnt2 * cnt2 == 0) {
2445 if (e1sq == 0 && e2sq == 0) {
2447 Error(
"Chi2TestX",
"h1 and h2 both have bin %d,%d,%d with all zero errors\n", i,j,k);
2452 Double_t delta = sum2 * cnt1 - sum1 * cnt2;
2453 chi2 += delta * delta /
sigma;
2456 Double_t temp = cnt1 * sum1 * e2sq + cnt2 * sum2 * e1sq;
2469 res[i - i_start] = z;
2472 if (e1sq > 0 && cnt1 * cnt1 / e1sq < 10)
m++;
2473 if (e2sq > 0 && cnt2 * cnt2 / e2sq < 10)
n++;
2479 Info(
"Chi2TestX",
"There is a bin in h1 with less than 10 effective events.\n");
2483 Info(
"Chi2TestX",
"There is a bin in h2 with less than 10 effective events.\n");
2501 Error(
"Chisquare",
"Function pointer is Null - return -1");
2550 Int_t nbins = nbinsx * nbinsy * nbinsz;
2555 for (
Int_t binz=1; binz <= nbinsz; ++binz) {
2556 for (
Int_t biny=1; biny <= nbinsy; ++biny) {
2557 for (
Int_t binx=1; binx <= nbinsx; ++binx) {
2560 if (onlyPositive &&
y < 0) {
2561 Error(
"ComputeIntegral",
"Bin content is negative - return a NaN value");
2572 Error(
"ComputeIntegral",
"Integral = 0, no hits in histogram bins (excluding over/underflow).");
2628 hintegrated->
Reset();
2632 for (
Int_t binz = firstZ; binz <= lastZ; ++binz) {
2633 for (
Int_t biny = firstY; biny <= lastY; ++biny) {
2634 for (
Int_t binx = firstX; binx <= lastX; ++binx) {
2635 const Int_t bin = hintegrated->
GetBin(binx, biny, binz);
2646 for (
Int_t binz = lastZ; binz >= firstZ; --binz) {
2647 for (
Int_t biny = lastY; biny >= firstY; --biny) {
2648 for (
Int_t binx = lastX; binx >= firstX; --binx) {
2649 const Int_t bin = hintegrated->
GetBin(binx, biny, binz);
2680 ((
TH1&)obj).fDirectory =
nullptr;
2694 delete [] ((
TH1&)obj).fBuffer;
2695 ((
TH1&)obj).fBuffer =
nullptr;
2701 ((
TH1&)obj).fBuffer = buf;
2731 ((
TH1&)obj).fXaxis.SetParent(&obj);
2732 ((
TH1&)obj).fYaxis.SetParent(&obj);
2733 ((
TH1&)obj).fZaxis.SetParent(&obj);
2743 ((
TH1&)obj).fFunctions->UseRWLock();
2771 oldparent = oldstats->GetParent();
2772 oldstats->SetParent(
nullptr);
2778 oldstats->SetParent(oldparent);
2790 if(newname && strlen(newname) ) {
2845 Error(
"Divide",
"Attempt to divide by a non-existing function");
2863 Int_t bin, binx, biny, binz;
2868 for (binz = 0; binz < nz; ++binz) {
2870 for (biny = 0; biny < ny; ++biny) {
2872 for (binx = 0; binx < nx; ++binx) {
2876 bin = binx + nx * (biny + ny * binz);
2913 Error(
"Divide",
"Input histogram passed does not exist (NULL).");
2976 Error(
"Divide",
"At least one of the input histograms passed does not exist (NULL).");
2989 Error(
"Divide",
"Coefficient of dividing histogram cannot be zero");
3002 Double_t b2 = h2->RetrieveBinContent(i);
3011 Double_t e2sq = h2->GetBinErrorSqUnchecked(i);
3026 fSumw2.
fArray[i] = c1sq * c2sq * (e1sq * b2sq + e2sq * b1sq) / (c2sq * c2sq * b2sq * b2sq);
3085 if (!
gPad->IsEditable())
gROOT->MakeDefCanvas();
3087 if (
gPad->GetX1() == 0 &&
gPad->GetX2() == 1 &&
3088 gPad->GetY1() == 0 &&
gPad->GetY2() == 1 &&
3096 gPad->IncrementPaletteColor(1, opt1);
3121 if (name_postfix) newName.
Form(
"%s%s",
GetName(), name_postfix);
3125 if (
gPad)
gPad->IncrementPaletteColor(1, opt);
3150 Error(
"DrawNormalized",
"Sum of weights is null. Cannot normalize histogram: %s",
GetName());
3162 if (opt.
IsNull() || opt ==
"SAME") opt +=
"HIST";
3197 Int_t range, stat, add;
3217 for (
Int_t binz = 1; binz <= nbinsz; ++binz) {
3219 for (
Int_t biny = 1; biny <= nbinsy; ++biny) {
3221 for (
Int_t binx = 1; binx <= nbinsx; ++binx) {
3319 if (!fft)
return nullptr;
3321 for (
Int_t binx = 1; binx<=ndim[0]; binx++) {
3322 for (
Int_t biny=1; biny<=ndim[1]; biny++) {
3323 for (
Int_t binz=1; binz<=ndim[2]; binz++) {
3353 if (bin <0)
return -1;
3386 if (bin <0)
return -1;
3419 if (bin <0)
return -1;
3455 for (i=0;i<ntimes;i+=stride) {
3462 auto weights =
w ? &
w[i] :
nullptr;
3463 DoFillN((ntimes-i)/stride,&
x[i],weights,stride);
3483 for (i=0;i<ntimes;i+=stride) {
3485 if (bin <0)
continue;
3490 if (bin == 0 || bin > nbins) {
3523 Int_t bin, binx, ibin, loop;
3527 if (!
f1) {
Error(
"FillRandom",
"Unknown function: %s",fname);
return; }
3537 Info(
"FillRandom",
"Using function axis and range [%g,%g]",
xmin,
xmax);
3543 Int_t nbinsx = last-first+1;
3547 for (binx=1;binx<=nbinsx;binx++) {
3549 integral[binx] = integral[binx-1] + fint;
3553 if (integral[nbinsx] == 0 ) {
3555 Error(
"FillRandom",
"Integral = zero");
return;
3557 for (bin=1;bin<=nbinsx;bin++) integral[bin] /= integral[nbinsx];
3560 for (loop=0;loop<ntimes;loop++) {
3566 +xAxis->
GetBinWidth(ibin+first)*(r1-integral[ibin])/(integral[ibin+1] - integral[ibin]);
3594 if (!
h) {
Error(
"FillRandom",
"Null histogram");
return; }
3596 Error(
"FillRandom",
"Histograms with different dimensions");
return;
3598 if (std::isnan(
h->ComputeIntegral(
true))) {
3599 Error(
"FillRandom",
"Histograms contains negative bins, does not represent probabilities");
3607 Int_t nbins = last-first+1;
3608 if (ntimes > 10*nbins) {
3610 if (inconsistency != kFullyConsistent)
return;
3611 Double_t sumw =
h->Integral(first,last);
3612 if (sumw == 0)
return;
3614 for (
Int_t bin=first;bin<=last;bin++) {
3615 Double_t mean =
h->RetrieveBinContent(bin)*ntimes/sumw;
3626 if (sumgen < ntimes) {
3628 for (i =
Int_t(sumgen+0.5); i < ntimes; ++i)
3634 else if (sumgen > ntimes) {
3636 i =
Int_t(sumgen+0.5);
3637 while( i > ntimes) {
3654 if (
h->ComputeIntegral() ==0)
return;
3657 for (loop=0;loop<ntimes;loop++) {
3683 return binx + nx*biny;
3691 return binx + nx*(biny +ny*binz);
3716 return binx + nx*biny;
3724 return binx + nx*(biny +ny*binz);
3742 Warning(
"FindFirstBinAbove",
"Invalid axis number : %d, axis x assumed\n",axis);
3756 for (
Int_t binx = firstBin; binx <= lastBin; binx++) {
3757 for (
Int_t biny = 1; biny <= nbinsy; biny++) {
3758 for (
Int_t binz = 1; binz <= nbinsz; binz++) {
3764 else if (axis == 2) {
3768 for (
Int_t biny = firstBin; biny <= lastBin; biny++) {
3769 for (
Int_t binx = 1; binx <= nbinsx; binx++) {
3770 for (
Int_t binz = 1; binz <= nbinsz; binz++) {
3776 else if (axis == 3) {
3780 for (
Int_t binz = firstBin; binz <= lastBin; binz++) {
3781 for (
Int_t binx = 1; binx <= nbinsx; binx++) {
3782 for (
Int_t biny = 1; biny <= nbinsy; biny++) {
3806 Warning(
"FindFirstBinAbove",
"Invalid axis number : %d, axis x assumed\n",axis);
3820 for (
Int_t binx = lastBin; binx >= firstBin; binx--) {
3821 for (
Int_t biny = 1; biny <= nbinsy; biny++) {
3822 for (
Int_t binz = 1; binz <= nbinsz; binz++) {
3828 else if (axis == 2) {
3832 for (
Int_t biny = lastBin; biny >= firstBin; biny--) {
3833 for (
Int_t binx = 1; binx <= nbinsx; binx++) {
3834 for (
Int_t binz = 1; binz <= nbinsz; binz++) {
3840 else if (axis == 3) {
3844 for (
Int_t binz = lastBin; binz >= firstBin; binz--) {
3845 for (
Int_t binx = 1; binx <= nbinsx; binx++) {
3846 for (
Int_t biny = 1; biny <= nbinsy; biny++) {
3903 linear= (
char*)strstr(fname,
"++");
3907 TF1 f1(fname, fname, xxmin, xxmax);
3911 TF2 f2(fname, fname);
3912 return Fit(&f2,
option,goption,xxmin,xxmax);
3915 TF3 f3(fname, fname);
3916 return Fit(&f3,
option,goption,xxmin,xxmax);
3921 if (!
f1) {
Printf(
"Unknown function: %s",fname);
return -1; }
4289 gROOT->MakeDefCanvas();
4292 Error(
"FitPanel",
"Unable to create a default canvas");
4299 if (handler && handler->
LoadPlugin() != -1) {
4301 Error(
"FitPanel",
"Unable to create the FitPanel");
4304 Error(
"FitPanel",
"Unable to find the FitPanel plug-in");
4361 asym->
Divide(top,bottom);
4368 if (h2->fBuffer) h2->BufferEmpty(1);
4375 for(
Int_t k=1; k<= zmax; k++){
4380 Double_t b = h2->RetrieveBinContent(bin);
4390 Double_t dbsq = h2->GetBinErrorSqUnchecked(bin);
4454 return (s[1] ? s[0]*s[0]/s[1] :
TMath::Abs(s[0]) );
4466 Info(
"SetHighlight",
"Supported only 1-D or 2-D histograms");
4483 return ((
TH1*)
this)->GetPainter()->GetObjectInfo(px,py);
4584 Error(
"GetQuantiles",
"Only available for 1-d histograms");
4594 Int_t nq = nprobSum;
4595 if (probSum ==
nullptr) {
4599 for (i=1;i<nq;i++) {
4604 for (i = 0; i < nq; i++) {
4606 while (ibin < nbins-1 &&
fIntegral[ibin+1] == prob[i]) {
4607 if (
fIntegral[ibin+2] == prob[i]) ibin++;
4615 if (!probSum)
delete [] prob;
4633 Double_t allcha, sumx, sumx2,
x, val, stddev, mean;
4644 allcha = sumx = sumx2 = 0;
4645 for (bin=hxfirst;bin<=hxlast;bin++) {
4648 if (val > valmax) valmax = val;
4653 if (allcha == 0)
return;
4655 stddev = sumx2/allcha - mean*mean;
4658 if (stddev == 0) stddev = binwidx*(hxlast-hxfirst+1)/4;
4665 Double_t constant = 0.5*(valmax+binwidx*allcha/(sqrtpi*stddev));
4673 if ((mean < xmin || mean >
xmax) && stddev > (
xmax-
xmin)) {
4694 Int_t nchanx = hxlast - hxfirst + 1;
4715 Int_t nchanx = hxlast - hxfirst + 1;
4718 if (nchanx <=1 || npar == 1) {
4741 const Int_t idim = 20;
4752 if (
m > idim ||
m >
n)
return;
4755 for (
l = 2;
l <=
m; ++
l) {
4757 b[
m +
l*20 - 21] = zero;
4764 for (k = hxfirst; k <= hxlast; ++k) {
4769 for (
l = 2;
l <=
m; ++
l) {
4772 da[
l-1] += power*yk;
4774 for (
l = 2;
l <=
m; ++
l) {
4776 b[
m +
l*20 - 21] += power;
4779 for (i = 3; i <=
m; ++i) {
4780 for (k = i; k <=
m; ++k) {
4781 b[k - 1 + (i-1)*20 - 21] =
b[k + (i-2)*20 - 21];
4786 for (i=0; i<
m; ++i)
a[i] = da[i];
4806 xbar = ybar = x2bar = xybar = 0;
4811 for (i = hxfirst; i <= hxlast; ++i) {
4815 if (yk <= 0) yk = 1
e-9;
4824 det = fn*x2bar - xbar*xbar;
4832 a0 = (x2bar*ybar - xbar*xybar) / det;
4833 a1 = (fn*xybar - xbar*ybar) / det;
4844 Int_t a_dim1, a_offset, b_dim1, b_offset;
4846 Int_t im1, jp1, nm1, nmi;
4852 b_offset = b_dim1 + 1;
4855 a_offset = a_dim1 + 1;
4858 if (idim <
n)
return;
4861 for (j = 1; j <=
n; ++j) {
4862 if (
a[j + j*a_dim1] <= 0) { ifail = -1;
return; }
4863 a[j + j*a_dim1] = one /
a[j + j*a_dim1];
4864 if (j ==
n)
continue;
4866 for (
l = jp1;
l <=
n; ++
l) {
4867 a[j +
l*a_dim1] =
a[j + j*a_dim1] *
a[
l + j*a_dim1];
4868 s1 = -
a[
l + (j+1)*a_dim1];
4869 for (i = 1; i <= j; ++i) {
s1 =
a[
l + i*a_dim1] *
a[i + (j+1)*a_dim1] +
s1; }
4870 a[
l + (j+1)*a_dim1] = -
s1;
4875 for (
l = 1;
l <= k; ++
l) {
4876 b[
l*b_dim1 + 1] =
a[a_dim1 + 1]*
b[
l*b_dim1 + 1];
4879 for (
l = 1;
l <= k; ++
l) {
4880 for (i = 2; i <=
n; ++i) {
4882 s21 = -
b[i +
l*b_dim1];
4883 for (j = 1; j <= im1; ++j) {
4884 s21 =
a[i + j*a_dim1]*
b[j +
l*b_dim1] + s21;
4886 b[i +
l*b_dim1] = -
a[i + i*a_dim1]*s21;
4889 for (i = 1; i <= nm1; ++i) {
4891 s22 = -
b[nmi +
l*b_dim1];
4892 for (j = 1; j <= i; ++j) {
4894 s22 =
a[nmi + nmjp1*a_dim1]*
b[nmjp1 +
l*b_dim1] + s22;
4896 b[nmi +
l*b_dim1] = -s22;
4934 if (binx < 0) binx = 0;
4935 if (binx > ofx) binx = ofx;
4950 binx = binglobal%nx;
4956 binx = binglobal%nx;
4957 biny = ((binglobal-binx)/nx)%ny;
4962 binx = binglobal%nx;
4963 biny = ((binglobal-binx)/nx)%ny;
4964 binz = ((binglobal-binx)/nx -biny)/ny;
4983 Error(
"GetRandom",
"Function only valid for 1-d histograms");
4993 integral = ((
TH1*)
this)->ComputeIntegral(
true);
4995 if (integral == 0)
return 0;
5034 if (bin < 0) bin = 0;
5060 Error(
"GetBinWithContent",
"function is only valid for 1-D histograms");
5066 if (firstx <= 0) firstx = 1;
5070 for (
Int_t i=firstx;i<=lastx;i++) {
5072 if (diff <= 0) {binx = i;
return diff;}
5073 if (diff < curmax && diff <= maxdiff) {curmax = diff, binminx=i;}
5108 return y0 + (
x-x0)*((
y1-y0)/(
x1-x0));
5117 Error(
"Interpolate",
"This function must be called with 1 argument for a TH1");
5126 Error(
"Interpolate",
"This function must be called with 1 argument for a TH1");
5154 Int_t binx, biny, binz;
5176 Error(
"IsBinOverflow",
"Invalid axis value");