From 3236df1678301ebd03a3ca691b0ae1fed805cc3d Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Sun, 23 Aug 2026 09:51:46 +0200 Subject: [PATCH] fix 'possible msr2data in global+ mode bug' bug report #16 gitea --- src/classes/PMsr2Data.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/classes/PMsr2Data.cpp b/src/classes/PMsr2Data.cpp index f264d2df..df6c20f4 100644 --- a/src/classes/PMsr2Data.cpp +++ b/src/classes/PMsr2Data.cpp @@ -1453,14 +1453,22 @@ bool PMsr2Data::PrepareGlobalInputFile(unsigned int tempRun, const std::string & //std::cout << "Number of run specific parameters: " << fNumSpecParam << std::endl; - if (newRunNumber.str().compare(tempRunNumber.str())) { // first run number does not match the template run number - // in global+ mode, read in the single run msr-file of the corresponding run - if (globalPlus) { - singleRunMsrFile = GetSingleRunMsrFile(); - if (singleRunMsrFile == nullptr) - return false; + // in global+ mode, read in the single-run msr-file of the first run and use its + // fitted values/steps as starting values for the run-specific parameters - + // also when the first run coincides with the template run + if (globalPlus) { + singleRunMsrFile = GetSingleRunMsrFile(); + if (singleRunMsrFile == nullptr) + return false; + for (unsigned int l(fNumGlobalParam); l < msrParamList->size(); ++l) { + fMsrHandler->SetMsrParamValue(l, singleRunMsrFile->GetMsrParamList()->at(l).fValue); + fMsrHandler->SetMsrParamStep(l, singleRunMsrFile->GetMsrParamList()->at(l).fStep); } + delete singleRunMsrFile; + singleRunMsrFile = nullptr; + } + if (newRunNumber.str().compare(tempRunNumber.str())) { // first run number does not match the template run number // substitute the template run-numbers in the parameter names for (unsigned int l(fNumGlobalParam); l < msrParamList->size(); ++l) { tempParamName = msrParamList->at(l).fName.Data(); @@ -1468,20 +1476,12 @@ bool PMsr2Data::PrepareGlobalInputFile(unsigned int tempRun, const std::string & if ( loc != std::string::npos ) { tempParamName.replace(loc, fRunNumberDigits, newRunNumber.str()); msrParamList->at(l).fName = tempParamName; - if (globalPlus && singleRunMsrFile) { - fMsrHandler->SetMsrParamValue(l, singleRunMsrFile->GetMsrParamList()->at(l).fValue); - fMsrHandler->SetMsrParamStep(l, singleRunMsrFile->GetMsrParamList()->at(l).fStep); - } } else { std::cerr << std::endl << ">> msr2data: **ERROR** The indices of the run specific parameters do not match the template run number!"; std::cerr << std::endl << ">> msr2data: **ERROR** This should not happen! Please report a bug!"; std::cerr << std::endl; } } - if (singleRunMsrFile) { - delete singleRunMsrFile; - singleRunMsrFile = nullptr; - } // substitute the template run-numbers in the RUN names for (unsigned int i(0); i < fNumTempRunBlocks; ++i) {