539 class DifferentDimension:
public std::exception {};
540 class DifferentNumberOfBins:
public std::exception {};
541 class DifferentAxisLimits:
public std::exception {};
542 class DifferentBinLimits:
public std::exception {};
543 class DifferentLabels:
public std::exception {};
643 if (nbins <= 0) {
Warning(
"TH1",
"nbins is <=0 - set to nbins = 1"); nbins = 1; }
665 if (nbins <= 0) {
Warning(
"TH1",
"nbins is <=0 - set to nbins = 1"); nbins = 1; }
687 if (nbins <= 0) {
Warning(
"TH1",
"nbins is <=0 - set to nbins = 1"); nbins = 1; }
754 fFunctions->UseRWLock();
780 Error(
"Add",
"Attempt to add a non-existing function");
800 for (
Int_t i = 0; i < 10; ++i) s1[i] = 0;
806 Int_t bin, binx, biny, binz;
811 for (binz = 0; binz < ncellsz; ++binz) {
813 for (biny = 0; biny < ncellsy; ++biny) {
815 for (binx = 0; binx < ncellsx; ++binx) {
819 bin = binx + ncellsx * (biny + ncellsy * binz);
865 Error(
"Add",
"Attempt to add a non-existing histogram");
876 }
catch(DifferentNumberOfBins&) {
878 Info(
"Add",
"Attempt to add histograms with different number of bins - trying to use TH1::Merge");
880 Error(
"Add",
"Attempt to add histograms with different number of bins : nbins h1 = %d , nbins h2 = %d",
GetNbinsX(), h1->
GetNbinsX());
883 }
catch(DifferentAxisLimits&) {
885 Info(
"Add",
"Attempt to add histograms with different axis limits - trying to use TH1::Merge");
887 Warning(
"Add",
"Attempt to add histograms with different axis limits");
888 }
catch(DifferentBinLimits&) {
890 Info(
"Add",
"Attempt to add histograms with different bin limits - trying to use TH1::Merge");
892 Warning(
"Add",
"Attempt to add histograms with different bin limits");
893 }
catch(DifferentLabels&) {
896 Info(
"Add",
"Attempt to add histograms with different labels - trying to use TH1::Merge");
898 Info(
"Warning",
"Attempt to add histograms with different labels");
903 l.
Add(const_cast<TH1*>(h1));
904 auto iret =
Merge(&l);
916 Bool_t resetStats = (c1 < 0);
946 if (e1sq) w1 = 1. / e1sq;
951 double sf = (s2[0] != 0) ? s2[1]/s2[0] : 1;
955 if (e2sq) w2 = 1. / e2sq;
960 double sf = (s1[0] != 0) ? s1[1]/s1[0] : 1;
965 double y = (w1*y1 + w2*y2)/(w1 + w2);
968 double err2 = 1./(w1 + w2);
969 if (err2 < 1.
E-200) err2 = 0;
985 if (i == 1) s1[i] += c1*c1*s2[i];
986 else s1[i] += c1*s2[i];
1027 Error(
"Add",
"Attempt to add a non-existing histogram");
1035 if (h1 == h2 && c2 < 0) {c2 = 0; normWidth =
kTRUE;}
1044 }
catch(DifferentNumberOfBins&) {
1046 Info(
"Add",
"Attempt to add histograms with different number of bins - trying to use TH1::Merge");
1048 Error(
"Add",
"Attempt to add histograms with different number of bins : nbins h1 = %d , nbins h2 = %d",
GetNbinsX(), h1->
GetNbinsX());
1051 }
catch(DifferentAxisLimits&) {
1053 Info(
"Add",
"Attempt to add histograms with different axis limits - trying to use TH1::Merge");
1055 Warning(
"Add",
"Attempt to add histograms with different axis limits");
1056 }
catch(DifferentBinLimits&) {
1058 Info(
"Add",
"Attempt to add histograms with different bin limits - trying to use TH1::Merge");
1060 Warning(
"Add",
"Attempt to add histograms with different bin limits");
1061 }
catch(DifferentLabels&) {
1064 Info(
"Add",
"Attempt to add histograms with different labels - trying to use TH1::Merge");
1066 Info(
"Warning",
"Attempt to add histograms with different labels");
1072 l.
Add(const_cast<TH1*>(h1));
1073 l.
Add(const_cast<TH1*>(h2));
1075 auto iret =
Merge(&l);
1095 Bool_t resetStats = (c1*c2 < 0) || normWidth;
1102 if (i == 1) s3[i] = c1*c1*s1[i] + c2*c2*s2[i];
1104 else s3[i] = c1*s1[i] + c2*s2[i];
1120 Int_t bin, binx, biny, binz;
1121 for (binz = 0; binz < nbinsz; ++binz) {
1123 for (biny = 0; biny < nbinsy; ++biny) {
1125 for (binx = 0; binx < nbinsx; ++binx) {
1127 bin =
GetBin(binx, biny, binz);
1148 if (e1sq) w1 = 1./ e1sq;
1152 double sf = (s1[0] != 0) ? s1[1]/s1[0] : 1;
1156 if (e2sq) w2 = 1./ e2sq;
1160 double sf = (s2[0] != 0) ? s2[1]/s2[0] : 1;
1165 double y = (w1*y1 + w2*y2)/(w1 + w2);
1168 double err2 = 1./(w1 + w2);
1169 if (err2 < 1.
E-200) err2 = 0;
1243 return ((next && x > 0.) || (!next && x <= 0.)) ?
std::ldexp(std::copysign(1., f2), nn)
1298 Double_t rr = (xhma - xhmi) / (xma - xmi);
1308 Int_t nbup = (xhma - xma) / bw;
1311 if (nbup != nbside) {
1313 xhma -= bw * (nbup - nbside);
1314 nb -= (nbup - nbside);
1318 Int_t nblw = (xmi - xhmi) / bw;
1321 if (nblw != nbside) {
1323 xhmi += bw * (nblw - nbside);
1324 nb -= (nblw - nbside);
1354 if (nbentries == 0) {
1364 if (nbentries < 0 && action == 0)
return 0;
1367 if (nbentries < 0) {
1368 nbentries = -nbentries;
1380 for (
Int_t i=1;i<nbentries;i++) {
1382 if (x < xmin) xmin =
x;
1383 if (x > xmax) xmax =
x;
1390 "incosistency found by power-of-2 autobin algorithm: fallback to standard method");
1408 DoFillN(nbentries,&buffer[2],&buffer[1],2);
1442 if (nbentries < 0) {
1445 nbentries = -nbentries;
1477 if ( h2Array->
fN != fN ) {
1478 throw DifferentBinLimits();
1482 for (
int i = 0; i < fN; ++i ) {
1484 throw DifferentBinLimits();
1505 throw DifferentLabels();
1510 throw DifferentLabels();
1513 for (
int i = 1; i <= a1->
GetNbins(); ++i) {
1516 if (label1 != label2) {
1517 throw DifferentLabels();
1533 throw DifferentAxisLimits();
1546 ::Info(
"CheckEqualAxes",
"Axes have different number of bins : nbin1 = %d nbin2 = %d",a1->
GetNbins(),a2->
GetNbins() );
1551 }
catch (DifferentAxisLimits&) {
1552 ::Info(
"CheckEqualAxes",
"Axes have different limits");
1557 }
catch (DifferentBinLimits&) {
1558 ::Info(
"CheckEqualAxes",
"Axes have different bin limits");
1565 }
catch (DifferentLabels&) {
1566 ::Info(
"CheckEqualAxes",
"Axes have different labels");
1581 Int_t nbins1 = lastBin1-firstBin1 + 1;
1589 if (firstBin2 < lastBin2) {
1591 nbins2 = lastBin1-firstBin1 + 1;
1596 if (nbins1 != nbins2 ) {
1597 ::Info(
"CheckConsistentSubAxes",
"Axes have different number of bins");
1603 ::Info(
"CheckConsistentSubAxes",
"Axes have different limits");
1615 if (h1 == h2)
return true;
1618 throw DifferentDimension();
1630 (dim > 1 && nbinsy != h2->
GetNbinsY()) ||
1631 (dim > 2 && nbinsz != h2->
GetNbinsZ()) ) {
1632 throw DifferentNumberOfBins();
1947 Int_t ndf = 0, igood = 0;
1955 printf(
"Chi2 = %f, Prob = %g, NDF = %d, igood = %d\n", chi2,prob,ndf,igood);
1958 if (ndf == 0)
return 0;
2006 Int_t i_start, i_end;
2007 Int_t j_start, j_end;
2008 Int_t k_start, k_end;
2037 Error(
"Chi2TestX",
"Histograms have different dimensions.");
2042 if (nbinx1 != nbinx2) {
2043 Error(
"Chi2TestX",
"different number of x channels");
2045 if (nbiny1 != nbiny2) {
2046 Error(
"Chi2TestX",
"different number of y channels");
2048 if (nbinz1 != nbinz2) {
2049 Error(
"Chi2TestX",
"different number of z channels");
2053 i_start = j_start = k_start = 1;
2084 ndf = (i_end - i_start + 1) * (j_end - j_start + 1) * (k_end - k_start + 1) - 1;
2091 if (scaledHistogram && !comparisonUU) {
2092 Info(
"Chi2TestX",
"NORM option should be used together with UU option. It is ignored");
2099 Double_t effEntries1 = (s[1] ? s[0] * s[0] / s[1] : 0.0);
2103 Double_t effEntries2 = (s[1] ? s[0] * s[0] / s[1] : 0.0);
2105 if (!comparisonUU && !comparisonUW && !comparisonWW ) {
2107 if (
TMath::Abs(sumBinContent1 - effEntries1) < 1) {
2108 if (
TMath::Abs(sumBinContent2 - effEntries2) < 1) comparisonUU =
true;
2109 else comparisonUW =
true;
2111 else comparisonWW =
true;
2115 if (
TMath::Abs(sumBinContent1 - effEntries1) >= 1) {
2116 Warning(
"Chi2TestX",
"First histogram is not unweighted and option UW has been requested");
2119 if ( (!scaledHistogram && comparisonUU) ) {
2120 if ( (
TMath::Abs(sumBinContent1 - effEntries1) >= 1) || (
TMath::Abs(sumBinContent2 - effEntries2) >= 1) ) {
2121 Warning(
"Chi2TestX",
"Both histograms are not unweighted and option UU has been requested");
2127 if (comparisonUU && scaledHistogram) {
2128 for (
Int_t i = i_start; i <= i_end; ++i) {
2129 for (
Int_t j = j_start; j <= j_end; ++j) {
2130 for (
Int_t k = k_start; k <= k_end; ++k) {
2139 if (e1sq > 0.0) cnt1 =
TMath::Floor(cnt1 * cnt1 / e1sq + 0.5);
2142 if (e2sq > 0.0) cnt2 =
TMath::Floor(cnt2 * cnt2 / e2sq + 0.5);
2153 if (sumw1 <= 0.0 || sumw2 <= 0.0) {
2154 Error(
"Chi2TestX",
"Cannot use option NORM when one histogram has all zero errors");
2159 for (
Int_t i = i_start; i <= i_end; ++i) {
2160 for (
Int_t j = j_start; j <= j_end; ++j) {
2161 for (
Int_t k = k_start; k <= k_end; ++k) {
2175 if (sum1 == 0.0 || sum2 == 0.0) {
2176 Error(
"Chi2TestX",
"one histogram is empty");
2180 if ( comparisonWW && ( sumw1 <= 0.0 && sumw2 <= 0.0 ) ){
2181 Error(
"Chi2TestX",
"Hist1 and Hist2 have both all zero errors\n");
2191 for (
Int_t i = i_start; i <= i_end; ++i) {
2192 for (
Int_t j = j_start; j <= j_end; ++j) {
2193 for (
Int_t k = k_start; k <= k_end; ++k) {
2200 if (scaledHistogram) {
2205 if (e1sq > 0) cnt1 =
TMath::Floor(cnt1 * cnt1 / e1sq + 0.5);
2208 if (e2sq > 0) cnt2 =
TMath::Floor(cnt2 * cnt2 / e2sq + 0.5);
2212 if (
Int_t(cnt1) == 0 &&
Int_t(cnt2) == 0) --ndf;
2219 if (res) res[i - i_start] = (cnt1 - nexp1) /
TMath::Sqrt(nexp1);
2225 Double_t correc = (1. - sum1 /
sum) * (1. - cntsum / sum);
2228 Double_t delta = sum2 * cnt1 - sum1 * cnt2;
2229 chi2 += delta * delta / cntsum;
2234 chi2 /= sum1 * sum2;
2239 Info(
"Chi2TestX",
"There is a bin in h1 with less than 1 event.\n");
2243 Info(
"Chi2TestX",
"There is a bin in h2 with less than 1 event.\n");
2254 if ( comparisonUW ) {
2255 for (
Int_t i = i_start; i <= i_end; ++i) {
2256 for (
Int_t j = j_start; j <= j_end; ++j) {
2257 for (
Int_t k = k_start; k <= k_end; ++k) {
2266 if (cnt1 * cnt1 == 0 && cnt2 * cnt2 == 0) {
2272 if (cnt2 * cnt2 == 0 && e2sq == 0) {
2276 e2sq = sumw2 / sum2;
2281 Error(
"Chi2TestX",
"Hist2 has in bin (%d,%d,%d) zero content and zero errors\n", i, j, k);
2287 if (e2sq > 0 && cnt2 * cnt2 / e2sq < 10)
n++;
2289 Double_t var1 = sum2 * cnt2 - sum1 * e2sq;
2290 Double_t var2 = var1 * var1 + 4. * sum2 * sum2 * cnt1 * e2sq;
2295 while (var1 * var1 + cnt1 == 0 || var1 + var2 == 0) {
2298 var1 = sum2 * cnt2 - sum1 * e2sq;
2299 var2 = var1 * var1 + 4. * sum2 * sum2 * cnt1 * e2sq;
2303 while (var1 + var2 == 0) {
2306 var1 = sum2 * cnt2 - sum1 * e2sq;
2307 var2 = var1 * var1 + 4. * sum2 * sum2 * cnt1 * e2sq;
2308 while (var1 * var1 + cnt1 == 0 || var1 + var2 == 0) {
2311 var1 = sum2 * cnt2 - sum1 * e2sq;
2312 var2 = var1 * var1 + 4. * sum2 * sum2 * cnt1 * e2sq;
2317 Double_t probb = (var1 + var2) / (2. * sum2 * sum2);
2325 chi2 += delta1 * delta1 / nexp1;
2328 chi2 += delta2 * delta2 / e2sq;
2333 Double_t temp1 = sum2 * e2sq / var2;
2334 Double_t temp2 = 1.0 + (sum1 * e2sq - sum2 * cnt2) / var2;
2335 temp2 = temp1 * temp1 * sum1 * probb * (1.0 - probb) + temp2 * temp2 * e2sq / 4.0;
2348 Info(
"Chi2TestX",
"There is a bin in h1 with less than 1 event.\n");
2352 Info(
"Chi2TestX",
"There is a bin in h2 with less than 10 effective events.\n");
2362 for (
Int_t i = i_start; i <= i_end; ++i) {
2363 for (
Int_t j = j_start; j <= j_end; ++j) {
2364 for (
Int_t k = k_start; k <= k_end; ++k) {
2374 if (cnt1 * cnt1 == 0 && cnt2 * cnt2 == 0) {
2379 if (e1sq == 0 && e2sq == 0) {
2381 Error(
"Chi2TestX",
"h1 and h2 both have bin %d,%d,%d with all zero errors\n", i,j,k);
2386 Double_t delta = sum2 * cnt1 - sum1 * cnt2;
2387 chi2 += delta * delta /
sigma;
2390 Double_t temp = cnt1 * sum1 * e2sq + cnt2 * sum2 * e1sq;
2403 res[i - i_start] =
z;
2406 if (e1sq > 0 && cnt1 * cnt1 / e1sq < 10) m++;
2407 if (e2sq > 0 && cnt2 * cnt2 / e2sq < 10)
n++;
2413 Info(
"Chi2TestX",
"There is a bin in h1 with less than 10 effective events.\n");
2417 Info(
"Chi2TestX",
"There is a bin in h2 with less than 10 effective events.\n");
2434 Error(
"Chisquare",
"Function pointer is Null - return -1");
2480 Int_t nbins = nbinsx * nbinsy * nbinsz;
2485 for (
Int_t binz=1; binz <= nbinsz; ++binz) {
2486 for (
Int_t biny=1; biny <= nbinsy; ++biny) {
2487 for (
Int_t binx=1; binx <= nbinsx; ++binx) {
2490 if (onlyPositive && y < 0) {
2491 Error(
"ComputeIntegral",
"Bin content is negative - return a NaN value");
2502 Error(
"ComputeIntegral",
"Integral = zero");
return 0;
2545 hintegrated->
Reset();
2548 for (
Int_t binz = 1; binz <= nbinsz; ++binz) {
2549 for (
Int_t biny = 1; biny <= nbinsy; ++biny) {
2550 for (
Int_t binx = 1; binx <= nbinsx; ++binx) {
2551 const Int_t bin = hintegrated->
GetBin(binx, biny, binz);
2559 for (
Int_t binz = nbinsz; binz >= 1; --binz) {
2560 for (
Int_t biny = nbinsy; biny >= 1; --biny) {
2561 for (
Int_t binx = nbinsx; binx >= 1; --binx) {
2562 const Int_t bin = hintegrated->
GetBin(binx, biny, binz);
2588 ((
TH1&)obj).fDirectory->Remove(&obj);
2589 ((
TH1&)obj).fDirectory = 0;
2603 delete [] ((
TH1&)obj).fBuffer;
2604 ((
TH1&)obj).fBuffer = 0;
2610 ((
TH1&)obj).fBuffer = buf;
2636 ((
TH1&)obj).fXaxis.SetParent(&obj);
2637 ((
TH1&)obj).fYaxis.SetParent(&obj);
2638 ((
TH1&)obj).fZaxis.SetParent(&obj);
2648 ((
TH1&)obj).fFunctions->UseRWLock();
2651 ((
TH1&)obj).fDirectory = 0;
2661 TH1* obj = (
TH1*)IsA()->GetNew()(0);
2679 if(newname && strlen(newname) ) {
2734 Error(
"Divide",
"Attempt to divide by a non-existing function");
2752 Int_t bin, binx, biny, binz;
2757 for (binz = 0; binz < nz; ++binz) {
2759 for (biny = 0; biny < ny; ++biny) {
2761 for (binx = 0; binx < nx; ++binx) {
2765 bin = binx + nx * (biny + ny * binz);
2802 Error(
"Divide",
"Input histogram passed does not exist (NULL).");
2811 }
catch(DifferentNumberOfBins&) {
2812 Error(
"Divide",
"Cannot divide histograms with different number of bins");
2814 }
catch(DifferentAxisLimits&) {
2815 Warning(
"Divide",
"Dividing histograms with different axis limits");
2816 }
catch(DifferentBinLimits&) {
2817 Warning(
"Divide",
"Dividing histograms with different bin limits");
2818 }
catch(DifferentLabels&) {
2819 Warning(
"Divide",
"Dividing histograms with different labels");
2874 Error(
"Divide",
"At least one of the input histograms passed does not exist (NULL).");
2884 }
catch(DifferentNumberOfBins&) {
2885 Error(
"Divide",
"Cannot divide histograms with different number of bins");
2887 }
catch(DifferentAxisLimits&) {
2888 Warning(
"Divide",
"Dividing histograms with different axis limits");
2889 }
catch(DifferentBinLimits&) {
2890 Warning(
"Divide",
"Dividing histograms with different bin limits");
2891 }
catch(DifferentLabels&) {
2892 Warning(
"Divide",
"Dividing histograms with different labels");
2897 Error(
"Divide",
"Coefficient of dividing histogram cannot be zero");
2934 fSumw2.
fArray[i] = c1sq * c2sq * (e1sq * b2sq + e2sq * b1sq) / (c2sq * c2sq * b2sq * b2sq);
2987 if (index>indb && index<indk) index = -1;
2993 if (!
gPad->IsEditable())
gROOT->MakeDefCanvas();
2995 if (
gPad->GetX1() == 0 &&
gPad->GetX2() == 1 &&
2996 gPad->GetY1() == 0 &&
gPad->GetY2() == 1 &&
2997 gPad->GetListOfPrimitives()->GetSize()==0) opt2.
Remove(index,4);
3004 gPad->IncrementPaletteColor(1, opt1);
3006 if (index>=0) opt2.
Remove(index,4);
3032 if (
gPad)
gPad->IncrementPaletteColor(1, opt);
3057 Error(
"DrawNormalized",
"Sum of weights is null. Cannot normalize histogram: %s",
GetName());
3069 if (opt.
IsNull() || opt ==
"SAME") opt +=
"HIST";
3104 Int_t range, stat, add;
3124 for (
Int_t binz = 1; binz <= nbinsz; ++binz) {
3126 for (
Int_t biny = 1; biny <= nbinsy; ++biny) {
3128 for (
Int_t binx = 1; binx <= nbinsx; ++binx) {
3131 if (range && !f1->
IsInside(x))
continue;
3228 for (
Int_t binx = 1; binx<=ndim[0]; binx++) {
3229 for (
Int_t biny=1; biny<=ndim[1]; biny++) {
3230 for (
Int_t binz=1; binz<=ndim[2]; binz++) {
3260 if (bin <0)
return -1;
3293 if (bin <0)
return -1;
3326 if (bin <0)
return -1;
3362 for (i=0;i<ntimes;i+=stride) {
3368 if (i < ntimes &&
fBuffer==0) {
3369 auto weights = w ? &w[i] :
nullptr;
3370 DoFillN((ntimes-i)/stride,&x[i],weights,stride);
3375 DoFillN(ntimes, x, w, stride);
3390 for (i=0;i<ntimes;i+=stride) {
3392 if (bin <0)
continue;
3397 if (bin == 0 || bin > nbins) {
3425 Int_t bin, binx, ibin, loop;
3429 if (!f1) {
Error(
"FillRandom",
"Unknown function: %s",fname);
return; }
3439 Info(
"FillRandom",
"Using function axis and range [%g,%g]",xmin, xmax);
3445 Int_t nbinsx = last-first+1;
3449 for (binx=1;binx<=nbinsx;binx++) {
3451 integral[binx] = integral[binx-1] + fint;
3455 if (integral[nbinsx] == 0 ) {
3457 Error(
"FillRandom",
"Integral = zero");
return;
3459 for (bin=1;bin<=nbinsx;bin++) integral[bin] /= integral[nbinsx];
3462 for (loop=0;loop<ntimes;loop++) {
3468 +xAxis->
GetBinWidth(ibin+first)*(r1-integral[ibin])/(integral[ibin+1] - integral[ibin]);
3492 if (!h) {
Error(
"FillRandom",
"Null histogram");
return; }
3494 Error(
"FillRandom",
"Histograms with different dimensions");
return;
3497 Error(
"FillRandom",
"Histograms contains negative bins, does not represent probabilities");
3505 Int_t nbins = last-first+1;
3506 if (ntimes > 10*nbins) {
3510 if (sumw == 0)
return;
3512 for (
Int_t bin=first;bin<=last;bin++) {
3524 if (sumgen < ntimes) {
3526 for (i =
Int_t(sumgen+0.5); i < ntimes; ++i)
3532 else if (sumgen > ntimes) {
3534 i =
Int_t(sumgen+0.5);
3535 while( i > ntimes) {
3550 catch(std::exception&) {}
3557 for (loop=0;loop<ntimes;loop++) {
3583 return binx + nx*biny;
3591 return binx + nx*(biny +ny*binz);
3616 return binx + nx*biny;
3624 return binx + nx*(biny +ny*binz);
3638 Warning(
"FindFirstBinAbove",
"Invalid axis number : %d, axis x assumed\n",axis);
3642 for (
Int_t bin=1;bin<=nbins;bin++) {
3657 Warning(
"FindLastBinAbove",
"Invalid axis number : %d, axis x assumed\n",axis);
3661 for (
Int_t bin=nbins;bin>=1;bin--) {
3700 linear= (
char*)strstr(fname,
"++");
3707 f1=
new TF1(fname, fname, xxmin, xxmax);
3708 return Fit(f1,option,goption,xxmin,xxmax);
3711 f2=
new TF2(fname, fname);
3712 return Fit(f2,option,goption,xxmin,xxmax);
3715 f3=
new TF3(fname, fname);
3716 return Fit(f3,option,goption,xxmin,xxmax);
3721 f1 = (
TF1*)
gROOT->GetFunction(fname);
3722 if (!f1) {
Printf(
"Unknown function: %s",fname);
return -1; }
3723 return Fit(f1,option,goption,xxmin,xxmax);
4051 gROOT->MakeDefCanvas();
4054 Error(
"FitPanel",
"Unable to create a default canvas");
4061 if (handler && handler->
LoadPlugin() != -1) {
4063 Error(
"FitPanel",
"Unable to create the FitPanel");
4066 Error(
"FitPanel",
"Unable to find the FitPanel plug-in");
4111 asym->SetTitle(title);
4121 top->
Add(h1,h2,1,-c2);
4122 bottom->
Add(h1,h2,1,c2);
4123 asym->Divide(top,bottom);
4127 Int_t zmax = asym->GetNbinsZ();
4137 for(
Int_t k=1; k<= zmax; k++){
4153 Double_t error = 2*
TMath::Sqrt(a*a*c2*c2*dbsq + c2*c2*b*b*dasq+a*a*b*b*dc2*dc2)/(bot*bot);
4154 asym->SetBinError(i,j,k,error);
4216 return (s[1] ? s[0]*s[0]/s[1] :
TMath::Abs(s[0]) );
4226 return ((
TH1*)
this)->GetPainter()->GetObjectInfo(px,py);
4327 Error(
"GetQuantiles",
"Only available for 1-d histograms");
4337 Int_t nq = nprobSum;
4342 for (i=1;i<nq;i++) {
4347 for (i = 0; i < nq; i++) {
4349 while (ibin < nbins-1 &&
fIntegral[ibin+1] == prob[i]) {
4350 if (
fIntegral[ibin+2] == prob[i]) ibin++;
4355 if (dint > 0) q[i] +=
GetBinWidth(ibin+1)*(prob[i]-fIntegral[ibin])/dint;
4358 if (!probSum)
delete [] prob;
4376 Double_t allcha, sumx, sumx2,
x, val, stddev, mean;
4387 allcha = sumx = sumx2 = 0;
4388 for (bin=hxfirst;bin<=hxlast;bin++) {
4391 if (val > valmax) valmax = val;
4396 if (allcha == 0)
return;
4398 stddev = sumx2/allcha - mean*mean;
4401 if (stddev == 0) stddev = binwidx*(hxlast-hxfirst+1)/4;
4408 Double_t constant = 0.5*(valmax+binwidx*allcha/(sqrtpi*stddev));
4416 if ((mean < xmin || mean > xmax) && stddev > (xmax-xmin)) {
4417 mean = 0.5*(xmax+
xmin);
4418 stddev = 0.5*(xmax-
xmin);
4437 Int_t nchanx = hxlast - hxfirst + 1;
4458 Int_t nchanx = hxlast - hxfirst + 1;
4461 if (nchanx <=1 || npar == 1) {
4484 const Int_t idim = 20;
4495 if (m > idim || m > n)
return;
4498 for (l = 2; l <=
m; ++
l) {
4500 b[m + l*20 - 21] = zero;
4507 for (k = hxfirst; k <= hxlast; ++k) {
4512 for (l = 2; l <=
m; ++
l) {
4515 da[l-1] += power*yk;
4517 for (l = 2; l <=
m; ++
l) {
4519 b[m + l*20 - 21] += power;
4522 for (i = 3; i <=
m; ++i) {
4523 for (k = i; k <=
m; ++k) {
4524 b[k - 1 + (i-1)*20 - 21] = b[k + (i-2)*20 - 21];
4529 for (i=0; i<
m; ++i) a[i] = da[i];
4549 xbar = ybar = x2bar = xybar = 0;
4554 for (i = hxfirst; i <= hxlast; ++i) {
4558 if (yk <= 0) yk = 1
e-9;
4567 det = fn*x2bar - xbar*xbar;
4575 a0 = (x2bar*ybar - xbar*xybar) / det;
4576 a1 = (fn*xybar - xbar*ybar) / det;
4587 Int_t a_dim1, a_offset, b_dim1, b_offset;
4589 Int_t im1, jp1, nm1, nmi;
4595 b_offset = b_dim1 + 1;
4598 a_offset = a_dim1 + 1;
4601 if (idim < n)
return;
4604 for (j = 1; j <=
n; ++j) {
4605 if (a[j + j*a_dim1] <= 0) { ifail = -1;
return; }
4606 a[j + j*a_dim1] = one / a[j + j*a_dim1];
4607 if (j == n)
continue;
4609 for (l = jp1; l <=
n; ++
l) {
4610 a[j + l*a_dim1] = a[j + j*a_dim1] * a[l + j*a_dim1];
4611 s1 = -a[l + (j+1)*a_dim1];
4612 for (i = 1; i <= j; ++i) { s1 = a[l + i*a_dim1] * a[i + (j+1)*a_dim1] + s1; }
4613 a[l + (j+1)*a_dim1] = -s1;
4618 for (l = 1; l <= k; ++
l) {
4619 b[l*b_dim1 + 1] = a[a_dim1 + 1]*b[l*b_dim1 + 1];
4622 for (l = 1; l <= k; ++
l) {
4623 for (i = 2; i <=
n; ++i) {
4625 s21 = -b[i + l*b_dim1];
4626 for (j = 1; j <= im1; ++j) {
4627 s21 = a[i + j*a_dim1]*b[j + l*b_dim1] + s21;
4629 b[i + l*b_dim1] = -a[i + i*a_dim1]*s21;
4632 for (i = 1; i <= nm1; ++i) {
4634 s22 = -b[nmi + l*b_dim1];
4635 for (j = 1; j <= i; ++j) {
4637 s22 = a[nmi + nmjp1*a_dim1]*b[nmjp1 + l*b_dim1] + s22;
4639 b[nmi + l*b_dim1] = -s22;
4677 if (binx < 0) binx = 0;
4678 if (binx > ofx) binx = ofx;
4693 binx = binglobal%nx;
4699 binx = binglobal%nx;
4700 biny = ((binglobal-binx)/nx)%ny;
4705 binx = binglobal%nx;
4706 biny = ((binglobal-binx)/nx)%ny;
4707 binz = ((binglobal-binx)/nx -biny)/ny;
4724 Error(
"GetRandom",
"Function only valid for 1-d histograms");
4734 integral = ((
TH1*)
this)->ComputeIntegral(
true);
4736 if (integral == 0)
return 0;
4775 if (bin < 0) bin = 0;
4801 Error(
"GetBinWithContent",
"function is only valid for 1-D histograms");
4807 if (firstx <= 0) firstx = 1;
4811 for (
Int_t i=firstx;i<=lastx;i++) {
4813 if (diff <= 0) {binx = i;
return diff;}
4814 if (diff < curmax && diff <= maxdiff) {curmax = diff, binminx=i;}
4849 return y0 + (x-x0)*((y1-y0)/(x1-x0));
4858 Error(
"Interpolate",
"This function must be called with 1 argument for a TH1");
4867 Error(
"Interpolate",
"This function must be called with 1 argument for a TH1");
4895 Int_t binx, biny, binz;
4917 Error(
"IsBinOverflow",
"Invalid axis value");
4927 Int_t binx, biny, binz;
4934 return (binx <= 0 || biny <= 0);
4936 return (binx <= 0 || biny <= 0 || binz <= 0);
4947 Error(
"IsBinUnderflow",
"Invalid axis value");
4964 Error(
"LabelsDeflate",
"Invalid axis option %s",ax);
4975 while ((obj = next())) {
4977 if (ibin > nbins) nbins = ibin;
4979 if (nbins < 1) nbins = 1;
4982 if (nbins==axis->
GetNbins())
return;
4984 TH1 *hold = (
TH1*)IsA()->New();
4992 if (xmax <= xmin) xmax = xmin +nbins;
4994 axis->
Set(nbins,xmin,xmax);
5007 Int_t bin,binx,biny,binz;
5008 for (bin=0; bin < hold->
fNcells; ++bin) {
5035 TH1 *hold = (
TH1*)IsA()->New();;
5043 xmax = xmin + 2*(xmax-
xmin);
5046 axis->
Set(2*nbins,xmin,xmax);
5056 Int_t bin,ibin,binx,biny,binz;
5057 for (ibin =0; ibin < hold->
fNcells; ibin++) {
5060 bin =
GetBin(binx,biny,binz);
5097 Warning(
"LabelsOption",
"Cannot sort. No labels");
5130 if (sort < 0)
return;
5132 Error(
"LabelsOption",
"Sorting by value not implemented for 3-D histograms");
5138 std::vector<Int_t>
a(n+2);
5141 std::vector<Double_t> cont;
5142 std::vector<Double_t> errors;
5144 TIter nextold(labels);
5146 while ((obj=nextold())) {
5155 for (i=1;i<=
n;i++) {
5157 if (!errors.empty()) errors[i-1] =
GetBinError(i);
5161 for (i=1;i<=
n;i++) {
5163 if (!errors.empty())
SetBinError(i,errors[a[i-1]]);
5165 for (i=1;i<=
n;i++) {
5166 obj = labold->
At(a[i-1]);
5171 std::vector<Double_t> pcont(n+2);
5174 cont.resize( (nx+2)*(ny+2));
5175 if (
fSumw2.
fN) errors.resize( (nx+2)*(ny+2));
5176 for (i=1;i<=nx;i++) {
5177 for (j=1;j<=ny;j++) {
5179 if (!errors.empty()) errors[i+nx*j] =
GetBinError(i,j);
5182 pcont[k-1] += cont[i+nx*j];
5188 obj = labold->
At(a[i]);
5193 for (i=1;i<=
n;i++) {
5194 for (j=1;j<=ny;j++) {
5196 if (!errors.empty())
SetBinError(i,j,errors[a[i-1]+1+nx*j]);
5202 for (i=1;i<=nx;i++) {
5203 for (j=1;j<=
n;j++) {
5205 if (!errors.empty())
SetBinError(i,j,errors[i+nx*(a[j-1]+1)]);
5214 const UInt_t kUsed = 1<<18;
5218 for (i=1;i<=
n;i++) {
5219 const char *label =
"zzzzzzzzzzzz";
5220 for (j=1;j<=
n;j++) {
5221 obj = labold->
At(j-1);
5223 if (obj->
TestBit(kUsed))
continue;
5225 if (strcmp(label,obj->
GetName()) < 0)
continue;
5236 for (i=1;i<=
n;i++) {
5237 obj = labels->
At(i-1);
5245 for (i=1;i<=
n;i++) {
5247 if (!errors.empty()) errors[i] =
GetBinError(a[i]);
5249 for (i=1;i<=
n;i++) {
5257 if (
fSumw2.
fN) errors.resize(nx*ny);
5258 for (i=0;i<nx;i++) {
5259 for (j=0;j<ny;j++) {
5261 if (!errors.empty()) errors[i+nx*j] =
GetBinError(i,j);
5265 for (i=1;i<=
n;i++) {
5266 for (j=0;j<ny;j++) {
5268 if (!errors.empty())
SetBinError(i,j,errors[a[i]+nx*j]);
5272 for (i=0;i<nx;i++) {
5273 for (j=1;j<=
n;j++) {
5275 if (!errors.empty())
SetBinError(i,j,errors[i+nx*a[j]]);
5283 cont.resize(nx*ny*nz);
5284 if (
fSumw2.
fN) errors.resize(nx*ny*nz);
5285 for (i=0;i<nx;i++) {
5286 for (j=0;j<ny;j++) {
5287 for (k=0;k<nz;k++) {
5289 if (!errors.empty()) errors[i+nx*(j+ny*k)] =
GetBinError(i,j,k);
5295 for (i=1;i<=
n;i++) {
5296 for (j=0;j<ny;j++) {
5297 for (k=0;k<nz;k++) {
5299 if (!errors.empty())
SetBinError(i,j,k,errors[a[i]+nx*(j+ny*k)]);
5306 for (i=0;i<nx;i++) {
5307 for (j=1;j<=
n;j++) {
5308 for (k=0;k<nz;k++) {
5310 if (!errors.empty())
SetBinError(i,j,k,errors[i+nx*(a[j]+ny*k)]);
5317 for (i=0;i<nx;i++) {
5318 for (j=0;j<ny;j++) {
5319 for (k=1;k<=
n;k++) {
5321 if (!errors.empty())
SetBinError(i,j,k,errors[i+nx*(j+ny*a[k])]);
5357 bool isEquidistant =
true;
5359 for (
int i = 1; i < axis.
GetNbins(); ++i) {
5362 isEquidistant &= match;
5366 return isEquidistant;
5393 if (width1 == 0 || width2 == 0)
5424 delta = (xmax - destAxis.
GetXmax())/width1;
5429 delta = (xmax - anAxis.
GetXmax())/width2;
5434 delta = (xmax - destAxis.
GetXmax())/width1;
5439 printf(
"TH1::RecomputeAxisLimits - Impossible\n");
5522 Error(
"Multiply",
"Attempt to multiply by a non-existing function");
5544 for (
Int_t binz = 0; binz < nz; ++binz) {
5546 for (
Int_t biny = 0; biny < ny; ++biny) {
5548 for (
Int_t binx = 0; binx < nx; ++binx) {
5552 Int_t bin = binx + nx * (biny + ny *binz);
5584 Error(
"Multiply",
"Attempt to multiply by a non-existing histogram");
5593 }
catch(DifferentNumberOfBins&) {
5594 Error(
"Multiply",
"Attempt to multiply histograms with different number of bins");
5596 }
catch(DifferentAxisLimits&) {
5597 Warning(
"Multiply",
"Attempt to multiply histograms with different axis limits");
5598 }
catch(DifferentBinLimits&) {
5599 Warning(
"Multiply",
"Attempt to multiply histograms with different bin limits");
5600 }
catch(DifferentLabels&) {
5601 Warning(
"Multiply",
"Attempt to multiply histograms with different labels");
5646 Error(
"Multiply",
"Attempt to multiply by a non-existing histogram");
5656 }
catch(DifferentNumberOfBins&) {
5657 Error(
"Multiply",
"Attempt to multiply histograms with different number of bins");
5659 }
catch(DifferentAxisLimits&) {
5660 Warning(
"Multiply",
"Attempt to multiply histograms with different axis limits");