some new stuff, some bug fixing

This commit is contained in:
nemu 2008-04-29 19:20:16 +00:00
parent a0532c3b44
commit 09278f2baa
6 changed files with 99 additions and 19 deletions

View File

@ -80,6 +80,12 @@ long term:
* implement FFT with msr-interface * implement FFT with msr-interface
* switch from qmake to cmake * switch from qmake to cmake
---------------------
bugs:
---------------------
* when having multiple plots: closing some of the plots and finally pressing 'q' will lead to a crash
since root already eliminated the closed canvas plot.
--------------------- ---------------------
problems: problems:
--------------------- ---------------------

View File

@ -329,10 +329,10 @@ int PMsrHandler::WriteMsrLogFile()
f << left << fParam[i].fUpperBoundary; f << left << fParam[i].fUpperBoundary;
f << " "; f << " ";
} }
CheckAndWriteComment(f, ++lineNo);
// terminate parameter line if not the last line // terminate parameter line if not the last line
if (i != fParam.size()-1) if (i != fParam.size()-1)
f << endl; f << endl;
CheckAndWriteComment(f, ++lineNo);
} }
// write theory block // write theory block
@ -2266,8 +2266,9 @@ void PMsrHandler::CheckAndWriteComment(ofstream &f, int &lineNo)
// check if lineNo is present // check if lineNo is present
for (i=0; i<fComments.size(); i++) { for (i=0; i<fComments.size(); i++) {
if (fComments[i].fLineNo == lineNo) if (fComments[i].fLineNo == lineNo) {
break; break;
}
} }
if (i<fComments.size()) { if (i<fComments.size()) {

View File

@ -316,31 +316,37 @@ void PMusrCanvas::UpdateParamTheoryPad()
str += " "; str += " ";
// parameter value // parameter value
if (round(param[i].fValue)-param[i].fValue==0) if (round(param[i].fValue)-param[i].fValue==0)
sprintf(cnum, "%.1lf", param[i].fValue); sprintf(cnum, "%.1lg", param[i].fValue);
else else
sprintf(cnum, "%.6lf", param[i].fValue); sprintf(cnum, "%.6lg", param[i].fValue);
str += cnum; str += cnum;
for (int j=0; j<9-(int)strlen(cnum); j++) // fill spaces for (int j=0; j<9-(int)strlen(cnum); j++) // fill spaces
str += " "; str += " ";
str += " "; // to make sure that at least 1 space is placed str += " "; // to make sure that at least 1 space is placed
// parameter error // parameter error
if (param[i].fPosErrorPresent) { // minos was used if (param[i].fPosErrorPresent) { // minos was used
if (round(param[i].fStep)-param[i].fStep==0) // calculate the arithmetic average of the pos. and neg. error
sprintf(cnum, "%.1lf", param[i].fStep); double err;
else err = param[i].fPosError - param[i].fStep / 2.0;
sprintf(cnum, "%.6lf", param[i].fStep); // check if the pos. and neg. error within 10%
str += cnum; if ((fabs(fabs(param[i].fStep) - param[i].fPosError) < 0.1*fabs(param[i].fStep)) &&
str += "/"; (fabs(fabs(param[i].fStep) - param[i].fPosError) < 0.1*param[i].fPosError)) {
if (round(param[i].fPosError)-param[i].fPosError==0) if (round(err)-err==0)
sprintf(cnum, "%.1lf", param[i].fPosError); sprintf(cnum, "%.1lg", err);
else else
sprintf(cnum, "%.6lf", param[i].fPosError); sprintf(cnum, "%.6lg", err);
} else {
if (round(err)-err==0)
sprintf(cnum, "%.1lg!!", err);
else
sprintf(cnum, "%.6lg!!", err);
}
str += cnum; str += cnum;
} else { // minos was not used } else { // minos was not used
if (round(param[i].fStep)-param[i].fStep==0) if (round(param[i].fStep)-param[i].fStep==0)
sprintf(cnum, "%.1lf", param[i].fStep); sprintf(cnum, "%.1lg", param[i].fStep);
else else
sprintf(cnum, "%.6lf", param[i].fStep); sprintf(cnum, "%.6lg", param[i].fStep);
str += cnum; str += cnum;
} }
ypos = 0.925-i*0.025; ypos = 0.925-i*0.025;

View File

@ -134,6 +134,70 @@ bool PRunNonMusr::PrepareData()
cout << endl << "in PRunNonMusr::PrepareData(): will feed fFitData"; cout << endl << "in PRunNonMusr::PrepareData(): will feed fFitData";
if (fHandleTag == kFit)
success = PrepareFitData();
else if (fHandleTag == kView)
success = PrepareViewData();
else
success = false;
return success; return success;
} }
//--------------------------------------------------------------------------
// PrepareFitData
//--------------------------------------------------------------------------
/**
* <p>
*
*/
bool PRunNonMusr::PrepareFitData()
{
bool success = true;
// get the proper run
PRawRunData* runData = fRawData->GetRunData(fRunInfo->fRunName);
if (!runData) { // couldn't get run
cout << endl << "PRunNonMusr::PrepareFitData(): **ERROR** Couldn't get run " << fRunInfo->fRunName.Data() << "!";
return false;
}
// keep start/stop time for fit: here the meaning is of course start x, stop x
fFitStartTime = fRunInfo->fFitRange[0];
fFitStopTime = fRunInfo->fFitRange[1];
// pack the raw data
double value = 0.0;
double err = 0.0;
for (unsigned int i=0; i<runData->fXData.size(); i++) {
if ((i % fRunInfo->fPacking == 0) && (i != 0)) { // fill data
fData.fX.push_back(runData->fXData[i]-(runData->fXData[i]-runData->fXData[i-fRunInfo->fPacking])/2.0);
fData.fValue.push_back(value);
fData.fError.push_back(TMath::Sqrt(err));
value = 0.0;
err = 0.0;
}
// sum raw data values
value += runData->fYData[i];
err += runData->fErrYData[i]*runData->fErrYData[i];
}
// count the number of bins to be fitted
fNoOfFitBins=0; // STILL MISSING!!
return success;
}
//--------------------------------------------------------------------------
// PrepareViewData
//--------------------------------------------------------------------------
/**
* <p>
*
*/
bool PRunNonMusr::PrepareViewData()
{
bool success = true;
return success;
}

View File

@ -130,12 +130,13 @@ typedef struct {
// data related info // data related info
double fDataTimeStart; double fDataTimeStart;
double fDataTimeStep; double fDataTimeStep;
vector<double> fValue; PDoubleVector fX; // only used for non-muSR
vector<double> fError; PDoubleVector fValue;
PDoubleVector fError;
// theory related info // theory related info
double fTheoryTimeStart; double fTheoryTimeStart;
double fTheoryTimeStep; double fTheoryTimeStep;
vector<double> fTheory; PDoubleVector fTheory;
} PRunData; } PRunData;
//------------------------------------------------------------- //-------------------------------------------------------------

View File

@ -49,6 +49,8 @@ class PRunNonMusr : public PRunBase
protected: protected:
virtual bool PrepareData(); virtual bool PrepareData();
virtual bool PrepareFitData();
virtual bool PrepareViewData();
private: private:
double fFitStartTime; double fFitStartTime;