iterator's -> index + minor bug fix

This commit is contained in:
nemu 2008-04-11 10:57:17 +00:00
parent 100f895667
commit 50a7bdf0a9

View File

@ -289,56 +289,55 @@ int PMsrHandler::WriteMsrLogFile()
f << endl << "FITPARAMETER"; f << endl << "FITPARAMETER";
CheckAndWriteComment(f, ++lineNo); CheckAndWriteComment(f, ++lineNo);
f << endl; f << endl;
PMsrParamList::iterator param_iter; for (unsigned int i=0; i<fParam.size(); i++) {
for (param_iter = fParam.begin(); param_iter != fParam.end(); ++param_iter) {
// parameter no // parameter no
f.width(9); f.width(9);
f << right << param_iter->fNo; f << right << fParam[i].fNo;
f << " "; f << " ";
// parameter name // parameter name
f.width(11); f.width(11);
f << left << param_iter->fName.Data(); f << left << fParam[i].fName.Data();
f << " "; f << " ";
// value of the parameter // value of the parameter
f.width(9); f.width(9);
f.precision(prec); f.precision(prec);
f << left << param_iter->fValue; f << left << fParam[i].fValue;
f << " "; f << " ";
// value of step/error/neg.error // value of step/error/neg.error
f.width(11); f.width(11);
f.precision(prec); f.precision(prec);
f << left << param_iter->fStep; f << left << fParam[i].fStep;
f << " "; f << " ";
f.width(11); f.width(11);
f.precision(prec); f.precision(prec);
if ((param_iter->fNoOfParams == 5) || (param_iter->fNoOfParams == 7)) // pos. error given if ((fParam[i].fNoOfParams == 5) || (fParam[i].fNoOfParams == 7)) // pos. error given
if (param_iter->fPosErrorPresent) // pos error is a number if (fParam[i].fPosErrorPresent) // pos error is a number
f << left << param_iter->fPosError; f << left << fParam[i].fPosError;
else // pos error is a none else // pos error is a none
f << left << "none"; f << left << "none";
else // no pos. error else // no pos. error
f << left << "none"; f << left << "none";
f << " "; f << " ";
// boundaries // boundaries
if (param_iter->fNoOfParams > 5) { if (fParam[i].fNoOfParams > 5) {
f.width(7); f.width(7);
f.precision(prec); f.precision(prec);
f << left << param_iter->fLowerBoundary; f << left << fParam[i].fLowerBoundary;
f << " "; f << " ";
f.width(7); f.width(7);
f.precision(prec); f.precision(prec);
f << left << param_iter->fUpperBoundary; f << left << fParam[i].fUpperBoundary;
f << " "; f << " ";
} }
// terminate parameter line // terminate parameter line if not the last line
f << endl; if (i != fParam.size()-1)
f << endl;
CheckAndWriteComment(f, ++lineNo); CheckAndWriteComment(f, ++lineNo);
} }
// write theory block // write theory block
PMsrLines::iterator theo_iter; for (unsigned int i=0; i<fTheory.size(); i++) {
for (theo_iter = fTheory.begin(); theo_iter != fTheory.end(); ++theo_iter) { f << endl << fTheory[i].fLine.Data();
f << endl << theo_iter->fLine.Data();
CheckAndWriteComment(f, ++lineNo); CheckAndWriteComment(f, ++lineNo);
} }
@ -353,23 +352,22 @@ int PMsrHandler::WriteMsrLogFile()
} }
// write run block // write run block
PMsrRunList::iterator run_iter; for (unsigned int i=0; i<fRuns.size(); i++) {
for (run_iter = fRuns.begin(); run_iter != fRuns.end(); ++run_iter) {
// run header // run header
f << endl << "RUN " << run_iter->fRunName.Data() << " "; f << endl << "RUN " << fRuns[i].fRunName.Data() << " ";
str = run_iter->fBeamline; str = fRuns[i].fBeamline;
str.ToUpper(); str.ToUpper();
f << str.Data() << " "; f << str.Data() << " ";
str = run_iter->fInstitute; str = fRuns[i].fInstitute;
str.ToUpper(); str.ToUpper();
f << str.Data() << " "; f << str.Data() << " ";
str = run_iter->fFileFormat; str = fRuns[i].fFileFormat;
str.ToUpper(); str.ToUpper();
f << str.Data() << " (name beamline institute data-file-format)"; f << str.Data() << " (name beamline institute data-file-format)";
CheckAndWriteComment(f, ++lineNo); CheckAndWriteComment(f, ++lineNo);
// fittype // fittype
f.width(16); f.width(16);
switch (run_iter->fFitType) { switch (fRuns[i].fFitType) {
case MSR_FITTYPE_SINGLE_HISTO: case MSR_FITTYPE_SINGLE_HISTO:
f << endl << left << "fittype" << MSR_FITTYPE_SINGLE_HISTO << " (single histogram fit)"; f << endl << left << "fittype" << MSR_FITTYPE_SINGLE_HISTO << " (single histogram fit)";
break; break;
@ -387,219 +385,216 @@ int PMsrHandler::WriteMsrLogFile()
} }
CheckAndWriteComment(f, ++lineNo); CheckAndWriteComment(f, ++lineNo);
// rrffrequency // rrffrequency
if (run_iter->fRRFFreq != -1.0) { if (fRuns[i].fRRFFreq != -1.0) {
f.width(16); f.width(16);
f << endl << left << "rrffrequency"; f << endl << left << "rrffrequency";
f.precision(prec); f.precision(prec);
f << run_iter->fRRFFreq; f << fRuns[i].fRRFFreq;
CheckAndWriteComment(f, ++lineNo); CheckAndWriteComment(f, ++lineNo);
} }
// rrfpacking // rrfpacking
if (run_iter->fRRFPacking != -1) { if (fRuns[i].fRRFPacking != -1) {
f.width(16); f.width(16);
f << endl << left << "rrfpacking"; f << endl << left << "rrfpacking";
f.precision(prec); f.precision(prec);
f << run_iter->fRRFPacking; f << fRuns[i].fRRFPacking;
CheckAndWriteComment(f, ++lineNo); CheckAndWriteComment(f, ++lineNo);
} }
// alpha // alpha
if (run_iter->fAlphaParamNo != -1) { if (fRuns[i].fAlphaParamNo != -1) {
f.width(16); f.width(16);
f << endl << left << "alpha"; f << endl << left << "alpha";
f << run_iter->fAlphaParamNo; f << fRuns[i].fAlphaParamNo;
CheckAndWriteComment(f, ++lineNo); CheckAndWriteComment(f, ++lineNo);
} }
// beta // beta
if (run_iter->fBetaParamNo != -1) { if (fRuns[i].fBetaParamNo != -1) {
f.width(16); f.width(16);
f << endl << left << "beta"; f << endl << left << "beta";
f << run_iter->fBetaParamNo; f << fRuns[i].fBetaParamNo;
CheckAndWriteComment(f, ++lineNo); CheckAndWriteComment(f, ++lineNo);
} }
// alpha2 // alpha2
if (run_iter->fAlpha2ParamNo != -1) { if (fRuns[i].fAlpha2ParamNo != -1) {
f.width(16); f.width(16);
f << endl << left << "alpha2"; f << endl << left << "alpha2";
f << run_iter->fAlpha2ParamNo; f << fRuns[i].fAlpha2ParamNo;
CheckAndWriteComment(f, ++lineNo); CheckAndWriteComment(f, ++lineNo);
} }
// beta2 // beta2
if (run_iter->fBeta2ParamNo != -1) { if (fRuns[i].fBeta2ParamNo != -1) {
f.width(16); f.width(16);
f << endl << left << "beta2"; f << endl << left << "beta2";
f << run_iter->fBeta2ParamNo; f << fRuns[i].fBeta2ParamNo;
CheckAndWriteComment(f, ++lineNo); CheckAndWriteComment(f, ++lineNo);
} }
// norm // norm
if (run_iter->fNormParamNo != -1) { if (fRuns[i].fNormParamNo != -1) {
f.width(16); f.width(16);
f << endl << left << "norm"; f << endl << left << "norm";
// check if norm is give as a function // check if norm is give as a function
if (run_iter->fNormParamNo >= MSR_PARAM_FUN_OFFSET) if (fRuns[i].fNormParamNo >= MSR_PARAM_FUN_OFFSET)
f << "fun" << run_iter->fNormParamNo-MSR_PARAM_FUN_OFFSET; f << "fun" << fRuns[i].fNormParamNo-MSR_PARAM_FUN_OFFSET;
else else
f << run_iter->fNormParamNo; f << fRuns[i].fNormParamNo;
CheckAndWriteComment(f, ++lineNo); CheckAndWriteComment(f, ++lineNo);
} }
// backgr.fit // backgr.fit
if (run_iter->fBkgFitParamNo != -1) { if (fRuns[i].fBkgFitParamNo != -1) {
f.width(16); f.width(16);
f << endl << left << "backgr.fit"; f << endl << left << "backgr.fit";
f << run_iter->fBkgFitParamNo; f << fRuns[i].fBkgFitParamNo;
CheckAndWriteComment(f, ++lineNo); CheckAndWriteComment(f, ++lineNo);
} }
// rphase // rphase
if (run_iter->fPhaseParamNo != -1) { if (fRuns[i].fPhaseParamNo != -1) {
f.width(16); f.width(16);
f << endl << left << "rphase"; f << endl << left << "rphase";
f << run_iter->fPhaseParamNo; f << fRuns[i].fPhaseParamNo;
CheckAndWriteComment(f, ++lineNo); CheckAndWriteComment(f, ++lineNo);
} }
// lifetime // lifetime
if (run_iter->fLifetimeParamNo != -1) { if (fRuns[i].fLifetimeParamNo != -1) {
f.width(16); f.width(16);
f << endl << left << "lifetime"; f << endl << left << "lifetime";
f << run_iter->fLifetimeParamNo; f << fRuns[i].fLifetimeParamNo;
CheckAndWriteComment(f, ++lineNo); CheckAndWriteComment(f, ++lineNo);
} }
// lifetimecorrection // lifetimecorrection
if ((run_iter->fLifetimeCorrection) && (run_iter->fFitType == MSR_FITTYPE_SINGLE_HISTO)) { if ((fRuns[i].fLifetimeCorrection) && (fRuns[i].fFitType == MSR_FITTYPE_SINGLE_HISTO)) {
f << endl << "lifetimecorrection"; f << endl << "lifetimecorrection";
CheckAndWriteComment(f, ++lineNo); CheckAndWriteComment(f, ++lineNo);
} }
// map // map
PIntVector::iterator map_iter;
f << endl << "map "; f << endl << "map ";
for (map_iter = run_iter->fMap.begin(); map_iter != run_iter->fMap.end(); ++map_iter) { for (unsigned int j=0; j>fRuns[i].fMap.size(); j++) {
f.width(5); f.width(5);
f << right << *map_iter; f << right << fRuns[i].fMap[j];
} }
// if there are less maps then 10 fill with zeros // if there are less maps then 10 fill with zeros
if (run_iter->fMap.size() < 10) { if (fRuns[i].fMap.size() < 10) {
for (int i=run_iter->fMap.size(); i<10; i++) for (int j=fRuns[i].fMap.size(); j<10; j++)
f << " 0"; f << " 0";
} }
CheckAndWriteComment(f, ++lineNo); CheckAndWriteComment(f, ++lineNo);
// forward // forward
if (run_iter->fForwardHistoNo != -1) { if (fRuns[i].fForwardHistoNo != -1) {
f.width(16); f.width(16);
f << endl << left << "forward"; f << endl << left << "forward";
f << run_iter->fForwardHistoNo; f << fRuns[i].fForwardHistoNo;
CheckAndWriteComment(f, ++lineNo); CheckAndWriteComment(f, ++lineNo);
} }
// backward // backward
if (run_iter->fBackwardHistoNo != -1) { if (fRuns[i].fBackwardHistoNo != -1) {
f.width(16); f.width(16);
f << endl << left << "backward"; f << endl << left << "backward";
f << run_iter->fBackwardHistoNo; f << fRuns[i].fBackwardHistoNo;
CheckAndWriteComment(f, ++lineNo); CheckAndWriteComment(f, ++lineNo);
} }
// right // right
if (run_iter->fRightHistoNo != -1) { if (fRuns[i].fRightHistoNo != -1) {
f.width(16); f.width(16);
f << endl << left << "right"; f << endl << left << "right";
f << run_iter->fRightHistoNo; f << fRuns[i].fRightHistoNo;
CheckAndWriteComment(f, ++lineNo); CheckAndWriteComment(f, ++lineNo);
} }
// left // left
if (run_iter->fLeftHistoNo != -1) { if (fRuns[i].fLeftHistoNo != -1) {
f.width(16); f.width(16);
f << endl << left << "left"; f << endl << left << "left";
f << run_iter->fLeftHistoNo; f << fRuns[i].fLeftHistoNo;
CheckAndWriteComment(f, ++lineNo); CheckAndWriteComment(f, ++lineNo);
} }
// backgr.fix // backgr.fix
if (!isnan(run_iter->fBkgFix[0])) { if (!isnan(fRuns[i].fBkgFix[0])) {
f.width(15); f.width(15);
f << endl << left << "backgr.fix"; f << endl << left << "backgr.fix";
for (int i=0; i<2; i++) { for (int i=0; i<2; i++) {
f.precision(prec); f.precision(prec);
f.width(12); f.width(12);
f << left << run_iter->fBkgFix[i]; f << left << fRuns[i].fBkgFix[i];
} }
CheckAndWriteComment(f, ++lineNo); CheckAndWriteComment(f, ++lineNo);
} }
// background // background
if (run_iter->fBkgRange[0] != -1) { if (fRuns[i].fBkgRange[0] != -1) {
f.width(16); f.width(16);
f << endl << "background"; f << endl << "background";
for (int i=0; i<4; i++) { for (int i=0; i<4; i++) {
if (run_iter->fBkgRange[i] == -1) if (fRuns[i].fBkgRange[i] == -1)
break; break;
f.width(8); f.width(8);
f << left << run_iter->fBkgRange[i]; f << left << fRuns[i].fBkgRange[i];
} }
CheckAndWriteComment(f, ++lineNo); CheckAndWriteComment(f, ++lineNo);
} }
// data // data
if (run_iter->fDataRange[0] != -1) { if (fRuns[i].fDataRange[0] != -1) {
f.width(16); f.width(16);
f << endl << "data"; f << endl << "data";
for (int i=0; i<4; i++) { for (int i=0; i<4; i++) {
if (run_iter->fDataRange[i] == -1) if (fRuns[i].fDataRange[i] == -1)
break; break;
f.width(8); f.width(8);
f << left << run_iter->fDataRange[i]; f << left << fRuns[i].fDataRange[i];
} }
CheckAndWriteComment(f, ++lineNo); CheckAndWriteComment(f, ++lineNo);
} }
// t0 // t0
if (run_iter->fT0[0] != -1) { if (fRuns[i].fT0[0] != -1) {
f.width(16); f.width(16);
f << endl << "t0"; f << endl << "t0";
for (int i=0; i<2; i++) { for (int i=0; i<2; i++) {
if (run_iter->fT0[i] == -1) if (fRuns[i].fT0[i] == -1)
break; break;
f.width(8); f.width(8);
f << left << run_iter->fT0[i]; f << left << fRuns[i].fT0[i];
} }
CheckAndWriteComment(f, ++lineNo); CheckAndWriteComment(f, ++lineNo);
} }
// fit // fit
if (run_iter->fFitRange[0] != -1) { if (fRuns[i].fFitRange[0] != -1) {
f.width(16); f.width(16);
f << endl << "fit"; f << endl << "fit";
for (int i=0; i<2; i++) { for (int i=0; i<2; i++) {
if (run_iter->fFitRange[i] == -1) if (fRuns[i].fFitRange[i] == -1)
break; break;
f.width(8); f.width(8);
f.precision(2); f.precision(2);
f << left << fixed << run_iter->fFitRange[i]; f << left << fixed << fRuns[i].fFitRange[i];
} }
CheckAndWriteComment(f, ++lineNo); CheckAndWriteComment(f, ++lineNo);
} }
// packing // packing
f.width(16); f.width(16);
f << endl << left << "packing"; f << endl << left << "packing";
f << run_iter->fPacking; f << fRuns[i].fPacking;
CheckAndWriteComment(f, ++lineNo); CheckAndWriteComment(f, ++lineNo);
} }
// write command block // write command block
f << endl << "COMMANDS"; f << endl << "COMMANDS";
CheckAndWriteComment(f, ++lineNo); CheckAndWriteComment(f, ++lineNo);
PMsrLines::iterator cmd_iter; for (unsigned int i=0; i<fCommands.size(); i++) {
for (cmd_iter = fCommands.begin(); cmd_iter != fCommands.end(); ++cmd_iter) { f << endl << fCommands[i].fLine.Data();
f << endl << cmd_iter->fLine.Data();
CheckAndWriteComment(f, ++lineNo); CheckAndWriteComment(f, ++lineNo);
} }
// write plot block // write plot block
PMsrPlotList::iterator plot_iter; for (unsigned int i=0; i<fPlots.size(); i++) {
for (plot_iter = fPlots.begin(); plot_iter != fPlots.end(); ++plot_iter) {
// plot header // plot header
switch (plot_iter->fPlotType) { switch (fPlots[i].fPlotType) {
case MSR_PLOT_SINGLE_HISTO: case MSR_PLOT_SINGLE_HISTO:
f << endl << "PLOT " << plot_iter->fPlotType << " (single histo plot)"; f << endl << "PLOT " << fPlots[i].fPlotType << " (single histo plot)";
break; break;
case MSR_PLOT_ASYM: case MSR_PLOT_ASYM:
f << endl << "PLOT " << plot_iter->fPlotType << " (asymmetry plot)"; f << endl << "PLOT " << fPlots[i].fPlotType << " (asymmetry plot)";
break; break;
case MSR_PLOT_ASYM_RRF: case MSR_PLOT_ASYM_RRF:
f << endl << "PLOT " << plot_iter->fPlotType << " (rotating reference frame plot)"; f << endl << "PLOT " << fPlots[i].fPlotType << " (rotating reference frame plot)";
break; break;
case MSR_PLOT_NO_MUSR: case MSR_PLOT_NO_MUSR:
f << endl << "PLOT " << plot_iter->fPlotType << " (non muSR plot)"; f << endl << "PLOT " << fPlots[i].fPlotType << " (non muSR plot)";
break; break;
default: default:
break; break;
@ -608,22 +603,21 @@ int PMsrHandler::WriteMsrLogFile()
// runs // runs
f << endl << "runs "; f << endl << "runs ";
f.precision(0); f.precision(0);
PComplexVector::iterator r_it; for (unsigned int j=0; j<fPlots[i].fRuns.size(); j++) {
for (r_it = plot_iter->fRuns.begin(); r_it != plot_iter->fRuns.end(); ++r_it) { if (fPlots[i].fPlotType != MSR_PLOT_ASYM_RRF) { // all but MSR_PLOT_ASYM_RRF
if (plot_iter->fPlotType != MSR_PLOT_ASYM_RRF) { // all but MSR_PLOT_ASYM_RRF
f.width(4); f.width(4);
f << r_it->Re(); f << fPlots[i].fRuns[j].Re();
} else { // MSR_PLOT_ASYM_RRF } else { // MSR_PLOT_ASYM_RRF
f << r_it->Re() << "," << r_it->Im() << " "; f << fPlots[i].fRuns[j].Re() << "," << fPlots[i].fRuns[j].Im() << " ";
} }
} }
CheckAndWriteComment(f, ++lineNo); CheckAndWriteComment(f, ++lineNo);
// range // range
f << endl << "range "; f << endl << "range ";
f.precision(2); f.precision(2);
f << plot_iter->fTmin << " " << plot_iter->fTmax; f << fPlots[i].fTmin << " " << fPlots[i].fTmax;
if (plot_iter->fYmin != -999.0) { if (fPlots[i].fYmin != -999.0) {
f << " " << plot_iter->fYmin << " " << plot_iter->fYmax; f << " " << fPlots[i].fYmin << " " << fPlots[i].fYmax;
} }
CheckAndWriteComment(f, ++lineNo); CheckAndWriteComment(f, ++lineNo);
} }
@ -656,9 +650,8 @@ int PMsrHandler::WriteMsrLogFile()
fStatistic.fStatLines.push_back(line); fStatistic.fStatLines.push_back(line);
} }
// write the statistics block // write the statistics block
PMsrLines::iterator stat_iter; for (unsigned int i=0; i<fStatistic.fStatLines.size(); i++) {
for (stat_iter = fStatistic.fStatLines.begin(); stat_iter != fStatistic.fStatLines.end(); ++stat_iter) { f << endl << fStatistic.fStatLines[i].fLine.Data();
f << endl << stat_iter->fLine.Data();
CheckAndWriteComment(f, ++lineNo); CheckAndWriteComment(f, ++lineNo);
} }