@@ -703,8 +703,10 @@ void HFInvMassFitter::drawReflection(TVirtualPad* pad)
703703// calculate signal yield via bin counting
704704void HFInvMassFitter::countSignal (double & signal, double & signalErr) const
705705{
706- const double binWidth = mResidualHist ->GetX ()[1 ] - mResidualHist ->GetX ()[0 ];
707- const double firstBinLowEdge = mResidualHist ->GetX ()[0 ] - binWidth / 2 ;
706+ const auto & histoForCounting = mTypeOfBkgPdf == NoBkg ? mInvMassFrame ->getHist (" data_c" ) : mResidualHist ;
707+
708+ const double binWidth = histoForCounting->GetX ()[1 ] - histoForCounting->GetX ()[0 ];
709+ const double firstBinLowEdge = histoForCounting->GetX ()[0 ] - binWidth / 2 ;
708710 const auto [minForSgn, maxForSgn] = getRangesOfSignal ();
709711 const int binForMinSgn = static_cast <int >((minForSgn - firstBinLowEdge) / binWidth) + 1 ;
710712 const int binForMaxSgn = static_cast <int >((maxForSgn - firstBinLowEdge) / binWidth) + 1 ;
@@ -716,14 +718,14 @@ void HFInvMassFitter::countSignal(double& signal, double& signalErr) const
716718 auto square = [](double value) { return value * value; };
717719
718720 double sumValues{}, sumErrorsSquare{};
719- sumValues += mResidualHist ->GetY ()[binForMinSgn - 1 ] * binForMinSgnFraction;
720- sumErrorsSquare += square (mResidualHist ->GetErrorY (binForMinSgn - 1 ) * binForMinSgnFraction);
721+ sumValues += histoForCounting ->GetY ()[binForMinSgn - 1 ] * binForMinSgnFraction;
722+ sumErrorsSquare += square (histoForCounting ->GetErrorY (binForMinSgn - 1 ) * binForMinSgnFraction);
721723 for (int iBin = binForMinSgn + 1 ; iBin <= binForMaxSgn - 1 ; iBin++) {
722- sumValues += mResidualHist ->GetY ()[iBin - 1 ];
723- sumErrorsSquare += square (mResidualHist ->GetErrorY (iBin - 1 ));
724+ sumValues += histoForCounting ->GetY ()[iBin - 1 ];
725+ sumErrorsSquare += square (histoForCounting ->GetErrorY (iBin - 1 ));
724726 }
725- sumValues += mResidualHist ->GetY ()[binForMaxSgn - 1 ] * binForMaxSgnFraction;
726- sumErrorsSquare += square (mResidualHist ->GetErrorY (binForMaxSgn - 1 ) * binForMaxSgnFraction);
727+ sumValues += histoForCounting ->GetY ()[binForMaxSgn - 1 ] * binForMaxSgnFraction;
728+ sumErrorsSquare += square (histoForCounting ->GetErrorY (binForMaxSgn - 1 ) * binForMaxSgnFraction);
727729
728730 signal = sumValues;
729731 signalErr = std::sqrt (sumErrorsSquare);
0 commit comments