various changes: comment and whitespace handling in the msr-files. Some more work in the direction of musrview

This commit is contained in:
nemu
2008-04-11 08:11:28 +00:00
parent 1a68669f8d
commit 100f895667
5 changed files with 47 additions and 64 deletions

View File

@ -52,8 +52,7 @@ short term:
* something is strange with the coordinate system in TPaveText! **CHECK**
* check problem with the mathmore implementation of 1F1(m;n;z)
2008-04-07 cannot reproduce Bastians problem!?!?!
* need a CLEAN concept for handling data/theory generation for kView!!
---------------------
intermediate term:

View File

@ -134,7 +134,7 @@ int PMsrHandler::ReadMsrFile()
current.fLineNo = line_no;
current.fLine = line;
if (line.BeginsWith("#")) { // if the line is not a comment line keep it
if (line.BeginsWith("#") || line.IsWhitespace()) { // if the line is a comment/empty line keep it
fComments.push_back(current);
continue;
}
@ -270,8 +270,6 @@ int PMsrHandler::WriteMsrLogFile()
tokens = 0;
}
//cout << endl << "log file name = " << str.Data() << endl << endl;
ofstream f;
// open mlog-file
@ -281,20 +279,16 @@ int PMsrHandler::WriteMsrLogFile()
}
// write mlog-file
int lineNo = 1;
// write title
f << fTitle.Data();
CheckAndWriteComment(f, ++lineNo);
// f << endl << "###############################################################";
// write fit parameter block
f << endl << "FITPARAMETER";
CheckAndWriteComment(f, ++lineNo);
// f << endl << "# No Name Value Step Pos_Error Boundaries";
f << endl;
CheckAndWriteComment(f, ++lineNo);
PMsrParamList::iterator param_iter;
for (param_iter = fParam.begin(); param_iter != fParam.end(); ++param_iter) {
// parameter no
@ -336,11 +330,10 @@ int PMsrHandler::WriteMsrLogFile()
f << left << param_iter->fUpperBoundary;
f << " ";
}
// terminate line
// terminate parameter line
f << endl;
CheckAndWriteComment(f, ++lineNo);
}
// f << endl << "###############################################################";
// write theory block
PMsrLines::iterator theo_iter;
@ -348,9 +341,6 @@ int PMsrHandler::WriteMsrLogFile()
f << endl << theo_iter->fLine.Data();
CheckAndWriteComment(f, ++lineNo);
}
f << endl;
CheckAndWriteComment(f, ++lineNo);
// f << endl << "###############################################################";
// write functions block
f << endl << "FUNCTIONS";
@ -361,9 +351,6 @@ int PMsrHandler::WriteMsrLogFile()
f << endl << str.Data();
CheckAndWriteComment(f, ++lineNo);
}
f << endl;
CheckAndWriteComment(f, ++lineNo);
// f << endl << "###############################################################";
// write run block
PMsrRunList::iterator run_iter;
@ -586,11 +573,7 @@ int PMsrHandler::WriteMsrLogFile()
f << endl << left << "packing";
f << run_iter->fPacking;
CheckAndWriteComment(f, ++lineNo);
// run block done
f << endl;
CheckAndWriteComment(f, ++lineNo);
}
// f << endl << "###############################################################";
// write command block
f << endl << "COMMANDS";
@ -600,9 +583,6 @@ int PMsrHandler::WriteMsrLogFile()
f << endl << cmd_iter->fLine.Data();
CheckAndWriteComment(f, ++lineNo);
}
f << endl;
CheckAndWriteComment(f, ++lineNo);
// f << endl << "###############################################################";
// write plot block
PMsrPlotList::iterator plot_iter;
@ -646,10 +626,7 @@ int PMsrHandler::WriteMsrLogFile()
f << " " << plot_iter->fYmin << " " << plot_iter->fYmax;
}
CheckAndWriteComment(f, ++lineNo);
f << endl;
CheckAndWriteComment(f, ++lineNo);
}
// f << endl << "###############################################################";
// write statistic block
TDatime dt;
@ -684,10 +661,6 @@ int PMsrHandler::WriteMsrLogFile()
f << endl << stat_iter->fLine.Data();
CheckAndWriteComment(f, ++lineNo);
}
f << endl;
CheckAndWriteComment(f, ++lineNo);
// f << endl << "###############################################################";
// close mlog-file
f.close();

View File

@ -685,8 +685,8 @@ void PMusrCanvas::HandleSingleHistoDataSet(unsigned int runNo, PRunData *data)
// fill histogram
int pack = fMsrHandler->GetMsrRunList()->at(runNo).fPacking;
for (unsigned int i=0; i<data->fValue.size(); i++) {
dataHisto->SetBinContent(i, pack*data->fValue[i]);
dataHisto->SetBinError(i, TMath::Sqrt(pack)*data->fError[i]);
dataHisto->SetBinContent(i, data->fValue[i]);
dataHisto->SetBinError(i, data->fError[i]);
}
}
@ -717,6 +717,8 @@ void PMusrCanvas::HandleSingleHistoDataSet(unsigned int runNo, PRunData *data)
start = data->fTheoryTimeStart;
end = data->fTheoryTimeStart + (data->fTheory.size()-1)*data->fTheoryTimeStep;
cout << endl << ">> start = " << start << ", end = " << end << endl;
// invoke histo
theoHisto = new TH1F(name, name, data->fTheory.size(), start, end);
@ -728,8 +730,8 @@ void PMusrCanvas::HandleSingleHistoDataSet(unsigned int runNo, PRunData *data)
} else { // no lifetimecorrection
// fill histogram
int pack = fMsrHandler->GetMsrRunList()->at(runNo).fPacking;
for (unsigned int i=0; i<data->fValue.size(); i++) {
theoHisto->SetBinContent(i, pack*data->fTheory[i]);
for (unsigned int i=0; i<data->fTheory.size(); i++) {
theoHisto->SetBinContent(i, data->fTheory[i]);
}
}

View File

@ -257,9 +257,38 @@ void PRunSingleHisto::CalcTheory()
}
// calculate theory
unsigned int size;
double start;
double resolution;
double time;
for (unsigned int i=0; i<fData.fValue.size(); i++) {
time = fData.fDataTimeStart + (double)i*fData.fDataTimeStep;
PRawRunData* runData; // only used for kView
unsigned int histoNo; // only used for kView
switch (fHandleTag) {
case kFit:
size = fData.fValue.size();
start = fData.fDataTimeStart;
resolution = fData.fDataTimeStep;
break;
case kView:
runData = fRawData->GetRunData(fRunInfo->fRunName);
if (fRunInfo->fFileFormat.Contains("ppc")) {
histoNo = runData->fDataBin.size()/2 + fRunInfo->fForwardHistoNo-1;
} else {
histoNo = fRunInfo->fForwardHistoNo-1;
}
size = runData->fDataBin[histoNo].size();
start = -fT0s[0]*fTimeResolution;
resolution = fTimeResolution;
fData.fTheoryTimeStart = start;
fData.fTheoryTimeStep = resolution;
break;
case kEmpty:
default:
size = -1;
break;
}
for (unsigned int i=0; i<size; i++) {
time = start + (double)i*resolution;
fData.fTheory.push_back(N0*TMath::Exp(-time/tau)*(1+fTheory->Func(time, par, fFuncValues))+bkg);
}
@ -382,7 +411,7 @@ bool PRunSingleHisto::PrepareData()
}
// everything looks fine, hence fill data set
double value = 0.0;
double value = 0.0;
// data start at data_start-t0
// time shifted so that packing is included correctly, i.e. t0 == t0 after packing
fData.fDataTimeStart = fTimeResolution*(((double)start-t0)+(double)fRunInfo->fPacking/2.0);
@ -412,28 +441,8 @@ bool PRunSingleHisto::PrepareData()
}
// fill theory vector for kView
if (kView) {
// feed the parameter vector
std::vector<double> par;
PMsrParamList *paramList = fMsrInfo->GetMsrParamList();
for (unsigned int i=0; i<paramList->size(); i++)
par.push_back((*paramList)[i].fValue);
fData.fTheoryTimeStart = -t0*fTimeResolution;
fData.fTheoryTimeStep = fTimeResolution;
for (unsigned int i=0; i<runData->fDataBin[histoNo].size(); i++) {
if ((int)i-(int)t0 < 0) {
fData.fTheory.push_back(0.0);
} else {
time = fData.fTheoryTimeStart + i*fTimeResolution;
value = fTheory->Func(time, par, fFuncValues);
fData.fTheory.push_back(value);
}
}
// clean up
par.clear();
if (fHandleTag == kView) {
CalcTheory();
}
return true;

View File

@ -55,7 +55,7 @@ using namespace std;
void musrview_syntax()
{
cout << endl << "usage: musrview <msr-file> | --version | --help";
cout << endl << " <msr-file>: msr input file";
cout << endl << " <msr-file>: msr/mlog input file";
cout << endl << " 'musrview <msr-file>' will execute msrfit";
cout << endl << " 'musrview' or 'msrfit --help' will show this help";
cout << endl << " 'musrview --version' will print the msrfit version";
@ -81,9 +81,9 @@ int main(int argc, char *argv[])
} else if (strstr(argv[1], "--help")) {
show_syntax = true;
} else {
// check if filename has extension msr
if (!strstr(argv[1], ".msr")) {
cout << endl << "**ERROR** " << argv[1] << " is not a msr-file!" << endl;
// 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;
show_syntax = true;
}
}