708 if (nbins <= 0) {
Warning(
"TH1",
"nbins is <=0 - set to nbins = 1"); nbins = 1; }
709 fXaxis.Set(nbins,xlow,xup);
730 if (nbins <= 0) {
Warning(
"TH1",
"nbins is <=0 - set to nbins = 1"); nbins = 1; }
731 if (xbins)
fXaxis.Set(nbins,xbins);
732 else fXaxis.Set(nbins,0,1);
752 if (nbins <= 0) {
Warning(
"TH1",
"nbins is <=0 - set to nbins = 1"); nbins = 1; }
753 if (xbins)
fXaxis.Set(nbins,xbins);
754 else fXaxis.Set(nbins,0,1);
774 Draw(
b ?
b->GetDrawOption() :
"");
839 Error(
"Add",
"Attempt to add a non-existing function");
859 for (
Int_t i = 0; i < 10; ++i)
s1[i] = 0;
865 Int_t bin, binx, biny, binz;
869 f1->InitArgs(xx,params);
870 for (binz = 0; binz < ncellsz; ++binz) {
871 xx[2] =
fZaxis.GetBinCenter(binz);
872 for (biny = 0; biny < ncellsy; ++biny) {
873 xx[1] =
fYaxis.GetBinCenter(biny);
874 for (binx = 0; binx < ncellsx; ++binx) {
875 xx[0] =
fXaxis.GetBinCenter(binx);
876 if (!
f1->IsInside(xx))
continue;
878 bin = binx + ncellsx * (biny + ncellsy * binz);
880 cu =
c1*
f1->Integral(
fXaxis.GetBinLowEdge(binx),
fXaxis.GetBinUpEdge(binx), 0.) /
fXaxis.GetBinWidth(binx);
882 cu =
c1*
f1->EvalPar(xx);
899 Info(
name,
"Histograms have different dimensions - trying to use TH1::Merge");
901 Error(
name,
"Histograms have different dimensions");
905 Info(
name,
"Histograms have different number of bins - trying to use TH1::Merge");
907 Error(
name,
"Histograms have different number of bins");
911 Info(
name,
"Histograms have different axis limits - trying to use TH1::Merge");
913 Warning(
name,
"Histograms have different axis limits");
916 Info(
name,
"Histograms have different bin limits - trying to use TH1::Merge");
918 Warning(
name,
"Histograms have different bin limits");
922 Info(
name,
"Histograms have different labels - trying to use TH1::Merge");
924 Info(
name,
"Histograms have different labels");
927 return inconsistency;
967 Error(
"Add",
"Attempt to add a non-existing histogram");
974 bool useMerge =
false;
983 useMerge = considerMerge;
988 l.Add(
const_cast<TH1*
>(
h1));
1018 if (
h1->GetNormFactor() != 0) factor =
h1->GetNormFactor()/
h1->GetSumOfWeights();
1027 Double_t e1sq =
h1->GetBinErrorSqUnchecked(bin);
1033 if (e1sq) w1 = 1. / e1sq;
1034 else if (
h1->fSumw2.fN) {
1038 double sf = (s2[0] != 0) ? s2[1]/s2[0] : 1;
1042 if (e2sq) w2 = 1. / e2sq;
1047 double sf = (
s1[0] != 0) ?
s1[1]/
s1[0] : 1;
1052 double y = (w1*y1 + w2*y2)/(w1 + w2);
1055 double err2 = 1./(w1 + w2);
1056 if (err2 < 1.E-200) err2 = 0;
1057 fSumw2.fArray[bin] = err2;
1061 if (
fSumw2.fN)
fSumw2.fArray[bin] += c1sq * factsq *
h1->GetBinErrorSqUnchecked(bin);
1072 if (i == 1)
s1[i] +=
c1*
c1*s2[i];
1073 else s1[i] +=
c1*s2[i];
1128 Error(
"Add",
"Attempt to add a non-existing histogram");
1136 if (
h1 == h2 &&
c2 < 0) {
c2 = 0; normWidth =
kTRUE;}
1139 bool useMerge =
false;
1153 useMerge = considerMerge;
1159 l.Add(
const_cast<TH1*
>(
h1));
1160 l.Add(
const_cast<TH1*
>(h2));
1183 Bool_t resetStats = (
c1*
c2 < 0) || normWidth;
1190 if (i == 1) s3[i] =
c1*
c1*
s1[i] +
c2*
c2*s2[i];
1192 else s3[i] =
c1*
s1[i] +
c2*s2[i];
1208 Int_t bin, binx, biny, binz;
1209 for (binz = 0; binz < nbinsz; ++binz) {
1210 Double_t wz =
h1->GetZaxis()->GetBinWidth(binz);
1211 for (biny = 0; biny < nbinsy; ++biny) {
1212 Double_t wy =
h1->GetYaxis()->GetBinWidth(biny);
1213 for (binx = 0; binx < nbinsx; ++binx) {
1214 Double_t wx =
h1->GetXaxis()->GetBinWidth(binx);
1215 bin =
GetBin(binx, biny, binz);
1230 Double_t e1sq =
h1->GetBinErrorSqUnchecked(i);
1236 if (e1sq) w1 = 1./ e1sq;
1237 else if (
h1->fSumw2.fN) {
1240 double sf = (
s1[0] != 0) ?
s1[1]/
s1[0] : 1;
1244 if (e2sq) w2 = 1./ e2sq;
1248 double sf = (s2[0] != 0) ? s2[1]/s2[0] : 1;
1253 double y = (w1*y1 + w2*y2)/(w1 + w2);
1256 double err2 = 1./(w1 + w2);
1257 if (err2 < 1.E-200) err2 = 0;
1280 if (
c1 == 1.0 &&
c2 == 1.0)
1327 return ((next &&
x > 0.) || (!next &&
x <= 0.)) ? std::ldexp(std::copysign(1., f2), nn)
1328 : std::ldexp(std::copysign(1., f2), --nn);
1341 return (
Int_t)std::ldexp(1., nn);
1381 Double_t rr = (xhma - xhmi) / (xma - xmi);
1387 Double_t autoside =
gEnv->GetValue(
"Hist.Binning.Auto.Side", 0.05);
1391 Int_t nbup = (xhma - xma) / bw;
1394 if (nbup != nbside) {
1396 xhma -= bw * (nbup - nbside);
1397 nb -= (nbup - nbside);
1401 Int_t nblw = (xmi - xhmi) / bw;
1404 if (nblw != nbside) {
1406 xhmi += bw * (nblw - nbside);
1407 nb -= (nblw - nbside);
1437 if (nbentries == 0) {
1447 if (nbentries < 0 && action == 0)
return 0;
1450 if (nbentries < 0) {
1451 nbentries = -nbentries;
1463 for (
Int_t i=0;i<nbentries;i++) {
1466 if (!std::isfinite(
x))
continue;
1475 "inconsistency found by power-of-2 autobin algorithm: fallback to standard method");
1493 DoFillN(nbentries,&buffer[2],&buffer[1],2);
1527 if (nbentries < 0) {
1530 nbentries = -nbentries;
1562 if ( h2Array->
fN != fN ) {
1566 for (
int i = 0; i < fN; ++i ) {
1597 for (
int i = 1; i <= a1->
GetNbins(); ++i) {
1600 if (label1 != label2) {
1629 ::Info(
"CheckEqualAxes",
"Axes have different number of bins : nbin1 = %d nbin2 = %d",a1->
GetNbins(),a2->
GetNbins() );
1633 ::Info(
"CheckEqualAxes",
"Axes have different limits");
1637 ::Info(
"CheckEqualAxes",
"Axes have different bin limits");
1643 ::Info(
"CheckEqualAxes",
"Axes have different labels");
1658 Int_t nbins1 = lastBin1-firstBin1 + 1;
1666 if (firstBin2 < lastBin2) {
1668 nbins2 = lastBin1-firstBin1 + 1;
1673 if (nbins1 != nbins2 ) {
1674 ::Info(
"CheckConsistentSubAxes",
"Axes have different number of bins");
1682 ::Info(
"CheckConsistentSubAxes",
"Axes have different limits");
1701 Int_t dim =
h1->GetDimension();
1704 Int_t nbinsx =
h1->GetNbinsX();
1705 Int_t nbinsy =
h1->GetNbinsY();
1706 Int_t nbinsz =
h1->GetNbinsZ();
1710 (dim > 1 && nbinsy != h2->
GetNbinsY()) ||
1711 (dim > 2 && nbinsz != h2->
GetNbinsZ()) ) {
1730 if ( !
h1->IsEmpty() && !h2->
IsEmpty() ) {
2030 Int_t ndf = 0, igood = 0;
2038 printf(
"Chi2 = %f, Prob = %g, NDF = %d, igood = %d\n", chi2,prob,ndf,igood);
2041 if (ndf == 0)
return 0;
2089 Int_t i_start, i_end;
2090 Int_t j_start, j_end;
2091 Int_t k_start, k_end;
2120 Error(
"Chi2TestX",
"Histograms have different dimensions.");
2125 if (nbinx1 != nbinx2) {
2126 Error(
"Chi2TestX",
"different number of x channels");
2128 if (nbiny1 != nbiny2) {
2129 Error(
"Chi2TestX",
"different number of y channels");
2131 if (nbinz1 != nbinz2) {
2132 Error(
"Chi2TestX",
"different number of z channels");
2136 i_start = j_start = k_start = 1;
2167 ndf = (i_end - i_start + 1) * (j_end - j_start + 1) * (k_end - k_start + 1) - 1;
2174 if (scaledHistogram && !comparisonUU) {
2175 Info(
"Chi2TestX",
"NORM option should be used together with UU option. It is ignored");
2182 Double_t effEntries1 = (s[1] ? s[0] * s[0] / s[1] : 0.0);
2186 Double_t effEntries2 = (s[1] ? s[0] * s[0] / s[1] : 0.0);
2188 if (!comparisonUU && !comparisonUW && !comparisonWW ) {
2190 if (
TMath::Abs(sumBinContent1 - effEntries1) < 1) {
2191 if (
TMath::Abs(sumBinContent2 - effEntries2) < 1) comparisonUU =
true;
2192 else comparisonUW =
true;
2194 else comparisonWW =
true;
2198 if (
TMath::Abs(sumBinContent1 - effEntries1) >= 1) {
2199 Warning(
"Chi2TestX",
"First histogram is not unweighted and option UW has been requested");
2202 if ( (!scaledHistogram && comparisonUU) ) {
2203 if ( (
TMath::Abs(sumBinContent1 - effEntries1) >= 1) || (
TMath::Abs(sumBinContent2 - effEntries2) >= 1) ) {
2204 Warning(
"Chi2TestX",
"Both histograms are not unweighted and option UU has been requested");
2210 if (comparisonUU && scaledHistogram) {
2211 for (
Int_t i = i_start; i <= i_end; ++i) {
2212 for (
Int_t j = j_start; j <= j_end; ++j) {
2213 for (
Int_t k = k_start; k <= k_end; ++k) {
2222 if (e1sq > 0.0) cnt1 =
TMath::Floor(cnt1 * cnt1 / e1sq + 0.5);
2225 if (e2sq > 0.0) cnt2 =
TMath::Floor(cnt2 * cnt2 / e2sq + 0.5);
2236 if (sumw1 <= 0.0 || sumw2 <= 0.0) {
2237 Error(
"Chi2TestX",
"Cannot use option NORM when one histogram has all zero errors");
2242 for (
Int_t i = i_start; i <= i_end; ++i) {
2243 for (
Int_t j = j_start; j <= j_end; ++j) {
2244 for (
Int_t k = k_start; k <= k_end; ++k) {
2258 if (sum1 == 0.0 || sum2 == 0.0) {
2259 Error(
"Chi2TestX",
"one histogram is empty");
2263 if ( comparisonWW && ( sumw1 <= 0.0 && sumw2 <= 0.0 ) ){
2264 Error(
"Chi2TestX",
"Hist1 and Hist2 have both all zero errors\n");
2274 for (
Int_t i = i_start; i <= i_end; ++i) {
2275 for (
Int_t j = j_start; j <= j_end; ++j) {
2276 for (
Int_t k = k_start; k <= k_end; ++k) {
2283 if (scaledHistogram) {
2288 if (e1sq > 0) cnt1 =
TMath::Floor(cnt1 * cnt1 / e1sq + 0.5);
2291 if (e2sq > 0) cnt2 =
TMath::Floor(cnt2 * cnt2 / e2sq + 0.5);
2295 if (
Int_t(cnt1) == 0 &&
Int_t(cnt2) == 0) --ndf;
2302 if (res) res[resIndex] = (cnt1 - nexp1) /
TMath::Sqrt(nexp1);
2310 if (res) resIndex++;
2311 Double_t delta = sum2 * cnt1 - sum1 * cnt2;
2312 chi2 += delta * delta / cntsum;
2317 chi2 /= sum1 * sum2;
2322 Info(
"Chi2TestX",
"There is a bin in h1 with less than 1 event.\n");
2326 Info(
"Chi2TestX",
"There is a bin in h2 with less than 1 event.\n");
2337 if ( comparisonUW ) {
2339 for (
Int_t i = i_start; i <= i_end; ++i) {
2340 for (
Int_t j = j_start; j <= j_end; ++j) {
2341 for (
Int_t k = k_start; k <= k_end; ++k) {
2350 if (cnt1 * cnt1 == 0 && cnt2 * cnt2 == 0) {
2356 if (cnt2 * cnt2 == 0 && e2sq == 0) {
2360 e2sq = sumw2 / sum2;
2365 Error(
"Chi2TestX",
"Hist2 has in bin (%d,%d,%d) zero content and zero errors\n", i, j, k);
2371 if (e2sq > 0 && cnt2 * cnt2 / e2sq < 10)
n++;
2373 Double_t var1 = sum2 * cnt2 - sum1 * e2sq;
2374 Double_t var2 = var1 * var1 + 4. * sum2 * sum2 * cnt1 * e2sq;
2379 while (var1 * var1 + cnt1 == 0 || var1 + var2 == 0) {
2382 var1 = sum2 * cnt2 - sum1 * e2sq;
2383 var2 = var1 * var1 + 4. * sum2 * sum2 * cnt1 * e2sq;
2387 while (var1 + var2 == 0) {
2390 var1 = sum2 * cnt2 - sum1 * e2sq;
2391 var2 = var1 * var1 + 4. * sum2 * sum2 * cnt1 * e2sq;
2392 while (var1 * var1 + cnt1 == 0 || var1 + var2 == 0) {
2395 var1 = sum2 * cnt2 - sum1 * e2sq;
2396 var2 = var1 * var1 + 4. * sum2 * sum2 * cnt1 * e2sq;
2401 Double_t probb = (var1 + var2) / (2. * sum2 * sum2);
2409 chi2 += delta1 * delta1 / nexp1;
2412 chi2 += delta2 * delta2 / e2sq;
2417 Double_t temp1 = sum2 * e2sq / var2;
2418 Double_t temp2 = 1.0 + (sum1 * e2sq - sum2 * cnt2) / var2;
2419 temp2 = temp1 * temp1 * sum1 * probb * (1.0 - probb) + temp2 * temp2 * e2sq / 4.0;
2433 Info(
"Chi2TestX",
"There is a bin in h1 with less than 1 event.\n");
2437 Info(
"Chi2TestX",
"There is a bin in h2 with less than 10 effective events.\n");
2448 for (
Int_t i = i_start; i <= i_end; ++i) {
2449 for (
Int_t j = j_start; j <= j_end; ++j) {
2450 for (
Int_t k = k_start; k <= k_end; ++k) {
2460 if (cnt1 * cnt1 == 0 && cnt2 * cnt2 == 0) {
2465 if (e1sq == 0 && e2sq == 0) {
2467 Error(
"Chi2TestX",
"h1 and h2 both have bin %d,%d,%d with all zero errors\n", i,j,k);
2472 Double_t delta = sum2 * cnt1 - sum1 * cnt2;
2473 chi2 += delta * delta /
sigma;
2476 Double_t temp = cnt1 * sum1 * e2sq + cnt2 * sum2 * e1sq;
2493 if (e1sq > 0 && cnt1 * cnt1 / e1sq < 10)
m++;
2494 if (e2sq > 0 && cnt2 * cnt2 / e2sq < 10)
n++;
2500 Info(
"Chi2TestX",
"There is a bin in h1 with less than 10 effective events.\n");
2504 Info(
"Chi2TestX",
"There is a bin in h2 with less than 10 effective events.\n");
2523 Error(
"Chisquare",
"Function pointer is Null - return -1");
2529 bool useIntegral = opt.
Contains(
"I");
2578 Int_t nbins = nbinsx * nbinsy * nbinsz;
2583 for (
Int_t binz=1; binz <= nbinsz; ++binz) {
2585 for (
Int_t biny=1; biny <= nbinsy; ++biny) {
2587 for (
Int_t binx=1; binx <= nbinsx; ++binx) {
2592 y *= xWidth * yWidth * zWidth;
2594 if (onlyPositive &&
y < 0) {
2595 Error(
"ComputeIntegral",
"Bin content is negative - return a NaN value");
2606 Error(
"ComputeIntegral",
"Integral = 0, no hits in histogram bins (excluding over/underflow).");
2662 hintegrated->
Reset();
2666 for (
Int_t binz = firstZ; binz <= lastZ; ++binz) {
2667 for (
Int_t biny = firstY; biny <= lastY; ++biny) {
2668 for (
Int_t binx = firstX; binx <= lastX; ++binx) {
2669 const Int_t bin = hintegrated->
GetBin(binx, biny, binz);
2680 for (
Int_t binz = lastZ; binz >= firstZ; --binz) {
2681 for (
Int_t biny = lastY; biny >= firstY; --biny) {
2682 for (
Int_t binx = lastX; binx >= firstX; --binx) {
2683 const Int_t bin = hintegrated->
GetBin(binx, biny, binz);
2780 ((
TH1&)obj).fDirectory =
nullptr;
2805 oldparent = oldstats->GetParent();
2806 oldstats->SetParent(
nullptr);
2812 oldstats->SetParent(oldparent);
2824 if(newname && strlen(newname) ) {
2861 return fPainter->DistancetoPrimitive(px,py);
2878 Error(
"Divide",
"Attempt to divide by a non-existing function");
2896 Int_t bin, binx, biny, binz;
2900 f1->InitArgs(xx,params);
2901 for (binz = 0; binz < nz; ++binz) {
2902 xx[2] =
fZaxis.GetBinCenter(binz);
2903 for (biny = 0; biny < ny; ++biny) {
2904 xx[1] =
fYaxis.GetBinCenter(biny);
2905 for (binx = 0; binx < nx; ++binx) {
2906 xx[0] =
fXaxis.GetBinCenter(binx);
2907 if (!
f1->IsInside(xx))
continue;
2909 bin = binx + nx * (biny + ny * binz);
2910 cu =
c1 *
f1->EvalPar(xx);
2917 else fSumw2.fArray[bin] = 0;
2946 Error(
"Divide",
"Input histogram passed does not exist (NULL).");
2968 if (
c1 == 0) {
fSumw2.fArray[i] = 0;
continue; }
3009 Error(
"Divide",
"At least one of the input histograms passed does not exist (NULL).");
3022 Error(
"Divide",
"Coefficient of dividing histogram cannot be zero");
3040 if (b2 == 0) {
fSumw2.fArray[i] = 0;
continue; }
3043 Double_t e1sq =
h1->GetBinErrorSqUnchecked(i);
3052 fSumw2.fArray[i] =
TMath::Abs( ( (1. - 2.* b1 / b2) * e1sq + b1sq * e2sq / b2sq ) / b2sq );
3059 fSumw2.fArray[i] = c1sq * c2sq * (e1sq * b2sq + e2sq * b1sq) / (c2sq * c2sq * b2sq * b2sq);
3110 if (index>indb && index<indk) index = -1;
3116 if (!
gPad->IsEditable())
gROOT->MakeDefCanvas();
3118 if (
gPad->GetX1() == 0 &&
gPad->GetX2() == 1 &&
3119 gPad->GetY1() == 0 &&
gPad->GetY2() == 1 &&
3120 gPad->GetListOfPrimitives()->GetSize()==0) opt2.
Remove(index,4);
3127 gPad->IncrementPaletteColor(1, opt1);
3129 if (index>=0) opt2.
Remove(index,4);
3170 if (name_postfix) newName.
Form(
"%s%s",
GetName(), name_postfix);
3174 if (
gPad)
gPad->IncrementPaletteColor(1, opt);
3199 Error(
"DrawNormalized",
"Sum of weights is null. Cannot normalize histogram: %s",
GetName());
3211 if (opt.
IsNull() || opt ==
"SAME") opt +=
"HIST";
3246 Int_t range, stat, add;
3266 for (
Int_t binz = 1; binz <= nbinsz; ++binz) {
3267 x[2] =
fZaxis.GetBinCenter(binz);
3268 for (
Int_t biny = 1; biny <= nbinsy; ++biny) {
3269 x[1] =
fYaxis.GetBinCenter(biny);
3270 for (
Int_t binx = 1; binx <= nbinsx; ++binx) {
3272 x[0] =
fXaxis.GetBinCenter(binx);
3273 if (range && !
f1->IsInside(
x))
continue;
3275 if (stat) fu =
gRandom->PoissonD(fu);
3368 if (!fft)
return nullptr;
3370 for (
Int_t binx = 1; binx<=ndim[0]; binx++) {
3371 for (
Int_t biny=1; biny<=ndim[1]; biny++) {
3372 for (
Int_t binz=1; binz<=ndim[2]; binz++) {
3402 if (bin <0)
return -1;
3405 if (bin == 0 || bin >
fXaxis.GetNbins()) {
3435 if (bin <0)
return -1;
3439 if (bin == 0 || bin >
fXaxis.GetNbins()) {
3467 bin =
fXaxis.FindBin(namex);
3468 if (bin <0)
return -1;
3472 if (bin == 0 || bin >
fXaxis.GetNbins())
return -1;
3504 for (i=0;i<ntimes;i+=stride) {
3511 auto weights = w ? &w[i] :
nullptr;
3512 DoFillN((ntimes-i)/stride,&
x[i],weights,stride);
3532 for (i=0;i<ntimes;i+=stride) {
3534 if (bin <0)
continue;
3539 if (bin == 0 || bin > nbins) {
3574 if (!
f1) {
Error(
"FillRandom",
"Unknown function: %s",fname);
return; }
3581 Int_t bin, binx, ibin, loop;
3592 Info(
"FillRandom",
"Using function axis and range [%g,%g]",
xmin,
xmax);
3593 xAxis =
f1->GetHistogram()->GetXaxis();
3598 Int_t nbinsx = last-first+1;
3602 for (binx=1;binx<=nbinsx;binx++) {
3604 integral[binx] = integral[binx-1] + fint;
3608 if (integral[nbinsx] == 0 ) {
3610 Error(
"FillRandom",
"Integral = zero");
return;
3612 for (bin=1;bin<=nbinsx;bin++) integral[bin] /= integral[nbinsx];
3615 for (loop=0;loop<ntimes;loop++) {
3621 +xAxis->
GetBinWidth(ibin+first)*(r1-integral[ibin])/(integral[ibin+1] - integral[ibin]);
3649 if (!
h) {
Error(
"FillRandom",
"Null histogram");
return; }
3651 Error(
"FillRandom",
"Histograms with different dimensions");
return;
3653 if (std::isnan(
h->ComputeIntegral(
true))) {
3654 Error(
"FillRandom",
"Histograms contains negative bins, does not represent probabilities");
3662 Int_t nbins = last-first+1;
3663 if (ntimes > 10*nbins) {
3666 Double_t sumw =
h->Integral(first,last);
3667 if (sumw == 0)
return;
3669 for (
Int_t bin=first;bin<=last;bin++) {
3670 Double_t mean =
h->RetrieveBinContent(bin)*ntimes/sumw;
3681 if (sumgen < ntimes) {
3683 for (i =
Int_t(sumgen+0.5); i < ntimes; ++i)
3689 else if (sumgen > ntimes) {
3691 i =
Int_t(sumgen+0.5);
3692 while( i > ntimes) {
3709 if (
h->ComputeIntegral() ==0)
return;
3712 for (loop=0;loop<ntimes;loop++) {
3738 return binx + nx*biny;
3746 return binx + nx*(biny +ny*binz);
3771 return binx + nx*biny;
3779 return binx + nx*(biny +ny*binz);
3797 Warning(
"FindFirstBinAbove",
"Invalid axis number : %d, axis x assumed\n",axis);
3808 if (lastBin < 0 || lastBin >
fXaxis.GetNbins()) {
3809 lastBin =
fXaxis.GetNbins();
3811 for (
Int_t binx = firstBin; binx <= lastBin; binx++) {
3812 for (
Int_t biny = 1; biny <= nbinsy; biny++) {
3813 for (
Int_t binz = 1; binz <= nbinsz; binz++) {
3819 else if (axis == 2) {
3820 if (lastBin < 0 || lastBin >
fYaxis.GetNbins()) {
3821 lastBin =
fYaxis.GetNbins();
3823 for (
Int_t biny = firstBin; biny <= lastBin; biny++) {
3824 for (
Int_t binx = 1; binx <= nbinsx; binx++) {
3825 for (
Int_t binz = 1; binz <= nbinsz; binz++) {
3831 else if (axis == 3) {
3832 if (lastBin < 0 || lastBin >
fZaxis.GetNbins()) {
3833 lastBin =
fZaxis.GetNbins();
3835 for (
Int_t binz = firstBin; binz <= lastBin; binz++) {
3836 for (
Int_t binx = 1; binx <= nbinsx; binx++) {
3837 for (
Int_t biny = 1; biny <= nbinsy; biny++) {
3861 Warning(
"FindFirstBinAbove",
"Invalid axis number : %d, axis x assumed\n",axis);
3872 if (lastBin < 0 || lastBin >
fXaxis.GetNbins()) {
3873 lastBin =
fXaxis.GetNbins();
3875 for (
Int_t binx = lastBin; binx >= firstBin; binx--) {
3876 for (
Int_t biny = 1; biny <= nbinsy; biny++) {
3877 for (
Int_t binz = 1; binz <= nbinsz; binz++) {
3883 else if (axis == 2) {
3884 if (lastBin < 0 || lastBin >
fYaxis.GetNbins()) {
3885 lastBin =
fYaxis.GetNbins();
3887 for (
Int_t biny = lastBin; biny >= firstBin; biny--) {
3888 for (
Int_t binx = 1; binx <= nbinsx; binx++) {
3889 for (
Int_t binz = 1; binz <= nbinsz; binz++) {
3895 else if (axis == 3) {
3896 if (lastBin < 0 || lastBin >
fZaxis.GetNbins()) {
3897 lastBin =
fZaxis.GetNbins();
3899 for (
Int_t binz = lastBin; binz >= firstBin; binz--) {
3900 for (
Int_t binx = 1; binx <= nbinsx; binx++) {
3901 for (
Int_t biny = 1; biny <= nbinsy; biny++) {
3959 linear= (
char*)strstr(fname,
"++");
3963 TF1 f1(fname, fname, xxmin, xxmax);
3964 return Fit(&
f1,option,goption,xxmin,xxmax);
3967 TF2 f2(fname, fname);
3968 return Fit(&f2,option,goption,xxmin,xxmax);
3971 TF3 f3(fname, fname);
3972 return Fit(&f3,option,goption,xxmin,xxmax);
3977 if (!
f1) {
Printf(
"Unknown function: %s",fname);
return -1; }
3978 return Fit(
f1,option,goption,xxmin,xxmax);
4345 gROOT->MakeDefCanvas();
4348 Error(
"FitPanel",
"Unable to create a default canvas");
4355 if (handler && handler->
LoadPlugin() != -1) {
4357 Error(
"FitPanel",
"Unable to create the FitPanel");
4360 Error(
"FitPanel",
"Unable to find the FitPanel plug-in");
4416 asym->
Divide(top,bottom);
4422 if (
h1->fBuffer)
h1->BufferEmpty(1);
4430 for(
Int_t k=1; k<= zmax; k++){
4444 Double_t dasq =
h1->GetBinErrorSqUnchecked(bin);
4509 return (s[1] ? s[0]*s[0]/s[1] :
TMath::Abs(s[0]) );
4528 if (markercolor >= 0)
4544 Info(
"SetHighlight",
"Supported only 1-D or 2-D histograms");
4561 return ((
TH1*)
this)->GetPainter()->GetObjectInfo(px,py);
4675 Error(
"GetQuantiles",
"Only available for 1-d histograms");
4685 std::unique_ptr<Double_t[]> localProb;
4690 for (i=1;i<nq;i++) {
4694 Double_t const *
const prob = p ? p : localProb.get();
4696 for (i = 0; i < nq; i++) {
4699 if (prob[i] == 0.) {
4700 for (; ibin+1 <= nbins &&
fIntegral[ibin+1] == 0.; ++ibin) {
4703 xp[i] =
fXaxis.GetBinUpEdge(ibin);
4705 else if (prob[i] == 1.) {
4706 xp[i] =
fXaxis.GetBinUpEdge(ibin);
4711 for (
Int_t j = ibin+1; j <= nbins; ++j) {
4713 width +=
fXaxis.GetBinWidth(j);
4718 xp[i] = width == 0 ?
fXaxis.GetBinCenter(ibin) :
fXaxis.GetBinUpEdge(ibin) + width/2.;
4745 Double_t allcha, sumx, sumx2,
x, val, stddev, mean;
4756 allcha = sumx = sumx2 = 0;
4757 for (bin=hxfirst;bin<=hxlast;bin++) {
4760 if (val > valmax) valmax = val;
4765 if (allcha == 0)
return;
4767 stddev = sumx2/allcha - mean*mean;
4770 if (stddev == 0) stddev = binwidx*(hxlast-hxfirst+1)/4;
4777 Double_t constant = 0.5*(valmax+binwidx*allcha/(sqrtpi*stddev));
4785 if ((mean < xmin || mean >
xmax) && stddev > (
xmax-
xmin)) {
4790 f1->SetParameter(0,constant);
4791 f1->SetParameter(1,mean);
4792 f1->SetParameter(2,stddev);
4793 f1->SetParLimits(2,0,10*stddev);
4806 Int_t nchanx = hxlast - hxfirst + 1;
4811 f1->SetParameter(0,constant);
4812 f1->SetParameter(1,slope);
4827 Int_t nchanx = hxlast - hxfirst + 1;
4830 if (nchanx <=1 || npar == 1) {
4836 for (
Int_t i=0;i<npar;i++)
f1->SetParameter(i, fitpar[i]);
4853 const Int_t idim = 20;
4864 if (
m > idim ||
m >
n)
return;
4867 for (
l = 2;
l <=
m; ++
l) {
4869 b[
m +
l*20 - 21] = zero;
4876 for (k = hxfirst; k <= hxlast; ++k) {
4881 for (
l = 2;
l <=
m; ++
l) {
4884 da[
l-1] += power*yk;
4886 for (
l = 2;
l <=
m; ++
l) {
4888 b[
m +
l*20 - 21] += power;
4891 for (i = 3; i <=
m; ++i) {
4892 for (k = i; k <=
m; ++k) {
4893 b[k - 1 + (i-1)*20 - 21] =
b[k + (i-2)*20 - 21];
4898 for (i=0; i<
m; ++i)
a[i] = da[i];
4918 xbar = ybar = x2bar = xybar = 0;
4923 for (i = hxfirst; i <= hxlast; ++i) {
4927 if (yk <= 0) yk = 1
e-9;
4936 det = fn*x2bar - xbar*xbar;
4944 a0 = (x2bar*ybar - xbar*xybar) / det;
4945 a1 = (fn*xybar - xbar*ybar) / det;
4956 Int_t a_dim1, a_offset, b_dim1, b_offset;
4958 Int_t im1, jp1, nm1, nmi;
4964 b_offset = b_dim1 + 1;
4967 a_offset = a_dim1 + 1;
4970 if (idim <
n)
return;
4973 for (j = 1; j <=
n; ++j) {
4974 if (
a[j + j*a_dim1] <= 0) { ifail = -1;
return; }
4975 a[j + j*a_dim1] = one /
a[j + j*a_dim1];
4976 if (j ==
n)
continue;
4978 for (
l = jp1;
l <=
n; ++
l) {
4979 a[j +
l*a_dim1] =
a[j + j*a_dim1] *
a[
l + j*a_dim1];
4980 s1 = -
a[
l + (j+1)*a_dim1];
4981 for (i = 1; i <= j; ++i) {
s1 =
a[
l + i*a_dim1] *
a[i + (j+1)*a_dim1] +
s1; }
4982 a[
l + (j+1)*a_dim1] = -
s1;
4987 for (
l = 1;
l <= k; ++
l) {
4988 b[
l*b_dim1 + 1] =
a[a_dim1 + 1]*
b[
l*b_dim1 + 1];
4991 for (
l = 1;
l <= k; ++
l) {
4992 for (i = 2; i <=
n; ++i) {
4994 s21 = -
b[i +
l*b_dim1];
4995 for (j = 1; j <= im1; ++j) {
4996 s21 =
a[i + j*a_dim1]*
b[j +
l*b_dim1] + s21;
4998 b[i +
l*b_dim1] = -
a[i + i*a_dim1]*s21;
5001 for (i = 1; i <= nm1; ++i) {
5003 s22 = -
b[nmi +
l*b_dim1];
5004 for (j = 1; j <= i; ++j) {
5006 s22 =
a[nmi + nmjp1*a_dim1]*
b[nmjp1 +
l*b_dim1] + s22;
5008 b[nmi +
l*b_dim1] = -s22;
5046 if (binx < 0) binx = 0;
5047 if (binx > ofx) binx = ofx;
5062 binx = binglobal%nx;
5068 binx = binglobal%nx;
5069 biny = ((binglobal-binx)/nx)%ny;
5074 binx = binglobal%nx;
5075 biny = ((binglobal-binx)/nx)%ny;
5076 binz = ((binglobal-binx)/nx -biny)/ny;
5096 Error(
"GetRandom",
"Function only valid for 1-d histograms");
5109 if (integral == 0)
return 0;
5148 if (bin < 0) bin = 0;
5174 Error(
"GetBinWithContent",
"function is only valid for 1-D histograms");
5180 if (firstx <= 0) firstx = 1;
5181 if (lastx < firstx) lastx =
fXaxis.GetNbins();
5184 for (
Int_t i=firstx;i<=lastx;i++) {
5186 if (diff <= 0) {binx = i;
return diff;}
5187 if (diff < curmax && diff <= maxdiff) {curmax = diff, binminx=i;}
5222 return y0 + (
x-x0)*((y1-y0)/(x1-x0));
5231 Error(
"Interpolate",
"This function must be called with 1 argument for a TH1");
5240 Error(
"Interpolate",
"This function must be called with 1 argument for a TH1");
5268 Int_t binx, biny, binz;
5290 Error(
"IsBinOverflow",
"Invalid axis value");
5300 Int_t binx, biny, binz;
5307 return (binx <= 0 || biny <= 0);
5309 return (binx <= 0 || biny <= 0 || binz <= 0);
5320 Error(
"IsBinUnderflow",
"Invalid axis value");
5332 TAxis *axis =
nullptr;
5337 Error(
"LabelsDeflate",
"Invalid axis option %s",ax);
5348 while ((obj = next())) {
5350 if (ibin > nbins) nbins = ibin;
5352 if (nbins < 1) nbins = 1;
5355 if (nbins==axis->
GetNbins())
return;
5380 Int_t bin,binx,biny,binz;
5381 for (bin=0; bin < hold->
fNcells; ++bin) {
5402 TAxis *axis =
nullptr;
5430 Int_t bin,ibin,binx,biny,binz;
5431 for (ibin =0; ibin < hold->
fNcells; ibin++) {
5434 bin =
GetBin(binx,biny,binz);
5469 TAxis *axis =
nullptr;
5480 Warning(
"LabelsOption",
"Axis %s has no labels!",axis->
GetName());
5523 Error(
"LabelsOption",
"%s is an invalid label placement option!",opt.
Data());
5532 Int_t n = labels->GetSize();
5537 Int_t lastLabelBin = -1;
5538 for (
Int_t i = 0; i <
n; ++i) {
5539 Int_t bin = labels->At(i)->GetUniqueID();
5540 if (bin < firstLabelBin) firstLabelBin = bin;
5541 if (bin > lastLabelBin) lastLabelBin = bin;
5543 if (firstLabelBin != 1 || lastLabelBin-firstLabelBin +1 !=
n) {
5544 Error(
"LabelsOption",
"%s of Histogram %s contains bins without labels. Sorting will not work correctly - return",
5550 Warning(
"LabelsOption",
"axis %s of Histogram %s has extra following bins without labels. Sorting will work only for first label bins",
5553 std::vector<Int_t>
a(
n);
5554 std::vector<Int_t>
b(
n);
5558 std::vector<Double_t> cont;
5559 std::vector<Double_t> errors2;
5561 TIter nextold(labels);
5576 for (i = 0; i <
n; i++) {
5578 if (!errors2.empty())
5587 for (i = 0; i <
n; i++) {
5591 Info(
"LabelsOption",
"setting bin %d value %f from bin %d label %s at pos %d ",
5593 if (!errors2.empty())
5594 fSumw2.fArray[i + 1] = errors2[
b[
a[i]] - 1];
5596 for (i = 0; i <
n; i++) {
5597 obj = labold->
At(
a[i]);
5602 std::vector<Double_t> pcont(
n + 2);
5605 cont.resize((nx + 2) * (ny + 2));
5607 errors2.resize((nx + 2) * (ny + 2));
5608 for (i = 0; i < nx; i++) {
5609 for (j = 0; j < ny; j++) {
5612 if (!errors2.empty())
5618 if (k >= 0 && k <
n) {
5619 pcont[k] += cont[i + nx * j];
5628 for (i = 0; i <
n; i++) {
5632 while ((obj = next())) {
5640 R__ASSERT(
"LabelsOption - No corresponding bin found when ordering labels");
5646 std::cout <<
" set label " << obj->
GetName() <<
" to bin " << i + 1 <<
" from order " <<
a[i] <<
" bin "
5647 <<
b[
a[i]] <<
"content " << pcont[
a[i]] << std::endl;
5651 for (i = 0; i <
n; i++) {
5652 labels->At(i)->SetUniqueID(i + 1);
5656 for (i = 0; i <
n; i++) {
5658 for (j = 0; j < ny; j++) {
5661 if (!errors2.empty())
5662 fSumw2.fArray[bin] = errors2[ix + nx * j];
5667 for (i = 0; i < nx; i++) {
5668 for (j = 0; j <
n; j++) {
5672 if (!errors2.empty())
5673 fSumw2.fArray[bin] = errors2[i + nx * iy];
5679 std::vector<Double_t> pcont(
n + 2);
5684 cont.resize((nx + 2) * (ny + 2) * (nz + 2));
5686 errors2.resize((nx + 2) * (ny + 2) * (nz + 2));
5687 for (i = 0; i < nx; i++) {
5688 for (j = 0; j < ny; j++) {
5689 for (k = 0; k < nz; k++) {
5698 if (
l >= 0 &&
l <
n) {
5702 cont[i + nx * (j + ny * k)] =
c;
5703 if (!errors2.empty())
5712 for (i = 0; i <
n; i++) {
5717 while ((obj = next())) {
5725 R__ASSERT(
"LabelsOption - No corresponding bin found when ordering labels");
5730 std::cout <<
" set label " << obj->
GetName() <<
" to bin " << i + 1 <<
" from bin " <<
a[i] <<
"content "
5731 << pcont[
a[i]] << std::endl;
5736 for (i = 0; i <
n; i++) {
5737 labels->At(i)->SetUniqueID(i + 1);
5741 for (i = 0; i <
n; i++) {
5743 for (j = 0; j < ny; j++) {
5744 for (k = 0; k < nz; k++) {
5747 if (!errors2.empty())
5748 fSumw2.fArray[bin] = errors2[ix + nx * (j + ny * k)];
5754 for (i = 0; i < nx; i++) {
5755 for (j = 0; j <
n; j++) {
5757 for (k = 0; k < nz; k++) {
5760 if (!errors2.empty())
5761 fSumw2.fArray[bin] = errors2[i + nx * (iy + ny * k)];
5767 for (i = 0; i < nx; i++) {
5768 for (j = 0; j < ny; j++) {
5769 for (k = 0; k <
n; k++) {
5773 if (!errors2.empty())
5774 fSumw2.fArray[bin] = errors2[i + nx * (j + ny * iz)];
5784 std::vector<std::string> vecLabels(
n);
5785 for (i = 0; i <
n; i++) {
5786 vecLabels[i] = labold->
At(i)->
GetName();
5793 for (i = 0; i <
n; i++) {
5795 labels->Add(labold->
At(
a[i]));
5799 std::cout <<
"bin " << i + 1 <<
" setting new labels for axis " << labold->
At(
a[i])->
GetName() <<
" from "
5800 <<
b[
a[i]] << std::endl;
5806 errors2.resize(
n + 2);
5807 for (i = 0; i <
n; i++) {
5809 if (!errors2.empty())
5812 for (i = 0; i <
n; i++) {
5814 if (!errors2.empty())
5815 fSumw2.fArray[i+1] = errors2[i];
5820 cont.resize(nx * ny);
5822 errors2.resize(nx * ny);
5825 for (i = 0; i < nx; i++) {
5826 for (j = 0; j < ny; j++) {
5829 if (!errors2.empty())
5834 for (i = 0; i <
n; i++) {
5835 for (j = 0; j < ny; j++) {
5838 if (!errors2.empty())
5839 fSumw2.fArray[bin] = errors2[
b[
a[i]] + nx * j];
5843 for (i = 0; i < nx; i++) {
5844 for (j = 0; j <
n; j++) {
5847 if (!errors2.empty())
5848 fSumw2.fArray[bin] = errors2[i + nx *
b[
a[j]]];
5857 cont.resize(nx * ny * nz);
5859 errors2.resize(nx * ny * nz);
5860 for (i = 0; i < nx; i++) {
5861 for (j = 0; j < ny; j++) {
5862 for (k = 0; k < nz; k++) {
5865 if (!errors2.empty())
5872 for (i = 0; i <
n; i++) {
5873 for (j = 0; j < ny; j++) {
5874 for (k = 0; k < nz; k++) {
5877 if (!errors2.empty())
5878 fSumw2.fArray[bin] = errors2[
b[
a[i]] + nx * (j + ny * k)];
5884 for (i = 0; i < nx; i++) {
5885 for (j = 0; j <
n; j++) {
5886 for (k = 0; k < nz; k++) {
5889 if (!errors2.empty())
5890 fSumw2.fArray[bin] = errors2[i + nx * (
b[
a[j]] + ny * k)];
5896 for (i = 0; i < nx; i++) {
5897 for (j = 0; j < ny; j++) {
5898 for (k = 0; k <
n; k++) {
5901 if (!errors2.empty())
5902 fSumw2.fArray[bin] = errors2[i + nx * (j + ny *
b[
a[k]])];
5911 bool labelsAreSorted =
kFALSE;
5912 for (i = 0; i <
n; ++i) {
5914 labelsAreSorted =
kTRUE;
5918 if (labelsAreSorted) {
5926 }
else if (iaxis == 2) {
5931 }
else if (iaxis == 3) {
5967 bool isEquidistant =
true;
5969 for (
int i = 1; i < axis.
GetNbins(); ++i) {
5972 isEquidistant &= match;
5976 return isEquidistant;
6002 if (width1 == 0 || width2 == 0)
6048 printf(
"TH1::RecomputeAxisLimits - Impossible\n");
6136 Error(
"Multiply",
"Attempt to multiply by a non-existing function");
6156 f1->InitArgs(xx,params);
6158 for (
Int_t binz = 0; binz < nz; ++binz) {
6159 xx[2] =
fZaxis.GetBinCenter(binz);
6160 for (
Int_t biny = 0; biny < ny; ++biny) {
6161 xx[1] =
fYaxis.GetBinCenter(biny);
6162 for (
Int_t binx = 0; binx < nx; ++binx) {
6163 xx[0] =
fXaxis.GetBinCenter(binx);
6164 if (!
f1->IsInside(xx))
continue;
6166 Int_t bin = binx + nx * (biny + ny *binz);
6198 Error(
"Multiply",
"Attempt to multiply by a non-existing histogram");
6251 Error(
"Multiply",
"Attempt to multiply by a non-existing histogram");
6299 if (!opt.
IsNull() && (opt !=
"max") && (opt !=
"sum")) {
6300 Error(
"Normalize",
"Unrecognized option %s", option);
6307 Error(
"Normalize",
"Attempt to normalize histogram with zero integral");
6309 Scale(1.0 / norm,
"");
6328 if (option && strlen(option) > 0)
6397 if ((ngroup <= 0) || (ngroup > nbins)) {
6398 Error(
"Rebin",
"Illegal value of ngroup=%d",ngroup);
6403 Error(
"Rebin",
"Operation valid on 1-D histograms only");
6406 if (!newname && xbins) {
6407 Error(
"Rebin",
"if xbins is specified, newname must be given");
6411 Int_t newbins = nbins/ngroup;
6413 Int_t nbg = nbins/ngroup;
6414 if (nbg*ngroup != nbins) {
6415 Warning(
"Rebin",
"ngroup=%d is not an exact divider of nbins=%d.",ngroup,nbins);
6435 for (bin=0;bin<nbins+2;bin++) oldErrors[bin] =
GetBinError(bin);
6439 if (xbins[0] <
fXaxis.GetXmin() && oldBins[0] != 0 )
6440 Warning(
"Rebin",
"underflow entries will not be used when rebinning");
6441 if (xbins[newbins] >
fXaxis.GetXmax() && oldBins[nbins+1] != 0 )
6442 Warning(
"Rebin",
"overflow entries will not be used when rebinning");
6448 if ((newname && strlen(newname) > 0) || xbins) {
6458 bool resetStat =
false;
6460 if(!xbins && (newbins*ngroup != nbins)) {
6477 if(!xbins && (
fXaxis.GetXbins()->GetSize() > 0)){
6479 for(i = 0; i <= newbins; ++i) bins[i] =
fXaxis.GetBinLowEdge(1+i*ngroup);
6489 fXaxis.SetNdivisions(nDivisions);
6490 fXaxis.SetAxisColor(axisColor);
6491 fXaxis.SetLabelColor(labelColor);
6492 fXaxis.SetLabelFont(labelFont);
6493 fXaxis.SetLabelOffset(labelOffset);
6494 fXaxis.SetLabelSize(labelSize);
6495 fXaxis.SetTickLength(tickLength);
6496 fXaxis.SetTitleOffset(titleOffset);
6497 fXaxis.SetTitleSize(titleSize);
6498 fXaxis.SetTitleColor(titleColor);
6499 fXaxis.SetTitleFont(titleFont);
6505 while(
fXaxis.GetBinCenter(startbin) < newxmin && startbin <= nbins ) {
6508 Int_t oldbin = startbin;
6510 for (bin = 1;bin<=newbins;bin++) {
6513 Int_t imax = ngroup;
6521 Warning(
"Rebin",
"Bin edge %d of rebinned histogram does not match any bin edges of the old histogram. Result can be inconsistent",bin);
6523 for (i=0;i<ngroup;i++) {
6524 if( (oldbin+i > nbins) ||
6525 ( hnew !=
this && (
fXaxis.GetBinCenter(oldbin+i) > xbinmax)) ) {
6529 binContent += oldBins[oldbin+i];
6530 if (oldErrors) binError += oldErrors[oldbin+i]*oldErrors[oldbin+i];
6540 for (i = 0; i < startbin; ++i) {
6541 binContent += oldBins[i];
6542 if (oldErrors) binError += oldErrors[i]*oldErrors[i];
6549 for (i = oldbin; i <= nbins+1; ++i) {
6550 binContent += oldBins[i];
6551 if (oldErrors) binError += oldErrors[i]*oldErrors[i];
6560 if (!resetStat) hnew->
PutStats(stat);
6562 if (oldErrors)
delete [] oldErrors;
6586 while (point <
xmin) {
6592 while (point >=
xmax) {
6650 if (axis == &
fXaxis) iaxis = 1;
6651 if (axis == &
fYaxis) iaxis = 2;
6652 if (axis == &
fZaxis) iaxis = 3;
6653 bool firstw =
kTRUE;
6654 Int_t binx,biny, binz = 0;
6655 Int_t ix = 0,iy = 0,iz = 0;
6658 for (
Int_t bin = 0; bin < ncells; ++bin) {
6661 ix =
fXaxis.FindFixBin(bx);
6664 iy =
fYaxis.FindFixBin(by);
6667 iz =
fZaxis.FindFixBin(bz);
6672 if (content == 0)
continue;
6675 Warning(
"ExtendAxis",
"Histogram %s has underflow or overflow in the axis that is extendable"
6676 " their content will be lost",
GetName() );
6736 if (i == 1) s[i] =
c1*
c1*s[i];
6737 else s[i] =
c1*s[i];
6745 if (ncontours == 0)
return;
6747 for (
Int_t i = 0; i < ncontours; ++i) levels[i] *=
c1;
6786 return oldExtendBitMask;
6841 fTitle.ReplaceAll(
"#;",2,
"#semicolon",10);
6850 str1 = str1(isc+1, lns);
6851 isc = str1.
Index(
";");
6854 str2.ReplaceAll(
"#semicolon",10,
";",1);
6855 fXaxis.SetTitle(str2.Data());
6857 str1 = str1(isc+1, lns);
6858 isc = str1.
Index(
";");
6861 str2.ReplaceAll(
"#semicolon",10,
";",1);
6862 fYaxis.SetTitle(str2.Data());
6864 str1 = str1(isc+1, lns);
6865 isc = str1.
Index(
";");
6868 str2.ReplaceAll(
"#semicolon",10,
";",1);
6869 fZaxis.SetTitle(str2.Data());
6884 fTitle.ReplaceAll(
"#semicolon",10,
";",1);
6898 ::Error(
"SmoothArray",
"Need at least 3 points for smoothing: n = %d",nn);
6903 std::array<double, 3> hh{};
6905 std::vector<double> yy(nn);
6906 std::vector<double> zz(nn);
6907 std::vector<double> rr(nn);
6909 for (
Int_t pass=0;pass<ntimes;pass++) {
6911 std::copy(xx, xx+nn, zz.begin() );
6913 for (
int noent = 0; noent < 2; ++noent) {
6916 for (
int kk = 0; kk < 3; kk++) {
6917 std::copy(zz.begin(), zz.end(), yy.begin());
6918 int medianType = (kk != 1) ? 3 : 5;
6919 int ifirst = (kk != 1 ) ? 1 : 2;
6920 int ilast = (kk != 1 ) ? nn-1 : nn -2;
6924 for ( ii = ifirst; ii < ilast; ii++) {
6925 zz[ii] =
TMath::Median(medianType, yy.data() + ii - ifirst);
6932 hh[2] = 3*zz[1] - 2*zz[2];
6937 hh[2] = 3*zz[nn - 2] - 2*zz[nn - 3];
6952 std::copy ( zz.begin(), zz.end(), yy.begin() );
6955 for (ii = 2; ii < (nn - 2); ii++) {
6956 if (zz[ii - 1] != zz[ii])
continue;
6957 if (zz[ii] != zz[ii + 1])
continue;
6958 const double tmp0 = zz[ii - 2] - zz[ii];
6959 const double tmp1 = zz[ii + 2] - zz[ii];
6960 if (tmp0 * tmp1 <= 0)
continue;
6962 if ( std::abs(tmp1) > std::abs(tmp0) ) jk = -1;
6963 yy[ii] = -0.5*zz[ii - 2*jk] + zz[ii]/0.75 + zz[ii + 2*jk] /6.;
6964 yy[ii + jk] = 0.5*(zz[ii + 2*jk] - zz[ii - 2*jk]) + zz[ii];
6969 for (ii = 1; ii < nn - 1; ii++) {
6970 zz[ii] = 0.25*yy[ii - 1] + 0.5*yy[ii] + 0.25*yy[ii + 1];
6973 zz[nn - 1] = yy[nn - 1];
6978 std::copy(zz.begin(), zz.end(), rr.begin());
6981 for (ii = 0; ii < nn; ii++) {
6982 zz[ii] = xx[ii] - zz[ii];
6990 for (ii = 0; ii < nn; ii++) {
6991 if (
xmin < 0) xx[ii] = rr[ii] + zz[ii];
6993 else xx[ii] = std::max((rr[ii] + zz[ii]),0.0 );
7009 Error(
"Smooth",
"Smooth only supported for 1-d histograms");
7014 Error(
"Smooth",
"Smooth only supported for histograms with >= 3 bins. Nbins = %d",nbins);
7021 Int_t firstbin = 1, lastbin = nbins;
7025 firstbin=
fXaxis.GetFirst();
7026 lastbin =
fXaxis.GetLast();
7028 nbins = lastbin - firstbin + 1;
7032 for (i=0;i<nbins;i++) {
7038 for (i=0;i<nbins;i++) {
7062 if (
b.IsReading()) {
7064 Version_t R__v =
b.ReadVersion(&R__s, &R__c);
7068 b.ReadClassBuffer(
TH1::Class(),
this, R__v, R__s, R__c);
7076 while ((obj=next())) {
7101 Float_t maximum, minimum, norm;
7106 Int_t n =
b.ReadArray(contour);
7120 b.CheckByteCount(R__s, R__c,
TH1::IsA());
7144 else if (opt.
Contains(
"range")) all = 1;
7145 else if (opt.
Contains(
"base")) all = 2;
7148 Int_t bin, binx, biny, binz;
7149 Int_t firstx=0,lastx=0,firsty=0,lasty=0,firstz=0,lastz=0;
7151 lastx =
fXaxis.GetNbins()+1;
7161 printf(
" Title = %s\n",
GetTitle());
7162 printf(
" NbinsX= %d, xmin= %g, xmax=%g",
fXaxis.GetNbins(),
fXaxis.GetXmin(),
fXaxis.GetXmax());
7172 for (binx=firstx;binx<=lastx;binx++) {
7173 x =
fXaxis.GetBinCenter(binx);
7176 if(
fSumw2.fN) printf(
" fSumw[%d]=%g, x=%g, error=%g\n",binx,w,
x,
e);
7177 else printf(
" fSumw[%d]=%g, x=%g\n",binx,w,
x);
7181 for (biny=firsty;biny<=lasty;biny++) {
7182 y =
fYaxis.GetBinCenter(biny);
7183 for (binx=firstx;binx<=lastx;binx++) {
7185 x =
fXaxis.GetBinCenter(binx);
7188 if(
fSumw2.fN) printf(
" fSumw[%d][%d]=%g, x=%g, y=%g, error=%g\n",binx,biny,w,
x,
y,
e);
7189 else printf(
" fSumw[%d][%d]=%g, x=%g, y=%g\n",binx,biny,w,
x,
y);
7194 for (binz=firstz;binz<=lastz;binz++) {
7195 z =
fZaxis.GetBinCenter(binz);
7196 for (biny=firsty;biny<=lasty;biny++) {
7197 y =
fYaxis.GetBinCenter(biny);
7198 for (binx=firstx;binx<=lastx;binx++) {
7199 bin =
GetBin(binx,biny,binz);
7200 x =
fXaxis.GetBinCenter(binx);
7203 if(
fSumw2.fN) printf(
" fSumw[%d][%d][%d]=%g, x=%g, y=%g, z=%g, error=%g\n",binx,biny,binz,w,
x,
y,z,
e);
7204 else printf(
" fSumw[%d][%d][%d]=%g, x=%g, y=%g, z=%g\n",binx,biny,binz,w,
x,
y,z);
7265 if (opt ==
"ICES")
return;
7319 }
else if (fname.
EndsWith(
".tsv")) {
7322 }
else if (fname.
EndsWith(
".txt")) {
7332 out.open(filename, std::ios::out);
7334 Error(
"SaveAs",
"cannot open file: %s", filename);
7339 out <<
"# " <<
"BinLowEdge" << del <<
"BinUpEdge" << del
7341 << del <<
"ey" << std::endl;
7343 out <<
"# " <<
"BinLowEdge" << del <<
"BinUpEdge" << del <<
GetYaxis()->
GetTitle() << del <<
"ey" << std::endl;
7358 Info(
"SaveAs",
"%s file: %s has been generated", ext.
Data(), filename);
7371 thread_local Int_t storeNumber = 0;
7381 histName += storeNumber;
7384 histName =
"unnamed";
7397 TString sxaxis, syaxis, szaxis;
7420 const auto old_precision{out.precision()};
7421 constexpr auto max_precision{std::numeric_limits<double>::digits10 + 1};
7422 out << std::setprecision(max_precision);
7427 out <<
", " << sxaxis <<
".data()";
7433 out <<
", " << syaxis <<
".data()";
7440 out <<
", " << szaxis <<
".data()";
7447 Int_t numbins = 0, numerrors = 0;
7449 std::vector<Double_t> content(
fNcells), errors(save_errors ?
fNcells : 0);
7461 if ((numbins < 100) && (numerrors < 100)) {
7465 out <<
" " << hname <<
"->SetBinContent(" << bin <<
"," << content[bin] <<
");\n";
7470 out <<
" " << hname <<
"->SetBinError(" << bin <<
"," << errors[bin] <<
");\n";
7475 out <<
" for (Int_t bin = 0; bin < " <<
fNcells <<
"; bin++)\n";
7476 out <<
" if (" << vectname <<
"[bin])\n";
7477 out <<
" " << hname <<
"->SetBinContent(bin, " << vectname <<
"[bin]);\n";
7479 if (numerrors > 0) {
7481 out <<
" for (Int_t bin = 0; bin < " <<
fNcells <<
"; bin++)\n";
7482 out <<
" if (" << vectname <<
"[bin])\n";
7483 out <<
" " << hname <<
"->SetBinError(bin, " << vectname <<
"[bin]);\n";
7488 out << std::setprecision(old_precision);
7499 out <<
" " << hname <<
"->SetBarOffset(" <<
GetBarOffset() <<
");\n";
7501 out <<
" " << hname <<
"->SetBarWidth(" <<
GetBarWidth() <<
");\n";
7503 out <<
" " << hname <<
"->SetMinimum(" <<
fMinimum <<
");\n";
7505 out <<
" " << hname <<
"->SetMaximum(" <<
fMaximum <<
");\n";
7507 out <<
" " << hname <<
"->SetNormFactor(" <<
fNormFactor <<
");\n";
7509 out <<
" " << hname <<
"->SetEntries(" <<
fEntries <<
");\n";
7511 out <<
" " << hname <<
"->SetDirectory(nullptr);\n";
7513 out <<
" " << hname <<
"->SetStats(0);\n";
7519 if (ncontours > 0) {
7522 std::vector<Double_t> levels(ncontours);
7523 for (
Int_t bin = 0; bin < ncontours; bin++)
7527 out <<
" " << hname <<
"->SetContour(" << ncontours;
7529 out <<
", " << vectname <<
".data()";
7539 fXaxis.SaveAttributes(out, hname,
"->GetXaxis()");
7540 fYaxis.SaveAttributes(out, hname,
"->GetYaxis()");
7541 fZaxis.SaveAttributes(out, hname,
"->GetZaxis()");
7552 thread_local Int_t funcNumber = 0;
7558 TString objvarname = obj->GetName();
7561 objvarname += funcNumber;
7563 out <<
" " << objvarname <<
"->SetParent(" << varname <<
");\n";
7564 }
else if (obj->InheritsFrom(
"TPaveStats")) {
7565 objvarname =
"ptstats";
7567 out <<
" " << objvarname <<
"->SetParent(" << varname <<
");\n";
7568 }
else if (obj->InheritsFrom(
"TPolyMarker")) {
7569 objvarname =
"pmarker";
7572 out <<
" " << varname <<
"->GetListOfFunctions()->Add(" << objvarname;
7587 if (
gStyle->IsReading()) {
7588 fXaxis.ResetAttAxis(
"X");
7589 fYaxis.ResetAttAxis(
"Y");
7590 fZaxis.ResetAttAxis(
"Z");
7602 if (
gStyle->GetOptFit() && !dostat) dostat = 1000000001;
7620 while ((obj = next())) {
7652 if (axis<1 || (axis>3 && axis<11) || axis>13)
return 0;
7656 if (stats[0] == 0)
return 0;
7658 Int_t ax[3] = {2,4,7};
7659 return stats[ax[axis-1]]/stats[0];
7664 return ( neff > 0 ? stddev/
TMath::Sqrt(neff) : 0. );
7724 if (axis<1 || (axis>3 && axis<11) || axis>13)
return 0;
7729 if (stats[0] == 0)
return 0;
7730 Int_t ax[3] = {2,4,7};
7731 Int_t axm = ax[axis%10 - 1];
7732 x = stats[axm]/stats[0];
7734 stddev2 =
TMath::Max( stats[axm+1]/stats[0] -
x*
x, 0.0 );
7741 return ( neff > 0 ?
TMath::Sqrt(stddev2/(2*neff) ) : 0. );
7789 if (axis > 0 && axis <= 3){
7793 Double_t stddev3 = stddev*stddev*stddev;
7804 if (firstBinX == 1) firstBinX = 0;
7805 if (lastBinX ==
fXaxis.GetNbins() ) lastBinX += 1;
7808 if (firstBinY == 1) firstBinY = 0;
7809 if (lastBinY ==
fYaxis.GetNbins() ) lastBinY += 1;
7812 if (firstBinZ == 1) firstBinZ = 0;
7813 if (lastBinZ ==
fZaxis.GetNbins() ) lastBinZ += 1;
7820 for (
Int_t binx = firstBinX; binx <= lastBinX; binx++) {
7821 for (
Int_t biny = firstBinY; biny <= lastBinY; biny++) {
7822 for (
Int_t binz = firstBinZ; binz <= lastBinZ; binz++) {
7823 if (axis==1 )
x =
fXaxis.GetBinCenter(binx);
7824 else if (axis==2 )
x =
fYaxis.GetBinCenter(biny);
7825 else if (axis==3 )
x =
fZaxis.GetBinCenter(binz);
7828 sum+=w*(
x-mean)*(
x-mean)*(
x-mean);
7835 else if (axis > 10 && axis <= 13) {
7842 Error(
"GetSkewness",
"illegal value of parameter");
7861 if (axis > 0 && axis <= 3){
7865 Double_t stddev4 = stddev*stddev*stddev*stddev;
7876 if (firstBinX == 1) firstBinX = 0;
7877 if (lastBinX ==
fXaxis.GetNbins() ) lastBinX += 1;
7880 if (firstBinY == 1) firstBinY = 0;
7881 if (lastBinY ==
fYaxis.GetNbins() ) lastBinY += 1;
7884 if (firstBinZ == 1) firstBinZ = 0;
7885 if (lastBinZ ==
fZaxis.GetNbins() ) lastBinZ += 1;
7892 for (
Int_t binx = firstBinX; binx <= lastBinX; binx++) {
7893 for (
Int_t biny = firstBinY; biny <= lastBinY; biny++) {
7894 for (
Int_t binz = firstBinZ; binz <= lastBinZ; binz++) {
7895 if (axis==1 )
x =
fXaxis.GetBinCenter(binx);
7896 else if (axis==2 )
x =
fYaxis.GetBinCenter(biny);
7897 else if (axis==3 )
x =
fZaxis.GetBinCenter(binz);
7900 sum+=w*(
x-mean)*(
x-mean)*(
x-mean)*(
x-mean);
7907 }
else if (axis > 10 && axis <= 13) {
7911 return ( neff > 0 ?
TMath::Sqrt(24./neff ) : 0. );
7914 Error(
"GetKurtosis",
"illegal value of parameter");
7961 for (bin=0;bin<4;bin++) stats[bin] = 0;
7967 if (firstBinX == 1) firstBinX = 0;
7968 if (lastBinX ==
fXaxis.GetNbins() ) lastBinX += 1;
7970 for (binx = firstBinX; binx <= lastBinX; binx++) {
7971 x =
fXaxis.GetBinCenter(binx);
8045 const Int_t start = (includeOverflow ? 0 : 1);
8046 const Int_t lastX =
fXaxis.GetNbins() + (includeOverflow ? 1 : 0);
8051 for(
auto binz =
start; binz <= lastZ; binz++) {
8052 for(
auto biny =
start; biny <= lastY; biny++) {
8053 for(
auto binx =
start; binx <= lastX; binx++) {
8054 const auto bin =
GetBin(binx, biny, binz);
8060 if (sumWeightSquare) {
8062 *sumWeightSquare = sum2;
8064 *sumWeightSquare =
sum;
8118 if (binx1 < 0) binx1 = 0;
8119 if (binx2 >= nx || binx2 < binx1) binx2 = nx - 1;
8123 if (biny1 < 0) biny1 = 0;
8124 if (biny2 >= ny || biny2 < biny1) biny2 = ny - 1;
8126 biny1 = 0; biny2 = 0;
8131 if (binz1 < 0) binz1 = 0;
8132 if (binz2 >= nz || binz2 < binz1) binz2 = nz - 1;
8134 binz1 = 0; binz2 = 0;
8147 for (
Int_t binx = binx1; binx <= binx2; ++binx) {
8148 if (width) dx =
fXaxis.GetBinWidth(binx);
8149 for (
Int_t biny = biny1; biny <= biny2; ++biny) {
8150 if (width) dy =
fYaxis.GetBinWidth(biny);
8151 for (
Int_t binz = binz1; binz <= binz2; ++binz) {
8155 dz =
fZaxis.GetBinWidth(binz);
8205 printf(
" AndersonDarlingTest Prob = %g, AD TestStatistic = %g\n",pvalue,advalue);
8207 if (opt.
Contains(
"T") )
return advalue;
8218 Error(
"AndersonDarlingTest",
"Histograms must be 1-D");
8320 if (h2 ==
nullptr)
return 0;
8321 const TAxis *axis1 =
h1->GetXaxis();
8328 Error(
"KolmogorovTest",
"Histograms must be 1-D\n");
8334 Error(
"KolmogorovTest",
"Histograms have different number of bins, %d and %d\n",ncx1,ncx2);
8344 Error(
"KolmogorovTest",
"Histograms are not consistent: they have different bin edges");
8358 if (opt.
Contains(
"O")) ilast = ncx1 +1;
8359 for (bin = ifirst; bin <= ilast; bin++) {
8360 sum1 +=
h1->RetrieveBinContent(bin);
8362 ew1 =
h1->GetBinError(bin);
8368 Error(
"KolmogorovTest",
"Histogram1 %s integral is zero\n",
h1->GetName());
8372 Error(
"KolmogorovTest",
"Histogram2 %s integral is zero\n",h2->
GetName());
8381 esum1 = sum1 * sum1 / w1;
8386 esum2 = sum2 * sum2 / w2;
8390 if (afunc2 && afunc1) {
8391 Error(
"KolmogorovTest",
"Errors are zero for both histograms\n");
8400 Double_t dfmax =0, rsum1 = 0, rsum2 = 0;
8402 for (bin=ifirst;bin<=ilast;bin++) {
8403 rsum1 +=
s1*
h1->RetrieveBinContent(bin);
8409 Double_t z, prb1=0, prb2=0, prb3=0;
8424 if (opt.
Contains(
"N") && !(afunc1 || afunc2 ) ) {
8428 Double_t chi2 = d12*d12/(esum1+esum2);
8431 if (prob > 0 && prb2 > 0) prob *= prb2*(1-
TMath::Log(prob*prb2));
8445 int numpos = opt.
Index(
"X=") + 2;
8448 while( (numpos+numlen<len) && isdigit(opt[numpos+numlen]) )
8450 TString snum = opt(numpos,numlen);
8451 int num = atoi(snum.
Data());
8453 Warning(
"KolmogorovTest",
"invalid number of toys given: %d - use 1000",num);
8461 if (afunc1 || esum1 > esum2 )
h1->Copy(hparent);
8462 else h2->
Copy(hparent);
8470 Warning(
"KolmogorovTest",
"Detected bins with negative weights, these have been ignored and output might be "
8471 "skewed. Reduce number of bins for histogram?");
8487 for (
Int_t i=0; i < nEXPT; i++) {
8504 if (dSEXPT>dfmax) prb3 += 1.0;
8513 printf(
" Kolmo Prob h1 = %s, sum bin content =%g effective entries =%g\n",
h1->GetName(),sum1,esum1);
8514 printf(
" Kolmo Prob h2 = %s, sum bin content =%g effective entries =%g\n",h2->
GetName(),sum2,esum2);
8515 printf(
" Kolmo Prob = %g, Max Dist = %g\n",prob,dfmax);
8517 printf(
" Kolmo Prob = %f for shape alone, =%f for normalisation alone\n",prb1,prb2);
8519 printf(
" Kolmo Prob = %f with %d pseudo-experiments\n",prb3,nEXPT);
8522 if (
TMath::Abs(rsum1-1) > 0.002)
Warning(
"KolmogorovTest",
"Numerical problems with h1=%s\n",
h1->GetName());
8525 if(opt.
Contains(
"M"))
return dfmax;
8526 else if(opt.
Contains(
"X"))
return prb3;
8556 for (
Int_t level=0; level<nlevels; level++) levels[level] =
fContour.fArray[level];
8577 if (level <0 || level >=
fContour.fN)
return 0;
8584 if (zlevel <= 0)
return 0;
8604 if (bufsize < 100) bufsize = 100;
8635 for (level=0; level<nlevels; level++)
fContour.fArray[level] = levels[level];
8640 if ((zmin == zmax) && (zmin != 0)) {
8646 if (zmax <= 0)
return;
8647 if (zmin <= 0) zmin = 0.001*zmax;
8650 dz = (zmax-zmin)/
Double_t(nlevels);
8652 for (level=0; level<nlevels; level++) {
8663 if (level < 0 || level >=
fContour.fN)
return;
8691 Int_t bin, binx, biny, binz;
8698 Double_t maximum = -FLT_MAX, value;
8699 for (binz=zfirst;binz<=zlast;binz++) {
8700 for (biny=yfirst;biny<=ylast;biny++) {
8701 for (binx=xfirst;binx<=xlast;binx++) {
8702 bin =
GetBin(binx,biny,binz);
8704 if (value > maximum && value < maxval) maximum = value;
8718 Int_t locmax, locmay, locmaz;
8730 Int_t bin, binx, biny, binz;
8738 Double_t maximum = -FLT_MAX, value;
8739 locm = locmax = locmay = locmaz = 0;
8740 for (binz=zfirst;binz<=zlast;binz++) {
8741 for (biny=yfirst;biny<=ylast;biny++) {
8742 for (binx=xfirst;binx<=xlast;binx++) {
8743 bin =
GetBin(binx,biny,binz);
8745 if (value > maximum) {
8781 Int_t bin, binx, biny, binz;
8789 for (binz=zfirst;binz<=zlast;binz++) {
8790 for (biny=yfirst;biny<=ylast;biny++) {
8791 for (binx=xfirst;binx<=xlast;binx++) {
8792 bin =
GetBin(binx,biny,binz);
8794 if (value < minimum && value > minval) minimum = value;
8806 Int_t locmix, locmiy, locmiz;
8818 Int_t bin, binx, biny, binz;
8827 locm = locmix = locmiy = locmiz = 0;
8828 for (binz=zfirst;binz<=zlast;binz++) {
8829 for (biny=yfirst;biny<=ylast;biny++) {
8830 for (binx=xfirst;binx<=xlast;binx++) {
8831 bin =
GetBin(binx,biny,binz);
8833 if (value < minimum) {
8875 Int_t bin, binx, biny, binz;
8885 for (binz=zfirst;binz<=zlast;binz++) {
8886 for (biny=yfirst;biny<=ylast;biny++) {
8887 for (binx=xfirst;binx<=xlast;binx++) {
8888 bin =
GetBin(binx,biny,binz);
8890 if (value < min) min = value;
8891 if (value > max) max = value;
8909 Error(
"SetBins",
"Operation only valid for 1-d histograms");
8936 Error(
"SetBins",
"Operation only valid for 1-d histograms");
8962 Error(
"SetBins",
"Operation only valid for 2-D histograms");
8990 Error(
"SetBins",
"Operation only valid for 2-D histograms");
9017 Error(
"SetBins",
"Operation only valid for 3-D histograms");
9025 fZaxis.Set(nz,zmin,zmax);
9026 fNcells = (nx+2)*(ny+2)*(nz+2);
9047 Error(
"SetBins",
"Operation only valid for 3-D histograms");
9056 fNcells = (nx+2)*(ny+2)*(nz+2);
9169 Warning(
"Sumw2",
"Sum of squares of weights structure already created");
9201 if (bin < 0) bin = 0;
9221 if (bin < 0) bin = 0;
9231 Warning(
"GetBinErrorLow",
"Histogram has negative bin content-force usage to normal errors");
9236 if (
n == 0)
return 0;
9251 if (bin < 0) bin = 0;
9261 Warning(
"GetBinErrorUp",
"Histogram has negative bin content-force usage to normal errors");
9280 Error(
"GetBinCenter",
"Invalid method for a %d-d histogram - return a NaN",
fDimension);
9291 Error(
"GetBinLowEdge",
"Invalid method for a %d-d histogram - return a NaN",
fDimension);
9302 Error(
"GetBinWidth",
"Invalid method for a %d-d histogram - return a NaN",
fDimension);
9313 fXaxis.GetCenter(center);
9329 Error(
"GetLowEdge",
"Invalid method for a %d-d histogram ",
fDimension);
9344 if (bin < 0 || bin>=
fNcells)
return;
9346 fSumw2.fArray[bin] = error * error;
9362 if (bin < 0)
return;
9379 if (binx < 0 || binx >
fXaxis.GetNbins() + 1)
return;
9380 if (biny < 0 || biny >
fYaxis.GetNbins() + 1)
return;
9389 if (binx < 0 || binx >
fXaxis.GetNbins() + 1)
return;
9390 if (biny < 0 || biny >
fYaxis.GetNbins() + 1)
return;
9391 if (binz < 0 || binz >
fZaxis.GetNbins() + 1)
return;
9426 (
size_t)
this, niter, option).Data());
9440 (
size_t)
this,
sigma, option, threshold).Data());
9457 if (!fft || !fft->
GetN() ) {
9458 ::Error(
"TransformHisto",
"Invalid FFT transform class");
9463 ::Error(
"TransformHisto",
"Only 1d and 2D transform are supported");
9487 for (binx = 1; binx<=hout->
GetNbinsX(); binx++) {
9488 for (biny=1; biny<=hout->
GetNbinsY(); biny++) {
9489 ind[0] = binx-1; ind[1] = biny-1;
9495 for (binx = 1; binx<=hout->
GetNbinsX(); binx++) {
9496 for (biny=1; biny<=hout->
GetNbinsY(); biny++) {
9497 ind[0] = binx-1; ind[1] = biny-1;
9506 for (binx = 1; binx<=hout->
GetNbinsX(); binx++) {
9507 for (biny=1; biny<=hout->
GetNbinsY(); biny++) {
9508 ind[0] = binx-1; ind[1] = biny-1;
9514 ::Error(
"TransformHisto",
"No complex numbers in the output");
9521 for (binx = 1; binx<=hout->
GetNbinsX(); binx++) {
9522 for (biny=1; biny<=hout->
GetNbinsY(); biny++) {
9523 ind[0] = binx-1; ind[1] = biny-1;
9529 for (binx = 1; binx<=hout->
GetNbinsX(); binx++) {
9530 for (biny=1; biny<=hout->
GetNbinsY(); biny++) {
9531 ind[0] = binx-1; ind[1] = biny-1;
9540 for (binx = 1; binx<=hout->
GetNbinsX(); binx++){
9541 for (biny=1; biny<=hout->
GetNbinsY(); biny++){
9542 ind[0] = binx-1; ind[1] = biny-1;
9563 printf(
"Pure real output, no phase");
9574std::string cling::printValue(
TH1 *val) {
9575 std::ostringstream strm;
9576 strm << cling::printValue((
TObject*)val) <<
" NbinsX: " << val->
GetNbinsX();
9601:
TH1(
name,title,nbins,xlow,xup)
9647 h1c.TH1C::Copy(*
this);
9667 if (newval > -128 && newval < 128) {
fArray[bin] =
Char_t(newval);
return;}
9668 if (newval < -127)
fArray[bin] = -127;
9669 if (newval > 127)
fArray[bin] = 127;
9695 if (
n < 0)
n =
fXaxis.GetNbins() + 2;
9706 h1.TH1C::Copy(*
this);
9786:
TH1(
name,title,nbins,xlow,xup)
9832 h1s.TH1S::Copy(*
this);
9852 if (newval > -32768 && newval < 32768) {
fArray[bin] =
Short_t(newval);
return;}
9853 if (newval < -32767)
fArray[bin] = -32767;
9854 if (newval > 32767)
fArray[bin] = 32767;
9880 if (
n < 0)
n =
fXaxis.GetNbins() + 2;
9891 h1.TH1S::Copy(*
this);
9972:
TH1(
name,title,nbins,xlow,xup)
10018 h1i.TH1I::Copy(*
this);
10038 if (newval > -INT_MAX && newval < INT_MAX) {
fArray[bin] =
Int_t(newval);
return;}
10039 if (newval < -INT_MAX)
fArray[bin] = -INT_MAX;
10040 if (newval > INT_MAX)
fArray[bin] = INT_MAX;
10066 if (
n < 0)
n =
fXaxis.GetNbins() + 2;
10077 h1.TH1I::Copy(*
this);
10159:
TH1(
name,title,nbins,xlow,xup)
10205 h1l.TH1L::Copy(*
this);
10225 if (newval > -LLONG_MAX && newval < LLONG_MAX) {
fArray[bin] = newval;
return;}
10226 if (newval < -LLONG_MAX)
fArray[bin] = -LLONG_MAX;
10227 if (newval > LLONG_MAX)
fArray[bin] = LLONG_MAX;
10253 if (
n < 0)
n =
fXaxis.GetNbins() + 2;
10264 h1.TH1L::Copy(*
this);
10345:
TH1(
name,title,nbins,xlow,xup)
10383:
TH1(
"TVectorF",
"",
v.GetNrows(),0,
v.GetNrows())
10387 Int_t ivlow =
v.GetLwb();
10401 h1f.TH1F::Copy(*
this);
10434 if (
n < 0)
n =
fXaxis.GetNbins() + 2;
10445 h1f.TH1F::Copy(*
this);
10525:
TH1(
name,title,nbins,xlow,xup)
10563:
TH1(
"TVectorD",
"",
v.GetNrows(),0,
v.GetNrows())
10567 Int_t ivlow =
v.GetLwb();
10614 if (
n < 0)
n =
fXaxis.GetNbins() + 2;
10693 if(hid >= 0) hname.
Form(
"h%d",hid);
10694 else hname.
Form(
"h_%d",hid);
int Int_t
Signed integer 4 bytes (int).
short Version_t
Class version identifier (short).
char Char_t
Character 1 byte (char).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
short Short_t
Signed Short integer 2 bytes (short).
double Double_t
Double 8 bytes.
double Stat_t
Statistics type (double).
short Color_t
Color number (short).
long long Long64_t
Portable signed long integer 8 bytes.
short Style_t
Style number (short).
float Float_t
Float 4 bytes (float).
const char Option_t
Option string (const char).
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
static bool IsEquidistantBinning(const TAxis &axis)
Test if the binning is equidistant.
void H1LeastSquareLinearFit(Int_t ndata, Double_t &a0, Double_t &a1, Int_t &ifail)
Least square linear fit without weights.
void H1InitGaus()
Compute Initial values of parameters for a gaussian.
void H1InitExpo()
Compute Initial values of parameters for an exponential.
TH1C operator+(const TH1C &h1, const TH1C &h2)
Operator +.
TH1C operator-(const TH1C &h1, const TH1C &h2)
Operator -.
TH1C operator/(const TH1C &h1, const TH1C &h2)
Operator /.
void H1LeastSquareSeqnd(Int_t n, Double_t *a, Int_t idim, Int_t &ifail, Int_t k, Double_t *b)
Extracted from CERN Program library routine DSEQN.
static Bool_t AlmostEqual(Double_t a, Double_t b, Double_t epsilon=0.00000001)
Test if two double are almost equal.
static Bool_t AlmostInteger(Double_t a, Double_t epsilon=0.00000001)
Test if a double is almost an integer.
TH1 * R__H(Int_t hid)
return pointer to histogram with name hid if id >=0 h_id if id <0
TH1C operator*(Double_t c1, const TH1C &h1)
Operator *.
void H1LeastSquareFit(Int_t n, Int_t m, Double_t *a)
Least squares lpolynomial fitting without weights.
void H1InitPolynom()
Compute Initial values of parameters for a polynom.
externTVirtualMutex * gROOTMutex
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
TVectorT< Double_t > TVectorD
TVectorT< Float_t > TVectorF
#define R__LOCKGUARD(mutex)
#define R__WRITE_LOCKGUARD(mutex)
Class describing the binned data sets : vectors of x coordinates, y values and optionally error on y ...
class describing the range in the coordinates it supports multiple range in a coordinate.
void AndersonDarling2SamplesTest(Double_t &pvalue, Double_t &testStat) const
Performs the Anderson-Darling 2-Sample Test.
TArrayC()
Default TArrayC ctor.
void Set(Int_t n) override
Set size of this array to n chars.
Array of doubles (64 bits per element).
Double_t GetAt(Int_t i) const override
void Set(Int_t n) override
Set size of this array to n doubles.
TArrayD()
Default TArrayD ctor.
TArrayF()
Default TArrayF ctor.
void Set(Int_t n) override
Set size of this array to n floats.
void Set(Int_t n) override
Set size of this array to n ints.
TArrayI()
Default TArrayI ctor.
void Set(Int_t n) override
Set size of this array to n long64s.
TArrayL64()
Default TArrayL64 ctor.
void Set(Int_t n) override
Set size of this array to n shorts.
TArrayS()
Default TArrayS ctor.
Abstract array base class.
virtual void Streamer(TBuffer &)
virtual Color_t GetFillColor() const
Return the fill area color.
void Copy(TAttFill &attfill) const
virtual Style_t GetFillStyle() const
Return the fill area style.
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
virtual void SaveFillAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1001)
virtual void Streamer(TBuffer &)
virtual Color_t GetLineColor() const
Return the line color.
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
virtual Width_t GetLineWidth() const
Return the line width.
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
virtual void SaveLineAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t widdef=1)
virtual void SetLineColor(Color_t lcolor)
Set the line color.
virtual Style_t GetLineStyle() const
Return the line style.
void Copy(TAttLine &attline) const
virtual Style_t GetMarkerStyle() const
Return the marker style.
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
virtual Color_t GetMarkerColor() const
Return the marker color.
virtual Size_t GetMarkerSize() const
Return the marker size.
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
void Copy(TAttMarker &attmarker) const
virtual void Streamer(TBuffer &)
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
virtual void SaveMarkerAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t sizdef=1)
Class to manage histogram axis.
virtual Bool_t GetTimeDisplay() const
const char * GetTitle() const override
Returns title of object.
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
const TArrayD * GetXbins() const
const char * GetBinLabel(Int_t bin) const
Return label for bin.
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
virtual void SetTimeDisplay(Int_t value)
virtual void Set(Int_t nbins, Double_t xmin, Double_t xmax)
Initialize axis with fix bins.
Int_t GetLast() const
Return last bin on the axis i.e.
virtual void SetLimits(Double_t xmin, Double_t xmax)
virtual void SetRange(Int_t first=0, Int_t last=0)
Set the viewing range for the axis using bin numbers.
virtual Double_t GetBinWidth(Int_t bin) const
Return bin width.
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
Int_t GetFirst() const
Return first bin on the axis i.e.
THashList * GetLabels() const
Using a TBrowser one can browse all ROOT objects.
Buffer base class used for serializing objects.
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Return a pointer to a newly allocated object of this class.
ROOT::NewFunc_t GetNew() const
Return the wrapper around new ThisClass().
Collection abstract base class.
virtual void AddAll(const TCollection *col)
Add all objects from collection col to this collection.
virtual Bool_t IsEmpty() const
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
TDirectory::TContext keeps track and restore the current directory.
Describe directory structure in memory.
static void RejectPoint(Bool_t reject=kTRUE)
virtual Double_t Integral(Double_t a, Double_t b, Double_t epsrel=1.e-12)
static Bool_t RejectedPoint()
Provides an indirection to the TFitResult class and with a semantics identical to a TFitResult pointe...
~TH1C() override
Destructor.
void SetBinsLength(Int_t n=-1) override
Set total number of bins including under/overflow Reallocate bin contents array.
TH1C & operator=(const TH1C &h1)
Operator =.
void Copy(TObject &hnew) const override
Copy this to newth1.
void AddBinContent(Int_t bin) override
Increment bin content by 1.
void Reset(Option_t *option="") override
Reset.
1-D histogram with a double per channel (see TH1 documentation)
~TH1D() override
Destructor.
void SetBinsLength(Int_t n=-1) override
Set total number of bins including under/overflow Reallocate bin contents array.
void Copy(TObject &hnew) const override
Copy this to newth1.
TH1D & operator=(const TH1D &h1)
Operator =.
void Reset(Option_t *option="") override
Reset.
TH1F & operator=(const TH1F &h1)
Operator =.
void Copy(TObject &hnew) const override
Copy this to newth1.
void SetBinsLength(Int_t n=-1) override
Set total number of bins including under/overflow Reallocate bin contents array.
~TH1F() override
Destructor.
void SetBinsLength(Int_t n=-1) override
Set total number of bins including under/overflow Reallocate bin contents array.
void AddBinContent(Int_t bin) override
Increment bin content by 1.
~TH1I() override
Destructor.
void Copy(TObject &hnew) const override
Copy this to newth1.
TH1I & operator=(const TH1I &h1)
Operator =.
TH1L & operator=(const TH1L &h1)
Operator =.
void AddBinContent(Int_t bin) override
Increment bin content by 1.
void SetBinsLength(Int_t n=-1) override
Set total number of bins including under/overflow Reallocate bin contents array.
~TH1L() override
Destructor.
void Copy(TObject &hnew) const override
Copy this to newth1.
TH1S & operator=(const TH1S &h1)
Operator =.
void Copy(TObject &hnew) const override
Copy this to newth1.
void SetBinsLength(Int_t n=-1) override
Set total number of bins including under/overflow Reallocate bin contents array.
~TH1S() override
Destructor.
void AddBinContent(Int_t bin) override
Increment bin content by 1.
TH1 is the base class of all histogram classes in ROOT.
~TH1() override
Histogram default destructor.
virtual void SetError(const Double_t *error)
Replace bin errors by values in array error.
virtual void SetDirectory(TDirectory *dir)
By default, when a histogram is created, it is added to the list of histogram objects in the current ...
virtual void FitPanel()
Display a panel with all histogram fit options.
Double_t * fBuffer
[fBufferSize] entry buffer
virtual Int_t AutoP2FindLimits(Double_t min, Double_t max)
Buffer-based estimate of the histogram range using the power of 2 algorithm.
virtual Double_t GetEffectiveEntries() const
Number of effective entries of the histogram.
char * GetObjectInfo(Int_t px, Int_t py) const override
Redefines TObject::GetObjectInfo.
virtual void Smooth(Int_t ntimes=1, Option_t *option="")
Smooth bin contents of this histogram.
virtual Double_t GetBinCenter(Int_t bin) const
Return bin center for 1D histogram.
virtual void Rebuild(Option_t *option="")
Using the current bin info, recompute the arrays for contents and errors.
static Bool_t fgStatOverflows
! Flag to use under/overflows in statistics
virtual Int_t FindLastBinAbove(Double_t threshold=0, Int_t axis=1, Int_t firstBin=1, Int_t lastBin=-1) const
Find last bin with content > threshold for axis (1=x, 2=y, 3=z) if no bins with content > threshold i...
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px,py to a line.
virtual Bool_t Multiply(TF1 *f1, Double_t c1=1)
Performs the operation:
Int_t fNcells
Number of bins(1D), cells (2D) +U/Overflows.
virtual void GetStats(Double_t *stats) const
fill the array stats from the contents of this histogram The array stats must be correctly dimensione...
virtual void Normalize(Option_t *option="")
Normalize a histogram to its integral or to its maximum.
void Copy(TObject &hnew) const override
Copy this histogram structure to newth1.
void SetTitle(const char *title) override
Change/set the title.
Double_t fTsumw
Total Sum of weights.
virtual Float_t GetBarWidth() const
Double_t fTsumw2
Total Sum of squares of weights.
static void StatOverflows(Bool_t flag=kTRUE)
if flag=kTRUE, underflows and overflows are used by the Fill functions in the computation of statisti...
virtual Float_t GetBarOffset() const
Double_t GetSumOfAllWeights(const bool includeOverflow, Double_t *sumWeightSquare=nullptr) const
Return the sum of all weights and optionally also the sum of weight squares.
TList * fFunctions
->Pointer to list of functions (fits and user)
static Bool_t fgAddDirectory
! Flag to add histograms to the directory
static Int_t GetDefaultBufferSize()
Static function return the default buffer size for automatic histograms the parameter fgBufferSize ma...
virtual Double_t DoIntegral(Int_t ix1, Int_t ix2, Int_t iy1, Int_t iy2, Int_t iz1, Int_t iz2, Double_t &err, Option_t *opt, Bool_t doerr=kFALSE) const
Internal function compute integral and optionally the error between the limits specified by the bin n...
Double_t fTsumwx2
Total Sum of weight*X*X.
virtual Double_t GetStdDev(Int_t axis=1) const
Returns the Standard Deviation (Sigma).
TH1()
Histogram default constructor.
static TH1 * TransformHisto(TVirtualFFT *fft, TH1 *h_output, Option_t *option)
For a given transform (first parameter), fills the histogram (second parameter) with the transform ou...
void UseCurrentStyle() override
Copy current attributes from/to current style.
virtual void LabelsOption(Option_t *option="h", Option_t *axis="X")
Sort bins with labels or set option(s) to draw axis with labels.
virtual Int_t GetNbinsY() const
Short_t fBarOffset
(1000*offset) for bar charts or legos
virtual Double_t Chi2TestX(const TH1 *h2, Double_t &chi2, Int_t &ndf, Int_t &igood, Option_t *option="UU", Double_t *res=nullptr) const
The computation routine of the Chisquare test.
static bool CheckBinLimits(const TAxis *a1, const TAxis *a2)
Check bin limits.
virtual Double_t GetBinError(Int_t bin) const
Return value of error associated to bin number bin.
static Int_t FitOptionsMake(Option_t *option, Foption_t &Foption)
Decode string choptin and fill fitOption structure.
virtual Int_t GetNbinsZ() const
virtual Double_t GetMean(Int_t axis=1) const
For axis = 1,2 or 3 returns the mean value of the histogram along X,Y or Z axis.
virtual Double_t GetSkewness(Int_t axis=1) const
virtual void ClearUnderflowAndOverflow()
Remove all the content from the underflow and overflow bins, without changing the number of entries A...
virtual void FillRandom(TF1 *f1, Int_t ntimes=5000, TRandom *rng=nullptr)
virtual Double_t GetContourLevelPad(Int_t level) const
Return the value of contour number "level" in Pad coordinates.
virtual TH1 * DrawNormalized(Option_t *option="", Double_t norm=1) const
Draw a normalized copy of this histogram.
@ kNeutral
Adapt to the global flag.
virtual Int_t GetDimension() const
void Streamer(TBuffer &) override
Stream a class object.
static void AddDirectory(Bool_t add=kTRUE)
Sets the flag controlling the automatic add of histograms in memory.
@ kIsAverage
Bin contents are average (used by Add).
@ kUserContour
User specified contour levels.
@ kNoStats
Don't draw stats box.
@ kAutoBinPTwo
different than 1.
@ kIsNotW
Histogram is forced to be not weighted even when the histogram is filled with weighted.
@ kIsHighlight
bit set if histo is highlight
virtual void SetContourLevel(Int_t level, Double_t value)
Set value for one contour level.
virtual Bool_t CanExtendAllAxes() const
Returns true if all axes are extendable.
TDirectory * fDirectory
! Pointer to directory holding this histogram
virtual void Reset(Option_t *option="")
Reset this histogram: contents, errors, etc.
void SetNameTitle(const char *name, const char *title) override
Change the name and title of this histogram.
virtual void GetBinXYZ(Int_t binglobal, Int_t &binx, Int_t &biny, Int_t &binz) const
Return binx, biny, binz corresponding to the global bin number globalbin see TH1::GetBin function abo...
TH1 * GetCumulative(Bool_t forward=kTRUE, const char *suffix="_cumulative") const
Return a pointer to a histogram containing the cumulative content.
static Double_t AutoP2GetPower2(Double_t x, Bool_t next=kTRUE)
Auxiliary function to get the power of 2 next (larger) or previous (smaller) a given x.
virtual Int_t GetNcells() const
virtual Int_t ShowPeaks(Double_t sigma=2, Option_t *option="", Double_t threshold=0.05)
Interface to TSpectrum::Search.
static Bool_t RecomputeAxisLimits(TAxis &destAxis, const TAxis &anAxis)
Finds new limits for the axis for the Merge function.
virtual Double_t GetSumOfWeights() const
Return the sum of weights across all bins excluding under/overflows.
virtual void PutStats(Double_t *stats)
Replace current statistics with the values in array stats.
TVirtualHistPainter * GetPainter(Option_t *option="")
Return pointer to painter.
TObject * FindObject(const char *name) const override
Search object named name in the list of functions.
void Print(Option_t *option="") const override
Print some global quantities for this histogram.
static Bool_t GetDefaultSumw2()
Return kTRUE if TH1::Sumw2 must be called when creating new histograms.
virtual Int_t FindFirstBinAbove(Double_t threshold=0, Int_t axis=1, Int_t firstBin=1, Int_t lastBin=-1) const
Find first bin with content > threshold for axis (1=x, 2=y, 3=z) if no bins with content > threshold ...
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Double_t xmin=0, Double_t xmax=0)
Fit histogram with function fname.
virtual Int_t GetBin(Int_t binx, Int_t biny=0, Int_t binz=0) const
Return Global bin number corresponding to binx,y,z.
virtual Double_t GetMaximum(Double_t maxval=FLT_MAX) const
Return maximum value smaller than maxval of bins in the range, unless the value has been overridden b...
virtual Int_t GetNbinsX() const
virtual void SetMaximum(Double_t maximum=-1111)
virtual TH1 * FFT(TH1 *h_output, Option_t *option)
This function allows to do discrete Fourier transforms of TH1 and TH2.
virtual void LabelsInflate(Option_t *axis="X")
Double the number of bins for axis.
virtual TH1 * ShowBackground(Int_t niter=20, Option_t *option="same")
This function calculates the background spectrum in this histogram.
static Bool_t SameLimitsAndNBins(const TAxis &axis1, const TAxis &axis2)
Same limits and bins.
virtual Bool_t Add(TF1 *h1, Double_t c1=1, Option_t *option="")
Performs the operation: this = this + c1*f1 if errors are defined (see TH1::Sumw2),...
Double_t fMaximum
Maximum value for plotting.
Int_t fBufferSize
fBuffer size
TString ProvideSaveName(Option_t *option, Bool_t testfdir=kFALSE)
Provide variable name for histogram for saving as primitive Histogram pointer has by default the hist...
virtual Double_t IntegralAndError(Int_t binx1, Int_t binx2, Double_t &err, Option_t *option="") const
Return integral of bin contents in range [binx1,binx2] and its error.
Int_t fDimension
! Histogram dimension (1, 2 or 3 dim)
virtual void SetBinError(Int_t bin, Double_t error)
Set the bin Error Note that this resets the bin eror option to be of Normal Type and for the non-empt...
EBinErrorOpt fBinStatErrOpt
Option for bin statistical errors.
static Int_t fgBufferSize
! Default buffer size for automatic histograms
virtual void SetBinsLength(Int_t=-1)
Double_t fNormFactor
Normalization factor.
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
TArrayD fContour
Array to display contour levels.
virtual Double_t GetBinErrorLow(Int_t bin) const
Return lower error associated to bin number bin.
void Browse(TBrowser *b) override
Browse the Histogram object.
virtual void SetContent(const Double_t *content)
Replace bin contents by the contents of array content.
void Draw(Option_t *option="") override
Draw this histogram with options.
virtual void SavePrimitiveHelp(std::ostream &out, const char *hname, Option_t *option="")
Helper function for the SavePrimitive functions from TH1 or classes derived from TH1,...
Short_t fBarWidth
(1000*width) for bar charts or legos
virtual Double_t GetBinErrorSqUnchecked(Int_t bin) const
Int_t AxisChoice(Option_t *axis) const
Choose an axis according to "axis".
virtual void SetMinimum(Double_t minimum=-1111)
Bool_t IsBinUnderflow(Int_t bin, Int_t axis=0) const
Return true if the bin is underflow.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
static bool CheckBinLabels(const TAxis *a1, const TAxis *a2)
Check that axis have same labels.
virtual Double_t Interpolate(Double_t x) const
Given a point x, approximates the value via linear interpolation based on the two nearest bin centers...
static void SetDefaultSumw2(Bool_t sumw2=kTRUE)
When this static function is called with sumw2=kTRUE, all new histograms will automatically activate ...
virtual void SetBuffer(Int_t bufsize, Option_t *option="")
Set the maximum number of entries to be kept in the buffer.
Bool_t IsBinOverflow(Int_t bin, Int_t axis=0) const
Return true if the bin is overflow.
UInt_t GetAxisLabelStatus() const
Internal function used in TH1::Fill to see which axis is full alphanumeric, i.e.
Double_t * fIntegral
! Integral of bins used by GetRandom
Double_t fMinimum
Minimum value for plotting.
virtual Double_t Integral(Option_t *option="") const
Return integral of bin contents.
virtual void SetBarWidth(Float_t width=0.5)
Set the width of bars as fraction of the bin width for drawing mode "B".
static void SetDefaultBufferSize(Int_t bufsize=1000)
Static function to set the default buffer size for automatic histograms.
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content see convention for numbering bins in TH1::GetBin In case the bin number is greater th...
virtual void DirectoryAutoAdd(TDirectory *)
Callback to perform the automatic addition of the histogram to the given directory.
virtual void GetLowEdge(Double_t *edge) const
Fill array with low edge of bins for 1D histogram Better to use h1.GetXaxis()->GetLowEdge(edge).
virtual Double_t GetBinLowEdge(Int_t bin) const
Return bin lower edge for 1D histogram.
void Build()
Creates histogram basic data structure.
virtual Double_t GetEntries() const
Return the current number of entries.
virtual Double_t RetrieveBinContent(Int_t bin) const =0
Raw retrieval of bin content on internal data structure see convention for numbering bins in TH1::Get...
virtual TF1 * GetFunction(const char *name) const
Return pointer to function with name.
virtual TH1 * Rebin(Int_t ngroup=2, const char *newname="", const Double_t *xbins=nullptr)
Rebin this histogram.
virtual Int_t BufferFill(Double_t x, Double_t w)
accumulate arguments in buffer.
virtual Double_t GetBinWithContent(Double_t c, Int_t &binx, Int_t firstx=0, Int_t lastx=0, Double_t maxdiff=0) const
Compute first binx in the range [firstx,lastx] for which diff = abs(bin_content-c) <= maxdiff.
virtual UInt_t SetCanExtend(UInt_t extendBitMask)
Make the histogram axes extendable / not extendable according to the bit mask returns the previous bi...
TList * GetListOfFunctions() const
void SetName(const char *name) override
Change the name of this histogram.
virtual TH1 * DrawCopy(Option_t *option="", const char *name_postfix="_copy") const
Copy this histogram and Draw in the current pad.
virtual Double_t GetRandom(TRandom *rng=nullptr, Option_t *option="") const
Return a random number distributed according the histogram bin contents.
Bool_t IsEmpty() const
Check if a histogram is empty (this is a protected method used mainly by TH1Merger ).
virtual Double_t GetMeanError(Int_t axis=1) const
Return standard error of mean of this histogram along the X axis.
void Paint(Option_t *option="") override
Control routine to paint any kind of histograms.
virtual void SetBarOffset(Float_t offset=0.25)
Set the bar offset as fraction of the bin width for drawing mode "B".
virtual Double_t AndersonDarlingTest(const TH1 *h2, Option_t *option="") const
Statistical test of compatibility in shape between this histogram and h2, using the Anderson-Darling ...
virtual void ResetStats()
Reset the statistics including the number of entries and replace with values calculated from bin cont...
@ kNstat
Size of statistics data (up to TProfile3D).
virtual void SetBinErrorOption(EBinErrorOpt type)
virtual void DrawPanel()
Display a panel with all histogram drawing options.
virtual Double_t Chisquare(TF1 *f1, Option_t *option="") const
Compute and return the chisquare of this histogram with respect to a function The chisquare is comput...
virtual Double_t Chi2Test(const TH1 *h2, Option_t *option="UU", Double_t *res=nullptr) const
test for comparing weighted and unweighted histograms.
virtual void DoFillN(Int_t ntimes, const Double_t *x, const Double_t *w, Int_t stride=1)
Internal method to fill histogram content from a vector called directly by TH1::BufferEmpty.
virtual void GetMinimumAndMaximum(Double_t &min, Double_t &max) const
Retrieve the minimum and maximum values in the histogram.
virtual Int_t GetMaximumBin() const
Return location of bin with maximum value in the range.
static Int_t AutoP2GetBins(Int_t n)
Auxiliary function to get the next power of 2 integer value larger then n.
Double_t fEntries
Number of entries.
virtual Long64_t Merge(TCollection *list)
virtual void SetColors(Color_t linecolor=-1, Color_t markercolor=-1, Color_t fillcolor=-1)
Shortcut to set the three histogram colors with a single call.
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
virtual Double_t * GetIntegral()
Return a pointer to the array of bins integral.
TAxis fZaxis
Z axis descriptor.
EStatOverflows fStatOverflows
Per object flag to use under/overflows in statistics.
TClass * IsA() const override
virtual void FillN(Int_t ntimes, const Double_t *x, const Double_t *w, Int_t stride=1)
Fill this histogram with an array x and weights w.
static bool CheckEqualAxes(const TAxis *a1, const TAxis *a2)
Check that the axis are the same.
@ kPoisson2
Errors from Poisson interval at 95% CL (~ 2 sigma).
@ kNormal
Errors with Normal (Wald) approximation: errorUp=errorLow= sqrt(N).
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
virtual Int_t GetContour(Double_t *levels=nullptr)
Return contour values into array levels if pointer levels is non zero.
TAxis fXaxis
X axis descriptor.
virtual Bool_t IsHighlight() const
virtual void ExtendAxis(Double_t x, TAxis *axis)
Histogram is resized along axis such that x is in the axis range.
virtual Double_t GetBinWidth(Int_t bin) const
Return bin width for 1D histogram.
TArrayD fSumw2
Array of sum of squares of weights.
TH1 * GetAsymmetry(TH1 *h2, Double_t c2=1, Double_t dc2=0)
Return a histogram containing the asymmetry of this histogram with h2, where the asymmetry is defined...
virtual Double_t GetContourLevel(Int_t level) const
Return value of contour number level.
virtual void SetContour(Int_t nlevels, const Double_t *levels=nullptr)
Set the number and values of contour levels.
virtual void SetHighlight(Bool_t set=kTRUE)
Set highlight (enable/disable) mode for the histogram by default highlight mode is disable.
virtual Double_t GetBinErrorUp(Int_t bin) const
Return upper error associated to bin number bin.
virtual void Scale(Double_t c1=1, Option_t *option="")
Multiply this histogram by a constant c1.
virtual Int_t GetMinimumBin() const
Return location of bin with minimum value in the range.
virtual Double_t ComputeIntegral(Bool_t onlyPositive=false, Option_t *option="")
Compute integral (normalized cumulative sum of bins) w/o under/overflows The result is stored in fInt...
virtual Int_t GetSumw2N() const
virtual Int_t FindBin(Double_t x, Double_t y=0, Double_t z=0)
Return Global bin number corresponding to x,y,z.
Bool_t GetStatOverflowsBehaviour() const
void SaveAs(const char *filename="hist", Option_t *option="") const override
Save the histogram as .csv, .tsv or .txt.
virtual Int_t GetQuantiles(Int_t n, Double_t *xp, const Double_t *p=nullptr)
Compute Quantiles for this histogram.
virtual void AddBinContent(Int_t bin)=0
Increment bin content by 1.
TObject * Clone(const char *newname="") const override
Make a complete copy of the underlying object.
virtual Double_t GetStdDevError(Int_t axis=1) const
Return error of standard deviation estimation for Normal distribution.
virtual Bool_t Divide(TF1 *f1, Double_t c1=1)
Performs the operation: this = this/(c1*f1) if errors are defined (see TH1::Sumw2),...
virtual Double_t GetMinimum(Double_t minval=-FLT_MAX) const
Return minimum value larger than minval of bins in the range, unless the value has been overridden by...
int LoggedInconsistency(const char *name, const TH1 *h1, const TH1 *h2, bool useMerge=false) const
static bool CheckConsistentSubAxes(const TAxis *a1, Int_t firstBin1, Int_t lastBin1, const TAxis *a2, Int_t firstBin2=0, Int_t lastBin2=0)
Check that two sub axis are the same.
static Int_t CheckConsistency(const TH1 *h1, const TH1 *h2)
Check histogram compatibility.
void RecursiveRemove(TObject *obj) override
Recursively remove object from the list of functions.
TAxis fYaxis
Y axis descriptor.
virtual Double_t KolmogorovTest(const TH1 *h2, Option_t *option="") const
Statistical test of compatibility in shape between this histogram and h2, using Kolmogorov test.
static void SmoothArray(Int_t NN, Double_t *XX, Int_t ntimes=1)
Smooth array xx, translation of Hbook routine hsmoof.F.
virtual void GetCenter(Double_t *center) const
Fill array with center of bins for 1D histogram Better to use h1.GetXaxis()->GetCenter(center).
TVirtualHistPainter * fPainter
! Pointer to histogram painter
virtual void SetBins(Int_t nx, Double_t xmin, Double_t xmax)
Redefine x axis parameters.
virtual Int_t FindFixBin(Double_t x, Double_t y=0, Double_t z=0) const
Return Global bin number corresponding to x,y,z.
virtual void Sumw2(Bool_t flag=kTRUE)
Create structure to store sum of squares of weights.
virtual void SetEntries(Double_t n)
virtual Bool_t FindNewAxisLimits(const TAxis *axis, const Double_t point, Double_t &newMin, Double_t &newMax)
finds new limits for the axis so that point is within the range and the limits are compatible with th...
static bool CheckAxisLimits(const TAxis *a1, const TAxis *a2)
Check that the axis limits of the histograms are the same.
static Bool_t AddDirectoryStatus()
Check whether TH1-derived classes should register themselves to the current gDirectory.
static Bool_t fgDefaultSumw2
! Flag to call TH1::Sumw2 automatically at histogram creation time
static void SavePrimitiveFunctions(std::ostream &out, const char *varname, TList *lst)
Save list of functions Also can be used by TGraph classes.
virtual void UpdateBinContent(Int_t bin, Double_t content)=0
Raw update of bin content on internal data structure see convention for numbering bins in TH1::GetBin...
Double_t fTsumwx
Total Sum of weight*X.
virtual void LabelsDeflate(Option_t *axis="X")
Reduce the number of bins for the axis passed in the option to the number of bins having a label.
TString fOption
Histogram options.
virtual void Eval(TF1 *f1, Option_t *option="")
Evaluate function f1 at the center of bins of this histogram.
virtual Int_t BufferEmpty(Int_t action=0)
Fill histogram with all entries in the buffer.
@ kNoAxis
NOTE: Must always be 0 !!!
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
virtual Double_t GetKurtosis(Int_t axis=1) const
2-D histogram with a double per channel (see TH1 documentation)
static THLimitsFinder * GetLimitsFinder()
Return pointer to the current finder.
virtual Int_t FindGoodLimits(TH1 *h, Double_t xmin, Double_t xmax)
Compute the best axis limits for the X axis.
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
virtual TObjLink * FirstLink() const
TObject * At(Int_t idx) const override
Returns the object at position idx. Returns 0 if idx is out of range.
void Copy(TObject &named) const override
Copy this to obj.
const char * GetName() const override
Returns name of object.
void Streamer(TBuffer &) override
Stream an object of class TObject.
const char * GetTitle() const override
Returns title of object.
Wrapper around a TObject so it can be stored in a TList.
TObject * GetObject() const
virtual Option_t * GetOption() const
Mother of all ROOT objects.
Bool_t TestBit(UInt_t f) const
virtual const char * GetName() const
Returns name of object.
virtual UInt_t GetUniqueID() const
Return the unique object id.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
virtual void UseCurrentStyle()
Set current style settings in this object This function is called when either TCanvas::UseCurrentStyl...
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
virtual void SaveAs(const char *filename="", Option_t *option="") const
Save this object in the file specified by filename.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void SetUniqueID(UInt_t uid)
Set the unique object id.
static void SavePrimitiveDraw(std::ostream &out, const char *variable_name, Option_t *option=nullptr)
Save invocation of primitive Draw() method Skipped if option contains "nodraw" string.
TObject()
TObject constructor.
static TString SavePrimitiveVector(std::ostream &out, const char *prefix, Int_t len, Double_t *arr, Int_t flag=0)
Save array in the output stream "out" as vector.
@ kCanDelete
if object in a list can be deleted
@ kInvalidObject
if object ctor succeeded but object should not be used
@ kMustCleanup
if object destructor must call RecursiveRemove()
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Longptr_t ExecPlugin(int nargs)
Int_t LoadPlugin()
Load the plugin library for this handler.
This is the base class for the ROOT Random number generators.
Double_t Rndm() override
Machine independent random number generator.
virtual ULong64_t Poisson(Double_t mean)
Generates a random integer N according to a Poisson law.
void ToLower()
Change string to lower-case.
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
TString & ReplaceSpecialCppChars()
Find special characters which are typically used in printf() calls and replace them by appropriate es...
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
void ToUpper()
Change string to upper case.
TString & Remove(Ssiz_t pos)
TString & Append(const char *cs)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
TVirtualFFT is an interface class for Fast Fourier Transforms.
static TVirtualFFT * FFT(Int_t ndim, Int_t *n, Option_t *option)
Returns a pointer to the FFT of requested size and type.
virtual Int_t GetNdim() const =0
static TVirtualFFT * SineCosine(Int_t ndim, Int_t *n, Int_t *r2rkind, Option_t *option)
Returns a pointer to a sine or cosine transform of requested size and kind.
virtual Option_t * GetType() const =0
virtual void Transform()=0
virtual void GetPointComplex(Int_t ipoint, Double_t &re, Double_t &im, Bool_t fromInput=kFALSE) const =0
virtual Int_t * GetN() const =0
virtual Double_t GetPointReal(Int_t ipoint, Bool_t fromInput=kFALSE) const =0
virtual void SetPoint(Int_t ipoint, Double_t re, Double_t im=0)=0
Abstract Base Class for Fitting.
virtual Int_t GetXlast() const
virtual TObject * GetObjectFit() const
virtual Int_t GetXfirst() const
static TVirtualFitter * GetFitter()
static: return the current Fitter
virtual TObject * GetUserFunc() const
Abstract interface to a histogram painter.
static TVirtualHistPainter * HistPainter(TH1 *obj)
Static function returning a pointer to the current histogram painter.
virtual void SetParent(TObject *)=0
double gamma_quantile_c(double z, double alpha, double theta)
Inverse ( ) of the cumulative distribution function of the upper tail of the gamma distribution (gamm...
double gamma_quantile(double z, double alpha, double theta)
Inverse ( ) of the cumulative distribution function of the lower tail of the gamma distribution (gamm...
bool HasBeenDeleted(const TObject *obj)
Check if the TObject's memory has been deleted.
bool ObjectAutoRegistrationEnabled()
Test whether objects in this thread auto-register themselves, e.g.
TFitResultPtr FitObject(TH1 *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
fitting function for a TH1 (called from TH1::Fit)
double Chisquare(const TH1 &h1, TF1 &f1, bool useRange, EChisquareType type, bool useIntegral=false)
compute the chi2 value for an histogram given a function (see TH1::Chisquare for the documentation)
void FitOptionsMake(EFitObjectType type, const char *option, Foption_t &fitOption)
Decode list of options into fitOption.
void FillData(BinData &dv, const TH1 *hist, TF1 *func=nullptr)
fill the data vector from a TH1.
externTVirtualRWMutex * gCoreMutex
Int_t Nint(T x)
Round to nearest integer. Rounds half integers to the nearest even integer.
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Double_t Prob(Double_t chi2, Int_t ndf)
Double_t Median(Long64_t n, const T *a, const Double_t *w=nullptr, Long64_t *work=nullptr)
Same as RMS.
Double_t QuietNaN()
Returns a quiet NaN as defined by IEEE 754.
Double_t Floor(Double_t x)
Rounds x downward, returning the largest integral value that is not greater than x.
Double_t ATan(Double_t)
Returns the principal value of the arc tangent of x, expressed in radians.
Double_t Ceil(Double_t x)
Rounds x upward, returning the smallest integral value that is not less than x.
T MinElement(Long64_t n, const T *a)
Returns minimum of array a of length n.
Double_t Log(Double_t x)
Returns the natural logarithm of x.
Double_t Sqrt(Double_t x)
Returns the square root of x.
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Bool_t AreEqualRel(Double_t af, Double_t bf, Double_t relPrec)
Comparing floating points.
Bool_t AreEqualAbs(Double_t af, Double_t bf, Double_t epsilon)
Comparing floating points.
Double_t KolmogorovProb(Double_t z)
void Sort(Index n, const Element *a, Index *index, Bool_t down=kTRUE)
Sort the n elements of the array a of generic templated type Element.
Long64_t BinarySearch(Long64_t n, const T *array, T value)
Binary search in an array of n values to locate value.
Double_t Log10(Double_t x)
Returns the common (base-10) logarithm of x.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Double_t Infinity()
Returns an infinity as defined by the IEEE standard.
static uint64_t sum(uint64_t i)