104 :
TH1(
name,title,nbinsx,xlow,xup)
108 Warning(
"TH3",
"nbinsy is <=0 - set to nbinsy = 1");
112 Warning(
"TH3",
"nbinsz is <=0 - set to nbinsz = 1");
117 fNcells = (nbinsx+2)*(nbinsy+2)*(nbinsz+2);
148 if (nbinsy <= 0) {
Warning(
"TH3",
"nbinsy is <=0 - set to nbinsy = 1"); nbinsy = 1; }
149 if (nbinsz <= 0) nbinsz = 1;
154 fNcells = (nbinsx+2)*(nbinsy+2)*(nbinsz+2);
185 if (nbinsy <= 0) {
Warning(
"TH3",
"nbinsy is <=0 - set to nbinsy = 1"); nbinsy = 1; }
186 if (nbinsz <= 0) nbinsz = 1;
191 fNcells = (nbinsx+2)*(nbinsy+2)*(nbinsz+2);
269 if (!nbentries)
return 0;
272 if (action == 0)
return 0;
273 nbentries = -nbentries;
288 for (
Int_t i=1;i<nbentries;i++) {
296 if (z < zmin) zmin = z;
297 if (z > zmax) zmax = z;
316 for (
Int_t i=0;i<nbentries;i++) {
317 Fill(buffer[4*i+2],buffer[4*i+3],buffer[4*i+4],buffer[4*i+1]);
344 nbentries = -nbentries;
370 Error(
"Fill",
"Invalid signature - do nothing");
385 Int_t binx, biny, binz, bin;
390 if (binx <0 || biny <0 || binz<0)
return -1;
433 Int_t binx, biny, binz, bin;
438 if (binx <0 || biny <0 || binz<0)
return -1;
478 Int_t binx, biny, binz, bin;
483 if (binx <0 || biny <0 || binz<0)
return -1;
526 Int_t binx, biny, binz, bin;
531 if (binx <0 || biny <0 || binz<0)
return -1;
574 Int_t binx, biny, binz, bin;
579 if (binx <0 || biny <0 || binz<0)
return -1;
622 Int_t binx, biny, binz, bin;
627 if (binx <0 || biny <0 || binz<0)
return -1;
670 Int_t binx, biny, binz, bin;
675 if (binx < 0 || biny < 0 || binz < 0)
724 Int_t binx, biny, binz, bin;
729 if (binx <0 || biny <0 || binz<0)
return -1;
773 Int_t binx, biny, binz, bin;
778 if (binx <0 || biny <0 || binz<0)
return -1;
835 Int_t bin, binx, biny, binz, ibin, loop;
839 if (!fobj) {
Error(
"FillRandom",
"Unknown function: %s",fname);
return; }
840 TF3 *
f1 =
dynamic_cast<TF3*
>( fobj );
841 if (!
f1) {
Error(
"FillRandom",
"Function: %s is not a TF3, is a %s",fname,fobj->
IsA()->
GetName());
return; }
851 Info(
"FillRandom",
"Using function axis and range ([%g,%g],[%g,%g],[%g,%g])",
xmin,
xmax,
ymin,
ymax,zmin,zmax);
861 Int_t nxy = nbinsx*nbinsy;
862 Int_t nbins = nbinsx*nbinsy*nbinsz;
868 for (binz=1;binz<=nbinsz;binz++) {
870 for (biny=1;biny<=nbinsy;biny++) {
872 for (binx=1;binx<=nbinsx;binx++) {
880 integral[ibin] = integral[ibin-1] + fint;
886 if (integral[nbins] == 0 ) {
888 Error(
"FillRandom",
"Integral = zero");
return;
890 for (bin=1;bin<=nbins;bin++) integral[bin] /= integral[nbins];
895 for (loop=0;loop<ntimes;loop++) {
899 biny = (ibin - nxy*binz)/nbinsx;
900 binx = 1 + ibin - nbinsx*(biny + nbinsy*binz);
930 if (!
h) {
Error(
"FillRandom",
"Null histogram");
return; }
932 Error(
"FillRandom",
"Histograms with different dimensions");
return;
935 if (
h->ComputeIntegral() == 0)
return;
940 for (loop=0;loop<ntimes;loop++) {
941 h3->GetRandom3(
x,
y,z,rng);
985 auto computeFirstAndLastBin = [](
const TAxis & outerAxis,
Int_t &firstbin,
Int_t &lastbin) {
993 if (firstbin == 0 && lastbin == 0) {
998 if (firstbin < 0) firstbin = 0;
999 if (lastbin < 0 || lastbin > nbins + 1) lastbin = nbins + 1;
1000 if (lastbin < firstbin) {firstbin = 0; lastbin = nbins + 1;}
1003 computeFirstAndLastBin(
fXaxis, binminx, binmaxx);
1004 computeFirstAndLastBin(
fYaxis, binminy, binmaxy);
1007 auto computeAxisLimits = [](
const TAxis & outerAxis,
Int_t firstbin,
Int_t lastbin,
1009 Int_t firstOutBin = std::max(firstbin,1);
1010 Int_t lastOutBin = std::min(lastbin,outerAxis.
GetNbins() ) ;
1011 nBins = lastOutBin-firstOutBin+1;
1019 Int_t firstBinXaxis = computeAxisLimits(
fXaxis, binminx, binmaxx, nbinsX, xMin, xMax);
1022 Int_t firstBinYaxis = computeAxisLimits(
fYaxis, binminy, binmaxy, nbinsY, yMin, yMax);
1025 if (
f1 ==
nullptr) {
1039 std::vector<TH1*> hlist(npar+1);
1042 for (ipar=0;ipar<= npar;ipar++) {
1050 title =
"chisquare";
1052 if (xbins->fN == 0 && ybins->
fN == 0) {
1053 hlist[ipar] =
new TH2D(
name, title,
1055 nbinsY, yMin, yMax);
1056 }
else if (xbins->fN > 0 && ybins->
fN > 0 ) {
1057 hlist[ipar] =
new TH2D(
name, title,
1058 nbinsX, &xbins->fArray[firstBinXaxis],
1059 nbinsY, &ybins->
fArray[firstBinYaxis]);
1067 TH1 * hchi2 = hlist.back();
1070 TH1D *hpz =
nullptr;
1075 for (
Int_t biny=binminy; biny<=binmaxy; biny++) {
1076 for (
Int_t binx=binminx; binx<=binmaxx; binx++) {
1083 Info(
"FitSlicesZ",
"Slice (%d,%d) skipped, the number of entries is zero or smaller than the given cut value, n=%f",binx,biny,
nentries);
1089 int ibx,iby,ibz = 0;
1090 hlist[0]->GetBinXYZ(bin,ibx,iby,ibz);
1096 if (npfits > npar && npfits >= cut) {
1097 for (ipar=0;ipar<npar;ipar++) {
1105 Info(
"FitSlicesZ",
"Fitted slice (%d,%d) skipped, the number of fitted points is too small, n=%d",binx,biny,npfits);
1120 if (biny < 0) biny = 0;
1121 if (biny > ofy) biny = ofy;
1124 if (binz < 0) binz = 0;
1125 if (binz > ofz) binz = ofz;
1161 Error(
"GetBinWithContent3",
"function is only valid for 3-D histograms");
1164 if (firstx <= 0) firstx = 1;
1166 if (firsty <= 0) firsty = 1;
1168 if (firstz <= 0) firstz = 1;
1170 Int_t binminx = 0, binminy=0, binminz=0;
1172 for (
Int_t k=firstz;k<=lastz;k++) {
1173 for (
Int_t j=firsty;j<=lasty;j++) {
1174 for (
Int_t i=firstx;i<=lastx;i++) {
1176 if (diff <= 0) {binx = i; biny=j; binz=k;
return diff;}
1177 if (diff < curmax && diff <= maxdiff) {curmax = diff, binminx=i; binminy=j;binminz=k;}
1193 if (axis1 < 1 || axis2 < 1 || axis1 > 3 || axis2 > 3) {
1194 Error(
"GetCorrelationFactor",
"Wrong parameters");
1197 if (axis1 == axis2)
return 1;
1199 if (stddev1 == 0)
return 0;
1201 if (stddev2 == 0)
return 0;
1211 if (axis1 < 1 || axis2 < 1 || axis1 > 3 || axis2 > 3) {
1212 Error(
"GetCovariance",
"Wrong parameters");
1228 if (sumw == 0)
return 0;
1229 if (axis1 == 1 && axis2 == 1) {
1230 return TMath::Abs(sumwx2/sumw - sumwx*sumwx/(sumw*sumw));
1232 if (axis1 == 2 && axis2 == 2) {
1233 return TMath::Abs(sumwy2/sumw - sumwy*sumwy/(sumw*sumw));
1235 if (axis1 == 3 && axis2 == 3) {
1236 return TMath::Abs(sumwz2/sumw - sumwz*sumwz/(sumw*sumw));
1238 if ((axis1 == 1 && axis2 == 2) || (axis1 == 2 && axis2 == 1)) {
1239 return sumwxy/sumw - sumwx*sumwy/(sumw*sumw);
1241 if ((axis1 == 1 && axis2 == 3) || (axis1 == 3 && axis2 == 1)) {
1242 return sumwxz/sumw - sumwx*sumwz/(sumw*sumw);
1244 if ((axis1 == 2 && axis2 == 3) || (axis1 == 3 && axis2 == 2)) {
1245 return sumwyz/sumw - sumwy*sumwz/(sumw*sumw);
1264 Int_t nxy = nbinsx*nbinsy;
1265 Int_t nbins = nxy*nbinsz;
1274 if (integral == 0 ) {
x = 0;
y = 0; z = 0;
return;}
1281 Int_t binz = ibin/nxy;
1282 Int_t biny = (ibin - nxy*binz)/nbinsx;
1283 Int_t binx = ibin - nbinsx*(biny + nbinsy*binz);
1311 Int_t bin, binx, biny, binz;
1315 for (bin=0;bin<11;bin++) stats[bin] = 0;
1326 if (firstBinX == 1) firstBinX = 0;
1330 if (firstBinY == 1) firstBinY = 0;
1334 if (firstBinZ == 1) firstBinZ = 0;
1344 for (binz = firstBinZ; binz <= lastBinZ; binz++) {
1346 for (biny = firstBinY; biny <= lastBinY; biny++) {
1348 for (binx = firstBinX; binx <= lastBinX; binx++) {
1349 bin =
GetBin(binx,biny,binz);
1355 stats[1] += err*err;
1433 Error(
"Interpolate",
"This function must be called with 3 arguments for a TH3");
1443 Error(
"Interpolate",
"This function must be called with 3 arguments for a TH3");
1462 Int_t obx = ubx + 1;
1466 Int_t oby = uby + 1;
1470 Int_t obz = ubz + 1;
1475 if (ubx <=0 || uby <=0 || ubz <= 0 ||
1477 Error(
"Interpolate",
"Cannot interpolate outside histogram domain.");
1502 Double_t w1 = i1 * (1 - yd) + i2 * yd;
1503 Double_t w2 = j1 * (1 - yd) + j2 * yd;
1539 if (h2 ==
nullptr)
return 0;
1541 const TAxis *xaxis2 = h2->GetXaxis();
1543 const TAxis *yaxis2 = h2->GetYaxis();
1545 const TAxis *zaxis2 = h2->GetZaxis();
1555 Error(
"KolmogorovTest",
"Histograms must be 3-D\n");
1561 Error(
"KolmogorovTest",
"Number of channels in X is different, %d and %d\n",ncx1,ncx2);
1565 Error(
"KolmogorovTest",
"Number of channels in Y is different, %d and %d\n",ncy1,ncy2);
1569 Error(
"KolmogorovTest",
"Number of channels in Z is different, %d and %d\n",ncz1,ncz2);
1579 if (diff1 > difprec || diff2 > difprec) {
1580 Error(
"KolmogorovTest",
"histograms with different binning along X");
1585 if (diff1 > difprec || diff2 > difprec) {
1586 Error(
"KolmogorovTest",
"histograms with different binning along Y");
1591 if (diff1 > difprec || diff2 > difprec) {
1592 Error(
"KolmogorovTest",
"histograms with different binning along Z");
1597 Int_t ibeg = 1, jbeg = 1, kbeg = 1;
1598 Int_t iend = ncx1, jend = ncy1, kend = ncz1;
1599 if (opt.
Contains(
"U")) {ibeg = 0; jbeg = 0; kbeg = 0;}
1600 if (opt.
Contains(
"O")) {iend = ncx1+1; jend = ncy1+1; kend = ncz1+1;}
1607 for (i = ibeg; i <= iend; i++) {
1608 for (j = jbeg; j <= jend; j++) {
1609 for (k = kbeg; k <= kend; k++) {
1612 sum2 += h2->GetBinContent(bin);
1614 Double_t ew2 = h2->GetBinError(bin);
1624 Error(
"KolmogorovTest",
"Integral is zero for h1=%s\n",
h1->
GetName());
1628 Error(
"KolmogorovTest",
"Integral is zero for h2=%s\n",h2->GetName());
1636 esum1 = sum1 * sum1 / w1;
1641 esum2 = sum2 * sum2 / w2;
1645 if (afunc2 && afunc1) {
1646 Error(
"KolmogorovTest",
"Errors are zero for both histograms\n");
1652 int order[3] = {0,1,2};
1656 binbeg[0] = ibeg; binbeg[1] = jbeg; binbeg[2] = kbeg;
1657 binend[0] = iend; binend[1] = jend; binend[2] = kend;
1666 for (i = binbeg[order[0] ]; i <= binend[order[0] ]; i++) {
1667 for ( j = binbeg[order[1] ]; j <= binend[order[1] ]; j++) {
1668 for ( k = binbeg[order[2] ]; k <= binend[order[2] ]; k++) {
1669 ibin[ order[0] ] = i;
1670 ibin[ order[1] ] = j;
1671 ibin[ order[2] ] = k;
1672 bin =
h1->
GetBin(ibin[0],ibin[1],ibin[2]);
1674 rsum2 += s2*h2->GetBinContent(bin);
1679 vdfmax[icomb] = dmax;
1698 if (opt.
Contains(
"N") && !(afunc1 || afunc2 ) ) {
1702 Double_t chi2 = d12*d12/(esum1+esum2);
1705 if (prb > 0 && prb2 > 0) prb = prb*prb2*(1-
TMath::Log(prb*prb2));
1711 printf(
" Kolmo Prob h1 = %s, sum1=%g\n",
h1->
GetName(),sum1);
1712 printf(
" Kolmo Prob h2 = %s, sum2=%g\n",h2->GetName(),sum2);
1713 printf(
" Kolmo Probabil = %f, Max Dist = %g\n",prb,dfmax);
1715 printf(
" Kolmo Probabil = %f for shape alone, =%f for normalisation alone\n",prb1,prb2);
1719 if (
TMath::Abs(rsum2-1) > 0.002)
Warning(
"KolmogorovTest",
"Numerical problems with h2=%s\n",h2->GetName());
1721 if (opt.
Contains(
"M"))
return dfmax;
1854 computeErrors =
kTRUE;
1859 originalRange =
kTRUE;
1863 TH1D *
h1 =
DoProject1D(
name, title, projAxis, &out1, &out2, computeErrors, originalRange,
true,
true);
1891 bool computeErrors,
bool originalRange,
1892 bool useUF,
bool useOF)
const
1901 Int_t nx = ixmax-ixmin+1;
1907 Error(
"DoProject1D",
"Histogram with name %s must be a TH1D and is a %s",
name,h1obj->
ClassName());
1914 if ( originalRange )
1916 if (bins->
fN == 0) {
1922 if (bins->
fN == 0) {
1932 if ( originalRange )
1934 if (bins->
fN == 0) {
1940 if (bins->
fN == 0) {
1970 if (out1 ==
nullptr && out2 ==
nullptr) {
1982 R__ASSERT(out1 !=
nullptr && out2 !=
nullptr);
1984 Int_t *refX =
nullptr, *refY =
nullptr, *refZ =
nullptr;
1985 Int_t ixbin, out1bin, out2bin;
2001 R__ASSERT (refX !=
nullptr && refY !=
nullptr && refZ !=
nullptr);
2023 for (ixbin=0;ixbin<=1+projX->
GetNbins();ixbin++) {
2030 for (out1bin = out1min; out1bin <= out1max; out1bin++) {
2031 for (out2bin = out2min; out2bin <= out2max; out2bin++) {
2037 if (computeErrors) {
2056 bool resetStats =
true;
2057 double eps = 1.E-12;
2061 bool resetEntries = resetStats;
2063 resetEntries |= !useUF || !useOF;
2070 stats[2] = stats[4];
2071 stats[3] = stats[5];
2074 stats[2] = stats[7];
2075 stats[3] = stats[8];
2104 bool computeErrors,
bool originalRange,
2105 bool useUF,
bool useOF)
const
2115 Int_t nx = ixmax-ixmin+1;
2116 Int_t ny = iymax-iymin+1;
2124 Error(
"DoProject2D",
"Histogram with name %s must be a TH2D and is a %s",
name,h2obj->
ClassName());
2132 if ( originalRange ) {
2139 h2->GetYaxis()->Set(projX->
GetNbins(),&xbins->fArray[ixmin-1]);
2144 h2->GetXaxis()->Set(ny,&ybins->
fArray[iymin-1]);
2146 h2->GetYaxis()->Set(nx,&xbins->fArray[ixmin-1]);
2154 if ( originalRange )
2156 if (xbins->fN == 0 && ybins->
fN == 0) {
2159 }
else if (ybins->
fN == 0) {
2161 ,projX->
GetNbins(),&xbins->fArray[ixmin-1]);
2162 }
else if (xbins->fN == 0) {
2169 if (xbins->fN == 0 && ybins->
fN == 0) {
2172 }
else if (ybins->
fN == 0) {
2174 ,nx,&xbins->fArray[ixmin-1]);
2175 }
else if (xbins->fN == 0) {
2179 h2 =
new TH2D(
name,title,ny,&ybins->
fArray[iymin-1],nx,&xbins->fArray[ixmin-1]);
2188 h2->GetXaxis()->ImportAttributes(projY);
2189 h2->GetYaxis()->ImportAttributes(projX);
2197 h2->GetXaxis()->SetBinLabel(i,lb->
String().
Data());
2206 h2->GetYaxis()->SetBinLabel(i,lb->
String().
Data());
2216 if ( computeErrors && (h2->GetSumw2N() != h2->GetNcells()) ) h2->Sumw2();
2219 const TAxis* out =
nullptr;
2228 Int_t *refX =
nullptr, *refY =
nullptr, *refZ =
nullptr;
2229 Int_t ixbin, iybin, outbin;
2230 if ( projX ==
GetXaxis() && projY ==
GetYaxis() ) { refX = &ixbin; refY = &iybin; refZ = &outbin; }
2231 if ( projX ==
GetYaxis() && projY ==
GetXaxis() ) { refX = &iybin; refY = &ixbin; refZ = &outbin; }
2232 if ( projX ==
GetXaxis() && projY ==
GetZaxis() ) { refX = &ixbin; refY = &outbin; refZ = &iybin; }
2233 if ( projX ==
GetZaxis() && projY ==
GetXaxis() ) { refX = &iybin; refY = &outbin; refZ = &ixbin; }
2234 if ( projX ==
GetYaxis() && projY ==
GetZaxis() ) { refX = &outbin; refY = &ixbin; refZ = &iybin; }
2235 if ( projX ==
GetZaxis() && projY ==
GetYaxis() ) { refX = &outbin; refY = &iybin; refZ = &ixbin; }
2236 R__ASSERT (refX !=
nullptr && refY !=
nullptr && refZ !=
nullptr);
2242 Int_t outmin = out->GetFirst();
2243 Int_t outmax = out->GetLast();
2245 if (outmin == 0 && outmax == 0) { outmin = 1; outmax = out->GetNbins(); }
2250 for (ixbin=0;ixbin<=1+projX->
GetNbins();ixbin++) {
2254 for (iybin=0;iybin<=1+projY->
GetNbins();iybin++) {
2262 for (outbin = outmin; outbin <= outmax; outbin++) {
2268 if (computeErrors) {
2276 h2->SetBinContent(iy , ix, cont);
2277 if (computeErrors) h2->SetBinError(iy, ix,
TMath::Sqrt(err2) );
2286 bool resetStats =
true;
2287 double eps = 1.E-12;
2291 bool resetEntries = resetStats;
2293 resetEntries |= !useUF || !useOF;
2298 for (
Int_t i = 0; i <
kNstat; ++i) { oldst[i] = 0; }
2300 std::copy(oldst,oldst+
kNstat,stats);
2304 stats[4] = oldst[7];
2305 stats[5] = oldst[8];
2306 stats[6] = oldst[9];
2309 stats[2] = oldst[4];
2310 stats[3] = oldst[5];
2312 stats[4] = oldst[2];
2313 stats[5] = oldst[3];
2316 stats[4] = oldst[7];
2317 stats[5] = oldst[8];
2318 stats[6] = oldst[10];
2322 stats[2] = oldst[7];
2323 stats[3] = oldst[8];
2325 stats[4] = oldst[2];
2326 stats[5] = oldst[3];
2327 stats[6] = oldst[9];
2330 stats[4] = oldst[4];
2331 stats[5] = oldst[5];
2332 stats[6] = oldst[10];
2336 h2->PutStats(stats);
2346 Double_t entries = h2->GetEffectiveEntries();
2347 if (!computeErrors) entries =
TMath::Floor( entries + 0.5);
2348 h2->SetEntries( entries );
2413 Int_t underscore = extra_name.
Last(
'_');
2414 if (underscore > 0) {
2415 extra_name.
Remove(underscore,extra_name.
Length()-underscore);
2416 opt.
Remove(0,underscore+1);
2422 if (opt.
Contains(
"x")) { pcase = 1; ptype =
"x"; }
2423 if (opt.
Contains(
"y")) { pcase = 2; ptype =
"y"; }
2424 if (opt.
Contains(
"z")) { pcase = 3; ptype =
"z"; }
2425 if (opt.
Contains(
"xy")) { pcase = 4; ptype =
"xy"; }
2426 if (opt.
Contains(
"yx")) { pcase = 5; ptype =
"yx"; }
2427 if (opt.
Contains(
"xz")) { pcase = 6; ptype =
"xz"; }
2428 if (opt.
Contains(
"zx")) { pcase = 7; ptype =
"zx"; }
2429 if (opt.
Contains(
"yz")) { pcase = 8; ptype =
"yz"; }
2430 if (opt.
Contains(
"zy")) { pcase = 9; ptype =
"zy"; }
2433 Error(
"Project3D",
"No projection axis specified - return a NULL pointer");
2440 computeErrors =
kTRUE;
2457 originalRange =
kTRUE;
2467 if (underscore > 0) {
2472 title +=
" "; title += ptype; title +=
" projection";
2478 computeErrors, originalRange, useUF, useOF);
2484 computeErrors, originalRange, useUF, useOF);
2490 computeErrors, originalRange, useUF, useOF);
2496 computeErrors, originalRange, useUF, useOF);
2502 computeErrors, originalRange, useUF, useOF);
2508 computeErrors, originalRange, useUF, useOF);
2514 computeErrors, originalRange, useUF, useOF);
2520 computeErrors, originalRange, useUF, useOF);
2526 computeErrors, originalRange, useUF, useOF);
2557 if (useWeights && binSumw2.
fN <= 0) useWeights =
false;
2564 if (outBin <0)
return;
2566 if ( useWeights ) tmp = binSumw2.
fArray[outBin];
2567 p2->
Fill( u ,
v,
w, cont);
2577 bool originalRange,
bool useUF,
bool useOF)
const
2585 Int_t nx = ixmax-ixmin+1;
2586 Int_t ny = iymax-iymin+1;
2596 Error(
"DoProjectProfile2D",
"Histogram with name %s must be a TProfile2D and is a %s",
name,p2obj->
ClassName());
2604 if ( originalRange ) {
2625 if ( originalRange ) {
2626 if (xbins->fN == 0 && ybins->
fN == 0) {
2629 }
else if (ybins->
fN == 0) {
2631 ,projX->
GetNbins(),&xbins->fArray[ixmin-1]);
2632 }
else if (xbins->fN == 0) {
2639 if (xbins->fN == 0 && ybins->
fN == 0) {
2642 }
else if (ybins->
fN == 0) {
2644 ,nx,&xbins->fArray[ixmin-1]);
2645 }
else if (xbins->fN == 0) {
2679 const TAxis* outAxis =
nullptr;
2694 Int_t *refX =
nullptr, *refY =
nullptr, *refZ =
nullptr;
2695 Int_t ixbin, iybin, outbin;
2696 if ( projX ==
GetXaxis() && projY ==
GetYaxis() ) { refX = &ixbin; refY = &iybin; refZ = &outbin; }
2697 if ( projX ==
GetYaxis() && projY ==
GetXaxis() ) { refX = &iybin; refY = &ixbin; refZ = &outbin; }
2698 if ( projX ==
GetXaxis() && projY ==
GetZaxis() ) { refX = &ixbin; refY = &outbin; refZ = &iybin; }
2699 if ( projX ==
GetZaxis() && projY ==
GetXaxis() ) { refX = &iybin; refY = &outbin; refZ = &ixbin; }
2700 if ( projX ==
GetYaxis() && projY ==
GetZaxis() ) { refX = &outbin; refY = &ixbin; refZ = &iybin; }
2701 if ( projX ==
GetZaxis() && projY ==
GetYaxis() ) { refX = &outbin; refY = &iybin; refZ = &ixbin; }
2702 R__ASSERT (refX !=
nullptr && refY !=
nullptr && refZ !=
nullptr);
2712 if (useWeights && binSumw2.
fN <= 0) useWeights =
false;
2716 for (ixbin=0;ixbin<=1+projX->
GetNbins();ixbin++) {
2718 for ( iybin=0;iybin<=1+projY->
GetNbins();iybin++) {
2723 if (poutBin <0)
continue;
2725 for (outbin = outmin; outbin <= outmax; outbin++) {
2732 if (!cont)
continue;
2736 if ( useWeights ) tmp = binSumw2.
fArray[poutBin];
2746 bool resetStats =
true;
2757 if (!useWeights) entries =
TMath::Floor( entries + 0.5);
2811 if (opt.
Contains(
"xy")) { pcase = 4; ptype =
"xy"; }
2812 if (opt.
Contains(
"yx")) { pcase = 5; ptype =
"yx"; }
2813 if (opt.
Contains(
"xz")) { pcase = 6; ptype =
"xz"; }
2814 if (opt.
Contains(
"zx")) { pcase = 7; ptype =
"zx"; }
2815 if (opt.
Contains(
"yz")) { pcase = 8; ptype =
"yz"; }
2816 if (opt.
Contains(
"zy")) { pcase = 9; ptype =
"zy"; }
2819 Error(
"Project3D",
"No projection axis specified - return a NULL pointer");
2837 originalRange =
kTRUE;
2846 title +=
" profile "; title += ptype; title +=
" projection";
2908 return Rebin3D(ngroup, 1, 1, newname);
2918 return Rebin3D(1, ngroup, 1, newname);
2928 return Rebin3D(1, 1, ngroup, newname);
2959 Int_t i,j,k,xbin,ybin,zbin;
2969 if ((nxgroup <= 0) || (nxgroup > nxbins)) {
2970 Error(
"Rebin",
"Illegal value of nxgroup=%d",nxgroup);
2973 if ((nygroup <= 0) || (nygroup > nybins)) {
2974 Error(
"Rebin",
"Illegal value of nygroup=%d",nygroup);
2977 if ((nzgroup <= 0) || (nzgroup > nzbins)) {
2978 Error(
"Rebin",
"Illegal value of nzgroup=%d",nzgroup);
2982 Int_t newxbins = nxbins/nxgroup;
2983 Int_t newybins = nybins/nygroup;
2984 Int_t newzbins = nzbins/nzgroup;
3002 if (newname && strlen(newname)) {
3010 bool resetStat =
false;
3014 if (newxbins*nxgroup != nxbins) {
3018 if (newybins*nygroup != nybins) {
3022 if (newzbins*nzgroup != nzbins) {
3064 if (nxgroup != 1 || nygroup != 1 || nzgroup != 1) {
3073 hnew->
SetBins(newxbins,xbins, newybins, ybins, newzbins, zbins);
3086 for (xbin = 1; xbin <= newxbins; xbin++) {
3089 for (ybin = 1; ybin <= newybins; ybin++) {
3091 for (zbin = 1; zbin <= newzbins; zbin++) {
3094 for (i = 0; i < nxgroup; i++) {
3095 if (oldxbin+i > nxbins)
break;
3096 for (j =0; j < nygroup; j++) {
3097 if (oldybin+j > nybins)
break;
3098 for (k =0; k < nzgroup; k++) {
3099 if (oldzbin+k > nzbins)
break;
3101 bin = oldxbin + i + (oldybin + j)*(nxbins + 2) + (oldzbin + k)*(nxbins + 2)*(nybins + 2);
3102 binContent += oldBins[bin];
3103 if (oldSumw2) binSumw2 += oldSumw2[bin];
3118 for (
Int_t xover = 0; xover <= 1; xover++) {
3119 for (
Int_t yover = 0; yover <= 1; yover++) {
3120 for (
Int_t zover = 0; zover <= 1; zover++) {
3124 for (xbin = xover*oldxbin; xbin <= xover*(nxbins+1); xbin++) {
3125 for (ybin = yover*oldybin; ybin <= yover*(nybins+1); ybin++) {
3126 for (zbin = zover*oldzbin; zbin <= zover*(nzbins+1); zbin++) {
3127 bin =
GetBin(xbin,ybin,zbin);
3128 binContent += oldBins[bin];
3129 if (oldSumw2) binSumw2 += oldSumw2[bin];
3134 yover*(newybins+1), zover*(newzbins+1) );
3141 Double_t binContent0, binContent2, binContent3, binContent4;
3142 Double_t binError0, binError2, binError3, binError4;
3143 Int_t oldxbin2, oldybin2, oldzbin2;
3144 Int_t ufbin, ofbin, ofbin2, ofbin3, ofbin4;
3150 for (xbin = 1; xbin<=newxbins; xbin++) {
3152 for (zbin = 1; zbin<=newzbins; zbin++) {
3153 binContent0 = binContent2 = 0;
3154 binError0 = binError2 = 0;
3155 for (i=0; i<nxgroup; i++) {
3156 if (oldxbin2+i > nxbins)
break;
3157 for (k=0; k<nzgroup; k++) {
3158 if (oldzbin2+k > nzbins)
break;
3160 ufbin = oldxbin2 + i + (nxbins+2)*(nybins+2)*(oldzbin2+k);
3161 binContent0 += oldBins[ufbin];
3162 if (oldSumw2) binError0 += oldSumw2[ufbin];
3163 for (ybin = oldybin; ybin <= nybins + 1; ybin++) {
3165 ofbin = ufbin + ybin*(nxbins+2);
3166 binContent2 += oldBins[ofbin];
3167 if (oldSumw2) binError2 += oldSumw2[ofbin];
3177 oldzbin2 += nzgroup;
3179 oldxbin2 += nxgroup;
3186 for (ybin = 1; ybin<=newybins; ybin++) {
3188 for (zbin = 1; zbin<=newzbins; zbin++) {
3189 binContent0 = binContent2 = 0;
3190 binError0 = binError2 = 0;
3191 for (j=0; j<nygroup; j++) {
3192 if (oldybin2+j > nybins)
break;
3193 for (k=0; k<nzgroup; k++) {
3194 if (oldzbin2+k > nzbins)
break;
3196 ufbin = (oldybin2 + j)*(nxbins+2) + (nxbins+2)*(nybins+2)*(oldzbin2+k);
3197 binContent0 += oldBins[ufbin];
3198 if (oldSumw2) binError0 += oldSumw2[ufbin];
3199 for (xbin = oldxbin; xbin <= nxbins + 1; xbin++) {
3201 ofbin = ufbin + xbin;
3202 binContent2 += oldBins[ofbin];
3203 if (oldSumw2) binError2 += oldSumw2[ofbin];
3213 oldzbin2 += nzgroup;
3215 oldybin2 += nygroup;
3222 for (xbin = 1; xbin<=newxbins; xbin++) {
3224 for (ybin = 1; ybin<=newybins; ybin++) {
3225 binContent0 = binContent2 = 0;
3226 binError0 = binError2 = 0;
3227 for (i=0; i<nxgroup; i++) {
3228 if (oldxbin2+i > nxbins)
break;
3229 for (j=0; j<nygroup; j++) {
3230 if (oldybin2+j > nybins)
break;
3232 ufbin = oldxbin2 + i + (nxbins+2)*(oldybin2+j);
3233 binContent0 += oldBins[ufbin];
3234 if (oldSumw2) binError0 += oldSumw2[ufbin];
3235 for (zbin = oldzbin; zbin <= nzbins + 1; zbin++) {
3237 ofbin = ufbin + (nxbins+2)*(nybins+2)*zbin;
3238 binContent2 += oldBins[ofbin];
3239 if (oldSumw2) binError2 += oldSumw2[ofbin];
3249 oldybin2 += nygroup;
3251 oldxbin2 += nxgroup;
3258 for (xbin = 1; xbin<=newxbins; xbin++) {
3267 for (i=0; i<nxgroup; i++) {
3268 if (oldxbin2+i > nxbins)
break;
3269 ufbin = oldxbin2 + i;
3270 binContent0 += oldBins[ufbin];
3271 if (oldSumw2) binError0 += oldSumw2[ufbin];
3272 for (ybin = oldybin; ybin <= nybins + 1; ybin++) {
3273 ofbin3 = ufbin+ybin*(nxbins+2);
3274 binContent3 += oldBins[ ofbin3 ];
3275 if (oldSumw2) binError3 += oldSumw2[ofbin3];
3276 for (zbin = oldzbin; zbin <= nzbins + 1; zbin++) {
3278 ofbin4 = oldxbin2 + i + ybin*(nxbins+2) + (nxbins+2)*(nybins+2)*zbin;
3279 binContent4 += oldBins[ofbin4];
3280 if (oldSumw2) binError4 += oldSumw2[ofbin4];
3283 for (zbin = oldzbin; zbin <= nzbins + 1; zbin++) {
3284 ofbin2 = ufbin+zbin*(nxbins+2)*(nybins+2);
3285 binContent2 += oldBins[ ofbin2 ];
3286 if (oldSumw2) binError2 += oldSumw2[ofbin2];
3292 hnew->
SetBinContent(xbin,newybins+1,newzbins+1,binContent4);
3299 oldxbin2 += nxgroup;
3306 for (zbin = 1; zbin<=newzbins; zbin++) {
3315 for (i=0; i<nzgroup; i++) {
3316 if (oldzbin2+i > nzbins)
break;
3317 ufbin = (oldzbin2 + i)*(nxbins+2)*(nybins+2);
3318 binContent0 += oldBins[ufbin];
3319 if (oldSumw2) binError0 += oldSumw2[ufbin];
3320 for (ybin = oldybin; ybin <= nybins + 1; ybin++) {
3321 ofbin3 = ufbin+ybin*(nxbins+2);
3322 binContent3 += oldBins[ ofbin3 ];
3323 if (oldSumw2) binError3 += oldSumw2[ofbin3];
3324 for (xbin = oldxbin; xbin <= nxbins + 1; xbin++) {
3326 ofbin4 = ufbin + xbin + ybin*(nxbins+2);
3327 binContent4 += oldBins[ofbin4];
3328 if (oldSumw2) binError4 += oldSumw2[ofbin4];
3331 for (xbin = oldxbin; xbin <= nxbins + 1; xbin++) {
3332 ofbin2 = xbin +(oldzbin2+i)*(nxbins+2)*(nybins+2);
3333 binContent2 += oldBins[ ofbin2 ];
3334 if (oldSumw2) binError2 += oldSumw2[ofbin2];
3340 hnew->
SetBinContent(newxbins+1,newybins+1,zbin,binContent4);
3347 oldzbin2 += nzgroup;
3354 for (ybin = 1; ybin<=newybins; ybin++) {
3363 for (i=0; i<nygroup; i++) {
3364 if (oldybin2+i > nybins)
break;
3365 ufbin = (oldybin2 + i)*(nxbins+2);
3366 binContent0 += oldBins[ufbin];
3367 if (oldSumw2) binError0 += oldSumw2[ufbin];
3368 for (xbin = oldxbin; xbin <= nxbins + 1; xbin++) {
3369 ofbin3 = ufbin+xbin;
3370 binContent3 += oldBins[ ofbin3 ];
3371 if (oldSumw2) binError3 += oldSumw2[ofbin3];
3372 for (zbin = oldzbin; zbin <= nzbins + 1; zbin++) {
3374 ofbin4 = xbin + (nxbins+2)*(nybins+2)*zbin+(oldybin2+i)*(nxbins+2);
3375 binContent4 += oldBins[ofbin4];
3376 if (oldSumw2) binError4 += oldSumw2[ofbin4];
3379 for (zbin = oldzbin; zbin <= nzbins + 1; zbin++) {
3380 ofbin2 = (oldybin2+i)*(nxbins+2)+zbin*(nxbins+2)*(nybins+2);
3381 binContent2 += oldBins[ ofbin2 ];
3382 if (oldSumw2) binError2 += oldSumw2[ofbin2];
3388 hnew->
SetBinContent(newxbins+1,ybin,newzbins+1,binContent4);
3395 oldybin2 += nygroup;
3438 if (!resetStat) hnew->
PutStats(stat);
3441 if (oldSumw2)
delete [] oldSumw2;
3472 if (bin < 0)
return;
3505 bool originalRange,
bool useUF,
bool useOF)
3507 return h.DoProject1D(
name, title, projX,
nullptr,
nullptr, computeErrors, originalRange, useUF, useOF);
3514 bool computeErrors,
bool originalRange,
bool useUF,
bool useOF)
3516 return h.DoProject2D(
name, title, projX, projY, computeErrors, originalRange, useUF, useOF);
3552 :
TH3(
name,title,nbinsx,xlow,xup,nbinsy,ylow,yup,nbinsz,zlow,zup)
3568 :
TH3(
name,title,nbinsx,xbins,nbinsy,ybins,nbinsz,zbins)
3582 :
TH3(
name,title,nbinsx,xbins,nbinsy,ybins,nbinsz,zbins)
3595 h3c.TH3C::Copy(*
this);
3617 if (newval > -128 && newval < 128) {
fArray[bin] =
Char_t(newval);
return;}
3618 if (newval < -127)
fArray[bin] = -127;
3619 if (newval > 127)
fArray[bin] = 127;
3723 h3c.TH3C::Copy(*
this);
3821 :
TH3(
name,title,nbinsx,xlow,xup,nbinsy,ylow,yup,nbinsz,zlow,zup)
3837 :
TH3(
name,title,nbinsx,xbins,nbinsy,ybins,nbinsz,zbins)
3851 :
TH3(
name,title,nbinsx,xbins,nbinsy,ybins,nbinsz,zbins)
3864 h3s.TH3S::Copy(*
this);
3886 if (newval > -32768 && newval < 32768) {
fArray[bin] =
Short_t(newval);
return;}
3887 if (newval < -32767)
fArray[bin] = -32767;
3888 if (newval > 32767)
fArray[bin] = 32767;
3963 h3s.TH3S::Copy(*
this);
4061 :
TH3(
name,title,nbinsx,xlow,xup,nbinsy,ylow,yup,nbinsz,zlow,zup)
4077 :
TH3(
name,title,nbinsx,xbins,nbinsy,ybins,nbinsz,zbins)
4091 :
TH3(
name,title,nbinsx,xbins,nbinsy,ybins,nbinsz,zbins)
4104 h3i.TH3I::Copy(*
this);
4126 if (newval > -INT_MAX && newval < INT_MAX) {
fArray[bin] =
Int_t(newval);
return;}
4127 if (newval < -INT_MAX)
fArray[bin] = -INT_MAX;
4128 if (newval > INT_MAX)
fArray[bin] = INT_MAX;
4170 h3i.TH3I::Copy(*
this);
4268 :
TH3(
name,title,nbinsx,xlow,xup,nbinsy,ylow,yup,nbinsz,zlow,zup)
4284 :
TH3(
name,title,nbinsx,xbins,nbinsy,ybins,nbinsz,zbins)
4298 :
TH3(
name,title,nbinsx,xbins,nbinsy,ybins,nbinsz,zbins)
4311 h3l.TH3L::Copy(*
this);
4333 if (newval > -LLONG_MAX && newval < LLONG_MAX) {
fArray[bin] =
Int_t(newval);
return;}
4334 if (newval < -LLONG_MAX)
fArray[bin] = -LLONG_MAX;
4335 if (newval > LLONG_MAX)
fArray[bin] = LLONG_MAX;
4377 h3l.TH3L::Copy(*
this);
4475 :
TH3(
name,title,nbinsx,xlow,xup,nbinsy,ylow,yup,nbinsz,zlow,zup)
4491 :
TH3(
name,title,nbinsx,xbins,nbinsy,ybins,nbinsz,zbins)
4505 :
TH3(
name,title,nbinsx,xbins,nbinsy,ybins,nbinsz,zbins)
4518 h3f.TH3F::Copy(*
this);
4593 h3f.TH3F::Copy(*
this);
4691 :
TH3(
name,title,nbinsx,xlow,xup,nbinsy,ylow,yup,nbinsz,zlow,zup)
4707 :
TH3(
name,title,nbinsx,xbins,nbinsy,ybins,nbinsz,zbins)
4721 :
TH3(
name,title,nbinsx,xbins,nbinsy,ybins,nbinsz,zbins)