crash of musrfit if a run-data-files is not found (MUSR-176)

This commit is contained in:
nemu 2011-02-14 20:18:45 +00:00
parent fe38ded491
commit 7fc76c7cb1
2 changed files with 42 additions and 32 deletions

View File

@ -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 NEW musrt0: added the possibility to show the t0 saved in the data file 's'. Furthermore added the option
--getT0FromPromptPeak, -g with <firstGoodBinOffset>: will, in non-interactive mode estimate the t0's from --getT0FromPromptPeak, -g with <firstGoodBinOffset>: will, in non-interactive mode estimate the t0's from
the prompt peak and write it into the msr-file (MUSR-133). 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 corrected time resolution for WKM from (ns) -> (us)
FIXED the formating of fixed parameters (step=0) where wrongly formatted (connected to MUSR-167). This FIXED the formating of fixed parameters (step=0) where wrongly formatted (connected to MUSR-167). This
should be done correctly now. should be done correctly now.

View File

@ -42,6 +42,8 @@ using namespace std;
#include <TFile.h> #include <TFile.h>
#include <TCanvas.h> #include <TCanvas.h>
#include <TH1.h> #include <TH1.h>
#include <TSystem.h>
#include <TSystemFile.h>
#include "PMusr.h" #include "PMusr.h"
#include "PStartupHandler.h" #include "PStartupHandler.h"
@ -488,7 +490,7 @@ int main(int argc, char *argv[])
} }
// if present, replace the run title of the <msr-file> with the run title of the FIRST run in the run block of the msr-file // if present, replace the run title of the <msr-file> 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(); PMsrRunList *rl = msrHandler->GetMsrRunList();
PRawRunData *rrd = dataHandler->GetRunData(*(rl->at(0).GetRunName())); PRawRunData *rrd = dataHandler->GetRunData(*(rl->at(0).GetRunName()));
if (rrd->GetRunTitle()->Length() > 0) if (rrd->GetRunTitle()->Length() > 0)
@ -522,10 +524,11 @@ int main(int argc, char *argv[])
} }
// write log file // write log file
if (success && !chisq_only && !fitter->IsScanOnly()) { if (success && !chisq_only) {
status = msrHandler->WriteMsrLogFile(); if (!fitter->IsScanOnly()) {
if (status != PMUSR_SUCCESS) { status = msrHandler->WriteMsrLogFile();
switch (status) { if (status != PMUSR_SUCCESS) {
switch (status) {
case PMUSR_MSR_LOG_FILE_WRITE_ERROR: case PMUSR_MSR_LOG_FILE_WRITE_ERROR:
cout << endl << "**ERROR** couldn't write mlog-file" << endl << endl; cout << endl << "**ERROR** couldn't write mlog-file" << endl << endl;
break; break;
@ -535,6 +538,7 @@ int main(int argc, char *argv[])
default: default:
cout << endl << "**UNKOWN ERROR** when trying to write the mlog-file" << endl << endl; cout << endl << "**UNKOWN ERROR** when trying to write the mlog-file" << endl << endl;
break; break;
}
} }
} }
} }
@ -552,36 +556,41 @@ int main(int argc, char *argv[])
} }
// rename MINUIT2.OUTPUT and MINUIT2.root file if wanted // rename MINUIT2.OUTPUT and MINUIT2.root file if wanted
if (keep_mn2_output && !chisq_only && !fitter->IsScanOnly()) { if (success) {
// 1st rename MINUIT2.OUTPUT if (keep_mn2_output && !chisq_only && !fitter->IsScanOnly()) {
TString fln = TString(filename); // 1st rename MINUIT2.OUTPUT
char ext[32]; TString fln = TString(filename);
strcpy(ext, "-mn2.output"); char ext[32];
fln.ReplaceAll(".msr", 4, ext, strlen(ext)); strcpy(ext, "-mn2.output");
gSystem->CopyFile("MINUIT2.OUTPUT", fln.Data(), kTRUE); fln.ReplaceAll(".msr", 4, ext, strlen(ext));
gSystem->CopyFile("MINUIT2.OUTPUT", fln.Data(), kTRUE);
// 2nd rename MINUIT2.ROOT // 2nd rename MINUIT2.ROOT
fln = TString(filename); fln = TString(filename);
strcpy(ext, "-mn2.root"); strcpy(ext, "-mn2.root");
fln.ReplaceAll(".msr", 4, ext, strlen(ext)); fln.ReplaceAll(".msr", 4, ext, strlen(ext));
gSystem->CopyFile("MINUIT2.root", fln.Data(), kTRUE); gSystem->CopyFile("MINUIT2.root", fln.Data(), kTRUE);
}
} }
if (!chisq_only && !fitter->IsScanOnly()) { if (success) {
// swap msr- and mlog-file if (!chisq_only && !fitter->IsScanOnly()) {
cout << endl << ">> swapping msr-, mlog-file ..." << endl; // swap msr- and mlog-file
// copy msr-file -> __temp.msr cout << endl << ">> swapping msr-, mlog-file ..." << endl;
gSystem->CopyFile(filename, "__temp.msr", kTRUE); // copy msr-file -> __temp.msr
// copy mlog-file -> msr-file gSystem->CopyFile(filename, "__temp.msr", kTRUE);
TString fln = TString(filename); // copy mlog-file -> msr-file
char ext[32]; TString fln = TString(filename);
strcpy(ext, ".mlog"); char ext[32];
fln.ReplaceAll(".msr", 4, ext, strlen(ext)); strcpy(ext, ".mlog");
gSystem->CopyFile(fln.Data(), filename, kTRUE); fln.ReplaceAll(".msr", 4, ext, strlen(ext));
// copy __temp.msr -> mlog-file gSystem->CopyFile(fln.Data(), filename, kTRUE);
gSystem->CopyFile("__temp.msr", fln.Data(), kTRUE); // copy __temp.msr -> mlog-file
// delete __temp.msr gSystem->CopyFile("__temp.msr", fln.Data(), kTRUE);
gSystem->Exec("rm __temp.msr"); // delete __temp.msr
TSystemFile tmp("__temp.msr", "./");
tmp.Delete();
}
} }
// clean up // clean up