fixed handling of new mlog file writer for musrt0

This commit is contained in:
nemu
2009-05-22 11:39:47 +00:00
parent c89026c018
commit 5d99f6cf8c
4 changed files with 43 additions and 24 deletions

View File

@ -325,7 +325,7 @@ cout << endl;
/**
* <p>
*/
int PMsrHandler::WriteMsrLogFile(TString ext)
int PMsrHandler::WriteMsrLogFile(const bool messages)
{
const unsigned int prec = 6; // output precision for float/doubles
@ -350,14 +350,8 @@ 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";
ifstream fin;
ofstream fout;
@ -826,9 +820,11 @@ int PMsrHandler::WriteMsrLogFile(TString ext)
str += ", chisq/NDF = ";
str += fStatistic.fMin / fStatistic.fNdf;
fout << str.Data() << endl;
if (messages)
cout << endl << str.Data() << endl;
} else {
fout << "*** FIT DID NOT CONVERGE ***" << endl;
if (messages)
cout << endl << "*** FIT DID NOT CONVERGE ***" << endl;
}
} else if (sstr.BeginsWith("maxLH")) {
@ -840,9 +836,11 @@ int PMsrHandler::WriteMsrLogFile(TString ext)
str += ", maxLH/NDF = ";
str += fStatistic.fMin / fStatistic.fNdf;
fout << str.Data() << endl;
if (messages)
cout << endl << str.Data() << endl;
} else {
fout << "*** FIT DID NOT CONVERGE ***" << endl;
if (messages)
cout << endl << "*** FIT DID NOT CONVERGE ***" << endl;
}
} else if (sstr.BeginsWith("*** FIT DID NOT CONVERGE ***")) {
@ -855,6 +853,7 @@ int PMsrHandler::WriteMsrLogFile(TString ext)
str += ", chisq/NDF = ";
str += fStatistic.fMin / fStatistic.fNdf;
fout << str.Data() << endl;
if (messages)
cout << endl << str.Data() << endl;
} else { // max. log. liklihood
str = " maxLH = ";
@ -864,10 +863,12 @@ int PMsrHandler::WriteMsrLogFile(TString ext)
str += ", maxLH/NDF = ";
str += fStatistic.fMin / fStatistic.fNdf;
fout << str.Data() << endl;
if (messages)
cout << endl << str.Data() << endl;
}
} else {
fout << "*** FIT DID NOT CONVERGE ***" << endl;
if (messages)
cout << endl << "*** FIT DID NOT CONVERGE ***" << endl;
}
} else {

View File

@ -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; }

View File

@ -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) {

View File

@ -39,6 +39,7 @@ using namespace std;
#include <TApplication.h>
#include <TSAXParser.h>
#include <TROOT.h>
#include <TSystem.h>
#include "PMusr.h"
#include "PStartupHandler.h"
@ -55,7 +56,7 @@ using namespace std;
void musrt0_syntax()
{
cout << endl << "usage: musrt0 <msr-file> | --version | --help";
cout << endl << " <msr-file>: msr/mlog input file";
cout << endl << " <msr-file>: msr input file";
cout << endl << " 'musrt0 <msr-file>' 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);