diff --git a/ChangeLog b/ChangeLog index efb4cc68..6920d2ff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,7 @@ NEW any2many: an attempt to write the universial musr-data-file converter. Just NEW musrt0: added the possibility to show the t0 saved in the data file 's'. Furthermore added the option --getT0FromPromptPeak, -g with : will, in non-interactive mode estimate the t0's from the prompt peak and write it into the msr-file (MUSR-133). +FIXED crash of musrfit if a run-data-files is not found (MUSR-176) FIXED corrected time resolution for WKM from (ns) -> (us) FIXED the formating of fixed parameters (step=0) where wrongly formatted (connected to MUSR-167). This should be done correctly now. diff --git a/src/musrfit.cpp b/src/musrfit.cpp index 6ece48c1..c3673cb5 100644 --- a/src/musrfit.cpp +++ b/src/musrfit.cpp @@ -42,6 +42,8 @@ using namespace std; #include #include #include +#include +#include #include "PMusr.h" #include "PStartupHandler.h" @@ -488,7 +490,7 @@ int main(int argc, char *argv[]) } // if present, replace the run title of the with the run title of the FIRST run in the run block of the msr-file - if (title_from_data_file) { + if (title_from_data_file && success) { PMsrRunList *rl = msrHandler->GetMsrRunList(); PRawRunData *rrd = dataHandler->GetRunData(*(rl->at(0).GetRunName())); if (rrd->GetRunTitle()->Length() > 0) @@ -522,10 +524,11 @@ int main(int argc, char *argv[]) } // write log file - if (success && !chisq_only && !fitter->IsScanOnly()) { - status = msrHandler->WriteMsrLogFile(); - if (status != PMUSR_SUCCESS) { - switch (status) { + if (success && !chisq_only) { + if (!fitter->IsScanOnly()) { + status = msrHandler->WriteMsrLogFile(); + if (status != PMUSR_SUCCESS) { + switch (status) { case PMUSR_MSR_LOG_FILE_WRITE_ERROR: cout << endl << "**ERROR** couldn't write mlog-file" << endl << endl; break; @@ -535,6 +538,7 @@ int main(int argc, char *argv[]) default: cout << endl << "**UNKOWN ERROR** when trying to write the mlog-file" << endl << endl; break; + } } } } @@ -552,36 +556,41 @@ int main(int argc, char *argv[]) } // rename MINUIT2.OUTPUT and MINUIT2.root file if wanted - if (keep_mn2_output && !chisq_only && !fitter->IsScanOnly()) { - // 1st rename MINUIT2.OUTPUT - TString fln = TString(filename); - char ext[32]; - strcpy(ext, "-mn2.output"); - fln.ReplaceAll(".msr", 4, ext, strlen(ext)); - gSystem->CopyFile("MINUIT2.OUTPUT", fln.Data(), kTRUE); + if (success) { + if (keep_mn2_output && !chisq_only && !fitter->IsScanOnly()) { + // 1st rename MINUIT2.OUTPUT + TString fln = TString(filename); + char ext[32]; + strcpy(ext, "-mn2.output"); + fln.ReplaceAll(".msr", 4, ext, strlen(ext)); + gSystem->CopyFile("MINUIT2.OUTPUT", fln.Data(), kTRUE); - // 2nd rename MINUIT2.ROOT - fln = TString(filename); - strcpy(ext, "-mn2.root"); - fln.ReplaceAll(".msr", 4, ext, strlen(ext)); - gSystem->CopyFile("MINUIT2.root", fln.Data(), kTRUE); + // 2nd rename MINUIT2.ROOT + fln = TString(filename); + strcpy(ext, "-mn2.root"); + fln.ReplaceAll(".msr", 4, ext, strlen(ext)); + gSystem->CopyFile("MINUIT2.root", fln.Data(), kTRUE); + } } - if (!chisq_only && !fitter->IsScanOnly()) { - // swap msr- and mlog-file - 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"); + if (success) { + if (!chisq_only && !fitter->IsScanOnly()) { + // swap msr- and mlog-file + 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 + TSystemFile tmp("__temp.msr", "./"); + tmp.Delete(); + } } // clean up