00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "TProfile.h"
00013 #include "TMath.h"
00014 #include "TF1.h"
00015 #include "THLimitsFinder.h"
00016 #include "Riostream.h"
00017 #include "TVirtualPad.h"
00018 #include "TError.h"
00019 #include "TClass.h"
00020
00021 #include "TProfileHelper.h"
00022
00023 Bool_t TProfile::fgApproximate = kFALSE;
00024
00025 ClassImp(TProfile)
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073 TProfile::TProfile() : TH1D()
00074 {
00075
00076
00077
00078 BuildOptions(0,0,"");
00079 }
00080
00081
00082 TProfile::~TProfile()
00083 {
00084
00085
00086
00087 }
00088
00089
00090 TProfile::TProfile(const char *name,const char *title,Int_t nbins,Double_t xlow,Double_t xup,Option_t *option)
00091 : TH1D(name,title,nbins,xlow,xup)
00092 {
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115 BuildOptions(0,0,option);
00116 }
00117
00118
00119 TProfile::TProfile(const char *name,const char *title,Int_t nbins,const Float_t *xbins,Option_t *option)
00120 : TH1D(name,title,nbins,xbins)
00121 {
00122
00123
00124
00125
00126
00127
00128
00129 BuildOptions(0,0,option);
00130 }
00131
00132
00133 TProfile::TProfile(const char *name,const char *title,Int_t nbins,const Double_t *xbins,Option_t *option)
00134 : TH1D(name,title,nbins,xbins)
00135 {
00136
00137
00138
00139
00140
00141
00142
00143 BuildOptions(0,0,option);
00144 }
00145
00146
00147 TProfile::TProfile(const char *name,const char *title,Int_t nbins,const Double_t *xbins,Double_t ylow,Double_t yup,Option_t *option)
00148 : TH1D(name,title,nbins,xbins)
00149 {
00150
00151
00152
00153
00154
00155
00156
00157 BuildOptions(ylow,yup,option);
00158 }
00159
00160
00161 TProfile::TProfile(const char *name,const char *title,Int_t nbins,Double_t xlow,Double_t xup,Double_t ylow,Double_t yup,Option_t *option)
00162 : TH1D(name,title,nbins,xlow,xup)
00163 {
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175 BuildOptions(ylow,yup,option);
00176 }
00177
00178
00179
00180 void TProfile::BuildOptions(Double_t ymin, Double_t ymax, Option_t *option)
00181 {
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228 SetErrorOption(option);
00229
00230 fBinEntries.Set(fNcells);
00231
00232
00233 TH1::Sumw2();
00234
00235 if (fgDefaultSumw2) Sumw2();
00236
00237 fYmin = ymin;
00238 fYmax = ymax;
00239 fScaling = kFALSE;
00240 fTsumwy = fTsumwy2 = 0;
00241
00242 }
00243
00244
00245 TProfile::TProfile(const TProfile &profile) : TH1D()
00246 {
00247
00248
00249 ((TProfile&)profile).Copy(*this);
00250 }
00251
00252
00253
00254 void TProfile::Add(TF1 *, Double_t, Option_t * )
00255 {
00256
00257
00258 Error("Add","Function not implemented for TProfile");
00259 return;
00260 }
00261
00262
00263
00264 void TProfile::Add(const TH1 *h1, Double_t c1)
00265 {
00266
00267
00268 if (!h1) {
00269 Error("Add","Attempt to add a non-existing profile");
00270 return;
00271 }
00272 if (!h1->InheritsFrom(TProfile::Class())) {
00273 Error("Add","Attempt to add a non-profile object");
00274 return;
00275 }
00276
00277 TProfileHelper::Add(this, this, h1, 1, c1);
00278 }
00279
00280
00281 void TProfile::Add(const TH1 *h1, const TH1 *h2, Double_t c1, Double_t c2)
00282 {
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292 if (!h1 || !h2) {
00293 Error("Add","Attempt to add a non-existing profile");
00294 return;
00295 }
00296 if (!h1->InheritsFrom(TProfile::Class())) {
00297 Error("Add","Attempt to add a non-profile object");
00298 return;
00299 }
00300 if (!h2->InheritsFrom(TProfile::Class())) {
00301 Error("Add","Attempt to add a non-profile object");
00302 return;
00303 }
00304 TProfileHelper::Add(this, h1, h2, c1, c2);
00305 }
00306
00307
00308
00309 void TProfile::Approximate(Bool_t approx)
00310 {
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320 fgApproximate = approx;
00321 }
00322
00323
00324 Int_t TProfile::BufferEmpty(Int_t action)
00325 {
00326
00327
00328
00329
00330
00331
00332
00333
00334 if (!fBuffer) return 0;
00335 Int_t nbentries = (Int_t)fBuffer[0];
00336 if (!nbentries) return 0;
00337 Double_t *buffer = fBuffer;
00338 if (nbentries < 0) {
00339 if (action == 0) return 0;
00340 nbentries = -nbentries;
00341 fBuffer=0;
00342 Reset();
00343 fBuffer = buffer;
00344 }
00345 if (TestBit(kCanRebin) || fXaxis.GetXmax() <= fXaxis.GetXmin()) {
00346
00347 Double_t xmin = fBuffer[2];
00348 Double_t xmax = xmin;
00349 for (Int_t i=1;i<nbentries;i++) {
00350 Double_t x = fBuffer[3*i+2];
00351 if (x < xmin) xmin = x;
00352 if (x > xmax) xmax = x;
00353 }
00354 if (fXaxis.GetXmax() <= fXaxis.GetXmin()) {
00355 THLimitsFinder::GetLimitsFinder()->FindGoodLimits(this,xmin,xmax);
00356 } else {
00357 fBuffer = 0;
00358 Int_t keep = fBufferSize; fBufferSize = 0;
00359 if (xmin < fXaxis.GetXmin()) RebinAxis(xmin,&fXaxis);
00360 if (xmax >= fXaxis.GetXmax()) RebinAxis(xmax,&fXaxis);
00361 fBuffer = buffer;
00362 fBufferSize = keep;
00363 }
00364 }
00365
00366 fBuffer = 0;
00367
00368 for (Int_t i=0;i<nbentries;i++) {
00369 Fill(buffer[3*i+2],buffer[3*i+3],buffer[3*i+1]);
00370 }
00371 fBuffer = buffer;
00372
00373 if (action > 0) { delete [] fBuffer; fBuffer = 0; fBufferSize = 0;}
00374 else {
00375 if (nbentries == (Int_t)fEntries) fBuffer[0] = -nbentries;
00376 else fBuffer[0] = 0;
00377 }
00378 return nbentries;
00379 }
00380
00381
00382 Int_t TProfile::BufferFill(Double_t x, Double_t y, Double_t w)
00383 {
00384
00385
00386
00387
00388
00389
00390 if (!fBuffer) return -2;
00391 Int_t nbentries = (Int_t)fBuffer[0];
00392 if (nbentries < 0) {
00393 nbentries = -nbentries;
00394 fBuffer[0] = nbentries;
00395 if (fEntries > 0) {
00396 Double_t *buffer = fBuffer; fBuffer=0;
00397 Reset();
00398 fBuffer = buffer;
00399 }
00400 }
00401 if (3*nbentries+3 >= fBufferSize) {
00402 BufferEmpty(1);
00403 return Fill(x,y,w);
00404 }
00405 fBuffer[3*nbentries+1] = w;
00406 fBuffer[3*nbentries+2] = x;
00407 fBuffer[3*nbentries+3] = y;
00408 fBuffer[0] += 1;
00409 return -2;
00410 }
00411
00412
00413 void TProfile::Copy(TObject &obj) const
00414 {
00415
00416
00417
00418 TH1D::Copy(((TProfile&)obj));
00419 fBinEntries.Copy(((TProfile&)obj).fBinEntries);
00420 fBinSumw2.Copy(((TProfile&)obj).fBinSumw2);
00421 for (int bin=0;bin<fNcells;bin++) {
00422 ((TProfile&)obj).fArray[bin] = fArray[bin];
00423 ((TProfile&)obj).fSumw2.fArray[bin] = fSumw2.fArray[bin];
00424 }
00425
00426 ((TProfile&)obj).fYmin = fYmin;
00427 ((TProfile&)obj).fYmax = fYmax;
00428 ((TProfile&)obj).fScaling = fScaling;
00429 ((TProfile&)obj).fErrorMode = fErrorMode;
00430 ((TProfile&)obj).fTsumwy = fTsumwy;
00431 ((TProfile&)obj).fTsumwy2 = fTsumwy2;
00432 }
00433
00434
00435
00436 void TProfile::Divide(TF1 *, Double_t )
00437 {
00438
00439
00440 Error("Divide","Function not implemented for TProfile");
00441 return;
00442 }
00443
00444
00445 void TProfile::Divide(const TH1 *h1)
00446 {
00447
00448
00449
00450
00451
00452
00453
00454 if (!h1) {
00455 Error("Divide","Attempt to divide a non-existing profile");
00456 return;
00457 }
00458 if (!h1->InheritsFrom(TH1::Class())) {
00459 Error("Divide","Attempt to divide by a non-profile or non-histogram object");
00460 return;
00461 }
00462 TProfile *p1 = (TProfile*)h1;
00463
00464 Int_t nbinsx = GetNbinsX();
00465
00466 if (nbinsx != p1->GetNbinsX()) {
00467 Error("Divide","Attempt to divide profiles with different number of bins");
00468 return;
00469 }
00470
00471
00472 fEntries = fTsumw = fTsumw2 = fTsumwx = fTsumwx2 = fTsumwy = fTsumwy2 = 0;
00473
00474
00475 Int_t bin;
00476 Double_t *cu1=0, *er1=0, *en1=0;
00477 Double_t e0,e1,c12;
00478 if (h1->InheritsFrom(TProfile::Class())) {
00479 cu1 = p1->GetW();
00480 er1 = p1->GetW2();
00481 en1 = p1->GetB();
00482 }
00483 Double_t c0,c1,w,z,x;
00484 for (bin=0;bin<=nbinsx+1;bin++) {
00485 c0 = fArray[bin];
00486 if (cu1) c1 = cu1[bin];
00487 else c1 = h1->GetBinContent(bin);
00488 if (c1) w = c0/c1;
00489 else w = 0;
00490 fArray[bin] = w;
00491 z = TMath::Abs(w);
00492 x = fXaxis.GetBinCenter(bin);
00493 fEntries++;
00494 fTsumw += z;
00495 fTsumw2 += z*z;
00496 fTsumwx += z*x;
00497 fTsumwx2 += z*x*x;
00498 fTsumwy += z*c1;
00499 fTsumwx2 += z*c1*c1;
00500 e0 = fSumw2.fArray[bin];
00501 if (er1) e1 = er1[bin];
00502 else {e1 = h1->GetBinError(bin); e1*=e1;}
00503 c12= c1*c1;
00504 if (!c1) fSumw2.fArray[bin] = 0;
00505 else fSumw2.fArray[bin] = (e0*c1*c1 + e1*c0*c0)/(c12*c12);
00506 if (!en1) continue;
00507 if (!en1[bin]) fBinEntries.fArray[bin] = 0;
00508 else fBinEntries.fArray[bin] /= en1[bin];
00509 }
00510
00511
00512 if (fBinSumw2.fN) {
00513 Warning("Divide","Cannot preserve during the division of profiles the sum of bin weight square");
00514 fBinSumw2 = TArrayD();
00515 }
00516
00517 }
00518
00519
00520
00521 void TProfile::Divide(const TH1 *h1, const TH1 *h2, Double_t c1, Double_t c2, Option_t *option)
00522 {
00523
00524
00525
00526
00527
00528
00529 TString opt = option;
00530 opt.ToLower();
00531 Bool_t binomial = kFALSE;
00532 if (opt.Contains("b")) binomial = kTRUE;
00533 if (!h1 || !h2) {
00534 Error("Divide","Attempt to divide a non-existing profile");
00535 return;
00536 }
00537 if (!h1->InheritsFrom(TProfile::Class())) {
00538 Error("Divide","Attempt to divide a non-profile object");
00539 return;
00540 }
00541 TProfile *p1 = (TProfile*)h1;
00542 if (!h2->InheritsFrom(TProfile::Class())) {
00543 Error("Divide","Attempt to divide by a non-profile object");
00544 return;
00545 }
00546 TProfile *p2 = (TProfile*)h2;
00547
00548 Int_t nbinsx = GetNbinsX();
00549
00550 if (nbinsx != p1->GetNbinsX() || nbinsx != p2->GetNbinsX()) {
00551 Error("Divide","Attempt to divide profiles with different number of bins");
00552 return;
00553 }
00554 if (!c2) {
00555 Error("Divide","Coefficient of dividing profile cannot be zero");
00556 return;
00557 }
00558
00559
00560 printf("WARNING!!: The algorithm in TProfile::Divide computing the errors is not accurate\n");
00561 printf(" Instead of Divide(TProfile *h1, TProfile *h2, do:\n");
00562 printf(" TH1D *p1 = h1->ProjectionX();\n");
00563 printf(" TH1D *p2 = h2->ProjectionX();\n");
00564 printf(" p1->Divide(p2);\n");
00565
00566
00567 fEntries = fTsumw = fTsumw2 = fTsumwx = fTsumwx2 = 0;
00568
00569
00570 Int_t bin;
00571 Double_t *cu1 = p1->GetW();
00572 Double_t *cu2 = p2->GetW();
00573 Double_t *er1 = p1->GetW2();
00574 Double_t *er2 = p2->GetW2();
00575 Double_t *en1 = p1->GetB();
00576 Double_t *en2 = p2->GetB();
00577 Double_t b1,b2,w,z,x,ac1,ac2;
00578
00579
00580 ac1 = TMath::Abs(c1);
00581 ac2 = TMath::Abs(c2);
00582 for (bin=0;bin<=nbinsx+1;bin++) {
00583 b1 = cu1[bin];
00584 b2 = cu2[bin];
00585 if (b2) w = c1*b1/(c2*b2);
00586 else w = 0;
00587 fArray[bin] = w;
00588 z = TMath::Abs(w);
00589 x = fXaxis.GetBinCenter(bin);
00590 fEntries++;
00591 fTsumw += z;
00592 fTsumw2 += z*z;
00593 fTsumwx += z*x;
00594 fTsumwx2 += z*x*x;
00595
00596
00597 Double_t e1 = er1[bin];
00598 Double_t e2 = er2[bin];
00599
00600 Double_t b22= b2*b2*TMath::Abs(c2);
00601 if (!b2) fSumw2.fArray[bin] = 0;
00602 else {
00603 if (binomial) {
00604 fSumw2.fArray[bin] = TMath::Abs(w*(1-w)/b2);
00605 } else {
00606
00607 fSumw2.fArray[bin] = ac1*ac2*(e1*b2*b2 + e2*b1*b1)/(b22*b22);
00608 }
00609 }
00610 if (en2[bin]) fBinEntries.fArray[bin] = en1[bin]/en2[bin];
00611 else fBinEntries.fArray[bin] = 0;
00612 }
00613
00614
00615
00616 if (fBinSumw2.fN) {
00617 Warning("Divide","Cannot preserve during the division of profiles the sum of bin weight square");
00618 fBinSumw2 = TArrayD();
00619 }
00620
00621 }
00622
00623
00624 TH1 *TProfile::DrawCopy(Option_t *option) const
00625 {
00626
00627
00628 TString opt = option;
00629 opt.ToLower();
00630 if (gPad && !opt.Contains("same")) gPad->Clear();
00631 TProfile *newpf = (TProfile*)Clone();
00632 newpf->SetDirectory(0);
00633 newpf->SetBit(kCanDelete);
00634 newpf->AppendPad(option);
00635 return newpf;
00636 }
00637
00638
00639 Int_t TProfile::Fill(Double_t x, Double_t y)
00640 {
00641
00642
00643
00644 if (fBuffer) return BufferFill(x,y,1);
00645
00646 Int_t bin;
00647 if (fYmin != fYmax) {
00648 if (y <fYmin || y> fYmax) return -1;
00649 }
00650
00651 fEntries++;
00652 bin =fXaxis.FindBin(x);
00653 AddBinContent(bin, y);
00654 fSumw2.fArray[bin] += (Double_t)y*y;
00655 fBinEntries.fArray[bin] += 1;
00656 if (fBinSumw2.fN) fBinSumw2.fArray[bin] += 1;
00657 if (bin == 0 || bin > fXaxis.GetNbins()) {
00658 if (!fgStatOverflows) return -1;
00659 }
00660 fTsumw++;
00661 fTsumw2++;
00662 fTsumwx += x;
00663 fTsumwx2 += x*x;
00664 fTsumwy += y;
00665 fTsumwy2 += y*y;
00666 return bin;
00667 }
00668
00669
00670 Int_t TProfile::Fill(const char *namex, Double_t y)
00671 {
00672
00673
00674 Int_t bin;
00675 if (fYmin != fYmax) {
00676 if (y <fYmin || y> fYmax) return -1;
00677 }
00678
00679 fEntries++;
00680 bin =fXaxis.FindBin(namex);
00681 AddBinContent(bin, y);
00682 fSumw2.fArray[bin] += (Double_t)y*y;
00683 fBinEntries.fArray[bin] += 1;
00684 if (fBinSumw2.fN) fBinSumw2.fArray[bin] += 1;
00685 if (bin == 0 || bin > fXaxis.GetNbins()) {
00686 if (!fgStatOverflows) return -1;
00687 }
00688 Double_t x = fXaxis.GetBinCenter(bin);
00689 fTsumw++;
00690 fTsumw2++;
00691 fTsumwx += x;
00692 fTsumwx2 += x*x;
00693 fTsumwy += y;
00694 fTsumwy2 += y*y;
00695 return bin;
00696 }
00697
00698
00699 Int_t TProfile::Fill(Double_t x, Double_t y, Double_t w)
00700 {
00701
00702
00703
00704 if (fBuffer) return BufferFill(x,y,w);
00705
00706 Int_t bin;
00707 if (fYmin != fYmax) {
00708 if (y <fYmin || y> fYmax) return -1;
00709 }
00710
00711 Double_t u= (w > 0 ? w : -w);
00712 fEntries++;
00713 bin =fXaxis.FindBin(x);
00714 AddBinContent(bin, u*y);
00715 fSumw2.fArray[bin] += u*y*y;
00716 fBinEntries.fArray[bin] += u;
00717 if (fBinSumw2.fN) fBinSumw2.fArray[bin] += u*u;
00718 if (bin == 0 || bin > fXaxis.GetNbins()) {
00719 if (!fgStatOverflows) return -1;
00720 }
00721 fTsumw += u;
00722 fTsumw2 += u*u;
00723 fTsumwx += u*x;
00724 fTsumwx2 += u*x*x;
00725 fTsumwy += u*y;
00726 fTsumwy2 += u*y*y;
00727 return bin;
00728 }
00729
00730
00731 Int_t TProfile::Fill(const char *namex, Double_t y, Double_t w)
00732 {
00733
00734
00735 Int_t bin;
00736
00737 if (fYmin != fYmax) {
00738 if (y <fYmin || y> fYmax) return -1;
00739 }
00740
00741 Double_t u= (w > 0 ? w : -w);
00742 fEntries++;
00743 bin =fXaxis.FindBin(namex);
00744 AddBinContent(bin, u*y);
00745 fSumw2.fArray[bin] += u*y*y;
00746 fBinEntries.fArray[bin] += u;
00747 if (fBinSumw2.fN) fBinSumw2.fArray[bin] += u*u;
00748 if (bin == 0 || bin > fXaxis.GetNbins()) {
00749 if (!fgStatOverflows) return -1;
00750 }
00751 Double_t x = fXaxis.GetBinCenter(bin);
00752 fTsumw += u;
00753 fTsumw2 += u*u;
00754 fTsumwx += u*x;
00755 fTsumwx2 += u*x*x;
00756 fTsumwy += u*y;
00757 fTsumwy2 += u*y*y;
00758 return bin;
00759 }
00760
00761
00762
00763 void TProfile::FillN(Int_t ntimes, const Double_t *x, const Double_t *y, const Double_t *w, Int_t stride)
00764 {
00765
00766
00767 Int_t bin,i;
00768 ntimes *= stride;
00769 for (i=0;i<ntimes;i+=stride) {
00770 if (fYmin != fYmax) {
00771 if (y[i] <fYmin || y[i]> fYmax) continue;
00772 }
00773
00774 Double_t u= (w[i] > 0 ? w[i] : -w[i]);
00775 fEntries++;
00776 bin =fXaxis.FindBin(x[i]);
00777 AddBinContent(bin, u*y[i]);
00778 fSumw2.fArray[bin] += u*y[i]*y[i];
00779 fBinEntries.fArray[bin] += u;
00780 if (fBinSumw2.fN) fBinSumw2.fArray[bin] += u*u;
00781 if (bin == 0 || bin > fXaxis.GetNbins()) {
00782 if (!fgStatOverflows) continue;
00783 }
00784 fTsumw += u;
00785 fTsumw2 += u*u;
00786 fTsumwx += u*x[i];
00787 fTsumwx2 += u*x[i]*x[i];
00788 fTsumwy += u*y[i];
00789 fTsumwy2 += u*y[i]*y[i];
00790 }
00791 }
00792
00793
00794 Double_t TProfile::GetBinContent(Int_t bin) const
00795 {
00796
00797
00798
00799 if (fBuffer) ((TProfile*)this)->BufferEmpty();
00800
00801 if (bin < 0 || bin >= fNcells) return 0;
00802 if (fBinEntries.fArray[bin] == 0) return 0;
00803 if (!fArray) return 0;
00804 return fArray[bin]/fBinEntries.fArray[bin];
00805 }
00806
00807
00808 Double_t TProfile::GetBinEntries(Int_t bin) const
00809 {
00810
00811
00812
00813 if (fBuffer) ((TProfile*)this)->BufferEmpty();
00814
00815 if (bin < 0 || bin >= fNcells) return 0;
00816 return fBinEntries.fArray[bin];
00817 }
00818
00819
00820 Double_t TProfile::GetBinEffectiveEntries(Int_t bin) const
00821 {
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831 return TProfileHelper::GetBinEffectiveEntries((TProfile*)this, bin);
00832 }
00833
00834
00835 Double_t TProfile::GetBinError(Int_t bin) const
00836 {
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866 return TProfileHelper::GetBinError((TProfile*)this, bin);
00867 }
00868
00869
00870 Option_t *TProfile::GetErrorOption() const
00871 {
00872
00873
00874
00875 if (fErrorMode == kERRORSPREAD) return "s";
00876 if (fErrorMode == kERRORSPREADI) return "i";
00877 if (fErrorMode == kERRORSPREADG) return "g";
00878 return "";
00879 }
00880
00881
00882 char* TProfile::GetObjectInfo(Int_t px, Int_t py) const
00883 {
00884
00885
00886
00887
00888 if (!gPad) return (char*)"";
00889 static char info[200];
00890 Double_t x = gPad->PadtoX(gPad->AbsPixeltoX(px));
00891 Double_t y = gPad->PadtoY(gPad->AbsPixeltoY(py));
00892 Int_t binx = GetXaxis()->FindFixBin(x);
00893 snprintf(info,200,"(x=%g, y=%g, binx=%d, binc=%g, bine=%g, binn=%d)", x, y, binx, GetBinContent(binx), GetBinError(binx), (Int_t)GetBinEntries(binx));
00894 return info;
00895 }
00896
00897
00898 void TProfile::GetStats(Double_t *stats) const
00899 {
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914 if (fBuffer) ((TProfile*)this)->BufferEmpty();
00915
00916
00917 Int_t bin, binx;
00918 if (fTsumw == 0 || fXaxis.TestBit(TAxis::kAxisRange)) {
00919 for (bin=0;bin<6;bin++) stats[bin] = 0;
00920 if (!fBinEntries.fArray) return;
00921 Int_t firstBinX = fXaxis.GetFirst();
00922 Int_t lastBinX = fXaxis.GetLast();
00923
00924 if (fgStatOverflows && !fXaxis.TestBit(TAxis::kAxisRange)) {
00925 if (firstBinX == 1) firstBinX = 0;
00926 if (lastBinX == fXaxis.GetNbins() ) lastBinX += 1;
00927 }
00928 for (binx = firstBinX; binx <= lastBinX; binx++) {
00929 Double_t w = fBinEntries.fArray[binx];
00930 Double_t w2 = (fBinSumw2.fN ? fBinSumw2.fArray[binx] : w);
00931 Double_t x = fXaxis.GetBinCenter(binx);
00932 stats[0] += w;
00933 stats[1] += w2;
00934 stats[2] += w*x;
00935 stats[3] += w*x*x;
00936 stats[4] += fArray[binx];
00937 stats[5] += fSumw2.fArray[binx];
00938 }
00939 } else {
00940 if (fTsumwy == 0 && fTsumwy2 == 0) {
00941
00942 TProfile *p = (TProfile*)this;
00943 for (binx=fXaxis.GetFirst();binx<=fXaxis.GetLast();binx++) {
00944 p->fTsumwy += fArray[binx];
00945 p->fTsumwy2 += fSumw2.fArray[binx];
00946 }
00947 }
00948 stats[0] = fTsumw;
00949 stats[1] = fTsumw2;
00950 stats[2] = fTsumwx;
00951 stats[3] = fTsumwx2;
00952 stats[4] = fTsumwy;
00953 stats[5] = fTsumwy2;
00954 }
00955 }
00956
00957
00958 void TProfile::LabelsDeflate(Option_t *option)
00959 {
00960
00961
00962 TProfileHelper::LabelsDeflate(this, option);
00963 }
00964
00965
00966 void TProfile::LabelsInflate(Option_t *options)
00967 {
00968
00969
00970
00971
00972 TProfileHelper::LabelsInflate(this, options);
00973 }
00974
00975
00976 void TProfile::LabelsOption(Option_t *option, Option_t * )
00977 {
00978
00979
00980
00981
00982
00983
00984
00985
00986
00987 THashList *labels = fXaxis.GetLabels();
00988 if (!labels) {
00989 Warning("LabelsOption","Cannot sort. No labels");
00990 return;
00991 }
00992 TString opt = option;
00993 opt.ToLower();
00994 if (opt.Contains("h")) {
00995 fXaxis.SetBit(TAxis::kLabelsHori);
00996 fXaxis.ResetBit(TAxis::kLabelsVert);
00997 fXaxis.ResetBit(TAxis::kLabelsDown);
00998 fXaxis.ResetBit(TAxis::kLabelsUp);
00999 }
01000 if (opt.Contains("v")) {
01001 fXaxis.SetBit(TAxis::kLabelsVert);
01002 fXaxis.ResetBit(TAxis::kLabelsHori);
01003 fXaxis.ResetBit(TAxis::kLabelsDown);
01004 fXaxis.ResetBit(TAxis::kLabelsUp);
01005 }
01006 if (opt.Contains("u")) {
01007 fXaxis.SetBit(TAxis::kLabelsUp);
01008 fXaxis.ResetBit(TAxis::kLabelsVert);
01009 fXaxis.ResetBit(TAxis::kLabelsDown);
01010 fXaxis.ResetBit(TAxis::kLabelsHori);
01011 }
01012 if (opt.Contains("d")) {
01013 fXaxis.SetBit(TAxis::kLabelsDown);
01014 fXaxis.ResetBit(TAxis::kLabelsVert);
01015 fXaxis.ResetBit(TAxis::kLabelsHori);
01016 fXaxis.ResetBit(TAxis::kLabelsUp);
01017 }
01018 Int_t sort = -1;
01019 if (opt.Contains("a")) sort = 0;
01020 if (opt.Contains(">")) sort = 1;
01021 if (opt.Contains("<")) sort = 2;
01022 if (sort < 0) return;
01023
01024 Int_t n = TMath::Min(fXaxis.GetNbins(), labels->GetSize());
01025 Int_t *a = new Int_t[n+2];
01026 Int_t i,j;
01027 Double_t *cont = new Double_t[n+2];
01028 Double_t *sumw = new Double_t[n+2];
01029 Double_t *errors = new Double_t[n+2];
01030 Double_t *ent = new Double_t[n+2];
01031 THashList *labold = new THashList(labels->GetSize(),1);
01032 TIter nextold(labels);
01033 TObject *obj;
01034 while ((obj=nextold())) {
01035 labold->Add(obj);
01036 }
01037 labels->Clear();
01038 if (sort > 0) {
01039
01040 for (i=1;i<=n;i++) {
01041 sumw[i-1] = fArray[i];
01042 errors[i-1] = fSumw2.fArray[i];
01043 ent[i-1] = fBinEntries.fArray[i];
01044 if (fBinEntries.fArray[i] == 0) cont[i-1] = 0;
01045 else cont[i-1] = fArray[i]/fBinEntries.fArray[i];
01046 }
01047 if (sort ==1) TMath::Sort(n,cont,a,kTRUE);
01048 else TMath::Sort(n,cont,a,kFALSE);
01049 for (i=1;i<=n;i++) {
01050 fArray[i] = sumw[a[i-1]];
01051 fSumw2.fArray[i] = errors[a[i-1]];
01052 fBinEntries.fArray[i] = ent[a[i-1]];
01053 }
01054 for (i=1;i<=n;i++) {
01055 obj = labold->At(a[i-1]);
01056 labels->Add(obj);
01057 obj->SetUniqueID(i);
01058 }
01059 } else {
01060
01061 const UInt_t kUsed = 1<<18;
01062 TObject *objk=0;
01063 a[0] = 0;
01064 a[n+1] = n+1;
01065 for (i=1;i<=n;i++) {
01066 const char *label = "zzzzzzzzzzzz";
01067 for (j=1;j<=n;j++) {
01068 obj = labold->At(j-1);
01069 if (!obj) continue;
01070 if (obj->TestBit(kUsed)) continue;
01071
01072 if (strcmp(label,obj->GetName()) < 0) continue;
01073 objk = obj;
01074 a[i] = j;
01075 label = obj->GetName();
01076 }
01077 if (objk) {
01078 objk->SetUniqueID(i);
01079 labels->Add(objk);
01080 objk->SetBit(kUsed);
01081 }
01082 }
01083 for (i=1;i<=n;i++) {
01084 obj = labels->At(i-1);
01085 if (!obj) continue;
01086 obj->ResetBit(kUsed);
01087 }
01088
01089 for (i=1;i<=n;i++) {
01090 sumw[i] = fArray[a[i]];
01091 errors[i] = fSumw2.fArray[a[i]];
01092 ent[i] = fBinEntries.fArray[a[i]];
01093 }
01094 for (i=1;i<=n;i++) {
01095 fArray[i] = sumw[i];
01096 fSumw2.fArray[i] = errors[i];
01097 fBinEntries.fArray[i] = ent[i];
01098 }
01099 }
01100 delete labold;
01101 if (a) delete [] a;
01102 if (sumw) delete [] sumw;
01103 if (cont) delete [] cont;
01104 if (errors) delete [] errors;
01105 if (ent) delete [] ent;
01106 }
01107
01108
01109 Long64_t TProfile::Merge(TCollection *li)
01110 {
01111
01112
01113
01114
01115
01116
01117
01118
01119
01120
01121
01122
01123
01124 return TProfileHelper::Merge(this, li);
01125 }
01126
01127
01128
01129 void TProfile::Multiply(TF1 *f1, Double_t c1)
01130 {
01131
01132
01133 if (!f1) {
01134 Error("Multiply","Attempt to multiply by a null function");
01135 return;
01136 }
01137
01138 Int_t nbinsx = GetNbinsX();
01139
01140
01141 Double_t xx[1], cf1, ac1 = TMath::Abs(c1);
01142 Double_t s1[10];
01143 Int_t i;
01144 for (i=0;i<10;i++) {s1[i] = 0;}
01145 PutStats(s1);
01146
01147 SetMinimum();
01148 SetMaximum();
01149
01150
01151 Int_t bin;
01152 for (bin=0;bin<=nbinsx+1;bin++) {
01153 xx[0] = fXaxis.GetBinCenter(bin);
01154 if (!f1->IsInside(xx)) continue;
01155 TF1::RejectPoint(kFALSE);
01156 cf1 = f1->EvalPar(xx);
01157 if (TF1::RejectedPoint()) continue;
01158 fArray[bin] *= c1*cf1;
01159
01160
01161 fSumw2.fArray[bin] *= ac1*cf1*cf1;
01162
01163 }
01164 }
01165
01166
01167 void TProfile::Multiply(const TH1 *)
01168 {
01169
01170
01171
01172
01173
01174 Error("Multiply","Multiplication of profile histograms not implemented");
01175 }
01176
01177
01178
01179 void TProfile::Multiply(const TH1 *, const TH1 *, Double_t, Double_t, Option_t *)
01180 {
01181
01182
01183
01184
01185
01186
01187 Error("Multiply","Multiplication of profile histograms not implemented");
01188 }
01189
01190
01191 TH1D *TProfile::ProjectionX(const char *name, Option_t *option) const
01192 {
01193
01194
01195
01196
01197
01198
01199
01200
01201
01202
01203
01204
01205
01206
01207
01208
01209
01210
01211
01212
01213
01214
01215 TString opt = option;
01216 opt.ToLower();
01217 Int_t nx = fXaxis.GetNbins();
01218
01219
01220 TString pname = name;
01221 if (pname == "_px") {
01222 pname = GetName();
01223 pname.Append("_px");
01224 }
01225 TH1D *h1;
01226 const TArrayD *bins = fXaxis.GetXbins();
01227 if (bins->fN == 0) {
01228 h1 = new TH1D(pname,GetTitle(),nx,fXaxis.GetXmin(),fXaxis.GetXmax());
01229 } else {
01230 h1 = new TH1D(pname,GetTitle(),nx,bins->fArray);
01231 }
01232 Bool_t computeErrors = kFALSE;
01233 Bool_t cequalErrors = kFALSE;
01234 Bool_t binEntries = kFALSE;
01235 Bool_t binWeight = kFALSE;
01236 if (opt.Contains("b")) binEntries = kTRUE;
01237 if (opt.Contains("e")) computeErrors = kTRUE;
01238 if (opt.Contains("w")) binWeight = kTRUE;
01239 if (opt.Contains("c=e")) {cequalErrors = kTRUE; computeErrors=kFALSE;}
01240 if (computeErrors || binWeight ) h1->Sumw2();
01241
01242
01243 Double_t cont;
01244 for (Int_t bin =0;bin<=nx+1;bin++) {
01245
01246 if (binEntries) cont = GetBinEntries(bin);
01247 else if (cequalErrors) cont = GetBinError(bin);
01248 else if (binWeight) cont = fArray[bin];
01249 else cont = GetBinContent(bin);
01250
01251 h1->SetBinContent(bin ,cont);
01252
01253
01254 if (computeErrors ) h1->SetBinError(bin , GetBinError(bin) );
01255
01256
01257 if (binWeight) h1->SetBinError(bin , TMath::Sqrt(fSumw2.fArray[bin] ) );
01258
01259 if (binEntries && h1->GetSumw2() ) {
01260 Double_t err2;
01261 if (fBinSumw2.fN)
01262 err2 = fBinSumw2.fArray[bin];
01263 else
01264 err2 = cont;
01265 h1->SetBinError(bin, TMath::Sqrt(err2 ) );
01266 }
01267
01268 }
01269
01270
01271 h1->GetXaxis()->ImportAttributes(this->GetXaxis());
01272 h1->GetYaxis()->ImportAttributes(this->GetYaxis());
01273 THashList* labels=this->GetXaxis()->GetLabels();
01274 if (labels) {
01275 TIter iL(labels);
01276 TObjString* lb;
01277 Int_t i = 1;
01278 while ((lb=(TObjString*)iL())) {
01279 h1->GetXaxis()->SetBinLabel(i,lb->String().Data());
01280 i++;
01281 }
01282 }
01283
01284 h1->SetEntries(fEntries);
01285 return h1;
01286 }
01287
01288
01289 void TProfile::PutStats(Double_t *stats)
01290 {
01291
01292
01293 fTsumw = stats[0];
01294 fTsumw2 = stats[1];
01295 fTsumwx = stats[2];
01296 fTsumwx2 = stats[3];
01297 fTsumwy = stats[4];
01298 fTsumwy2 = stats[5];
01299 }
01300
01301
01302 TH1 *TProfile::Rebin(Int_t ngroup, const char*newname, const Double_t *xbins)
01303 {
01304
01305
01306
01307
01308
01309
01310
01311
01312
01313
01314
01315
01316
01317
01318
01319
01320
01321
01322
01323
01324
01325
01326
01327
01328
01329
01330
01331
01332
01333
01334
01335
01336
01337
01338
01339 Int_t nbins = fXaxis.GetNbins();
01340 Double_t xmin = fXaxis.GetXmin();
01341 Double_t xmax = fXaxis.GetXmax();
01342 if ((ngroup <= 0) || (ngroup > nbins)) {
01343 Error("Rebin", "Illegal value of ngroup=%d",ngroup);
01344 return 0;
01345 }
01346 if (!newname && xbins) {
01347 Error("Rebin","if xbins is specified, newname must be given");
01348 return 0;
01349 }
01350
01351 Int_t newbins = nbins/ngroup;
01352 if (!xbins) {
01353 Int_t nbg = nbins/ngroup;
01354 if (nbg*ngroup != nbins) {
01355 Warning("Rebin", "ngroup=%d must be an exact divider of nbins=%d",ngroup,nbins);
01356 }
01357 }
01358 else {
01359
01360
01361
01362
01363 newbins = ngroup;
01364 ngroup = nbins;
01365 }
01366
01367
01368 Double_t *oldBins = new Double_t[nbins+2];
01369 Double_t *oldCount = new Double_t[nbins+2];
01370 Double_t *oldErrors = new Double_t[nbins+2];
01371 Double_t *oldBinw2 = (fBinSumw2.fN ? new Double_t[nbins+2] : 0 );
01372 Int_t bin, i;
01373 Double_t *cu1 = GetW();
01374 Double_t *er1 = GetW2();
01375 Double_t *en1 = GetB();
01376 Double_t *ew1 = GetB2();
01377
01378 for (bin=0;bin<=nbins+1;bin++) {
01379 oldBins[bin] = cu1[bin];
01380 oldCount[bin] = en1[bin];
01381 oldErrors[bin] = er1[bin];
01382 if (ew1 && fBinSumw2.fN) oldBinw2[bin] = ew1[bin];
01383 }
01384
01385
01386 TProfile *hnew = this;
01387 if ((newname && strlen(newname) > 0) || xbins) {
01388 hnew = (TProfile*)Clone(newname);
01389 }
01390
01391
01392
01393 if(!xbins && (newbins*ngroup != nbins)) {
01394 xmax = fXaxis.GetBinUpEdge(newbins*ngroup);
01395 hnew->fTsumw = 0;
01396 }
01397
01398
01399 if(!xbins && (fXaxis.GetXbins()->GetSize() > 0)){
01400
01401 Double_t *bins = new Double_t[newbins+1];
01402 for(i = 0; i <= newbins; ++i) bins[i] = fXaxis.GetBinLowEdge(1+i*ngroup);
01403 hnew->SetBins(newbins,bins);
01404 delete [] bins;
01405 } else if (xbins) {
01406
01407 hnew->SetBins(newbins,xbins);
01408 } else {
01409 hnew->SetBins(newbins,xmin,xmax);
01410 }
01411
01412
01413 if (fBinSumw2.fN) hnew->Sumw2();
01414
01415
01416 Int_t startbin = 1;
01417 const Double_t newxmin = hnew->GetXaxis()->GetBinLowEdge(1);
01418 while( fXaxis.GetBinCenter(startbin) < newxmin && startbin <= nbins ) {
01419 startbin++;
01420 }
01421
01422 Double_t *cu2 = hnew->GetW();
01423 Double_t *er2 = hnew->GetW2();
01424 Double_t *en2 = hnew->GetB();
01425 Double_t *ew2 = hnew->GetB2();
01426 Int_t oldbin = startbin;
01427 Double_t binContent, binCount, binError, binSumw2;
01428 for (bin = 1;bin<=newbins;bin++) {
01429 binContent = 0;
01430 binCount = 0;
01431 binError = 0;
01432 binSumw2 = 0;
01433
01434
01435 Int_t imax = ngroup;
01436 Double_t xbinmax = hnew->GetXaxis()->GetBinUpEdge(bin);
01437 for (i=0;i<ngroup;i++) {
01438 if((hnew == this && (oldbin+i > nbins)) ||
01439 (hnew != this && (fXaxis.GetBinCenter(oldbin+i) > xbinmax)))
01440 {
01441 imax = i;
01442 break;
01443 }
01444
01445 binContent += oldBins[oldbin+i];
01446 binCount += oldCount[oldbin+i];
01447 binError += oldErrors[oldbin+i];
01448 if (fBinSumw2.fN) binSumw2 += oldBinw2[oldbin+i];
01449 }
01450
01451 cu2[bin] = binContent;
01452 er2[bin] = binError;
01453 en2[bin] = binCount;
01454 if (fBinSumw2.fN) ew2[bin] = binSumw2;
01455 oldbin += imax;
01456 }
01457
01458 binContent = 0;
01459 binCount = 0;
01460 binError = 0;
01461 binSumw2 = 0;
01462 for(i=0;i<startbin;i++)
01463 {
01464 binContent += oldBins[i];
01465 binCount += oldCount[i];
01466 binError += oldErrors[i];
01467 if (fBinSumw2.fN) binSumw2 += oldBinw2[i];
01468 }
01469 hnew->fArray[0] = binContent;
01470 hnew->fBinEntries[0] = binCount;
01471 hnew->fSumw2[0] = binError;
01472 if ( fBinSumw2.fN ) hnew->fBinSumw2[0] = binSumw2;
01473
01474
01475 binContent = 0;
01476 binCount = 0;
01477 binError = 0;
01478 binSumw2 = 0;
01479 for(i=oldbin;i<=nbins+1;i++)
01480 {
01481 binContent += oldBins[i];
01482 binCount += oldCount[i];
01483 binError += oldErrors[i];
01484 if (fBinSumw2.fN) binSumw2 += oldBinw2[i];
01485 }
01486 hnew->fArray[newbins+1] = binContent;
01487 hnew->fBinEntries[newbins+1] = binCount;
01488 hnew->fSumw2[newbins+1] = binError;
01489 if ( fBinSumw2.fN ) hnew->fBinSumw2[newbins+1] = binSumw2;
01490
01491
01492 delete [] oldBins;
01493 delete [] oldCount;
01494 delete [] oldErrors;
01495 if (oldBinw2) delete [] oldBinw2;
01496 return hnew;
01497 }
01498
01499
01500 void TProfile::RebinAxis(Double_t x, TAxis *axis)
01501 {
01502
01503
01504
01505
01506
01507
01508
01509
01510
01511 TProfile* hold = TProfileHelper::RebinAxis(this, x, axis);
01512 if ( hold ) {
01513 fTsumwy = hold->fTsumwy;
01514 fTsumwy2 = hold->fTsumwy2;
01515
01516 delete hold;
01517 }
01518 }
01519
01520
01521 void TProfile::Reset(Option_t *option)
01522 {
01523
01524
01525 TH1D::Reset(option);
01526 fBinEntries.Reset();
01527 fBinSumw2.Reset();
01528 TString opt = option;
01529 opt.ToUpper();
01530 if (opt.Contains("ICE")) return;
01531 fTsumwy = 0;
01532 fTsumwy2 = 0;
01533 }
01534
01535
01536 void TProfile::SavePrimitive(ostream &out, Option_t *option )
01537 {
01538
01539
01540
01541
01542
01543
01544 Bool_t nonEqiX = kFALSE;
01545 Int_t i;
01546
01547
01548 if (GetXaxis()->GetXbins()->fN && GetXaxis()->GetXbins()->fArray) {
01549 nonEqiX = kTRUE;
01550 out << " Double_t xAxis[" << GetXaxis()->GetXbins()->fN
01551 << "] = {";
01552 for (i = 0; i < GetXaxis()->GetXbins()->fN; i++) {
01553 if (i != 0) out << ", ";
01554 out << GetXaxis()->GetXbins()->fArray[i];
01555 }
01556 out << "}; " << endl;
01557 }
01558
01559 char quote = '"';
01560 out<<" "<<endl;
01561 out<<" "<<ClassName()<<" *";
01562
01563
01564
01565 static Int_t hcounter = 0;
01566 TString histName = GetName();
01567 if (!fDirectory) {
01568 hcounter++;
01569 histName += "__";
01570 histName += hcounter;
01571 }
01572 const char *hname = histName.Data();
01573
01574 out<<hname<<" = new "<<ClassName()<<"("<<quote<<GetName()<<quote<<","<<quote<<GetTitle()<<quote
01575 <<","<<GetXaxis()->GetNbins();
01576 if (nonEqiX)
01577 out << ", xAxis";
01578 else
01579 out << "," << GetXaxis()->GetXmin()
01580 << "," << GetXaxis()->GetXmax()
01581 <<","<<quote<<GetErrorOption()<<quote<<");"<<endl;
01582
01583
01584 Int_t bin;
01585 for (bin=0;bin<fNcells;bin++) {
01586 Double_t bi = GetBinEntries(bin);
01587 if (bi) {
01588 out<<" "<<hname<<"->SetBinEntries("<<bin<<","<<bi<<");"<<endl;
01589 }
01590 }
01591
01592 for (bin=0;bin<fNcells;bin++) {
01593 Double_t bc = fArray[bin];
01594 if (bc) {
01595 out<<" "<<hname<<"->SetBinContent("<<bin<<","<<bc<<");"<<endl;
01596 }
01597 }
01598
01599 if (fSumw2.fN) {
01600 for (bin=0;bin<fNcells;bin++) {
01601 Double_t be = TMath::Sqrt(fSumw2.fArray[bin]);
01602 if (be) {
01603 out<<" "<<hname<<"->SetBinError("<<bin<<","<<be<<");"<<endl;
01604 }
01605 }
01606 }
01607
01608 TH1::SavePrimitiveHelp(out, hname, option);
01609 }
01610
01611
01612 void TProfile::Scale(Double_t c1, Option_t * option)
01613 {
01614
01615
01616
01617
01618
01619
01620
01621
01622 TProfileHelper::Scale(this, c1, option);
01623 }
01624
01625
01626 void TProfile::SetBinEntries(Int_t bin, Double_t w)
01627 {
01628
01629
01630
01631 if (bin < 0 || bin >= fNcells) return;
01632 fBinEntries.fArray[bin] = w;
01633 }
01634
01635
01636 void TProfile::SetBins(Int_t nx, Double_t xmin, Double_t xmax)
01637 {
01638
01639
01640
01641 fXaxis.Set(nx,xmin,xmax);
01642 fNcells = nx+2;
01643 SetBinsLength(fNcells);
01644 fBinEntries.Set(fNcells);
01645 fSumw2.Set(fNcells);
01646 if (fBinSumw2.fN) fBinSumw2.Set(fNcells);
01647 }
01648
01649
01650 void TProfile::SetBins(Int_t nx, const Double_t *xbins)
01651 {
01652
01653
01654
01655 fXaxis.Set(nx,xbins);
01656 fNcells = nx+2;
01657 SetBinsLength(fNcells);
01658 fBinEntries.Set(fNcells);
01659 fSumw2.Set(fNcells);
01660 if (fBinSumw2.fN) fBinSumw2.Set(fNcells);
01661 }
01662
01663
01664
01665 void TProfile::SetBuffer(Int_t buffersize, Option_t *)
01666 {
01667
01668
01669 if (fBuffer) {
01670 BufferEmpty();
01671 delete [] fBuffer;
01672 fBuffer = 0;
01673 }
01674 if (buffersize <= 0) {
01675 fBufferSize = 0;
01676 return;
01677 }
01678 if (buffersize < 100) buffersize = 100;
01679 fBufferSize = 1 + 3*buffersize;
01680 fBuffer = new Double_t[fBufferSize];
01681 memset(fBuffer,0,8*fBufferSize);
01682 }
01683
01684
01685 void TProfile::SetErrorOption(Option_t *option)
01686 {
01687
01688
01689
01690
01691
01692
01693
01694
01695
01696
01697
01698
01699
01700
01701
01702
01703
01704
01705
01706
01707
01708
01709 TString opt = option;
01710 opt.ToLower();
01711 fErrorMode = kERRORMEAN;
01712 if (opt.Contains("s")) fErrorMode = kERRORSPREAD;
01713 if (opt.Contains("i")) fErrorMode = kERRORSPREADI;
01714 if (opt.Contains("g")) fErrorMode = kERRORSPREADG;
01715 }
01716
01717
01718 void TProfile::Streamer(TBuffer &R__b)
01719 {
01720
01721
01722 if (R__b.IsReading()) {
01723 UInt_t R__s, R__c;
01724 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
01725 if (R__v > 2) {
01726 R__b.ReadClassBuffer(TProfile::Class(), this, R__v, R__s, R__c);
01727 return;
01728 }
01729
01730 TH1D::Streamer(R__b);
01731 fBinEntries.Streamer(R__b);
01732 Int_t errorMode;
01733 R__b >> errorMode;
01734 fErrorMode = (EErrorType)errorMode;
01735 if (R__v < 2) {
01736 Float_t ymin,ymax;
01737 R__b >> ymin; fYmin = ymin;
01738 R__b >> ymax; fYmax = ymax;
01739 } else {
01740 R__b >> fYmin;
01741 R__b >> fYmax;
01742 }
01743 R__b.CheckByteCount(R__s, R__c, TProfile::IsA());
01744
01745
01746 } else {
01747 R__b.WriteClassBuffer(TProfile::Class(),this);
01748 }
01749 }
01750
01751 void TProfile::Sumw2()
01752 {
01753
01754
01755
01756
01757
01758
01759
01760
01761 TProfileHelper::Sumw2(this);
01762 }