From 1e115c7bd318de5fcd3ea35ab2177a489f0d2584 Mon Sep 17 00:00:00 2001 From: "Bastian M. Wojek" Date: Wed, 13 Jul 2011 13:37:28 +0000 Subject: [PATCH] Slightly changed the behavior of msr2data (see ChangeLog for details) --- ChangeLog | 4 ++++ src/classes/PMsr2Data.cpp | 29 ++++++++++++++++++++--------- src/include/PMsr2Data.h | 2 +- src/msr2data.cpp | 10 +++++----- 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6e2cce01..9751af3c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -25,6 +25,10 @@ FIXED bug reported in MUSR-183: missing background for 2nd histo in asymmetry fi FIXED Makefiles so that the NeXus support will not be built if it has not been enabled during the configure stage FIXED ASCII export from musrview in case of a Fourier-Power- or Fourier-Phase-difference plot FIXED bug in asymmetry fit with fixed background +CHANGED the behavior of msr2data so that + * it proceeds to the next run if a fit did not converge (and does not stop as before) + * it always tries to read the data files if the nosummary option is not present + (before this was switched off for the next runs when the data file of the present run could not be read) CHANGED in case first good bin (fgb) is not given, it is now fgb=t0+(10ns/time resolution) (MUSR-190) CHANGED improved handling of 'old' ROOT LEM data files (2006 and earlier) for any2many (MUSR-178) CHANGED improved handling of WKM/ASCII in PRunDataHandler for any2many (MUSR-172) diff --git a/src/classes/PMsr2Data.cpp b/src/classes/PMsr2Data.cpp index 24a8fd8e..d0d17c1e 100644 --- a/src/classes/PMsr2Data.cpp +++ b/src/classes/PMsr2Data.cpp @@ -513,10 +513,10 @@ PMsrHandler* PMsr2Data::GetSingleRunMsrFile() const *

Read in a run data-file * *

return: - * - true if everything is OK - * - false otherwise + * - 0 if everything is OK + * - 1 otherwise */ -bool PMsr2Data::ReadRunDataFile() +int PMsr2Data::ReadRunDataFile() { if (fStartupHandler) fDataHandler = new PRunDataHandler(fMsrHandler, fStartupHandler->GetDataPathList()); @@ -528,13 +528,14 @@ bool PMsr2Data::ReadRunDataFile() cerr << endl << ">> msr2data: **WARNING** Could not read all data files, will continue without the data file information..." << endl; delete fDataHandler; fDataHandler = 0; + return 1; } - return success; + return 0; } //------------------------------------------------------------- /** - *

Generate a new single run msr-file from a template + *

Generate a new single-run msr file from a template * *

return: * - true if everything is OK @@ -623,6 +624,9 @@ bool PMsr2Data::PrepareNewInputFile(unsigned int tempRun, bool calledFromGlobalM while (strLine >> firstOnLine) out << " " << firstOnLine; out << endl; + } else if (!to_lower_copy(firstOnLine).compare("chisq") || !to_lower_copy(firstOnLine).compare("maxlh")) { + out << "*** FIT DID NOT CONVERGE ***" << endl; + break; } else { out << line << endl; } @@ -1525,6 +1529,9 @@ bool PMsr2Data::PrepareGlobalInputFile(unsigned int tempRun, const string &msrOu ++fRunVectorIter; } + // set the convergence flag to false because no fit has been performed using the newly generated file + fMsrHandler->GetMsrStatistic()->fValid = false; + // write the global msr-file status = fMsrHandler->WriteMsrFile(msrOutFile.c_str(), &commentsP, 0, 0, &commentsR); @@ -1619,6 +1626,9 @@ bool PMsr2Data::PrepareNewSortedInputFile(unsigned int tempRun) const } } + // set the convergence flag to false because no fit has been performed using the newly generated file + fMsrHandler->GetMsrStatistic()->fValid = false; + // write the msr-file int status = fMsrHandler->WriteMsrFile(msrOutFile.str().c_str()); @@ -1632,7 +1642,7 @@ bool PMsr2Data::PrepareNewSortedInputFile(unsigned int tempRun) const titleCopy.Clear(); if (status != PMUSR_SUCCESS) { - cerr << endl << ">> msr2data: **ERROR** Writing the new msr-file has not been successful!"; + cerr << endl << ">> msr2data: **ERROR** Writing the new msr file has not been successful!"; cerr << endl; return false; } @@ -1643,11 +1653,12 @@ bool PMsr2Data::PrepareNewSortedInputFile(unsigned int tempRun) const //------------------------------------------------------------- /** - *

Append fit parameters of a msr-file to the DB or ASCII file + *

Append fit parameters of a msr file to the DB or ASCII file * *

return: * - PMUSR_SUCCESS if everything is OK - * - -1 in case of an error + * - -1 in case of a fatal error + * - -2 if a fit has not converged (and the data is not appended to the output file) * * \param outfile name of the DB/ASCII output file * \param db DB or plain ASCII output @@ -1944,7 +1955,7 @@ int PMsr2Data::WriteOutput(const string &outfile, bool db, unsigned int withHead dataParamErr.clear(); indVarValues.clear(); - return -1; + return -2; } // open the DB or dat file and write the data diff --git a/src/include/PMsr2Data.h b/src/include/PMsr2Data.h index 655d23c7..e743d7de 100644 --- a/src/include/PMsr2Data.h +++ b/src/include/PMsr2Data.h @@ -68,7 +68,7 @@ class PMsr2Data int ParseXmlStartupFile(); int ReadMsrFile(const string&) const; - bool ReadRunDataFile(); + int ReadRunDataFile(); bool PrepareNewInputFile(unsigned int, bool) const; // template bool PrepareGlobalInputFile(unsigned int, const string&, unsigned int) const; // generate msr-input file for a global fit diff --git a/src/msr2data.cpp b/src/msr2data.cpp index 9f76fb2c..43425e16 100644 --- a/src/msr2data.cpp +++ b/src/msr2data.cpp @@ -725,14 +725,14 @@ int main(int argc, char *argv[]) // read data files if (writeSummary) - writeSummary = msr2dataHandler->ReadRunDataFile(); + status = msr2dataHandler->ReadRunDataFile(); unsigned int counter(0); while (msr2dataHandler->GetPresentRun()) { // write DB or dat file status = msr2dataHandler->WriteOutput(outputFile, db, writeHeader, !setNormalMode, counter); - if (status != PMUSR_SUCCESS) { + if (status == -1) { msr2data_cleanup(msr2dataHandler, arg); return status; } @@ -805,7 +805,7 @@ int main(int argc, char *argv[]) if (status != PMUSR_SUCCESS) { // if the msr-file cannot be read, write no output but proceed to the next run status = msr2dataHandler->WriteOutput("none", db, writeHeader); - if (status != PMUSR_SUCCESS) { + if (status == -1) { msr2data_cleanup(msr2dataHandler, arg); return status; } else { @@ -816,11 +816,11 @@ int main(int argc, char *argv[]) // read data files if (writeSummary) - writeSummary = msr2dataHandler->ReadRunDataFile(); + status = msr2dataHandler->ReadRunDataFile(); // write DB or dat file status = msr2dataHandler->WriteOutput(outputFile, db, writeHeader); - if (status != PMUSR_SUCCESS) { + if (status == -1) { msr2data_cleanup(msr2dataHandler, arg); return status; }