diff --git a/ChangeLog b/ChangeLog index bf509f5f..122587a2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15,6 +15,14 @@ https://bitbucket.org/muonspin/musrfit Release of V1.12.0, 2026/07/22 ============================== +Bug fix: +Fix the dead time correction for Red/Green (period) data of NeXus HDF5 IDF V2 files. +The histogram numbers of the routed histograms carry the period offset (10000), +whereas the dead time parameters are stored contiguously, period-by-period. The +dead time parameter vector was addressed with 'histoNo-1' which, for period > 0, +read beyond the end of the vector. As a consequence any fit of such data gave a +different (random) result at each invocation. + Refactoring: Replace ROOT's TString::Tokenize() + TObjArray/TObjString token handling with the dependency-free PStringUtils::Split() across all classes. This reduces the diff --git a/src/classes/PMusr.cpp b/src/classes/PMusr.cpp index 3a928880..19a21174 100644 --- a/src/classes/PMusr.cpp +++ b/src/classes/PMusr.cpp @@ -700,6 +700,40 @@ const Double_t PRawRunData::GetRingAnode(const UInt_t idx) return fRingAnode[idx]; } +//-------------------------------------------------------------------------- +// GetDeadTimeParam (public) +//-------------------------------------------------------------------------- +/** + *
Returns the dead time parameter belonging to the histogram number histoNo. + * + *
The histogram numbers of Red/Green (period) data carry the period offset,
+ * i.e. histoNo = period*PERIOD_HISTO_OFFSET + histo, whereas the dead time
+ * parameters are stored contiguously, period-by-period, and hence need to be
+ * addressed as period*fNoOfHistosPerPeriod + histo - 1.
+ *
+ * return:
+ * - dead time parameter, if it can be addressed
+ * - 0.0, otherwise, i.e. no dead time correction will be applied
+ *
+ * \param histoNo histogram number as given in the msr-file
+ */
+const Double_t PRawRunData::GetDeadTimeParam(const UInt_t histoNo)
+{
+ UInt_t idx = histoNo - 1;
+
+ if (fNoOfHistosPerPeriod > 0) // Red/Green (period) data
+ idx = (histoNo / PERIOD_HISTO_OFFSET) * fNoOfHistosPerPeriod + (histoNo % PERIOD_HISTO_OFFSET) - 1;
+
+ if (idx >= fDeadTimeParam.size()) {
+ std::cerr << std::endl << ">> PRawRunData::GetDeadTimeParam: **WARNING** histoNo=" << histoNo << " maps onto idx=" << idx;
+ std::cerr << " which is out of range [0," << fDeadTimeParam.size() << "[. Will not dead time correct this histogram.";
+ std::cerr << std::endl;
+ return 0.0;
+ }
+
+ return fDeadTimeParam[idx];
+}
+
//--------------------------------------------------------------------------
// GetDataSet (public)
//--------------------------------------------------------------------------
diff --git a/src/classes/PRunBase.cpp b/src/classes/PRunBase.cpp
index 4bb89453..b9c15cf8 100644
--- a/src/classes/PRunBase.cpp
+++ b/src/classes/PRunBase.cpp
@@ -210,9 +210,9 @@ void PRunBase::DeadTimeCorrection(std::vector Fourier transform unit tags.
@@ -880,7 +889,9 @@ class PRawRunData {
virtual const Bool_t DeadTimeCorrectionReady();
virtual const Int_t GetNumberOfGoodFrames() { return fNumberOfGoodFrames; }
virtual const std::vector