49#include "PStringUtils.h"
141 std::cerr << std::endl <<
">> PRunSingleHistoRRF::PRunSingleHistoRRF(): **SEVERE ERROR**: no GLOBAL-block present!";
142 std::cerr << std::endl <<
">> For Single Histo RRF the GLOBAL-block is mandatory! Please fix this first.";
143 std::cerr << std::endl;
149 std::cerr << std::endl <<
">> PRunSingleHistoRRF::PRunSingleHistoRRF(): **SEVERE ERROR**: no RRF-Frequency found!";
150 std::cerr << std::endl;
157 std::cerr << std::endl <<
">> PRunSingleHistoRRF::PRunSingleHistoRRF(): **SEVERE ERROR**: no RRF-Packing found!";
158 std::cerr << std::endl;
171 std::cerr << std::endl <<
">> PRunSingleHistoRRF::PRunSingleHistoRRF(): **SEVERE ERROR**: Couldn't prepare data for fitting!";
172 std::cerr << std::endl <<
">> This is very bad :-(, will quit ...";
173 std::cerr << std::endl;
242 Double_t chisq = 0.0;
246 for (Int_t i=0; i<
fMsrInfo->GetNoOfFuncs(); i++) {
247 UInt_t funcNo =
fMsrInfo->GetFuncNo(i);
265 #pragma omp parallel for default(shared) private(i,time,diff) schedule(dynamic,chunk) reduction(+:chisq)
268 time =
fData.GetDataTimeStart() +
static_cast<Double_t
>(i)*
fData.GetDataTimeStep();
270 chisq += diff*diff / (
fData.GetError()->at(i)*
fData.GetError()->at(i));
309 Double_t chisq = 0.0;
314 for (Int_t i=0; i<
fMsrInfo->GetNoOfFuncs(); i++) {
315 UInt_t funcNo =
fMsrInfo->GetFuncNo(i);
333 #pragma omp parallel for default(shared) private(i,time,diff) schedule(dynamic,chunk) reduction(+:chisq)
336 time =
fData.GetDataTimeStart() +
static_cast<Double_t
>(i)*
fData.GetDataTimeStep();
338 diff =
fData.GetValue()->at(i) - theo;
339 chisq += diff*diff / theo;
427 std::vector<Double_t> par;
429 for (UInt_t i=0; i<paramList->size(); i++)
430 par.push_back((*paramList)[i].fValue);
433 for (Int_t i=0; i<
fMsrInfo->GetNoOfFuncs(); i++) {
438 UInt_t size =
fData.GetValue()->size();
439 Double_t start =
fData.GetDataTimeStart();
440 Double_t resolution =
fData.GetDataTimeStep();
442 for (UInt_t i=0; i<size; i++) {
443 time = start +
static_cast<Double_t
>(i)*resolution;
536 std::vector<std::string> tok = PStringUtils::Split(fitRange.Data(),
" \t");
538 if (tok.size() == 3) {
542 idx = str.First(
"+");
544 str.Remove(0, idx+1);
553 idx = str.First(
"-");
555 str.Remove(0, idx+1);
560 }
else if ((tok.size() > 3) && (tok.size() % 2 == 1)) {
561 UInt_t pos = 2*(
fRunNo+1)-1;
563 if (pos + 1 >= tok.size()) {
564 std::cerr << std::endl <<
">> PRunSingleHistoRRF::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange <<
"'";
565 std::cerr << std::endl <<
">> will ignore it. Sorry ..." << std::endl;
570 idx = str.First(
"+");
572 str.Remove(0, idx+1);
581 idx = str.First(
"-");
583 str.Remove(0, idx+1);
590 std::cerr << std::endl <<
">> PRunSingleHistoRRF::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange <<
"'";
591 std::cerr << std::endl <<
">> will ignore it. Sorry ..." << std::endl;
698 Bool_t success =
true;
709 std::cerr << std::endl <<
">> PRunSingleHistoRRF::PrepareData(): **ERROR** Couldn't get run " <<
fRunInfo->GetRunName()->Data() <<
"!";
710 std::cerr << std::endl;
726 for (UInt_t i=0; i<
fRunInfo->GetForwardHistoNoSize(); i++) {
727 histoNo.push_back(
fRunInfo->GetForwardHistoNo(i));
730 std::cerr << std::endl <<
">> PRunSingleHistoRRF::PrepareData(): **PANIC ERROR**:";
731 std::cerr << std::endl <<
">> histoNo found = " << histoNo[i] <<
", which is NOT present in the data file!?!?";
732 std::cerr << std::endl <<
">> Will quit :-(";
733 std::cerr << std::endl;
741 std::cout.precision(10);
742 std::cout << std::endl <<
">> PRunSingleHisto::PrepareData(): time resolution=" << std::fixed << runData->
GetTimeResolution() <<
"(ns)" << std::endl;
750 std::vector<PDoubleVector> forward;
751 forward.resize(histoNo.size());
752 for (UInt_t i=0; i<histoNo.size(); i++) {
753 forward[i].resize(runData->
GetDataBin(histoNo[i])->size());
754 forward[i] = *runData->
GetDataBin(histoNo[i]);
758 if (
fRunInfo->GetRunNameSize() > 1) {
760 std::vector<PDoubleVector> addForward;
761 for (UInt_t i=1; i<
fRunInfo->GetRunNameSize(); i++) {
765 if (addRunData ==
nullptr) {
766 std::cerr << std::endl <<
">> PRunSingleHistoRRF::PrepareData(): **ERROR** Couldn't get addrun " <<
fRunInfo->GetRunName(i)->Data() <<
"!";
767 std::cerr << std::endl;
772 addForward.resize(histoNo.size());
773 for (UInt_t j=0; j<histoNo.size(); j++) {
774 addForward[j].resize(addRunData->
GetDataBin(histoNo[j])->size());
775 addForward[j] = *addRunData->
GetDataBin(histoNo[j]);
781 for (UInt_t k=0; k<histoNo.size(); k++) {
782 addRunSize = addForward[k].size();
783 for (UInt_t j=0; j<addRunSize; j++) {
785 if ((
static_cast<Int_t
>(j)+
static_cast<Int_t
>(
fAddT0s[i-1][k])-
static_cast<Int_t
>(
fT0s[k]) >= 0) &&
786 (j+
static_cast<Int_t
>(
fAddT0s[i-1][k])-
static_cast<Int_t
>(
fT0s[k]) < addRunSize)) {
787 forward[k][j] += addForward[k][j+
static_cast<Int_t
>(
fAddT0s[i-1][k])-
static_cast<Int_t
>(
fT0s[k])];
796 for (UInt_t i=0; i<
fForward.size(); i++) {
801 for (UInt_t i=1; i<histoNo.size(); i++) {
802 for (UInt_t j=0; j<runData->
GetDataBin(histoNo[i])->size(); j++) {
804 if ((
static_cast<Int_t
>(j)+
static_cast<Int_t
>(
fT0s[i])-
static_cast<Int_t
>(
fT0s[0]) >= 0) &&
805 (j+
static_cast<Int_t
>(
fT0s[i])-
static_cast<Int_t
>(
fT0s[0]) < runData->
GetDataBin(histoNo[i])->size())) {
806 fForward[j] += forward[i][j+
static_cast<Int_t
>(
fT0s[i])-
static_cast<Int_t
>(
fT0s[0])];
909 for (UInt_t i=0; i<
fForward.size(); i++) {
913 std::cout <<
"info> freqMax=" << freqMax <<
" (MHz)" << std::endl;
916 Double_t optNoPoints = 8;
919 std::cout <<
"info> optimal packing: " <<
static_cast<Int_t
>(1.0 / (
fTimeResolution*(freqMax -
fMsrInfo->GetMsrGlobal()->GetRRFFreq(
"MHz"))) / optNoPoints);
926 if (
fRunInfo->GetBkgRange(0) >= 0) {
930 fRunInfo->SetBkgRange(
static_cast<Int_t
>(
fT0s[0]*0.1), 0);
931 fRunInfo->SetBkgRange(
static_cast<Int_t
>(
fT0s[0]*0.6), 1);
932 std::cerr << std::endl <<
">> PRunSingleHistoRRF::PrepareFitData(): **WARNING** Neither fix background nor background bins are given!";
933 std::cerr << std::endl <<
">> Will try the following: bkg start = " <<
fRunInfo->GetBkgRange(0) <<
", bkg end = " <<
fRunInfo->GetBkgRange(1);
934 std::cerr << std::endl <<
">> NO WARRANTY THAT THIS MAKES ANY SENSE! Better check ...";
935 std::cerr << std::endl;
940 for (UInt_t i=0; i<
fForward.size(); i++)
943 for (UInt_t i=0; i<
fForward.size(); i++) {
950 Int_t t0 =
static_cast<Int_t
>(
fT0s[0]);
955 Double_t time_tau=0.0;
956 Double_t exp_t_tau=0.0;
959 exp_t_tau = exp(time_tau);
966 for (UInt_t i=0; i<
fMerr.size(); i++) {
975 Double_t errN0 = 0.0;
986 exp_t_tau = exp(time_tau);
987 fAerr.push_back(exp_t_tau/n0*sqrt(rawNt[i]+pow(((rawNt[i]-
fBackground)/n0)*errN0,2.0)));
992 Double_t wRRF = globalBlock->
GetRRFFreq(
"Mc");
993 Double_t phaseRRF = globalBlock->
GetRRFPhase()*TMath::TwoPi()/180.0;
997 fForward[i] *= 2.0*cos(wRRF * time + phaseRRF);
1008 fData.AppendValue(dval);
1101 Int_t viewPacking =
fMsrInfo->GetMsrPlotList()->at(0).fViewPacking;
1102 if (viewPacking > 0) {
1104 std::cerr <<
">> PRunSingleHistoRRF::PrepareViewData(): **WARNING** Found View Packing (" << viewPacking <<
") < RRF Packing (" <<
fRRFPacking <<
").";
1105 std::cerr <<
">> Will ignore View Packing." << std::endl;
1116 std::vector<Double_t> par;
1118 for (UInt_t i=0; i<paramList->size(); i++)
1119 par.push_back((*paramList)[i].fValue);
1122 for (Int_t i=0; i<
fMsrInfo->GetNoOfFuncs(); i++) {
1129 fData.SetTheoryTimeStart(
fData.GetDataTimeStart());
1131 fData.SetTheoryTimeStep(
fData.GetDataTimeStep());
1135 fData.SetTheoryTimeStep(
fData.GetDataTimeStep()/(Double_t)factor);
1139 Double_t time = 0.0;
1140 Double_t theoryValue = 0.0;
1141 for (UInt_t i=0; i<size; i++) {
1142 time =
fData.GetTheoryTimeStart() +
static_cast<Double_t
>(i)*
fData.GetTheoryTimeStep();
1144 if (fabs(theoryValue) > 10.0) {
1147 fData.AppendTheoryValue(theoryValue);
1209 fT0s.resize(histoNo.size());
1210 for (UInt_t i=0; i<
fT0s.size(); i++) {
1215 for (UInt_t i=0; i<
fRunInfo->GetT0BinSize(); i++) {
1221 if (
fT0s[i] == -1.0) {
1227 for (UInt_t i=0; i<histoNo.size(); i++) {
1228 if (
fT0s[i] == -1.0) {
1229 if (runData->
GetT0Bin(histoNo[i]) > 0.0) {
1237 for (UInt_t i=0; i<histoNo.size(); i++) {
1238 if (
fT0s[i] == -1.0) {
1242 std::cerr << std::endl <<
">> PRunSingleHistoRRF::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!";
1243 std::cerr << std::endl <<
">> run: " <<
fRunInfo->GetRunName()->Data();
1244 std::cerr << std::endl <<
">> will try the estimated one: forward t0 = " << runData->
GetT0BinEstimated(histoNo[i]);
1245 std::cerr << std::endl <<
">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!";
1246 std::cerr << std::endl;
1251 for (UInt_t i=0; i<
fRunInfo->GetForwardHistoNoSize(); i++) {
1252 if ((
fT0s[i] < 0.0) || (
fT0s[i] >
static_cast<Int_t
>(runData->
GetDataBin(histoNo[i])->size()))) {
1253 std::cerr << std::endl <<
">> PRunSingleHistoRRF::GetProperT0(): **ERROR** t0 data bin (" <<
fT0s[i] <<
") doesn't make any sense!";
1254 std::cerr << std::endl;
1260 if (
fRunInfo->GetRunNameSize() > 1) {
1263 for (UInt_t i=1; i<
fRunInfo->GetRunNameSize(); i++) {
1267 if (addRunData ==
nullptr) {
1268 std::cerr << std::endl <<
">> PRunSingleHistoRRF::GetProperT0(): **ERROR** Couldn't get addrun " <<
fRunInfo->GetRunName(i)->Data() <<
"!";
1269 std::cerr << std::endl;
1275 fAddT0s[i-1].resize(histoNo.size());
1276 for (UInt_t j=0; j<
fAddT0s[i-1].size(); j++) {
1281 for (UInt_t j=0; j<
fRunInfo->GetT0BinSize(); j++) {
1286 for (UInt_t j=0; j<histoNo.size(); j++) {
1288 if (addRunData->
GetT0Bin(histoNo[j]) > 0.0) {
1295 for (UInt_t j=0; j<histoNo.size(); j++) {
1296 if (
fAddT0s[i-1][j] == -1.0) {
1300 std::cerr << std::endl <<
">> PRunSingleHistoRRF::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!";
1301 std::cerr << std::endl <<
">> run: " <<
fRunInfo->GetRunName(i)->Data();
1302 std::cerr << std::endl <<
">> will try the estimated one: forward t0 = " << addRunData->
GetT0BinEstimated(histoNo[j]);
1303 std::cerr << std::endl <<
">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!";
1304 std::cerr << std::endl;
1309 for (UInt_t j=0; j<
fRunInfo->GetForwardHistoNoSize(); j++) {
1311 std::cerr << std::endl <<
">> PRunSingleHistoRRF::GetProperT0(): **ERROR** addt0 data bin (" <<
fAddT0s[i-1][j] <<
") doesn't make any sense!";
1312 std::cerr << std::endl;
1371 start =
fMsrInfo->GetMsrGlobal()->GetDataRange(0);
1374 end =
fMsrInfo->GetMsrGlobal()->GetDataRange(1);
1380 start =
static_cast<Int_t
>(
fT0s[0])+offset;
1382 std::cerr << std::endl <<
">> PRunSingleHistoRRF::GetProperDataRange(): **WARNING** data range was not provided, will try data range start = t0+" << offset <<
"(=10ns) = " << start <<
".";
1383 std::cerr << std::endl <<
">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE.";
1384 std::cerr << std::endl;
1389 std::cerr << std::endl <<
">> PRunSingleHistoRRF::GetProperDataRange(): **WARNING** data range was not provided, will try data range end = " << end <<
".";
1390 std::cerr << std::endl <<
">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE.";
1391 std::cerr << std::endl;
1402 if ((start < 0) || (start >
static_cast<Int_t
>(
fForward.size()))) {
1403 std::cerr << std::endl <<
">> PRunSingleHistoRRF::GetProperDataRange(): **ERROR** start data bin (" << start <<
") doesn't make any sense!";
1404 std::cerr << std::endl;
1409 std::cerr << std::endl <<
">> PRunSingleHistoRRF::GetProperDataRange(): **ERROR** end data bin (" << end <<
") doesn't make any sense!";
1410 std::cerr << std::endl;
1413 if (end >
static_cast<Int_t
>(
fForward.size())) {
1414 std::cerr << std::endl <<
">> PRunSingleHistoRRF::GetProperDataRange(): **WARNING** end data bin (" << end <<
") > histo length (" <<
fForward.size() <<
").";
1415 std::cerr << std::endl <<
">> Will set end = (histo length - 1). Consider to change it in the msr-file." << std::endl;
1416 std::cerr << std::endl;
1417 end =
static_cast<Int_t
>(
fForward.size()-1);
1428 std::cerr << std::endl <<
">> PRunSingleHisto::GetProperDataRange **WARNING** needed to shift forward lgb,";
1429 std::cerr << std::endl <<
">> from " <<
fGoodBins[1] <<
" to " <<
fForward.size()-1 << std::endl;
1508 std::cerr <<
">> PRunSingleHistoRRF::GetProperFitRange(): **WARNING** Couldn't get fit start/end time!" << std::endl;
1509 std::cerr <<
">> Will set it to fgb/lgb which given in time is: " <<
fFitStartTime <<
"..." <<
fFitEndTime <<
" (usec)" << std::endl;
1555 Double_t freqMax = 0.0;
1562 histo->SetBinContent(i-
fGoodBins[0]+1, data[i]);
1566 std::unique_ptr<PFourier> ft = std::make_unique<PFourier>(histo.get(),
FOURIER_UNIT_FREQ);
1570 TH1F *power = ft->GetPowerFourier();
1571 Double_t maxFreqVal = 0.0;
1572 for (Int_t i=1; i<power->GetNbinsX(); i++) {
1574 if (i<power->GetNbinsX()-1) {
1575 if (power->GetBinContent(i)>power->GetBinContent(i+1))
1579 if (power->GetBinCenter(i) < 10.0)
1582 if (power->GetBinContent(i) > maxFreqVal) {
1583 maxFreqVal = power->GetBinContent(i);
1584 freqMax = power->GetBinCenter(i);
1652 for (Int_t i=0; i<endBin; i++) {
1661 for (Int_t i=0; i<endBin; i++) {
1664 errN0 = sqrt(errN0)/wN;
1666 std::cout <<
"info> PRunSingleHistoRRF::EstimateN0(): N0=" << n0 <<
"(" << errN0 <<
")" << std::endl;
1719 Double_t beamPeriod = 0.0;
1722 if (
fRunInfo->GetInstitute()->Contains(
"psi"))
1724 else if (
fRunInfo->GetInstitute()->Contains(
"ral"))
1726 else if (
fRunInfo->GetInstitute()->Contains(
"triumf"))
1732 UInt_t start =
fRunInfo->GetBkgRange(0);
1733 UInt_t end =
fRunInfo->GetBkgRange(1);
1735 std::cout << std::endl <<
"PRunSingleHistoRRF::EstimatBkg(): end = " << end <<
" > start = " << start <<
"! Will swap them!";
1742 if (beamPeriod != 0.0) {
1744 UInt_t fullCycles =
static_cast<UInt_t
>(timeBkg/beamPeriod);
1746 end = start +
static_cast<UInt_t
>((fullCycles*beamPeriod)/
fTimeResolution);
1747 std::cout << std::endl <<
"PRunSingleHistoRRF::EstimatBkg(): Background " << start <<
", " << end;
1754 std::cerr << std::endl <<
">> PRunSingleHistoRRF::EstimatBkg(): **ERROR** background bin values out of bound!";
1755 std::cerr << std::endl <<
">> histo lengths = " <<
fForward.size();
1756 std::cerr << std::endl <<
">> background start = " << start;
1757 std::cerr << std::endl;
1763 std::cerr << std::endl <<
">> PRunSingleHistoRRF::EstimatBkg(): **ERROR** background bin values out of bound!";
1764 std::cerr << std::endl <<
">> histo lengths = " <<
fForward.size();
1765 std::cerr << std::endl <<
">> background end = " << end;
1766 std::cerr << std::endl;
1774 for (UInt_t i=start; i<end; i++)
1776 bkg /=
static_cast<Double_t
>(end - start + 1);
1781 for (UInt_t i=start; i<end; i++)
1783 fBkgErr = sqrt(bkg/(
static_cast<Double_t
>(end - start)));
1785 std::cout << std::endl <<
"info> fBackground=" <<
fBackground <<
"(" <<
fBkgErr <<
")" << std::endl;
#define F_APODIZATION_STRONG
Strong apodization (heavy roll-off for best frequency resolution)
std::vector< UInt_t > PUIntVector
#define ACCEL_PERIOD_TRIUMF
TRIUMF accelerator cycle: 43.37 ns.
@ kFit
Fitting mode - perform least-squares fit to data.
@ kView
Viewing mode - display data and theory without fitting.
#define FOURIER_UNIT_FREQ
Frequency in MHz.
std::vector< PMsrParamStructure > PMsrParamList
#define ACCEL_PERIOD_PSI
PSI (Paul Scherrer Institute) accelerator cycle: 19.75 ns.
std::vector< Double_t > PDoubleVector
#define ACCEL_PERIOD_RAL
RAL (Rutherford Appleton Lab) - pulsed beam.
virtual Bool_t IsPresent()
virtual void SetFitRange(Double_t dval, UInt_t idx)
virtual Double_t GetFitRange(UInt_t idx)
virtual UInt_t GetT0BinSize()
virtual Bool_t IsFitRangeInBin()
virtual Int_t GetRRFPacking()
virtual TString GetRRFUnit()
virtual Int_t GetFitRangeOffset(UInt_t idx)
virtual Double_t GetT0Bin(UInt_t idx=0)
virtual Double_t GetRRFPhase()
virtual Double_t GetRRFFreq(const char *unit)
MSR file parser and manager for the musrfit framework.
virtual PMsrGlobalBlock * GetMsrGlobal()
Returns pointer to GLOBAL block settings.
virtual const PDoubleVector * GetDataBin(const UInt_t histoNo)
virtual const Double_t GetT0Bin(const UInt_t histoNo)
virtual const Double_t GetTimeResolution()
virtual const Bool_t IsPresent(UInt_t histoNo)
virtual const UInt_t GetNoOfTemperatures()
virtual const Double_t GetField()
virtual const Double_t GetEnergy()
virtual const Double_t GetT0BinEstimated(const UInt_t histoNo)
virtual const PDoublePairVector * GetTemperature() const
Double_t fTimeResolution
Time resolution of raw histogram data in microseconds (μs), e.g., 0.01953125 μs for PSI GPS.
Bool_t fValid
Flag indicating if run object initialized successfully; false if any error occurred.
Double_t fFitEndTime
Fit range end time in microseconds (μs) relative to t0.
PDoubleVector fFuncValues
Cached values of user-defined functions from FUNCTIONS block, evaluated at current parameters.
PMsrHandler * fMsrInfo
Pointer to MSR file handler (owned externally, not deleted here)
virtual void DeadTimeCorrection(std::vector< PDoubleVector > &histos, PUIntVector &histoNo)
carry out dead time correction
PMetaData fMetaData
Experimental metadata extracted from data file header (magnetic field, temperature,...
std::unique_ptr< PTheory > fTheory
Theory function evaluator (smart pointer, automatically deleted)
std::vector< PDoubleVector > fAddT0s
Time-zero bin values for additional runs to be added to main run.
EPMusrHandleTag fHandleTag
Operation mode: kFit (fitting), kView (display only), kEmpty (uninitialized)
PRunData fData
Processed data container: background-corrected, packed, with theory values.
PRunDataHandler * fRawData
Pointer to raw data handler (owned externally, not deleted here)
PDoubleVector fT0s
Time-zero bin values for all histograms in this run (forward, backward, etc.)
PRunBase()
Default constructor.
Int_t fRunNo
Run number (0-based index in MSR file RUN blocks)
PMsrRunBlock * fRunInfo
Pointer to this run's RUN block settings within fMsrInfo.
Double_t fFitStartTime
Fit range start time in microseconds (μs) relative to t0.
Raw data file reader and format converter for μSR data.
PDoubleVector fForward
Forward detector histogram data (progressively transformed during preparation)
Int_t fEndTimeBin
Last bin index in fit range (exclusive: loop as i < fEndTimeBin)
virtual Double_t CalcChiSquare(const std::vector< Double_t > &par)
Calculates χ² between RRF-transformed data and theory.
PDoubleVector fAerr
Asymmetry errors before RRF packing. Used for packed error calculation.
virtual Double_t GetMainFrequency(PDoubleVector &data)
Finds the dominant precession frequency in raw data.
PRunSingleHistoRRF()
Default constructor creating an empty, invalid RRF single histogram run object.
virtual Double_t EstimateN0(Double_t &errN0, Double_t freqMax)
Estimates initial normalization N₀ from lifetime-corrected data.
virtual Bool_t PrepareFitData(PRawRunData *runData, const UInt_t histoNo)
Performs full RRF transformation for fitting.
Double_t fBackground
Estimated or fixed background level in counts/bin (before packing)
virtual Double_t CalcChiSquareExpected(const std::vector< Double_t > &par)
Calculates expected χ² using theory variance instead of data variance.
virtual ~PRunSingleHistoRRF()
Virtual destructor releasing allocated resources.
virtual Bool_t PrepareData()
Main data preparation orchestrator for RRF single histogram analysis.
Int_t fStartTimeBin
First bin index in fit range (inclusive, 0-based in RRF-packed data)
virtual void GetProperFitRange(PMsrGlobalBlock *globalBlock)
Determines fit time range from MSR file settings.
Bool_t fTheoAsData
Theory resolution mode: true = at data points only, false = 8× finer grid for smooth Fourier transfor...
virtual Bool_t PrepareViewData(PRawRunData *runData, const UInt_t histoNo)
Prepares RRF data for viewing/plotting.
PDoubleVector fM
Lifetime-corrected histogram: M(t) = [N(t) - B] × exp(+t/τ_μ). Used for N₀ estimation.
virtual Bool_t EstimateBkg(UInt_t histoNo)
Estimates background from pre-t0 bins.
Int_t fGoodBins[2]
Good bin range: [0] = first good bin (fgb), [1] = last good bin (lgb). Used for COMMANDS block fit ra...
Double_t fN0EstimateEndTime
End time (μs) for N₀ estimation window. Rounded to integer number of oscillation cycles based on main...
Double_t fBkgErr
Statistical error on background estimate (std dev of background region)
PDoubleVector fMerr
Error on M(t): σ_M = exp(+t/τ_μ) × √(N(t) + σ_B²). Includes background error.
Int_t fRRFPacking
RRF packing factor from GLOBAL block (number of raw bins averaged together)
UInt_t fNoOfFitBins
Number of RRF-packed bins within fit range [fStartTimeBin, fEndTimeBin)
virtual Bool_t GetProperT0(PRawRunData *runData, PMsrGlobalBlock *globalBlock, PUIntVector &histoNo)
Determines and validates t0 values for all histograms.
virtual Double_t CalcMaxLikelihood(const std::vector< Double_t > &par)
Calculates maximum likelihood (not yet implemented for RRF).
virtual Bool_t GetProperDataRange()
Determines valid data range (first/last good bins).
PDoubleVector fW
Weights for N₀ estimation: W(t) = 1/σ_M². Used in weighted average.
virtual void SetFitRangeBin(const TString fitRange)
Sets fit range using bin-offset syntax from COMMANDS block.
virtual UInt_t GetNoOfFitBins()
Returns the number of bins included in the current fit range.
virtual void CalcTheory()
Evaluates theory function at all data points for viewing/plotting.
virtual void CalcNoOfFitBins()
Calculates start/end bin indices from fit time range.