|
50 | 50 | #include <cstring> |
51 | 51 | #include <stdexcept> |
52 | 52 | #include <string> |
| 53 | +#include <vector> |
53 | 54 |
|
54 | 55 | using namespace RooFit; |
55 | 56 |
|
@@ -564,65 +565,80 @@ void HFInvMassFitter::fillWorkspace(RooWorkspace& workspace) const |
564 | 565 | } |
565 | 566 |
|
566 | 567 | // draw fit output |
567 | | -void HFInvMassFitter::drawFit(TVirtualPad* pad, Int_t writeFitInfo) |
| 568 | +void HFInvMassFitter::drawFit(TVirtualPad* pad, const std::vector<std::string>& plotLabels, Bool_t writeParInfo) |
568 | 569 | { |
569 | 570 | gStyle->SetOptStat(0); |
570 | 571 | gStyle->SetCanvasColor(0); |
571 | 572 | gStyle->SetFrameFillColor(0); |
572 | 573 | pad->cd(); |
573 | | - if (writeFitInfo > 0) { |
574 | | - auto* textInfoLeft = new TPaveText(0.12, 0.65, 0.47, 0.89, "NDC"); |
575 | | - auto* textInfoRight = new TPaveText(0.6, 0.7, 1., .87, "NDC"); |
576 | | - textInfoLeft->SetBorderSize(0); |
577 | | - textInfoLeft->SetFillStyle(0); |
578 | | - textInfoRight->SetBorderSize(0); |
579 | | - textInfoRight->SetFillStyle(0); |
580 | | - textInfoRight->SetTextColor(kBlue); |
581 | | - textInfoLeft->AddText(Form("S = %.0f #pm %.0f ", mRawYield, mRawYieldErr)); |
582 | | - textInfoLeft->AddText(Form("S_{count} = %.0f #pm %.0f ", mRawYieldCounted, mRawYieldCountedErr)); |
583 | | - if (mTypeOfBkgPdf != NoBkg) { |
584 | | - textInfoLeft->AddText(Form("B (%d#sigma) = %.0f #pm %.0f", mNSigmaForSidebands, mBkgYield, mBkgYieldErr)); |
585 | | - textInfoLeft->AddText(Form("S/B (%d#sigma) = %.4g ", mNSigmaForSidebands, mRawYield / mBkgYield)); |
586 | | - } |
587 | | - if (mReflPdf != nullptr) { |
588 | | - textInfoLeft->AddText(Form("Refl/Sig = %.3f #pm %.3f ", mReflOverSgn, 0.0)); |
589 | | - } |
590 | | - if (mTypeOfBkgPdf != NoBkg) { |
591 | | - textInfoLeft->AddText(Form("Signif (%d#sigma) = %.1f #pm %.1f ", mNSigmaForSidebands, mSignificance, mSignificanceErr)); |
592 | | - textInfoLeft->AddText(Form("#chi^{2} / ndf = %.3f", mChiSquareOverNdfTotal)); |
593 | | - } |
| 574 | + // Fit metrics |
| 575 | + TPaveText* textFitMetrics = new TPaveText(0.65, 0.7, 0.9, 0.88, "NDC"); |
| 576 | + textFitMetrics->SetBorderSize(0); |
| 577 | + textFitMetrics->SetFillStyle(0); |
| 578 | + textFitMetrics->SetTextSize(0.04); |
| 579 | + textFitMetrics->SetTextAlign(33); |
| 580 | + textFitMetrics->AddText(Form("S = %.0f #pm %.0f ", mRawYield, mRawYieldErr)); |
| 581 | + if (mTypeOfBkgPdf != NoBkg) { |
| 582 | + textFitMetrics->AddText(Form("B (%d#sigma) = %.0f #pm %.0f", mNSigmaForSidebands, mBkgYield, mBkgYieldErr)); |
| 583 | + textFitMetrics->AddText(Form("S/B (%d#sigma) = %.4g ", mNSigmaForSidebands, mRawYield / mBkgYield)); |
| 584 | + } |
| 585 | + if (mReflPdf) { |
| 586 | + textFitMetrics->AddText(Form("Refl/Sig = %.3f #pm %.3f ", mReflOverSgn, 0.0)); |
| 587 | + } |
| 588 | + if (mTypeOfBkgPdf != NoBkg) { |
| 589 | + textFitMetrics->AddText(Form("Significance (%d#sigma) = %.1f #pm %.1f ", mNSigmaForSidebands, mSignificance, mSignificanceErr)); |
| 590 | + textFitMetrics->AddText(Form("#chi^{2} / ndf = %.3f", mChiSquareOverNdfTotal)); |
| 591 | + } |
| 592 | + mInvMassFrame->addObject(textFitMetrics); |
| 593 | + // Analysis information |
| 594 | + TPaveText* textAnalysisInfo = new TPaveText(0.18, 0.78, 0.35, 0.88, "NDC"); |
| 595 | + textAnalysisInfo->SetBorderSize(0); |
| 596 | + textAnalysisInfo->SetFillStyle(0); |
| 597 | + textAnalysisInfo->SetTextSize(0.05); |
| 598 | + textAnalysisInfo->SetTextAlign(13); |
| 599 | + for (const auto& label : plotLabels) { |
| 600 | + textAnalysisInfo->AddText(label.c_str()); |
| 601 | + } |
| 602 | + mInvMassFrame->addObject(textAnalysisInfo); |
| 603 | + if (writeParInfo) { |
| 604 | + // right text box |
| 605 | + TPaveText* textSignalPar = new TPaveText(0.18, 0.65, 0.4, 0.75, "NDC"); |
| 606 | + textSignalPar->SetBorderSize(0); |
| 607 | + textSignalPar->SetFillStyle(0); |
| 608 | + textSignalPar->SetTextColor(kBlue); |
| 609 | + textSignalPar->SetTextAlign(13); |
594 | 610 | if (mFixedMean) { |
595 | | - textInfoRight->AddText(Form("mean(fixed) = %.3f #pm %.3f", mRooMeanSgn->getVal(), mRooMeanSgn->getError())); |
| 611 | + textSignalPar->AddText(Form("mean(fixed) = %.3f #pm %.3f", mRooMeanSgn->getVal(), mRooMeanSgn->getError())); |
596 | 612 | } else { |
597 | | - textInfoRight->AddText(Form("mean(free) = %.3f #pm %.3f", mRooMeanSgn->getVal(), mRooMeanSgn->getError())); |
| 613 | + textSignalPar->AddText(Form("mean(free) = %.3f #pm %.3f", mRooMeanSgn->getVal(), mRooMeanSgn->getError())); |
598 | 614 | } |
599 | 615 | if (mTypeOfSgnPdf == DoubleGaus) { |
600 | 616 | if (mFixedSigma) { |
601 | | - textInfoRight->AddText(Form("sigma(fixed) = %.3f #pm %.3f", mRooSigmaSgn->getVal(), mRooSigmaSgn->getError())); |
| 617 | + textSignalPar->AddText(Form("sigma(fixed) = %.3f #pm %.3f", mRooSigmaSgn->getVal(), mRooSigmaSgn->getError())); |
602 | 618 | } else { |
603 | | - textInfoRight->AddText(Form("sigma(free) = %.3f #pm %.3f", mRooSigmaSgn->getVal(), mRooSigmaSgn->getError())); |
| 619 | + textSignalPar->AddText(Form("sigma(free) = %.3f #pm %.3f", mRooSigmaSgn->getVal(), mRooSigmaSgn->getError())); |
604 | 620 | } |
605 | 621 | if (mFixedSigmaDoubleGaus) { |
606 | | - textInfoRight->AddText(Form("sigma 2(fixed) = %.3f #pm %.3f", mRooSecSigmaSgn->getVal(), mRooSecSigmaSgn->getError())); |
| 622 | + textSignalPar->AddText(Form("sigma 2(fixed) = %.3f #pm %.3f", mRooSecSigmaSgn->getVal(), mRooSecSigmaSgn->getError())); |
607 | 623 | } else { |
608 | | - textInfoRight->AddText(Form("sigma 2(free) = %.3f #pm %.3f", mRooSecSigmaSgn->getVal(), mRooSecSigmaSgn->getError())); |
| 624 | + textSignalPar->AddText(Form("sigma 2(free) = %.3f #pm %.3f", mRooSecSigmaSgn->getVal(), mRooSecSigmaSgn->getError())); |
609 | 625 | } |
610 | 626 | } else if (mFixedSigma) { |
611 | | - textInfoRight->AddText(Form("sigma(fixed) = %.3f #pm %.3f", mRooSigmaSgn->getVal(), mRooSigmaSgn->getError())); |
| 627 | + textSignalPar->AddText(Form("sigma(fixed) = %.3f #pm %.3f", mRooSigmaSgn->getVal(), mRooSigmaSgn->getError())); |
612 | 628 | } else { |
613 | | - textInfoRight->AddText(Form("sigma(free) = %.3f #pm %.3f", mRooSigmaSgn->getVal(), mRooSigmaSgn->getError())); |
614 | | - } |
615 | | - mInvMassFrame->addObject(textInfoLeft); |
616 | | - mInvMassFrame->addObject(textInfoRight); |
617 | | - mInvMassFrame->GetYaxis()->SetTitleOffset(1.8); |
618 | | - gPad->SetLeftMargin(0.15); |
619 | | - mInvMassFrame->GetYaxis()->SetTitle(Form("%s", mHistoInvMass->GetYaxis()->GetTitle())); |
620 | | - mInvMassFrame->GetXaxis()->SetTitle(Form("%s", mHistoInvMass->GetXaxis()->GetTitle())); |
621 | | - mInvMassFrame->Draw(); |
622 | | - highlightPeakRegion(mInvMassFrame); |
623 | | - if (mHistoTemplateRefl != nullptr) { |
624 | | - mReflFrame->Draw("same"); |
| 629 | + textSignalPar->AddText(Form("sigma(free) = %.3f #pm %.3f", mRooSigmaSgn->getVal(), mRooSigmaSgn->getError())); |
625 | 630 | } |
| 631 | + mInvMassFrame->addObject(textSignalPar); |
| 632 | + } |
| 633 | + mInvMassFrame->GetXaxis()->SetTitleOffset(1.2); |
| 634 | + mInvMassFrame->GetYaxis()->SetTitleOffset(1.8); |
| 635 | + gPad->SetLeftMargin(0.15); |
| 636 | + mInvMassFrame->GetYaxis()->SetTitle(Form("%s", mHistoInvMass->GetYaxis()->GetTitle())); |
| 637 | + mInvMassFrame->GetXaxis()->SetTitle(Form("%s", mHistoInvMass->GetXaxis()->GetTitle())); |
| 638 | + mInvMassFrame->Draw(); |
| 639 | + highlightPeakRegion(mInvMassFrame); |
| 640 | + if (mHistoTemplateRefl) { |
| 641 | + mReflFrame->Draw("same"); |
626 | 642 | } |
627 | 643 | } |
628 | 644 |
|
|
0 commit comments