musrfit 1.10.0
PRunSingleHistoRRF.h
Go to the documentation of this file.
1/***************************************************************************
2
3 PRunSingleHistoRRF.h
4
5 Author: Andreas Suter
6 e-mail: andreas.suter@psi.ch
7
8***************************************************************************/
9
10/***************************************************************************
11 * Copyright (C) 2007-2026 by Andreas Suter *
12 * andreas.suter@psi.ch *
13 * *
14 * This program is free software; you can redistribute it and/or modify *
15 * it under the terms of the GNU General Public License as published by *
16 * the Free Software Foundation; either version 2 of the License, or *
17 * (at your option) any later version. *
18 * *
19 * This program is distributed in the hope that it will be useful, *
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
22 * GNU General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU General Public License *
25 * along with this program; if not, write to the *
26 * Free Software Foundation, Inc., *
27 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
28 ***************************************************************************/
29
30#ifndef _PRUNSINGLEHISTORRF_H_
31#define _PRUNSINGLEHISTORRF_H_
32
33#include "PRunBase.h"
34
145{
146 public:
163
195 PRunSingleHistoRRF(PMsrHandler *msrInfo, PRunDataHandler *rawData, UInt_t runNo, EPMusrHandleTag tag, Bool_t theoAsData);
196
202 virtual ~PRunSingleHistoRRF();
203
228 virtual Double_t CalcChiSquare(const std::vector<Double_t>& par);
229
244 virtual Double_t CalcChiSquareExpected(const std::vector<Double_t>& par);
245
259 virtual Double_t CalcMaxLikelihood(const std::vector<Double_t>& par);
260
271 virtual void CalcTheory();
272
281 virtual UInt_t GetNoOfFitBins();
282
300 virtual void SetFitRangeBin(const TString fitRange);
301
306 virtual Int_t GetStartTimeBin() { return fStartTimeBin; }
307
312 virtual Int_t GetEndTimeBin() { return fEndTimeBin; }
313
325 virtual void CalcNoOfFitBins();
326
327 protected:
349 virtual Bool_t PrepareData();
350
394 virtual Bool_t PrepareFitData(PRawRunData* runData, const UInt_t histoNo);
395
411 virtual Bool_t PrepareViewData(PRawRunData* runData, const UInt_t histoNo);
412
413 private:
415
417 Double_t fBackground;
418 Double_t fBkgErr;
420 Bool_t fTheoAsData;
421
422 Int_t fGoodBins[2];
423
426
432
449 virtual Bool_t GetProperT0(PRawRunData* runData, PMsrGlobalBlock *globalBlock, PUIntVector &histoNo);
450
463 virtual Bool_t GetProperDataRange();
464
477 virtual void GetProperFitRange(PMsrGlobalBlock *globalBlock);
478
496 virtual Double_t GetMainFrequency(PDoubleVector &data);
497
518 virtual Double_t EstimateN0(Double_t &errN0, Double_t freqMax);
519
532 virtual Bool_t EstimateBkg(UInt_t histoNo);
533};
534
535#endif // _PRUNSINGLEHISTORRF_H_
std::vector< UInt_t > PUIntVector
Definition PMusr.h:375
EPMusrHandleTag
Definition PMusr.h:427
std::vector< Double_t > PDoubleVector
Definition PMusr.h:399
MSR file parser and manager for the musrfit framework.
PRunBase()
Default constructor.
Definition PRunBase.cpp:52
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.
virtual Int_t GetEndTimeBin()
Returns the last bin index in the fit range (exclusive).
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.
virtual Int_t GetStartTimeBin()
Returns the first bin index in the fit range.
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.