musrfit 1.10.0
PRunSingleHisto.h
Go to the documentation of this file.
1/***************************************************************************
2
3 PRunSingleHisto.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 _PRUNSINGLEHISTO_H_
31#define _PRUNSINGLEHISTO_H_
32
33#include "PRunBase.h"
34
144{
145 public:
162
205 PRunSingleHisto(PMsrHandler *msrInfo, PRunDataHandler *rawData, UInt_t runNo, EPMusrHandleTag tag, Bool_t theoAsData);
206
213 virtual ~PRunSingleHisto();
214
229 virtual Double_t CalcChiSquare(const std::vector<Double_t>& par);
230
236 virtual Double_t CalcChiSquareExpected(const std::vector<Double_t>& par);
237
247 virtual Double_t CalcMaxLikelihood(const std::vector<Double_t>& par);
248
254 virtual Double_t CalcMaxLikelihoodExpected(const std::vector<Double_t>& par);
255
262 virtual void CalcTheory();
263
271 virtual UInt_t GetNoOfFitBins();
272
280 virtual void SetFitRangeBin(const TString fitRange);
281
286 virtual Double_t GetBackground() { return fBackground; }
287
292 virtual Int_t GetStartTimeBin() { return fStartTimeBin; }
293
298 virtual Int_t GetEndTimeBin() { return fEndTimeBin; }
299
304 virtual Int_t GetPacking() { return fPacking; }
305
310 virtual Bool_t GetScaleN0AndBkg() { return fScaleN0AndBkg; }
311
318 virtual void CalcNoOfFitBins();
319
320 protected:
329 virtual Bool_t PrepareData();
330
341 virtual Bool_t PrepareFitData(PRawRunData* runData, const UInt_t histoNo);
342
353 virtual Bool_t PrepareRawViewData(PRawRunData* runData, const UInt_t histoNo);
354
365 virtual Bool_t PrepareViewData(PRawRunData* runData, const UInt_t histoNo);
366
367 private:
370 Double_t fBackground;
371 Int_t fPacking;
372 Bool_t fTheoAsData;
373
374 Int_t fGoodBins[2];
375
377
380
392 virtual Bool_t GetProperT0(PRawRunData* runData, PMsrGlobalBlock *globalBlock, PUIntVector &histoNo);
393
402 virtual Bool_t GetProperDataRange();
403
412 virtual void GetProperFitRange(PMsrGlobalBlock *globalBlock);
413
420 virtual void EstimateN0();
421
431 virtual Bool_t EstimateBkg(UInt_t histoNo);
432
441 virtual Bool_t IsScaleN0AndBkg();
442};
443
444#endif // _PRUNSINGLEHISTO_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.
virtual Double_t CalcChiSquare(const std::vector< Double_t > &par)
Calculates χ² between histogram data and theory.
virtual void CalcNoOfFitBins()
Calculates start/end bin indices from fit time range.
virtual Double_t CalcChiSquareExpected(const std::vector< Double_t > &par)
Calculates expected χ² based on theory predictions.
virtual Bool_t IsScaleN0AndBkg()
Determines if N₀ and background should be scaled to 1/ns.
Double_t fBackground
Background level in counts/bin (estimated from pre-t0 bins or fixed value from RUN block)
UInt_t fNoOfFitBins
Number of bins within fit range (fStartTimeBin to fEndTimeBin)
virtual ~PRunSingleHisto()
Virtual destructor cleaning up allocated resources.
virtual Bool_t PrepareViewData(PRawRunData *runData, const UInt_t histoNo)
Prepares processed histogram data for viewing/plotting.
virtual Double_t CalcMaxLikelihood(const std::vector< Double_t > &par)
Calculates maximum likelihood for Poisson-distributed histogram counts.
virtual Bool_t EstimateBkg(UInt_t histoNo)
Estimates background from pre-t0 bins.
virtual Int_t GetStartTimeBin()
Returns the first bin index in the fit range.
virtual void CalcTheory()
Evaluates theory function at all data points or high-resolution grid.
virtual Int_t GetPacking()
Returns the bin packing factor.
virtual UInt_t GetNoOfFitBins()
Returns the number of bins included in the fit range.
virtual void EstimateN0()
Estimates initial normalization N₀ from histogram data.
virtual Bool_t GetScaleN0AndBkg()
Returns the N₀/background scaling mode.
Int_t fEndTimeBin
Last bin index in fit range (exclusive: loop as i < fEndTimeBin)
PRunSingleHisto()
Default constructor creating an empty, invalid single histogram run object.
virtual void GetProperFitRange(PMsrGlobalBlock *globalBlock)
Determines fit range from MSR file settings.
virtual void SetFitRangeBin(const TString fitRange)
Sets fit range using bin-offset specification (COMMANDS block syntax).
virtual Int_t GetEndTimeBin()
Returns the last bin index in the fit range (exclusive).
Bool_t fScaleN0AndBkg
Scaling mode: true = scale N₀ and B to 1/ns, false = leave as 1/bin (determined by IsScaleN0AndBkg())
Int_t fStartTimeBin
First bin index in fit range (inclusive, 0-based after packing)
virtual Bool_t GetProperDataRange()
Determines data range (region of valid histogram data).
virtual Bool_t GetProperT0(PRawRunData *runData, PMsrGlobalBlock *globalBlock, PUIntVector &histoNo)
Determines and validates t0 values for histogram.
virtual Double_t GetBackground()
Returns the estimated background level.
Bool_t fTheoAsData
Theory mode: true = at data points, false = high-resolution grid for smooth Fourier transforms.
Int_t fGoodBins[2]
Good bin markers for COMMANDS block: [0]=fgb (first good bin/t0), [1]=lgb (last good bin)
Int_t fPacking
Bin packing factor (REQUIRED: from RUN or GLOBAL block)
virtual Bool_t PrepareRawViewData(PRawRunData *runData, const UInt_t histoNo)
Prepares raw histogram data for viewing (minimal processing).
virtual Double_t CalcMaxLikelihoodExpected(const std::vector< Double_t > &par)
Calculates expected maximum likelihood.
virtual Bool_t PrepareData()
Main data preparation orchestrator.
virtual Bool_t PrepareFitData(PRawRunData *runData, const UInt_t histoNo)
Prepares histogram data for fitting.
PDoubleVector fForward
Forward detector histogram (background-corrected, packed)