diff --git a/src/classes/PMsrHandler.cpp b/src/classes/PMsrHandler.cpp index dec301bb..69ccc20a 100644 --- a/src/classes/PMsrHandler.cpp +++ b/src/classes/PMsrHandler.cpp @@ -325,7 +325,7 @@ cout << endl; /** *

*/ -int PMsrHandler::WriteMsrLogFile(TString ext) +int PMsrHandler::WriteMsrLogFile(const bool messages) { const unsigned int prec = 6; // output precision for float/doubles @@ -350,13 +350,7 @@ int PMsrHandler::WriteMsrLogFile(TString ext) // remove extension str = fFileName; str.Remove(idx+1); - - // add new extension - if (ext.Length() != 0) - str += ext; - else - str += "mlog"; - + str += "mlog"; ifstream fin; ofstream fout; @@ -826,10 +820,12 @@ int PMsrHandler::WriteMsrLogFile(TString ext) str += ", chisq/NDF = "; str += fStatistic.fMin / fStatistic.fNdf; fout << str.Data() << endl; - cout << endl << str.Data() << endl; + if (messages) + cout << endl << str.Data() << endl; } else { fout << "*** FIT DID NOT CONVERGE ***" << endl; - cout << endl << "*** FIT DID NOT CONVERGE ***" << endl; + if (messages) + cout << endl << "*** FIT DID NOT CONVERGE ***" << endl; } } else if (sstr.BeginsWith("maxLH")) { if (fStatistic.fValid) { // valid fit result @@ -840,10 +836,12 @@ int PMsrHandler::WriteMsrLogFile(TString ext) str += ", maxLH/NDF = "; str += fStatistic.fMin / fStatistic.fNdf; fout << str.Data() << endl; - cout << endl << str.Data() << endl; + if (messages) + cout << endl << str.Data() << endl; } else { fout << "*** FIT DID NOT CONVERGE ***" << endl; - cout << endl << "*** FIT DID NOT CONVERGE ***" << endl; + if (messages) + cout << endl << "*** FIT DID NOT CONVERGE ***" << endl; } } else if (sstr.BeginsWith("*** FIT DID NOT CONVERGE ***")) { if (fStatistic.fValid) { // valid fit result @@ -855,7 +853,8 @@ int PMsrHandler::WriteMsrLogFile(TString ext) str += ", chisq/NDF = "; str += fStatistic.fMin / fStatistic.fNdf; fout << str.Data() << endl; - cout << endl << str.Data() << endl; + if (messages) + cout << endl << str.Data() << endl; } else { // max. log. liklihood str = " maxLH = "; str += fStatistic.fMin; @@ -864,11 +863,13 @@ int PMsrHandler::WriteMsrLogFile(TString ext) str += ", maxLH/NDF = "; str += fStatistic.fMin / fStatistic.fNdf; fout << str.Data() << endl; - cout << endl << str.Data() << endl; + if (messages) + cout << endl << str.Data() << endl; } } else { fout << "*** FIT DID NOT CONVERGE ***" << endl; - cout << endl << "*** FIT DID NOT CONVERGE ***" << endl; + if (messages) + cout << endl << "*** FIT DID NOT CONVERGE ***" << endl; } } else { fout << str.Data() << endl; diff --git a/src/include/PMsrHandler.h b/src/include/PMsrHandler.h index 8886e4f0..94ffeeb1 100644 --- a/src/include/PMsrHandler.h +++ b/src/include/PMsrHandler.h @@ -51,7 +51,7 @@ class PMsrHandler virtual ~PMsrHandler(); virtual int ReadMsrFile(); - virtual int WriteMsrLogFile(TString ext=TString("")); + virtual int WriteMsrLogFile(const bool messages = true); virtual TString* GetMsrTitle() { return &fTitle; } virtual PMsrParamList* GetMsrParamList() { return &fParam; } diff --git a/src/musrfit.cpp b/src/musrfit.cpp index 6050a3fd..abd5ad8f 100644 --- a/src/musrfit.cpp +++ b/src/musrfit.cpp @@ -490,7 +490,7 @@ int main(int argc, char *argv[]) bool keep_mn2_output = false; bool chisq_only = false; TString dump(""); - char filename[256]; + char filename[1024]; // check syntax if (argc < 2) { diff --git a/src/musrt0.cpp b/src/musrt0.cpp index 468fcaf1..da894421 100644 --- a/src/musrt0.cpp +++ b/src/musrt0.cpp @@ -39,6 +39,7 @@ using namespace std; #include #include #include +#include #include "PMusr.h" #include "PStartupHandler.h" @@ -55,7 +56,7 @@ using namespace std; void musrt0_syntax() { cout << endl << "usage: musrt0 | --version | --help"; - cout << endl << " : msr/mlog input file"; + cout << endl << " : msr input file"; cout << endl << " 'musrt0 ' will execute musrt0"; cout << endl << " 'musrt0' or 'musrt0 --help' will show this help"; cout << endl << " 'musrt0 --version' will print the musrt0 version"; @@ -135,6 +136,7 @@ int main(int argc, char *argv[]) bool show_syntax = false; int status; bool success = true; + char filename[1024]; switch (argc) { case 1: @@ -149,9 +151,11 @@ int main(int argc, char *argv[]) show_syntax = true; } else { // check if filename has extension msr or mlog - if (!strstr(argv[1], ".msr") && !strstr(argv[1], ".mlog")) { - cout << endl << "**ERROR** " << argv[1] << " is not a msr/mlog-file!" << endl; + if (!strstr(argv[1], ".msr")) { + cout << endl << "**ERROR** " << argv[1] << " is not a msr-file!" << endl; show_syntax = true; + } else { + strncpy(filename, argv[1], sizeof(filename)); } } break; @@ -190,15 +194,15 @@ int main(int argc, char *argv[]) startupHandler->CheckLists(); // read msr-file - PMsrHandler *msrHandler = new PMsrHandler(argv[1]); + PMsrHandler *msrHandler = new PMsrHandler(filename); status = msrHandler->ReadMsrFile(); if (status != PMUSR_SUCCESS) { switch (status) { case PMUSR_MSR_FILE_NOT_FOUND: - cout << endl << "**ERROR** couldn't find '" << argv[1] << "'" << endl << endl; + cout << endl << "**ERROR** couldn't find '" << filename << "'" << endl << endl; break; case PMUSR_MSR_SYNTAX_ERROR: - cout << endl << "**SYNTAX ERROR** in file " << argv[1] << ", full stop here." << endl << endl; + cout << endl << "**SYNTAX ERROR** in file " << filename << ", full stop here." << endl << endl; break; default: cout << endl << "**UNKNOWN ERROR** when trying to read the msr-file" << endl << endl; @@ -287,7 +291,21 @@ int main(int argc, char *argv[]) } // write msr-file - msrHandler->WriteMsrLogFile("msr"); + msrHandler->WriteMsrLogFile(false); + + // swap msr- and mlog-file + // copy msr-file -> __temp.msr + gSystem->CopyFile(filename, "__temp.msr", kTRUE); + // copy mlog-file -> msr-file + TString fln = TString(filename); + char ext[32]; + strcpy(ext, ".mlog"); + fln.ReplaceAll(".msr", 4, ext, strlen(ext)); + gSystem->CopyFile(fln.Data(), filename, kTRUE); + // copy __temp.msr -> mlog-file + gSystem->CopyFile("__temp.msr", fln.Data(), kTRUE); + // delete __temp.msr + gSystem->Exec("rm __temp.msr"); // clean up musrt0_cleanup(saxParser, startupHandler, msrHandler, dataHandler);