24 Bool_t TProfile3D::fgApproximate = kFALSE;
77 TProfile3D::TProfile3D() : TH3D()
79 fTsumwt = fTsumwt2 = 0;
87 TProfile3D::~TProfile3D()
114 TProfile3D::TProfile3D(
const char *name,
const char *title,Int_t nx,Double_t xlow,Double_t xup,Int_t ny,Double_t ylow,Double_t yup,Int_t nz, Double_t zlow,Double_t zup,Option_t *option)
115 : TH3D(name,title,nx,xlow,xup,ny,ylow,yup,nz,zlow,zup)
117 BuildOptions(0,0,option);
118 if (xlow >= xup || ylow >= yup || zlow >= zup) SetBuffer(fgBufferSize);
124 TProfile3D::TProfile3D(
const char *name,
const char *title,Int_t nx,
const Double_t *xbins,Int_t ny,
const Double_t *ybins,Int_t nz,
const Double_t *zbins,Option_t *option)
125 : TH3D(name,title,nx,xbins,ny,ybins,nz,zbins)
127 BuildOptions(0,0,option);
142 void TProfile3D::BuildOptions(Double_t tmin, Double_t tmax, Option_t *option)
144 SetErrorOption(option);
147 TProfileHelper::BuildArray(
this);
152 fTsumwt = fTsumwt2 = 0;
158 TProfile3D::TProfile3D(
const TProfile3D &profile) : TH3D()
160 ((TProfile3D&)profile).Copy(*
this);
163 TProfile3D &TProfile3D::operator=(
const TProfile3D &profile)
165 ((TProfile3D &)profile).Copy(*
this);
172 Bool_t TProfile3D::Add(TF1 *, Double_t , Option_t*)
174 Error(
"Add",
"Function not implemented for TProfile3D");
181 Bool_t TProfile3D::Add(
const TH1 *h1, Double_t c1)
184 Error(
"Add",
"Attempt to add a non-existing profile");
187 if (!h1->InheritsFrom(TProfile3D::Class())) {
188 Error(
"Add",
"Attempt to add a non-profile2D object");
192 return TProfileHelper::Add(
this,
this, h1, 1, c1);
200 Bool_t TProfile3D::Add(
const TH1 *h1,
const TH1 *h2, Double_t c1, Double_t c2)
203 Error(
"Add",
"Attempt to add a non-existing profile");
206 if (!h1->InheritsFrom(TProfile3D::Class())) {
207 Error(
"Add",
"Attempt to add a non-profile3D object");
210 if (!h2->InheritsFrom(TProfile3D::Class())) {
211 Error(
"Add",
"Attempt to add a non-profile3D object");
215 return TProfileHelper::Add(
this, h1, h2, c1, c2);
231 void TProfile3D::Approximate(Bool_t approx)
233 fgApproximate = approx;
246 Int_t TProfile3D::BufferEmpty(Int_t action)
249 if (!fBuffer)
return 0;
250 Int_t nbentries = (Int_t)fBuffer[0];
251 if (!nbentries)
return 0;
252 Double_t *buffer = fBuffer;
254 if (action == 0)
return 0;
255 nbentries = -nbentries;
260 if (CanExtendAllAxes() || fXaxis.GetXmax() <= fXaxis.GetXmin() || fYaxis.GetXmax() <= fYaxis.GetXmin()) {
262 Double_t xmin = fBuffer[2];
263 Double_t xmax = xmin;
264 Double_t ymin = fBuffer[3];
265 Double_t ymax = ymin;
266 Double_t zmin = fBuffer[4];
267 Double_t zmax = zmin;
268 for (Int_t i=1;i<nbentries;i++) {
269 Double_t x = fBuffer[5*i+2];
270 if (x < xmin) xmin = x;
271 if (x > xmax) xmax = x;
272 Double_t y = fBuffer[5*i+3];
273 if (y < ymin) ymin = y;
274 if (y > ymax) ymax = y;
275 Double_t z = fBuffer[5*i+4];
276 if (z < zmin) zmin = z;
277 if (z > zmax) zmax = z;
279 if (fXaxis.GetXmax() <= fXaxis.GetXmin() || fYaxis.GetXmax() <= fYaxis.GetXmin() || fZaxis.GetXmax() <= fZaxis.GetXmin()) {
280 THLimitsFinder::GetLimitsFinder()->FindGoodLimits(
this,xmin,xmax,ymin,ymax,zmin,zmax);
283 Int_t keep = fBufferSize; fBufferSize = 0;
284 if (xmin < fXaxis.GetXmin()) ExtendAxis(xmin,&fXaxis);
285 if (xmax >= fXaxis.GetXmax()) ExtendAxis(xmax,&fXaxis);
286 if (ymin < fYaxis.GetXmin()) ExtendAxis(ymin,&fYaxis);
287 if (ymax >= fYaxis.GetXmax()) ExtendAxis(ymax,&fYaxis);
288 if (zmin < fZaxis.GetXmin()) ExtendAxis(zmin,&fZaxis);
289 if (zmax >= fZaxis.GetXmax()) ExtendAxis(zmax,&fZaxis);
296 for (Int_t i=0;i<nbentries;i++) {
297 Fill(buffer[5*i+2],buffer[5*i+3],buffer[5*i+4],buffer[5*i+5],buffer[5*i+1]);
301 if (action > 0) {
delete [] fBuffer; fBuffer = 0; fBufferSize = 0;}
303 if (nbentries == (Int_t)fEntries) fBuffer[0] = -nbentries;
321 Int_t TProfile3D::BufferFill(Double_t x, Double_t y, Double_t z, Double_t t, Double_t w)
323 if (!fBuffer)
return -3;
324 Int_t nbentries = (Int_t)fBuffer[0];
326 nbentries = -nbentries;
327 fBuffer[0] = nbentries;
329 Double_t *buffer = fBuffer; fBuffer=0;
334 if (5*nbentries+5 >= fBufferSize) {
336 return Fill(x,y,z,t,w);
338 fBuffer[5*nbentries+1] = w;
339 fBuffer[5*nbentries+2] = x;
340 fBuffer[5*nbentries+3] = y;
341 fBuffer[5*nbentries+4] = z;
342 fBuffer[5*nbentries+5] = t;
350 void TProfile3D::Copy(TObject &obj)
const
353 TProfile3D & pobj =
dynamic_cast<TProfile3D&
>(obj);
356 fBinEntries.Copy(pobj.fBinEntries);
357 fBinSumw2.Copy(pobj.fBinSumw2);
358 for (
int bin=0;bin<fNcells;bin++) {
359 pobj.fArray[bin] = fArray[bin];
360 pobj.fSumw2.fArray[bin] = fSumw2.fArray[bin];
364 pobj.fScaling = fScaling;
365 pobj.fErrorMode = fErrorMode;
366 pobj.fTsumwt = fTsumwt;
367 pobj.fTsumwt2 = fTsumwt2;
370 Fatal(
"Copy",
"Cannot copy a TProfile3D in a %s",obj.IsA()->GetName());
379 Bool_t TProfile3D::Divide(TF1 *, Double_t )
381 Error(
"Divide",
"Function not implemented for TProfile3D");
392 Bool_t TProfile3D::Divide(
const TH1 *h1)
395 Error(
"Divide",
"Attempt to divide a non-existing profile2D");
398 if (!h1->InheritsFrom(TProfile3D::Class())) {
399 Error(
"Divide",
"Attempt to divide a non-profile3D object");
402 TProfile3D *p1 = (TProfile3D*)h1;
405 if (fBuffer) BufferEmpty(1);
408 Int_t nx = GetNbinsX();
409 if (nx != p1->GetNbinsX()) {
410 Error(
"Divide",
"Attempt to divide profiles with different number of bins");
413 Int_t ny = GetNbinsY();
414 if (ny != p1->GetNbinsY()) {
415 Error(
"Divide",
"Attempt to divide profiles with different number of bins");
418 Int_t nz = GetNbinsZ();
419 if (nz != p1->GetNbinsZ()) {
420 Error(
"Divide",
"Attempt to divide profiles with different number of bins");
425 fEntries = fTsumw = fTsumw2 = fTsumwx = fTsumwx2 = 0;
428 Int_t bin,binx,biny,binz;
429 Double_t *cu1 = p1->GetW();
430 Double_t *er1 = p1->GetW2();
431 Double_t *en1 = p1->GetB();
432 Double_t c0,c1,w,u,x,y,z;
433 for (binx =0;binx<=nx+1;binx++) {
434 for (biny =0;biny<=ny+1;biny++) {
435 for (binz =0;binz<=nz+1;binz++) {
436 bin = GetBin(binx,biny,binz);
443 x = fXaxis.GetBinCenter(binx);
444 y = fYaxis.GetBinCenter(biny);
445 z = fZaxis.GetBinCenter(binz);
460 Double_t e0 = fSumw2.fArray[bin];
461 Double_t e1 = er1[bin];
463 if (!c1) fSumw2.fArray[bin] = 0;
464 else fSumw2.fArray[bin] = (e0*c1*c1 + e1*c0*c0)/(c12*c12);
465 if (!en1[bin]) fBinEntries.fArray[bin] = 0;
466 else fBinEntries.fArray[bin] /= en1[bin];
473 Warning(
"Divide",
"Cannot preserve during the division of profiles the sum of bin weight square");
474 fBinSumw2 = TArrayD();
486 Bool_t TProfile3D::Divide(
const TH1 *h1,
const TH1 *h2, Double_t c1, Double_t c2, Option_t *option)
488 TString opt = option;
490 Bool_t binomial = kFALSE;
491 if (opt.Contains(
"b")) binomial = kTRUE;
493 Error(
"Divide",
"Attempt to divide a non-existing profile2D");
496 if (!h1->InheritsFrom(TProfile3D::Class())) {
497 Error(
"Divide",
"Attempt to divide a non-profile2D object");
500 TProfile3D *p1 = (TProfile3D*)h1;
501 if (!h2->InheritsFrom(TProfile3D::Class())) {
502 Error(
"Divide",
"Attempt to divide a non-profile2D object");
505 TProfile3D *p2 = (TProfile3D*)h2;
508 Int_t nx = GetNbinsX();
509 if (nx != p1->GetNbinsX() || nx != p2->GetNbinsX()) {
510 Error(
"Divide",
"Attempt to divide profiles with different number of bins");
513 Int_t ny = GetNbinsY();
514 if (ny != p1->GetNbinsY() || ny != p2->GetNbinsY()) {
515 Error(
"Divide",
"Attempt to divide profiles with different number of bins");
518 Int_t nz = GetNbinsZ();
519 if (nz != p1->GetNbinsZ() || nz != p2->GetNbinsZ()) {
520 Error(
"Divide",
"Attempt to divide profiles with different number of bins");
524 Error(
"Divide",
"Coefficient of dividing profile cannot be zero");
529 fEntries = fTsumw = fTsumw2 = fTsumwx = fTsumwx2 = 0;
532 Int_t bin,binx,biny,binz;
533 Double_t *cu1 = p1->GetW();
534 Double_t *cu2 = p2->GetW();
535 Double_t *er1 = p1->GetW2();
536 Double_t *er2 = p2->GetW2();
537 Double_t *en1 = p1->GetB();
538 Double_t *en2 = p2->GetB();
539 Double_t b1,b2,w,u,x,y,z,ac1,ac2;
540 ac1 = TMath::Abs(c1);
541 ac2 = TMath::Abs(c2);
542 for (binx =0;binx<=nx+1;binx++) {
543 for (biny =0;biny<=ny+1;biny++) {
544 for (binz =0;binz<=nz+1;binz++) {
545 bin = GetBin(binx,biny,binz);
548 if (b2) w = c1*b1/(c2*b2);
552 x = fXaxis.GetBinCenter(binx);
553 y = fYaxis.GetBinCenter(biny);
554 z = fZaxis.GetBinCenter(biny);
569 Double_t e1 = er1[bin];
570 Double_t e2 = er2[bin];
572 Double_t b22= b2*b2*TMath::Abs(c2);
573 if (!b2) fSumw2.fArray[bin] = 0;
576 fSumw2.fArray[bin] = TMath::Abs(w*(1-w)/(c2*b2));
578 fSumw2.fArray[bin] = ac1*ac2*(e1*b2*b2 + e2*b1*b1)/(b22*b22);
581 if (!en2[bin]) fBinEntries.fArray[bin] = 0;
582 else fBinEntries.fArray[bin] = en1[bin]/en2[bin];
592 Int_t TProfile3D::Fill(Double_t x, Double_t y, Double_t z, Double_t t)
594 if (fBuffer)
return BufferFill(x,y,z,t,1);
596 Int_t bin,binx,biny,binz;
598 if (fTmin != fTmax) {
599 if (t <fTmin || t> fTmax || TMath::IsNaN(t) )
return -1;
603 binx =fXaxis.FindBin(x);
604 biny =fYaxis.FindBin(y);
605 binz =fZaxis.FindBin(z);
606 if (binx <0 || biny <0 || binz<0)
return -1;
607 bin = GetBin(binx,biny,binz);
608 AddBinContent(bin, t);
609 fSumw2.fArray[bin] += (Double_t)t*t;
610 fBinEntries.fArray[bin] += 1;
611 if (fBinSumw2.fN) fBinSumw2.fArray[bin] += 1;
612 if (binx == 0 || binx > fXaxis.GetNbins()) {
613 if (!GetStatOverflowsBehaviour())
return -1;
615 if (biny == 0 || biny > fYaxis.GetNbins()) {
616 if (!GetStatOverflowsBehaviour())
return -1;
618 if (binz == 0 || binz > fZaxis.GetNbins()) {
619 if (!GetStatOverflowsBehaviour())
return -1;
641 Int_t TProfile3D::Fill(Double_t x, Double_t y, Double_t z, Double_t t, Double_t w)
643 if (fBuffer)
return BufferFill(x,y,z,t,w);
645 Int_t bin,binx,biny,binz;
647 if (fTmin != fTmax) {
648 if (t <fTmin || t> fTmax || TMath::IsNaN(t) )
return -1;
653 binx =fXaxis.FindBin(x);
654 biny =fYaxis.FindBin(y);
655 binz =fZaxis.FindBin(z);
656 if (binx <0 || biny <0 || binz<0)
return -1;
657 bin = GetBin(binx,biny,binz);
658 AddBinContent(bin, u*t);
659 fSumw2.fArray[bin] += u*t*t;
660 if (!fBinSumw2.fN && u != 1.0 && !TestBit(TH1::kIsNotW)) Sumw2();
661 if (fBinSumw2.fN) fBinSumw2.fArray[bin] += u*u;
662 fBinEntries.fArray[bin] += u;
663 if (binx == 0 || binx > fXaxis.GetNbins()) {
664 if (!GetStatOverflowsBehaviour())
return -1;
666 if (biny == 0 || biny > fYaxis.GetNbins()) {
667 if (!GetStatOverflowsBehaviour())
return -1;
669 if (binz == 0 || binz > fZaxis.GetNbins()) {
670 if (!GetStatOverflowsBehaviour())
return -1;
691 Double_t TProfile3D::GetBinContent(Int_t bin)
const
693 if (fBuffer) ((TProfile3D*)
this)->BufferEmpty();
695 if (bin < 0 || bin >= fNcells)
return 0;
696 if (fBinEntries.fArray[bin] == 0)
return 0;
697 if (!fArray)
return 0;
698 return fArray[bin]/fBinEntries.fArray[bin];
704 Double_t TProfile3D::GetBinEntries(Int_t bin)
const
706 if (fBuffer) ((TProfile3D*)
this)->BufferEmpty();
708 if (bin < 0 || bin >= fNcells)
return 0;
709 return fBinEntries.fArray[bin];
721 Double_t TProfile3D::GetBinEffectiveEntries(Int_t bin)
723 return TProfileHelper::GetBinEffectiveEntries((TProfile3D*)
this, bin);
745 Double_t TProfile3D::GetBinError(Int_t bin)
const
747 return TProfileHelper::GetBinError((TProfile3D*)
this, bin);
753 Option_t *TProfile3D::GetErrorOption()
const
755 if (fErrorMode == kERRORSPREAD)
return "s";
756 if (fErrorMode == kERRORSPREADI)
return "i";
757 if (fErrorMode == kERRORSPREADG)
return "g";
785 void TProfile3D::GetStats(Double_t *stats)
const
787 if (fBuffer) ((TProfile3D*)
this)->BufferEmpty();
790 if (fTsumw == 0 || fXaxis.TestBit(TAxis::kAxisRange) || fYaxis.TestBit(TAxis::kAxisRange)) {
791 Int_t bin, binx, biny,binz;
794 for (bin=0;bin<kNstat;bin++) stats[bin] = 0;
795 if (!fBinEntries.fArray)
return;
796 for (binz=fZaxis.GetFirst();binz<=fZaxis.GetLast();binz++) {
797 z = fZaxis.GetBinCenter(binz);
798 for (biny=fYaxis.GetFirst();biny<=fYaxis.GetLast();biny++) {
799 y = fYaxis.GetBinCenter(biny);
800 for (binx=fXaxis.GetFirst();binx<=fXaxis.GetLast();binx++) {
801 bin = GetBin(binx,biny,binz);
802 w = fBinEntries.fArray[bin];
803 w2 = (fBinSumw2.fN ? fBinSumw2.fArray[bin] : w );
804 x = fXaxis.GetBinCenter(binx);
816 stats[11] += fArray[bin];
817 stats[12] += fSumw2.fArray[bin];
832 stats[10] = fTsumwyz;
834 stats[12] = fTsumwt2;
853 Long64_t TProfile3D::Merge(TCollection *li)
855 return TProfileHelper::Merge(
this, li);
861 Bool_t TProfile3D::Multiply(TF1 *, Double_t )
863 Error(
"Multiply",
"Function not implemented for TProfile3D");
872 Bool_t TProfile3D::Multiply(
const TH1 *)
874 Error(
"Multiply",
"Multiplication of profile2D histograms not implemented");
883 Bool_t TProfile3D::Multiply(
const TH1 *,
const TH1 *, Double_t, Double_t, Option_t *)
885 Error(
"Multiply",
"Multiplication of profile2D histograms not implemented");
920 TH3D *TProfile3D::ProjectionXYZ(
const char *name, Option_t *option)
const
923 TString opt = option;
925 Int_t nx = fXaxis.GetNbins();
926 Int_t ny = fYaxis.GetNbins();
927 Int_t nz = fZaxis.GetNbins();
928 const TArrayD *xbins = fXaxis.GetXbins();
929 const TArrayD *ybins = fYaxis.GetXbins();
930 const TArrayD *zbins = fZaxis.GetXbins();
933 TString pname = name;
934 if (pname ==
"_px") {
935 pname = GetName(); pname.Append(
"_pxyz");
938 if (xbins->fN == 0 && ybins->fN == 0 && zbins->fN == 0)
939 h1 =
new TH3D(pname,GetTitle(),nx,fXaxis.GetXmin(),fXaxis.GetXmax(),ny,fYaxis.GetXmin(),fYaxis.GetXmax(),nz,fZaxis.GetXmin(),fZaxis.GetXmax());
940 else if ( xbins->fN != 0 && ybins->fN != 0 && zbins->fN != 0)
941 h1 =
new TH3D(pname,GetTitle(),nx,xbins->GetArray(),ny,ybins->GetArray(), nz,zbins->GetArray() );
943 Error(
"ProjectionXYZ",
"Histogram has an axis with variable bins and an axis with fixed bins. This case is not supported - return a null pointer");
948 Bool_t computeErrors = kFALSE;
949 Bool_t cequalErrors = kFALSE;
950 Bool_t binEntries = kFALSE;
951 Bool_t binWeight = kFALSE;
953 if (opt.Contains(
"b")) binEntries = kTRUE;
954 if (opt.Contains(
"e")) computeErrors = kTRUE;
955 if (opt.Contains(
"w")) binWeight = kTRUE;
956 if (opt.Contains(
"c=e")) {cequalErrors = kTRUE; computeErrors=kFALSE;}
957 if (computeErrors || binWeight || (binEntries && fBinSumw2.fN) ) h1->Sumw2();
960 Int_t bin,binx,biny,binz;
962 for (binx =0;binx<=nx+1;binx++) {
963 for (biny =0;biny<=ny+1;biny++) {
964 for (binz =0;binz<=nz+1;binz++) {
965 bin = GetBin(binx,biny,binz);
967 if (binEntries) cont = GetBinEntries(bin);
968 else if (cequalErrors) cont = GetBinError(bin);
969 else if (binWeight) cont = GetBinContent(bin) * GetBinEntries(bin);
970 else cont = GetBinContent(bin);
972 h1->SetBinContent(bin ,cont);
975 if (computeErrors ) h1->SetBinError(bin , GetBinError(bin) );
978 if (binWeight) h1->GetSumw2()->fArray[bin] = fSumw2.fArray[bin];
980 if (binEntries && fBinSumw2.fN ) {
981 R__ASSERT( h1->GetSumw2() );
982 h1->GetSumw2()->fArray[bin] = fBinSumw2.fArray[bin];
987 h1->SetEntries(fEntries);
1013 TProfile2D *TProfile3D::Project3DProfile(Option_t *option)
const
1017 TString opt(option);
1018 opt.Append(
" UF OF");
1019 return TH3::Project3DProfile(opt);
1028 TProfile2D *TProfile3D::DoProjectProfile2D(
const char* name,
const char * title,
const TAxis* projX,
const TAxis* projY,
1029 bool originalRange,
bool useUF,
bool useOF)
const
1032 Int_t ixmin = projX->GetFirst();
1033 Int_t ixmax = projX->GetLast();
1034 Int_t iymin = projY->GetFirst();
1035 Int_t iymax = projY->GetLast();
1036 if (ixmin == 0 && ixmax == 0) { ixmin = 1; ixmax = projX->GetNbins(); }
1037 if (iymin == 0 && iymax == 0) { iymin = 1; iymax = projY->GetNbins(); }
1038 Int_t nx = ixmax-ixmin+1;
1039 Int_t ny = iymax-iymin+1;
1045 const TArrayD *xbins = projX->GetXbins();
1046 const TArrayD *ybins = projY->GetXbins();
1048 if ( originalRange ) {
1049 if (xbins->fN == 0 && ybins->fN == 0) {
1050 p2 =
new TProfile2D(name,title,projY->GetNbins(),projY->GetXmin(),projY->GetXmax()
1051 ,projX->GetNbins(),projX->GetXmin(),projX->GetXmax());
1053 p2 =
new TProfile2D(name,title,projY->GetNbins(),&ybins->fArray[iymin-1],projX->GetNbins(),&xbins->fArray[ixmin-1]);
1056 if (xbins->fN == 0 && ybins->fN == 0) {
1057 p2 =
new TProfile2D(name,title,ny,projY->GetBinLowEdge(iymin),projY->GetBinUpEdge(iymax)
1058 ,nx,projX->GetBinLowEdge(ixmin),projX->GetBinUpEdge(ixmax));
1060 p2 =
new TProfile2D(name,title,ny,&ybins->fArray[iymin-1],nx,&xbins->fArray[ixmin-1]);
1065 bool useWeights = (fBinSumw2.fN != 0);
1066 if (useWeights) p2->Sumw2();
1069 TH3D * h3dW = ProjectionXYZ(
"h3temp-W",
"W");
1070 TH3D * h3dN = ProjectionXYZ(
"h3temp-N",
"B");
1072 h3dW->SetDirectory(0); h3dN->SetDirectory(0);
1078 if (fXaxis.TestBit(TAxis::kAxisRange) ) {
1079 h3dW->GetXaxis()->SetRange(fXaxis.GetFirst(),fXaxis.GetLast());
1080 h3dN->GetXaxis()->SetRange(fXaxis.GetFirst(),fXaxis.GetLast());
1082 if (fYaxis.TestBit(TAxis::kAxisRange) ) {
1083 h3dW->GetYaxis()->SetRange(fYaxis.GetFirst(),fYaxis.GetLast());
1084 h3dN->GetYaxis()->SetRange(fYaxis.GetFirst(),fYaxis.GetLast());
1086 if (fZaxis.TestBit(TAxis::kAxisRange) ) {
1087 h3dW->GetZaxis()->SetRange(fZaxis.GetFirst(),fZaxis.GetLast());
1088 h3dN->GetZaxis()->SetRange(fZaxis.GetFirst(),fZaxis.GetLast());
1092 TAxis * projX_hW = h3dW->GetXaxis();
1093 TAxis * projX_hN = h3dN->GetXaxis();
1094 if (projX == GetYaxis() ) { projX_hW = h3dW->GetYaxis(); projX_hN = h3dN->GetYaxis(); }
1095 if (projX == GetZaxis() ) { projX_hW = h3dW->GetZaxis(); projX_hN = h3dN->GetZaxis(); }
1096 TAxis * projY_hW = h3dW->GetYaxis();
1097 TAxis * projY_hN = h3dN->GetYaxis();
1098 if (projY == GetXaxis() ) { projY_hW = h3dW->GetXaxis(); projY_hN = h3dN->GetXaxis(); }
1099 if (projY == GetZaxis() ) { projY_hW = h3dW->GetZaxis(); projY_hN = h3dN->GetZaxis(); }
1101 TH2D * h2W = TH3::DoProject2D(*h3dW,
"htemp-W",
"",projX_hW, projY_hW,
true, originalRange, useUF, useOF);
1102 TH2D * h2N = TH3::DoProject2D(*h3dN,
"htemp-N",
"",projX_hN, projY_hN, useWeights, originalRange, useUF, useOF);
1103 h2W->SetDirectory(0); h2N->SetDirectory(0);
1107 R__ASSERT( h2W->fN == p2->fN );
1108 R__ASSERT( h2N->fN == p2->fN );
1109 R__ASSERT( h2W->GetSumw2()->fN != 0);
1110 for (
int i = 0; i < p2->fN ; ++i) {
1112 p2->fArray[i] = h2W->fArray[i];
1113 p2->GetSumw2()->fArray[i] = h2W->GetSumw2()->fArray[i];
1114 p2->SetBinEntries(i, h2N->fArray[i] );
1115 if (useWeights) p2->GetBinSumw2()->fArray[i] = h2N->GetSumw2()->fArray[i];
1125 p2->SetEntries( p2->GetEffectiveEntries() );
1134 void TProfile3D::PutStats(Double_t *stats)
1136 TH3::PutStats(stats);
1137 fTsumwt = stats[11];
1138 fTsumwt2 = stats[12];
1144 void TProfile3D::Reset(Option_t *option)
1146 TH3D::Reset(option);
1148 fBinEntries.Reset();
1149 TString opt = option;
1151 if (opt.Contains(
"ICE") && !opt.Contains(
"S"))
return;
1152 fTsumwt = fTsumwt2 = 0;
1165 void TProfile3D::ExtendAxis(Double_t x, TAxis *axis)
1167 TProfile3D* hold = TProfileHelper::ExtendAxis(
this, x, axis);
1169 fTsumwt = hold->fTsumwt;
1170 fTsumwt2 = hold->fTsumwt2;
1182 void TProfile3D::SavePrimitive(std::ostream &out, Option_t *option )
1185 out <<
" "<<std::endl;
1186 out <<
" "<<ClassName()<<
" *";
1188 out << GetName() <<
" = new " << ClassName() <<
"(" << quote
1189 << GetName() << quote <<
"," << quote<< GetTitle() << quote
1190 <<
"," << GetXaxis()->GetNbins();
1191 out <<
"," << GetXaxis()->GetXmin()
1192 <<
"," << GetXaxis()->GetXmax();
1193 out <<
"," << GetYaxis()->GetNbins();
1194 out <<
"," << GetYaxis()->GetXmin()
1195 <<
"," << GetYaxis()->GetXmax();
1196 out <<
"," << GetZaxis()->GetNbins();
1197 out <<
"," << GetZaxis()->GetXmin()
1198 <<
"," << GetZaxis()->GetXmax();
1201 out <<
");" << std::endl;
1206 for (bin=0;bin<fNcells;bin++) {
1207 Double_t bi = GetBinEntries(bin);
1209 out<<
" "<<GetName()<<
"->SetBinEntries("<<bin<<
","<<bi<<
");"<<std::endl;
1213 for (bin=0;bin<fNcells;bin++) {
1214 Double_t bc = fArray[bin];
1216 out<<
" "<<GetName()<<
"->SetBinContent("<<bin<<
","<<bc<<
");"<<std::endl;
1221 for (bin=0;bin<fNcells;bin++) {
1222 Double_t be = TMath::Sqrt(fSumw2.fArray[bin]);
1224 out<<
" "<<GetName()<<
"->SetBinError("<<bin<<
","<<be<<
");"<<std::endl;
1229 TH1::SavePrimitiveHelp(out, GetName(), option);
1239 void TProfile3D::Scale(Double_t c1, Option_t *option)
1241 TProfileHelper::Scale(
this, c1, option);
1247 void TProfile3D::SetBinEntries(Int_t bin, Double_t w)
1249 TProfileHelper::SetBinEntries(
this, bin, w);
1255 void TProfile3D::SetBins(Int_t nx, Double_t xmin, Double_t xmax, Int_t ny, Double_t ymin, Double_t ymax, Int_t nz, Double_t zmin, Double_t zmax)
1257 TH1::SetBins(nx, xmin, xmax, ny, ymin, ymax, nz, zmin, zmax);
1258 fBinEntries.Set(fNcells);
1259 if (fBinSumw2.fN) fBinSumw2.Set(fNcells);
1265 void TProfile3D::SetBins(Int_t nx,
const Double_t *xBins, Int_t ny,
const Double_t *yBins, Int_t nz,
const Double_t *zBins)
1267 TH1::SetBins(nx,xBins,ny,yBins,nz,zBins);
1268 fBinEntries.Set(fNcells);
1269 if (fBinSumw2.fN) fBinSumw2.Set(fNcells);
1277 void TProfile3D::SetBinsLength(Int_t n)
1279 TH3D::SetBinsLength(n);
1280 TProfileHelper::BuildArray(
this);
1286 void TProfile3D::SetBuffer(Int_t buffersize, Option_t *)
1293 if (buffersize <= 0) {
1297 if (buffersize < 100) buffersize = 100;
1298 fBufferSize = 1 + 5*buffersize;
1299 fBuffer =
new Double_t[fBufferSize];
1300 memset(fBuffer,0,
sizeof(Double_t)*fBufferSize);
1324 void TProfile3D::SetErrorOption(Option_t *option)
1326 TProfileHelper::SetErrorOption(
this, option);
1338 void TProfile3D::Sumw2(Bool_t flag)
1340 TProfileHelper::Sumw2(
this, flag);