3083 TH1 *gCurrentHist = 0;
3088 const Int_t kNMAX = 2000;
3090 const Int_t kMAXCONTOUR = 104;
3091 const UInt_t kCannotRotate = BIT(11);
3093 static TBox *gXHighlightBox = 0;
3094 static TBox *gYHighlightBox = 0;
3096 static TString gStringEntries;
3097 static TString gStringMean;
3098 static TString gStringMeanX;
3099 static TString gStringMeanY;
3100 static TString gStringMeanZ;
3101 static TString gStringStdDev;
3102 static TString gStringStdDevX;
3103 static TString gStringStdDevY;
3104 static TString gStringStdDevZ;
3105 static TString gStringUnderflow;
3106 static TString gStringOverflow;
3107 static TString gStringIntegral;
3108 static TString gStringIntegralBinWidth;
3109 static TString gStringSkewness;
3110 static TString gStringSkewnessX;
3111 static TString gStringSkewnessY;
3112 static TString gStringSkewnessZ;
3113 static TString gStringKurtosis;
3114 static TString gStringKurtosisX;
3115 static TString gStringKurtosisY;
3116 static TString gStringKurtosisZ;
3118 ClassImp(THistPainter);
3123 THistPainter::THistPainter()
3137 fGraph2DPainter = 0;
3138 fShowProjection = 0;
3140 for (
int i=0; i<kMaxCuts; i++) {
3144 fXHighlightBin = -1;
3145 fYHighlightBin = -1;
3147 gStringEntries = gEnv->GetValue(
"Hist.Stats.Entries",
"Entries");
3148 gStringMean = gEnv->GetValue(
"Hist.Stats.Mean",
"Mean");
3149 gStringMeanX = gEnv->GetValue(
"Hist.Stats.MeanX",
"Mean x");
3150 gStringMeanY = gEnv->GetValue(
"Hist.Stats.MeanY",
"Mean y");
3151 gStringMeanZ = gEnv->GetValue(
"Hist.Stats.MeanZ",
"Mean z");
3152 gStringStdDev = gEnv->GetValue(
"Hist.Stats.StdDev",
"Std Dev");
3153 gStringStdDevX = gEnv->GetValue(
"Hist.Stats.StdDevX",
"Std Dev x");
3154 gStringStdDevY = gEnv->GetValue(
"Hist.Stats.StdDevY",
"Std Dev y");
3155 gStringStdDevZ = gEnv->GetValue(
"Hist.Stats.StdDevZ",
"Std Dev z");
3156 gStringUnderflow = gEnv->GetValue(
"Hist.Stats.Underflow",
"Underflow");
3157 gStringOverflow = gEnv->GetValue(
"Hist.Stats.Overflow",
"Overflow");
3158 gStringIntegral = gEnv->GetValue(
"Hist.Stats.Integral",
"Integral");
3159 gStringIntegralBinWidth = gEnv->GetValue(
"Hist.Stats.IntegralBinWidth",
"Integral(w)");
3160 gStringSkewness = gEnv->GetValue(
"Hist.Stats.Skewness",
"Skewness");
3161 gStringSkewnessX = gEnv->GetValue(
"Hist.Stats.SkewnessX",
"Skewness x");
3162 gStringSkewnessY = gEnv->GetValue(
"Hist.Stats.SkewnessY",
"Skewness y");
3163 gStringSkewnessZ = gEnv->GetValue(
"Hist.Stats.SkewnessZ",
"Skewness z");
3164 gStringKurtosis = gEnv->GetValue(
"Hist.Stats.Kurtosis",
"Kurtosis");
3165 gStringKurtosisX = gEnv->GetValue(
"Hist.Stats.KurtosisX",
"Kurtosis x");
3166 gStringKurtosisY = gEnv->GetValue(
"Hist.Stats.KurtosisY",
"Kurtosis y");
3167 gStringKurtosisZ = gEnv->GetValue(
"Hist.Stats.KurtosisZ",
"Kurtosis z");
3173 THistPainter::~THistPainter()
3186 Int_t THistPainter::DistancetoPrimitive(Int_t px, Int_t py)
3189 Double_t defaultLabelSize = 0.04;
3191 const Int_t big = 9999;
3192 const Int_t kMaxDiff = 7;
3194 if (fPie)
return fPie->DistancetoPrimitive(px, py);
3196 Double_t x = gPad->AbsPixeltoX(px);
3197 Double_t x1 = gPad->AbsPixeltoX(px+1);
3199 Int_t puxmin = gPad->XtoAbsPixel(gPad->GetUxmin());
3200 Int_t puymin = gPad->YtoAbsPixel(gPad->GetUymin());
3201 Int_t puxmax = gPad->XtoAbsPixel(gPad->GetUxmax());
3202 Int_t puymax = gPad->YtoAbsPixel(gPad->GetUymax());
3203 Int_t curdist = big;
3204 Int_t yxaxis, dyaxis,xyaxis, dxaxis;
3206 TObject *PadPointer = gPad->GetPadPointer();
3207 if (!PadPointer)
return 0;
3208 TString doption = PadPointer->GetDrawOption();
3209 Double_t factor = 1;
3210 if (fH->GetNormFactor() != 0) {
3211 factor = fH->GetNormFactor()/fH->GetSumOfWeights();
3216 TView *view = gPad->GetView();
3218 if (view && Hoption.Contour != 14) {
3220 d3 = view->GetDistancetoAxis(3, px, py, ratio);
3221 if (d3 <= kMaxDiff) {gPad->SetSelected(fZaxis);
return 0;}
3222 d1 = view->GetDistancetoAxis(1, px, py, ratio);
3223 if (d1 <= kMaxDiff) {gPad->SetSelected(fXaxis);
return 0;}
3224 d2 = view->GetDistancetoAxis(2, px, py, ratio);
3225 if (d2 <= kMaxDiff) {gPad->SetSelected(fYaxis);
return 0;}
3226 if ( px > puxmin && px < puxmax && py > puymax && py < puymin) curdist = 1;
3232 if (doption.Contains(
"same")) dsame = kTRUE;
3234 dyaxis = Int_t(2*(puymin-puymax)*TMath::Max(Double_t(fYaxis->GetLabelSize()), defaultLabelSize));
3235 if (doption.Contains(
"y+")) {
3236 xyaxis = puxmax + Int_t((puxmax-puxmin)*fYaxis->GetLabelOffset());
3237 if (px <= xyaxis+dyaxis && px >= xyaxis && py >puymax && py < puymin) {
3239 if (gPad->IsVertical()) gPad->SetSelected(fYaxis);
3240 else gPad->SetSelected(fXaxis);
3245 xyaxis = puxmin - Int_t((puxmax-puxmin)*fYaxis->GetLabelOffset());
3246 if (px >= xyaxis-dyaxis && px <= xyaxis && py >puymax && py < puymin) {
3248 if (gPad->IsVertical()) gPad->SetSelected(fYaxis);
3249 else gPad->SetSelected(fXaxis);
3255 dxaxis = Int_t((puymin-puymax)*TMath::Max(Double_t(fXaxis->GetLabelSize()), defaultLabelSize));
3256 if (doption.Contains(
"x+")) {
3257 yxaxis = puymax - Int_t((puymin-puymax)*fXaxis->GetLabelOffset());
3258 if (py >= yxaxis-dxaxis && py <= yxaxis && px <puxmax && px > puxmin) {
3260 if (gPad->IsVertical()) gPad->SetSelected(fXaxis);
3261 else gPad->SetSelected(fYaxis);
3266 yxaxis = puymin + Int_t((puymin-puymax)*fXaxis->GetLabelOffset());
3267 if (yxaxis < puymin) yxaxis = puymin;
3268 if (py <= yxaxis+dxaxis && py >= yxaxis && px <puxmax && px > puxmin) {
3270 if (gPad->IsVertical()) gPad->SetSelected(fXaxis);
3271 else gPad->SetSelected(fYaxis);
3277 if (fH->IsHighlight()) {
3278 if ((px > puxmin) && (py < puymin) && (px < puxmax) && (py > puymax))
3279 HighlightBin(px, py);
3283 if (fH->GetDimension() == 2) {
3284 if (fH->InheritsFrom(TH2Poly::Class())) {
3285 TH2Poly *th2 = (TH2Poly*)fH;
3286 Double_t xmin, ymin, xmax, ymax;
3287 gPad->GetRangeAxis(xmin, ymin, xmax, ymax);
3288 Double_t pxu = gPad->AbsPixeltoX(px);
3289 Double_t pyu = gPad->AbsPixeltoY(py);
3290 if ((pxu>xmax) || (pxu < xmin) || (pyu>ymax) || (pyu < ymin)) {
3294 Int_t bin = th2->FindBin(pxu, pyu);
3295 if (bin>0) curdist = 1;
3301 if ( px > puxmin + delta2
3302 && px < puxmax - delta2
3303 && py > puymax + delta2
3304 && py < puymin - delta2) {curdist =1;
goto FUNCTIONS;}
3308 if (gPad->IsVertical()) {
3309 Int_t bin = fXaxis->FindFixBin(gPad->PadtoX(x));
3310 Int_t binsup = fXaxis->FindFixBin(gPad->PadtoX(x1));
3311 Double_t binval = factor*fH->GetBinContent(bin);
3312 Int_t pybin = gPad->YtoAbsPixel(gPad->YtoPad(binval));
3313 if (binval == 0 && pybin < puymin) pybin = 10000;
3316 Double_t binvalmin, binvalmax;
3319 for (Int_t ibin=bin+1; ibin<binsup; ibin++) {
3320 Double_t binvaltmp = factor*fH->GetBinContent(ibin);
3321 if (binvalmin>binvaltmp) binvalmin=binvaltmp;
3322 if (binvalmax<binvaltmp) binvalmax=binvaltmp;
3324 Int_t pybinmin = gPad->YtoAbsPixel(gPad->YtoPad(binvalmax));
3325 Int_t pybinmax = gPad->YtoAbsPixel(gPad->YtoPad(binvalmin));
3326 if (py<pybinmax+kMaxDiff/2 && py>pybinmin-kMaxDiff/2) pybin = py;
3328 if (bin != binsup) {
3329 Double_t binsupval = factor*fH->GetBinContent(binsup);
3330 Int_t pybinsub = gPad->YtoAbsPixel(gPad->YtoPad(binsupval));
3331 if (py <= TMath::Max(pybinsub,pybin) && py >= TMath::Min(pybinsub,pybin) && pybin != 10000)
return 0;
3333 if (TMath::Abs(py - pybin) <= kMaxDiff)
return TMath::Abs(py - pybin);
3335 Double_t y = gPad->AbsPixeltoY(py);
3336 Double_t y1 = gPad->AbsPixeltoY(py+1);
3337 Int_t bin = fXaxis->FindFixBin(gPad->PadtoY(y));
3338 Int_t binsup = fXaxis->FindFixBin(gPad->PadtoY(y1));
3339 Double_t binval = factor*fH->GetBinContent(bin);
3340 Int_t pxbin = gPad->XtoAbsPixel(gPad->XtoPad(binval));
3341 if (binval == 0 && pxbin > puxmin) pxbin = 10000;
3344 Double_t binvalmin, binvalmax;
3347 for (Int_t ibin=bin+1; ibin<binsup; ibin++) {
3348 Double_t binvaltmp = factor*fH->GetBinContent(ibin);
3349 if (binvalmin>binvaltmp) binvalmin=binvaltmp;
3350 if (binvalmax<binvaltmp) binvalmax=binvaltmp;
3352 Int_t pxbinmin = gPad->XtoAbsPixel(gPad->XtoPad(binvalmax));
3353 Int_t pxbinmax = gPad->XtoAbsPixel(gPad->XtoPad(binvalmin));
3354 if (px<pxbinmax+kMaxDiff/2 && px>pxbinmin-kMaxDiff/2) pxbin = px;
3356 if (TMath::Abs(px - pxbin) <= kMaxDiff)
return TMath::Abs(px - pxbin);
3361 TIter next(fFunctions);
3362 while ((f = (TObject*) next())) {
3364 if (f->InheritsFrom(TF1::Class())) dist = f->DistancetoPrimitive(-px,py);
3365 else dist = f->DistancetoPrimitive(px,py);
3366 if (dist < kMaxDiff) {gPad->SetSelected(f);
return dist;}
3374 void THistPainter::DrawPanel()
3379 Error(
"DrawPanel",
"need to draw histogram first");
3382 TVirtualPadEditor *editor = TVirtualPadEditor::GetPadEditor();
3384 gROOT->ProcessLine(Form(
"((TCanvas*)0x%lx)->Selected((TVirtualPad*)0x%lx,(TObject*)0x%lx,1)",
3385 (ULong_t)gPad->GetCanvas(), (ULong_t)gPad, (ULong_t)fH));
3394 void THistPainter::ExecuteEvent(Int_t event, Int_t px, Int_t py)
3399 static Int_t bin, px1, py1, px2, py2, pyold;
3400 static TBox *zoombox;
3401 Double_t zbx1,zbx2,zby1,zby2;
3404 Double_t xlow, xup, ylow, binval, x, baroffset, barwidth, binwidth;
3405 Bool_t opaque = gPad->OpaqueMoving();
3407 if (!gPad->IsEditable())
return;
3410 fPie->ExecuteEvent(event, px, py);
3414 TView *view = gPad->GetView();
3416 if (!fShowProjection && view && view->TestBit(kCannotRotate) == 0) {
3417 view->ExecuteRotateView(event, px, py);
3421 TAxis *xaxis = fH->GetXaxis();
3422 TAxis *yaxis = fH->GetYaxis();
3423 Int_t dimension = fH->GetDimension();
3426 TString IsSame = fH->GetDrawOption();
3428 if (IsSame.Index(
"same")>=0) {
3430 TIter next(gPad->GetListOfPrimitives());
3431 while ((h1 = (TH1 *)next())) {
3432 if (!h1->InheritsFrom(TH1::Class()))
continue;
3433 xaxis = h1->GetXaxis();
3434 yaxis = h1->GetYaxis();
3439 Double_t factor = 1;
3440 if (fH->GetNormFactor() != 0) {
3441 factor = fH->GetNormFactor()/fH->GetSumOfWeights();
3448 if (!opaque) gVirtualX->SetLineColor(-1);
3449 fH->TAttLine::Modify();
3451 if (opaque && dimension ==2) {
3452 zbx1 = gPad->AbsPixeltoX(px);
3453 zbx2 = gPad->AbsPixeltoX(px);
3454 zby1 = gPad->AbsPixeltoY(py);
3455 zby2 = gPad->AbsPixeltoY(py);
3458 if (gPad->GetLogx()) {
3459 zbx1 = TMath::Power(10,zbx1);
3460 zbx2 = TMath::Power(10,zbx2);
3462 if (gPad->GetLogy()) {
3463 zby1 = TMath::Power(10,zby1);
3464 zby2 = TMath::Power(10,zby2);
3466 zoombox =
new TBox(zbx1, zby1, zbx2, zby2);
3467 Int_t ci = TColor::GetColor(
"#7d7dff");
3468 TColor *zoomcolor = gROOT->GetColor(ci);
3469 if (!TCanvas::SupportAlpha() || !zoomcolor) zoombox->SetFillStyle(3002);
3470 else zoomcolor->SetAlpha(0.5);
3471 zoombox->SetFillColor(ci);
3480 if (fShowProjection) {ShowProjection3(px,py);
break;}
3482 gPad->SetCursor(kPointer);
3483 if (dimension ==1) {
3485 baroffset = fH->GetBarOffset();
3486 barwidth = fH->GetBarWidth();
3491 x = gPad->AbsPixeltoX(px);
3492 bin = fXaxis->FindFixBin(gPad->PadtoX(x));
3493 binwidth = fXaxis->GetBinWidth(bin);
3494 xlow = gPad->XtoPad(fXaxis->GetBinLowEdge(bin) + baroffset*binwidth);
3495 xup = gPad->XtoPad(xlow + barwidth*binwidth);
3496 ylow = gPad->GetUymin();
3497 px1 = gPad->XtoAbsPixel(xlow);
3498 px2 = gPad->XtoAbsPixel(xup);
3499 py1 = gPad->YtoAbsPixel(ylow);
3502 if (gROOT->GetEditHistograms()) gPad->SetCursor(kArrowVer);
3507 case kButton1Motion:
3509 if (dimension ==1) {
3510 if (gROOT->GetEditHistograms()) {
3512 gVirtualX->DrawBox(px1, py1, px2, py2,TVirtualX::kHollow);
3514 gVirtualX->DrawBox(px1, py1, px2, py2,TVirtualX::kHollow);
3519 binval = gPad->PadtoY(gPad->AbsPixeltoY(py2))/factor;
3520 fH->SetBinContent(bin,binval);
3521 gPad->Modified(kTRUE);
3526 if (opaque && dimension ==2) {
3527 if (TMath::Abs(px1-px)>5 && TMath::Abs(py1-py)>5) {
3528 zbx2 = gPad->AbsPixeltoX(px);
3529 zby2 = gPad->AbsPixeltoY(py);
3530 if (gPad->GetLogx()) zbx2 = TMath::Power(10,zbx2);
3531 if (gPad->GetLogy()) zby2 = TMath::Power(10,zby2);
3532 zoombox->SetX2(zbx2);
3533 zoombox->SetY2(zby2);
3543 if (dimension ==2) {
3544 bin1 = xaxis->GetFirst()+1;
3545 bin2 = xaxis->GetLast()-1;
3546 bin1 = TMath::Max(bin1, 1);
3547 bin2 = TMath::Min(bin2, xaxis->GetNbins());
3548 if (bin2>bin1) xaxis->SetRange(bin1,bin2);
3549 bin1 = yaxis->GetFirst()+1;
3550 bin2 = yaxis->GetLast()-1;
3551 bin1 = TMath::Max(bin1, 1);
3552 bin2 = TMath::Min(bin2, yaxis->GetNbins());
3553 if (bin2>bin1) yaxis->SetRange(bin1,bin2);
3562 if (dimension == 2) {
3563 bin1 = xaxis->GetFirst()-1;
3564 bin2 = xaxis->GetLast()+1;
3565 bin1 = TMath::Max(bin1, 1);
3566 bin2 = TMath::Min(bin2, xaxis->GetNbins());
3567 if (bin2>bin1) xaxis->SetRange(bin1,bin2);
3568 bin1 = yaxis->GetFirst()-1;
3569 bin2 = yaxis->GetLast()+1;
3570 bin1 = TMath::Max(bin1, 1);
3571 bin2 = TMath::Min(bin2, yaxis->GetNbins());
3572 if (bin2>bin1) yaxis->SetRange(bin1,bin2);
3580 if (dimension ==1) {
3581 if (gROOT->GetEditHistograms()) {
3582 binval = gPad->PadtoY(gPad->AbsPixeltoY(py2))/factor;
3583 fH->SetBinContent(bin,binval);
3590 if (opaque && dimension ==2) {
3592 Double_t x1 = TMath::Min(zoombox->GetX1(), zoombox->GetX2());
3593 Double_t x2 = TMath::Max(zoombox->GetX1(), zoombox->GetX2());
3594 Double_t y1 = TMath::Min(zoombox->GetY1(), zoombox->GetY2());
3595 Double_t y2 = TMath::Max(zoombox->GetY1(), zoombox->GetY2());
3596 x1 = TMath::Max(x1,xaxis->GetXmin());
3597 x2 = TMath::Min(x2,xaxis->GetXmax());
3598 y1 = TMath::Max(y1,yaxis->GetXmin());
3599 y2 = TMath::Min(y2,yaxis->GetXmax());
3600 if (x1<x2 && y1<y2) {
3601 xaxis->SetRangeUser(x1, x2);
3602 yaxis->SetRangeUser(y1, y2);
3608 gPad->Modified(kTRUE);
3609 if (opaque) gVirtualX->SetLineColor(-1);
3613 case kButton1Locate:
3615 ExecuteEvent(kButton1Down, px, py);
3619 event = gVirtualX->RequestLocator(1, 1, px, py);
3621 ExecuteEvent(kButton1Motion, px, py);
3624 ExecuteEvent(kButton1Up, px, py);
3634 TList *THistPainter::GetContourList(Double_t contour)
const
3640 TList *hl = fH->GetListOfFunctions();
3641 TGraphDelaunay2D *dt = (TGraphDelaunay2D*)hl->FindObject(
"TGraphDelaunay2D");
3643 TGraphDelaunay *dtOld =
nullptr;
3644 if (!dt) dtOld = (TGraphDelaunay*)hl->FindObject(
"TGraphDelaunay");
3646 if (!dt && !dtOld)
return nullptr;
3650 if (!fGraph2DPainter) {
3651 if (dt) ((THistPainter*)
this)->fGraph2DPainter =
new TGraph2DPainter(dt);
3652 else ((THistPainter*)
this)->fGraph2DPainter =
new TGraph2DPainter(dtOld);
3655 return fGraph2DPainter->GetContourList(contour);
3662 char *THistPainter::GetObjectInfo(Int_t px, Int_t py)
const
3665 if (!gPad)
return (
char*)
"";
3667 Double_t x = gPad->PadtoX(gPad->AbsPixeltoX(px));
3668 Double_t y = gPad->PadtoY(gPad->AbsPixeltoY(py));
3669 Double_t x1 = gPad->PadtoX(gPad->AbsPixeltoX(px+1));
3670 TString drawOption = fH->GetDrawOption();
3671 drawOption.ToLower();
3672 Double_t xmin, xmax, uxmin,uxmax;
3673 Double_t ymin, ymax, uymin,uymax;
3674 if (fH->GetDimension() == 2) {
3675 if (gPad->GetView() || drawOption.Index(
"cont") >= 0) {
3676 uxmin=gPad->GetUxmin();
3677 uxmax=gPad->GetUxmax();
3678 xmin = fXaxis->GetBinLowEdge(fXaxis->GetFirst());
3679 xmax = fXaxis->GetBinUpEdge(fXaxis->GetLast());
3680 x = xmin +(xmax-xmin)*(x-uxmin)/(uxmax-uxmin);
3681 uymin=gPad->GetUymin();
3682 uymax=gPad->GetUymax();
3683 ymin = fYaxis->GetBinLowEdge(fYaxis->GetFirst());
3684 ymax = fYaxis->GetBinUpEdge(fYaxis->GetLast());
3685 y = ymin +(ymax-ymin)*(y-uymin)/(uymax-uymin);
3688 Int_t binx,biny,binmin=0,binx1;
3689 if (gPad->IsVertical()) {
3690 binx = fXaxis->FindFixBin(x);
3691 if (drawOption.Index(
"same") >= 0) {
3693 TIter next(gPad->GetListOfPrimitives());
3694 while ((h1 = (TH1 *)next())) {
3695 if (!h1->InheritsFrom(TH1::Class()))
continue;
3696 binmin = h1->GetXaxis()->GetFirst();
3700 binmin = fXaxis->GetFirst();
3702 binx1 = fXaxis->FindFixBin(x1);
3704 if (binx1-binx>1 && fH->GetDimension() == 1) {
3705 Double_t binval=fH->GetBinContent(binx);
3707 for (Int_t ibin=binx+1; ibin<binx1; ibin++) {
3708 Double_t binvaltmp = fH->GetBinContent(ibin);
3709 if (TMath::Abs(y-binvaltmp) < TMath::Abs(y-binval)) {
3717 x1 = gPad->PadtoY(gPad->AbsPixeltoY(py+1));
3718 binx = fXaxis->FindFixBin(y);
3719 if (drawOption.Index(
"same") >= 0) {
3721 TIter next(gPad->GetListOfPrimitives());
3722 while ((h1 = (TH1 *)next())) {
3723 if (!h1->InheritsFrom(TH1::Class()))
continue;
3724 binmin = h1->GetXaxis()->GetFirst();
3728 binmin = fXaxis->GetFirst();
3730 binx1 = fXaxis->FindFixBin(x1);
3732 if (binx1-binx>1 && fH->GetDimension() == 1) {
3733 Double_t binval=fH->GetBinContent(binx);
3735 for (Int_t ibin=binx+1; ibin<binx1; ibin++) {
3736 Double_t binvaltmp = fH->GetBinContent(ibin);
3737 if (TMath::Abs(x-binvaltmp) < TMath::Abs(x-binval)) {
3745 if (fH->GetDimension() == 1) {
3746 if (fH->InheritsFrom(TProfile::Class())) {
3747 TProfile *tp = (TProfile*)fH;
3748 fObjectInfo.Form(
"(x=%g, y=%g, binx=%d, binc=%g, bine=%g, binn=%d)",
3749 x, y, binx, fH->GetBinContent(binx), fH->GetBinError(binx),
3750 (Int_t) tp->GetBinEntries(binx));
3754 for (Int_t bin=binmin;bin<=binx;bin++) {integ += fH->GetBinContent(bin);}
3755 fObjectInfo.Form(
"(x=%g, y=%g, binx=%d, binc=%g, Sum=%g)",
3756 x,y,binx,fH->GetBinContent(binx),integ);
3758 }
else if (fH->GetDimension() == 2) {
3759 if (fH->InheritsFrom(TH2Poly::Class())) {
3760 TH2Poly *th2 = (TH2Poly*)fH;
3761 biny = th2->FindBin(x,y);
3762 fObjectInfo.Form(
"%s (x=%g, y=%g, bin=%d, binc=%g)",
3763 th2->GetBinTitle(biny),x,y,biny,th2->GetBinContent(biny));
3765 else if (fH->InheritsFrom(TProfile2D::Class())) {
3766 TProfile2D *tp = (TProfile2D*)fH;
3767 biny = fYaxis->FindFixBin(y);
3768 Int_t bin = fH->GetBin(binx,biny);
3769 fObjectInfo.Form(
"(x=%g, y=%g, binx=%d, biny=%d, binc=%g, bine=%g, binn=%d)",
3770 x, y, binx, biny, fH->GetBinContent(bin),
3771 fH->GetBinError(bin), (Int_t) tp->GetBinEntries(bin));
3773 biny = fYaxis->FindFixBin(y);
3774 fObjectInfo.Form(
"(x=%g, y=%g, binx=%d, biny=%d, binc=%g bine=%g)",
3775 x,y,binx,biny,fH->GetBinContent(binx,biny),
3776 fH->GetBinError(binx,biny));
3781 fObjectInfo.Form(
"(x=%g, y=%g)",x,y);
3784 return (
char *)fObjectInfo.Data();
3790 void THistPainter::SetHighlight()
3792 if (fH->IsHighlight())
return;
3794 fXHighlightBin = -1;
3795 fYHighlightBin = -1;
3797 if (gXHighlightBox) { gXHighlightBox->Delete(); gXHighlightBox = 0; }
3798 if (gYHighlightBox) { gYHighlightBox->Delete(); gYHighlightBox = 0; }
3800 if (gPad->GetCanvas()) gPad->GetCanvas()->Highlighted(gPad, fH, fXHighlightBin, fYHighlightBin);
3806 void THistPainter::HighlightBin(Int_t px, Int_t py)
3810 Double_t x = gPad->PadtoX(gPad->AbsPixeltoX(px));
3811 Double_t y = gPad->PadtoY(gPad->AbsPixeltoY(py));
3812 Int_t binx = fXaxis->FindFixBin(x);
3813 Int_t biny = fYaxis->FindFixBin(y);
3814 if (!gPad->IsVertical()) binx = fXaxis->FindFixBin(y);
3816 Bool_t changedBin = kFALSE;
3817 if (binx != fXHighlightBin) {
3818 fXHighlightBin = binx;
3820 }
else if (fH->GetDimension() == 1)
return;
3821 if (biny != fYHighlightBin) {
3822 fYHighlightBin = biny;
3825 if (!changedBin)
return;
3831 gPad->Modified(kTRUE);
3835 if (gPad->GetCanvas()) gPad->GetCanvas()->Highlighted(gPad, fH, fXHighlightBin, fYHighlightBin);
3841 void THistPainter::PaintHighlightBin(Option_t * )
3845 if (!fH->IsHighlight())
return;
3847 Double_t uxmin = gPad->GetUxmin();
3848 Double_t uxmax = gPad->GetUxmax();
3849 Double_t uymin = gPad->GetUymin();
3850 Double_t uymax = gPad->GetUymax();
3851 if (gPad->GetLogx()) {
3852 uxmin = TMath::Power(10.0, uxmin);
3853 uxmax = TMath::Power(10.0, uxmax);
3855 if (gPad->GetLogy()) {
3856 uymin = TMath::Power(10.0, uymin);
3857 uymax = TMath::Power(10.0, uymax);
3862 if (gPad->IsVertical()) {
3863 hcenter = fXaxis->GetBinCenter(fXHighlightBin);
3864 if ((hcenter < uxmin) || (hcenter > uxmax))
return;
3866 hcenter = fYaxis->GetBinCenter(fXHighlightBin);
3867 if ((hcenter < uymin) || (hcenter > uymax))
return;
3869 if (fH->GetDimension() == 2) {
3870 hcenter = fYaxis->GetBinCenter(fYHighlightBin);
3871 if ((hcenter < uymin) || (hcenter > uymax))
return;
3875 Double_t hbx1, hbx2, hby1, hby2;
3876 if (gPad->IsVertical()) {
3877 hbx1 = fXaxis->GetBinLowEdge(fXHighlightBin);
3878 hbx2 = fXaxis->GetBinUpEdge(fXHighlightBin);
3884 hby1 = fYaxis->GetBinLowEdge(fXHighlightBin);
3885 hby2 = fYaxis->GetBinUpEdge(fXHighlightBin);
3888 if (!gXHighlightBox) {
3889 gXHighlightBox =
new TBox(hbx1, hby1, hbx2, hby2);
3890 gXHighlightBox->SetBit(kCannotPick);
3891 gXHighlightBox->SetFillColor(TColor::GetColor(
"#9797ff"));
3892 if (!TCanvas::SupportAlpha()) gXHighlightBox->SetFillStyle(3001);
3893 else gROOT->GetColor(gXHighlightBox->GetFillColor())->SetAlpha(0.5);
3895 gXHighlightBox->SetX1(hbx1);
3896 gXHighlightBox->SetX2(hbx2);
3897 gXHighlightBox->SetY1(hby1);
3898 gXHighlightBox->SetY2(hby2);
3899 gXHighlightBox->Paint();
3905 if (fH->GetDimension() != 2)
return;
3908 hby1 = fYaxis->GetBinLowEdge(fYHighlightBin);
3909 hby2 = fYaxis->GetBinUpEdge(fYHighlightBin);
3911 if (!gYHighlightBox) {
3912 gYHighlightBox =
new TBox(hbx1, hby1, hbx2, hby2);
3913 gYHighlightBox->SetBit(kCannotPick);
3914 gYHighlightBox->SetFillColor(gXHighlightBox->GetFillColor());
3915 gYHighlightBox->SetFillStyle(gXHighlightBox->GetFillStyle());
3917 gYHighlightBox->SetX1(hbx1);
3918 gYHighlightBox->SetX2(hbx2);
3919 gYHighlightBox->SetY1(hby1);
3920 gYHighlightBox->SetY2(hby2);
3921 gYHighlightBox->Paint();
3927 Bool_t THistPainter::IsInside(Int_t ix, Int_t iy)
3930 for (Int_t i=0;i<fNcuts;i++) {
3931 Double_t x = fXaxis->GetBinCenter(ix);
3932 Double_t y = fYaxis->GetBinCenter(iy);
3933 if (fCutsOpt[i] > 0) {
3934 if (!fCuts[i]->IsInside(x,y))
return kFALSE;
3936 if (fCuts[i]->IsInside(x,y))
return kFALSE;
3945 Bool_t THistPainter::IsInside(Double_t x, Double_t y)
3948 for (Int_t i=0;i<fNcuts;i++) {
3949 if (fCutsOpt[i] > 0) {
3950 if (!fCuts[i]->IsInside(x,y))
return kFALSE;
3952 if (fCuts[i]->IsInside(x,y))
return kFALSE;
3961 Int_t THistPainter::MakeChopt(Option_t *choptin)
3966 Int_t nch = strlen(choptin);
3967 strlcpy(chopt,choptin,128);
3968 Int_t hdim = fH->GetDimension();
3970 Hoption.Axis = Hoption.Bar = Hoption.Curve = Hoption.Error = 0;
3971 Hoption.Hist = Hoption.Line = Hoption.Mark = Hoption.Fill = 0;
3972 Hoption.Same = Hoption.Func = Hoption.Scat = 0;
3973 Hoption.Star = Hoption.Arrow = Hoption.Box = Hoption.Text = 0;
3974 Hoption.Char = Hoption.Color = Hoption.Contour = Hoption.Logx = 0;
3975 Hoption.Logy = Hoption.Logz = Hoption.Lego = Hoption.Surf = 0;
3976 Hoption.Off = Hoption.Tri = Hoption.Proj = Hoption.AxisPos = 0;
3977 Hoption.Spec = Hoption.Pie = Hoption.Candle = 0;
3982 Hoption.FrontBox = 1;
3983 Hoption.BackBox = 1;
3984 Hoption.System = kCARTESIAN;
3988 Hoption.MinimumZero = gStyle->GetHistMinimumZero() ? 1 : 0;
3993 for (Int_t i=0;i<nch;i++) chopt[i] = toupper(chopt[i]);
3994 if (hdim > 1) Hoption.Scat = 1;
3995 if (!nch) Hoption.Hist = 1;
3996 if (fFunctions->First()) Hoption.Func = 1;
3997 if (fH->GetSumw2N() && hdim == 1) Hoption.Error = 2;
3999 char *l1 = strstr(chopt,
"PFC");
4000 char *l2 = strstr(chopt,
"PLC");
4001 char *l3 = strstr(chopt,
"PMC");
4002 if (l1 || l2 || l3) {
4003 Int_t i = gPad->NextPaletteColor();
4004 if (l1) {memcpy(l1,
" ",3); fH->SetFillColor(i);}
4005 if (l2) {memcpy(l2,
" ",3); fH->SetLineColor(i);}
4006 if (l3) {memcpy(l3,
" ",3); fH->SetMarkerColor(i);}
4010 l = strstr(chopt,
"MIN0");
4012 Hoption.MinimumZero = 1;
4016 l = strstr(chopt,
"SPEC");
4021 l = strstr(chopt,
"BF(");
4023 if (sscanf(&l[3],
"%d",&bs) > 0) {
4032 Hoption.Spec = TMath::Max(1600,bs);
4036 l = strstr(chopt,
"GL");
4040 l = strstr(chopt,
"X+");
4042 Hoption.AxisPos = 10;
4045 l = strstr(chopt,
"Y+");
4047 Hoption.AxisPos += 1;
4050 if ((Hoption.AxisPos == 10 || Hoption.AxisPos == 1) && (nch == 2)) Hoption.Hist = 1;
4051 if (Hoption.AxisPos == 11 && nch == 4) Hoption.Hist = 1;
4053 l = strstr(chopt,
"SAMES");
4055 if (nch == 5) Hoption.Hist = 1;
4058 if (l[5] ==
'0') { Hoption.Same += 10; l[5] =
' '; }
4060 l = strstr(chopt,
"SAME");
4062 if (nch == 4) Hoption.Hist = 1;
4065 if (l[4] ==
'0') { Hoption.Same += 10; l[4] =
' '; }
4068 l = strstr(chopt,
"PIE");
4075 l = strstr(chopt,
"CANDLE");
4078 Hoption.Candle = candle.ParseOption(l);
4082 l = strstr(chopt,
"VIOLIN");
4085 Hoption.Candle = candle.ParseOption(l);
4089 l = strstr(chopt,
"LEGO");
4092 Hoption.Lego = 1; memcpy(l,
" ",4);
4093 if (l[4] ==
'1') { Hoption.Lego = 11; l[4] =
' '; }
4094 if (l[4] ==
'2') { Hoption.Lego = 12; l[4] =
' '; }
4095 if (l[4] ==
'3') { Hoption.Lego = 13; l[4] =
' '; }
4096 if (l[4] ==
'4') { Hoption.Lego = 14; l[4] =
' '; }
4097 if (l[4] ==
'9') { Hoption.Lego = 19; l[4] =
' '; }
4098 l = strstr(chopt,
"FB");
if (l) { Hoption.FrontBox = 0; memcpy(l,
" ",2); }
4099 l = strstr(chopt,
"BB");
if (l) { Hoption.BackBox = 0; memcpy(l,
" ",2); }
4100 l = strstr(chopt,
"0");
if (l) { Hoption.Zero = 1; memcpy(l,
" ",1); }
4103 l = strstr(chopt,
"SURF");
4106 Hoption.Surf = 1; memcpy(l,
" ",4);
4107 if (l[4] ==
'1') { Hoption.Surf = 11; l[4] =
' '; }
4108 if (l[4] ==
'2') { Hoption.Surf = 12; l[4] =
' '; }
4109 if (l[4] ==
'3') { Hoption.Surf = 13; l[4] =
' '; }
4110 if (l[4] ==
'4') { Hoption.Surf = 14; l[4] =
' '; }
4111 if (l[4] ==
'5') { Hoption.Surf = 15; l[4] =
' '; }
4112 if (l[4] ==
'6') { Hoption.Surf = 16; l[4] =
' '; }
4113 if (l[4] ==
'7') { Hoption.Surf = 17; l[4] =
' '; }
4114 l = strstr(chopt,
"FB");
if (l) { Hoption.FrontBox = 0; memcpy(l,
" ",2); }
4115 l = strstr(chopt,
"BB");
if (l) { Hoption.BackBox = 0; memcpy(l,
" ",2); }
4118 l = strstr(chopt,
"TF3");
4120 l = strstr(chopt,
"FB");
if (l) { Hoption.FrontBox = 0; memcpy(l,
" ",2); }
4121 l = strstr(chopt,
"BB");
if (l) { Hoption.BackBox = 0; memcpy(l,
" ",2); }
4124 l = strstr(chopt,
"ISO");
4126 l = strstr(chopt,
"FB");
if (l) { Hoption.FrontBox = 0; memcpy(l,
" ",2); }
4127 l = strstr(chopt,
"BB");
if (l) { Hoption.BackBox = 0; memcpy(l,
" ",2); }
4130 l = strstr(chopt,
"LIST");
if (l) { Hoption.List = 1; memcpy(l,
" ",4);}
4132 l = strstr(chopt,
"CONT");
4137 Hoption.Contour = 1;
4138 if (l[4] ==
'1') { Hoption.Contour = 11; l[4] =
' '; }
4139 if (l[4] ==
'2') { Hoption.Contour = 12; l[4] =
' '; }
4140 if (l[4] ==
'3') { Hoption.Contour = 13; l[4] =
' '; }
4141 if (l[4] ==
'4') { Hoption.Contour = 14; l[4] =
' '; }
4142 if (l[4] ==
'5') { Hoption.Contour = 15; l[4] =
' '; }
4147 l = strstr(chopt,
"HBAR");
4150 Hoption.Bar = 20; memcpy(l,
" ",4);
4151 if (l[4] ==
'1') { Hoption.Bar = 21; l[4] =
' '; }
4152 if (l[4] ==
'2') { Hoption.Bar = 22; l[4] =
' '; }
4153 if (l[4] ==
'3') { Hoption.Bar = 23; l[4] =
' '; }
4154 if (l[4] ==
'4') { Hoption.Bar = 24; l[4] =
' '; }
4156 l = strstr(chopt,
"BAR");
4159 Hoption.Bar = 10; memcpy(l,
" ",3);
4160 if (l[3] ==
'1') { Hoption.Bar = 11; l[3] =
' '; }
4161 if (l[3] ==
'2') { Hoption.Bar = 12; l[3] =
' '; }
4162 if (l[3] ==
'3') { Hoption.Bar = 13; l[3] =
' '; }
4163 if (l[3] ==
'4') { Hoption.Bar = 14; l[3] =
' '; }
4166 l = strstr(chopt,
"ARR" );
4172 l = strstr(chopt,
"COL");
if (l) { Hoption.Arrow = 2; memcpy(l,
" ",3); }
4173 l = strstr(chopt,
"Z");
if (l) { Hoption.Zscale = 1; memcpy(l,
" ",1); }
4178 l = strstr(chopt,
"BOX" );
4184 if (l[3] ==
'1') { Hoption.Box = 11; l[3] =
' '; }
4185 if (l[3] ==
'2') { Hoption.Box = 12; l[3] =
' '; }
4186 if (l[3] ==
'3') { Hoption.Box = 13; l[3] =
' '; }
4191 l = strstr(chopt,
"COLZ");
4198 if (l[4] ==
'2') { Hoption.Color = 3; l[4] =
' '; }
4199 l = strstr(chopt,
"0");
if (l) { Hoption.Zero = 1; memcpy(l,
" ",1); }
4200 l = strstr(chopt,
"1");
if (l) { Hoption.Color = 2; memcpy(l,
" ",1); }
4205 l = strstr(chopt,
"COL" );
4211 if (l[3] ==
'2') { Hoption.Color = 3; l[3] =
' '; }
4212 l = strstr(chopt,
"0");
if (l) { Hoption.Zero = 1; memcpy(l,
" ",1); }
4213 l = strstr(chopt,
"1");
if (l) { Hoption.Color = 2; memcpy(l,
" ",1); }
4218 l = strstr(chopt,
"CHAR");
if (l) { Hoption.Char = 1; memcpy(l,
" ",4); Hoption.Scat = 0; }
4219 l = strstr(chopt,
"FUNC");
if (l) { Hoption.Func = 2; memcpy(l,
" ",4); Hoption.Hist = 0; }
4220 l = strstr(chopt,
"HIST");
if (l) { Hoption.Hist = 2; memcpy(l,
" ",4); Hoption.Func = 0; Hoption.Error = 0;}
4221 l = strstr(chopt,
"AXIS");
if (l) { Hoption.Axis = 1; memcpy(l,
" ",4); }
4222 l = strstr(chopt,
"AXIG");
if (l) { Hoption.Axis = 2; memcpy(l,
" ",4); }
4223 l = strstr(chopt,
"SCAT");
if (l) { Hoption.Scat = 1; memcpy(l,
" ",4); }
4224 l = strstr(chopt,
"TEXT");
4227 if (sscanf(&l[4],
"%d",&angle) > 0) {
4228 if (angle < 0) angle=0;
4229 if (angle > 90) angle=90;
4230 Hoption.Text = 1000+angle;
4235 l = strstr(chopt,
"N");
4236 if (l && fH->InheritsFrom(TH2Poly::Class())) Hoption.Text += 3000;
4239 l = strstr(chopt,
"POL");
if (l) { Hoption.System = kPOLAR; memcpy(l,
" ",3); }
4240 l = strstr(chopt,
"CYL");
if (l) { Hoption.System = kCYLINDRICAL; memcpy(l,
" ",3); }
4241 l = strstr(chopt,
"SPH");
if (l) { Hoption.System = kSPHERICAL; memcpy(l,
" ",3); }
4242 l = strstr(chopt,
"PSR");
if (l) { Hoption.System = kRAPIDITY; memcpy(l,
" ",3); }
4244 l = strstr(chopt,
"TRI");
4248 Hoption.Tri = 1; memcpy(l,
" ",3);
4249 l = strstr(chopt,
"FB");
if (l) { Hoption.FrontBox = 0; memcpy(l,
" ",2); }
4250 l = strstr(chopt,
"BB");
if (l) { Hoption.BackBox = 0; memcpy(l,
" ",2); }
4251 l = strstr(chopt,
"ERR");
if (l) memcpy(l,
" ",3);
4254 l = strstr(chopt,
"AITOFF");
4256 Hoption.Proj = 1; memcpy(l,
" ",6);
4258 l = strstr(chopt,
"MERCATOR");
4260 Hoption.Proj = 2; memcpy(l,
" ",8);
4262 l = strstr(chopt,
"SINUSOIDAL");
4264 Hoption.Proj = 3; memcpy(l,
" ",10);
4266 l = strstr(chopt,
"PARABOLIC");
4268 Hoption.Proj = 4; memcpy(l,
" ",9);
4270 if (Hoption.Proj > 0) {
4272 Hoption.Contour = 14;
4275 if (strstr(chopt,
"A")) Hoption.Axis = -1;
4276 if (strstr(chopt,
"B")) Hoption.Bar = 1;
4277 if (strstr(chopt,
"C") && !strstr(chopt,
"CJUST")) { Hoption.Curve =1; Hoption.Hist = -1;}
4278 if (strstr(chopt,
"F")) Hoption.Fill =1;
4279 if (strstr(chopt,
"][")) {Hoption.Off =1; Hoption.Hist =1;}
4280 if (strstr(chopt,
"F2")) Hoption.Fill =2;
4281 if (strstr(chopt,
"L")) { Hoption.Line =1; Hoption.Hist = -1;}
4282 if (strstr(chopt,
"P")) { Hoption.Mark =1; Hoption.Hist = -1;}
4283 if (strstr(chopt,
"Z")) Hoption.Zscale =1;
4284 if (strstr(chopt,
"*")) Hoption.Star =1;
4285 if (strstr(chopt,
"H")) Hoption.Hist =2;
4286 if (strstr(chopt,
"P0")) Hoption.Mark =10;
4288 if (fH->InheritsFrom(TH2Poly::Class())) {
4289 if (Hoption.Fill+Hoption.Line+Hoption.Mark != 0 ) Hoption.Scat = 0;
4292 if (strstr(chopt,
"E")) {
4295 if (strstr(chopt,
"E0")) Hoption.Error = 10;
4296 if (strstr(chopt,
"E1")) Hoption.Error = 11;
4297 if (strstr(chopt,
"E2")) Hoption.Error = 12;
4298 if (strstr(chopt,
"E3")) Hoption.Error = 13;
4299 if (strstr(chopt,
"E4")) Hoption.Error = 14;
4300 if (strstr(chopt,
"E5")) Hoption.Error = 15;
4301 if (strstr(chopt,
"E6")) Hoption.Error = 16;
4302 if (strstr(chopt,
"X0")) {
4303 if (Hoption.Error == 1) Hoption.Error += 20;
4304 Hoption.Error += 10;
4306 if (Hoption.Text && fH->InheritsFrom(TProfile::Class())) {
4307 Hoption.Text += 2000;
4311 if (Hoption.Error == 0) {
4312 Hoption.Error = 100;
4316 Hoption.Text += 2000;
4322 if (Hoption.Surf == 15) {
4323 if (Hoption.System == kPOLAR || Hoption.System == kCARTESIAN) {
4325 Warning(
"MakeChopt",
"option SURF5 is not supported in Cartesian and Polar modes");
4330 Hoption.Logx = gPad->GetLogx();
4331 Hoption.Logy = gPad->GetLogy();
4332 Hoption.Logz = gPad->GetLogz();
4335 if (Hoption.Bar == 1) Hoption.Hist = -1;
4342 Int_t THistPainter::MakeCuts(
char *choptin)
4346 char *left = (
char*)strchr(choptin,
'[');
4347 if (!left)
return 0;
4348 char *right = (
char*)strchr(choptin,
']');
4349 if (!right)
return 0;
4350 Int_t nch = right-left;
4351 if (nch < 2)
return 0;
4352 char *cuts = left+1;
4354 char *comma, *minus;
4357 comma = strchr(cuts,
',');
4358 if (comma) *comma = 0;
4359 minus = strchr(cuts,
'-');
4360 if (minus) cuts = minus+1;
4361 while (*cuts ==
' ') cuts++;
4362 Int_t nc = strlen(cuts);
4363 while (cuts[nc-1] ==
' ') {cuts[nc-1] = 0; nc--;}
4364 TIter next(gROOT->GetListOfSpecials());
4367 while ((obj = next())) {
4368 if (!obj->InheritsFrom(TCutG::Class()))
continue;
4369 if (strcmp(obj->GetName(),cuts))
continue;
4374 fCuts[fNcuts] = cut;
4375 fCutsOpt[fNcuts] = 1;
4376 if (minus) fCutsOpt[fNcuts] = -1;
4382 for (i=0;i<=nch;i++) left[i] =
' ';
4389 void THistPainter::Paint(Option_t *option)
4392 if (fH->GetBuffer()) fH->BufferEmpty(-1);
4395 const TPickerStackGuard topPush(fH);
4397 gPad->SetVertical(kTRUE);
4399 TH1 *oldhist = gCurrentHist;
4402 Double_t minsav = fH->GetMinimumStored();
4404 if (!MakeChopt(option))
return;
4408 if (!TableInit())
return;
4409 if (!TClass::GetClass(
"TSpectrum2Painter")) gSystem->Load(
"libSpectrumPainter");
4410 gROOT->ProcessLineFast(Form(
"TSpectrum2Painter::PaintSpectrum((TH2F*)0x%lx,\"%s\",%d)",
4411 (ULong_t)fH, option, Hoption.Spec));
4416 if (fH->GetDimension() == 1) {
4417 if (!fPie) fPie =
new TPie(fH);
4418 fPie->Paint(option);
4420 Error(
"Paint",
"Option PIE is for 1D histograms only");
4424 if (fPie)
delete fPie;
4428 fXbuf =
new Double_t[kNMAX];
4429 fYbuf =
new Double_t[kNMAX];
4430 if (fH->GetDimension() > 2) {
4432 fH->SetMinimum(minsav);
4434 Hoption_t hoptsave = Hoption;
4435 Hparam_t hparsave = Hparam;
4436 PaintFunction(option);
4437 SetHistogram(hsave);
4441 gCurrentHist = oldhist;
4442 delete [] fXbuf;
delete [] fYbuf;
4445 TView *view = gPad->GetView();
4447 if (!Hoption.Lego && !Hoption.Surf && !Hoption.Tri) {
4452 if (fH->GetDimension() > 1 || Hoption.Lego || Hoption.Surf) {
4454 Int_t logysav=0, logzsav=0;
4455 if (fH->GetDimension() == 1) {
4456 logysav = Hoption.Logy;
4457 logzsav = Hoption.Logz;
4466 Hoption_t hoptsave = Hoption;
4467 Hparam_t hparsave = Hparam;
4468 PaintFunction(option);
4469 SetHistogram(hsave);
4473 fH->SetMinimum(minsav);
4474 gCurrentHist = oldhist;
4475 delete [] fXbuf;
delete [] fYbuf;
4476 if (fH->GetDimension() == 1) {
4477 Hoption.Logy = logysav;
4478 Hoption.Logz = logzsav;
4483 if (Hoption.Bar >= 20) {
4485 delete [] fXbuf;
delete [] fYbuf;
4491 delete [] fXbuf;
delete [] fYbuf;
4500 Bool_t gridx = gPad->GetGridx();
4501 Bool_t gridy = gPad->GetGridy();
4502 if (Hoption.Axis > 0) {
4503 if (Hoption.Axis > 1) PaintAxis(kTRUE);
4505 if (gridx) gPad->SetGridx(0);
4506 if (gridy) gPad->SetGridy(0);
4508 if (gridx) gPad->SetGridx(1);
4509 if (gridy) gPad->SetGridy(1);
4511 if ((Hoption.Same%10) ==1) Hoption.Same += 1;
4514 if (gridx || gridy) PaintAxis(kTRUE);
4517 if (Hoption.Bar >= 10) {
4522 if (!Hoption.Error) {
4523 if (Hoption.Hist && Hoption.Bar<10) PaintHist(option);
4527 if (Hoption.Error) {
4528 PaintErrors(option);
4529 if (Hoption.Hist == 2) PaintHist(option);
4532 if (Hoption.Text) PaintText(option);
4536 Hoption_t hoptsave = Hoption;
4537 Hparam_t hparsave = Hparam;
4538 PaintFunction(option);
4539 SetHistogram(hsave);
4544 if (gridx) gPad->SetGridx(0);
4545 if (gridy) gPad->SetGridy(0);
4547 if (gridx) gPad->SetGridx(1);
4548 if (gridy) gPad->SetGridy(1);
4554 if ((Hoption.Same%10) != 1 && !fH->TestBit(TH1::kNoStats)) {
4555 TIter next(fFunctions);
4557 while ((obj = next())) {
4558 if (obj->InheritsFrom(TF1::Class()))
break;
4565 if (!gPad->PadInSelectionMode() && !gPad->PadInHighlightMode())
4566 PaintStat(gStyle->GetOptStat(),(TF1*)obj);
4568 fH->SetMinimum(minsav);
4569 gCurrentHist = oldhist;
4570 delete [] fXbuf; fXbuf = 0;
4571 delete [] fYbuf; fYbuf = 0;
4578 void THistPainter::PaintArrows(Option_t *)
4580 Double_t xk, xstep, yk, ystep;
4581 Double_t dx, dy, x1, x2, y1, y2, xc, yc, dxn, dyn;
4582 Int_t ncx = Hparam.xlast - Hparam.xfirst + 1;
4583 Int_t ncy = Hparam.ylast - Hparam.yfirst + 1;
4584 Double_t xrg = gPad->GetUxmin();
4585 Double_t yrg = gPad->GetUymin();
4586 Double_t xln = gPad->GetUxmax() - xrg;
4587 Double_t yln = gPad->GetUymax() - yrg;
4588 Double_t cx = (xln/Double_t(ncx) -0.03)/2;
4589 Double_t cy = (yln/Double_t(ncy) -0.03)/2;
4590 Double_t dn = 1.E-30;
4592 auto arrow =
new TArrow();
4593 arrow->SetAngle(30);
4594 arrow->SetFillStyle(1001);
4595 arrow->SetFillColor(fH->GetLineColor());
4596 arrow->SetLineColor(fH->GetLineColor());
4597 arrow->SetLineWidth(fH->GetLineWidth());
4600 Int_t ncolors=0, ndivz=0;
4602 if (Hoption.Arrow>1) {
4603 ncolors = gStyle->GetNumberOfColors();
4604 Int_t ndiv = fH->GetContour();
4606 ndiv = gStyle->GetNumberContours();
4607 fH->SetContour(ndiv);
4609 ndivz = TMath::Abs(ndiv);
4610 if (fH->TestBit(TH1::kUserContour) == 0) fH->SetContour(ndiv);
4611 scale = ndivz/(fH->GetMaximum()-fH->GetMinimum());
4614 for (Int_t
id=1;
id<=2;
id++) {
4615 for (Int_t j=Hparam.yfirst; j<=Hparam.ylast;j++) {
4616 yk = fYaxis->GetBinLowEdge(j);
4617 ystep = fYaxis->GetBinWidth(j);
4618 for (Int_t i=Hparam.xfirst; i<=Hparam.xlast;i++) {
4619 xk = fXaxis->GetBinLowEdge(i);
4620 xstep = fXaxis->GetBinWidth(i);
4621 if (!IsInside(xk+0.5*xstep,yk+0.5*ystep))
continue;
4622 if (i == Hparam.xfirst) {
4623 dx = fH->GetBinContent(i+1, j) - fH->GetBinContent(i, j);
4624 }
else if (i == Hparam.xlast) {
4625 dx = fH->GetBinContent(i, j) - fH->GetBinContent(i-1, j);
4627 dx = 0.5*(fH->GetBinContent(i+1, j) - fH->GetBinContent(i-1, j));
4629 if (j == Hparam.yfirst) {
4630 dy = fH->GetBinContent(i, j+1) - fH->GetBinContent(i, j);
4631 }
else if (j == Hparam.ylast) {
4632 dy = fH->GetBinContent(i, j) - fH->GetBinContent(i, j-1);
4634 dy = 0.5*(fH->GetBinContent(i, j+1) - fH->GetBinContent(i, j-1));
4637 dn = TMath::Max(dn, TMath::Abs(dx));
4638 dn = TMath::Max(dn, TMath::Abs(dy));
4639 }
else if (
id == 2) {
4640 xc = xrg + xln*(Double_t(i - Hparam.xfirst+1)-0.5)/Double_t(ncx);
4644 yc = yrg + yln*(Double_t(j - Hparam.yfirst+1)-0.5)/Double_t(ncy);
4648 if (Hoption.Arrow>1) {
4649 int color = Int_t(0.01+(fH->GetBinContent(i, j)-fH->GetMinimum())*scale);
4650 Int_t theColor = Int_t((color+0.99)*Float_t(ncolors)/Float_t(ndivz));
4651 if (theColor > ncolors-1) theColor = ncolors-1;
4652 arrow->SetFillColor(gStyle->GetColorPalette(theColor));
4653 arrow->SetLineColor(gStyle->GetColorPalette(theColor));
4655 if (TMath::Abs(x2-x1) > 0. || TMath::Abs(y2-y1) > 0.) {
4656 arrow->PaintArrow(x1, y1, x2, y2, 0.015,
"|>");
4658 arrow->PaintArrow(x1, y1, x2, y2, 0.005,
"|>");
4665 if (Hoption.Zscale) PaintPalette();
4676 void THistPainter::PaintAxis(Bool_t drawGridOnly)
4681 if (drawGridOnly && (gPad->PadInHighlightMode() || gPad->PadInSelectionMode()))
4684 if (Hoption.Axis == -1)
return;
4685 if (Hoption.Same && Hoption.Axis <= 0)
return;
4691 if (Hoption.Same && Hoption.Axis) {
4692 if (fXaxis->GetLabels() || fYaxis->GetLabels()) {
4693 TIter next(gPad->GetListOfPrimitives());
4696 while ((obj = next())) {
4697 if (!obj->InheritsFrom(TH1::Class()) &&
4698 !obj->InheritsFrom(THStack::Class()))
continue;
4699 TString opt = obj->GetDrawOption();
4702 if (strstr(opt,
"hbar")) {
4703 gPad->SetVertical(kFALSE);
4706 if (!strcmp(xaxis->GetName(),
"xaxis")) {
4716 static char chopt[10] =
"";
4718 Int_t ndiv, ndivx, ndivy, nx1, nx2, ndivsave;
4719 Int_t useHparam = 0;
4720 Double_t umin, umax, uminsave, umaxsave;
4721 Short_t xAxisPos = Hoption.AxisPos/10;
4722 Short_t yAxisPos = Hoption.AxisPos - 10*xAxisPos;
4724 Double_t axmin = gPad->GetUxmin();
4725 Double_t axmax = gPad->GetUxmax();
4726 Double_t aymin = gPad->GetUymin();
4727 Double_t aymax = gPad->GetUymax();
4733 if (Hoption.Contour == 14) useHparam = 1;
4736 TIter next(gPad->GetListOfPrimitives());
4737 while ((obj=next())) {
4738 if (strstr(obj->GetDrawOption(),
"cont4")) {
4748 if (gPad->PadInSelectionMode())
4749 gPad->PushSelectableObject(fXaxis);
4752 if (gPad->PadInSelectionMode() || !gPad->PadInHighlightMode() || (gPad->PadInHighlightMode() && gPad->GetSelected() == fXaxis)) {
4753 ndivx = fXaxis->GetNdivisions();
4756 nx1 = TMath::Max(1, ndivx%100);
4757 ndivx = 100*nx2 + Int_t(Float_t(nx1)*gPad->GetAbsWNDC());
4759 axis.SetTextAngle(0);
4760 axis.ImportAxisAttributes(fXaxis);
4763 strlcat(chopt,
"SDH",10);
4764 if (ndivx < 0) strlcat(chopt,
"N",10);
4765 if (gPad->GetGridx()) {
4766 gridl = (aymax-aymin)/(gPad->GetY2() - gPad->GetY1());
4767 strlcat(chopt,
"W",10);
4772 strlcat(chopt,
"G",10);
4773 ndiv = TMath::Abs(ndivx);
4775 umin = TMath::Power(10,Hparam.xmin);
4776 umax = TMath::Power(10,Hparam.xmax);
4778 umin = TMath::Power(10,axmin);
4779 umax = TMath::Power(10,axmax);
4782 ndiv = TMath::Abs(ndivx);
4793 if (fXaxis->GetTimeDisplay()) {
4794 strlcat(chopt,
"t",10);
4795 if (strlen(fXaxis->GetTimeFormatOnly()) == 0) {
4796 axis.SetTimeFormat(fXaxis->ChooseTimeFormat(Hparam.xmax-Hparam.xmin));
4801 Double_t xAxisYPos1, xAxisYPos2;
4802 if (xAxisPos == 1) {
4816 axis.SetOption(chopt);
4818 strlcat(chopt,
"-",10);
4821 if (Hoption.Same && Hoption.Axis) {
4822 axis.SetLabelSize(0.);
4825 axis.PaintAxis(axmin, xAxisYPos1,
4827 umin, umax, ndiv, chopt, gridl, drawGridOnly);
4832 if (gPad->GetTickx() && !gPad->PadInSelectionMode() && !gPad->PadInHighlightMode()) {
4834 cw=strstr(chopt,
"-");
4837 strlcat(chopt,
"-",10);
4839 if (gPad->GetTickx() < 2) strlcat(chopt,
"U",10);
4840 if ((cw=strstr(chopt,
"W"))) *cw=
'z';
4842 axis.PaintAxis(axmin, xAxisYPos2,
4844 uminsave, umaxsave, ndivsave, chopt, gridl, drawGridOnly);
4850 if (gPad->PadInSelectionMode())
4851 gPad->PushSelectableObject(fYaxis);
4854 if (gPad->PadInSelectionMode() || !gPad->PadInHighlightMode() || (gPad->PadInHighlightMode() && gPad->GetSelected() == fYaxis)) {
4855 ndivy = fYaxis->GetNdivisions();
4856 axis.ImportAxisAttributes(fYaxis);
4859 strlcat(chopt,
"SDH",10);
4860 if (ndivy < 0) strlcat(chopt,
"N",10);
4861 if (gPad->GetGridy()) {
4862 gridl = (axmax-axmin)/(gPad->GetX2() - gPad->GetX1());
4863 strlcat(chopt,
"W",10);
4868 strlcat(chopt,
"G",10);
4869 ndiv = TMath::Abs(ndivy);
4871 umin = TMath::Power(10,Hparam.ymin);
4872 umax = TMath::Power(10,Hparam.ymax);
4874 umin = TMath::Power(10,aymin);
4875 umax = TMath::Power(10,aymax);
4878 ndiv = TMath::Abs(ndivy);
4889 if (fYaxis->GetTimeDisplay()) {
4890 strlcat(chopt,
"t",10);
4891 if (strlen(fYaxis->GetTimeFormatOnly()) == 0) {
4892 axis.SetTimeFormat(fYaxis->ChooseTimeFormat(Hparam.ymax-Hparam.ymin));
4897 Double_t yAxisXPos1, yAxisXPos2;
4898 if (yAxisPos == 1) {
4912 axis.SetOption(chopt);
4914 strlcat(chopt,
"+L",10);
4917 if (Hoption.Same && Hoption.Axis) {
4918 axis.SetLabelSize(0.);
4921 axis.PaintAxis(yAxisXPos1, aymin,
4923 umin, umax, ndiv, chopt, gridl, drawGridOnly);
4928 if (gPad->GetTicky() && !gPad->PadInSelectionMode() && !gPad->PadInHighlightMode()) {
4929 if (gPad->GetTicky() < 2) {
4930 strlcat(chopt,
"U",10);
4931 axis.SetTickSize(-fYaxis->GetTickLength());
4933 strlcat(chopt,
"+L",10);
4935 if ((cw=strstr(chopt,
"W"))) *cw=
'z';
4937 axis.PaintAxis(yAxisXPos2, aymin,
4939 uminsave, umaxsave, ndivsave, chopt, gridl, drawGridOnly);
4953 void THistPainter::PaintBar(Option_t *)
4956 Int_t bar = Hoption.Bar - 10;
4957 Double_t xmin,xmax,ymin,ymax,umin,umax,w,y;
4958 Double_t offset = fH->GetBarOffset();
4959 Double_t width = fH->GetBarWidth();
4961 Int_t hcolor = fH->GetFillColor();
4962 if (hcolor == gPad->GetFrameFillColor()) ++hcolor;
4963 Int_t hstyle = fH->GetFillStyle();
4964 box.SetFillColor(hcolor);
4965 box.SetFillStyle(hstyle);
4966 box.SetLineStyle(fH->GetLineStyle());
4967 box.SetLineColor(fH->GetLineColor());
4968 box.SetLineWidth(fH->GetLineWidth());
4969 for (Int_t bin=fXaxis->GetFirst();bin<=fXaxis->GetLast();bin++) {
4970 y = fH->GetBinContent(bin);
4971 xmin = gPad->XtoPad(fXaxis->GetBinLowEdge(bin));
4972 xmax = gPad->XtoPad(fXaxis->GetBinUpEdge(bin));
4973 ymin = gPad->GetUymin();
4974 ymax = gPad->YtoPad(y);
4975 if (ymax < gPad->GetUymin())
continue;
4976 if (ymax > gPad->GetUymax()) ymax = gPad->GetUymax();
4977 if (ymin < gPad->GetUymin()) ymin = gPad->GetUymin();
4978 if (Hoption.MinimumZero && ymin < 0)
4979 ymin=TMath::Min(0.,gPad->GetUymax());
4980 w = (xmax-xmin)*width;
4981 xmin += offset*(xmax-xmin);
4984 box.PaintBox(xmin,ymin,xmax,ymax);
4986 umin = xmin + bar*(xmax-xmin)/10.;
4987 umax = xmax - bar*(xmax-xmin)/10.;
4989 box.SetFillColor(TColor::GetColorBright(hcolor));
4990 box.PaintBox(xmin,ymin,umin,ymax);
4991 box.SetFillColor(hcolor);
4992 box.PaintBox(umin,ymin,umax,ymax);
4993 box.SetFillColor(TColor::GetColorDark(hcolor));
4994 box.PaintBox(umax,ymin,xmax,ymax);
5002 void THistPainter::PaintBarH(Option_t *)
5005 gPad->SetVertical(kFALSE);
5009 TAxis *xaxis = fXaxis;
5010 TAxis *yaxis = fYaxis;
5011 if (!strcmp(xaxis->GetName(),
"xaxis")) {
5019 Int_t bar = Hoption.Bar - 20;
5020 Double_t xmin,xmax,ymin,ymax,umin,umax,w;
5021 Double_t offset = fH->GetBarOffset();
5022 Double_t width = fH->GetBarWidth();
5024 Int_t hcolor = fH->GetFillColor();
5025 if (hcolor == gPad->GetFrameFillColor()) ++hcolor;
5026 Int_t hstyle = fH->GetFillStyle();
5027 box.SetFillColor(hcolor);
5028 box.SetFillStyle(hstyle);
5029 box.SetLineStyle(fH->GetLineStyle());
5030 box.SetLineColor(fH->GetLineColor());
5031 box.SetLineWidth(fH->GetLineWidth());
5032 for (Int_t bin=fYaxis->GetFirst();bin<=fYaxis->GetLast();bin++) {
5033 ymin = gPad->YtoPad(fYaxis->GetBinLowEdge(bin));
5034 ymax = gPad->YtoPad(fYaxis->GetBinUpEdge(bin));
5035 xmin = gPad->GetUxmin();
5036 xmax = gPad->XtoPad(fH->GetBinContent(bin));
5037 if (xmax < gPad->GetUxmin())
continue;
5038 if (xmax > gPad->GetUxmax()) xmax = gPad->GetUxmax();
5039 if (xmin < gPad->GetUxmin()) xmin = gPad->GetUxmin();
5040 if (Hoption.MinimumZero && xmin < 0)
5041 xmin=TMath::Min(0.,gPad->GetUxmax());
5042 w = (ymax-ymin)*width;
5043 ymin += offset*(ymax-ymin);
5046 box.PaintBox(xmin,ymin,xmax,ymax);
5048 umin = ymin + bar*(ymax-ymin)/10.;
5049 umax = ymax - bar*(ymax-ymin)/10.;
5050 box.SetFillColor(TColor::GetColorDark(hcolor));
5051 box.PaintBox(xmin,ymin,xmax,umin);
5052 box.SetFillColor(hcolor);
5053 box.PaintBox(xmin,umin,xmax,umax);
5054 box.SetFillColor(TColor::GetColorBright(hcolor));
5055 box.PaintBox(xmin,umax,xmax,ymax);
5062 if ((Hoption.Same%10) != 1 && !fH->TestBit(TH1::kNoStats)) {
5063 TIter next(fFunctions);
5065 while ((obj = next())) {
5066 if (obj->InheritsFrom(TF1::Class()))
break;
5069 PaintStat(gStyle->GetOptStat(),(TF1*)obj);
5079 void THistPainter::PaintBoxes(Option_t *)
5082 Style_t fillsav = fH->GetFillStyle();
5083 Style_t colsav = fH->GetFillColor();
5084 if (fH->GetFillColor() == 0) fH->SetFillStyle(0);
5085 if (Hoption.Box == 11) fH->SetFillStyle(1001);
5086 fH->TAttLine::Modify();
5087 fH->TAttFill::Modify();
5089 Double_t z, xk,xstep, yk, ystep, xcent, ycent, xlow, xup, ylow, yup;
5090 Double_t ux1 = gPad->PixeltoX(1);
5091 Double_t ux0 = gPad->PixeltoX(0);
5092 Double_t uy1 = gPad->PixeltoY(1);
5093 Double_t uy0 = gPad->PixeltoY(0);
5094 Double_t dxmin = 0.51*(gPad->PadtoX(ux1)-gPad->PadtoX(ux0));
5095 Double_t dymin = 0.51*(gPad->PadtoY(uy0)-gPad->PadtoY(uy1));
5097 Double_t zmin = TMath::Max(fH->GetMinimum(),0.);
5098 Double_t zmax = TMath::Max(TMath::Abs(fH->GetMaximum()),
5099 TMath::Abs(fH->GetMinimum()));
5100 Double_t zminlin = zmin, zmaxlin = zmax;
5104 if (Hoption.Same > 0 && Hoption.Same < 10) {
5106 TIter next(gPad->GetListOfPrimitives());
5107 while ((h2 = (TH2 *)next())) {
5108 if (!h2->InheritsFrom(TH2::Class()))
continue;
5109 zmin = TMath::Max(h2->GetMinimum(), 0.);
5110 zmax = TMath::Max(TMath::Abs(h2->GetMaximum()),
5111 TMath::Abs(h2->GetMinimum()));
5116 zmin = TMath::Log10(zmax*0.001);
5118 zmin = TMath::Log10(zmin);
5120 zmax = TMath::Log10(zmax);
5127 zmin = TMath::Log10(zmin);
5128 zmax = TMath::Log10(zmax);
5135 Double_t zratio, dz = zmax - zmin;
5136 Bool_t kZminNeg = kFALSE;
5137 if (fH->GetMinimum()<0) kZminNeg = kTRUE;
5138 Bool_t kZNeg = kFALSE;
5141 Color_t color = fH->GetFillColor();
5142 Color_t light=0, dark=0;
5143 if (Hoption.Box == 11) {
5144 light = TColor::GetColorBright(color);
5145 dark = TColor::GetColorDark(color);
5149 for (Int_t j=Hparam.yfirst; j<=Hparam.ylast;j++) {
5150 yk = fYaxis->GetBinLowEdge(j);
5151 ystep = fYaxis->GetBinWidth(j);
5153 for (Int_t i=Hparam.xfirst; i<=Hparam.xlast;i++) {
5154 Int_t bin = j*(fXaxis->GetNbins()+2) + i;
5155 xk = fXaxis->GetBinLowEdge(i);
5156 xstep = fXaxis->GetBinWidth(i);
5157 if (!IsInside(xk+0.5*xstep,yk+0.5*ystep))
continue;
5159 z = Hparam.factor*fH->GetBinContent(bin);
5162 if (TMath::Abs(z) < zminlin)
continue;
5163 if (TMath::Abs(z) > zmaxlin) z = zmaxlin;
5164 if (kZminNeg && z==0)
continue;
5167 if (Hoption.Logz)
continue;
5172 if (z != 0) z = TMath::Log10(z);
5176 if (dz == 0)
continue;
5177 zratio = TMath::Sqrt((z-zmin)/dz);
5178 if (zratio == 0)
continue;
5180 xup = xcent*zratio + xk + xcent;
5181 xlow = 2*(xk + xcent) - xup;
5182 if (xup-xlow < dxmin) xup = xlow+dxmin;
5184 if (xup > 0) xup = TMath::Log10(xup);
5186 if (xlow > 0) xlow = TMath::Log10(xlow);
5190 yup = ycent*zratio + yk + ycent;
5191 ylow = 2*(yk + ycent) - yup;
5192 if (yup-ylow < dymin) yup = ylow+dymin;
5194 if (yup > 0) yup = TMath::Log10(yup);
5196 if (ylow > 0) ylow = TMath::Log10(ylow);
5200 xlow = TMath::Max(xlow, gPad->GetUxmin());
5201 ylow = TMath::Max(ylow, gPad->GetUymin());
5202 xup = TMath::Min(xup , gPad->GetUxmax());
5203 yup = TMath::Min(yup , gPad->GetUymax());
5205 if (xlow >= xup)
continue;
5206 if (ylow >= yup)
continue;
5208 if (Hoption.Box == 1) {
5209 fH->SetFillColor(color);
5210 fH->TAttFill::Modify();
5211 gPad->PaintBox(xlow, ylow, xup, yup);
5213 gPad->PaintLine(xlow, ylow, xup, yup);
5214 gPad->PaintLine(xlow, yup, xup, ylow);
5216 }
else if (Hoption.Box == 11) {
5218 fH->SetFillColor(color);
5219 fH->TAttFill::Modify();
5220 gPad->PaintBox(xlow, ylow, xup, yup);
5223 Double_t x[7], y[7];
5224 Double_t bwidth = 0.1;
5225 x[0] = xlow; y[0] = ylow;
5226 x[1] = xlow + bwidth*(xup-xlow); y[1] = ylow + bwidth*(yup-ylow);
5227 x[2] = x[1]; y[2] = yup - bwidth*(yup-ylow);
5228 x[3] = xup - bwidth*(xup-xlow); y[3] = y[2];
5229 x[4] = xup; y[4] = yup;
5230 x[5] = xlow; y[5] = yup;
5231 x[6] = xlow; y[6] = ylow;
5232 if (kZNeg) fH->SetFillColor(dark);
5233 else fH->SetFillColor(light);
5234 fH->TAttFill::Modify();
5235 gPad->PaintFillArea(7, x, y);
5238 x[0] = xlow; y[0] = ylow;
5239 x[1] = xlow + bwidth*(xup-xlow); y[1] = ylow + bwidth*(yup-ylow);
5240 x[2] = xup - bwidth*(xup-xlow); y[2] = y[1];
5241 x[3] = x[2]; y[3] = yup - bwidth*(yup-ylow);
5242 x[4] = xup; y[4] = yup;
5243 x[5] = xup; y[5] = ylow;
5244 x[6] = xlow; y[6] = ylow;
5245 if (kZNeg) fH->SetFillColor(light);
5246 else fH->SetFillColor(dark);
5247 fH->TAttFill::Modify();
5248 gPad->PaintFillArea(7, x, y);
5253 if (Hoption.Zscale) PaintPalette();
5254 fH->SetFillStyle(fillsav);
5255 fH->SetFillColor(colsav);
5256 fH->TAttFill::Modify();
5264 void THistPainter::PaintCandlePlot(Option_t *)
5267 TH2D *h2 = (TH2D*)fH;
5270 myCandle.SetOption((TCandle::CandleOption)Hoption.Candle);
5271 myCandle.SetMarkerColor(fH->GetLineColor());
5272 myCandle.SetLineColor(fH->GetLineColor());
5273 myCandle.SetLineWidth(fH->GetLineWidth());
5274 myCandle.SetFillColor(fH->GetFillColor());
5275 myCandle.SetFillStyle(fH->GetFillStyle());
5276 myCandle.SetMarkerSize(fH->GetMarkerSize());
5277 myCandle.SetMarkerStyle(fH->GetMarkerStyle());
5278 myCandle.SetLog(Hoption.Logx,Hoption.Logy, Hoption.Logz);
5280 Bool_t swapXY = myCandle.IsHorizontal();
5281 const Double_t standardCandleWidth = 0.66;
5282 const Double_t standardHistoWidth = 0.8;
5284 double allMaxContent = h2->GetBinContent(h2->GetMaximumBin());
5285 double allMaxIntegral = 0;
5289 for (Int_t i=Hparam.xfirst; i<=Hparam.xlast; i++) {
5290 hproj = h2->ProjectionY(
"_px", i, i);
5291 if (hproj->Integral() > allMaxIntegral) allMaxIntegral = hproj->Integral();
5293 for (Int_t i=Hparam.xfirst; i<=Hparam.xlast; i++) {
5294 Double_t binPosX = fXaxis->GetBinLowEdge(i);
5295 Double_t binWidth = fXaxis->GetBinWidth(i);
5296 hproj = h2->ProjectionY(
"_px", i, i);
5297 if (hproj->GetEntries() !=0) {
5298 Double_t candleWidth = fH->GetBarWidth();
5299 Double_t offset = fH->GetBarOffset()*binWidth;
5300 double myMaxContent = hproj->GetBinContent(hproj->GetMaximumBin());
5301 double myIntegral = hproj->Integral();
5302 Double_t histoWidth = candleWidth;
5303 if (candleWidth > 0.999 && candleWidth < 1.001) {
5304 candleWidth = standardCandleWidth;
5305 histoWidth = standardHistoWidth;
5307 if (Hoption.Logz && myMaxContent > 0) {
5308 histoWidth *= myMaxContent/TMath::Log10(myMaxContent);
5309 if (myCandle.IsViolinScaled() && myMaxContent > 0 && allMaxContent > 0) histoWidth *= TMath::Log10(myMaxContent)/TMath::Log10(allMaxContent);
5310 }
else if (myCandle.IsViolinScaled()) histoWidth *= myMaxContent/allMaxContent;
5311 if (myCandle.IsCandleScaled()) candleWidth *= myIntegral/allMaxIntegral;
5313 myCandle.SetAxisPosition(binPosX+binWidth/2. + offset);
5314 myCandle.SetCandleWidth(candleWidth*binWidth);
5315 myCandle.SetHistoWidth(histoWidth*binWidth);
5316 myCandle.SetHistogram(hproj);
5322 for (Int_t i=Hparam.yfirst; i<=Hparam.ylast; i++) {
5323 hproj = h2->ProjectionX(
"_py", i, i);
5324 if (hproj->Integral() > allMaxIntegral) allMaxIntegral = hproj->Integral();
5326 for (Int_t i=Hparam.yfirst; i<=Hparam.ylast; i++) {
5327 Double_t binPosY = fYaxis->GetBinLowEdge(i);
5328 Double_t binWidth = fYaxis->GetBinWidth(i);
5329 hproj = h2->ProjectionX(
"_py", i, i);
5330 if (hproj->GetEntries() !=0) {
5331 Double_t candleWidth = fH->GetBarWidth();
5332 Double_t offset = fH->GetBarOffset()*binWidth;
5333 double myMaxContent = hproj->GetBinContent(hproj->GetMaximumBin());
5334 double myIntegral = hproj->Integral();
5335 Double_t histoWidth = candleWidth;
5336 if (candleWidth > 0.999 && candleWidth < 1.001) {
5337 candleWidth = standardCandleWidth;
5338 histoWidth = standardHistoWidth;
5340 if (Hoption.Logz && myMaxContent > 0) {
5341 histoWidth *= myMaxContent/TMath::Log10(myMaxContent);
5342 if (myCandle.IsViolinScaled() && myMaxContent > 0 && allMaxContent > 0) histoWidth *= TMath::Log10(myMaxContent)/TMath::Log10(allMaxContent);
5343 }
else if (myCandle.IsViolinScaled()) histoWidth *= myMaxContent/allMaxContent;
5344 if (myCandle.IsCandleScaled()) candleWidth *= myIntegral/allMaxIntegral;
5346 myCandle.SetAxisPosition(binPosY+binWidth/2. + offset);
5347 myCandle.SetCandleWidth(candleWidth*binWidth);
5348 myCandle.SetHistoWidth(histoWidth*binWidth);
5349 myCandle.SetHistogram(hproj);
5372 std::vector<THistRenderingRegion>
5373 THistPainter::ComputeRenderingRegions(TAxis* pAxis, Int_t nPixels, Bool_t isLog)
5375 std::vector<THistRenderingRegion> regions;
5377 enum STRATEGY { Bins, Pixels } strategy;
5379 Int_t nBins = (pAxis->GetLast() - pAxis->GetFirst() + 1);
5381 if (nBins >= nPixels) {
5391 Double_t xMin = pAxis->GetBinLowEdge(pAxis->GetFirst());
5393 while (xMin <= 0 && ((pAxis->GetFirst()+binOffset) != pAxis->GetLast()) ) {
5395 xMin = pAxis->GetBinLowEdge(pAxis->GetFirst()+binOffset);
5401 Double_t xMax = pAxis->GetBinUpEdge(pAxis->GetLast());
5403 if (strategy == Bins) {
5409 Double_t eta = (nPixels-1.0)/(TMath::Log10(xMax) - TMath::Log10(xMin));
5410 Double_t offset = -1.0 * eta * TMath::Log10(xMin);
5412 for (Int_t bin=pAxis->GetFirst()+binOffset; bin<=pAxis->GetLast(); bin++) {
5416 Double_t xLowValue = pAxis->GetBinLowEdge(bin);
5417 Double_t xUpValue = pAxis->GetBinUpEdge(bin);
5418 Int_t xPx0 = eta*TMath::Log10(xLowValue)+ offset;
5419 Int_t xPx1 = eta*TMath::Log10(xUpValue) + offset;
5420 THistRenderingRegion region = {std::make_pair(xPx0, xPx1),
5421 std::make_pair(bin, bin+1)};
5422 regions.push_back(region);
5429 Double_t beta = (TMath::Log10(xMax) - TMath::Log10(xMin))/(nPixels-1.0);
5431 for (Int_t pixelIndex=0; pixelIndex<(nPixels-1); pixelIndex++) {
5433 Int_t binLow = pAxis->FindBin(xMin*TMath::Power(10.0, beta*pixelIndex));
5434 Int_t binHigh = pAxis->FindBin(xMin*TMath::Power(10.0, beta*(pixelIndex+1)));
5435 THistRenderingRegion region = { std::make_pair(pixelIndex, pixelIndex+1),
5436 std::make_pair(binLow, binHigh)};
5437 regions.push_back(region);
5443 if (strategy == Bins) {
5445 for (Int_t bin=pAxis->GetFirst(); bin<=pAxis->GetLast(); bin++) {
5449 Int_t xPx0 = ((bin - pAxis->GetFirst()) * nPixels)/nBins;
5450 Int_t xPx1 = xPx0 + nPixels/nBins;
5453 if (xPx1>= nPixels) xPx1 = nPixels-1;
5455 THistRenderingRegion region = {std::make_pair(xPx0, xPx1),
5456 std::make_pair(bin, bin+1)};
5457 regions.push_back(region);
5461 for (Int_t pixelIndex=0; pixelIndex<nPixels-1; pixelIndex++) {
5463 Int_t binLow = (nBins*pixelIndex)/nPixels + pAxis->GetFirst();
5464 Int_t binHigh = binLow + nBins/nPixels;
5465 THistRenderingRegion region = { std::make_pair(pixelIndex, pixelIndex+1),
5466 std::make_pair(binLow, binHigh)};
5467 regions.push_back(region);
5478 void THistPainter::PaintColorLevelsFast(Option_t*)
5481 if (Hoption.System != kCARTESIAN) {
5482 Error(
"THistPainter::PaintColorLevelsFast(Option_t*)",
5483 "Only cartesian coordinates supported by 'COL2' option. Using 'COL' option instead.");
5484 PaintColorLevels(
nullptr);
5492 Double_t zmin = fH->GetMinimumStored();
5493 Double_t zmax = fH->GetMaximumStored();
5494 Double_t originalZMin = zmin;
5495 Double_t originalZMax = zmax;
5496 if ((zmin == -1111) && (zmax == -1111)) {
5497 fH->GetMinimumAndMaximum(zmin, zmax);
5498 fH->SetMinimum(zmin);
5499 fH->SetMaximum(zmax);
5500 }
else if (zmin == -1111) {
5501 zmin = fH->GetMinimum();
5502 fH->SetMinimum(zmin);
5503 }
else if (zmax == -1111) {
5504 zmax = fH->GetMaximum();
5505 fH->SetMaximum(zmax);
5508 Double_t dz = zmax - zmin;
5510 zmax += 0.1*TMath::Abs(zmax);
5511 zmin -= 0.1*TMath::Abs(zmin);
5517 zmin = TMath::Log10(zmin);
5518 zmax = TMath::Log10(zmax);
5521 Error(
"THistPainter::PaintColorLevelsFast(Option_t*)",
5522 "Cannot plot logz because bin content is less than 0.");
5528 Int_t ndiv = fH->GetContour();
5530 ndiv = gStyle->GetNumberContours();
5531 fH->SetContour(ndiv);
5533 std::vector<Double_t> colorBounds(ndiv);
5534 std::vector<Double_t> contours(ndiv, 0);
5535 if (fH->TestBit(TH1::kUserContour) == 0) {
5536 fH->SetContour(ndiv);
5538 fH->GetContour(contours.data());
5541 Double_t step = 1.0/ndiv;
5542 for (Int_t i=0; i<ndiv; ++i) {
5543 colorBounds[i] = step*i;
5546 auto pFrame = gPad->GetFrame();
5547 Int_t px0 = gPad->XtoPixel(pFrame->GetX1());
5548 Int_t px1 = gPad->XtoPixel(pFrame->GetX2());
5549 Int_t py0 = gPad->YtoPixel(pFrame->GetY1());
5550 Int_t py1 = gPad->YtoPixel(pFrame->GetY2());
5551 Int_t nXPixels = px1-px0;
5552 Int_t nYPixels = py0-py1;
5554 std::vector<Double_t> buffer(nXPixels*nYPixels, 0);
5556 auto xRegions = ComputeRenderingRegions(fXaxis, nXPixels, Hoption.Logx);
5557 auto yRegions = ComputeRenderingRegions(fYaxis, nYPixels, Hoption.Logy);
5558 if (xRegions.size() == 0 || yRegions.size() == 0) {
5559 Error(
"THistPainter::PaintColorLevelFast(Option_t*)",
5560 "Encountered error while computing rendering regions.");
5564 Bool_t minExists = kFALSE;
5565 Bool_t maxExists = kFALSE;
5566 Double_t minValue = 1.;
5567 Double_t maxValue = 0.;
5568 for (
auto& yRegion : yRegions) {
5569 for (
auto& xRegion : xRegions ) {
5571 const auto& xBinRange = xRegion.fBinRange;
5572 const auto& yBinRange = yRegion.fBinRange;
5575 z = fH->GetBinContent(xBinRange.second-1, yBinRange.second-1);
5578 if (z > 0) z = TMath::Log10(z);
5583 if (z > zmax) z = zmax;
5584 if (z < zmin) z = zmin;
5586 if (fH->TestBit(TH1::kUserContour) == 1) {
5588 auto index = TMath::BinarySearch(contours.size(), contours.data(), z);
5589 z = colorBounds[index];
5593 index = 0.001 + ((z - zmin)/dz)*ndiv;
5596 if (index == static_cast<Int_t>(colorBounds.size())) {
5604 }
else if (index == static_cast<Int_t>(colorBounds.size()-1)) {
5608 z = colorBounds[index];
5619 const auto& xPixelRange = xRegion.fPixelRange;
5620 const auto& yPixelRange = yRegion.fPixelRange;
5621 for (Int_t xPx = xPixelRange.first; xPx <= xPixelRange.second; ++xPx) {
5622 for (Int_t yPx = yPixelRange.first; yPx <= yPixelRange.second; ++yPx) {
5623 Int_t pixel = yPx*nXPixels + xPx;
5634 if (minValue != maxValue) {
5640 buffer[buffer.size()-nXPixels] = 0.95;
5645 TImagePalette* pPalette = TImagePalette::CreateCOLPalette(ndiv);
5646 TImage* pImage = TImage::Create();
5647 pImage->SetImageQuality(TAttImage::kImgBest);
5648 pImage->SetImage(buffer.data(), nXPixels, nYPixels, pPalette);
5651 Window_t wid =
static_cast<Window_t
>(gVirtualX->GetWindowID(gPad->GetPixmapID()));
5652 pImage->PaintImage(wid, px0, py1, 0, 0, nXPixels, nYPixels);
5655 if (Hoption.Zscale) PaintPalette();
5660 fH->SetMinimum(originalZMin);
5661 fH->SetMaximum(originalZMax);
5667 void THistPainter::PaintColorLevels(Option_t*)
5669 Double_t z, zc, xk, xstep, yk, ystep, xlow, xup, ylow, yup;
5671 Double_t zmin = fH->GetMinimum();
5672 Double_t zmax = fH->GetMaximum();
5674 Double_t dz = zmax - zmin;
5676 zmax += 0.1*TMath::Abs(zmax);
5677 zmin -= 0.1*TMath::Abs(zmin);
5683 if (Hoption.Same > 0 && Hoption.Same < 10) {
5685 TIter next(gPad->GetListOfPrimitives());
5686 while ((h2 = (TH2 *)next())) {
5687 if (!h2->InheritsFrom(TH2::Class()))
continue;
5688 zmin = h2->GetMinimum();
5689 zmax = h2->GetMaximum();
5690 fH->SetMinimum(zmin);
5691 fH->SetMaximum(zmax);
5694 zmin = TMath::Log10(zmax*0.001);
5696 zmin = TMath::Log10(zmin);
5698 zmax = TMath::Log10(zmax);
5706 zmin = TMath::Log10(zmin);
5707 zmax = TMath::Log10(zmax);
5715 Style_t fillsav = fH->GetFillStyle();
5716 Style_t colsav = fH->GetFillColor();
5717 fH->SetFillStyle(1001);
5718 fH->TAttFill::Modify();
5721 Int_t ncolors = gStyle->GetNumberOfColors();
5722 Int_t ndiv = fH->GetContour();
5724 ndiv = gStyle->GetNumberContours();
5725 fH->SetContour(ndiv);
5727 Int_t ndivz = TMath::Abs(ndiv);
5728 if (fH->TestBit(TH1::kUserContour) == 0) fH->SetContour(ndiv);
5729 Double_t scale = ndivz/dz;
5732 TProfile2D* prof2d =
dynamic_cast<TProfile2D*
>(fH);
5733 for (Int_t j=Hparam.yfirst; j<=Hparam.ylast;j++) {
5734 yk = fYaxis->GetBinLowEdge(j);
5735 ystep = fYaxis->GetBinWidth(j);
5736 for (Int_t i=Hparam.xfirst; i<=Hparam.xlast;i++) {
5737 Int_t bin = j*(fXaxis->GetNbins()+2) + i;
5738 xk = fXaxis->GetBinLowEdge(i);
5739 xstep = fXaxis->GetBinWidth(i);
5740 if (Hoption.System == kPOLAR && xk<0) xk= 2*TMath::Pi()+xk;
5741 if (!IsInside(xk+0.5*xstep,yk+0.5*ystep))
continue;
5742 z = fH->GetBinContent(bin);
5745 const Double_t binEntries = prof2d->GetBinEntries(bin);
5746 if (binEntries == 0)
5752 if (zmin >= 0 || Hoption.Logz)
continue;
5753 if (Hoption.Color == 2)
continue;
5758 if (z > 0) z = TMath::Log10(z);
5761 if (z < zmin && !Hoption.Zero)
continue;
5765 if (xup > 0) xup = TMath::Log10(xup);
5767 if (xlow > 0) xlow = TMath::Log10(xlow);
5772 if (Hoption.System != kPOLAR) {
5774 if (yup > 0) yup = TMath::Log10(yup);
5776 if (ylow > 0) ylow = TMath::Log10(ylow);
5779 if (xup < gPad->GetUxmin())
continue;
5780 if (yup < gPad->GetUymin())
continue;
5781 if (xlow > gPad->GetUxmax())
continue;
5782 if (ylow > gPad->GetUymax())
continue;
5783 if (xlow < gPad->GetUxmin()) xlow = gPad->GetUxmin();
5784 if (ylow < gPad->GetUymin()) ylow = gPad->GetUymin();
5785 if (xup > gPad->GetUxmax()) xup = gPad->GetUxmax();
5786 if (yup > gPad->GetUymax()) yup = gPad->GetUymax();
5789 if (fH->TestBit(TH1::kUserContour)) {
5790 zc = fH->GetContourLevelPad(0);
5791 if (z < zc)
continue;
5793 for (Int_t k=0; k<ndiv; k++) {
5794 zc = fH->GetContourLevelPad(k);
5802 color = Int_t(0.01+(z-zmin)*scale);
5805 Int_t theColor = Int_t((color+0.99)*Float_t(ncolors)/Float_t(ndivz));
5806 if (theColor > ncolors-1) theColor = ncolors-1;
5807 fH->SetFillColor(gStyle->GetColorPalette(theColor));
5808 fH->TAttFill::Modify();
5809 if (Hoption.System != kPOLAR) {
5810 gPad->PaintBox(xlow, ylow, xup, yup);
5812 TCrown crown(0,0,ylow,yup,xlow*TMath::RadToDeg(),xup*TMath::RadToDeg());
5813 crown.SetFillColor(gStyle->GetColorPalette(theColor));
5819 if (Hoption.Zscale) PaintPalette();
5821 fH->SetFillStyle(fillsav);
5822 fH->SetFillColor(colsav);
5823 fH->TAttFill::Modify();
5830 void THistPainter::PaintContour(Option_t *option)
5833 Int_t i, j, count, ncontour, icol, n, lj, m, ix, jx, ljfill;
5834 Int_t itars, mode, ir[4];
5835 Double_t xsave, ysave, thesave,phisave,x[4], y[4], zc[4];
5837 if (Hoption.Contour == 14) {
5840 thesave = gPad->GetTheta();
5841 phisave = gPad->GetPhi();
5843 gPad->SetTheta(90.);
5844 PaintSurface(option);
5845 gPad->SetPhi(phisave);
5846 gPad->SetTheta(thesave);
5847 TView *view = gPad->GetView();
5848 if (view) view->SetBit(kCannotRotate);
5857 TIter next(gPad->GetListOfPrimitives());
5858 while ((obj=next())) {
5859 if (strstr(obj->GetDrawOption(),
"surf") ||
5860 strstr(obj->GetDrawOption(),
"lego") ||
5861 strstr(obj->GetDrawOption(),
"tri")) {
5863 PaintSurface(option);
5869 if (Hoption.Contour == 15) {
5870 TGraphDelaunay2D *dt =
nullptr;
5871 TGraphDelaunay *dtOld =
nullptr;
5872 TList *hl = fH->GetListOfFunctions();
5873 dt = (TGraphDelaunay2D*)hl->FindObject(
"TGraphDelaunay2D");
5874 if (!dt) dtOld = (TGraphDelaunay*)hl->FindObject(
"TGraphDelaunay");
5875 if (!dt && !dtOld)
return;
5876 if (!fGraph2DPainter) {
5877 if (dt) fGraph2DPainter =
new TGraph2DPainter(dt);
5878 else fGraph2DPainter =
new TGraph2DPainter(dtOld);
5880 fGraph2DPainter->Paint(option);
5884 gPad->SetBit(TGraph::kClipFrame);
5886 Double_t *levels =
new Double_t[2*kMAXCONTOUR];
5887 Double_t *xarr =
new Double_t[2*kMAXCONTOUR];
5888 Double_t *yarr =
new Double_t[2*kMAXCONTOUR];
5889 Int_t *itarr =
new Int_t[2*kMAXCONTOUR];
5892 for (i=0;i<2*kMAXCONTOUR;i++) itarr[i] = 0;
5894 ncontour = fH->GetContour();
5895 if (ncontour == 0) {
5896 ncontour = gStyle->GetNumberContours();
5897 fH->SetContour(ncontour);
5899 if (ncontour > kMAXCONTOUR) {
5900 Warning(
"PaintContour",
"maximum number of contours is %d, asked for %d",
5901 kMAXCONTOUR, ncontour);
5902 ncontour = kMAXCONTOUR-1;
5904 if (fH->TestBit(TH1::kUserContour) == 0) fH->SetContour(ncontour);
5906 for (i=0;i<ncontour;i++) levels[i] = fH->GetContourLevelPad(i);
5907 Int_t linesav = fH->GetLineStyle();
5908 Int_t colorsav = fH->GetLineColor();
5909 Int_t fillsav = fH->GetFillColor();
5910 if (Hoption.Contour == 13) {
5911 fH->TAttLine::Modify();
5914 TPolyLine **polys = 0;
5916 TObjArray *contours = 0;
5920 if (Hoption.Contour == 1) {
5921 np =
new Int_t[ncontour];
5922 for (i=0;i<ncontour;i++) np[i] = 0;
5923 polys =
new TPolyLine*[ncontour];
5924 for (i=0;i<ncontour;i++) {
5925 polys[i] =
new TPolyLine(100);
5927 if (Hoption.List == 1) {
5928 contours = (TObjArray*)gROOT->GetListOfSpecials()->FindObject(
"contours");
5930 gROOT->GetListOfSpecials()->Remove(contours);
5931 count = contours->GetSize();
5932 for (i=0;i<count;i++) {
5933 list = (TList*)contours->At(i);
5934 if (list) list->Delete();
5937 contours =
new TObjArray(ncontour);
5938 contours->SetName(
"contours");
5939 gROOT->GetListOfSpecials()->Add(contours);
5940 for (i=0;i<ncontour;i++) {
5942 contours->Add(list);
5947 Int_t ncolors = gStyle->GetNumberOfColors();
5948 Int_t ndivz = TMath::Abs(ncontour);
5951 for (j=Hparam.yfirst; j<Hparam.ylast; j++) {
5952 y[0] = fYaxis->GetBinCenter(j);
5954 y[2] = fYaxis->GetBinCenter(j+1);
5956 for (i=Hparam.xfirst; i<Hparam.xlast; i++) {
5957 zc[0] = fH->GetBinContent(i, j);
5958 zc[1] = fH->GetBinContent(i+1, j);
5959 zc[2] = fH->GetBinContent(i+1, j+1);
5960 zc[3] = fH->GetBinContent(i, j+1);
5961 if (!IsInside(fXaxis->GetBinCenter(i),fYaxis->GetBinCenter(j)))
continue;
5963 if (zc[0] > 0) zc[0] = TMath::Log10(zc[0]);
5964 else zc[0] = Hparam.zmin;
5965 if (zc[1] > 0) zc[1] = TMath::Log10(zc[1]);
5966 else zc[1] = Hparam.zmin;
5967 if (zc[2] > 0) zc[2] = TMath::Log10(zc[2]);
5968 else zc[2] = Hparam.zmin;
5969 if (zc[3] > 0) zc[3] = TMath::Log10(zc[3]);
5970 else zc[3] = Hparam.zmin;
5973 ir[k] = TMath::BinarySearch(ncontour,levels,zc[k]);
5975 if (ir[0] != ir[1] || ir[1] != ir[2] || ir[2] != ir[3] || ir[3] != ir[0]) {
5976 x[0] = fXaxis->GetBinCenter(i);
5978 x[1] = fXaxis->GetBinCenter(i+1);
5980 if (zc[0] <= zc[1]) n = 0;
else n = 1;
5981 if (zc[2] <= zc[3]) m = 2;
else m = 3;
5982 if (zc[n] > zc[m]) n = m;
5985 for (ix=1;ix<=4;ix++) {
5987 ljfill = PaintContourLine(zc[n-1],ir[n-1],x[n-1],y[n-1],zc[m-1],
5988 ir[m-1],x[m-1],y[m-1],&xarr[lj-1],&yarr[lj-1],&itarr[lj-1], levels);
5993 if (zc[0] <= zc[1]) n = 0;
else n = 1;
5994 if (zc[2] <= zc[3]) m = 2;
else m = 3;
5995 if (zc[n] > zc[m]) n = m;
5998 for (ix=1;ix<=4;ix++) {
6001 ljfill = PaintContourLine(zc[n-1],ir[n-1],x[n-1],y[n-1],zc[m-1],
6002 ir[m-1],x[m-1],y[m-1],&xarr[lj-1],&yarr[lj-1],&itarr[lj-1], levels);
6010 for (ix=1; ix<=lj-5; ix +=2) {
6012 while (itarr[ix-1] != itarr[ix]) {
6016 for (jx=ix; jx<=lj-5; jx +=2) {
6017 xarr[jx] = xarr[jx+2];
6018 yarr[jx] = yarr[jx+2];
6019 itarr[jx] = itarr[jx+2];
6023 itarr[lj-3] = itars;
6024 if (count > 100)
break;
6029 if (count > 100)
continue;
6030 for (ix=1; ix<=lj-2; ix +=2) {
6031 theColor = Int_t((itarr[ix-1]+0.99)*Float_t(ncolors)/Float_t(ndivz));
6032 icol = gStyle->GetColorPalette(theColor);
6033 if (Hoption.Contour == 11) {
6034 fH->SetLineColor(icol);
6036 if (Hoption.Contour == 12) {
6038 if (mode == 0) mode = 5;
6039 fH->SetLineStyle(mode);
6041 if (Hoption.Contour != 1) {
6042 fH->TAttLine::Modify();
6043 gPad->PaintPolyLine(2,&xarr[ix-1],&yarr[ix-1]);
6047 ipoly = itarr[ix-1];
6048 if (ipoly >=0 && ipoly <ncontour) {
6049 poly = polys[ipoly];
6050 poly->SetPoint(np[ipoly] ,xarr[ix-1],yarr[ix-1]);
6051 poly->SetPoint(np[ipoly]+1,xarr[ix], yarr[ix]);
6053 if (npmax < np[ipoly]) npmax = np[ipoly];
6062 Int_t nadd,iminus,iplus;
6065 Int_t first = ncontour;
6066 Int_t *polysort = 0;
6068 if (Hoption.Contour != 1)
goto theEND;
6074 xmin = gPad->GetUxmin();
6075 ymin = gPad->GetUymin();
6076 xp =
new Double_t[2*npmax];
6077 yp =
new Double_t[2*npmax];
6078 polysort =
new Int_t[ncontour];
6080 for (ipoly=0;ipoly<ncontour;ipoly++) {
6081 if (levels[ipoly] >= 0) {first = ipoly;
break;}
6085 for (ipoly=first-1;ipoly>=0;ipoly--) {polysort[k] = ipoly; k++;}
6086 for (ipoly=first;ipoly<ncontour;ipoly++) {polysort[k] = ipoly; k++;}
6089 fH->SetFillStyle(1001);
6090 for (k=0;k<ncontour;k++) {
6091 ipoly = polysort[k];
6092 if (np[ipoly] == 0)
continue;
6093 if (Hoption.List) list = (TList*)contours->At(contListNb);
6095 poly = polys[ipoly];
6102 xp[iminus]= xx[istart]; yp[iminus] = yy[istart];
6103 xp[iplus] = xx[istart+1]; yp[iplus] = yy[istart+1];
6104 xx[istart] = xmin; yy[istart] = ymin;
6105 xx[istart+1] = xmin; yy[istart+1] = ymin;
6108 for (i=2;i<np[ipoly];i+=2) {
6109 if ((iplus < 2*npmax-1) && (xx[i] == xp[iplus]) && (yy[i] == yp[iplus])) {
6111 xp[iplus] = xx[i+1]; yp[iplus] = yy[i+1];
6112 xx[i] = xmin; yy[i] = ymin;
6113 xx[i+1] = xmin; yy[i+1] = ymin;
6116 if ((iminus > 0) && (xx[i+1] == xp[iminus]) && (yy[i+1] == yp[iminus])) {
6118 xp[iminus] = xx[i]; yp[iminus] = yy[i];
6119 xx[i] = xmin; yy[i] = ymin;
6120 xx[i+1] = xmin; yy[i+1] = ymin;
6124 if (nadd == 0)
break;
6126 theColor = Int_t((ipoly+0.99)*Float_t(ncolors)/Float_t(ndivz));
6127 icol = gStyle->GetColorPalette(theColor);
6128 if (ndivz > 1) fH->SetFillColor(icol);
6129 fH->TAttFill::Modify();
6130 gPad->PaintFillArea(iplus-iminus+1,&xp[iminus],&yp[iminus]);
6132 graph =
new TGraph(iplus-iminus+1,&xp[iminus],&yp[iminus]);
6133 graph->SetFillColor(icol);
6134 graph->SetLineWidth(fH->GetLineWidth());
6139 for (i=2;i<np[ipoly];i+=2) {
6140 if (xx[i] != xmin && yy[i] != ymin) {
6145 if (istart == 0)
break;
6149 for (i=0;i<ncontour;i++)
delete polys[i];
6156 gPad->ResetBit(TGraph::kClipFrame);
6157 if (Hoption.Zscale) PaintPalette();
6158 fH->SetLineStyle(linesav);
6159 fH->SetLineColor(colorsav);
6160 fH->SetFillColor(fillsav);
6161 if (np)
delete [] np;
6171 Int_t THistPainter::PaintContourLine(Double_t elev1, Int_t icont1, Double_t x1, Double_t y1,
6172 Double_t elev2, Int_t icont2, Double_t x2, Double_t y2,
6173 Double_t *xarr, Double_t *yarr, Int_t *itarr, Double_t *levels)
6177 Double_t tlen, tdif, elev, diff, pdif, xlen;
6189 tdif = elev2 - elev1;
6192 while (n <= icont2 && i <= kMAXCONTOUR/2 -3) {
6195 diff = elev - elev1;
6200 xarr[i] = TMath::Log10(x1);
6204 yarr[i] = TMath::Log10(y1 + xlen);
6206 yarr[i] = y1 + xlen;
6209 xarr[i] = TMath::Log10(x1 + xlen);
6211 xarr[i] = x1 + xlen;
6213 yarr[i] = TMath::Log10(y1);
6228 void THistPainter::PaintErrors(Option_t *)
6234 if (gPad->PadInHighlightMode() && gPad->GetSelected() != fH)
return;
6236 const Int_t kBASEMARKER=8;
6237 Double_t xp, yp, ex1, ex2, ey1, ey2;
6239 Double_t s2x, s2y, bxsize, bysize, symbolsize, xerror, sbase;
6240 Double_t xi1, xi2, xi3, xi4, yi1, yi2, yi3, yi4;
6241 Double_t xmin, xmax, ymin, ymax;
6242 Double_t logxmin = 0;
6243 Double_t logymin = 0;
6244 Double_t offset = 0.;
6245 Double_t width = 0.;
6246 Int_t i, k, npoints, first, last, fixbin;
6249 Int_t drawmarker, errormarker;
6250 Int_t option0, option1, option2, option3, option4, optionE, optionEX0, optionI0;
6252 Double_t *xline = 0;
6253 Double_t *yline = 0;
6254 option0 = option1 = option2 = option3 = option4 = optionE = optionEX0 = optionI0 = 0;
6255 if (Int_t(Hoption.Error/10) == 2) {optionEX0 = 1; Hoption.Error -= 10;}
6256 if (Hoption.Error == 31) {optionEX0 = 1; Hoption.Error = 1;}
6257 if (Hoption.Error == 10) option0 = 1;
6258 if (Hoption.Error == 11) option1 = 1;
6259 if (Hoption.Error == 12) option2 = 1;
6260 if (Hoption.Error == 13) option3 = 1;
6261 if (Hoption.Error == 14) {option4 = 1; option3 = 1;}
6262 if (Hoption.Error == 15) {optionI0 = 1; option3 = 1;}
6263 if (Hoption.Error == 16) {optionI0 = 1; option4 = 1; option3 = 1;}
6264 if (option2+option3 == 0) optionE = 1;
6265 if (Hoption.Error == 0) optionE = 0;
6266 if (fXaxis->GetXbins()->fN) fixbin = 0;
6269 offset = fH->GetBarOffset();
6270 width = fH->GetBarWidth();
6272 errormarker = fH->GetMarkerStyle();
6276 xerror = gStyle->GetErrorX();
6278 symbolsize = fH->GetMarkerSize();
6279 if (errormarker == 1) symbolsize = 0.01;
6280 sbase = symbolsize*kBASEMARKER;
6283 fH->TAttLine::Modify();
6284 fH->TAttFill::Modify();
6285 fH->TAttMarker::Modify();
6289 Double_t factor = Hparam.factor;
6290 first = Hparam.xfirst;
6291 last = Hparam.xlast;
6292 npoints = last - first +1;
6293 xmin = gPad->GetUxmin();
6294 xmax = gPad->GetUxmax();
6295 ymin = gPad->GetUymin();
6296 ymax = gPad->GetUymax();
6300 xline =
new Double_t[2*npoints];
6301 yline =
new Double_t[2*npoints];
6302 if (!xline || !yline) {
6303 Error(
"PaintErrors",
"too many points, out of memory");
6311 s2x = gPad->PixeltoX(Int_t(0.5*sbase)) - gPad->PixeltoX(0);
6312 s2y =-gPad->PixeltoY(Int_t(0.5*sbase)) + gPad->PixeltoY(0);
6315 Int_t dxend = Int_t(gStyle->GetEndErrorSize());
6316 bxsize = gPad->PixeltoX(dxend) - gPad->PixeltoX(0);
6317 bysize =-gPad->PixeltoY(dxend) + gPad->PixeltoY(0);
6321 if (Hoption.Logx) xp = TMath::Power(10,Hparam.xmin) + 0.5*Hparam.xbinsize;
6322 else xp = Hparam.xmin + 0.5*Hparam.xbinsize;
6324 delta = fH->GetBinWidth(first);
6325 xp = fH->GetBinLowEdge(first) + 0.5*delta;
6329 if (Hoption.Logx) logxmin = TMath::Power(10,Hparam.xmin);
6330 if (Hoption.Logy) logymin = TMath::Power(10,Hparam.ymin);
6333 for (k=first; k<=last; k++) {
6345 Double_t xminTmp = gPad->XtoPad(fXaxis->GetBinLowEdge(k));
6346 Double_t xmaxTmp = gPad->XtoPad(fXaxis->GetBinUpEdge(k));
6347 Double_t w = (xmaxTmp-xminTmp)*width;
6348 xminTmp += offset*(xmaxTmp-xminTmp);
6349 xmaxTmp = xminTmp + w;
6350 xp = (xminTmp+xmaxTmp)/2.;
6353 if (xp <= 0)
goto L30;
6354 if (xp < logxmin)
goto L30;
6355 if (xp > TMath::Power(10,xmax))
break;
6357 if (xp < xmin)
goto L30;
6358 if (xp > xmax)
break;
6360 yp = factor*fH->GetBinContent(k);
6361 if (optionI0 && yp==0)
goto L30;
6363 ex1 = xerror*Hparam.xbinsize;
6365 delta = fH->GetBinWidth(k);
6368 if (fH->GetBinErrorOption() == TH1::kNormal) {
6369 ey1 = factor*fH->GetBinError(k);
6372 ey1 = factor*fH->GetBinErrorLow(k);
6373 ey2 = factor*fH->GetBinErrorUp(k);
6389 xi1 = TMath::Log10(TMath::Max(xi1,logxmin));
6390 xi2 = TMath::Log10(TMath::Max(xi2,logxmin));
6391 xi3 = TMath::Log10(TMath::Max(xi3,logxmin));
6392 xi4 = TMath::Log10(TMath::Max(xi4,logxmin));
6395 yi1 = TMath::Log10(TMath::Max(yi1,logymin));
6396 yi2 = TMath::Log10(TMath::Max(yi2,logymin));
6397 yi3 = TMath::Log10(TMath::Max(yi3,logymin));
6398 yi4 = TMath::Log10(TMath::Max(yi4,logymin));
6404 xi1 = TMath::Max(xi1,xmin);
6405 xi2 = TMath::Min(xi2,xmax);
6406 yi3 = TMath::Max(yi3,ymin);
6407 yi4 = TMath::Min(yi4,ymax);
6413 if (!option0 && !option3) {
6414 if (Hoption.Logy && yp < logymin)
goto L30;
6415 if (yi1 < ymin || yi1 > ymax)
goto L30;
6416 if (Hoption.Error != 0 && yp == 0 && ey1 <= 0) drawmarker = kFALSE;
6418 if (!symbolsize || !errormarker) drawmarker = kFALSE;
6421 if (option2) gPad->PaintBox(xi1,yi3,xi2,yi4);
6434 if (Hoption.Logy && yp < logymin) drawmarker = kFALSE;
6435 if (optionE && drawmarker) {
6436 if ((yi3 < yi1 - s2y) && (yi3 < ymax)) gPad->PaintLine(xi3,yi3,xi4,TMath::Min(yi1 - s2y,ymax));
6437 if ((yi1 + s2y < yi4) && (yi4 > ymin)) gPad->PaintLine(xi3,TMath::Max(yi1 + s2y, ymin),xi4,yi4);
6439 if (Hoption.Hist != 2) {
6440 if (yi1<ymax && yi1>ymin) {
6441 if (xi1 < xi3 - s2x) gPad->PaintLine(xi1,yi1,xi3 - s2x,yi2);
6442 if (xi3 + s2x < xi2) gPad->PaintLine(xi3 + s2x,yi1,xi2,yi2);
6446 if (optionE && !drawmarker && (ey1 != 0 || ey2 !=0)) {
6447 if ((yi3 < yi1) && (yi3 < ymax)) gPad->PaintLine(xi3,yi3,xi4,TMath::Min(yi1,ymax));
6448 if ((yi1 < yi4) && (yi4 > ymin)) gPad->PaintLine(xi3,TMath::Max(yi1,ymin),xi4,yi4);
6450 if (Hoption.Hist != 2) {
6451 if (yi1<ymax && yi1>ymin) {
6452 if (xi1 < xi3) gPad->PaintLine(xi1,yi1,xi3,yi2);
6453 if (xi3 < xi2) gPad->PaintLine(xi3,yi1,xi2,yi2);
6460 if (option1 && drawmarker) {
6461 if (yi3 < yi1-s2y) gPad->PaintLine(xi3 - bxsize,yi3,xi3 + bxsize,yi3);
6462 if (yi4 > yi1+s2y) gPad->PaintLine(xi3 - bxsize,yi4,xi3 + bxsize,yi4);
6463 if (xi1 < xi3-s2x) gPad->PaintLine(xi1,yi1 - bysize,xi1,yi1 + bysize);
6464 if (xi2 > xi3+s2x) gPad->PaintLine(xi2,yi1 - bysize,xi2,yi1 + bysize);
6469 if (drawmarker) gPad->PaintPolyMarker(1, &xi3, &yi1);
6472 if (fixbin) xp += Hparam.xbinsize;
6475 delta = fH->GetBinWidth(k+1);
6476 xp = fH->GetBinLowEdge(k+1) + 0.5*delta;
6485 graph.SetLineStyle(fH->GetLineStyle());
6486 graph.SetLineColor(fH->GetLineColor());
6487 graph.SetLineWidth(fH->GetLineWidth());
6488 graph.SetFillStyle(fH->GetFillStyle());
6489 graph.SetFillColor(fH->GetFillColor());
6490 Int_t logx = gPad->GetLogx();
6491 Int_t logy = gPad->GetLogy();
6498 if (if2 > npoints) {
6499 for (i=1; i<if1; i++) {
6500 xline[if1-2+i] = xline[if2-1+i];
6501 yline[if1-2+i] = yline[if2-1+i];
6505 if (option4) graph.PaintGraph(2*npoints,xline,yline,
"FC");
6506 else graph.PaintGraph(2*npoints,xline,yline,
"F");
6507 gPad->SetLogx(logx);
6508 gPad->SetLogy(logy);
6517 void THistPainter::Paint2DErrors(Option_t *)
6520 fH->TAttMarker::Modify();
6521 fH->TAttLine::Modify();
6524 fXbuf[0] = Hparam.xmin;
6525 fYbuf[0] = Hparam.xmax;
6526 fXbuf[1] = Hparam.ymin;
6527 fYbuf[1] = Hparam.ymax;
6528 fXbuf[2] = Hparam.zmin;
6529 fYbuf[2] = Hparam.zmax*(1. + gStyle->GetHistTopMargin());
6530 fLego =
new TPainter3dAlgorithms(fXbuf, fYbuf);
6531 TView *view = gPad->GetView();
6533 Error(
"Paint2DErrors",
"no TView in current pad");
6536 Double_t thedeg = 90 - gPad->GetTheta();
6537 Double_t phideg = -90 - gPad->GetPhi();
6538 Double_t psideg = view->GetPsi();
6540 view->SetView(phideg, thedeg, psideg, irep);
6543 fLego->SetFillStyle(gPad->GetFrameFillStyle());
6544 fLego->SetFillColor(gPad->GetFrameFillColor());
6545 fLego->TAttFill::Modify();
6546 Int_t backcolor = gPad->GetFrameFillColor();
6547 if (Hoption.System != kCARTESIAN) backcolor = 0;
6548 view->PadRange(backcolor);
6549 fLego->SetFillStyle(fH->GetFillStyle());
6550 fLego->SetFillColor(fH->GetFillColor());
6551 fLego->TAttFill::Modify();
6554 if (Hoption.BackBox && !Hoption.Same && !Hoption.Lego && !Hoption.Surf) {
6555 fLego->InitMoveScreen(-1.1,1.1);
6556 fLego->DefineGridLevels(fZaxis->GetNdivisions()%100);
6557 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove1);
6562 Double_t x, ex, x1, x2;
6563 Double_t y, ey, y1, y2;
6564 Double_t z, ez1, ez2, z1, z2;
6565 Double_t temp1[3],temp2[3];
6567 if (Hoption.Error == 110) {
6570 xyerror = gStyle->GetErrorX();
6573 Double_t xk, xstep, yk, ystep;
6574 for (Int_t j=Hparam.yfirst; j<=Hparam.ylast;j++) {
6575 y = fYaxis->GetBinCenter(j);
6576 ey = fYaxis->GetBinWidth(j)*xyerror;
6580 if (y > 0) y = TMath::Log10(y);
6582 if (y1 > 0) y1 = TMath::Log10(y1);
6583 else y1 = Hparam.ymin;
6584 if (y2 > 0) y2 = TMath::Log10(y2);
6585 else y2 = Hparam.ymin;
6587 yk = fYaxis->GetBinLowEdge(j);
6588 ystep = fYaxis->GetBinWidth(j);
6589 for (Int_t i=Hparam.xfirst; i<=Hparam.xlast;i++) {
6590 xk = fXaxis->GetBinLowEdge(i);
6591 xstep = fXaxis->GetBinWidth(i);
6592 if (!IsInside(xk+0.5*xstep,yk+0.5*ystep))
continue;
6593 Int_t bin = fH->GetBin(i,j);
6594 x = fXaxis->GetBinCenter(i);
6595 ex = fXaxis->GetBinWidth(i)*xyerror;
6599 if (x > 0) x = TMath::Log10(x);
6601 if (x1 > 0) x1 = TMath::Log10(x1);
6602 else x1 = Hparam.xmin;
6603 if (x2 > 0) x2 = TMath::Log10(x2);
6604 else x2 = Hparam.xmin;
6606 z = fH->GetBinContent(bin);
6607 if (fH->GetBinErrorOption() == TH1::kNormal) {
6608 ez1 = fH->GetBinError(bin);
6612 ez1 = fH->GetBinErrorLow(bin);
6613 ez2 = fH->GetBinErrorUp(bin);
6618 if (z > 0) z = TMath::Log10(z);
6619 else z = Hparam.zmin;
6620 if (z1 > 0) z1 = TMath::Log10(z1);
6621 else z1 = Hparam.zmin;
6622 if (z2 > 0) z2 = TMath::Log10(z2);
6623 else z2 = Hparam.zmin;
6626 if (z <= Hparam.zmin)
continue;
6627 if (z > Hparam.zmax) z = Hparam.zmax;
6635 gPad->PaintLine3D(temp1, temp2);
6642 gPad->PaintLine3D(temp1, temp2);
6649 gPad->PaintLine3D(temp1, temp2);
6653 view->WCtoNDC(temp1, &temp2[0]);
6654 gPad->PaintPolyMarker(1, &temp2[0], &temp2[1]);
6659 if (Hoption.FrontBox) {
6660 fLego->InitMoveScreen(-1.1,1.1);
6661 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove2);
6662 fLego->FrontBox(90);
6666 if (!Hoption.Axis && !Hoption.Same && !Hoption.Lego && !Hoption.Surf) {
6667 TGaxis *axis =
new TGaxis();
6668 PaintLegoAxis(axis, 90);
6672 delete fLego; fLego = 0;
6678 void THistPainter::PaintFrame()
6681 if (Hoption.Same)
return;
6685 if (Hoption.Lego || Hoption.Surf || Hoption.Tri ||
6686 Hoption.Contour == 14 || Hoption.Error >= 100) {
6687 TObject *frame = gPad->FindObject(
"TFrame");
6688 if (frame) gPad->GetListOfPrimitives()->Remove(frame);
6694 if (!gPad->PadInSelectionMode() && !gPad->PadInHighlightMode())
6695 gPad->PaintPadFrame(Hparam.xmin,Hparam.ymin,Hparam.xmax,Hparam.ymax);
6701 void THistPainter::PaintFunction(Option_t *)
6704 TObjOptLink *lnk = (TObjOptLink*)fFunctions->FirstLink();
6708 obj = lnk->GetObject();
6709 TVirtualPad *padsave = gPad;
6710 if (obj->InheritsFrom(TF2::Class())) {
6711 if (obj->TestBit(TF2::kNotDraw) == 0) {
6712 if (Hoption.Lego || Hoption.Surf || Hoption.Error >= 100) {
6713 TF2 *f2 = (TF2*)obj;
6714 f2->SetMinimum(fH->GetMinimum());
6715 f2->SetMaximum(fH->GetMaximum());
6716 f2->SetRange(fH->GetXaxis()->GetXmin(), fH->GetYaxis()->GetXmin(), fH->GetXaxis()->GetXmax(), fH->GetYaxis()->GetXmax() );
6717 f2->Paint(
"surf same");
6719 obj->Paint(
"cont3 same");
6722 }
else if (obj->InheritsFrom(TF1::Class())) {
6723 if (obj->TestBit(TF1::kNotDraw) == 0) obj->Paint(
"lsame");
6726 gPad->PushSelectableObject(obj);
6730 if (!gPad->PadInHighlightMode() || (gPad->PadInHighlightMode() && obj == gPad->GetSelected()))
6731 obj->Paint(lnk->GetOption());
6733 lnk = (TObjOptLink*)lnk->Next();
6741 void THistPainter::PaintHist(Option_t *)
6746 if (gPad->PadInHighlightMode() && gPad->GetSelected() != fH)
6749 static char chopth[17];
6751 Int_t htype, oldhtype;
6752 Int_t i, j, first, last, nbins, fixbin;
6756 strlcpy(chopth,
" ",17);
6758 Double_t ymin = Hparam.ymin;
6759 Double_t ymax = Hparam.ymax;
6760 Double_t baroffset = fH->GetBarOffset();
6761 Double_t barwidth = fH->GetBarWidth();
6762 Double_t baroffsetsave = gStyle->GetBarOffset();
6763 Double_t barwidthsave = gStyle->GetBarWidth();
6764 gStyle->SetBarOffset(baroffset);
6765 gStyle->SetBarWidth(barwidth);
6769 first = Hparam.xfirst;
6770 last = Hparam.xlast;
6771 nbins = last - first + 1;
6773 Double_t *keepx = 0;
6774 Double_t *keepy = 0;
6775 if (fXaxis->GetXbins()->fN) fixbin = 0;
6777 if (fixbin) keepx =
new Double_t[2];
6778 else keepx =
new Double_t[nbins+1];
6779 keepy =
new Double_t[nbins];
6780 Double_t logymin = 0;
6781 if (Hoption.Logy) logymin = TMath::Power(10,ymin);
6785 for (j=first; j<=last;j++) {
6786 c1 = Hparam.factor*fH->GetBinContent(j);
6787 if (TMath::Abs(ymax-ymin) > 0) {
6788 if (Hoption.Logy) yb = TMath::Log10(TMath::Max(c1,.1*logymin));
6791 if (!Hoption.Line) {
6792 yb = TMath::Max(yb, ymin);
6793 yb = TMath::Min(yb, ymax);
6795 keepy[j-first] = yb;
6800 if (fixbin) { keepx[0] = Hparam.xmin; keepx[1] = Hparam.xmax; }
6802 for (i=0; i<nbins; i++) keepx[i] = fXaxis->GetBinLowEdge(i+first);
6803 keepx[nbins] = fXaxis->GetBinUpEdge(nbins-1+first);
6808 oldhtype = fH->GetFillStyle();
6811 if (htype == 0 || htype == 1000) htype = 1001;
6814 Width_t lw = (Width_t)fH->GetLineWidth();
6818 if (Hoption.Line) chopth[0] =
'L';
6819 if (Hoption.Star) chopth[1] =
'*';
6820 if (Hoption.Mark) chopth[2] =
'P';
6821 if (Hoption.Mark == 10) chopth[3] =
'0';
6822 if (Hoption.Line || Hoption.Curve || Hoption.Hist || Hoption.Bar) {
6823 if (Hoption.Curve) chopth[3] =
'C';
6824 if (Hoption.Hist > 0) chopth[4] =
'H';
6825 else if (Hoption.Bar) chopth[5] =
'B';
6826 if (fH->GetFillColor() && htype) {
6830 if (Hoption.Hist > 0 || Hoption.Curve || Hoption.Line) {
6835 if (!fixbin && strlen(chopth)) {
6839 if (Hoption.Fill == 2) chopth[13] =
'2';
6847 keepx[0] = TMath::Power(10,keepx[0]);
6848 keepx[1] = TMath::Power(10,keepx[1]);
6860 graph.SetLineWidth(lw);
6861 graph.SetLineStyle(fH->GetLineStyle());
6862 graph.SetLineColor(fH->GetLineColor());
6863 graph.SetFillStyle(htype);
6864 graph.SetFillColor(fH->GetFillColor());
6865 graph.SetMarkerStyle(fH->GetMarkerStyle());
6866 graph.SetMarkerSize(fH->GetMarkerSize());
6867 graph.SetMarkerColor(fH->GetMarkerColor());
6868 if (!Hoption.Same) graph.ResetBit(TGraph::kClipFrame);
6870 graph.PaintGrapHist(nbins, keepx, keepy ,chopth);
6874 gStyle->SetBarOffset(baroffsetsave);
6875 gStyle->SetBarWidth(barwidthsave);
6883 void THistPainter::PaintH3(Option_t *option)
6887 TString opt = option;
6891 if (Hoption.Box || Hoption.Lego) {
6892 if (Hoption.Box == 11 || Hoption.Lego == 11) {
6894 }
else if (Hoption.Box == 12 || Hoption.Lego == 12) {
6896 }
else if (Hoption.Box == 13 || Hoption.Lego == 13) {
6902 }
else if (strstr(opt,
"iso")) {
6905 }
else if (strstr(opt,
"tf3")) {
6909 cmd = Form(
"TPolyMarker3D::PaintH3((TH1 *)0x%lx,\"%s\");",(Long_t)fH,option);
6912 if (strstr(opt,
"fb")) Hoption.FrontBox = 0;
6913 if (strstr(opt,
"bb")) Hoption.BackBox = 0;
6915 TView *view = gPad->GetView();
6917 Double_t thedeg = 90 - gPad->GetTheta();
6918 Double_t phideg = -90 - gPad->GetPhi();
6919 Double_t psideg = view->GetPsi();
6920 view->SetView(phideg, thedeg, psideg, irep);
6923 gROOT->ProcessLine(cmd);
6925 if (Hoption.Same)
return;
6928 view->SetOutlineToCube();
6929 TSeqCollection *ol = view->GetOutline();
6930 if (ol && Hoption.BackBox && Hoption.FrontBox) ol->Paint(option);
6931 Hoption.System = kCARTESIAN;
6932 TGaxis *axis =
new TGaxis();
6933 if (!Hoption.Axis && !Hoption.Same) PaintLegoAxis(axis, 90);
6938 if (fH->GetDrawOption() && strstr(opt,
"colz")) {
6939 Int_t ndiv = fH->GetContour();
6941 ndiv = gStyle->GetNumberContours();
6942 fH->SetContour(ndiv);
6952 TIter next(fFunctions);
6954 while ((obj = next())) {
6955 if (obj->InheritsFrom(TF1::Class())) {
6960 if ((Hoption.Same%10) != 1) {
6961 if (!fH->TestBit(TH1::kNoStats)) {
6962 PaintStat3(gStyle->GetOptStat(),fit);
6971 Int_t THistPainter::PaintInit()
6974 if (fH->GetDimension() > 1 || Hoption.Lego || Hoption.Surf)
return 1;
6977 static const char *where =
"PaintInit";
6978 Double_t yMARGIN = gStyle->GetHistTopMargin();
6981 if (fH->GetMaximumStored() != -1111) maximum = 1;
6982 if (fH->GetMinimumStored() != -1111) minimum = 1;
6986 Int_t last = fXaxis->GetLast();
6987 Int_t first = fXaxis->GetFirst();
6988 Hparam.xlowedge = fXaxis->GetBinLowEdge(first);
6989 Hparam.xbinsize = fXaxis->GetBinWidth(first);
6990 Hparam.xlast = last;
6991 Hparam.xfirst = first;
6992 Hparam.xmin = Hparam.xlowedge;
6993 Hparam.xmax = fXaxis->GetBinLowEdge(last)+fXaxis->GetBinWidth(last);
6997 if (Hparam.xmax<=0) {
6998 Error(where,
"cannot set X axis to log scale");
7001 if (Hparam.xlowedge <=0 ) {
7003 Hparam.xlowedge = TMath::Power(10, gPad->GetUxmin());
7005 for (i=first; i<=last; i++) {
7006 Double_t binLow = fXaxis->GetBinLowEdge(i);
7008 Hparam.xlowedge = binLow;
7011 if (binLow == 0 && fH->GetBinContent(i) !=0) {
7012 Hparam.xlowedge = fXaxis->GetBinUpEdge(i)*0.001;
7016 if (Hparam.xlowedge<=0) {
7017 Error(where,
"cannot set X axis to log scale");
7021 Hparam.xmin = Hparam.xlowedge;
7023 Hparam.xfirst= fXaxis->FindFixBin(Hparam.xmin);
7024 Hparam.xlast = fXaxis->FindFixBin(Hparam.xmax);
7025 Hparam.xmin = TMath::Log10(Hparam.xmin);
7026 Hparam.xmax = TMath::Log10(Hparam.xmax);
7027 if (Hparam.xlast > last) Hparam.xlast = last;
7028 if (Hparam.xfirst < first) Hparam.xfirst = first;
7032 Double_t bigp = TMath::Power(10,32);
7033 Double_t ymax = -bigp;
7034 Double_t ymin = bigp;
7040 Double_t allchan = 0;
7041 Int_t nonNullErrors = 0;
7042 TIter next(fFunctions);
7043 for (i=first; i<=last;i++) {
7044 c1 = fH->GetBinContent(i);
7045 ymax = TMath::Max(ymax,c1);
7047 if (c1 > 0) ymin = TMath::Min(ymin,c1);
7049 ymin = TMath::Min(ymin,c1);
7051 if (Hoption.Error) {
7052 if (fH->GetBinErrorOption() == TH1::kNormal)
7053 e1 = fH->GetBinError(i);
7055 e1 = fH->GetBinErrorUp(i);
7056 if (e1 > 0) nonNullErrors++;
7057 ymax = TMath::Max(ymax,c1+e1);
7058 if (fH->GetBinErrorOption() != TH1::kNormal)
7059 e1 = fH->GetBinErrorLow(i);
7062 if (c1-e1>0.01*TMath::Abs(c1)) ymin = TMath::Min(ymin,c1-e1);
7064 ymin = TMath::Min(ymin,c1-e1);
7068 xv[0] = fXaxis->GetBinCenter(i);
7069 while ((f = (TObject*) next())) {
7070 if (f->IsA() == TF1::Class()) {
7072 if (xv[0] < f1->GetXmin() || xv[0] > f1->GetXmax())
continue;
7073 fval = f1->Eval(xv[0],0,0);
7074 if (f1->GetMaximumStored() != -1111) fval = TMath::Min(f1->GetMaximumStored(), fval);
7075 ymax = TMath::Max(ymax,fval);
7077 if (c1 > 0 && fval > 0.3*c1) ymin = TMath::Min(ymin,fval);
7085 if (!nonNullErrors) {
7086 if (Hoption.Error) {
7087 if (!Hoption.Mark && !Hoption.Line && !Hoption.Star && !Hoption.Curve) Hoption.Hist = 2;
7095 if (Hoption.Logy && ymin <= 0) {
7096 if (ymax >= 1) ymin = TMath::Max(.005,ymax*1e-10);
7097 else ymin = 0.001*ymax;
7101 if (maximum) ymax = fH->GetMaximumStored();
7102 if (minimum) xm = fH->GetMinimumStored();
7103 if (Hoption.Logy && xm < 0) {
7104 Error(where,
"log scale requested with a negative argument (%f)", xm);
7106 }
else if (Hoption.Logy && xm>=0 && ymax==0) {
7115 if (ymax > 0) ymin = 0.001*ymax;
7117 if (!Hoption.Same) Error(where,
"log scale is requested but maximum is less or equal 0 (%f)", ymax);
7125 }
else if (ymin < 0) {
7136 if (TMath::AreEqualRel(ymin,ymax,1E-15)) {
7137 ymin = ymin*(1-1E-14);
7138 ymax = ymax*(1+1E-14);
7142 Hparam.allchan = allchan;
7143 Double_t factor = allchan;
7144 if (fH->GetNormFactor() > 0) factor = fH->GetNormFactor();
7145 if (allchan) factor /= allchan;
7146 if (factor == 0) factor = 1;
7147 Hparam.factor = factor;
7153 Double_t temp = ymax;
7163 if (ymin <=0 || ymax <=0) {
7164 Error(where,
"Cannot set Y axis to log scale");
7167 ymin = TMath::Log10(ymin);
7168 if (!minimum) ymin += TMath::Log10(0.5);
7169 ymax = TMath::Log10(ymax);
7170 if (!maximum) ymax += TMath::Log10(2*(0.9/0.95));
7171 if (!Hoption.Same) {
7182 if (Hoption.MinimumZero) {
7183 if (ymin >= 0) ymin = 0;
7184 else ymin -= yMARGIN*(ymax-ymin);
7186 Double_t dymin = yMARGIN*(ymax-ymin);
7187 if (ymin >= 0 && (ymin-dymin <= 0)) ymin = 0;
7196 ymax += yMARGIN*(ymax-ymin);
7207 Int_t THistPainter::PaintInitH()
7210 static const char *where =
"PaintInitH";
7211 Double_t yMARGIN = gStyle->GetHistTopMargin();
7214 if (fH->GetMaximumStored() != -1111) maximum = 1;
7215 if (fH->GetMinimumStored() != -1111) minimum = 1;
7219 Int_t last = fXaxis->GetLast();
7220 Int_t first = fXaxis->GetFirst();
7221 Hparam.xlowedge = fXaxis->GetBinLowEdge(first);
7222 Hparam.xbinsize = fXaxis->GetBinWidth(first);
7223 Hparam.xlast = last;
7224 Hparam.xfirst = first;
7225 Hparam.ymin = Hparam.xlowedge;
7226 Hparam.ymax = fXaxis->GetBinLowEdge(last)+fXaxis->GetBinWidth(last);
7230 if (Hparam.xlowedge <=0 ) {
7231 Hparam.xlowedge = 0.1*Hparam.xbinsize;
7232 Hparam.ymin = Hparam.xlowedge;
7234 if (Hparam.ymin <=0 || Hparam.ymax <=0) {
7235 Error(where,
"cannot set Y axis to log scale");
7238 Hparam.xfirst= fXaxis->FindFixBin(Hparam.ymin);
7239 Hparam.xlast = fXaxis->FindFixBin(Hparam.ymax);
7240 Hparam.ymin = TMath::Log10(Hparam.ymin);
7241 Hparam.ymax = TMath::Log10(Hparam.ymax);
7242 if (Hparam.xlast > last) Hparam.xlast = last;
7246 Double_t bigp = TMath::Power(10,32);
7247 Double_t xmax = -bigp;
7248 Double_t xmin = bigp;
7255 Double_t allchan = 0;
7256 TIter next(fFunctions);
7257 for (i=first; i<=last;i++) {
7258 c1 = fH->GetBinContent(i);
7259 xmax = TMath::Max(xmax,c1);
7260 xmin = TMath::Min(xmin,c1);
7261 if (Hoption.Error) {
7262 e1 = fH->GetBinError(i);
7263 xmax = TMath::Max(xmax,c1+e1);
7264 xmin = TMath::Min(xmin,c1-e1);
7267 xv[0] = fXaxis->GetBinCenter(i);
7268 while ((f = (TObject*) next())) {
7269 if (f->IsA() == TF1::Class()) {
7271 if (xv[0] < f1->GetXmin() || xv[0] > f1->GetXmax())
continue;
7272 fval = f1->Eval(xv[0],0,0);
7273 xmax = TMath::Max(xmax,fval);
7275 if (fval > 0.3*c1) xmin = TMath::Min(xmin,fval);
7286 if (Hoption.Logx && xmin <= 0) {
7287 if (xmax >= 1) xmin = TMath::Max(.5,xmax*1e-10);
7288 else xmin = 0.001*xmax;
7291 if (maximum) xmax = fH->GetMaximumStored();
7292 if (minimum) xm = fH->GetMinimumStored();
7293 if (Hoption.Logx && xm <= 0) {
7294 Error(where,
"log scale requested with zero or negative argument (%f)", xm);
7300 if (xmax > 0) xmin = 0.001*xmax;
7302 if (!Hoption.Same) Error(where,
"log scale is requested but maximum is less or equal 0 (%f)", xmax);
7310 }
else if (xmin < 0) {
7321 Hparam.allchan = allchan;
7322 Double_t factor = allchan;
7323 if (fH->GetNormFactor() > 0) factor = fH->GetNormFactor();
7324 if (allchan) factor /= allchan;
7325 if (factor == 0) factor = 1;
7326 Hparam.factor = factor;
7335 if (xmin <=0 || xmax <=0) {
7336 Error(where,
"Cannot set Y axis to log scale");
7339 xmin = TMath::Log10(xmin);
7340 if (!minimum) xmin += TMath::Log10(0.5);
7341 xmax = TMath::Log10(xmax);
7342 if (!maximum) xmax += TMath::Log10(2*(0.9/0.95));
7343 if (!Hoption.Same) {
7354 if (xmin >= 0) xmin = 0;
7355 else xmin -= yMARGIN*(xmax-xmin);
7362 xmax += yMARGIN*(xmax-xmin);
7372 void THistPainter::PaintH3Box(Int_t iopt)
7375 Double_t wxyz[8][3] = { {-1,-1,-1}, {1,-1,-1}, {1,1,-1}, {-1,1,-1},
7376 {-1,-1, 1}, {1,-1, 1}, {1,1, 1}, {-1,1, 1} };
7377 Int_t iface[6][4] = { {0,3,2,1}, {4,5,6,7},
7378 {0,1,5,4}, {1,2,6,5}, {2,3,7,6}, {3,0,4,7} };
7381 TGaxis *axis =
new TGaxis();
7382 TAxis *xaxis = fH->GetXaxis();
7383 TAxis *yaxis = fH->GetYaxis();
7384 TAxis *zaxis = fH->GetZaxis();
7386 fXbuf[0] = xaxis->GetBinLowEdge(xaxis->GetFirst());
7387 fYbuf[0] = xaxis->GetBinUpEdge(xaxis->GetLast());
7388 fXbuf[1] = yaxis->GetBinLowEdge(yaxis->GetFirst());
7389 fYbuf[1] = yaxis->GetBinUpEdge(yaxis->GetLast());
7390 fXbuf[2] = zaxis->GetBinLowEdge(zaxis->GetFirst());
7391 fYbuf[2] = zaxis->GetBinUpEdge(zaxis->GetLast());
7393 fLego =
new TPainter3dAlgorithms(fXbuf, fYbuf);
7396 TView *view = gPad->GetView();
7398 Error(
"PaintH3",
"no TView in current pad");
7401 Double_t thedeg = 90 - gPad->GetTheta();
7402 Double_t phideg = -90 - gPad->GetPhi();
7403 Double_t psideg = view->GetPsi();
7405 view->SetView(phideg, thedeg, psideg, irep);
7407 Int_t backcolor = gPad->GetFrameFillColor();
7408 view->PadRange(backcolor);
7411 fLego->InitMoveScreen(-1.1,1.1);
7412 if (Hoption.BackBox) {
7413 fLego->DefineGridLevels(fZaxis->GetNdivisions()%100);
7414 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove1);
7418 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMode1);
7421 Double_t *tnorm = view->GetTnorm();
7423 Int_t incrx = (tnorm[ 8] < 0.) ? -1 : +1;
7424 Int_t incry = (tnorm[ 9] < 0.) ? -1 : +1;
7425 Int_t incrz = (tnorm[10] < 0.) ? -1 : +1;
7426 Int_t ix1 = (incrx == +1) ? xaxis->GetFirst() : xaxis->GetLast();
7427 Int_t iy1 = (incry == +1) ? yaxis->GetFirst() : yaxis->GetLast();
7428 Int_t iz1 = (incrz == +1) ? zaxis->GetFirst() : zaxis->GetLast();
7429 Int_t ix2 = (incrx == +1) ? xaxis->GetLast() : xaxis->GetFirst();
7430 Int_t iy2 = (incry == +1) ? yaxis->GetLast() : yaxis->GetFirst();
7431 Int_t iz2 = (incrz == +1) ? zaxis->GetLast() : zaxis->GetFirst();
7434 Style_t fillsav = fH->GetFillStyle();
7435 Style_t colsav = fH->GetFillColor();
7436 Style_t coldark = TColor::GetColorDark(colsav);
7437 Style_t colbright = TColor::GetColorBright(colsav);
7439 fH->SetFillStyle(1001);
7440 fH->TAttFill::Modify();
7441 fH->TAttLine::Modify();
7442 Int_t ncolors = gStyle->GetNumberOfColors();
7446 Double_t wmin = TMath::Max(fH->GetMinimum(),0.);
7447 Double_t wmax = TMath::Max(TMath::Abs(fH->GetMaximum()),
7448 TMath::Abs(fH->GetMinimum()));
7450 Double_t pmin[3], pmax[3], sxyz[8][3];
7451 for (Int_t ix = ix1; ix !=ix2+incrx; ix += incrx) {
7452 pmin[0] = xaxis->GetBinLowEdge(ix);
7453 pmax[0] = xaxis->GetBinUpEdge(ix);
7454 for (Int_t iy = iy1; iy != iy2+incry; iy += incry) {
7455 pmin[1] = yaxis->GetBinLowEdge(iy);
7456 pmax[1] = yaxis->GetBinUpEdge(iy);
7457 for (Int_t iz = iz1; iz != iz2+incrz; iz += incrz) {
7458 pmin[2] = zaxis->GetBinLowEdge(iz);
7459 pmax[2] = zaxis->GetBinUpEdge(iz);
7460 Double_t w = fH->GetBinContent(fH->GetBin(ix,iy,iz));
7461 Bool_t neg = kFALSE;
7467 if (w < wmin)
continue;
7468 if (w > wmax) w = wmax;
7469 Double_t scale = (TMath::Power((w-wmin)/(wmax-wmin),1./3.))/2.;
7470 if (scale == 0)
continue;
7471 for (Int_t i=0; i<3; ++i) {
7472 Double_t c = (pmax[i] + pmin[i])*0.5;
7473 Double_t d = (pmax[i] - pmin[i])*scale;
7474 for (Int_t k=0; k<8; ++k) {
7475 sxyz[k][i] = wxyz[k][i]*d + c;
7478 for (Int_t k=0; k<8; ++k) {
7479 view->WCtoNDC(&sxyz[k][0],&sxyz[k][0]);
7481 Double_t x[8], y[8];
7482 for (Int_t k=0; k<6; ++k) {
7483 for (Int_t i=0; i<4; ++i) {
7484 Int_t iv = iface[k][i];
7488 x[4] = x[0] ; y[4] = y[0];
7490 x[5] = x[2] ; y[5] = y[2];
7491 x[6] = x[3] ; y[6] = y[3];
7492 x[7] = x[1] ; y[7] = y[1];
7497 Double_t z = (x[2]-x[0])*(y[3]-y[1]) - (y[2]-y[0])*(x[3]-x[1]);
7498 if (z <= 0.)
continue;
7500 theColor = ncolors*((w-wmin)/(wmax-wmin)) -1;
7501 fH->SetFillColor(gStyle->GetColorPalette(theColor));
7503 if (k == 3 || k == 5) {
7504 fH->SetFillColor(coldark);
7505 }
else if (k == 0 || k == 1) {
7506 fH->SetFillColor(colbright);
7508 fH->SetFillColor(colsav);
7511 fH->TAttFill::Modify();
7512 gPad->PaintFillArea(4, x, y);
7513 if (iopt != 3)gPad->PaintPolyLine(n, x, y);
7520 if (Hoption.FrontBox) fLego->FrontBox(90);
7523 if (!Hoption.Axis && !Hoption.Same) PaintLegoAxis(axis, 90);
7527 if (Hoption.Zscale) {
7528 Int_t ndiv = fH->GetContour();
7530 ndiv = gStyle->GetNumberContours();
7531 fH->SetContour(ndiv);
7537 delete fLego; fLego = 0;
7539 fH->SetFillStyle(fillsav);
7540 fH->SetFillColor(colsav);
7541 fH->TAttFill::Modify();
7547 void THistPainter::PaintH3BoxRaster()
7550 Double_t wxyz[8][3] = {
7551 {-1,-1,-1}, {1,-1,-1}, {1,1,-1}, {-1,1,-1},
7552 {-1,-1, 1}, {1,-1, 1}, {1,1, 1}, {-1,1, 1}
7554 Int_t iface[6][4] = {
7555 {0,3,2,1}, {4,5,6,7},
7556 {0,1,5,4}, {1,2,6,5}, {2,3,7,6}, {3,0,4,7}
7558 Double_t normal[6][3] = {
7560 {0,-1,0}, {1,0,0}, {0,1,0}, {-1,0,0}
7564 TGaxis *axis =
new TGaxis();
7565 TAxis *xaxis = fH->GetXaxis();
7566 TAxis *yaxis = fH->GetYaxis();
7567 TAxis *zaxis = fH->GetZaxis();
7569 fXbuf[0] = xaxis->GetBinLowEdge(xaxis->GetFirst());
7570 fYbuf[0] = xaxis->GetBinUpEdge(xaxis->GetLast());
7571 fXbuf[1] = yaxis->GetBinLowEdge(yaxis->GetFirst());
7572 fYbuf[1] = yaxis->GetBinUpEdge(yaxis->GetLast());
7573 fXbuf[2] = zaxis->GetBinLowEdge(zaxis->GetFirst());
7574 fYbuf[2] = zaxis->GetBinUpEdge(zaxis->GetLast());
7576 fLego =
new TPainter3dAlgorithms(fXbuf, fYbuf);
7579 TView *view = gPad->GetView();
7581 Error(
"PaintH3",
"no TView in current pad");
7584 Double_t thedeg = 90 - gPad->GetTheta();
7585 Double_t phideg = -90 - gPad->GetPhi();
7586 Double_t psideg = view->GetPsi();
7588 view->SetView(phideg, thedeg, psideg, irep);
7590 Int_t backcolor = gPad->GetFrameFillColor();
7591 view->PadRange(backcolor);
7594 if (Hoption.FrontBox) {
7595 fLego->InitMoveScreen(-1.1,1.1);
7596 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove2);
7600 fLego->InitRaster(-1.1,-1.1,1.1,1.1,1000,800);
7603 Double_t *tnorm = view->GetTnorm();
7605 Int_t incrx = (tnorm[ 8] < 0.) ? +1 : -1;
7606 Int_t incry = (tnorm[ 9] < 0.) ? +1 : -1;
7607 Int_t incrz = (tnorm[10] < 0.) ? +1 : -1;
7608 Int_t ix1 = (incrx == +1) ? xaxis->GetFirst() : xaxis->GetLast();
7609 Int_t iy1 = (incry == +1) ? yaxis->GetFirst() : yaxis->GetLast();
7610 Int_t iz1 = (incrz == +1) ? zaxis->GetFirst() : zaxis->GetLast();
7611 Int_t ix2 = (incrx == +1) ? xaxis->GetLast() : xaxis->GetFirst();
7612 Int_t iy2 = (incry == +1) ? yaxis->GetLast() : yaxis->GetFirst();
7613 Int_t iz2 = (incrz == +1) ? zaxis->GetLast() : zaxis->GetFirst();
7616 fH->TAttLine::Modify();
7619 const Int_t NTMAX = 100;
7620 Double_t tt[NTMAX][2];
7621 Double_t wmin = TMath::Max(fH->GetMinimum(),0.);
7622 Double_t wmax = TMath::Max(TMath::Abs(fH->GetMaximum()),
7623 TMath::Abs(fH->GetMinimum()));
7624 Double_t pmin[3], pmax[3], sxyz[8][3], pp[4][2];
7625 for (Int_t ix = ix1; ix !=ix2+incrx; ix += incrx) {
7626 pmin[0] = xaxis->GetBinLowEdge(ix);
7627 pmax[0] = xaxis->GetBinUpEdge(ix);
7628 for (Int_t iy = iy1; iy != iy2+incry; iy += incry) {
7629 pmin[1] = yaxis->GetBinLowEdge(iy);
7630 pmax[1] = yaxis->GetBinUpEdge(iy);
7631 for (Int_t iz = iz1; iz != iz2+incrz; iz += incrz) {
7632 pmin[2] = zaxis->GetBinLowEdge(iz);
7633 pmax[2] = zaxis->GetBinUpEdge(iz);
7634 Double_t w = fH->GetBinContent(fH->GetBin(ix,iy,iz));
7635 Bool_t neg = kFALSE;
7640 if (w < wmin)
continue;
7641 if (w > wmax) w = wmax;
7642 Double_t scale = (TMath::Power((w-wmin)/(wmax-wmin),1./3.))/2.;
7643 if (scale == 0)
continue;
7644 for (Int_t i=0; i<3; ++i) {
7645 Double_t c = (pmax[i] + pmin[i])*0.5;
7646 Double_t d = (pmax[i] - pmin[i])*scale;
7647 for (Int_t k=0; k<8; ++k) {
7648 sxyz[k][i] = wxyz[k][i]*d + c;
7651 for (Int_t k=0; k<8; ++k) {
7652 view->WCtoNDC(&sxyz[k][0],&sxyz[k][0]);
7654 for (Int_t k=0; k<6; ++k) {
7656 view->FindNormal(normal[k][0], normal[k][1], normal[k][2], zn);
7657 if (zn <= 0)
continue;
7658 for (Int_t i=0; i<4; ++i) {
7659 Int_t ip = iface[k][i];
7660 pp[i][0] = sxyz[ip][0];
7661 pp[i][1] = sxyz[ip][1];
7663 for (Int_t i=0; i<4; ++i) {
7665 Int_t i2 = (i == 3) ? 0 : i + 1;
7667 fLego->FindVisibleLine(&pp[i1][0], &pp[i2][0], NTMAX, nt, &tt[0][0]);
7668 Double_t xdel = pp[i2][0] - pp[i1][0];
7669 Double_t ydel = pp[i2][1] - pp[i1][1];
7670 Double_t x[2], y[2];
7671 for (Int_t it = 0; it < nt; ++it) {
7672 x[0] = pp[i1][0] + xdel*tt[it][0];
7673 y[0] = pp[i1][1] + ydel*tt[it][0];
7674 x[1] = pp[i1][0] + xdel*tt[it][1];
7675 y[1] = pp[i1][1] + ydel*tt[it][1];
7676 gPad->PaintPolyLine(2, x, y);
7683 fLego->FindVisibleLine(&pp[i1][0], &pp[i2][0], NTMAX, nt, &tt[0][0]);
7684 Double_t xdel = pp[i2][0] - pp[i1][0];
7685 Double_t ydel = pp[i2][1] - pp[i1][1];
7686 Double_t x[2], y[2];
7687 for (Int_t it = 0; it < nt; ++it) {
7688 x[0] = pp[i1][0] + xdel*tt[it][0];
7689 y[0] = pp[i1][1] + ydel*tt[it][0];
7690 x[1] = pp[i1][0] + xdel*tt[it][1];
7691 y[1] = pp[i1][1] + ydel*tt[it][1];
7692 gPad->PaintPolyLine(2, x, y);
7696 fLego->FindVisibleLine(&pp[i1][0], &pp[i2][0], NTMAX, nt, &tt[0][0]);
7697 xdel = pp[i2][0] - pp[i1][0];
7698 ydel = pp[i2][1] - pp[i1][1];
7699 for (Int_t it = 0; it < nt; ++it) {
7700 x[0] = pp[i1][0] + xdel*tt[it][0];
7701 y[0] = pp[i1][1] + ydel*tt[it][0];
7702 x[1] = pp[i1][0] + xdel*tt[it][1];
7703 y[1] = pp[i1][1] + ydel*tt[it][1];
7704 gPad->PaintPolyLine(2, x, y);
7707 fLego->FillPolygonBorder(4, &pp[0][0]);
7714 if (Hoption.BackBox) {
7715 fLego->DefineGridLevels(fZaxis->GetNdivisions()%100);
7716 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceRaster1);
7720 if (Hoption.FrontBox) fLego->FrontBox(90);
7723 if (!Hoption.Axis && !Hoption.Same) PaintLegoAxis(axis, 90);
7727 delete fLego; fLego = 0;
7733 void THistPainter::PaintH3Iso()
7736 const Double_t ydiff = 1;
7737 const Double_t yligh1 = 10;
7738 const Double_t qa = 0.15;
7739 const Double_t qd = 0.15;
7740 const Double_t qs = 0.8;
7741 Double_t fmin, fmax;
7746 Int_t ic2 = ic1+nbcol;
7747 Int_t ic3 = ic2+nbcol;
7749 TGaxis *axis =
new TGaxis();
7750 TAxis *xaxis = fH->GetXaxis();
7751 TAxis *yaxis = fH->GetYaxis();
7752 TAxis *zaxis = fH->GetZaxis();
7754 Int_t nx = fH->GetNbinsX();
7755 Int_t ny = fH->GetNbinsY();
7756 Int_t nz = fH->GetNbinsZ();
7758 Double_t *x =
new Double_t[nx];
7759 Double_t *y =
new Double_t[ny];
7760 Double_t *z =
new Double_t[nz];
7762 for (i=0; i<nx; i++) x[i] = xaxis->GetBinCenter(i+1);
7763 for (i=0; i<ny; i++) y[i] = yaxis->GetBinCenter(i+1);
7764 for (i=0; i<nz; i++) z[i] = zaxis->GetBinCenter(i+1);
7766 fXbuf[0] = xaxis->GetBinLowEdge(xaxis->GetFirst());
7767 fYbuf[0] = xaxis->GetBinUpEdge(xaxis->GetLast());
7768 fXbuf[1] = yaxis->GetBinLowEdge(yaxis->GetFirst());
7769 fYbuf[1] = yaxis->GetBinUpEdge(yaxis->GetLast());
7770 fXbuf[2] = zaxis->GetBinLowEdge(zaxis->GetFirst());
7771 fYbuf[2] = zaxis->GetBinUpEdge(zaxis->GetLast());
7774 s[0] = fH->GetSumOfWeights()/(fH->GetNbinsX()*fH->GetNbinsY()*fH->GetNbinsZ());
7778 fLego =
new TPainter3dAlgorithms(fXbuf, fYbuf);
7780 TView *view = gPad->GetView();
7782 Error(
"PaintH3Iso",
"no TView in current pad");
7788 Double_t thedeg = 90 - gPad->GetTheta();
7789 Double_t phideg = -90 - gPad->GetPhi();
7790 Double_t psideg = view->GetPsi();
7791 view->SetView(phideg, thedeg, psideg, irep);
7793 Int_t backcolor = gPad->GetFrameFillColor();
7794 if (Hoption.System != kCARTESIAN) backcolor = 0;
7795 view->PadRange(backcolor);
7797 Double_t dcol = 0.5/Double_t(nbcol);
7798 TColor *colref = gROOT->GetColor(fH->GetFillColor());
7805 Float_t r, g, b, hue, light, satur;
7806 colref->GetRGB(r,g,b);
7807 TColor::RGBtoHLS(r,g,b,hue,light,satur);
7809 for (Int_t col=0;col<nbcol;col++) {
7810 acol = gROOT->GetColor(col+icol1);
7811 TColor::HLStoRGB(hue, .4+col*dcol, satur, r, g, b);
7812 if (acol) acol->SetRGB(r, g, b);
7815 fLego->InitMoveScreen(-1.1,1.1);
7817 if (Hoption.BackBox) {
7818 fLego->DefineGridLevels(fZaxis->GetNdivisions()%100);
7819 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove1);
7823 fLego->LightSource(0, ydiff, 0, 0, 0, irep);
7824 fLego->LightSource(1, yligh1, 1, 1, 1, irep);
7825 fLego->SurfaceProperty(qa, qd, qs, 1, irep);
7827 fmax = ydiff*qa + (yligh1+0.1)*(qd+qs);
7828 fLego->SetIsoSurfaceParameters(fmin, fmax, nbcol, ic1, ic2, ic3);
7830 fLego->IsoSurface(1, s, nx, ny, nz, x, y, z,
"BF");
7832 if (Hoption.FrontBox) {
7833 fLego->InitMoveScreen(-1.1,1.1);
7834 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove2);
7835 fLego->FrontBox(90);
7837 if (!Hoption.Axis && !Hoption.Same) PaintLegoAxis(axis, 90);
7842 delete fLego; fLego = 0;
7851 void THistPainter::PaintLego(Option_t *)
7855 if (Hparam.zmin == 0 && Hparam.zmax == 0) {Hparam.zmin = -1; Hparam.zmax = 1;}
7856 Int_t nx = Hparam.xlast - Hparam.xfirst + 1;
7857 Int_t ny = Hparam.ylast - Hparam.yfirst + 1;
7858 Double_t zmin = Hparam.zmin;
7859 Double_t zmax = Hparam.zmax;
7860 Double_t xlab1 = Hparam.xmin;
7861 Double_t xlab2 = Hparam.xmax;
7862 Double_t ylab1 = Hparam.ymin;
7863 Double_t ylab2 = Hparam.ymax;
7864 Double_t dangle = 10*3.141592/180;
7865 Double_t deltaz = TMath::Abs(zmin);
7866 if (deltaz == 0) deltaz = 1;
7871 Double_t z1c = zmin;
7872 Double_t z2c = zmin + (zmax-zmin)*(1+gStyle->GetHistTopMargin());
7879 if (Hoption.System == kPOLAR) {
7882 }
else if (Hoption.System == kCYLINDRICAL) {
7884 if (ylab1 > 0) fXbuf[2] = TMath::Log10(ylab1);
7886 if (ylab2 > 0) fYbuf[2] = TMath::Log10(ylab2);
7893 }
else if (Hoption.System == kSPHERICAL) {
7897 }
else if (Hoption.System == kRAPIDITY) {
7898 fXbuf[2] = -1/TMath::Tan(dangle);
7899 fYbuf[2] = 1/TMath::Tan(dangle);
7910 fLego =
new TPainter3dAlgorithms(fXbuf, fYbuf, Hoption.System);
7914 Color_t colormain = -1, colordark = -1;
7915 Bool_t drawShadowsInLego1 = kTRUE;
7918 if (Hoption.Lego == 13) {
7923 if (Hoption.Lego == 14) {
7925 drawShadowsInLego1 = kFALSE;
7930 TGaxis *axis =
new TGaxis();
7933 Int_t ndiv = fH->GetContour();
7935 ndiv = gStyle->GetNumberContours();
7936 fH->SetContour(ndiv);
7938 Int_t ndivz = TMath::Abs(ndiv);
7939 if (fH->TestBit(TH1::kUserContour) == 0) fH->SetContour(ndiv);
7943 fLego->SetEdgeAtt(fH->GetLineColor(),fH->GetLineStyle(),fH->GetLineWidth(),0);
7945 for (Int_t
id=0;
id<=fStack->GetSize();
id++) {
7946 hid = (TH1*)fStack->At((
id==0)?
id:
id-1);
7947 fLego->SetEdgeAtt(hid->GetLineColor(),hid->GetLineStyle(),hid->GetLineWidth(),id);
7951 if (Hoption.Lego == 11) {
7953 if (fStack) nids = fStack->GetSize();
7955 for (Int_t
id=0;
id<=nids;
id++) {
7956 if (
id > 0 && fStack) hid = (TH1*)fStack->At(
id-1);
7957 colormain = hid->GetFillColor();
7958 if (colormain == 1) colormain = 17;
7959 if (drawShadowsInLego1) colordark = TColor::GetColorDark(colormain);
7960 else colordark = colormain;
7961 fLego->SetColorMain(colormain,
id);
7962 fLego->SetColorDark(colordark,
id);
7963 if (
id <= 1) fLego->SetColorMain(colormain,-1);
7964 if (
id == nids) fLego->SetColorMain(colormain,99);
7971 TView *view = gPad->GetView();
7973 Error(
"PaintLego",
"no TView in current pad");
7977 Double_t thedeg = 90 - gPad->GetTheta();
7978 Double_t phideg = -90 - gPad->GetPhi();
7979 Double_t psideg = view->GetPsi();
7980 view->SetView(phideg, thedeg, psideg, irep);
7982 fLego->SetLineColor(kBlack);
7983 fLego->SetFillStyle(fH->GetFillStyle());
7986 fLego->SetFillStyle(gPad->GetFrameFillStyle());
7987 fLego->SetFillColor(gPad->GetFrameFillColor());
7988 fLego->TAttFill::Modify();
7990 Int_t backcolor = gPad->GetFrameFillColor();
7991 if (Hoption.System != kCARTESIAN) backcolor = 0;
7992 view->PadRange(backcolor);
7994 fLego->SetFillStyle(fH->GetFillStyle());
7995 fLego->SetFillColor(fH->GetFillColor());
7996 fLego->TAttFill::Modify();
7998 fLego->DefineGridLevels(fZaxis->GetNdivisions()%100);
8000 if (raster) fLego->InitRaster(-1.1,-1.1,1.1,1.1,1000,800);
8001 else fLego->InitMoveScreen(-1.1,1.1);
8003 if (Hoption.Lego == 19) {
8004 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove1);
8005 if (Hoption.BackBox) fLego->BackBox(90);
8006 if (Hoption.FrontBox) fLego->FrontBox(90);
8007 if (!Hoption.Axis) PaintLegoAxis(axis, 90);
8011 if (Hoption.Lego == 11 || Hoption.Lego == 12) {
8012 if (Hoption.System == kCARTESIAN && Hoption.BackBox) {
8013 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove1);
8018 if (Hoption.Lego == 12) DefineColorLevels(ndivz);
8020 fLego->SetLegoFunction(&TPainter3dAlgorithms::LegoFunction);
8021 if (Hoption.Lego == 1) fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceRaster2);
8022 if (Hoption.Lego == 11) fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMode3);
8023 if (Hoption.Lego == 12) fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMode2);
8024 if (Hoption.System == kPOLAR) {
8025 if (Hoption.Lego == 1) fLego->LegoPolar(1,nx,ny,
"FB");
8026 if (Hoption.Lego == 11) fLego->LegoPolar(1,nx,ny,
"BF");
8027 if (Hoption.Lego == 12) fLego->LegoPolar(1,nx,ny,
"BF");
8028 }
else if (Hoption.System == kCYLINDRICAL) {
8029 if (Hoption.Lego == 1) fLego->LegoCylindrical(1,nx,ny,
"FB");
8030 if (Hoption.Lego == 11) fLego->LegoCylindrical(1,nx,ny,
"BF");
8031 if (Hoption.Lego == 12) fLego->LegoCylindrical(1,nx,ny,
"BF");
8032 }
else if (Hoption.System == kSPHERICAL) {
8033 if (Hoption.Lego == 1) fLego->LegoSpherical(0,1,nx,ny,
"FB");
8034 if (Hoption.Lego == 11) fLego->LegoSpherical(0,1,nx,ny,
"BF");
8035 if (Hoption.Lego == 12) fLego->LegoSpherical(0,1,nx,ny,
"BF");
8036 }
else if (Hoption.System == kRAPIDITY) {
8037 if (Hoption.Lego == 1) fLego->LegoSpherical(1,1,nx,ny,
"FB");
8038 if (Hoption.Lego == 11) fLego->LegoSpherical(1,1,nx,ny,
"BF");
8039 if (Hoption.Lego == 12) fLego->LegoSpherical(1,1,nx,ny,
"BF");
8041 if (Hoption.Lego == 1) {
8042 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove2);
8043 fLego->LegoCartesian(90,nx,ny,
"FB");}
8044 if (Hoption.Lego == 11) fLego->LegoCartesian(90,nx,ny,
"BF");
8045 if (Hoption.Lego == 12) fLego->LegoCartesian(90,nx,ny,
"BF");
8048 if (Hoption.Lego == 1 || Hoption.Lego == 11) {
8049 if (Hoption.System == kCARTESIAN && Hoption.BackBox) {
8050 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove1);
8054 if (Hoption.System == kCARTESIAN) {
8055 fLego->InitMoveScreen(-1.1,1.1);
8056 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove2);
8057 if (Hoption.FrontBox) fLego->FrontBox(90);
8059 if (!Hoption.Axis && !Hoption.Same) PaintLegoAxis(axis, 90);
8060 if (Hoption.Zscale) PaintPalette();
8062 delete fLego; fLego = 0;
8068 void THistPainter::PaintLegoAxis(TGaxis *axis, Double_t ang)
8071 static Double_t epsil = 0.001;
8073 Double_t cosa, sina;
8074 Double_t bmin, bmax;
8076 Int_t ndivx, ndivy, ndivz, i;
8077 Double_t x1[3], x2[3], y1[3], y2[3], z1[3], z2[3], av[24] ;
8078 static char chopax[8], chopay[8], chopaz[8];
8079 Int_t ix1, ix2, iy1, iy2, iz1, iz2;
8082 TView *view = gPad->GetView();
8084 Error(
"PaintLegoAxis",
"no TView in current pad");
8090 if (Hoption.System == kPOLAR) {
8094 view->WCtoNDC(r, x1);
8098 view->WCtoNDC(r, x2);
8099 gPad->PaintLine(x1[0],x1[1],x2[0],x2[1]);
8103 if (Hoption.System != kCARTESIAN)
return;
8105 rad = TMath::ATan(1.) * 4. /180.;
8106 cosa = TMath::Cos(ang*rad);
8107 sina = TMath::Sin(ang*rad);
8109 view->AxisVertex(ang, av, ix1, ix2, iy1, iy2, iz1, iz2);
8110 for (i = 1; i <= 8; ++i) {
8111 r[i*3 - 3] = av[i*3 - 3] + av[i*3 - 2]*cosa;
8112 r[i*3 - 2] = av[i*3 - 2]*sina;
8113 r[i*3 - 1] = av[i*3 - 1];
8116 view->WCtoNDC(&r[ix1*3 - 3], x1);
8117 view->WCtoNDC(&r[ix2*3 - 3], x2);
8118 view->WCtoNDC(&r[iy1*3 - 3], y1);
8119 view->WCtoNDC(&r[iy2*3 - 3], y2);
8120 view->WCtoNDC(&r[iz1*3 - 3], z1);
8121 view->WCtoNDC(&r[iz2*3 - 3], z2);
8123 view->SetAxisNDC(x1, x2, y1, y2, z1, z2);
8125 Double_t *rmin = view->GetRmin();
8126 Double_t *rmax = view->GetRmax();
8127 if (!rmin || !rmax)
return;
8130 if (x1[0] > x2[0]) strlcpy(chopax,
"SDH=+",8);
8131 else strlcpy(chopax,
"SDH=-",8);
8132 if (y1[0] > y2[0]) strlcpy(chopay,
"SDH=+",8);
8133 else strlcpy(chopay,
"SDH=-",8);
8134 if (z2[1] > z1[1]) strlcpy(chopaz,
"SDH=+",8);
8135 else strlcpy(chopaz,
"SDH=-",8);
8138 if (Hoption.Logx) strlcat(chopax,
"G",8);
8139 if (Hoption.Logy) strlcat(chopay,
"G",8);
8140 if (Hoption.Logz) strlcat(chopaz,
"G",8);
8144 ndivx = fXaxis->GetNdivisions();
8145 ndivy = fYaxis->GetNdivisions();
8146 ndivz = fZaxis->GetNdivisions();
8148 ndivx = TMath::Abs(ndivx);
8149 strlcat(chopax,
"N",8);
8152 ndivy = TMath::Abs(ndivy);
8153 strlcat(chopay,
"N",8);
8156 ndivz = TMath::Abs(ndivz);
8157 strlcat(chopaz,
"N",8);
8164 axis->SetLineWidth(1);
8167 if (TMath::Abs(x1[0] - x2[0]) >= epsil || TMath::Abs(x1[1] - x2[1]) > epsil) {
8168 axis->ImportAxisAttributes(fXaxis);
8169 axis->SetLabelOffset(fXaxis->GetLabelOffset()+fXaxis->GetTickLength());
8170 if (Hoption.Logx && !fH->InheritsFrom(TH3::Class())) {
8171 bmin = TMath::Power(10, rmin[0]);
8172 bmax = TMath::Power(10, rmax[0]);
8178 if (fXaxis->GetTimeDisplay()) {
8179 strlcat(chopax,
"t",8);
8180 if (strlen(fXaxis->GetTimeFormatOnly()) == 0) {
8181 axis->SetTimeFormat(fXaxis->ChooseTimeFormat(bmax-bmin));
8183 axis->SetTimeFormat(fXaxis->GetTimeFormat());
8186 axis->SetOption(chopax);
8187 axis->PaintAxis(x1[0], x1[1], x2[0], x2[1], bmin, bmax, ndivx, chopax);
8191 if (TMath::Abs(y1[0] - y2[0]) >= epsil || TMath::Abs(y1[1] - y2[1]) > epsil) {
8192 axis->ImportAxisAttributes(fYaxis);
8193 axis->SetLabelOffset(fYaxis->GetLabelOffset()+fYaxis->GetTickLength());
8194 if (fYaxis->GetTitleOffset() == 0) axis->SetTitleOffset(1.5);
8196 if (fH->GetDimension() < 2) {
8197 strlcpy(chopay,
"V=+UN",8);
8200 if (TMath::Abs(y1[0] - y2[0]) < epsil) {
8203 if (Hoption.Logy && !fH->InheritsFrom(TH3::Class())) {
8204 bmin = TMath::Power(10, rmin[1]);
8205 bmax = TMath::Power(10, rmax[1]);
8211 if (fYaxis->GetTimeDisplay()) {
8212 strlcat(chopay,
"t",8);
8213 if (strlen(fYaxis->GetTimeFormatOnly()) == 0) {
8214 axis->SetTimeFormat(fYaxis->ChooseTimeFormat(bmax-bmin));
8216 axis->SetTimeFormat(fYaxis->GetTimeFormat());
8219 axis->SetOption(chopay);
8220 axis->PaintAxis(y1[0], y1[1], y2[0], y2[1], bmin, bmax, ndivy, chopay);
8224 if (TMath::Abs(z1[0] - z2[0]) >= 100*epsil || TMath::Abs(z1[1] - z2[1]) > 100*epsil) {
8225 axis->ImportAxisAttributes(fZaxis);
8226 if (Hoption.Logz && !fH->InheritsFrom(TH3::Class())) {
8227 bmin = TMath::Power(10, rmin[2]);
8228 bmax = TMath::Power(10, rmax[2]);
8234 if (fZaxis->GetTimeDisplay()) {
8235 strlcat(chopaz,
"t",8);
8236 if (strlen(fZaxis->GetTimeFormatOnly()) == 0) {
8237 axis->SetTimeFormat(fZaxis->ChooseTimeFormat(bmax-bmin));
8239 axis->SetTimeFormat(fZaxis->GetTimeFormat());
8242 axis->SetOption(chopaz);
8243 axis->PaintAxis(z1[0], z1[1], z2[0], z2[1], bmin, bmax, ndivz, chopaz);
8252 void THistPainter::PaintPalette()
8255 TPaletteAxis *palette = (TPaletteAxis*)fFunctions->FindObject(
"palette");
8256 TView *view = gPad->GetView();
8259 if (!palette->TestBit(TPaletteAxis::kHasView)) {
8260 fFunctions->Remove(palette);
8261 delete palette; palette = 0;
8264 if (palette->TestBit(TPaletteAxis::kHasView)) {
8265 fFunctions->Remove(palette);
8266 delete palette; palette = 0;
8270 if (palette && !palette->GetHistogram()) palette->SetHistogram(fH);
8274 Double_t xup = gPad->GetUxmax();
8275 Double_t x2 = gPad->PadtoX(gPad->GetX2());
8276 Double_t ymin = gPad->PadtoY(gPad->GetUymin());
8277 Double_t ymax = gPad->PadtoY(gPad->GetUymax());
8278 Double_t xr = 0.05*(gPad->GetX2() - gPad->GetX1());
8279 Double_t xmin = gPad->PadtoX(xup +0.1*xr);
8280 Double_t xmax = gPad->PadtoX(xup + xr);
8281 if (xmax > x2) xmax = gPad->PadtoX(gPad->GetX2()-0.01*xr);
8282 palette =
new TPaletteAxis(xmin,ymin,xmax,ymax,fH);
8283 fFunctions->AddFirst(palette);
8291 void THistPainter::PaintScatterPlot(Option_t *option)
8294 fH->TAttMarker::Modify();
8297 Double_t dz, z, xk,xstep, yk, ystep;
8299 Bool_t ltest = kFALSE;
8300 Double_t zmax = fH->GetMaximum();
8301 Double_t zmin = fH->GetMinimum();
8302 if (zmin == 0 && zmax == 0)
return;
8304 zmax += 0.1*TMath::Abs(zmax);
8305 zmin -= 0.1*TMath::Abs(zmin);
8307 Int_t ncells = (Hparam.ylast-Hparam.yfirst)*(Hparam.xlast-Hparam.xfirst);
8309 if (zmin > 0) zmin = TMath::Log10(zmin);
8311 if (zmax > 0) zmax = TMath::Log10(zmax);
8313 if (zmin == 0 && zmax == 0)
return;
8316 if (ncells > 10000) scale /= 5;
8320 if (dz >= kNMAX || zmax < 1) {
8321 scale = (kNMAX-1)/dz;
8322 if (ncells > 10000) scale /= 5;
8326 if (fH->GetMinimumStored() == -1111) {
8327 Double_t yMARGIN = gStyle->GetHistTopMargin();
8328 if (Hoption.MinimumZero) {
8329 if (zmin >= 0) zmin = 0;
8330 else zmin -= yMARGIN*(zmax-zmin);
8332 Double_t dzmin = yMARGIN*(zmax-zmin);
8333 if (zmin >= 0 && (zmin-dzmin <= 0)) zmin = 0;
8338 TString opt = option;
8340 if (opt.Contains(
"scat=")) {
8342 strlcpy(optscat,opt.Data(),100);
8343 char *oscat = strstr(optscat,
"scat=");
8344 char *blank = strstr(oscat,
" ");
if (blank) *blank = 0;
8345 sscanf(oscat+5,
"%lg",&scale);
8352 for (Int_t j=Hparam.yfirst; j<=Hparam.ylast;j++) {
8353 yk = fYaxis->GetBinLowEdge(j);
8354 ystep = fYaxis->GetBinWidth(j);
8355 for (Int_t i=Hparam.xfirst; i<=Hparam.xlast;i++) {
8356 Int_t bin = j*(fXaxis->GetNbins()+2) + i;
8357 xk = fXaxis->GetBinLowEdge(i);
8358 xstep = fXaxis->GetBinWidth(i);
8359 if (!IsInside(xk+0.5*xstep,yk+0.5*ystep))
continue;
8360 z = fH->GetBinContent(bin);
8361 if (z < zmin) z = zmin;
8362 if (z > zmax) z = zmax;
8364 if (z > 0) z = TMath::Log10(z) - zmin;
8368 if (z <= 0)
continue;
8372 for (Int_t loop=0; loop<k; loop++) {
8373 if (k+marker >= kNMAX) {
8374 gPad->PaintPolyMarker(marker, fXbuf, fYbuf);
8377 fXbuf[marker] = (random.Rndm()*xstep) + xk;
8378 fYbuf[marker] = (random.Rndm()*ystep) + yk;
8380 if (fXbuf[marker] > 0) fXbuf[marker] = TMath::Log10(fXbuf[marker]);
8384 if (fYbuf[marker] > 0) fYbuf[marker] = TMath::Log10(fYbuf[marker]);
8387 if (fXbuf[marker] < gPad->GetUxmin())
break;
8388 if (fYbuf[marker] < gPad->GetUymin())
break;
8389 if (fXbuf[marker] > gPad->GetUxmax())
break;
8390 if (fYbuf[marker] > gPad->GetUymax())
break;
8396 if (marker > 0) gPad->PaintPolyMarker(marker, fXbuf, fYbuf);
8398 if (Hoption.Zscale) PaintPalette();
8407 void THistPainter::PaintSpecialObjects(
const TObject *obj, Option_t *option)
8411 Bool_t status = TH1::AddDirectoryStatus();
8412 TH1::AddDirectory(kFALSE);
8414 if (obj->InheritsFrom(TMatrixFBase::Class())) {
8416 TH2F *R__TMatrixFBase =
new TH2F((TMatrixFBase &)*obj);
8417 R__TMatrixFBase->SetBit(kCanDelete);
8418 R__TMatrixFBase->Draw(option);
8420 }
else if (obj->InheritsFrom(TMatrixDBase::Class())) {
8422 TH2D *R__TMatrixDBase =
new TH2D((TMatrixDBase &)*obj);
8423 R__TMatrixDBase->SetBit(kCanDelete);
8424 R__TMatrixDBase->Draw(option);
8426 }
else if (obj->InheritsFrom(TVectorF::Class())) {
8428 TH1F *R__TVectorF =
new TH1F((TVectorF &)*obj);
8429 R__TVectorF->SetBit(kCanDelete);
8430 R__TVectorF->Draw(option);
8432 }
else if (obj->InheritsFrom(TVectorD::Class())) {
8434 TH1D *R__TVectorD =
new TH1D((TVectorD &)*obj);
8435 R__TVectorD->SetBit(kCanDelete);
8436 R__TVectorD->Draw(option);
8439 TH1::AddDirectory(status);
8445 void THistPainter::PaintStat(Int_t dostat, TF1 *fit)
8450 TPaveStats *stats = 0;
8451 TIter next(fFunctions);
8453 while ((obj = next())) {
8454 if (obj->InheritsFrom(TPaveStats::Class())) {
8455 stats = (TPaveStats*)obj;
8460 if (stats && dostat) {
8461 dofit = stats->GetOptFit();
8462 dostat = stats->GetOptStat();
8464 dofit = gStyle->GetOptFit();
8466 if (!dofit) fit = 0;
8467 if (dofit == 1) dofit = 111;
8468 if (dostat == 1) dostat = 1111;
8469 Int_t print_name = dostat%10;
8470 Int_t print_entries = (dostat/10)%10;
8471 Int_t print_mean = (dostat/100)%10;
8472 Int_t print_stddev = (dostat/1000)%10;
8473 Int_t print_under = (dostat/10000)%10;
8474 Int_t print_over = (dostat/100000)%10;
8475 Int_t print_integral= (dostat/1000000)%10;
8476 Int_t print_skew = (dostat/10000000)%10;
8477 Int_t print_kurt = (dostat/100000000)%10;
8478 Int_t nlines = print_name + print_entries + print_mean + print_stddev +
8479 print_under + print_over + print_integral +
8480 print_skew + print_kurt;
8481 Int_t print_fval = dofit%10;
8482 Int_t print_ferrors = (dofit/10)%10;
8483 Int_t print_fchi2 = (dofit/100)%10;
8484 Int_t print_fprob = (dofit/1000)%10;
8485 Int_t nlinesf = print_fval + print_fchi2 + print_fprob;
8487 if (print_fval < 2) nlinesf += fit->GetNumberFreeParameters();
8488 else nlinesf += fit->GetNpar();
8490 if (fH->InheritsFrom(TProfile::Class())) nlinesf += print_mean + print_stddev;
8493 Bool_t done = kFALSE;
8494 if (!dostat && !fit) {
8495 if (stats) { fFunctions->Remove(stats);
delete stats;}
8498 Double_t statw = gStyle->GetStatW();
8499 if (fit) statw = 1.8*gStyle->GetStatW();
8500 Double_t stath = (nlines+nlinesf)*gStyle->GetStatFontSize();
8501 if (stath <= 0 || 3 == (gStyle->GetStatFont()%10)) {
8502 stath = 0.25*(nlines+nlinesf)*gStyle->GetStatH();
8508 stats =
new TPaveStats(
8509 gStyle->GetStatX()-statw,
8510 gStyle->GetStatY()-stath,
8512 gStyle->GetStatY(),
"brNDC");
8514 stats->SetParent(fH);
8515 stats->SetOptFit(dofit);
8516 stats->SetOptStat(dostat);
8517 stats->SetFillColor(gStyle->GetStatColor());
8518 stats->SetFillStyle(gStyle->GetStatStyle());
8519 stats->SetBorderSize(gStyle->GetStatBorderSize());
8520 stats->SetTextFont(gStyle->GetStatFont());
8521 if (gStyle->GetStatFont()%10 > 2)
8522 stats->SetTextSize(gStyle->GetStatFontSize());
8523 stats->SetFitFormat(gStyle->GetFitFormat());
8524 stats->SetStatFormat(gStyle->GetStatFormat());
8525 stats->SetName(
"stats");
8527 stats->SetTextColor(gStyle->GetStatTextColor());
8528 stats->SetTextAlign(12);
8529 stats->SetBit(kCanDelete);
8530 stats->SetBit(kMustCleanup);
8532 if (print_name) stats->AddText(fH->GetName());
8533 if (print_entries) {
8534 if (fH->GetEntries() < 1e7) tt.Form(
"%s = %-7d",gStringEntries.Data(),Int_t(fH->GetEntries()+0.5));
8535 else tt.Form(
"%s = %14.7g",gStringEntries.Data(),Float_t(fH->GetEntries()));
8536 stats->AddText(tt.Data());
8539 if (print_mean == 1) {
8540 tf.Form(
"%s = %s%s",gStringMean.Data(),
"%",stats->GetStatFormat());
8541 tt.Form(tf.Data(),fH->GetMean(1));
8543 tf.Form(
"%s = %s%s #pm %s%s",gStringMean.Data(),
"%",stats->GetStatFormat()
8544 ,
"%",stats->GetStatFormat());
8545 tt.Form(tf.Data(),fH->GetMean(1),fH->GetMeanError(1));
8547 stats->AddText(tt.Data());
8548 if (fH->InheritsFrom(TProfile::Class())) {
8549 if (print_mean == 1) {
8550 tf.Form(
"%s = %s%s",gStringMeanY.Data(),
"%",stats->GetStatFormat());
8551 tt.Form(tf.Data(),fH->GetMean(2));
8553 tf.Form(
"%s = %s%s #pm %s%s",gStringMeanY.Data(),
"%",stats->GetStatFormat()
8554 ,
"%",stats->GetStatFormat());
8555 tt.Form(tf.Data(),fH->GetMean(2),fH->GetMeanError(2));
8557 stats->AddText(tt.Data());
8561 if (print_stddev == 1) {
8562 tf.Form(
"%s = %s%s",gStringStdDev.Data(),
"%",stats->GetStatFormat());
8563 tt.Form(tf.Data(),fH->GetStdDev(1));
8565 tf.Form(
"%s = %s%s #pm %s%s",gStringStdDev.Data(),
"%",stats->GetStatFormat()
8566 ,
"%",stats->GetStatFormat());
8567 tt.Form(tf.Data(),fH->GetStdDev(1),fH->GetStdDevError(1));
8569 stats->AddText(tt.Data());
8570 if (fH->InheritsFrom(TProfile::Class())) {
8571 if (print_stddev == 1) {
8572 tf.Form(
"%s = %s%s",gStringStdDevY.Data(),
"%",stats->GetStatFormat());
8573 tt.Form(tf.Data(),fH->GetStdDev(2));
8575 tf.Form(
"%s = %s%s #pm %s%s",gStringStdDevY.Data(),
"%",stats->GetStatFormat()
8576 ,
"%",stats->GetStatFormat());
8577 tt.Form(tf.Data(),fH->GetStdDev(2),fH->GetStdDevError(2));
8579 stats->AddText(tt.Data());
8583 tf.Form(
"%s = %s%s",gStringUnderflow.Data(),
"%",stats->GetStatFormat());
8584 tt.Form(tf.Data(),fH->GetBinContent(0));
8585 stats->AddText(tt.Data());
8588 tf.Form(
"%s = %s%s",gStringOverflow.Data(),
"%",stats->GetStatFormat());
8589 tt.Form(tf.Data(),fH->GetBinContent(fXaxis->GetNbins()+1));
8590 stats->AddText(tt.Data());
8592 if (print_integral) {
8593 if (print_integral == 1) {
8594 tf.Form(
"%s = %s%s",gStringIntegral.Data(),
"%",stats->GetStatFormat());
8595 tt.Form(tf.Data(),fH->Integral());
8597 tf.Form(
"%s = %s%s",gStringIntegralBinWidth.Data(),
"%",stats->GetStatFormat());
8598 tt.Form(tf.Data(),fH->Integral(
"width"));
8600 stats->AddText(tt.Data());
8603 if (print_skew == 1) {
8604 tf.Form(
"%s = %s%s",gStringSkewness.Data(),
"%",stats->GetStatFormat());
8605 tt.Form(tf.Data(),fH->GetSkewness(1));
8607 tf.Form(
"%s = %s%s #pm %s%s",gStringSkewness.Data(),
"%",stats->GetStatFormat()
8608 ,
"%",stats->GetStatFormat());
8609 tt.Form(tf.Data(),fH->GetSkewness(1),fH->GetSkewness(11));
8611 stats->AddText(tt.Data());
8614 if (print_kurt == 1) {
8615 tf.Form(
"%s = %s%s",gStringKurtosis.Data(),
"%",stats->GetStatFormat());
8616 tt.Form(tf.Data(),fH->GetKurtosis(1));
8618 tf.Form(
"%s = %s%s #pm %s%s",gStringKurtosis.Data(),
"%",stats->GetStatFormat()
8619 ,
"%",stats->GetStatFormat());
8620 tt.Form(tf.Data(),fH->GetKurtosis(1),fH->GetKurtosis(11));
8622 stats->AddText(tt.Data());
8627 Int_t ndf = fit->GetNDF();
8628 tf.Form(
"#chi^{2} / ndf = %s%s / %d",
"%",stats->GetFitFormat(),ndf);
8629 tt.Form(tf.Data(),(Float_t)fit->GetChisquare());
8630 if (print_fchi2) stats->AddText(tt.Data());
8632 tf.Form(
"Prob = %s%s",
"%",stats->GetFitFormat());
8633 tt.Form(tf.Data(),(Float_t)TMath::Prob(fit->GetChisquare(),ndf));
8634 stats->AddText(tt.Data());
8636 if (print_fval || print_ferrors) {
8637 Double_t parmin,parmax;
8638 for (Int_t ipar=0;ipar<fit->GetNpar();ipar++) {
8639 fit->GetParLimits(ipar,parmin,parmax);
8640 if (print_fval < 2 && parmin*parmax != 0 && parmin >= parmax)
continue;
8641 if (print_ferrors) {
8642 tf.Form(
"%-8s = %s%s #pm %s ", fit->GetParName(ipar),
"%",stats->GetFitFormat(),
8643 GetBestFormat(fit->GetParameter(ipar), fit->GetParError(ipar), stats->GetFitFormat()));
8644 tt.Form(tf.Data(),(Float_t)fit->GetParameter(ipar)
8645 ,(Float_t)fit->GetParError(ipar));
8647 tf.Form(
"%-8s = %s%s ",fit->GetParName(ipar),
"%",stats->GetFitFormat());
8648 tt.Form(tf.Data(),(Float_t)fit->GetParameter(ipar));
8650 stats->AddText(tt.Data());
8655 if (!done) fFunctions->Add(stats);
8662 void THistPainter::PaintStat2(Int_t dostat, TF1 *fit)
8665 if (fH->GetDimension() != 2)
return;
8670 TPaveStats *stats = 0;
8671 TIter next(fFunctions);
8673 while ((obj = next())) {
8674 if (obj->InheritsFrom(TPaveStats::Class())) {
8675 stats = (TPaveStats*)obj;
8679 if (stats && dostat) {
8680 dofit = stats->GetOptFit();
8681 dostat = stats->GetOptStat();
8683 dofit = gStyle->GetOptFit();
8685 if (dostat == 1) dostat = 1111;
8686 Int_t print_name = dostat%10;
8687 Int_t print_entries = (dostat/10)%10;
8688 Int_t print_mean = (dostat/100)%10;
8689 Int_t print_stddev = (dostat/1000)%10;
8690 Int_t print_under = (dostat/10000)%10;
8691 Int_t print_over = (dostat/100000)%10;
8692 Int_t print_integral= (dostat/1000000)%10;
8693 Int_t print_skew = (dostat/10000000)%10;
8694 Int_t print_kurt = (dostat/100000000)%10;
8695 Int_t nlines = print_name + print_entries + 2*print_mean + 2*print_stddev + print_integral;
8696 if (print_under || print_over) nlines += 3;
8699 if (!gStyle->GetOptFit()) fit = 0;
8700 Bool_t done = kFALSE;
8701 if (!dostat && !fit) {
8702 if (stats) { fFunctions->Remove(stats);
delete stats;}
8705 Double_t statw = gStyle->GetStatW();
8706 if (fit) statw = 1.8*gStyle->GetStatW();
8707 Double_t stath = nlines*gStyle->GetStatFontSize();
8708 if (stath <= 0 || 3 == (gStyle->GetStatFont()%10)) {
8709 stath = 0.25*nlines*gStyle->GetStatH();
8711 if (fit) stath += gStyle->GetStatH();
8716 stats =
new TPaveStats(
8717 gStyle->GetStatX()-statw,
8718 gStyle->GetStatY()-stath,
8720 gStyle->GetStatY(),
"brNDC");
8722 stats->SetParent(fH);
8723 stats->SetOptFit(dofit);
8724 stats->SetOptStat(dostat);
8725 stats->SetFillColor(gStyle->GetStatColor());
8726 stats->SetFillStyle(gStyle->GetStatStyle());
8727 stats->SetBorderSize(gStyle->GetStatBorderSize());
8728 stats->SetName(
"stats");
8730 stats->SetTextColor(gStyle->GetStatTextColor());
8731 stats->SetTextAlign(12);
8732 stats->SetTextFont(gStyle->GetStatFont());
8733 if (gStyle->GetStatFont()%10 > 2)
8734 stats->SetTextSize(gStyle->GetStatFontSize());
8735 stats->SetFitFormat(gStyle->GetFitFormat());
8736 stats->SetStatFormat(gStyle->GetStatFormat());
8737 stats->SetBit(kCanDelete);
8738 stats->SetBit(kMustCleanup);
8740 if (print_name) stats->AddText(h2->GetName());
8741 if (print_entries) {
8742 if (h2->GetEntries() < 1e7) tt.Form(
"%s = %-7d",gStringEntries.Data(),Int_t(h2->GetEntries()+0.5));
8743 else tt.Form(
"%s = %14.7g",gStringEntries.Data(),Float_t(h2->GetEntries()));
8744 stats->AddText(tt.Data());
8747 if (print_mean == 1) {
8748 tf.Form(
"%s = %s%s",gStringMeanX.Data(),
"%",stats->GetStatFormat());
8749 tt.Form(tf.Data(),h2->GetMean(1));
8750 stats->AddText(tt.Data());
8751 tf.Form(
"%s = %s%s",gStringMeanY.Data(),
"%",stats->GetStatFormat());
8752 tt.Form(tf.Data(),h2->GetMean(2));
8753 stats->AddText(tt.Data());
8755 tf.Form(
"%s = %s%s #pm %s%s",gStringMeanX.Data(),
"%",stats->GetStatFormat()
8756 ,
"%",stats->GetStatFormat());
8757 tt.Form(tf.Data(),h2->GetMean(1),h2->GetMeanError(1));
8758 stats->AddText(tt.Data());
8759 tf.Form(
"%s = %s%s #pm %s%s",gStringMeanY.Data(),
"%",stats->GetStatFormat()
8760 ,
"%",stats->GetStatFormat());
8761 tt.Form(tf.Data(),h2->GetMean(2),h2->GetMeanError(2));
8762 stats->AddText(tt.Data());
8766 if (print_stddev == 1) {
8767 tf.Form(
"%s = %s%s",gStringStdDevX.Data(),
"%",stats->GetStatFormat());
8768 tt.Form(tf.Data(),h2->GetStdDev(1));
8769 stats->AddText(tt.Data());
8770 tf.Form(
"%s = %s%s",gStringStdDevY.Data(),
"%",stats->GetStatFormat());
8771 tt.Form(tf.Data(),h2->GetStdDev(2));
8772 stats->AddText(tt.Data());
8774 tf.Form(
"%s = %s%s #pm %s%s",gStringStdDevX.Data(),
"%",stats->GetStatFormat()
8775 ,
"%",stats->GetStatFormat());
8776 tt.Form(tf.Data(),h2->GetStdDev(1),h2->GetStdDevError(1));
8777 stats->AddText(tt.Data());
8778 tf.Form(
"%s = %s%s #pm %s%s",gStringStdDevY.Data(),
"%",stats->GetStatFormat()
8779 ,
"%",stats->GetStatFormat());
8780 tt.Form(tf.Data(),h2->GetStdDev(2),h2->GetStdDevError(2));
8781 stats->AddText(tt.Data());
8784 if (print_integral) {
8785 tf.Form(
"%s = %s%s",gStringIntegral.Data(),
"%",stats->GetStatFormat());
8786 tt.Form(tf.Data(),fH->Integral());
8787 stats->AddText(tt.Data());
8790 if (print_skew == 1) {
8791 tf.Form(
"%s = %s%s",gStringSkewnessX.Data(),
"%",stats->GetStatFormat());
8792 tt.Form(tf.Data(),h2->GetSkewness(1));
8793 stats->AddText(tt.Data());
8794 tf.Form(
"%s = %s%s",gStringSkewnessY.Data(),
"%",stats->GetStatFormat());
8795 tt.Form(tf.Data(),h2->GetSkewness(2));
8796 stats->AddText(tt.Data());
8798 tf.Form(
"%s = %s%s #pm %s%s",gStringSkewnessX.Data(),
"%",stats->GetStatFormat()
8799 ,
"%",stats->GetStatFormat());
8800 tt.Form(tf.Data(),h2->GetSkewness(1),h2->GetSkewness(11));
8801 stats->AddText(tt.Data());
8802 tf.Form(
"%s = %s%s #pm %s%s",gStringSkewnessY.Data(),
"%",stats->GetStatFormat()
8803 ,
"%",stats->GetStatFormat());
8804 tt.Form(tf.Data(),h2->GetSkewness(2),h2->GetSkewness(12));
8805 stats->AddText(tt.Data());
8809 if (print_kurt == 1) {
8810 tf.Form(
"%s = %s%s",gStringKurtosisX.Data(),
"%",stats->GetStatFormat());
8811 tt.Form(tf.Data(),h2->GetKurtosis(1));
8812 stats->AddText(tt.Data());
8813 tf.Form(
"%s = %s%s",gStringKurtosisY.Data(),
"%",stats->GetStatFormat());
8814 tt.Form(tf.Data(),h2->GetKurtosis(2));
8815 stats->AddText(tt.Data());
8817 tf.Form(
"%s = %s%s #pm %s%s",gStringKurtosisX.Data(),
"%",stats->GetStatFormat()
8818 ,
"%",stats->GetStatFormat());
8819 tt.Form(tf.Data(),h2->GetKurtosis(1),h2->GetKurtosis(11));
8820 stats->AddText(tt.Data());
8821 tf.Form(
"%s = %s%s #pm %s%s",gStringKurtosisY.Data(),
"%",stats->GetStatFormat()
8822 ,
"%",stats->GetStatFormat());
8823 tt.Form(tf.Data(),h2->GetKurtosis(2),h2->GetKurtosis(12));
8824 stats->AddText(tt.Data());
8827 if (print_under || print_over) {
8831 Int_t cellsX = h2->GetXaxis()->GetNbins() + 1;
8832 Int_t cellsY = h2->GetYaxis()->GetNbins() + 1;
8833 Int_t firstX = std::max(1, h2->GetXaxis()->GetFirst());
8834 Int_t firstY = std::max(1, h2->GetYaxis()->GetFirst());
8835 Int_t lastX = std::min(h2->GetXaxis()->GetLast(), h2->GetXaxis()->GetNbins());
8836 Int_t lastY = std::min(h2->GetYaxis()->GetLast(), h2->GetYaxis()->GetNbins());
8838 unov[0] = h2->Integral( 0, firstX-1, lastY+1, cellsY );
8839 unov[1] = h2->Integral(firstX , lastX , lastY+1, cellsY );
8840 unov[2] = h2->Integral(lastX+1, cellsX , lastY+1, cellsY );
8841 unov[3] = h2->Integral( 0, firstX-1, firstY , lastY );
8842 unov[4] = h2->Integral(firstX , lastX , firstY , lastY );
8843 unov[5] = h2->Integral(lastX+1, cellsX , firstY , lastY );
8844 unov[6] = h2->Integral( 0, firstX-1, 0, firstY-1);
8845 unov[7] = h2->Integral(firstX, lastX, 0, firstY-1);
8846 unov[8] = h2->Integral(lastX+1, cellsX , 0, firstY-1);
8848 tt.Form(
" %7d|%7d|%7d\n", (Int_t)unov[0], (Int_t)unov[1], (Int_t)unov[2]);
8849 stats->AddText(tt.Data());
8850 if (TMath::Abs(unov[4]) < 1.e7)
8851 tt.Form(
" %7d|%7d|%7d\n", (Int_t)unov[3], (Int_t)unov[4], (Int_t)unov[5]);
8853 tt.Form(
" %7d|%14.7g|%7d\n", (Int_t)unov[3], (Float_t)unov[4], (Int_t)unov[5]);
8854 stats->AddText(tt.Data());
8855 tt.Form(
" %7d|%7d|%7d\n", (Int_t)unov[6], (Int_t)unov[7], (Int_t)unov[8]);
8856 stats->AddText(tt.Data());
8861 Int_t ndf = fit->GetNDF();
8862 tt.Form(
"#chi^{2} / ndf = %6.4g / %d",(Float_t)fit->GetChisquare(),ndf);
8863 stats->AddText(tt.Data());
8864 for (Int_t ipar=0;ipar<fit->GetNpar();ipar++) {
8865 tt.Form(
"%-8s = %5.4g #pm %5.4g ",fit->GetParName(ipar)
8866 ,(Float_t)fit->GetParameter(ipar)
8867 ,(Float_t)fit->GetParError(ipar));
8868 stats->AddText(tt.Data());
8872 if (!done) fFunctions->Add(stats);
8879 void THistPainter::PaintStat3(Int_t dostat, TF1 *fit)
8882 if (fH->GetDimension() != 3)
return;
8887 TPaveStats *stats = 0;
8888 TIter next(fFunctions);
8890 while ((obj = next())) {
8891 if (obj->InheritsFrom(TPaveStats::Class())) {
8892 stats = (TPaveStats*)obj;
8896 if (stats && dostat) {
8897 dofit = stats->GetOptFit();
8898 dostat = stats->GetOptStat();
8900 dofit = gStyle->GetOptFit();
8902 if (dostat == 1) dostat = 1111;
8903 Int_t print_name = dostat%10;
8904 Int_t print_entries = (dostat/10)%10;
8905 Int_t print_mean = (dostat/100)%10;
8906 Int_t print_stddev = (dostat/1000)%10;
8907 Int_t print_under = (dostat/10000)%10;
8908 Int_t print_over = (dostat/100000)%10;
8909 Int_t print_integral= (dostat/1000000)%10;
8910 Int_t print_skew = (dostat/10000000)%10;
8911 Int_t print_kurt = (dostat/100000000)%10;
8912 Int_t nlines = print_name + print_entries + 3*print_mean + 3*print_stddev + print_integral;
8913 if (print_under || print_over) nlines += 3;
8916 if (!gStyle->GetOptFit()) fit = 0;
8917 Bool_t done = kFALSE;
8918 if (!dostat && !fit) {
8919 if (stats) { fFunctions->Remove(stats);
delete stats;}
8922 Double_t statw = gStyle->GetStatW();
8923 if (fit) statw = 1.8*gStyle->GetStatW();
8924 Double_t stath = nlines*gStyle->GetStatFontSize();
8925 if (stath <= 0 || 3 == (gStyle->GetStatFont()%10)) {
8926 stath = 0.25*nlines*gStyle->GetStatH();
8928 if (fit) stath += gStyle->GetStatH();
8933 stats =
new TPaveStats(
8934 gStyle->GetStatX()-statw,
8935 gStyle->GetStatY()-stath,
8937 gStyle->GetStatY(),
"brNDC");
8939 stats->SetParent(fH);
8940 stats->SetOptFit(dofit);
8941 stats->SetOptStat(dostat);
8942 stats->SetFillColor(gStyle->GetStatColor());
8943 stats->SetFillStyle(gStyle->GetStatStyle());
8944 stats->SetBorderSize(gStyle->GetStatBorderSize());
8945 stats->SetName(
"stats");
8947 stats->SetTextColor(gStyle->GetStatTextColor());
8948 stats->SetTextAlign(12);
8949 stats->SetTextFont(gStyle->GetStatFont());
8950 stats->SetFitFormat(gStyle->GetFitFormat());
8951 stats->SetStatFormat(gStyle->GetStatFormat());
8952 stats->SetBit(kCanDelete);
8953 stats->SetBit(kMustCleanup);
8955 if (print_name) stats->AddText(h3->GetName());
8956 if (print_entries) {
8957 if (h3->GetEntries() < 1e7) tt.Form(
"%s = %-7d",gStringEntries.Data(),Int_t(h3->GetEntries()+0.5));
8958 else tt.Form(
"%s = %14.7g",gStringEntries.Data(),Float_t(h3->GetEntries()+0.5));
8959 stats->AddText(tt.Data());
8962 if (print_mean == 1) {
8963 tf.Form(
"%s = %s%s",gStringMeanX.Data(),
"%",stats->GetStatFormat());
8964 tt.Form(tf.Data(),h3->GetMean(1));
8965 stats->AddText(tt.Data());
8966 tf.Form(
"%s = %s%s",gStringMeanY.Data(),
"%",stats->GetStatFormat());
8967 tt.Form(tf.Data(),h3->GetMean(2));
8968 stats->AddText(tt.Data());
8969 tf.Form(
"%s = %s%s",gStringMeanZ.Data(),
"%",stats->GetStatFormat());
8970 tt.Form(tf.Data(),h3->GetMean(3));
8971 stats->AddText(tt.Data());
8973 tf.Form(
"%s = %s%s #pm %s%s",gStringMeanX.Data(),
"%",stats->GetStatFormat()
8974 ,
"%",stats->GetStatFormat());
8975 tt.Form(tf.Data(),h3->GetMean(1),h3->GetMeanError(1));
8976 stats->AddText(tt.Data());
8977 tf.Form(
"%s = %s%s #pm %s%s",gStringMeanY.Data(),
"%",stats->GetStatFormat()
8978 ,
"%",stats->GetStatFormat());
8979 tt.Form(tf.Data(),h3->GetMean(2),h3->GetMeanError(2));
8980 stats->AddText(tt.Data());
8981 tf.Form(
"%s = %s%s #pm %s%s",gStringMeanZ.Data(),
"%",stats->GetStatFormat()
8982 ,
"%",stats->GetStatFormat());
8983 tt.Form(tf.Data(),h3->GetMean(3),h3->GetMeanError(3));
8984 stats->AddText(tt.Data());
8988 if (print_stddev == 1) {
8989 tf.Form(
"%s = %s%s",gStringStdDevX.Data(),
"%",stats->GetStatFormat());
8990 tt.Form(tf.Data(),h3->GetStdDev(1));
8991 stats->AddText(tt.Data());
8992 tf.Form(
"%s = %s%s",gStringStdDevY.Data(),
"%",stats->GetStatFormat());
8993 tt.Form(tf.Data(),h3->GetStdDev(2));
8994 stats->AddText(tt.Data());
8995 tf.Form(
"%s = %s%s",gStringStdDevZ.Data(),
"%",stats->GetStatFormat());
8996 tt.Form(tf.Data(),h3->GetStdDev(3));
8997 stats->AddText(tt.Data());
8999 tf.Form(
"%s = %s%s #pm %s%s",gStringStdDevX.Data(),
"%",stats->GetStatFormat()
9000 ,
"%",stats->GetStatFormat());
9001 tt.Form(tf.Data(),h3->GetStdDev(1),h3->GetStdDevError(1));
9002 stats->AddText(tt.Data());
9003 tf.Form(
"%s = %s%s #pm %s%s",gStringStdDevY.Data(),
"%",stats->GetStatFormat()
9004 ,
"%",stats->GetStatFormat());
9005 tt.Form(tf.Data(),h3->GetStdDev(2),h3->GetStdDevError(2));
9006 stats->AddText(tt.Data());
9007 tf.Form(
"%s = %s%s #pm %s%s",gStringStdDevZ.Data(),
"%",stats->GetStatFormat()
9008 ,
"%",stats->GetStatFormat());
9009 tt.Form(tf.Data(),h3->GetStdDev(3),h3->GetStdDevError(3));
9010 stats->AddText(tt.Data());
9013 if (print_integral) {
9014 tt.Form(
"%s = %6.4g",gStringIntegral.Data(),h3->Integral());
9015 stats->AddText(tt.Data());
9018 if (print_skew == 1) {
9019 tf.Form(
"%s = %s%s",gStringSkewnessX.Data(),
"%",stats->GetStatFormat());
9020 tt.Form(tf.Data(),h3->GetSkewness(1));
9021 stats->AddText(tt.Data());
9022 tf.Form(
"%s = %s%s",gStringSkewnessY.Data(),
"%",stats->GetStatFormat());
9023 tt.Form(tf.Data(),h3->GetSkewness(2));
9024 stats->AddText(tt.Data());
9025 tf.Form(
"%s = %s%s",gStringSkewnessZ.Data(),
"%",stats->GetStatFormat());
9026 tt.Form(tf.Data(),h3->GetSkewness(3));
9027 stats->AddText(tt.Data());
9029 tf.Form(
"%s = %s%s #pm %s%s",gStringSkewnessX.Data(),
"%",stats->GetStatFormat()
9030 ,
"%",stats->GetStatFormat());
9031 tt.Form(tf.Data(),h3->GetSkewness(1),h3->GetSkewness(11));
9032 stats->AddText(tt.Data());
9033 tf.Form(
"%s = %s%s #pm %s%s",gStringSkewnessY.Data(),
"%",stats->GetStatFormat()
9034 ,
"%",stats->GetStatFormat());
9035 tt.Form(tf.Data(),h3->GetSkewness(2),h3->GetSkewness(12));
9036 stats->AddText(tt.Data());
9037 tf.Form(
"%s = %s%s #pm %s%s",gStringSkewnessZ.Data(),
"%",stats->GetStatFormat()
9038 ,
"%",stats->GetStatFormat());
9039 tt.Form(tf.Data(),h3->GetSkewness(3),h3->GetSkewness(13));
9040 stats->AddText(tt.Data());
9044 if (print_kurt == 1) {
9045 tf.Form(
"%s = %s%s",gStringKurtosisX.Data(),
"%",stats->GetStatFormat());
9046 tt.Form(tf.Data(),h3->GetKurtosis(1));
9047 stats->AddText(tt.Data());
9048 tf.Form(
"%s = %s%s",gStringKurtosisY.Data(),
"%",stats->GetStatFormat());
9049 tt.Form(tf.Data(),h3->GetKurtosis(2));
9050 stats->AddText(tt.Data());
9051 tf.Form(
"%s = %s%s",gStringKurtosisZ.Data(),
"%",stats->GetStatFormat());
9052 tt.Form(tf.Data(),h3->GetKurtosis(3));
9053 stats->AddText(tt.Data());
9055 tf.Form(
"%s = %s%s #pm %s%s",gStringKurtosisX.Data(),
"%",stats->GetStatFormat()
9056 ,
"%",stats->GetStatFormat());
9057 tt.Form(tf.Data(),h3->GetKurtosis(1),h3->GetKurtosis(11));
9058 stats->AddText(tt.Data());
9059 tf.Form(
"%s = %s%s #pm %s%s",gStringKurtosisY.Data(),
"%",stats->GetStatFormat()
9060 ,
"%",stats->GetStatFormat());
9061 tt.Form(tf.Data(),h3->GetKurtosis(2),h3->GetKurtosis(12));
9062 stats->AddText(tt.Data());
9063 tf.Form(
"%s = %s%s #pm %s%s",gStringKurtosisZ.Data(),
"%",stats->GetStatFormat()
9064 ,
"%",stats->GetStatFormat());
9065 tt.Form(tf.Data(),h3->GetKurtosis(3),h3->GetKurtosis(13));
9066 stats->AddText(tt.Data());
9069 if (print_under || print_over) {
9076 Int_t ndf = fit->GetNDF();
9077 tt.Form(
"#chi^{2} / ndf = %6.4g / %d",(Float_t)fit->GetChisquare(),ndf);
9078 stats->AddText(tt.Data());
9079 for (Int_t ipar=0;ipar<fit->GetNpar();ipar++) {
9080 tt.Form(
"%-8s = %5.4g #pm %5.4g ",fit->GetParName(ipar)
9081 ,(Float_t)fit->GetParameter(ipar)
9082 ,(Float_t)fit->GetParError(ipar));
9083 stats->AddText(tt.Data());
9087 if (!done) fFunctions->Add(stats);
9094 void THistPainter::PaintSurface(Option_t *)
9097 const Double_t ydiff = 1;
9098 const Double_t yligh1 = 10;
9099 const Double_t qa = 0.15;
9100 const Double_t qd = 0.15;
9101 const Double_t qs = 0.8;
9102 Double_t fmin, fmax;
9106 if (Hparam.zmin == 0 && Hparam.zmax == 0) {Hparam.zmin = -1; Hparam.zmax = 1;}
9107 Int_t nx = Hparam.xlast - Hparam.xfirst;
9108 Int_t ny = Hparam.ylast - Hparam.yfirst;
9109 Double_t zmin = Hparam.zmin;
9110 Double_t zmax = Hparam.zmax;
9111 Double_t xlab1 = Hparam.xmin;
9112 Double_t xlab2 = Hparam.xmax;
9113 Double_t ylab1 = Hparam.ymin;
9114 Double_t ylab2 = Hparam.ymax;
9115 Double_t dangle = 10*3.141592/180;
9116 Double_t deltaz = TMath::Abs(zmin);
9117 if (deltaz == 0) deltaz = 1;
9122 Double_t z1c = zmin;
9123 Double_t z2c = zmin + (zmax-zmin)*(1+gStyle->GetHistTopMargin());
9129 if (Hoption.System >= kPOLAR && (Hoption.Surf == 1 || Hoption.Surf == 13)) raster = 1;
9130 if (Hoption.System == kPOLAR) {
9133 }
else if (Hoption.System == kCYLINDRICAL) {
9135 if (ylab1 > 0) fXbuf[2] = TMath::Log10(ylab1);
9137 if (ylab2 > 0) fYbuf[2] = TMath::Log10(ylab2);
9144 }
else if (Hoption.System == kSPHERICAL) {
9148 }
else if (Hoption.System == kRAPIDITY) {
9149 fXbuf[2] = -1/TMath::Tan(dangle);
9150 fYbuf[2] = 1/TMath::Tan(dangle);
9160 fLego =
new TPainter3dAlgorithms(fXbuf, fYbuf, Hoption.System);
9161 fLego->SetEdgeAtt(fH->GetLineColor(),fH->GetLineStyle(),fH->GetLineWidth(),0);
9162 fLego->SetFillColor(fH->GetFillColor());
9166 TGaxis *axis =
new TGaxis();
9169 Int_t ndiv = fH->GetContour();
9171 ndiv = gStyle->GetNumberContours();
9172 fH->SetContour(ndiv);
9174 Int_t ndivz = TMath::Abs(ndiv);
9175 if (fH->TestBit(TH1::kUserContour) == 0) fH->SetContour(ndiv);
9177 if (Hoption.Surf == 13 || Hoption.Surf == 15) fLego->SetMesh(3);
9178 if (Hoption.Surf == 12 || Hoption.Surf == 14 || Hoption.Surf == 17) fLego->SetMesh(0);
9182 if (Hoption.System != kCARTESIAN) {nx++; ny++;}
9186 TView *view = gPad->GetView();
9188 Error(
"PaintSurface",
"no TView in current pad");
9192 Double_t thedeg = 90 - gPad->GetTheta();
9193 Double_t phideg = -90 - gPad->GetPhi();
9194 Double_t psideg = view->GetPsi();
9195 view->SetView(phideg, thedeg, psideg, irep);
9199 fLego->SetFillStyle(0);
9200 fLego->SetFillColor(1);
9202 fLego->SetFillStyle(gPad->GetFrameFillStyle());
9203 fLego->SetFillColor(gPad->GetFrameFillColor());
9205 fLego->TAttFill::Modify();
9207 Int_t backcolor = gPad->GetFrameFillColor();
9208 if (Hoption.System != kCARTESIAN) backcolor = 0;
9209 view->PadRange(backcolor);
9211 fLego->SetFillStyle(fH->GetFillStyle());
9212 fLego->SetFillColor(fH->GetFillColor());
9213 fLego->TAttFill::Modify();
9216 Int_t icol1 = fH->GetFillColor();
9218 Int_t hoption35 = Hoption.Surf;
9219 if (Hoption.Surf == 13 || Hoption.Surf == 15) {
9220 DefineColorLevels(ndivz);
9222 fLego->SetSurfaceFunction(&TPainter3dAlgorithms::SurfaceFunction);
9223 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMode2);
9224 if (Hoption.System == kPOLAR) fLego->SurfacePolar(1,nx,ny,
"BF");
9225 if (Hoption.System == kCYLINDRICAL) fLego->SurfaceCylindrical(1,nx,ny,
"BF");
9226 if (Hoption.System == kSPHERICAL) fLego->SurfaceSpherical(0,1,nx,ny,
"BF");
9227 if (Hoption.System == kRAPIDITY ) fLego->SurfaceSpherical(1,1,nx,ny,
"BF");
9228 if (Hoption.System == kCARTESIAN) fLego->SurfaceCartesian(90,nx,ny,
"BF");
9229 Hoption.Surf = hoption35;
9233 if (raster) fLego->InitRaster(-1.1,-1.1,1.1,1.1,1000,800);
9234 else fLego->InitMoveScreen(-1.1,1.1);
9236 if (Hoption.Surf == 11 || Hoption.Surf == 12 || Hoption.Surf == 14 || Hoption.Surf == 17) {
9237 fLego->DefineGridLevels(fZaxis->GetNdivisions()%100);
9238 if (Hoption.System == kCARTESIAN && Hoption.BackBox) {
9239 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove1);
9245 if (Hoption.Surf == 14) {
9247 fLego->LightSource(0, ydiff, 0,0,0,irep);
9248 fLego->LightSource(1, yligh1 ,1,1,1,irep);
9249 fLego->SurfaceProperty(qa, qd, qs, 1, irep);
9251 fmax = fmin + (yligh1+0.1)*(qd+qs);
9254 Double_t dcol = 0.5/Double_t(nbcol);
9255 TColor *colref = gROOT->GetColor(fH->GetFillColor());
9256 if (!colref)
return;
9257 Float_t r,g,b,hue,light,satur;
9258 colref->GetRGB(r,g,b);
9259 TColor::RGBtoHLS(r,g,b,hue,light,satur);
9261 for (Int_t col=0;col<nbcol;col++) {
9262 acol = gROOT->GetColor(col+icol1);
9263 TColor::HLStoRGB(hue,.4+col*dcol,satur,r,g,b);
9264 if (acol) acol->SetRGB(r,g,b);
9266 fLego->Spectrum(nbcol, fmin, fmax, icol1, 1, irep);
9267 fLego->SetSurfaceFunction(&TPainter3dAlgorithms::GouraudFunction);
9268 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMode2);
9269 if (Hoption.System == kPOLAR) fLego->SurfacePolar(1,nx,ny,
"BF");
9270 if (Hoption.System == kCYLINDRICAL) fLego->SurfaceCylindrical(1,nx,ny,
"BF");
9271 if (Hoption.System == kSPHERICAL) fLego->SurfaceSpherical(0,1,nx,ny,
"BF");
9272 if (Hoption.System == kRAPIDITY ) fLego->SurfaceSpherical(1,1,nx,ny,
"BF");
9273 if (Hoption.System == kCARTESIAN) fLego->SurfaceCartesian(90,nx,ny,
"BF");
9274 }
else if (Hoption.Surf == 15) {
9278 if (Hoption.Surf == 11 || Hoption.Surf == 12 || Hoption.Surf == 16 || Hoption.Surf == 17) {
9279 DefineColorLevels(ndivz);
9281 fLego->DefineGridLevels(fZaxis->GetNdivisions()%100);
9283 fLego->SetSurfaceFunction(&TPainter3dAlgorithms::SurfaceFunction);
9284 if (Hoption.Surf == 1 || Hoption.Surf == 13) fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceRaster1);
9285 if (Hoption.Surf == 11 || Hoption.Surf == 12 || Hoption.Surf == 17) fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMode2);
9286 if (Hoption.System == kPOLAR) {
9287 if (Hoption.Surf == 1 || Hoption.Surf == 13) fLego->SurfacePolar(1,nx,ny,
"FB");
9288 if (Hoption.Surf == 11 || Hoption.Surf == 12 || Hoption.Surf == 17) fLego->SurfacePolar(1,nx,ny,
"BF");
9289 }
else if (Hoption.System == kCYLINDRICAL) {
9290 if (Hoption.Surf == 1 || Hoption.Surf == 13) fLego->SurfaceCylindrical(1,nx,ny,
"FB");
9291 if (Hoption.Surf == 11 || Hoption.Surf == 12 || Hoption.Surf == 17) fLego->SurfaceCylindrical(1,nx,ny,
"BF");
9292 }
else if (Hoption.System == kSPHERICAL) {
9293 if (Hoption.Surf == 1 || Hoption.Surf == 13) fLego->SurfaceSpherical(0,1,nx,ny,
"FB");
9294 if (Hoption.Surf == 11 || Hoption.Surf == 12 || Hoption.Surf == 17) fLego->SurfaceSpherical(0,1,nx,ny,
"BF");
9295 }
else if (Hoption.System == kRAPIDITY) {
9296 if (Hoption.Surf == 1 || Hoption.Surf == 13) fLego->SurfaceSpherical(1,1,nx,ny,
"FB");
9297 if (Hoption.Surf == 11 || Hoption.Surf == 12 || Hoption.Surf == 17) fLego->SurfaceSpherical(1,1,nx,ny,
"BF");
9299 if (Hoption.Surf == 1 || Hoption.Surf == 13) fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove1);
9300 if (Hoption.Surf == 16) fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove3);
9301 if (Hoption.Surf == 1 || Hoption.Surf == 13 || Hoption.Surf == 16) fLego->SurfaceCartesian(90,nx,ny,
"FB");
9302 if (Hoption.Surf == 11 || Hoption.Surf == 12 || Hoption.Surf == 17) fLego->SurfaceCartesian(90,nx,ny,
"BF");
9307 if (Hoption.Surf == 17) {
9308 fLego->InitMoveScreen(-1.1,1.1);
9309 fLego->DefineGridLevels(fZaxis->GetNdivisions()%100);
9311 fLego->SetSurfaceFunction(&TPainter3dAlgorithms::SurfaceFunction);
9312 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawLevelLines);
9313 if (Hoption.System == kPOLAR) fLego->SurfacePolar(1,nx,ny,
"FB");
9314 if (Hoption.System == kCYLINDRICAL) fLego->SurfaceCylindrical(1,nx,ny,
"FB");
9315 if (Hoption.System == kSPHERICAL) fLego->SurfaceSpherical(0,1,nx,ny,
"FB");
9316 if (Hoption.System == kRAPIDITY ) fLego->SurfaceSpherical(1,1,nx,ny,
"FB");
9317 if (Hoption.System == kCARTESIAN) fLego->SurfaceCartesian(90,nx,ny,
"FB");
9320 if ((!Hoption.Same) &&
9321 (Hoption.Surf == 1 || Hoption.Surf == 13 || Hoption.Surf == 16)) {
9322 if (Hoption.System == kCARTESIAN && Hoption.BackBox) {
9323 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove1);
9327 if (Hoption.System == kCARTESIAN) {
9328 fLego->InitMoveScreen(-1.1,1.1);
9329 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove2);
9330 if (Hoption.FrontBox) fLego->FrontBox(90);
9332 if (!Hoption.Axis && !Hoption.Same) PaintLegoAxis(axis, 90);
9334 if (Hoption.Zscale) PaintPalette();
9337 delete fLego; fLego = 0;
9343 void THistPainter::PaintTriangles(Option_t *option)
9346 TGraphDelaunay2D *dt =
nullptr;
9347 TGraphDelaunay *dtOld =
nullptr;
9350 TList *hl = fH->GetListOfFunctions();
9351 dt = (TGraphDelaunay2D*)hl->FindObject(
"TGraphDelaunay2D");
9352 if (!dt) dtOld = (TGraphDelaunay*)hl->FindObject(
"TGraphDelaunay");
9353 if (!dt && !dtOld)
return;
9356 if (!fGraph2DPainter) {
9357 if (dt) fGraph2DPainter =
new TGraph2DPainter(dt);
9358 else fGraph2DPainter =
new TGraph2DPainter(dtOld);
9362 if (Hparam.zmin == 0 && Hparam.zmax == 0) {Hparam.zmin = -1; Hparam.zmax = 1;}
9364 TView *viewsame = gPad->GetView();
9366 Error(
"PaintTriangles",
"no TView in current pad, do not use option SAME");
9369 Double_t *rmin = viewsame->GetRmin();
9370 Double_t *rmax = viewsame->GetRmax();
9371 if (!rmin || !rmax)
return;
9379 fXbuf[0] = Hparam.xmin;
9380 fYbuf[0] = Hparam.xmax;
9381 fXbuf[1] = Hparam.ymin;
9382 fYbuf[1] = Hparam.ymax;
9383 fXbuf[2] = Hparam.zmin;
9384 fYbuf[2] = Hparam.zmax;
9387 fLego =
new TPainter3dAlgorithms(fXbuf, fYbuf);
9388 TView *view = gPad->GetView();
9390 Error(
"PaintTriangles",
"no TView in current pad");
9393 Double_t thedeg = 90 - gPad->GetTheta();
9394 Double_t phideg = -90 - gPad->GetPhi();
9395 Double_t psideg = view->GetPsi();
9397 view->SetView(phideg, thedeg, psideg, irep);
9400 fLego->SetFillStyle(gPad->GetFrameFillStyle());
9401 fLego->SetFillColor(gPad->GetFrameFillColor());
9402 fLego->TAttFill::Modify();
9403 Int_t backcolor = gPad->GetFrameFillColor();
9404 if (Hoption.System != kCARTESIAN) backcolor = 0;
9405 view->PadRange(backcolor);
9406 fLego->SetFillStyle(fH->GetFillStyle());
9407 fLego->SetFillColor(fH->GetFillColor());
9408 fLego->TAttFill::Modify();
9411 if (Hoption.BackBox && !Hoption.Same) {
9412 fLego->InitMoveScreen(-1.1,1.1);
9413 fLego->DefineGridLevels(fZaxis->GetNdivisions()%100);
9414 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove1);
9419 fGraph2DPainter->Paint(option);
9422 if (Hoption.FrontBox) {
9423 fLego->InitMoveScreen(-1.1,1.1);
9424 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove2);
9425 fLego->FrontBox(90);
9429 if (!Hoption.Axis && !Hoption.Same) {
9430 TGaxis *axis =
new TGaxis();
9431 PaintLegoAxis(axis, 90);
9435 if (Hoption.Zscale) PaintPalette();
9437 delete fLego; fLego = 0;
9443 void THistPainter::DefineColorLevels(Int_t ndivz)
9450 Warning(
"PaintSurface",
"too many color levels, %d, reset to 8", ndivz);
9453 Double_t *funlevel =
new Double_t[ndivz+1];
9454 Int_t *colorlevel =
new Int_t[ndivz+1];
9456 Int_t ncolors = gStyle->GetNumberOfColors();
9457 for (i = 0; i < ndivz; ++i) {
9458 funlevel[i] = fH->GetContourLevelPad(i);
9459 theColor = Int_t((i+0.99)*Float_t(ncolors)/Float_t(ndivz));
9460 colorlevel[i] = gStyle->GetColorPalette(theColor);
9462 colorlevel[ndivz] = gStyle->GetColorPalette(ncolors-1);
9463 fLego->ColorFunction(ndivz, funlevel, colorlevel, irep);
9464 delete [] colorlevel;
9471 void THistPainter::PaintTable(Option_t *option)
9475 if (!TableInit())
return;
9481 if (!Hoption.Zscale) {
9482 TObject *palette = fFunctions->FindObject(
"palette");
9483 if (palette) { fFunctions->Remove(palette);
delete palette;}
9487 if (Hoption.Func == 2) {
9488 if (Hoption.Zscale) {
9489 Int_t ndiv = fH->GetContour();
9491 ndiv = gStyle->GetNumberContours();
9492 fH->SetContour(ndiv);
9499 if (fH->InheritsFrom(TH2Poly::Class())) {
9500 if (Hoption.Fill) PaintTH2PolyBins(
"f");
9501 if (Hoption.Color) PaintTH2PolyColorLevels(option);
9502 if (Hoption.Scat) PaintTH2PolyScatterPlot(option);
9503 if (Hoption.Text) PaintTH2PolyText(option);
9504 if (Hoption.Line) PaintTH2PolyBins(
"l");
9505 if (Hoption.Mark) PaintTH2PolyBins(
"P");
9506 }
else if (fH->GetEntries() != 0 && Hoption.Axis<=0) {
9507 if (Hoption.Scat) PaintScatterPlot(option);
9508 if (Hoption.Arrow) PaintArrows(option);
9509 if (Hoption.Box) PaintBoxes(option);
9510 if (Hoption.Color) {
9511 if (Hoption.Color == 3) PaintColorLevelsFast(option);
9512 else PaintColorLevels(option);
9514 if (Hoption.Contour) PaintContour(option);
9515 if (Hoption.Text) PaintText(option);
9516 if (Hoption.Error >= 100) Paint2DErrors(option);
9517 if (Hoption.Candle) PaintCandlePlot(option);
9519 if (Hoption.Lego) PaintLego(option);
9520 if (Hoption.Surf && !Hoption.Contour) PaintSurface(option);
9521 if (Hoption.Tri) PaintTriangles(option);
9528 if (!Hoption.Lego && !Hoption.Surf &&
9529 !Hoption.Tri && !(Hoption.Error >= 100)) PaintAxis(kFALSE);
9532 TIter next(fFunctions);
9534 while ((obj = next())) {
9535 if (obj->InheritsFrom(TF1::Class())) {
9540 if ((Hoption.Same%10) != 1) {
9541 if (!fH->TestBit(TH1::kNoStats)) {
9542 if (!gPad->PadInSelectionMode() && !gPad->PadInHighlightMode()) {
9545 PaintStat2(gStyle->GetOptStat(),fit);
9558 void THistPainter::PaintTH2PolyBins(Option_t *option)
9562 if (gPad->PadInHighlightMode() && gPad->GetSelected() != fH)
return;
9564 TString opt = option;
9566 Bool_t line = kFALSE;
9567 Bool_t fill = kFALSE;
9568 Bool_t mark = kFALSE;
9569 if (opt.Contains(
"l")) line = kTRUE;
9570 if (opt.Contains(
"f")) fill = kTRUE;
9571 if (opt.Contains(
"p")) mark = kTRUE;
9576 TIter next(((TH2Poly*)fH)->GetBins());
9577 TObject *obj, *poly;
9579 while ((obj=next())) {
9580 b = (TH2PolyBin*)obj;
9581 z = b->GetContent();
9582 if (z==0 && Hoption.Zero)
continue;
9583 poly = b->GetPolygon();
9586 if (poly->IsA() == TGraph::Class()) {
9587 TGraph *g = (TGraph*)poly;
9588 g->TAttLine::Modify();
9589 g->TAttMarker::Modify();
9590 g->TAttFill::Modify();
9592 Int_t fs = g->GetFillStyle();
9593 Int_t fc = g->GetFillColor();
9595 g->SetFillColor(g->GetLineColor());
9597 g->SetFillStyle(fs);
9598 g->SetFillColor(fc);
9600 if (fill) g->Paint(
"F");
9601 if (mark) g->Paint(
"P");
9605 if (poly->IsA() == TMultiGraph::Class()) {
9606 TMultiGraph *mg = (TMultiGraph*)poly;
9607 TList *gl = mg->GetListOfGraphs();
9611 while ((g = (TGraph*) nextg())) {
9612 g->TAttLine::Modify();
9613 g->TAttMarker::Modify();
9614 g->TAttFill::Modify();
9616 Int_t fs = g->GetFillStyle();
9617 Int_t fc = g->GetFillColor();
9619 g->SetFillColor(g->GetLineColor());
9621 g->SetFillStyle(fs);
9622 g->SetFillColor(fc);
9624 if (fill) g->Paint(
"F");
9625 if (mark) g->Paint(
"P");
9634 void THistPainter::PaintTH2PolyColorLevels(Option_t *)
9638 if (gPad->PadInHighlightMode() && gPad->GetSelected() != fH)
9641 Int_t ncolors, color, theColor;
9643 Double_t zmin = fH->GetMinimum();
9644 Double_t zmax = fH->GetMaximum();
9647 if (zmin <= 0) zmin = TMath::Min((Double_t)1, (Double_t)0.001*zmax);
9648 zmin = TMath::Log10(zmin);
9649 zmax = TMath::Log10(zmax);
9654 Double_t dz = zmax - zmin;
9657 ncolors = gStyle->GetNumberOfColors();
9658 Int_t ndiv = fH->GetContour();
9660 ndiv = gStyle->GetNumberContours();
9661 fH->SetContour(ndiv);
9663 Int_t ndivz = TMath::Abs(ndiv);
9664 if (fH->TestBit(TH1::kUserContour) == 0) fH->SetContour(ndiv);
9665 Double_t scale = ndivz/dz;
9669 TIter next(((TH2Poly*)fH)->GetBins());
9670 TObject *obj, *poly;
9672 while ((obj=next())) {
9673 b = (TH2PolyBin*)obj;
9674 poly = b->GetPolygon();
9676 z = b->GetContent();
9677 if (z==0 && Hoption.Zero)
continue;
9679 if (z > 0) z = TMath::Log10(z);
9682 if (z < zmin)
continue;
9685 if (fH->TestBit(TH1::kUserContour)) {
9686 zc = fH->GetContourLevelPad(0);
9687 if (z < zc)
continue;
9689 for (Int_t k=0; k<ndiv; k++) {
9690 zc = fH->GetContourLevelPad(k);
9698 color = Int_t(0.01+(z-zmin)*scale);
9700 theColor = Int_t((color+0.99)*Float_t(ncolors)/Float_t(ndivz));
9701 if (theColor > ncolors-1) theColor = ncolors-1;
9704 if (poly->IsA() == TGraph::Class()) {
9705 TGraph *g = (TGraph*)poly;
9706 g->SetFillColor(gStyle->GetColorPalette(theColor));
9707 g->TAttFill::Modify();
9712 if (poly->IsA() == TMultiGraph::Class()) {
9713 TMultiGraph *mg = (TMultiGraph*)poly;
9714 TList *gl = mg->GetListOfGraphs();
9718 while ((g = (TGraph*) nextg())) {
9719 g->SetFillColor(gStyle->GetColorPalette(theColor));
9720 g->TAttFill::Modify();
9725 if (Hoption.Zscale) PaintPalette();
9731 void THistPainter::PaintTH2PolyScatterPlot(Option_t *)
9735 if (gPad->PadInHighlightMode() && gPad->GetSelected() != fH)
9738 Int_t k, loop, marker=0;
9739 Double_t z, xk,xstep, yk, ystep, xp, yp;
9741 Double_t zmin = fH->GetMinimum();
9742 Double_t zmax = fH->GetMaximum();
9745 if (zmin <= 0) zmin = TMath::Min((Double_t)1, (Double_t)0.001*zmax);
9746 zmin = TMath::Log10(zmin);
9747 zmax = TMath::Log10(zmax);
9752 Double_t dz = zmax - zmin;
9753 scale = (kNMAX-1)/dz;
9763 TIter next(((TH2Poly*)fH)->GetBins());
9764 TObject *obj, *poly;
9766 Double_t maxarea = 0, a;
9767 while ((obj=next())) {
9768 b = (TH2PolyBin*)obj;
9770 if (a>maxarea) maxarea = a;
9775 while ((obj=next())) {
9776 b = (TH2PolyBin*)obj;
9777 poly = b->GetPolygon();
9778 z = b->GetContent();
9779 if (z < zmin) z = zmin;
9780 if (z > zmax) z = zmax;
9782 if (z > 0) z = TMath::Log10(z) - zmin;
9786 k = Int_t((z*scale)*(b->GetArea()/maxarea));
9789 xstep = b->GetXMax()-xk;
9790 ystep = b->GetYMax()-yk;
9793 if (poly->IsA() == TGraph::Class()) {
9794 TGraph *g = (TGraph*)poly;
9795 if (k <= 0 || z <= 0)
continue;
9798 if (k+marker >= kNMAX) {
9799 gPad->PaintPolyMarker(marker, fXbuf, fYbuf);
9802 xp = (random.Rndm()*xstep) + xk;
9803 yp = (random.Rndm()*ystep) + yk;
9804 if (g->IsInside(xp,yp)) {
9811 if (marker > 0) gPad->PaintPolyMarker(marker, fXbuf, fYbuf);
9815 if (poly->IsA() == TMultiGraph::Class()) {
9816 TMultiGraph *mg = (TMultiGraph*)poly;
9817 TList *gl = mg->GetListOfGraphs();
9819 if (k <= 0 || z <= 0)
continue;
9822 if (k+marker >= kNMAX) {
9823 gPad->PaintPolyMarker(marker, fXbuf, fYbuf);
9826 xp = (random.Rndm()*xstep) + xk;
9827 yp = (random.Rndm()*ystep) + yk;
9828 if (mg->IsInside(xp,yp)) {
9835 if (marker > 0) gPad->PaintPolyMarker(marker, fXbuf, fYbuf);
9838 PaintTH2PolyBins(
"l");
9844 void THistPainter::PaintTH2PolyText(Option_t *)
9848 text.SetTextFont(gStyle->GetTextFont());
9849 text.SetTextColor(fH->GetMarkerColor());
9850 text.SetTextSize(0.02*fH->GetMarkerSize());
9852 Double_t x, y, z, e, angle = 0;
9854 tf.Form(
"%s%s",
"%",gStyle->GetPaintTextFormat());
9855 if (Hoption.Text >= 1000) angle = Hoption.Text%1000;
9856 Int_t opt = (Int_t)Hoption.Text/1000;
9858 text.SetTextAlign(22);
9859 if (Hoption.Text == 1) angle = 0;
9860 text.SetTextAngle(angle);
9861 text.TAttText::Modify();
9865 TIter next(((TH2Poly*)fH)->GetBins());
9868 while ((obj=next())) {
9869 b = (TH2PolyBin*)obj;
9870 p = b->GetPolygon();
9871 x = (b->GetXMin()+b->GetXMax())/2;
9873 if (x > 0) x = TMath::Log10(x);
9876 y = (b->GetYMin()+b->GetYMax())/2;
9878 if (y > 0) y = TMath::Log10(y);
9881 z = b->GetContent();
9882 if (z < fH->GetMinimum() || (z == 0 && !Hoption.MinimumZero))
continue;
9884 e = fH->GetBinError(b->GetBinNumber());
9885 tf.Form(
"#splitline{%s%s}{#pm %s%s}",
9886 "%",gStyle->GetPaintTextFormat(),
9887 "%",gStyle->GetPaintTextFormat());
9888 tt.Form(tf.Data(),z,e);
9890 tt.Form(tf.Data(),z);
9892 if (opt==3) text.PaintLatex(x,y,angle,0.02*fH->GetMarkerSize(),p->GetName());
9893 else text.PaintLatex(x,y,angle,0.02*fH->GetMarkerSize(),tt.Data());
9896 PaintTH2PolyBins(
"l");
9902 void THistPainter::PaintText(Option_t *)
9906 text.SetTextFont(gStyle->GetTextFont());
9907 text.SetTextColor(fH->GetMarkerColor());
9908 text.SetTextSize(0.02*fH->GetMarkerSize());
9910 Double_t x, y, z, e, angle = 0;
9912 tf.Form(
"%s%s",
"%",gStyle->GetPaintTextFormat());
9913 if (Hoption.Text >= 1000) angle = Hoption.Text%1000;
9916 if (fH->GetDimension() == 1) {
9917 Bool_t getentries = kFALSE;
9919 TProfile *hp = (TProfile*)fH;
9920 if (Hoption.Text>2000 && fH->InheritsFrom(TProfile::Class())) {
9921 Hoption.Text = Hoption.Text-2000;
9924 if (Hoption.Text == 1) angle = 90;
9925 text.SetTextAlign(11);
9926 if (angle == 90) text.SetTextAlign(12);
9927 if (angle == 0) text.SetTextAlign(21);
9928 text.TAttText::Modify();
9929 Double_t dt = 0.02*(gPad->GetY2()-gPad->GetY1());
9930 for (Int_t i=Hparam.xfirst; i<=Hparam.xlast;i++) {
9932 x = fH->GetXaxis()->GetBinLowEdge(i)+
9933 fH->GetXaxis()->GetBinWidth(i)*
9934 (fH->GetBarOffset()+0.5*fH->GetBarWidth());
9936 x = fH->GetXaxis()->GetBinCenter(i);
9938 y = fH->GetBinContent(i);
9940 if (Hoption.MinimumZero && y<0) y = 0;
9941 if (getentries) yt = hp->GetBinEntries(i);
9942 if (yt == 0.)
continue;
9943 tt.Form(tf.Data(),yt);
9945 if (x > 0) x = TMath::Log10(x);
9949 if (y > 0) y = TMath::Log10(y);
9952 if (y >= gPad->GetY2())
continue;
9953 if (y <= gPad->GetY1())
continue;
9954 text.PaintLatex(x,y+0.2*dt,angle,0.02*fH->GetMarkerSize(),tt.Data());
9959 text.SetTextAlign(22);
9960 if (Hoption.Text == 1) angle = 0;
9961 text.SetTextAngle(angle);
9962 text.TAttText::Modify();
9963 for (Int_t j=Hparam.yfirst; j<=Hparam.ylast;j++) {
9964 y = fYaxis->GetBinCenter(j);
9966 if (y > 0) y = TMath::Log10(y);
9969 for (Int_t i=Hparam.xfirst; i<=Hparam.xlast;i++) {
9970 Int_t bin = j*(fXaxis->GetNbins()+2) + i;
9971 x = fXaxis->GetBinCenter(i);
9973 if (x > 0) x = TMath::Log10(x);
9976 if (!IsInside(x,y))
continue;
9977 z = fH->GetBinContent(bin);
9978 if (z < Hparam.zmin || (z == 0 && !Hoption.MinimumZero))
continue;
9979 if (Hoption.Text>2000) {
9980 e = fH->GetBinError(bin);
9981 tf.Form(
"#splitline{%s%s}{#pm %s%s}",
9982 "%",gStyle->GetPaintTextFormat(),
9983 "%",gStyle->GetPaintTextFormat());
9984 tt.Form(tf.Data(),z,e);
9986 tt.Form(tf.Data(),z);
9988 text.PaintLatex(x,y+fH->GetBarOffset()*fYaxis->GetBinWidth(j),
9989 angle,0.02*fH->GetMarkerSize(),tt.Data());
9998 void THistPainter::PaintTF3()
10003 TGaxis *axis =
new TGaxis();
10004 TAxis *xaxis = fH->GetXaxis();
10005 TAxis *yaxis = fH->GetYaxis();
10006 TAxis *zaxis = fH->GetZaxis();
10008 fXbuf[0] = xaxis->GetBinLowEdge(xaxis->GetFirst());
10009 fYbuf[0] = xaxis->GetBinUpEdge(xaxis->GetLast());
10010 fXbuf[1] = yaxis->GetBinLowEdge(yaxis->GetFirst());
10011 fYbuf[1] = yaxis->GetBinUpEdge(yaxis->GetLast());
10012 fXbuf[2] = zaxis->GetBinLowEdge(zaxis->GetFirst());
10013 fYbuf[2] = zaxis->GetBinUpEdge(zaxis->GetLast());
10015 fLego =
new TPainter3dAlgorithms(fXbuf, fYbuf);
10017 TView *view = gPad->GetView();
10019 Error(
"PaintTF3",
"no TView in current pad");
10022 Double_t thedeg = 90 - gPad->GetTheta();
10023 Double_t phideg = -90 - gPad->GetPhi();
10024 Double_t psideg = view->GetPsi();
10025 view->SetView(phideg, thedeg, psideg, irep);
10027 fLego->InitMoveScreen(-1.1,1.1);
10029 if (Hoption.BackBox) {
10030 fLego->DefineGridLevels(fZaxis->GetNdivisions()%100);
10031 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove1);
10032 fLego->BackBox(90);
10035 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMode1);
10037 fLego->ImplicitFunction(fXbuf, fYbuf, fH->GetNbinsX(),
10039 fH->GetNbinsZ(),
"BF");
10041 if (Hoption.FrontBox) {
10042 fLego->InitMoveScreen(-1.1,1.1);
10043 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove2);
10044 fLego->FrontBox(90);
10046 if (!Hoption.Axis && !Hoption.Same) PaintLegoAxis(axis, 90);
10051 delete fLego; fLego = 0;
10068 void THistPainter::PaintTitle()
10072 if (!gPad->GetView()) PaintHighlightBin();
10074 if (Hoption.Same)
return;
10075 if (fH->TestBit(TH1::kNoTitle))
return;
10076 Int_t nt = strlen(fH->GetTitle());
10077 TPaveText *title = 0;
10079 TIter next(gPad->GetListOfPrimitives());
10080 while ((obj = next())) {
10081 if (!obj->InheritsFrom(TPaveText::Class()))
continue;
10082 title = (TPaveText*)obj;
10083 if (strcmp(title->GetName(),
"title")) {title = 0;
continue;}
10086 if (nt == 0 || gStyle->GetOptTitle() <= 0) {
10087 if (title)
delete title;
10090 Double_t ht = gStyle->GetTitleH();
10091 Double_t wt = gStyle->GetTitleW();
10094 if (gStyle->GetTitleFont(
"")%10 == 3) {
10095 Double_t hw = TMath::Max((Double_t)gPad->XtoPixel(gPad->GetX2()),
10096 (Double_t)gPad->YtoPixel(gPad->GetY1()));
10097 ht = 1.1*(gStyle->GetTitleSize(
"")/hw);
10099 ht = 1.1*gStyle->GetTitleFontSize();
10102 if (ht <= 0) ht = 0.05;
10106 l.SetTitle(fH->GetTitle());
10108 ht = TMath::Max(ht, 1.2*l.GetYsize()/(gPad->GetY2() - gPad->GetY1()));
10109 Double_t wndc = l.GetXsize()/(gPad->GetX2() - gPad->GetX1());
10110 wt = TMath::Min(0.7, 0.02+wndc);
10113 TText *t0 = (TText*)title->GetLine(0);
10115 if (!strcmp(t0->GetTitle(),fH->GetTitle()))
return;
10116 t0->SetTitle(fH->GetTitle());
10117 if (wt > 0) title->SetX2NDC(title->GetX1NDC()+wt);
10122 Int_t talh = gStyle->GetTitleAlign()/10;
10123 if (talh < 1) talh = 1;
else if (talh > 3) talh = 3;
10124 Int_t talv = gStyle->GetTitleAlign()%10;
10125 if (talv < 1) talv = 1;
else if (talv > 3) talv = 3;
10126 Double_t xpos, ypos;
10127 xpos = gStyle->GetTitleX();
10128 ypos = gStyle->GetTitleY();
10129 if (talh == 2) xpos = xpos-wt/2.;
10130 if (talh == 3) xpos = xpos-wt;
10131 if (talv == 2) ypos = ypos+ht/2.;
10132 if (talv == 1) ypos = ypos+ht;
10134 TPaveText *ptitle =
new TPaveText(xpos, ypos-ht, xpos+wt, ypos,
"blNDC");
10137 ptitle->SetFillColor(gStyle->GetTitleFillColor());
10138 ptitle->SetFillStyle(gStyle->GetTitleStyle());
10139 ptitle->SetName(
"title");
10140 ptitle->SetBorderSize(gStyle->GetTitleBorderSize());
10141 ptitle->SetTextColor(gStyle->GetTitleTextColor());
10142 ptitle->SetTextFont(gStyle->GetTitleFont(
""));
10143 if (gStyle->GetTitleFont(
"")%10 > 2)
10144 ptitle->SetTextSize(gStyle->GetTitleFontSize());
10145 ptitle->AddText(fH->GetTitle());
10146 ptitle->SetBit(kCanDelete);
10150 if(!gPad->IsEditable())
delete ptitle;
10156 void THistPainter::ProcessMessage(
const char *mess,
const TObject *obj)
10159 if (!strcmp(mess,
"SetF3")) {
10160 TPainter3dAlgorithms::SetF3((TF3*)obj);
10161 }
else if (!strcmp(mess,
"SetF3ClippingBoxOff")) {
10162 TPainter3dAlgorithms::SetF3ClippingBoxOff();
10163 }
else if (!strcmp(mess,
"SetF3ClippingBoxOn")) {
10164 TVectorD &v = (TVectorD&)(*obj);
10165 Double_t xclip = v(0);
10166 Double_t yclip = v(1);
10167 Double_t zclip = v(2);
10168 TPainter3dAlgorithms::SetF3ClippingBoxOn(xclip,yclip,zclip);
10185 Int_t THistPainter::ProjectAitoff2xy(Double_t l, Double_t b, Double_t &Al, Double_t &Ab)
10190 Double_t alpha2 = (l/2)*TMath::DegToRad();
10191 Double_t delta = b*TMath::DegToRad();
10192 Double_t r2 = TMath::Sqrt(2.);
10193 Double_t f = 2*r2/TMath::Pi();
10194 Double_t cdec = TMath::Cos(delta);
10195 Double_t denom = TMath::Sqrt(1. + cdec*TMath::Cos(alpha2));
10196 x = cdec*TMath::Sin(alpha2)*2.*r2/denom;
10197 y = TMath::Sin(delta)*r2/denom;
10198 x *= TMath::RadToDeg()/f;
10199 y *= TMath::RadToDeg()/f;
10220 Int_t THistPainter::ProjectMercator2xy(Double_t l, Double_t b, Double_t &Al, Double_t &Ab)
10224 Double_t aid = TMath::Tan((TMath::PiOver2() + b*TMath::DegToRad())/2);
10225 Ab = TMath::Log(aid);
10232 Int_t THistPainter::ProjectSinusoidal2xy(Double_t l, Double_t b, Double_t &Al, Double_t &Ab)
10235 Al = l*cos(b*TMath::DegToRad());
10243 Int_t THistPainter::ProjectParabolic2xy(Double_t l, Double_t b, Double_t &Al, Double_t &Ab)
10246 Al = l*(2.*TMath::Cos(2*b*TMath::DegToRad()/3) - 1);
10247 Ab = 180*TMath::Sin(b*TMath::DegToRad()/3);
10254 void THistPainter::RecalculateRange()
10257 if (Hoption.Same)
return;
10260 Double_t xmin = Hparam.xmin;
10261 Double_t xmax = Hparam.xmax;
10262 Double_t ymin = Hparam.ymin;
10263 Double_t ymax = Hparam.ymax;
10265 Double_t xmin_aid, ymin_aid, xmax_aid, ymax_aid;
10266 if (Hoption.Proj ==1) {
10268 THistPainter::ProjectAitoff2xy(Hparam.xmin, Hparam.ymin, xmin_aid, ymin_aid);
10269 THistPainter::ProjectAitoff2xy(Hparam.xmin, Hparam.ymax, xmin, ymax_aid);
10270 THistPainter::ProjectAitoff2xy(Hparam.xmax, Hparam.ymax, xmax_aid, ymax);
10271 THistPainter::ProjectAitoff2xy(Hparam.xmax, Hparam.ymin, xmax, ymin);
10273 if (xmin > xmin_aid) xmin = xmin_aid;
10274 if (ymin > ymin_aid) ymin = ymin_aid;
10275 if (xmax < xmax_aid) xmax = xmax_aid;
10276 if (ymax < ymax_aid) ymax = ymax_aid;
10277 if (Hparam.ymin<0 && Hparam.ymax>0) {
10279 THistPainter::ProjectAitoff2xy(Hparam.xmin*0.9999, 0, xmin_aid, ymin_aid);
10280 THistPainter::ProjectAitoff2xy(Hparam.xmax*0.9999, 0, xmax_aid, ymin_aid);
10281 if (xmin >xmin_aid) xmin = xmin_aid;
10282 if (xmax <xmax_aid) xmax = xmax_aid;
10284 if (Hparam.xmin<0 && Hparam.xmax>0) {
10285 THistPainter::ProjectAitoff2xy(0, Hparam.ymin, xmin_aid, ymin_aid);
10286 THistPainter::ProjectAitoff2xy(0, Hparam.ymax, xmax_aid, ymax_aid);
10287 if (ymin >ymin_aid) ymin = ymin_aid;
10288 if (ymax <ymax_aid) ymax = ymax_aid;
10290 }
else if ( Hoption.Proj ==2) {
10291 if (Hparam.ymin <= -90 || Hparam.ymax >=90) {
10292 Warning(
"Mercator Projection",
"Latitude out of range %f or %f", Hparam.ymin, Hparam.ymax);
10295 THistPainter::ProjectMercator2xy(Hparam.xmin, Hparam.ymin, xmin, ymin);
10296 THistPainter::ProjectMercator2xy(Hparam.xmax, Hparam.ymax, xmax, ymax);
10298 }
else if (Hoption.Proj == 3) {
10299 THistPainter::ProjectSinusoidal2xy(Hparam.xmin, Hparam.ymin, xmin_aid, ymin_aid);
10300 THistPainter::ProjectSinusoidal2xy(Hparam.xmin, Hparam.ymax, xmin, ymax_aid);
10301 THistPainter::ProjectSinusoidal2xy(Hparam.xmax, Hparam.ymax, xmax_aid, ymax);
10302 THistPainter::ProjectSinusoidal2xy(Hparam.xmax, Hparam.ymin, xmax, ymin);
10304 if (xmin > xmin_aid) xmin = xmin_aid;
10305 if (ymin > ymin_aid) ymin = ymin_aid;
10306 if (xmax < xmax_aid) xmax = xmax_aid;
10307 if (ymax < ymax_aid) ymax = ymax_aid;
10308 if (Hparam.ymin<0 && Hparam.ymax>0) {
10309 THistPainter::ProjectSinusoidal2xy(Hparam.xmin, 0, xmin_aid, ymin_aid);
10310 THistPainter::ProjectSinusoidal2xy(Hparam.xmax, 0, xmax_aid, ymin_aid);
10311 if (xmin >xmin_aid) xmin = xmin_aid;
10312 if (xmax <xmax_aid) xmax = xmax_aid;
10314 if (Hparam.xmin<0 && Hparam.xmax>0) {
10315 THistPainter::ProjectSinusoidal2xy(0,Hparam.ymin, xmin_aid, ymin_aid);
10316 THistPainter::ProjectSinusoidal2xy(0, Hparam.ymax, xmax_aid, ymin_aid);
10317 if (ymin >ymin_aid) ymin = ymin_aid;
10318 if (ymax <ymax_aid) ymax = ymax_aid;
10320 }
else if (Hoption.Proj == 4) {
10321 THistPainter::ProjectParabolic2xy(Hparam.xmin, Hparam.ymin, xmin_aid, ymin_aid);
10322 THistPainter::ProjectParabolic2xy(Hparam.xmin, Hparam.ymax, xmin, ymax_aid);
10323 THistPainter::ProjectParabolic2xy(Hparam.xmax, Hparam.ymax, xmax_aid, ymax);
10324 THistPainter::ProjectParabolic2xy(Hparam.xmax, Hparam.ymin, xmax, ymin);
10326 if (xmin > xmin_aid) xmin = xmin_aid;
10327 if (ymin > ymin_aid) ymin = ymin_aid;
10328 if (xmax < xmax_aid) xmax = xmax_aid;
10329 if (ymax < ymax_aid) ymax = ymax_aid;
10330 if (Hparam.ymin<0 && Hparam.ymax>0) {
10331 THistPainter::ProjectParabolic2xy(Hparam.xmin, 0, xmin_aid, ymin_aid);
10332 THistPainter::ProjectParabolic2xy(Hparam.xmax, 0, xmax_aid, ymin_aid);
10333 if (xmin >xmin_aid) xmin = xmin_aid;
10334 if (xmax <xmax_aid) xmax = xmax_aid;
10336 if (Hparam.xmin<0 && Hparam.xmax>0) {
10337 THistPainter::ProjectParabolic2xy(0, Hparam.ymin, xmin_aid, ymin_aid);
10338 THistPainter::ProjectParabolic2xy(0, Hparam.ymax, xmax_aid, ymin_aid);
10339 if (ymin >ymin_aid) ymin = ymin_aid;
10340 if (ymax <ymax_aid) ymax = ymax_aid;
10348 Double_t dx = xmax-xmin;
10349 Double_t dy = ymax-ymin;
10350 Double_t dxr = dx/(1 - gPad->GetLeftMargin() - gPad->GetRightMargin());
10351 Double_t dyr = dy/(1 - gPad->GetBottomMargin() - gPad->GetTopMargin());
10355 gPad->Range(xmin - dxr*gPad->GetLeftMargin(),
10356 ymin - dyr*gPad->GetBottomMargin(),
10357 xmax + dxr*gPad->GetRightMargin(),
10358 ymax + dyr*gPad->GetTopMargin());
10359 gPad->RangeAxis(xmin, ymin, xmax, ymax);
10365 void THistPainter::SetHistogram(TH1 *h)
10368 if (h == 0)
return;
10370 fXaxis = h->GetXaxis();
10371 fYaxis = h->GetYaxis();
10372 fZaxis = h->GetZaxis();
10373 fFunctions = fH->GetListOfFunctions();
10379 Int_t THistPainter::TableInit()
10382 static const char *where =
"TableInit";
10385 Double_t yMARGIN= gStyle->GetHistTopMargin();
10386 Double_t zmin, zmax;
10389 if (fH->GetMaximumStored() != -1111) maximum = 1;
10390 if (fH->GetMinimumStored() != -1111) minimum = 1;
10393 first = fXaxis->GetFirst();
10394 last = fXaxis->GetLast();
10395 Hparam.xlast = last;
10396 Hparam.xfirst = first;
10397 Hparam.xlowedge = fXaxis->GetBinLowEdge(first);
10398 Hparam.xbinsize = fXaxis->GetBinWidth(first);
10399 Hparam.xmin = Hparam.xlowedge;
10400 Hparam.xmax = fXaxis->GetBinLowEdge(last)+fXaxis->GetBinWidth(last);
10403 if (Hoption.Logx) {
10405 if (Hparam.xlowedge <=0 ) {
10406 Hparam.xlowedge = fXaxis->GetBinUpEdge(fXaxis->FindFixBin(0.01*Hparam.xbinsize));
10407 Hparam.xmin = Hparam.xlowedge;
10409 if (Hparam.xmin <=0 || Hparam.xmax <=0) {
10410 Error(where,
"cannot set X axis to log scale");
10413 Hparam.xfirst= fXaxis->FindFixBin(Hparam.xmin);
10414 if (Hparam.xfirst < first) Hparam.xfirst = first;
10415 Hparam.xlast = fXaxis->FindFixBin(Hparam.xmax);
10416 if (Hparam.xlast > last) Hparam.xlast = last;
10417 Hparam.xmin = TMath::Log10(Hparam.xmin);
10418 Hparam.xmax = TMath::Log10(Hparam.xmax);
10422 first = fYaxis->GetFirst();
10423 last = fYaxis->GetLast();
10424 Hparam.ylast = last;
10425 Hparam.yfirst = first;
10426 Hparam.ylowedge = fYaxis->GetBinLowEdge(first);
10427 Hparam.ybinsize = fYaxis->GetBinWidth(first);
10428 if (!Hparam.ybinsize) Hparam.ybinsize = 1;
10429 Hparam.ymin = Hparam.ylowedge;
10430 Hparam.ymax = fYaxis->GetBinLowEdge(last)+fYaxis->GetBinWidth(last);
10433 if (Hoption.Logy) {
10434 if (Hparam.ylowedge <=0 ) {
10435 Hparam.ylowedge = fYaxis->GetBinUpEdge(fYaxis->FindFixBin(0.01*Hparam.ybinsize));
10436 Hparam.ymin = Hparam.ylowedge;
10438 if (Hparam.ymin <=0 || Hparam.ymax <=0) {
10439 Error(where,
"cannot set Y axis to log scale");
10442 Hparam.yfirst= fYaxis->FindFixBin(Hparam.ymin);
10443 if (Hparam.yfirst < first) Hparam.yfirst = first;
10444 Hparam.ylast = fYaxis->FindFixBin(Hparam.ymax);
10445 if (Hparam.ylast > last) Hparam.ylast = last;
10446 Hparam.ymin = TMath::Log10(Hparam.ymin);
10447 Hparam.ymax = TMath::Log10(Hparam.ymax);
10452 Double_t bigp = TMath::Power(10,32);
10456 Double_t allchan = 0;
10457 for (Int_t j=Hparam.yfirst; j<=Hparam.ylast;j++) {
10458 for (Int_t i=Hparam.xfirst; i<=Hparam.xlast;i++) {
10459 c1 = fH->GetBinContent(i,j);
10460 zmax = TMath::Max(zmax,c1);
10461 if (Hoption.Error) {
10462 e1 = fH->GetBinError(i,j);
10463 zmax = TMath::Max(zmax,c1+e1);
10465 zmin = TMath::Min(zmin,c1);
10472 if (maximum) zmax = fH->GetMaximumStored();
10473 if (minimum) zmin = fH->GetMinimumStored();
10474 if (Hoption.Logz && zmax < 0) {
10475 if (!Hoption.Same) Error(where,
"log scale is requested but maximum is less or equal 0 (%f)", zmax);
10477 }
else if (Hoption.Logz && zmin>=0 && zmax==0) {
10481 if (zmin >= zmax) {
10482 if (Hoption.Logz) {
10483 if (zmax > 0) zmin = 0.001*zmax;
10485 if (!Hoption.Same) Error(where,
"log scale is requested but maximum is less or equal 0 (%f)", zmax);
10492 Hparam.allchan = allchan;
10493 Double_t factor = allchan;
10494 if (fH->GetNormFactor() > 0) factor = fH->GetNormFactor();
10495 if (allchan) factor /= allchan;
10496 if (factor == 0) factor = 1;
10497 Hparam.factor = factor;
10498 zmax = factor*zmax;
10499 zmin = factor*zmin;
10501 if (TMath::Abs(zmin) > TMath::Abs(c1)) c1 = zmin;
10507 if (Hoption.Logz) {
10509 zmin = TMath::Min((Double_t)1, (Double_t)0.001*zmax);
10510 fH->SetMinimum(zmin);
10512 zmin = TMath::Log10(zmin);
10513 if (!minimum) zmin += TMath::Log10(0.5);
10514 zmax = TMath::Log10(zmax);
10515 if (!maximum) zmax += TMath::Log10(2*(0.9/0.95));
10525 zmax += yMARGIN*(zmax-zmin);
10532 if (Hoption.MinimumZero) {
10533 if (zmin >= 0) zmin = 0;
10534 else zmin -= yMARGIN*(zmax-zmin);
10536 Double_t dzmin = yMARGIN*(zmax-zmin);
10537 if (zmin >= 0 && (zmin-dzmin <= 0)) zmin = 0;
10538 else zmin -= dzmin;
10543 Hparam.zmin = zmin;
10544 Hparam.zmax = zmax;
10547 Hparam.baroffset = fH->GetBarOffset();
10548 Hparam.barwidth = fH->GetBarWidth();
10557 const char * THistPainter::GetBestFormat(Double_t v, Double_t e,
const char *f)
10564 tf.Form(
"%s%s",
"%",f);
10565 tv.Form(tf.Data(),v);
10568 int ie = tv.Index(
"e");
10569 int iE = tv.Index(
"E");
10570 int id = tv.Index(
".");
10574 if (ie >= 0 || iE >= 0) {
10575 if (tv.Index(
"+") >= 0) {
10577 ef.Form(
"%s.1f",
"%");
10580 ef.Form(
"%s.%de",
"%",ie-
id-1);
10582 ef.Form(
"%s.%dE",
"%",iE-
id-1);
10587 ef.Form(
"%s.%de",
"%",ie-
id-1);
10589 ef.Form(
"%s.%dE",
"%",iE-
id-1);
10594 }
else if (
id < 0) {
10595 ef.Form(
"%s.1f",
"%");
10600 ef.Form(
"%s.%df",
"%",tv.Length()-
id-1);
10609 void THistPainter::SetShowProjection(
const char *option,Int_t nbins)
10612 if (fShowProjection)
return;
10613 TString opt = option;
10615 Int_t projection = 0;
10616 if (opt.Contains(
"x")) projection = 1;
10617 if (opt.Contains(
"y")) projection = 2;
10618 if (opt.Contains(
"z")) projection = 3;
10619 if (opt.Contains(
"xy")) projection = 4;
10620 if (opt.Contains(
"yx")) projection = 5;
10621 if (opt.Contains(
"xz")) projection = 6;
10622 if (opt.Contains(
"zx")) projection = 7;
10623 if (opt.Contains(
"yz")) projection = 8;
10624 if (opt.Contains(
"zy")) projection = 9;
10625 if (projection < 4) fShowOption = option+1;
10626 else fShowOption = option+2;
10627 fShowProjection = projection+100*nbins;
10628 gROOT->MakeDefCanvas();
10629 gPad->SetName(Form(
"c_%lx_projection_%d", (ULong_t)fH, fShowProjection));
10636 void THistPainter::ShowProjectionX(Int_t , Int_t py)
10639 Int_t nbins = (Int_t)fShowProjection/100;
10640 gPad->SetDoubleBuffer(0);
10641 gVirtualX->SetDrawMode(TVirtualX::kInvert);
10644 static int pyold1 = 0;
10645 static int pyold2 = 0;
10646 float uxmin = gPad->GetUxmin();
10647 float uxmax = gPad->GetUxmax();
10648 int pxmin = gPad->XtoAbsPixel(uxmin);
10649 int pxmax = gPad->XtoAbsPixel(uxmax);
10650 Float_t upy = gPad->AbsPixeltoY(py);
10651 Float_t y = gPad->PadtoY(upy);
10652 Int_t biny1 = fH->GetYaxis()->FindBin(y);
10653 Int_t biny2 = TMath::Min(biny1+nbins-1, fH->GetYaxis()->GetNbins());
10654 Int_t py1 = gPad->YtoAbsPixel(fH->GetYaxis()->GetBinLowEdge(biny1));
10655 Int_t py2 = gPad->YtoAbsPixel(fH->GetYaxis()->GetBinUpEdge(biny2));
10657 if (pyold1 || pyold2) gVirtualX->DrawBox(pxmin,pyold1,pxmax,pyold2,TVirtualX::kFilled);
10658 gVirtualX->DrawBox(pxmin,py1,pxmax,py2,TVirtualX::kFilled);
10663 TVirtualPad *padsav = gPad;
10664 TVirtualPad *c = (TVirtualPad*)gROOT->GetListOfCanvases()->FindObject(Form(
"c_%lx_projection_%d",
10665 (ULong_t)fH, fShowProjection));
10669 fShowProjection = 0;
10675 c->SetLogy(padsav->GetLogz());
10676 c->SetLogx(padsav->GetLogx());
10679 TString prjName = TString::Format(
"slice_px_of_%s",fH->GetName());
10680 TH1D *hp = ((TH2*)fH)->ProjectionX(prjName, biny1, biny2);
10682 hp->SetFillColor(38);
10685 if (biny1 == biny2) {
10686 Double_t valueFrom = fH->GetYaxis()->GetBinLowEdge(biny1);
10687 Double_t valueTo = fH->GetYaxis()->GetBinUpEdge(biny1);
10689 Int_t valuePrecision = -TMath::Nint(TMath::Log10(valueTo-valueFrom))+1;
10690 if (fH->GetYaxis()->GetLabels() != NULL) {
10691 hp->SetTitle(TString::Format(
"ProjectionX of biny=%d [y=%.*lf..%.*lf] %s", biny1, valuePrecision, valueFrom, valuePrecision, valueTo, fH->GetYaxis()->GetBinLabel(biny1)));
10693 hp->SetTitle(TString::Format(
"ProjectionX of biny=%d [y=%.*lf..%.*lf]", biny1, valuePrecision, valueFrom, valuePrecision, valueTo));
10696 Double_t valueFrom = fH->GetYaxis()->GetBinLowEdge(biny1);
10697 Double_t valueTo = fH->GetYaxis()->GetBinUpEdge(biny2);
10701 Int_t valuePrecision = -TMath::Nint(TMath::Log10(fH->GetYaxis()->GetBinUpEdge(biny1)-valueFrom))+1;
10702 if (fH->GetYaxis()->GetLabels() != NULL) {
10703 hp->SetTitle(TString::Format(
"ProjectionX of biny=[%d,%d] [y=%.*lf..%.*lf] [%s..%s]", biny1, biny2, valuePrecision, valueFrom, valuePrecision, valueTo, fH->GetYaxis()->GetBinLabel(biny1), fH->GetYaxis()->GetBinLabel(biny2)));
10705 hp->SetTitle(TString::Format(
"ProjectionX of biny=[%d,%d] [y=%.*lf..%.*lf]", biny1, biny2, valuePrecision, valueFrom, valuePrecision, valueTo));
10708 hp->SetXTitle(fH->GetXaxis()->GetTitle());
10709 hp->SetYTitle(
"Number of Entries");
10719 void THistPainter::ShowProjectionY(Int_t px, Int_t )
10722 Int_t nbins = (Int_t)fShowProjection/100;
10723 gPad->SetDoubleBuffer(0);
10724 gVirtualX->SetDrawMode(TVirtualX::kInvert);
10727 static int pxold1 = 0;
10728 static int pxold2 = 0;
10729 float uymin = gPad->GetUymin();
10730 float uymax = gPad->GetUymax();
10731 int pymin = gPad->YtoAbsPixel(uymin);
10732 int pymax = gPad->YtoAbsPixel(uymax);
10733 Float_t upx = gPad->AbsPixeltoX(px);
10734 Float_t x = gPad->PadtoX(upx);
10735 Int_t binx1 = fH->GetXaxis()->FindBin(x);
10736 Int_t binx2 = TMath::Min(binx1+nbins-1, fH->GetXaxis()->GetNbins());
10737 Int_t px1 = gPad->XtoAbsPixel(fH->GetXaxis()->GetBinLowEdge(binx1));
10738 Int_t px2 = gPad->XtoAbsPixel(fH->GetXaxis()->GetBinUpEdge(binx2));
10740 if (pxold1 || pxold2) gVirtualX->DrawBox(pxold1,pymin,pxold2,pymax,TVirtualX::kFilled);
10741 gVirtualX->DrawBox(px1,pymin,px2,pymax,TVirtualX::kFilled);
10746 TVirtualPad *padsav = gPad;
10747 TVirtualPad *c = (TVirtualPad*)gROOT->GetListOfCanvases()->FindObject(Form(
"c_%lx_projection_%d",
10748 (ULong_t)fH, fShowProjection));
10752 fShowProjection = 0;
10758 c->SetLogy(padsav->GetLogz());
10759 c->SetLogx(padsav->GetLogy());
10762 TString prjName = TString::Format(
"slice_py_of_%s",fH->GetName());
10763 TH1D *hp = ((TH2*)fH)->ProjectionY(prjName, binx1, binx2);
10765 hp->SetFillColor(38);
10768 if (binx1 == binx2) {
10769 Double_t valueFrom = fH->GetXaxis()->GetBinLowEdge(binx1);
10770 Double_t valueTo = fH->GetXaxis()->GetBinUpEdge(binx1);
10772 Int_t valuePrecision = -TMath::Nint(TMath::Log10(valueTo-valueFrom))+1;
10773 if (fH->GetXaxis()->GetLabels() != NULL) {
10774 hp->SetTitle(TString::Format(
"ProjectionY of binx=%d [x=%.*lf..%.*lf] [%s]", binx1, valuePrecision, valueFrom, valuePrecision, valueTo, fH->GetXaxis()->GetBinLabel(binx1)));
10776 hp->SetTitle(TString::Format(
"ProjectionY of binx=%d [x=%.*lf..%.*lf]", binx1, valuePrecision, valueFrom, valuePrecision, valueTo));
10779 Double_t valueFrom = fH->GetXaxis()->GetBinLowEdge(binx1);
10780 Double_t valueTo = fH->GetXaxis()->GetBinUpEdge(binx2);
10784 Int_t valuePrecision = -TMath::Nint(TMath::Log10(fH->GetXaxis()->GetBinUpEdge(binx1)-valueFrom))+1;
10785 if (fH->GetXaxis()->GetLabels() != NULL) {
10786 hp->SetTitle(TString::Format(
"ProjectionY of binx=[%d,%d] [x=%.*lf..%.*lf] [%s..%s]", binx1, binx2, valuePrecision, valueFrom, valuePrecision, valueTo, fH->GetXaxis()->GetBinLabel(binx1), fH->GetXaxis()->GetBinLabel(binx2)));
10788 hp->SetTitle(TString::Format(
"ProjectionY of binx=[%d,%d] [x=%.*lf..%.*lf]", binx1, binx2, valuePrecision, valueFrom, valuePrecision, valueTo));
10791 hp->SetXTitle(fH->GetYaxis()->GetTitle());
10792 hp->SetYTitle(
"Number of Entries");
10807 void THistPainter::ShowProjection3(Int_t px, Int_t py)
10810 Int_t nbins=(Int_t)fShowProjection/100;
10811 if (fH->GetDimension() < 3) {
10812 if (fShowProjection%100 == 1) {ShowProjectionX(px,py);
return;}
10813 if (fShowProjection%100 == 2) {ShowProjectionY(px,py);
return;}
10816 gPad->SetDoubleBuffer(0);
10817 gVirtualX->SetDrawMode(TVirtualX::kInvert);
10820 TView *view = gPad->GetView();
10822 TH3 *h3 = (TH3*)fH;
10823 TAxis *xaxis = h3->GetXaxis();
10824 TAxis *yaxis = h3->GetYaxis();
10825 TAxis *zaxis = h3->GetZaxis();
10826 Double_t u[3],xx[3];
10828 static TPoint line1[2];
10829 static TPoint line2[2];
10830 static TPoint line3[2];
10831 static TPoint line4[2];
10832 static TPoint endface1[5];
10833 static TPoint endface2[5];
10834 static TPoint rect1[5];
10835 static TPoint rect2[5];
10837 Double_t uxmin = gPad->GetUxmin();
10838 Double_t uxmax = gPad->GetUxmax();
10839 Double_t uymin = gPad->GetUymin();
10840 Double_t uymax = gPad->GetUymax();
10842 int pxmin = gPad->XtoAbsPixel(uxmin);
10843 int pxmax = gPad->XtoAbsPixel(uxmax);
10844 if (pxmin==pxmax)
return;
10845 int pymin = gPad->YtoAbsPixel(uymin);
10846 int pymax = gPad->YtoAbsPixel(uymax);
10847 if (pymin==pymax)
return;
10848 Double_t cx = (pxmax-pxmin)/(uxmax-uxmin);
10849 Double_t cy = (pymax-pymin)/(uymax-uymin);
10850 TVirtualPad *padsav = gPad;
10851 TVirtualPad *c = (TVirtualPad*)gROOT->GetListOfCanvases()->FindObject(Form(
"c_%lx_projection_%d",
10852 (ULong_t)fH, fShowProjection));
10854 fShowProjection = 0;
10858 switch ((Int_t)fShowProjection%100) {
10862 Int_t firstY = yaxis->GetFirst();
10863 Int_t lastY = yaxis->GetLast();
10864 Int_t biny = firstY + Int_t((lastY-firstY)*(px-pxmin)/(pxmax-pxmin));
10865 Int_t biny2 = TMath::Min(biny+nbins-1,yaxis->GetNbins() );
10866 yaxis->SetRange(biny,biny2);
10867 Int_t firstZ = zaxis->GetFirst();
10868 Int_t lastZ = zaxis->GetLast();
10869 Int_t binz = firstZ + Int_t((lastZ-firstZ)*(py-pymin)/(pymax-pymin));
10870 Int_t binz2 = TMath::Min(binz+nbins-1,zaxis->GetNbins() );
10871 zaxis->SetRange(binz,binz2);
10872 if (line1[0].GetX()) gVirtualX->DrawPolyLine(2,line1);
10873 if (nbins>1 && line1[0].GetX()) {
10874 gVirtualX->DrawPolyLine(2,line2);
10875 gVirtualX->DrawPolyLine(2,line3);
10876 gVirtualX->DrawPolyLine(2,line4);
10877 gVirtualX->DrawPolyLine(5,endface1);
10878 gVirtualX->DrawPolyLine(5,endface2);
10880 xx[0] = xaxis->GetXmin();
10881 xx[2] = zaxis->GetBinCenter(binz);
10882 xx[1] = yaxis->GetBinCenter(biny);
10883 view->WCtoNDC(xx,u);
10884 line1[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
10885 line1[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
10886 xx[0] = xaxis->GetXmax();
10887 view->WCtoNDC(xx,u);
10888 line1[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
10889 line1[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
10890 gVirtualX->DrawPolyLine(2,line1);
10892 xx[0] = xaxis->GetXmin();
10893 xx[2] = zaxis->GetBinCenter(binz+nbins-1);
10894 xx[1] = yaxis->GetBinCenter(biny);
10895 view->WCtoNDC(xx,u);
10896 line2[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
10897 line2[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
10898 xx[0] = xaxis->GetXmax();
10899 view->WCtoNDC(xx,u);
10900 line2[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
10901 line2[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
10903 xx[0] = xaxis->GetXmin();
10904 xx[2] = zaxis->GetBinCenter(binz+nbins-1);
10905 xx[1] = yaxis->GetBinCenter(biny+nbins-1);
10906 view->WCtoNDC(xx,u);
10907 line3[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
10908 line3[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
10909 xx[0] = xaxis->GetXmax();
10910 view->WCtoNDC(xx,u);
10911 line3[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
10912 line3[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
10914 xx[0] = xaxis->GetXmin();
10915 xx[2] = zaxis->GetBinCenter(binz);
10916 xx[1] = yaxis->GetBinCenter(biny+nbins-1);
10917 view->WCtoNDC(xx,u);
10918 line4[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
10919 line4[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
10920 xx[0] = xaxis->GetXmax();
10921 view->WCtoNDC(xx,u);
10922 line4[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
10923 line4[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
10925 endface1[0].SetX(line1[0].GetX());
10926 endface1[0].SetY(line1[0].GetY());
10927 endface1[1].SetX(line2[0].GetX());
10928 endface1[1].SetY(line2[0].GetY());
10929 endface1[2].SetX(line3[0].GetX());
10930 endface1[2].SetY(line3[0].GetY());
10931 endface1[3].SetX(line4[0].GetX());
10932 endface1[3].SetY(line4[0].GetY());
10933 endface1[4].SetX(line1[0].GetX());
10934 endface1[4].SetY(line1[0].GetY());
10936 endface2[0].SetX(line1[1].GetX());
10937 endface2[0].SetY(line1[1].GetY());
10938 endface2[1].SetX(line2[1].GetX());
10939 endface2[1].SetY(line2[1].GetY());
10940 endface2[2].SetX(line3[1].GetX());
10941 endface2[2].SetY(line3[1].GetY());
10942 endface2[3].SetX(line4[1].GetX());
10943 endface2[3].SetY(line4[1].GetY());
10944 endface2[4].SetX(line1[1].GetX());
10945 endface2[4].SetY(line1[1].GetY());
10947 gVirtualX->DrawPolyLine(2,line2);
10948 gVirtualX->DrawPolyLine(2,line3);
10949 gVirtualX->DrawPolyLine(2,line4);
10950 gVirtualX->DrawPolyLine(5,endface1);
10951 gVirtualX->DrawPolyLine(5,endface2);
10955 TH1 *hp = h3->Project3D(
"x");
10956 yaxis->SetRange(firstY,lastY);
10957 zaxis->SetRange(firstZ,lastZ);
10959 hp->SetFillColor(38);
10961 hp->SetTitle(TString::Format(
"ProjectionX of biny=%d [y=%.1f..%.1f] binz=%d [z=%.1f..%.1f]", biny, yaxis->GetBinLowEdge(biny), yaxis->GetBinUpEdge(biny),
10962 binz, zaxis->GetBinLowEdge(binz), zaxis->GetBinUpEdge(binz)));
10964 hp->SetTitle(TString::Format(
"ProjectionX, biny=[%d,%d] [y=%.1f..%.1f], binz=[%d,%d] [z=%.1f..%.1f]", biny, biny2, yaxis->GetBinLowEdge(biny), yaxis->GetBinUpEdge(biny2),
10965 binz, binz2, zaxis->GetBinLowEdge(binz), zaxis->GetBinUpEdge(binz2) ) );
10967 hp->SetXTitle(fH->GetXaxis()->GetTitle());
10968 hp->SetYTitle(
"Number of Entries");
10969 hp->Draw(fShowOption.Data());
10977 Int_t firstX = xaxis->GetFirst();
10978 Int_t lastX = xaxis->GetLast();
10979 Int_t binx = firstX + Int_t((lastX-firstX)*(px-pxmin)/(pxmax-pxmin));
10980 Int_t binx2 = TMath::Min(binx+nbins-1,xaxis->GetNbins() );
10981 xaxis->SetRange(binx,binx2);
10982 Int_t firstZ = zaxis->GetFirst();
10983 Int_t lastZ = zaxis->GetLast();
10984 Int_t binz = firstZ + Int_t((lastZ-firstZ)*(py-pymin)/(pymax-pymin));
10985 Int_t binz2 = TMath::Min(binz+nbins-1,zaxis->GetNbins() );
10986 zaxis->SetRange(binz,binz2);
10987 if (line1[0].GetX()) gVirtualX->DrawPolyLine(2,line1);
10988 if (nbins>1 && line1[0].GetX()) {
10989 gVirtualX->DrawPolyLine(2,line2);
10990 gVirtualX->DrawPolyLine(2,line3);
10991 gVirtualX->DrawPolyLine(2,line4);
10992 gVirtualX->DrawPolyLine(5,endface1);
10993 gVirtualX->DrawPolyLine(5,endface2);
10995 xx[0]=xaxis->GetBinCenter(binx);
10996 xx[2] = zaxis->GetBinCenter(binz);
10997 xx[1] = yaxis->GetXmin();
10998 view->WCtoNDC(xx,u);
10999 line1[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11000 line1[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
11001 xx[1] = yaxis->GetXmax();
11002 view->WCtoNDC(xx,u);
11003 line1[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11004 line1[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
11005 gVirtualX->DrawPolyLine(2,line1);
11007 xx[1] = yaxis->GetXmin();
11008 xx[2] = zaxis->GetBinCenter(binz+nbins-1);
11009 xx[0] = xaxis->GetBinCenter(binx);
11010 view->WCtoNDC(xx,u);
11011 line2[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11012 line2[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
11013 xx[1] = yaxis->GetXmax();
11014 view->WCtoNDC(xx,u);
11015 line2[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11016 line2[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
11018 xx[1] = yaxis->GetXmin();
11019 xx[2] = zaxis->GetBinCenter(binz+nbins-1);
11020 xx[0] = xaxis->GetBinCenter(binx+nbins-1);
11021 view->WCtoNDC(xx,u);
11022 line3[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11023 line3[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
11024 xx[1] = yaxis->GetXmax();
11025 view->WCtoNDC(xx,u);
11026 line3[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11027 line3[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
11029 xx[1] = yaxis->GetXmin();
11030 xx[2] = zaxis->GetBinCenter(binz);
11031 xx[0] = xaxis->GetBinCenter(binx+nbins-1);
11032 view->WCtoNDC(xx,u);
11033 line4[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11034 line4[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
11035 xx[1] = yaxis->GetXmax();
11036 view->WCtoNDC(xx,u);
11037 line4[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11038 line4[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
11040 endface1[0].SetX(line1[0].GetX());
11041 endface1[0].SetY(line1[0].GetY());
11042 endface1[1].SetX(line2[0].GetX());
11043 endface1[1].SetY(line2[0].GetY());
11044 endface1[2].SetX(line3[0].GetX());
11045 endface1[2].SetY(line3[0].GetY());
11046 endface1[3].SetX(line4[0].GetX());
11047 endface1[3].SetY(line4[0].GetY());
11048 endface1[4].SetX(line1[0].GetX());
11049 endface1[4].SetY(line1[0].GetY());
11051 endface2[0].SetX(line1[1].GetX());
11052 endface2[0].SetY(line1[1].GetY());
11053 endface2[1].SetX(line2[1].GetX());
11054 endface2[1].SetY(line2[1].GetY());
11055 endface2[2].SetX(line3[1].GetX());
11056 endface2[2].SetY(line3[1].GetY());
11057 endface2[3].SetX(line4[1].GetX());
11058 endface2[3].SetY(line4[1].GetY());
11059 endface2[4].SetX(line1[1].GetX());
11060 endface2[4].SetY(line1[1].GetY());
11062 gVirtualX->DrawPolyLine(2,line2);
11063 gVirtualX->DrawPolyLine(2,line3);
11064 gVirtualX->DrawPolyLine(2,line4);
11065 gVirtualX->DrawPolyLine(5,endface1);
11066 gVirtualX->DrawPolyLine(5,endface2);
11070 TH1 *hp = h3->Project3D(
"y");
11071 xaxis->SetRange(firstX,lastX);
11072 zaxis->SetRange(firstZ,lastZ);
11074 hp->SetFillColor(38);
11076 hp->SetTitle(TString::Format(
"ProjectionY of binx=%d [x=%.1f..%.1f] binz=%d [z=%.1f..%.1f]", binx, xaxis->GetBinLowEdge(binx), xaxis->GetBinUpEdge(binx),
11077 binz, zaxis->GetBinLowEdge(binz), zaxis->GetBinUpEdge(binz)));
11079 hp->SetTitle(TString::Format(
"ProjectionY, binx=[%d,%d] [x=%.1f..%.1f], binz=[%d,%d] [z=%.1f..%.1f]", binx, binx2, xaxis->GetBinLowEdge(binx), xaxis->GetBinUpEdge(binx2),
11080 binz, binz2, zaxis->GetBinLowEdge(binz), zaxis->GetBinUpEdge(binz2) ) );
11081 hp->SetXTitle(fH->GetYaxis()->GetTitle());
11082 hp->SetYTitle(
"Number of Entries");
11083 hp->Draw(fShowOption.Data());
11091 Int_t firstX = xaxis->GetFirst();
11092 Int_t lastX = xaxis->GetLast();
11093 Int_t binx = firstX + Int_t((lastX-firstX)*(px-pxmin)/(pxmax-pxmin));
11094 Int_t binx2 = TMath::Min(binx+nbins-1,xaxis->GetNbins() );
11095 xaxis->SetRange(binx,binx2);
11096 Int_t firstY = yaxis->GetFirst();
11097 Int_t lastY = yaxis->GetLast();
11098 Int_t biny = firstY + Int_t((lastY-firstY)*(py-pymin)/(pymax-pymin));
11099 Int_t biny2 = TMath::Min(biny+nbins-1,yaxis->GetNbins() );
11100 yaxis->SetRange(biny,biny2);
11101 if (line1[0].GetX()) gVirtualX->DrawPolyLine(2,line1);
11102 if (nbins>1 && line1[0].GetX()) {
11103 gVirtualX->DrawPolyLine(2,line2);
11104 gVirtualX->DrawPolyLine(2,line3);
11105 gVirtualX->DrawPolyLine(2,line4);
11106 gVirtualX->DrawPolyLine(5,endface1);
11107 gVirtualX->DrawPolyLine(5,endface2);
11109 xx[0] = xaxis->GetBinCenter(binx);
11110 xx[1] = yaxis->GetBinCenter(biny);
11111 xx[2] = zaxis->GetXmin();
11112 view->WCtoNDC(xx,u);
11113 line1[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11114 line1[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
11115 xx[2] = zaxis->GetXmax();
11116 view->WCtoNDC(xx,u);
11117 line1[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11118 line1[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
11119 gVirtualX->DrawPolyLine(2,line1);
11121 xx[2] = zaxis->GetXmin();
11122 xx[1] = yaxis->GetBinCenter(biny+nbins-1);
11123 xx[0] = xaxis->GetBinCenter(binx);
11124 view->WCtoNDC(xx,u);
11125 line2[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11126 line2[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
11127 xx[2] = zaxis->GetXmax();
11128 view->WCtoNDC(xx,u);
11129 line2[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11130 line2[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
11132 xx[2] = zaxis->GetXmin();
11133 xx[1] = yaxis->GetBinCenter(biny+nbins-1);
11134 xx[0] = xaxis->GetBinCenter(binx+nbins-1);
11135 view->WCtoNDC(xx,u);
11136 line3[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11137 line3[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
11138 xx[2] = zaxis->GetXmax();
11139 view->WCtoNDC(xx,u);
11140 line3[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11141 line3[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
11143 xx[2] = zaxis->GetXmin();
11144 xx[1] = yaxis->GetBinCenter(biny);
11145 xx[0] = xaxis->GetBinCenter(binx+nbins-1);
11146 view->WCtoNDC(xx,u);
11147 line4[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11148 line4[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
11149 xx[2] = zaxis->GetXmax();
11150 view->WCtoNDC(xx,u);
11151 line4[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11152 line4[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
11154 endface1[0].SetX(line1[0].GetX());
11155 endface1[0].SetY(line1[0].GetY());
11156 endface1[1].SetX(line2[0].GetX());
11157 endface1[1].SetY(line2[0].GetY());
11158 endface1[2].SetX(line3[0].GetX());
11159 endface1[2].SetY(line3[0].GetY());
11160 endface1[3].SetX(line4[0].GetX());
11161 endface1[3].SetY(line4[0].GetY());
11162 endface1[4].SetX(line1[0].GetX());
11163 endface1[4].SetY(line1[0].GetY());
11165 endface2[0].SetX(line1[1].GetX());
11166 endface2[0].SetY(line1[1].GetY());
11167 endface2[1].SetX(line2[1].GetX());
11168 endface2[1].SetY(line2[1].GetY());
11169 endface2[2].SetX(line3[1].GetX());
11170 endface2[2].SetY(line3[1].GetY());
11171 endface2[3].SetX(line4[1].GetX());
11172 endface2[3].SetY(line4[1].GetY());
11173 endface2[4].SetX(line1[1].GetX());
11174 endface2[4].SetY(line1[1].GetY());
11176 gVirtualX->DrawPolyLine(2,line2);
11177 gVirtualX->DrawPolyLine(2,line3);
11178 gVirtualX->DrawPolyLine(2,line4);
11179 gVirtualX->DrawPolyLine(5,endface1);
11180 gVirtualX->DrawPolyLine(5,endface2);
11184 TH1 *hp = h3->Project3D(
"z");
11185 xaxis->SetRange(firstX,lastX);
11186 yaxis->SetRange(firstY,lastY);
11188 hp->SetFillColor(38);
11190 hp->SetTitle(TString::Format(
"ProjectionZ of binx=%d [x=%.1f..%.1f] biny=%d [y=%.1f..%.1f]", binx, xaxis->GetBinLowEdge(binx), xaxis->GetBinUpEdge(binx),
11191 biny, yaxis->GetBinLowEdge(biny), yaxis->GetBinUpEdge(biny)));
11193 hp->SetTitle(TString::Format(
"ProjectionZ, binx=[%d,%d] [x=%.1f..%.1f], biny=[%d,%d] [y=%.1f..%.1f]", binx, binx2, xaxis->GetBinLowEdge(binx), xaxis->GetBinUpEdge(binx2),
11194 biny, biny2, yaxis->GetBinLowEdge(biny), yaxis->GetBinUpEdge(biny2) ) );
11195 hp->SetXTitle(fH->GetZaxis()->GetTitle());
11196 hp->SetYTitle(
"Number of Entries");
11197 hp->Draw(fShowOption.Data());
11205 Int_t first = zaxis->GetFirst();
11206 Int_t last = zaxis->GetLast();
11207 Int_t binz = first + Int_t((last-first)*(py-pymin)/(pymax-pymin));
11208 Int_t binz2 = TMath::Min(binz+nbins-1,zaxis->GetNbins() );
11209 zaxis->SetRange(binz,binz2);
11210 if (rect1[0].GetX()) gVirtualX->DrawPolyLine(5,rect1);
11211 if (nbins>1 && rect2[0].GetX()) gVirtualX->DrawPolyLine(5,rect2);
11212 xx[0] = xaxis->GetXmin();
11213 xx[1] = yaxis->GetXmax();
11214 xx[2] = zaxis->GetBinCenter(binz);
11215 view->WCtoNDC(xx,u);
11216 rect1[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11217 rect1[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
11218 rect1[4].SetX(rect1[0].GetX());
11219 rect1[4].SetY(rect1[0].GetY());
11220 xx[0] = xaxis->GetXmax();
11221 view->WCtoNDC(xx,u);
11222 rect1[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11223 rect1[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
11224 xx[1] = yaxis->GetXmin();
11225 view->WCtoNDC(xx,u);
11226 rect1[2].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11227 rect1[2].SetY(pymin + Int_t((u[1]-uymin)*cy));
11228 xx[0] = xaxis->GetXmin();
11229 view->WCtoNDC(xx,u);
11230 rect1[3].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11231 rect1[3].SetY(pymin + Int_t((u[1]-uymin)*cy));
11232 gVirtualX->DrawPolyLine(5,rect1);
11234 xx[0] = xaxis->GetXmin();
11235 xx[1] = yaxis->GetXmax();
11236 xx[2] = zaxis->GetBinCenter(binz+nbins-1);
11237 view->WCtoNDC(xx,u);
11238 rect2[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11239 rect2[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
11240 rect2[4].SetX(rect2[0].GetX());
11241 rect2[4].SetY(rect2[0].GetY());
11242 xx[0] = xaxis->GetXmax();
11243 view->WCtoNDC(xx,u);
11244 rect2[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11245 rect2[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
11246 xx[1] = yaxis->GetXmin();
11247 view->WCtoNDC(xx,u);
11248 rect2[2].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11249 rect2[2].SetY(pymin + Int_t((u[1]-uymin)*cy));
11250 xx[0] = xaxis->GetXmin();
11251 view->WCtoNDC(xx,u);
11252 rect2[3].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11253 rect2[3].SetY(pymin + Int_t((u[1]-uymin)*cy));
11254 gVirtualX->DrawPolyLine(5,rect2);
11259 TH2 *hp = (TH2*)h3->Project3D(
"xy");
11260 zaxis->SetRange(first,last);
11262 hp->SetFillColor(38);
11263 if (nbins==1)hp->SetTitle(TString::Format(
"ProjectionXY of binz=%d [z=%.1f..%.f]", binz,zaxis->GetBinLowEdge(binz),zaxis->GetBinUpEdge(binz)));
11264 else hp->SetTitle(TString::Format(
"ProjectionXY, binz=[%d,%d] [z=%.1f..%.1f]", binz,binz2,zaxis->GetBinLowEdge(binz),zaxis->GetBinUpEdge(binz2)));
11265 hp->SetXTitle(fH->GetYaxis()->GetTitle());
11266 hp->SetYTitle(fH->GetXaxis()->GetTitle());
11267 hp->SetZTitle(
"Number of Entries");
11268 hp->Draw(fShowOption.Data());
11276 Int_t first = zaxis->GetFirst();
11277 Int_t last = zaxis->GetLast();
11278 Int_t binz = first + Int_t((last-first)*(py-pymin)/(pymax-pymin));
11279 Int_t binz2 = TMath::Min(binz+nbins-1,zaxis->GetNbins() );
11280 zaxis->SetRange(binz,binz2);
11281 if (rect1[0].GetX()) gVirtualX->DrawPolyLine(5,rect1);
11282 if (nbins>1 && rect2[0].GetX()) gVirtualX->DrawPolyLine(5,rect2);
11283 xx[0] = xaxis->GetXmin();
11284 xx[1] = yaxis->GetXmax();
11285 xx[2] = zaxis->GetBinCenter(binz);
11286 view->WCtoNDC(xx,u);
11287 rect1[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11288 rect1[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
11289 rect1[4].SetX(rect1[0].GetX());
11290 rect1[4].SetY(rect1[0].GetY());
11291 xx[0] = xaxis->GetXmax();
11292 view->WCtoNDC(xx,u);
11293 rect1[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11294 rect1[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
11295 xx[1] = yaxis->GetXmin();
11296 view->WCtoNDC(xx,u);
11297 rect1[2].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11298 rect1[2].SetY(pymin + Int_t((u[1]-uymin)*cy));
11299 xx[0] = xaxis->GetXmin();
11300 view->WCtoNDC(xx,u);
11301 rect1[3].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11302 rect1[3].SetY(pymin + Int_t((u[1]-uymin)*cy));
11303 gVirtualX->DrawPolyLine(5,rect1);
11305 xx[0] = xaxis->GetXmin();
11306 xx[1] = yaxis->GetXmax();
11307 xx[2] = zaxis->GetBinCenter(binz+nbins-1);
11308 view->WCtoNDC(xx,u);
11309 rect2[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11310 rect2[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
11311 rect2[4].SetX(rect2[0].GetX());
11312 rect2[4].SetY(rect2[0].GetY());
11313 xx[0] = xaxis->GetXmax();
11314 view->WCtoNDC(xx,u);
11315 rect2[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11316 rect2[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
11317 xx[1] = yaxis->GetXmin();
11318 view->WCtoNDC(xx,u);
11319 rect2[2].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11320 rect2[2].SetY(pymin + Int_t((u[1]-uymin)*cy));
11321 xx[0] = xaxis->GetXmin();
11322 view->WCtoNDC(xx,u);
11323 rect2[3].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11324 rect2[3].SetY(pymin + Int_t((u[1]-uymin)*cy));
11325 gVirtualX->DrawPolyLine(5,rect2);
11329 TH2 *hp = (TH2*)h3->Project3D(
"yx");
11330 zaxis->SetRange(first,last);
11332 hp->SetFillColor(38);
11333 if (nbins==1)hp->SetTitle(TString::Format(
"ProjectionYX of binz=%d [z=%.1f..%.f]", binz,zaxis->GetBinLowEdge(binz),zaxis->GetBinUpEdge(binz)));
11334 else hp->SetTitle(TString::Format(
"ProjectionYX, binz=[%d,%d] [z=%.1f..%.1f]", binz,binz2,zaxis->GetBinLowEdge(binz),zaxis->GetBinUpEdge(binz2)));
11335 hp->SetXTitle(fH->GetXaxis()->GetTitle());
11336 hp->SetYTitle(fH->GetYaxis()->GetTitle());
11337 hp->SetZTitle(
"Number of Entries");
11338 hp->Draw(fShowOption.Data());
11346 Int_t first = yaxis->GetFirst();
11347 Int_t last = yaxis->GetLast();
11348 Int_t biny = first + Int_t((last-first)*(py-pymin)/(pymax-pymin));
11349 Int_t biny2 = TMath::Min(biny+nbins-1,yaxis->GetNbins() );
11350 yaxis->SetRange(biny,biny2);
11351 if (rect1[0].GetX()) gVirtualX->DrawPolyLine(5,rect1);
11352 if (nbins>1 && rect1[0].GetX()) gVirtualX->DrawPolyLine(5,rect2);
11353 xx[0] = xaxis->GetXmin();
11354 xx[2] = zaxis->GetXmax();
11355 xx[1] = yaxis->GetBinCenter(biny);
11356 view->WCtoNDC(xx,u);
11357 rect1[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11358 rect1[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
11359 rect1[4].SetX(rect1[0].GetX());
11360 rect1[4].SetY(rect1[0].GetY());
11361 xx[0] = xaxis->GetXmax();
11362 view->WCtoNDC(xx,u);
11363 rect1[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11364 rect1[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
11365 xx[2] = zaxis->GetXmin();
11366 view->WCtoNDC(xx,u);
11367 rect1[2].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11368 rect1[2].SetY(pymin + Int_t((u[1]-uymin)*cy));
11369 xx[0] = xaxis->GetXmin();
11370 view->WCtoNDC(xx,u);
11371 rect1[3].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11372 rect1[3].SetY(pymin + Int_t((u[1]-uymin)*cy));
11373 gVirtualX->DrawPolyLine(5,rect1);
11375 xx[0] = xaxis->GetXmin();
11376 xx[2] = zaxis->GetXmax();
11377 xx[1] = yaxis->GetBinCenter(biny+nbins-1);
11378 view->WCtoNDC(xx,u);
11379 rect2[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11380 rect2[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
11381 rect2[4].SetX(rect2[0].GetX());
11382 rect2[4].SetY(rect2[0].GetY());
11383 xx[0] = xaxis->GetXmax();
11384 view->WCtoNDC(xx,u);
11385 rect2[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11386 rect2[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
11387 xx[2] = zaxis->GetXmin();
11388 view->WCtoNDC(xx,u);
11389 rect2[2].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11390 rect2[2].SetY(pymin + Int_t((u[1]-uymin)*cy));
11391 xx[0] = xaxis->GetXmin();
11392 view->WCtoNDC(xx,u);
11393 rect2[3].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11394 rect2[3].SetY(pymin + Int_t((u[1]-uymin)*cy));
11395 gVirtualX->DrawPolyLine(5,rect2);
11399 TH2 *hp = (TH2*)h3->Project3D(
"xz");
11400 yaxis->SetRange(first,last);
11402 hp->SetFillColor(38);
11403 if (nbins==1)hp->SetTitle(TString::Format(
"ProjectionXZ of biny=%d [y=%.1f..%.f]", biny,yaxis->GetBinLowEdge(biny),yaxis->GetBinUpEdge(biny)));
11404 else hp->SetTitle(TString::Format(
"ProjectionXZ, biny=[%d,%d] [y=%.1f..%.1f]", biny,biny2,yaxis->GetBinLowEdge(biny),yaxis->GetBinUpEdge(biny2)));
11405 hp->SetXTitle(fH->GetZaxis()->GetTitle());
11406 hp->SetYTitle(fH->GetXaxis()->GetTitle());
11407 hp->SetZTitle(
"Number of Entries");
11408 hp->Draw(fShowOption.Data());
11416 Int_t first = yaxis->GetFirst();
11417 Int_t last = yaxis->GetLast();
11418 Int_t biny = first + Int_t((last-first)*(py-pymin)/(pymax-pymin));
11419 Int_t biny2 = TMath::Min(biny+nbins-1,yaxis->GetNbins() );
11420 yaxis->SetRange(biny,biny2);
11421 if (rect1[0].GetX()) gVirtualX->DrawPolyLine(5,rect1);
11422 if (nbins>1 && rect1[0].GetX()) gVirtualX->DrawPolyLine(5,rect2);
11423 xx[0] = xaxis->GetXmin();
11424 xx[2] = zaxis->GetXmax();
11425 xx[1] = yaxis->GetBinCenter(biny);
11426 view->WCtoNDC(xx,u);
11427 rect1[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11428 rect1[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
11429 rect1[4].SetX(rect1[0].GetX());
11430 rect1[4].SetY(rect1[0].GetY());
11431 xx[0] = xaxis->GetXmax();
11432 view->WCtoNDC(xx,u);
11433 rect1[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11434 rect1[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
11435 xx[2] = zaxis->GetXmin();
11436 view->WCtoNDC(xx,u);
11437 rect1[2].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11438 rect1[2].SetY(pymin + Int_t((u[1]-uymin)*cy));
11439 xx[0] = xaxis->GetXmin();
11440 view->WCtoNDC(xx,u);
11441 rect1[3].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11442 rect1[3].SetY(pymin + Int_t((u[1]-uymin)*cy));
11443 gVirtualX->DrawPolyLine(5,rect1);
11445 xx[0] = xaxis->GetXmin();
11446 xx[2] = zaxis->GetXmax();
11447 xx[1] = yaxis->GetBinCenter(biny+nbins-1);
11448 view->WCtoNDC(xx,u);
11449 rect2[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11450 rect2[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
11451 rect2[4].SetX(rect2[0].GetX());
11452 rect2[4].SetY(rect2[0].GetY());
11453 xx[0] = xaxis->GetXmax();
11454 view->WCtoNDC(xx,u);
11455 rect2[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11456 rect2[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
11457 xx[2] = zaxis->GetXmin();
11458 view->WCtoNDC(xx,u);
11459 rect2[2].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11460 rect2[2].SetY(pymin + Int_t((u[1]-uymin)*cy));
11461 xx[0] = xaxis->GetXmin();
11462 view->WCtoNDC(xx,u);
11463 rect2[3].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11464 rect2[3].SetY(pymin + Int_t((u[1]-uymin)*cy));
11465 gVirtualX->DrawPolyLine(5,rect2);
11469 TH2 *hp = (TH2*)h3->Project3D(
"zx");
11470 yaxis->SetRange(first,last);
11472 hp->SetFillColor(38);
11473 if (nbins==1)hp->SetTitle(TString::Format(
"ProjectionZX of biny=%d [y=%.1f..%.f]", biny,yaxis->GetBinLowEdge(biny),yaxis->GetBinUpEdge(biny)));
11474 else hp->SetTitle(TString::Format(
"ProjectionZX, biny=[%d,%d] [y=%.1f..%.1f]", biny,biny2,yaxis->GetBinLowEdge(biny),yaxis->GetBinUpEdge(biny2)));
11475 hp->SetXTitle(fH->GetXaxis()->GetTitle());
11476 hp->SetYTitle(fH->GetZaxis()->GetTitle());
11477 hp->SetZTitle(
"Number of Entries");
11478 hp->Draw(fShowOption.Data());
11486 Int_t first = xaxis->GetFirst();
11487 Int_t last = xaxis->GetLast();
11488 Int_t binx = first + Int_t((last-first)*(px-pxmin)/(pxmax-pxmin));
11489 Int_t binx2 = TMath::Min(binx+nbins-1,xaxis->GetNbins() );
11490 xaxis->SetRange(binx,binx2);
11491 if (rect1[0].GetX()) gVirtualX->DrawPolyLine(5,rect1);
11492 if (nbins>1 && rect1[0].GetX()) gVirtualX->DrawPolyLine(5,rect2);
11493 xx[2] = zaxis->GetXmin();
11494 xx[1] = yaxis->GetXmax();
11495 xx[0] = xaxis->GetBinCenter(binx);
11496 view->WCtoNDC(xx,u);
11497 rect1[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11498 rect1[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
11499 rect1[4].SetX(rect1[0].GetX());
11500 rect1[4].SetY(rect1[0].GetY());
11501 xx[2] = zaxis->GetXmax();
11502 view->WCtoNDC(xx,u);
11503 rect1[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11504 rect1[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
11505 xx[1] = yaxis->GetXmin();
11506 view->WCtoNDC(xx,u);
11507 rect1[2].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11508 rect1[2].SetY(pymin + Int_t((u[1]-uymin)*cy));
11509 xx[2] = zaxis->GetXmin();
11510 view->WCtoNDC(xx,u);
11511 rect1[3].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11512 rect1[3].SetY(pymin + Int_t((u[1]-uymin)*cy));
11513 gVirtualX->DrawPolyLine(5,rect1);
11515 xx[2] = zaxis->GetXmin();
11516 xx[1] = yaxis->GetXmax();
11517 xx[0] = xaxis->GetBinCenter(binx+nbins-1);
11518 view->WCtoNDC(xx,u);
11519 rect2[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11520 rect2[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
11521 rect2[4].SetX(rect2[0].GetX());
11522 rect2[4].SetY(rect2[0].GetY());
11523 xx[2] = zaxis->GetXmax();
11524 view->WCtoNDC(xx,u);
11525 rect2[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11526 rect2[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
11527 xx[1] = yaxis->GetXmin();
11528 view->WCtoNDC(xx,u);
11529 rect2[2].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11530 rect2[2].SetY(pymin + Int_t((u[1]-uymin)*cy));
11531 xx[2] = zaxis->GetXmin();
11532 view->WCtoNDC(xx,u);
11533 rect2[3].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11534 rect2[3].SetY(pymin + Int_t((u[1]-uymin)*cy));
11535 gVirtualX->DrawPolyLine(5,rect2);
11539 TH2 *hp = (TH2*)h3->Project3D(
"yz");
11540 xaxis->SetRange(first,last);
11542 hp->SetFillColor(38);
11543 if (nbins==1)hp->SetTitle(TString::Format(
"ProjectionYZ of binx=%d [x=%.1f..%.f]", binx,xaxis->GetBinLowEdge(binx),xaxis->GetBinUpEdge(binx)));
11544 else hp->SetTitle(TString::Format(
"ProjectionYZ, binx=[%d,%d] [x=%.1f..%.1f]", binx,binx2,xaxis->GetBinLowEdge(binx),xaxis->GetBinUpEdge(binx2)));
11545 hp->SetXTitle(fH->GetZaxis()->GetTitle());
11546 hp->SetYTitle(fH->GetYaxis()->GetTitle());
11547 hp->SetZTitle(
"Number of Entries");
11548 hp->Draw(fShowOption.Data());
11556 Int_t first = xaxis->GetFirst();
11557 Int_t last = xaxis->GetLast();
11558 Int_t binx = first + Int_t((last-first)*(px-pxmin)/(pxmax-pxmin));
11559 Int_t binx2 = TMath::Min(binx+nbins-1,xaxis->GetNbins() );
11560 xaxis->SetRange(binx,binx2);
11561 if (rect1[0].GetX()) gVirtualX->DrawPolyLine(5,rect1);
11562 if (nbins>1 && rect1[0].GetX()) gVirtualX->DrawPolyLine(5,rect2);
11563 xx[2] = zaxis->GetXmin();
11564 xx[1] = yaxis->GetXmax();
11565 xx[0] = xaxis->GetBinCenter(binx);
11566 view->WCtoNDC(xx,u);
11567 rect1[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11568 rect1[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
11569 rect1[4].SetX(rect1[0].GetX());
11570 rect1[4].SetY(rect1[0].GetY());
11571 xx[2] = zaxis->GetXmax();
11572 view->WCtoNDC(xx,u);
11573 rect1[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11574 rect1[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
11575 xx[1] = yaxis->GetXmin();
11576 view->WCtoNDC(xx,u);
11577 rect1[2].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11578 rect1[2].SetY(pymin + Int_t((u[1]-uymin)*cy));
11579 xx[2] = zaxis->GetXmin();
11580 view->WCtoNDC(xx,u);
11581 rect1[3].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11582 rect1[3].SetY(pymin + Int_t((u[1]-uymin)*cy));
11583 gVirtualX->DrawPolyLine(5,rect1);
11585 xx[2] = zaxis->GetXmin();
11586 xx[1] = yaxis->GetXmax();
11587 xx[0] = xaxis->GetBinCenter(binx+nbins-1);
11588 view->WCtoNDC(xx,u);
11589 rect2[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11590 rect2[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
11591 rect2[4].SetX(rect2[0].GetX());
11592 rect2[4].SetY(rect2[0].GetY());
11593 xx[2] = zaxis->GetXmax();
11594 view->WCtoNDC(xx,u);
11595 rect2[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11596 rect2[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
11597 xx[1] = yaxis->GetXmin();
11598 view->WCtoNDC(xx,u);
11599 rect2[2].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11600 rect2[2].SetY(pymin + Int_t((u[1]-uymin)*cy));
11601 xx[2] = zaxis->GetXmin();
11602 view->WCtoNDC(xx,u);
11603 rect2[3].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
11604 rect2[3].SetY(pymin + Int_t((u[1]-uymin)*cy));
11605 gVirtualX->DrawPolyLine(5,rect2);
11609 TH2 *hp = (TH2*)h3->Project3D(
"zy");
11610 xaxis->SetRange(first,last);
11612 hp->SetFillColor(38);
11613 if (nbins==1)hp->SetTitle(TString::Format(
"ProjectionZY of binx=%d [x=%.1f..%.f]", binx,xaxis->GetBinLowEdge(binx),xaxis->GetBinUpEdge(binx)));
11614 else hp->SetTitle(TString::Format(
"ProjectionZY, binx=[%d,%d] [x=%.1f..%.1f]", binx,binx2,xaxis->GetBinLowEdge(binx),xaxis->GetBinUpEdge(binx2)));
11615 hp->SetXTitle(fH->GetYaxis()->GetTitle());
11616 hp->SetYTitle(fH->GetZaxis()->GetTitle());
11617 hp->SetZTitle(
"Number of Entries");
11618 hp->Draw(fShowOption.Data());