36#include <TObjString.h>
99 fRunNo =
static_cast<Int_t
>(runNo);
100 if (runNo >
fMsrInfo->GetMsrRunList()->size()) {
110 std::cerr << std::endl <<
"**SEVERE ERROR** PRunBase::PRunBase: map and/or parameter out of range in FUNCTIONS." << std::endl;
118 for (Int_t i=0; i<
fMsrInfo->GetNoOfFuncs(); i++)
124 std::cerr << std::endl <<
"**SEVERE ERROR** PRunBase::PRunBase: Couldn't create an instance of PTheory :-(, will quit" << std::endl;
128 std::cerr << std::endl <<
"**SEVERE ERROR** PRunBase::PRunBase: Theory is not valid :-(, will quit" << std::endl;
155 for (UInt_t i=0; i<
fAddT0s.size(); i++)
175 if (runData ==
nullptr) {
176 std::cerr << std::endl <<
"**WARNING** PRunBase::DeadTimeCorrection: couldn't get data from '" << *
fRunInfo->GetRunName() <<
"'" << std::endl;
180 bool checkDeadTime{
false};
182 for (
unsigned int i=0; i<rl->size(); i++) {
183 if (!rl->at(i).GetFileFormat()->CompareTo(
"nexus", TString::kIgnoreCase)) {
184 checkDeadTime =
true;
190 std::cerr << std::endl <<
"**WARNING** PRunBase::DeadTimeCorrection: missing input for dead time correction" << std::endl;
197 TString dtcg =
fMsrInfo->GetMsrGlobal()->GetDeadTimeCorrection();
199 if (dtcg.Contains(
"file", TString::kIgnoreCase)) {
201 }
else if (dtcg.Contains(
"estimate", TString::kIgnoreCase)) {
206 Bool_t needToCheck{
true};
207 for (UInt_t i=0; i<histoNo.size(); i++) {
208 dtcr =
fRunInfo->GetDeadTimeCorrection();
209 if (dtcr.Contains(
"file", TString::kIgnoreCase) || (dtcg_tag != 0)) {
216 for (UInt_t j=0; j<histos[i].size(); j++) {
217 n_true = histos[i][j] / (1.0 - histos[i][j] * t_dt[histoNo[i]-1] / (gf *
fTimeResolution));
218 histos[i][j] = n_true;
222 if ((dtcr.Contains(
"estimate", TString::kIgnoreCase) || (dtcg_tag != 0)) && needToCheck) {
223 std::cerr << std::endl <<
"**INFO** deadtime correction estimate not yet implemented." << std::endl;
254 Double_t start=0.0, end=0.0;
256 assert(fitRange.size());
258 if (fitRange.size()==1) {
259 start = fitRange[0].first;
260 end = fitRange[0].second;
263 UInt_t idx=
static_cast<UInt_t
>(
fRunNo);
264 if (idx < fitRange.size()) {
265 start = fitRange[idx].first;
266 end = fitRange[idx].second;
268 std::cerr << std::endl <<
">> PRunBase::SetFitRange(): **ERROR** msr-file run entry " <<
fRunNo <<
" not present in fit range vector.";
269 std::cerr << std::endl <<
">> Will not do anything! Please check, this shouldn't happen." << std::endl;
276 std::cerr << std::endl <<
">> PRunBase::SetFitRange(): **WARNING** start=" << start <<
" is > as end=" << end;
277 std::cerr << std::endl <<
">> Will swap them, since otherwise chisq/logLH == 0.0" << std::endl;
342 Double_t dt =
fData.GetTheoryTimeStep();
347 beta = 0.1102*(A-8.7);
348 }
else if ((A >= 21.0) && (A <= 50.0)) {
349 beta = 0.5842*TMath::Power(A-21.0, 0.4) + 0.07886*(A-21.0);
354 m = TMath::FloorNint((A-8.0)/(2.285*dw*TMath::Pi()));
359 Double_t alpha =
static_cast<Double_t
>(m)/2.0;
362 for (Int_t i=0; i<=m; i++) {
363 dval = TMath::Sin(wc*(i-alpha)*dt)/(TMath::Pi()*(i-alpha)*dt);
364 dval *= TMath::BesselI0(beta*TMath::Sqrt(1.0-TMath::Power((i-alpha)*dt/alpha, 2.0)))/TMath::BesselI0(beta);
368 for (UInt_t i=0; i<=static_cast<UInt_t>(m); i++) {
411 for (UInt_t i=0; i<theo->size(); i++) {
418 theoFiltered.push_back(dval);
422 fData.ReplaceTheory(theoFiltered);
426 fData.SetTheoryTimeStart(dval);
428 theoFiltered.clear();
std::vector< UInt_t > PUIntVector
@ kEmpty
No operation active.
std::vector< PMsrRunBlock > PMsrRunList
std::vector< PDoublePair > PDoublePairVector
std::vector< Double_t > PDoubleVector
MSR file parser and manager for the musrfit framework.
virtual const Int_t GetNumberOfGoodFrames()
virtual const Bool_t DeadTimeCorrectionReady()
virtual const std::vector< float > GetDeadTimeParam()
virtual void CleanUp()
Cleans up internal data structures.
Double_t fTimeResolution
Time resolution of raw histogram data in microseconds (μs), e.g., 0.01953125 μs for PSI GPS.
virtual ~PRunBase()
Virtual destructor.
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.
PDoubleVector fKaiserFilter
Kaiser window FIR filter coefficients for smoothing RRF theory curves.
virtual void SetFitRange(PDoublePairVector fitRange)
Sets the fit time range for this run.
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)
virtual void CalculateKaiserFilterCoeff(Double_t wc, Double_t A, Double_t dw)
Calculates Kaiser window FIR filter coefficients for RRF smoothing.
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.
virtual void FilterTheo()
Applies Kaiser FIR filter to theory values for RRF fits.
Raw data file reader and format converter for μSR data.