option "title from data file" added to musrfit

This commit is contained in:
nemu 2009-06-25 14:15:00 +00:00
parent 2114c1670c
commit c8fc4a95fe
4 changed files with 29 additions and 14 deletions

View File

@ -87,7 +87,6 @@ PMsrHandler::PMsrHandler(char *fileName) : fFileName(fileName)
*/
PMsrHandler::~PMsrHandler()
{
fComments.clear();
fParam.clear();
fTheory.clear();
fFunctions.clear();
@ -166,8 +165,7 @@ int PMsrHandler::ReadMsrFile()
current.fLineNo = line_no;
current.fLine = line;
if (line.BeginsWith("#") || line.IsWhitespace()) { // if the line is a comment/empty line keep it
fComments.push_back(current);
if (line.BeginsWith("#") || line.IsWhitespace()) { // if the line is a comment/empty go to the next one
continue;
}
@ -297,12 +295,6 @@ int PMsrHandler::ReadMsrFile()
plot.clear();
statistic.clear();
// cout << endl << "# Comments: ";
// for (unsigned int i=0; i<fComments.size(); i++) {
// cout << endl << fComments[i].fLineNo << " " << fComments[i].fLine.Data();
// }
// cout << endl;
/*
cout << endl << ">> FOURIER Block:";
cout << endl << ">> Fourier Block Present : " << fFourier.fFourierBlockPresent;
@ -410,7 +402,10 @@ int PMsrHandler::WriteMsrLogFile(const bool messages)
// handle blocks
switch (tag) {
case MSR_TAG_TITLE:
fout << str.Data() << endl;
if (lineNo == 1)
fout << fTitle.Data() << endl;
else
fout << str.Data() << endl;
break;
case MSR_TAG_FITPARAMETER:
tokens = str.Tokenize(" \t");

View File

@ -389,6 +389,10 @@ bool PRunDataHandler::ReadRootFile(bool notPostPileup)
return false;
}
// get run title
TObjString ostr = runHeader->GetRunTitle();
runData.fRunTitle = ostr.GetString();
// get temperature
runData.fTemp = runHeader->GetSampleTemperature();
@ -490,7 +494,7 @@ bool PRunDataHandler::ReadRootFile(bool notPostPileup)
*/
bool PRunDataHandler::ReadNexusFile()
{
cout << endl << "PRunDataHandler::ReadNexusFile(): Sorry, not yet implemented ...";
cout << endl << "PRunDataHandler::ReadNexusFile(): Sorry, not yet implemented, ask Alex Amato ...";
return false;
}

View File

@ -68,6 +68,8 @@ class PMsrHandler
virtual unsigned int GetNoOfParams() { return fParam.size(); }
virtual const TString& GetFileName() const { return fFileName; }
virtual void SetMsrTitle(const TString &title) { fTitle = title; }
virtual bool SetMsrParamValue(unsigned int i, double value);
virtual bool SetMsrParamStep(unsigned int i, double value);
virtual bool SetMsrParamPosErrorPresent(unsigned int i, bool value);
@ -96,7 +98,6 @@ class PMsrHandler
virtual bool CheckFuncs();
private:
PMsrLines fComments; ///< holds the comments of the msr-file
TString fFileName; ///< file name of the msr-file
TString fMsrFileDirectoryPath; ///< msr-file directory path
TString fTitle; ///< holds the title string of the msr-file

View File

@ -57,8 +57,8 @@ using namespace std;
*/
void musrfit_syntax()
{
cout << endl << "usage: musrfit [<msr-file> [-k, --keep-mn2-ouput] [-c, --chisq-only] [--dump <type>] |";
cout << endl << " --version | --help";
cout << endl << "usage: musrfit [<msr-file> [-k, --keep-mn2-ouput] [-c, --chisq-only] [-t, --title-from-data-file]";
cout << endl << " [--dump <type>] | --version | --help";
cout << endl << " <msr-file>: msr input file";
cout << endl << " 'musrfit <msr-file>' will execute musrfit";
cout << endl << " 'musrfit' or 'musrfit --help' will show this help";
@ -70,6 +70,9 @@ void musrfit_syntax()
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 << " -t, --title-from-data-file: will replace the <msr-file> run title by the";
cout << endl << " run title of the FIRST run of the <msr-file> run block, if a run title";
cout << endl << " is present in the data file.";
cout << endl << " --dump <type> is writing a data file with the fit data and the theory";
cout << endl << " <type> can be 'ascii', 'root'" << endl;
cout << endl << " At the end of a fit, musrfit writes the fit results into an <mlog-file> and";
@ -325,6 +328,8 @@ int main(int argc, char *argv[])
int status;
bool keep_mn2_output = false;
bool chisq_only = false;
bool title_from_data_file = false;
TString dump("");
char filename[1024];
@ -359,6 +364,8 @@ int main(int argc, char *argv[])
keep_mn2_output = true;
} else if (!strcmp(argv[i], "-c") || !strcmp(argv[i], "--chisq-only")) {
chisq_only = true;
} else if (!strcmp(argv[i], "-t") || !strcmp(argv[i], "--title-from-data-file")) {
title_from_data_file = true;
} else if (!strcmp(argv[i], "--dump")) {
if (i<argc-1) {
dump = TString(argv[i+1]);
@ -446,6 +453,14 @@ int main(int argc, char *argv[])
cout << endl << "**ERROR** Couldn't read all data files, will quit ..." << endl;
}
// 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) {
PMsrRunList *rl = msrHandler->GetMsrRunList();
PRawRunData *rrd = dataHandler->GetRunData(rl->at(0).fRunName[0]);
if (rrd->fRunTitle.Length() > 0)
msrHandler->SetMsrTitle(rrd->fRunTitle);
}
// generate the necessary fit histogramms for the fit
PRunListCollection *runListCollection = 0;
if (success) {