From 5497ca2c2bf43eb0216a0ef054f9846376193085 Mon Sep 17 00:00:00 2001 From: nemu Date: Wed, 8 Apr 2009 05:41:58 +0000 Subject: [PATCH] added swap msr-, mlog-file switch --- src/musrfit.cpp | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/musrfit.cpp b/src/musrfit.cpp index 7e571c68..1d81920d 100644 --- a/src/musrfit.cpp +++ b/src/musrfit.cpp @@ -57,17 +57,21 @@ using namespace std; */ void musrfit_syntax() { - cout << endl << "usage: musrfit [ [-k, --keep-mn2-ouput] [-c, --chisq-only] [--debug] [--dump ]] | --version | --help"; + cout << endl << "usage: musrfit [ [-k, --keep-mn2-ouput] [-c, --chisq-only]"; + cout << endl << " [-s, --swap-msr-mlog] [--debug] [--dump ]] |"; + cout << endl << " --version | --help"; cout << endl << " : msr input file"; cout << endl << " 'musrfit ' will execute musrfit"; cout << endl << " 'musrfit' or 'musrfit --help' will show this help"; cout << endl << " 'musrfit --version' will print the musrfit version"; cout << endl << " -k, --keep-mn2-output: will rename the files MINUIT2.OUTPUT and "; - cout << endl << " MINUIT2.root to -mn2.output and -mn2.root, repectively,"; + cout << endl << " MINUIT2.root to -mn2.output and -mn2.root,"; + cout << endl << " respectively,"; cout << endl << " e.g. = 147.msr -> 147-mn2.output, 147-mn2.root"; cout << endl << " -c, --chisq-only: instead of fitting the data, chisq is just calculated"; cout << endl << " once and the result is set to the stdout. This feature is useful"; cout << endl << " to adjust initial parameters."; + cout << endl << " -s, --swap-msr-mlog: will swap msr-, mlog-file at the end of execution"; cout << endl << " --debug is used to print additional infos"; cout << endl << " --dump is writing a data file with the fit data and the theory"; cout << endl << " can be 'ascii', 'root'"; @@ -483,6 +487,7 @@ int main(int argc, char *argv[]) bool debug = false; bool keep_mn2_output = false; bool chisq_only = false; + bool swap_msr_mlog = false; TString dump(""); char filename[256]; @@ -527,6 +532,8 @@ int main(int argc, char *argv[]) show_syntax = true; break; } + } else if (!strcmp(argv[i], "-s") || !strcmp(argv[i], "--swap-msr-mlog")) { + swap_msr_mlog = true; } else { show_syntax = true; break; @@ -679,6 +686,23 @@ int main(int argc, char *argv[]) gSystem->CopyFile("MINUIT2.root", fln.Data(), kTRUE); } + // swap msr-, mlog-file if wished + if (swap_msr_mlog) { + cout << endl << ">> swapping msr-, mlog-file ..." << endl; + // 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 if (startupHandler) { delete startupHandler;