diff --git a/src/classes/PRunSingleHistoRRF.cpp b/src/classes/PRunSingleHistoRRF.cpp index 856935af..60f69ca7 100644 --- a/src/classes/PRunSingleHistoRRF.cpp +++ b/src/classes/PRunSingleHistoRRF.cpp @@ -563,11 +563,13 @@ Bool_t PRunSingleHistoRRF::PrepareData() Bool_t PRunSingleHistoRRF::PrepareFitData(PRawRunData* runData, const UInt_t histoNo) { // keep the raw data for the RRF asymmetry error estimate for later - PDoubleVector sqrtNt; + PDoubleVector rawNt; for (UInt_t i=0; iGetBkgFitParamNo() == -1) { // bkg shall **NOT** be fitted // subtract background from histogramms ------------------------------------------ @@ -589,8 +591,10 @@ Bool_t PRunSingleHistoRRF::PrepareFitData(PRawRunData* runData, const UInt_t his for (UInt_t i=0; iGetBkgFix(0); } + fBackground = fRunInfo->GetBkgFix(0); } } + // here fForward = N(t) - Nbkg Int_t t0 = (Int_t)fT0s[0]; @@ -601,20 +605,40 @@ Bool_t PRunSingleHistoRRF::PrepareFitData(PRawRunData* runData, const UInt_t his cout << endl << "debug> PRunSingleHistoRRF::PrepareFitData(): endTime =" << startTime+fTimeResolution*((Double_t)fGoodBins[1]-(Double_t)t0) << endl; Double_t time_tau=0.0; + Double_t exp_t_tau=0.0; for (Int_t i=fGoodBins[0]; i 0.0) + fW.push_back(1.0/(fMerr[i]*fMerr[i])); + else + fW.push_back(0.0); + } + // now fForward = exp(+t/tau) [N(t)-Nbkg] = M(t) // 3) estimate N0 - Double_t n0 = EstimateN0(); + Double_t errN0 = 0.0; + Double_t n0 = EstimateN0(errN0); - // 4) A(t) = exp(+t/tau) [N(t)-Nbkg] / N0 - 1.0 + // 4a) A(t) = exp(+t/tau) [N(t)-Nbkg] / N0 - 1.0 for (Int_t i=fGoodBins[0]; i A(t) * cos(wRRF t + phiRRF) + // 4b) error estimate of A(t): errA(t) = exp(+t/tau)/N0 sqrt( N(t) + ([N(t)-N_bkg]/N0)^2 errN0^2 ) + for (Int_t i=fGoodBins[0]; i 2* A(t) * cos(wRRF t + phiRRF), the factor 2.0 is needed since the high frequency part is suppressed. PMsrGlobalBlock *globalBlock = fMsrInfo->GetMsrGlobal(); Double_t wRRF = globalBlock->GetRRFFreq("Mc"); Double_t phaseRRF = globalBlock->GetRRFPhase()*TMath::TwoPi()/180.0; @@ -623,7 +647,7 @@ Bool_t PRunSingleHistoRRF::PrepareFitData(PRawRunData* runData, const UInt_t his Double_t time = 0.0; for (Int_t i=fGoodBins[0]; iEstimate the N0 for the given run. + * + * \param sqrtNt + * \param errN0 */ -Double_t PRunSingleHistoRRF::EstimateN0() +Double_t PRunSingleHistoRRF::EstimateN0(Double_t &errN0) { - Int_t endBin = N0EstimateEndTime / fTimeResolution; + Int_t endBin = N0EstimateEndTime / fTimeResolution - fGoodBins[0]; Double_t n0 = 0.0; - cout << "debug> PRunSingleHistoRRF::EstimateN0(): startBin=" << fGoodBins[0] << ", endBin=" << endBin << endl; - for (Int_t i=fGoodBins[0]; i PRunSingleHistoRRF::EstimateN0(): endBin=" << endBin << endl; + for (Int_t i=0; i PRunSingleHistoRRF::EstimateN0(): N0=" << n0 << endl; + n0 /= wN; + + errN0 = 0.0; + for (Int_t i=0; i PRunSingleHistoRRF::EstimateN0(): N0=" << n0 << "(" << errN0 << ")" << endl; return n0; } @@ -1475,7 +1507,9 @@ Bool_t PRunSingleHistoRRF::EstimateBkg(UInt_t histoNo) bkg += fForward[i]; bkg /= static_cast(end - start + 1); - fBackground = bkg * fPacking; // keep background (per bin) + fBackground = bkg; // keep background (per bin) + + cout << endl << "debug> fBackground=" << fBackground << endl; fRunInfo->SetBkgEstimated(fBackground, 0); diff --git a/src/include/PRunSingleHistoRRF.h b/src/include/PRunSingleHistoRRF.h index 17980533..0f60d6c7 100644 --- a/src/include/PRunSingleHistoRRF.h +++ b/src/include/PRunSingleHistoRRF.h @@ -65,14 +65,18 @@ class PRunSingleHistoRRF : public PRunBase Double_t fBackground; ///< needed if background range is given (units: 1/bin) Int_t fPacking; ///< packing for this particular run. Either given in the RUN- or GLOBAL-block. - Int_t fGoodBins[2]; ///< keep first/last good bins. 0=fgb, 1=lgb + Int_t fGoodBins[2]; ///< keep first/last good bins. 0=fgb, 1=lgb - PDoubleVector fForward; ///< forward histo data + PDoubleVector fForward; ///< forward histo data + PDoubleVector fM; ///< vector holding M(t) = [N(t)-N_bkg] exp(+t/tau). Needed to estimate N0. + PDoubleVector fMerr; ///< vector holding the error of M(t): M_err = exp(+t/tau) sqrt(N(t)). + PDoubleVector fW; ///< vector holding the weight needed to estimate N0, and errN0. + PDoubleVector fAerr; ///< vector holding the errors of estimated A(t) virtual Bool_t GetProperT0(PRawRunData* runData, PMsrGlobalBlock *globalBlock, PUIntVector &histoNo); virtual Bool_t GetProperDataRange(); virtual void GetProperFitRange(PMsrGlobalBlock *globalBlock); - virtual Double_t EstimateN0(); + virtual Double_t EstimateN0(Double_t &errN0); virtual Bool_t EstimateBkg(UInt_t histoNo); };