From 7b8574b3eef90d26c7656644a9aab486877cf39b Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Tue, 13 Oct 2026 09:00:56 +0200 Subject: [PATCH] musrt0 -g: handle msr-files with a GLOBAL block. If 't0' and/or 'addt0' is present in the GLOBAL block, only issue a warning and leave the msr-file untouched. Otherwise the estimated t0's are added/updated in the RUN blocks. Missing t0/addt0/background/data tags were only written at the 'fit' line of a RUN block, which is absent if the fit range is given in the GLOBAL block; in this case they are now written after the last line of the RUN block. --- src/classes/PMsrHandler.cpp | 144 ++++++++++++++++++++++-------------- src/musrt0.cpp | 10 +++ 2 files changed, 99 insertions(+), 55 deletions(-) diff --git a/src/classes/PMsrHandler.cpp b/src/classes/PMsrHandler.cpp index 4c8b3cf3..5e1cce93 100644 --- a/src/classes/PMsrHandler.cpp +++ b/src/classes/PMsrHandler.cpp @@ -475,6 +475,15 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages) for (UInt_t i=0; iCompareTo("isis", TString::kIgnoreCase)) { + if (fRuns[runNo].GetT0BinSize() > 0) { + fout.width(16); + fout << std::left << "t0"; + for (UInt_t j=0; jCompareTo("isis", TString::kIgnoreCase)) { + if (fRuns[runNo].GetAddT0BinSize(i) > 0) { + fout.width(16); + fout << std::left << "addt0"; + for (Int_t j=0; j= 0) { + fout.width(16); + fout << std::left << "background"; + for (UInt_t j=0; j<4; j++) { + if (fRuns[runNo].GetBkgRange(j) > 0) { + fout.width(8); + fout << std::left << fRuns[runNo].GetBkgRange(j); + } + } + fout << std::endl; + } + } + if (dataTagMissing[runNo]) { + if (fRuns[runNo].GetDataRange(0) >= 0) { + fout.width(16); + fout << std::left << "data"; + for (UInt_t j=0; j<4; j++) { + if (fRuns[runNo].GetDataRange(j) > 0) { + fout.width(8); + fout << std::left << fRuns[runNo].GetDataRange(j); + } + } + fout << std::endl; + } + } + }; + tag = MSR_TAG_TITLE; lineNo = 0; runNo = -1; @@ -1068,61 +1152,7 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages) } } else if (sstr.BeginsWith("fit")) { // check if missing t0/addt0/background/data tag are present eventhough the values are present, if so write these data values - // if ISIS data, do not do anything - if (t0TagMissing[runNo] && fRuns[runNo].GetInstitute()->CompareTo("isis", TString::kIgnoreCase)) { - if (fRuns[runNo].GetT0BinSize() > 0) { - fout.width(16); - fout << std::left << "t0"; - for (UInt_t j=0; jCompareTo("isis", TString::kIgnoreCase)) { - if (fRuns[runNo].GetAddT0BinSize(i) > 0) { - fout.width(16); - fout << std::left << "addt0"; - for (Int_t j=0; j= 0) { - fout.width(16); - fout << std::left << "background"; - for (UInt_t j=0; j<4; j++) { - if (fRuns[runNo].GetBkgRange(j) > 0) { - fout.width(8); - fout << std::left << fRuns[runNo].GetBkgRange(j); - } - } - fout << std::endl; - } - } - if (dataTagMissing[runNo]) { - if (fRuns[runNo].GetDataRange(0) >= 0) { - fout.width(16); - fout << std::left << "data"; - for (UInt_t j=0; j<4; j++) { - if (fRuns[runNo].GetDataRange(j) > 0) { - fout.width(8); - fout << std::left << fRuns[runNo].GetDataRange(j); - } - } - fout << std::endl; - } - } + writeMissingRunTags(runNo); // write fit range line fout.width(16); fout << std::left << "fit"; @@ -1163,6 +1193,10 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages) } else { fout << str.Data() << std::endl; } + // no 'fit' line in the RUN block (fit range given in the GLOBAL block), hence + // write missing tags after the last line of the RUN block + if (fitTagMissing[runNo] && (lineNo == lastRunLineNo[runNo])) + writeMissingRunTags(runNo); break; case MSR_TAG_COMMANDS: fout << str.Data() << std::endl; diff --git a/src/musrt0.cpp b/src/musrt0.cpp index 192f30d0..d8768350 100644 --- a/src/musrt0.cpp +++ b/src/musrt0.cpp @@ -346,6 +346,16 @@ Int_t main(Int_t argc, Char_t *argv[]) } } + // t0's given in the GLOBAL block are not touched by the prompt peak estimate + if (getT0FromPromptPeak && success) { + PMsrGlobalBlock *global = msrHandler->GetMsrGlobal(); + if ((global->GetT0BinSize() > 0) || (global->GetAddT0BinEntries() > 0)) { + std::cerr << std::endl << ">> musrt0 **WARNING** 't0' and/or 'addt0' already found in the GLOBAL block."; + std::cerr << std::endl << ">> Will not estimate t0's from the prompt peak, the msr-file is left untouched." << std::endl << std::endl; + return PMUSR_SUCCESS; + } + } + if (getT0FromPromptPeak && success) { Int_t histoNo = -1;