From c8fc4a95feeea1ed9d924f261f4ac9b50f2911d8 Mon Sep 17 00:00:00 2001 From: nemu Date: Thu, 25 Jun 2009 14:15:00 +0000 Subject: [PATCH] option "title from data file" added to musrfit --- src/classes/PMsrHandler.cpp | 15 +++++---------- src/classes/PRunDataHandler.cpp | 6 +++++- src/include/PMsrHandler.h | 3 ++- src/musrfit.cpp | 19 +++++++++++++++++-- 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/classes/PMsrHandler.cpp b/src/classes/PMsrHandler.cpp index d7419b33..de770445 100644 --- a/src/classes/PMsrHandler.cpp +++ b/src/classes/PMsrHandler.cpp @@ -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> 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"); diff --git a/src/classes/PRunDataHandler.cpp b/src/classes/PRunDataHandler.cpp index 2866e0cf..ee7eebca 100644 --- a/src/classes/PRunDataHandler.cpp +++ b/src/classes/PRunDataHandler.cpp @@ -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; } diff --git a/src/include/PMsrHandler.h b/src/include/PMsrHandler.h index 94ffeeb1..84f71959 100644 --- a/src/include/PMsrHandler.h +++ b/src/include/PMsrHandler.h @@ -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 diff --git a/src/musrfit.cpp b/src/musrfit.cpp index d9d4ecba..2b7ab452 100644 --- a/src/musrfit.cpp +++ b/src/musrfit.cpp @@ -57,8 +57,8 @@ using namespace std; */ void musrfit_syntax() { - cout << endl << "usage: musrfit [ [-k, --keep-mn2-ouput] [-c, --chisq-only] [--dump ] |"; - cout << endl << " --version | --help"; + cout << endl << "usage: musrfit [ [-k, --keep-mn2-ouput] [-c, --chisq-only] [-t, --title-from-data-file]"; + cout << endl << " [--dump ] | --version | --help"; cout << endl << " : msr input file"; cout << endl << " 'musrfit ' 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 run title by the"; + cout << endl << " run title of the FIRST run of the run block, if a run title"; + cout << endl << " is present in the data file."; cout << endl << " --dump is writing a data file with the fit data and the theory"; cout << endl << " can be 'ascii', 'root'" << endl; cout << endl << " At the end of a fit, musrfit writes the fit results into an 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 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) {