601enum EInconsistencyBits {
602 kFullyConsistent = 0,
603 kDifferentLabels =
BIT(0),
604 kDifferentBinLimits =
BIT(1),
605 kDifferentAxisLimits =
BIT(2),
606 kDifferentNumberOfBins =
BIT(3),
607 kDifferentDimensions =
BIT(4)
703 if (nbins <= 0) {
Warning(
"TH1",
"nbins is <=0 - set to nbins = 1"); nbins = 1; }
725 if (nbins <= 0) {
Warning(
"TH1",
"nbins is <=0 - set to nbins = 1"); nbins = 1; }
747 if (nbins <= 0) {
Warning(
"TH1",
"nbins is <=0 - set to nbins = 1"); nbins = 1; }
766 Draw(
b ?
b->GetDrawOption() :
"");
831 Error(
"Add",
"Attempt to add a non-existing function");
851 for (
Int_t i = 0; i < 10; ++i)
s1[i] = 0;
857 Int_t bin, binx, biny, binz;
862 for (binz = 0; binz < ncellsz; ++binz) {
864 for (biny = 0; biny < ncellsy; ++biny) {
866 for (binx = 0; binx < ncellsx; ++binx) {
870 bin = binx + ncellsx * (biny + ncellsy * binz);
889 if (inconsistency & kDifferentDimensions) {
891 Info(
name,
"Histograms have different dimensions - trying to use TH1::Merge");
893 Error(
name,
"Histograms have different dimensions");
895 }
else if (inconsistency & kDifferentNumberOfBins) {
897 Info(
name,
"Histograms have different number of bins - trying to use TH1::Merge");
899 Error(
name,
"Histograms have different number of bins");
901 }
else if (inconsistency & kDifferentAxisLimits) {
903 Info(
name,
"Histograms have different axis limits - trying to use TH1::Merge");
905 Warning(
name,
"Histograms have different axis limits");
906 }
else if (inconsistency & kDifferentBinLimits) {
908 Info(
name,
"Histograms have different bin limits - trying to use TH1::Merge");
910 Warning(
name,
"Histograms have different bin limits");
911 }
else if (inconsistency & kDifferentLabels) {
914 Info(
name,
"Histograms have different labels - trying to use TH1::Merge");
916 Info(
name,
"Histograms have different labels");
919 return inconsistency;
959 Error(
"Add",
"Attempt to add a non-existing histogram");
966 bool useMerge =
false;
970 if(inconsistency >= kDifferentNumberOfBins && !considerMerge) {
974 if(inconsistency > kFullyConsistent) {
975 useMerge = considerMerge;
980 l.Add(
const_cast<TH1*
>(
h1));
1023 if (e1sq) w1 = 1. / e1sq;
1028 double sf = (s2[0] != 0) ? s2[1]/s2[0] : 1;
1032 if (e2sq) w2 = 1. / e2sq;
1037 double sf = (
s1[0] != 0) ?
s1[1]/
s1[0] : 1;
1042 double y = (w1*
y1 + w2*
y2)/(w1 + w2);
1045 double err2 = 1./(w1 + w2);
1046 if (err2 < 1.E-200) err2 = 0;
1062 if (i == 1)
s1[i] +=
c1*
c1*s2[i];
1063 else s1[i] +=
c1*s2[i];
1110 Error(
"Add",
"Attempt to add a non-existing histogram");
1118 if (
h1 == h2 &&
c2 < 0) {
c2 = 0; normWidth =
kTRUE;}
1121 bool useMerge =
false;
1130 if(inconsistency >= kDifferentNumberOfBins && !considerMerge) {
1134 if(inconsistency > kFullyConsistent) {
1135 useMerge = considerMerge;
1141 l.Add(
const_cast<TH1*
>(
h1));
1142 l.Add(
const_cast<TH1*
>(h2));
1164 Bool_t resetStats = (
c1*
c2 < 0) || normWidth;
1171 if (i == 1) s3[i] =
c1*
c1*
s1[i] +
c2*
c2*s2[i];
1173 else s3[i] =
c1*
s1[i] +
c2*s2[i];
1189 Int_t bin, binx, biny, binz;
1190 for (binz = 0; binz < nbinsz; ++binz) {
1192 for (biny = 0; biny < nbinsy; ++biny) {
1194 for (binx = 0; binx < nbinsx; ++binx) {
1196 bin =
GetBin(binx, biny, binz);
1212 Double_t e2sq = h2->GetBinErrorSqUnchecked(i);
1217 if (e1sq) w1 = 1./ e1sq;
1221 double sf = (
s1[0] != 0) ?
s1[1]/
s1[0] : 1;
1225 if (e2sq) w2 = 1./ e2sq;
1226 else if (h2->fSumw2.fN) {
1229 double sf = (s2[0] != 0) ? s2[1]/s2[0] : 1;
1234 double y = (w1*
y1 + w2*
y2)/(w1 + w2);
1237 double err2 = 1./(w1 + w2);
1238 if (err2 < 1.E-200) err2 = 0;
1314 return ((next &&
x > 0.) || (!next &&
x <= 0.)) ? std::ldexp(std::copysign(1., f2), nn)
1315 : std::ldexp(std::copysign(1., f2), --nn);
1328 return (
Int_t)std::ldexp(1., nn);
1368 Double_t rr = (xhma - xhmi) / (xma - xmi);
1378 Int_t nbup = (xhma - xma) / bw;
1381 if (nbup != nbside) {
1383 xhma -= bw * (nbup - nbside);
1384 nb -= (nbup - nbside);
1388 Int_t nblw = (xmi - xhmi) / bw;
1391 if (nblw != nbside) {
1393 xhmi += bw * (nblw - nbside);
1394 nb -= (nblw - nbside);
1424 if (nbentries == 0) {
1434 if (nbentries < 0 && action == 0)
return 0;
1437 if (nbentries < 0) {
1438 nbentries = -nbentries;
1450 for (
Int_t i=0;i<nbentries;i++) {
1453 if (!std::isfinite(
x))
continue;
1462 "inconsistency found by power-of-2 autobin algorithm: fallback to standard method");
1480 DoFillN(nbentries,&buffer[2],&buffer[1],2);
1514 if (nbentries < 0) {
1517 nbentries = -nbentries;
1549 if ( h2Array->
fN != fN ) {
1553 for (
int i = 0; i < fN; ++i ) {
1584 for (
int i = 1; i <= a1->
GetNbins(); ++i) {
1587 if (label1 != label2) {
1616 ::Info(
"CheckEqualAxes",
"Axes have different number of bins : nbin1 = %d nbin2 = %d",a1->
GetNbins(),a2->
GetNbins() );
1620 ::Info(
"CheckEqualAxes",
"Axes have different limits");
1624 ::Info(
"CheckEqualAxes",
"Axes have different bin limits");
1630 ::Info(
"CheckEqualAxes",
"Axes have different labels");
1645 Int_t nbins1 = lastBin1-firstBin1 + 1;
1653 if (firstBin2 < lastBin2) {
1655 nbins2 = lastBin1-firstBin1 + 1;
1660 if (nbins1 != nbins2 ) {
1661 ::Info(
"CheckConsistentSubAxes",
"Axes have different number of bins");
1669 ::Info(
"CheckConsistentSubAxes",
"Axes have different limits");
1681 if (
h1 == h2)
return kFullyConsistent;
1684 return kDifferentDimensions;
1694 if (nbinsx != h2->GetNbinsX() ||
1695 (dim > 1 && nbinsy != h2->GetNbinsY()) ||
1696 (dim > 2 && nbinsz != h2->GetNbinsZ()) ) {
1697 return kDifferentNumberOfBins;
1706 if (!ret)
return kDifferentAxisLimits;
1712 if (!ret)
return kDifferentBinLimits;
1715 if ( !
h1->
IsEmpty() && !h2->IsEmpty() ) {
1719 if (!ret)
return kDifferentLabels;
1722 return kFullyConsistent;
2015 Int_t ndf = 0, igood = 0;
2023 printf(
"Chi2 = %f, Prob = %g, NDF = %d, igood = %d\n", chi2,prob,ndf,igood);
2026 if (ndf == 0)
return 0;
2074 Int_t i_start, i_end;
2075 Int_t j_start, j_end;
2076 Int_t k_start, k_end;
2090 const TAxis *xaxis2 = h2->GetXaxis();
2092 const TAxis *yaxis2 = h2->GetYaxis();
2094 const TAxis *zaxis2 = h2->GetZaxis();
2105 Error(
"Chi2TestX",
"Histograms have different dimensions.");
2110 if (nbinx1 != nbinx2) {
2111 Error(
"Chi2TestX",
"different number of x channels");
2113 if (nbiny1 != nbiny2) {
2114 Error(
"Chi2TestX",
"different number of y channels");
2116 if (nbinz1 != nbinz2) {
2117 Error(
"Chi2TestX",
"different number of z channels");
2121 i_start = j_start = k_start = 1;
2152 ndf = (i_end - i_start + 1) * (j_end - j_start + 1) * (k_end - k_start + 1) - 1;
2159 if (scaledHistogram && !comparisonUU) {
2160 Info(
"Chi2TestX",
"NORM option should be used together with UU option. It is ignored");
2167 Double_t effEntries1 = (s[1] ? s[0] * s[0] / s[1] : 0.0);
2171 Double_t effEntries2 = (s[1] ? s[0] * s[0] / s[1] : 0.0);
2173 if (!comparisonUU && !comparisonUW && !comparisonWW ) {
2175 if (
TMath::Abs(sumBinContent1 - effEntries1) < 1) {
2176 if (
TMath::Abs(sumBinContent2 - effEntries2) < 1) comparisonUU =
true;
2177 else comparisonUW =
true;
2179 else comparisonWW =
true;
2183 if (
TMath::Abs(sumBinContent1 - effEntries1) >= 1) {
2184 Warning(
"Chi2TestX",
"First histogram is not unweighted and option UW has been requested");
2187 if ( (!scaledHistogram && comparisonUU) ) {
2188 if ( (
TMath::Abs(sumBinContent1 - effEntries1) >= 1) || (
TMath::Abs(sumBinContent2 - effEntries2) >= 1) ) {
2189 Warning(
"Chi2TestX",
"Both histograms are not unweighted and option UU has been requested");
2195 if (comparisonUU && scaledHistogram) {
2196 for (
Int_t i = i_start; i <= i_end; ++i) {
2197 for (
Int_t j = j_start; j <= j_end; ++j) {
2198 for (
Int_t k = k_start; k <= k_end; ++k) {
2203 Double_t cnt2 = h2->RetrieveBinContent(bin);
2205 Double_t e2sq = h2->GetBinErrorSqUnchecked(bin);
2207 if (e1sq > 0.0) cnt1 =
TMath::Floor(cnt1 * cnt1 / e1sq + 0.5);
2210 if (e2sq > 0.0) cnt2 =
TMath::Floor(cnt2 * cnt2 / e2sq + 0.5);
2221 if (sumw1 <= 0.0 || sumw2 <= 0.0) {
2222 Error(
"Chi2TestX",
"Cannot use option NORM when one histogram has all zero errors");
2227 for (
Int_t i = i_start; i <= i_end; ++i) {
2228 for (
Int_t j = j_start; j <= j_end; ++j) {
2229 for (
Int_t k = k_start; k <= k_end; ++k) {
2234 sum2 += h2->RetrieveBinContent(bin);
2237 if ( comparisonUW || comparisonWW ) sumw2 += h2->GetBinErrorSqUnchecked(bin);
2243 if (sum1 == 0.0 || sum2 == 0.0) {
2244 Error(
"Chi2TestX",
"one histogram is empty");
2248 if ( comparisonWW && ( sumw1 <= 0.0 && sumw2 <= 0.0 ) ){
2249 Error(
"Chi2TestX",
"Hist1 and Hist2 have both all zero errors\n");
2259 for (
Int_t i = i_start; i <= i_end; ++i) {
2260 for (
Int_t j = j_start; j <= j_end; ++j) {
2261 for (
Int_t k = k_start; k <= k_end; ++k) {
2266 Double_t cnt2 = h2->RetrieveBinContent(bin);
2268 if (scaledHistogram) {
2271 Double_t e2sq = h2->GetBinErrorSqUnchecked(bin);
2273 if (e1sq > 0) cnt1 =
TMath::Floor(cnt1 * cnt1 / e1sq + 0.5);
2276 if (e2sq > 0) cnt2 =
TMath::Floor(cnt2 * cnt2 / e2sq + 0.5);
2280 if (
Int_t(cnt1) == 0 &&
Int_t(cnt2) == 0) --ndf;
2287 if (res) res[i - i_start] = (cnt1 - nexp1) /
TMath::Sqrt(nexp1);
2296 Double_t delta = sum2 * cnt1 - sum1 * cnt2;
2297 chi2 += delta * delta / cntsum;
2302 chi2 /= sum1 * sum2;
2307 Info(
"Chi2TestX",
"There is a bin in h1 with less than 1 event.\n");
2311 Info(
"Chi2TestX",
"There is a bin in h2 with less than 1 event.\n");
2322 if ( comparisonUW ) {
2323 for (
Int_t i = i_start; i <= i_end; ++i) {
2324 for (
Int_t j = j_start; j <= j_end; ++j) {
2325 for (
Int_t k = k_start; k <= k_end; ++k) {
2330 Double_t cnt2 = h2->RetrieveBinContent(bin);
2331 Double_t e2sq = h2->GetBinErrorSqUnchecked(bin);
2334 if (cnt1 * cnt1 == 0 && cnt2 * cnt2 == 0) {
2340 if (cnt2 * cnt2 == 0 && e2sq == 0) {
2344 e2sq = sumw2 / sum2;
2349 Error(
"Chi2TestX",
"Hist2 has in bin (%d,%d,%d) zero content and zero errors\n", i, j, k);
2355 if (e2sq > 0 && cnt2 * cnt2 / e2sq < 10)
n++;
2357 Double_t var1 = sum2 * cnt2 - sum1 * e2sq;
2358 Double_t var2 = var1 * var1 + 4. * sum2 * sum2 * cnt1 * e2sq;
2363 while (var1 * var1 + cnt1 == 0 || var1 + var2 == 0) {
2366 var1 = sum2 * cnt2 - sum1 * e2sq;
2367 var2 = var1 * var1 + 4. * sum2 * sum2 * cnt1 * e2sq;
2371 while (var1 + var2 == 0) {
2374 var1 = sum2 * cnt2 - sum1 * e2sq;
2375 var2 = var1 * var1 + 4. * sum2 * sum2 * cnt1 * e2sq;
2376 while (var1 * var1 + cnt1 == 0 || var1 + var2 == 0) {
2379 var1 = sum2 * cnt2 - sum1 * e2sq;
2380 var2 = var1 * var1 + 4. * sum2 * sum2 * cnt1 * e2sq;
2385 Double_t probb = (var1 + var2) / (2. * sum2 * sum2);
2393 chi2 += delta1 * delta1 / nexp1;
2396 chi2 += delta2 * delta2 / e2sq;
2401 Double_t temp1 = sum2 * e2sq / var2;
2402 Double_t temp2 = 1.0 + (sum1 * e2sq - sum2 * cnt2) / var2;
2403 temp2 = temp1 * temp1 * sum1 * probb * (1.0 - probb) + temp2 * temp2 * e2sq / 4.0;
2416 Info(
"Chi2TestX",
"There is a bin in h1 with less than 1 event.\n");
2420 Info(
"Chi2TestX",
"There is a bin in h2 with less than 10 effective events.\n");
2430 for (
Int_t i = i_start; i <= i_end; ++i) {
2431 for (
Int_t j = j_start; j <= j_end; ++j) {
2432 for (
Int_t k = k_start; k <= k_end; ++k) {
2436 Double_t cnt2 = h2->RetrieveBinContent(bin);
2438 Double_t e2sq = h2->GetBinErrorSqUnchecked(bin);
2442 if (cnt1 * cnt1 == 0 && cnt2 * cnt2 == 0) {
2447 if (e1sq == 0 && e2sq == 0) {
2449 Error(
"Chi2TestX",
"h1 and h2 both have bin %d,%d,%d with all zero errors\n", i,j,k);
2454 Double_t delta = sum2 * cnt1 - sum1 * cnt2;
2455 chi2 += delta * delta /
sigma;
2458 Double_t temp = cnt1 * sum1 * e2sq + cnt2 * sum2 * e1sq;
2471 res[i - i_start] = z;
2474 if (e1sq > 0 && cnt1 * cnt1 / e1sq < 10)
m++;
2475 if (e2sq > 0 && cnt2 * cnt2 / e2sq < 10)
n++;
2481 Info(
"Chi2TestX",
"There is a bin in h1 with less than 10 effective events.\n");
2485 Info(
"Chi2TestX",
"There is a bin in h2 with less than 10 effective events.\n");
2503 Error(
"Chisquare",
"Function pointer is Null - return -1");
2552 Int_t nbins = nbinsx * nbinsy * nbinsz;
2557 for (
Int_t binz=1; binz <= nbinsz; ++binz) {
2558 for (
Int_t biny=1; biny <= nbinsy; ++biny) {
2559 for (
Int_t binx=1; binx <= nbinsx; ++binx) {
2562 if (onlyPositive &&
y < 0) {
2563 Error(
"ComputeIntegral",
"Bin content is negative - return a NaN value");
2574 Error(
"ComputeIntegral",
"Integral = 0, no hits in histogram bins (excluding over/underflow).");
2630 hintegrated->
Reset();
2634 for (
Int_t binz = firstZ; binz <= lastZ; ++binz) {
2635 for (
Int_t biny = firstY; biny <= lastY; ++biny) {
2636 for (
Int_t binx = firstX; binx <= lastX; ++binx) {
2637 const Int_t bin = hintegrated->
GetBin(binx, biny, binz);
2648 for (
Int_t binz = lastZ; binz >= firstZ; --binz) {
2649 for (
Int_t biny = lastY; biny >= firstY; --biny) {
2650 for (
Int_t binx = lastX; binx >= firstX; --binx) {
2651 const Int_t bin = hintegrated->
GetBin(binx, biny, binz);
2682 ((
TH1&)obj).fDirectory =
nullptr;
2696 delete [] ((
TH1&)obj).fBuffer;
2697 ((
TH1&)obj).fBuffer =
nullptr;
2703 ((
TH1&)obj).fBuffer = buf;
2733 ((
TH1&)obj).fXaxis.SetParent(&obj);
2734 ((
TH1&)obj).fYaxis.SetParent(&obj);
2735 ((
TH1&)obj).fZaxis.SetParent(&obj);
2745 ((
TH1&)obj).fFunctions->UseRWLock();
2773 oldparent = oldstats->GetParent();
2774 oldstats->SetParent(
nullptr);
2780 oldstats->SetParent(oldparent);
2792 if(newname && strlen(newname) ) {
2847 Error(
"Divide",
"Attempt to divide by a non-existing function");
2865 Int_t bin, binx, biny, binz;
2870 for (binz = 0; binz < nz; ++binz) {
2872 for (biny = 0; biny < ny; ++biny) {
2874 for (binx = 0; binx < nx; ++binx) {
2878 bin = binx + nx * (biny + ny * binz);
2915 Error(
"Divide",
"Input histogram passed does not exist (NULL).");
2978 Error(
"Divide",
"At least one of the input histograms passed does not exist (NULL).");
2991 Error(
"Divide",
"Coefficient of dividing histogram cannot be zero");
3004 Double_t b2 = h2->RetrieveBinContent(i);
3013 Double_t e2sq = h2->GetBinErrorSqUnchecked(i);
3028 fSumw2.
fArray[i] = c1sq * c2sq * (e1sq * b2sq + e2sq * b1sq) / (c2sq * c2sq * b2sq * b2sq);
3087 if (!
gPad->IsEditable())
gROOT->MakeDefCanvas();
3089 if (
gPad->GetX1() == 0 &&
gPad->GetX2() == 1 &&
3090 gPad->GetY1() == 0 &&
gPad->GetY2() == 1 &&
3098 gPad->IncrementPaletteColor(1, opt1);
3123 if (name_postfix) newName.
Form(
"%s%s",
GetName(), name_postfix);
3127 if (
gPad)
gPad->IncrementPaletteColor(1, opt);
3152 Error(
"DrawNormalized",
"Sum of weights is null. Cannot normalize histogram: %s",
GetName());
3164 if (opt.
IsNull() || opt ==
"SAME") opt +=
"HIST";
3199 Int_t range, stat, add;
3219 for (
Int_t binz = 1; binz <= nbinsz; ++binz) {
3221 for (
Int_t biny = 1; biny <= nbinsy; ++biny) {
3223 for (
Int_t binx = 1; binx <= nbinsx; ++binx) {
3321 if (!fft)
return nullptr;
3323 for (
Int_t binx = 1; binx<=ndim[0]; binx++) {
3324 for (
Int_t biny=1; biny<=ndim[1]; biny++) {
3325 for (
Int_t binz=1; binz<=ndim[2]; binz++) {
3355 if (bin <0)
return -1;
3388 if (bin <0)
return -1;
3421 if (bin <0)
return -1;
3457 for (i=0;i<ntimes;i+=stride) {
3464 auto weights =
w ? &
w[i] :
nullptr;
3465 DoFillN((ntimes-i)/stride,&
x[i],weights,stride);
3485 for (i=0;i<ntimes;i+=stride) {
3487 if (bin <0)
continue;
3492 if (bin == 0 || bin > nbins) {
3527 if (!
f1) {
Error(
"FillRandom",
"Unknown function: %s",fname);
return; }
3534 Int_t bin, binx, ibin, loop;
3545 Info(
"FillRandom",
"Using function axis and range [%g,%g]",
xmin,
xmax);
3551 Int_t nbinsx = last-first+1;
3555 for (binx=1;binx<=nbinsx;binx++) {
3557 integral[binx] = integral[binx-1] + fint;
3561 if (integral[nbinsx] == 0 ) {
3563 Error(
"FillRandom",
"Integral = zero");
return;
3565 for (bin=1;bin<=nbinsx;bin++) integral[bin] /= integral[nbinsx];
3568 for (loop=0;loop<ntimes;loop++) {
3574 +xAxis->
GetBinWidth(ibin+first)*(r1-integral[ibin])/(integral[ibin+1] - integral[ibin]);
3602 if (!
h) {
Error(
"FillRandom",
"Null histogram");
return; }
3604 Error(
"FillRandom",
"Histograms with different dimensions");
return;
3606 if (std::isnan(
h->ComputeIntegral(
true))) {
3607 Error(
"FillRandom",
"Histograms contains negative bins, does not represent probabilities");
3615 Int_t nbins = last-first+1;
3616 if (ntimes > 10*nbins) {
3618 if (inconsistency != kFullyConsistent)
return;
3619 Double_t sumw =
h->Integral(first,last);
3620 if (sumw == 0)
return;
3622 for (
Int_t bin=first;bin<=last;bin++) {
3623 Double_t mean =
h->RetrieveBinContent(bin)*ntimes/sumw;
3634 if (sumgen < ntimes) {
3636 for (i =
Int_t(sumgen+0.5); i < ntimes; ++i)
3642 else if (sumgen > ntimes) {
3644 i =
Int_t(sumgen+0.5);
3645 while( i > ntimes) {
3662 if (
h->ComputeIntegral() ==0)
return;
3665 for (loop=0;loop<ntimes;loop++) {
3691 return binx + nx*biny;
3699 return binx + nx*(biny +ny*binz);
3724 return binx + nx*biny;
3732 return binx + nx*(biny +ny*binz);
3750 Warning(
"FindFirstBinAbove",
"Invalid axis number : %d, axis x assumed\n",axis);
3764 for (
Int_t binx = firstBin; binx <= lastBin; binx++) {
3765 for (
Int_t biny = 1; biny <= nbinsy; biny++) {
3766 for (
Int_t binz = 1; binz <= nbinsz; binz++) {
3772 else if (axis == 2) {
3776 for (
Int_t biny = firstBin; biny <= lastBin; biny++) {
3777 for (
Int_t binx = 1; binx <= nbinsx; binx++) {
3778 for (
Int_t binz = 1; binz <= nbinsz; binz++) {
3784 else if (axis == 3) {
3788 for (
Int_t binz = firstBin; binz <= lastBin; binz++) {
3789 for (
Int_t binx = 1; binx <= nbinsx; binx++) {
3790 for (
Int_t biny = 1; biny <= nbinsy; biny++) {
3814 Warning(
"FindFirstBinAbove",
"Invalid axis number : %d, axis x assumed\n",axis);
3828 for (
Int_t binx = lastBin; binx >= firstBin; binx--) {
3829 for (
Int_t biny = 1; biny <= nbinsy; biny++) {
3830 for (
Int_t binz = 1; binz <= nbinsz; binz++) {
3836 else if (axis == 2) {
3840 for (
Int_t biny = lastBin; biny >= firstBin; biny--) {
3841 for (
Int_t binx = 1; binx <= nbinsx; binx++) {
3842 for (
Int_t binz = 1; binz <= nbinsz; binz++) {
3848 else if (axis == 3) {
3852 for (
Int_t binz = lastBin; binz >= firstBin; binz--) {
3853 for (
Int_t binx = 1; binx <= nbinsx; binx++) {
3854 for (
Int_t biny = 1; biny <= nbinsy; biny++) {
3911 linear= (
char*)strstr(fname,
"++");
3915 TF1 f1(fname, fname, xxmin, xxmax);
3919 TF2 f2(fname, fname);
3920 return Fit(&f2,
option,goption,xxmin,xxmax);
3923 TF3 f3(fname, fname);
3924 return Fit(&f3,
option,goption,xxmin,xxmax);
3929 if (!
f1) {
Printf(
"Unknown function: %s",fname);
return -1; }
4297 gROOT->MakeDefCanvas();
4300 Error(
"FitPanel",
"Unable to create a default canvas");
4307 if (handler && handler->
LoadPlugin() != -1) {
4309 Error(
"FitPanel",
"Unable to create the FitPanel");
4312 Error(
"FitPanel",
"Unable to find the FitPanel plug-in");
4369 asym->
Divide(top,bottom);
4376 if (h2->fBuffer) h2->BufferEmpty(1);
4383 for(
Int_t k=1; k<= zmax; k++){
4388 Double_t b = h2->RetrieveBinContent(bin);
4398 Double_t dbsq = h2->GetBinErrorSqUnchecked(bin);
4462 return (s[1] ? s[0]*s[0]/s[1] :
TMath::Abs(s[0]) );
4481 if (markercolor >= 0)
4497 Info(
"SetHighlight",
"Supported only 1-D or 2-D histograms");
4514 return ((
TH1*)
this)->GetPainter()->GetObjectInfo(px,py);
4624 Error(
"GetQuantiles",
"Only available for 1-d histograms");
4639 for (i=1;i<nq;i++) {
4644 for (i = 0; i < nq; i++) {
4647 if (prob[i] == 0.) {
4648 for (; ibin+1 <= nbins &&
fIntegral[ibin+1] == 0.; ++ibin) {
4653 else if (prob[i] == 1.) {
4659 for (
Int_t j = ibin+1; j <= nbins; ++j) {
4676 if (!
p)
delete [] prob;
4694 Double_t allcha, sumx, sumx2,
x, val, stddev, mean;
4705 allcha = sumx = sumx2 = 0;
4706 for (bin=hxfirst;bin<=hxlast;bin++) {
4709 if (val > valmax) valmax = val;
4714 if (allcha == 0)
return;
4716 stddev = sumx2/allcha - mean*mean;
4719 if (stddev == 0) stddev = binwidx*(hxlast-hxfirst+1)/4;
4726 Double_t constant = 0.5*(valmax+binwidx*allcha/(sqrtpi*stddev));
4734 if ((mean < xmin || mean >
xmax) && stddev > (
xmax-
xmin)) {
4755 Int_t nchanx = hxlast - hxfirst + 1;
4776 Int_t nchanx = hxlast - hxfirst + 1;
4779 if (nchanx <=1 || npar == 1) {
4802 const Int_t idim = 20;
4813 if (
m > idim ||
m >
n)
return;
4816 for (
l = 2;
l <=
m; ++
l) {
4818 b[
m +
l*20 - 21] = zero;
4825 for (k = hxfirst; k <= hxlast; ++k) {
4830 for (
l = 2;
l <=
m; ++
l) {
4833 da[
l-1] += power*yk;
4835 for (
l = 2;
l <=
m; ++
l) {
4837 b[
m +
l*20 - 21] += power;
4840 for (i = 3; i <=
m; ++i) {
4841 for (k = i; k <=
m; ++k) {
4842 b[k - 1 + (i-1)*20 - 21] =
b[k + (i-2)*20 - 21];
4847 for (i=0; i<
m; ++i)
a[i] = da[i];
4867 xbar = ybar = x2bar = xybar = 0;
4872 for (i = hxfirst; i <= hxlast; ++i) {
4876 if (yk <= 0) yk = 1
e-9;
4885 det = fn*x2bar - xbar*xbar;
4893 a0 = (x2bar*ybar - xbar*xybar) / det;
4894 a1 = (fn*xybar - xbar*ybar) / det;
4905 Int_t a_dim1, a_offset, b_dim1, b_offset;
4907 Int_t im1, jp1, nm1, nmi;
4913 b_offset = b_dim1 + 1;
4916 a_offset = a_dim1 + 1;
4919 if (idim <
n)
return;
4922 for (j = 1; j <=
n; ++j) {
4923 if (
a[j + j*a_dim1] <= 0) { ifail = -1;
return; }
4924 a[j + j*a_dim1] = one /
a[j + j*a_dim1];
4925 if (j ==
n)
continue;
4927 for (
l = jp1;
l <=
n; ++
l) {
4928 a[j +
l*a_dim1] =
a[j + j*a_dim1] *
a[
l + j*a_dim1];
4929 s1 = -
a[
l + (j+1)*a_dim1];
4930 for (i = 1; i <= j; ++i) {
s1 =
a[
l + i*a_dim1] *
a[i + (j+1)*a_dim1] +
s1; }
4931 a[
l + (j+1)*a_dim1] = -
s1;
4936 for (
l = 1;
l <= k; ++
l) {
4937 b[
l*b_dim1 + 1] =
a[a_dim1 + 1]*
b[
l*b_dim1 + 1];
4940 for (
l = 1;
l <= k; ++
l) {
4941 for (i = 2; i <=
n; ++i) {
4943 s21 = -
b[i +
l*b_dim1];
4944 for (j = 1; j <= im1; ++j) {
4945 s21 =
a[i + j*a_dim1]*
b[j +
l*b_dim1] + s21;
4947 b[i +
l*b_dim1] = -
a[i + i*a_dim1]*s21;
4950 for (i = 1; i <= nm1; ++i) {
4952 s22 = -
b[nmi +
l*b_dim1];
4953 for (j = 1; j <= i; ++j) {
4955 s22 =
a[nmi + nmjp1*a_dim1]*
b[nmjp1 +
l*b_dim1] + s22;
4957 b[nmi +
l*b_dim1] = -s22;
4995 if (binx < 0) binx = 0;
4996 if (binx > ofx) binx = ofx;
5011 binx = binglobal%nx;
5017 binx = binglobal%nx;
5018 biny = ((binglobal-binx)/nx)%ny;
5023 binx = binglobal%nx;
5024 biny = ((binglobal-binx)/nx)%ny;
5025 binz = ((binglobal-binx)/nx -biny)/ny;
5044 Error(
"GetRandom",
"Function only valid for 1-d histograms");
5054 integral = ((
TH1*)
this)->ComputeIntegral(
true);
5056 if (integral == 0)
return 0;
5095 if (bin < 0) bin = 0;
5121 Error(
"GetBinWithContent",
"function is only valid for 1-D histograms");
5127 if (firstx <= 0) firstx = 1;
5131 for (
Int_t i=firstx;i<=lastx;i++) {
5133 if (diff <= 0) {binx = i;
return diff;}
5134 if (diff < curmax && diff <= maxdiff) {curmax = diff, binminx=i;}
5169 return y0 + (
x-x0)*((
y1-y0)/(
x1-x0));
5178 Error(
"Interpolate",
"This function must be called with 1 argument for a TH1");
5187 Error(
"Interpolate",
"This function must be called with 1 argument for a TH1&