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