fixed a varity of unsigned int bugs. Furthermore fixed the swap msr<->mlog bug

This commit is contained in:
nemu 2009-04-08 15:21:00 +00:00
parent 8a5501ed71
commit 659ab86f15
8 changed files with 50 additions and 193 deletions

View File

@ -66,20 +66,7 @@ using namespace std;
PFitter::PFitter(PMsrHandler *runInfo, PRunListCollection *runListCollection, bool chisq_only) : PFitter::PFitter(PMsrHandler *runInfo, PRunListCollection *runListCollection, bool chisq_only) :
fChisqOnly(chisq_only), fRunInfo(runInfo) fChisqOnly(chisq_only), fRunInfo(runInfo)
{ {
/* fConverged = false;
PRunData *data=runListCollection->GetSingleHisto(0);
fstream fout( "__test.dat", ios_base::out | ios_base::binary);
fout.write(reinterpret_cast<char *>(&data->fDataTimeStart),sizeof(double));
fout.write(reinterpret_cast<char *>(&data->fDataTimeStep),sizeof(double));
unsigned int ss=data->fValue.size();
fout.write(reinterpret_cast<char *>(&ss),sizeof(ss));
for (unsigned int i=0; i<ss; i++)
fout.write(reinterpret_cast<char *>(&data->fValue[i]),sizeof(double));
for (unsigned int i=0; i<ss; i++)
fout.write(reinterpret_cast<char *>(&data->fError[i]),sizeof(double));
fout.close();
*/
fUseChi2 = true; // chi^2 is the default fUseChi2 = true; // chi^2 is the default
fStrategy = 1; // 0=low, 1=default, 2=high fStrategy = 1; // 0=low, 1=default, 2=high
@ -460,12 +447,6 @@ bool PFitter::ExecuteMigrad()
ROOT::Minuit2::FunctionMinimum min = migrad(maxfcn, tolerance); ROOT::Minuit2::FunctionMinimum min = migrad(maxfcn, tolerance);
if (!min.IsValid()) { if (!min.IsValid()) {
cout << endl << "**WARNING**: PFitter::ExecuteMigrad(): Fit did not converge, sorry ..."; cout << endl << "**WARNING**: PFitter::ExecuteMigrad(): Fit did not converge, sorry ...";
/*
// set flag positive error present to false
for (unsigned int i=0; i<fParams.size(); i++) {
fRunInfo->SetMsrParamPosErrorPresent(i, false);
}
*/
fIsValid = false; fIsValid = false;
return false; return false;
} }
@ -501,6 +482,8 @@ bool PFitter::ExecuteMigrad()
fRunInfo->SetMsrStatisticMin(minVal); fRunInfo->SetMsrStatisticMin(minVal);
fRunInfo->SetMsrStatisticNdf(ndf); fRunInfo->SetMsrStatisticNdf(ndf);
fConverged = true;
return true; return true;
} }
@ -532,12 +515,6 @@ bool PFitter::ExecuteMinimize()
ROOT::Minuit2::FunctionMinimum min = minimize(maxfcn, tolerance); ROOT::Minuit2::FunctionMinimum min = minimize(maxfcn, tolerance);
if (!min.IsValid()) { if (!min.IsValid()) {
cout << endl << "**WARNING**: PFitter::ExecuteMinimize(): Fit did not converge, sorry ..."; cout << endl << "**WARNING**: PFitter::ExecuteMinimize(): Fit did not converge, sorry ...";
/*
// set flag positive error present to false
for (unsigned int i=0; i<fParams.size(); i++) {
fRunInfo->SetMsrParamPosErrorPresent(i, false);
}
*/
fIsValid = false; fIsValid = false;
return false; return false;
} }
@ -573,6 +550,8 @@ bool PFitter::ExecuteMinimize()
fRunInfo->SetMsrStatisticMin(minVal); fRunInfo->SetMsrStatisticMin(minVal);
fRunInfo->SetMsrStatisticNdf(ndf); fRunInfo->SetMsrStatisticNdf(ndf);
fConverged = true;
return true; return true;
} }
@ -596,7 +575,7 @@ bool PFitter::ExecuteMinos()
// check if minimum was valid // check if minimum was valid
if (!fFcnMin->IsValid()) { if (!fFcnMin->IsValid()) {
cout << endl << "**ERROR**: MINOS cannot started since the previews minimization failed :-("; cout << endl << "**ERROR**: MINOS cannot started since the previous minimization failed :-(";
cout << endl; cout << endl;
return false; return false;
} }
@ -927,5 +906,7 @@ bool PFitter::ExecuteSimplex()
fRunInfo->SetMsrStatisticMin(minVal); fRunInfo->SetMsrStatisticMin(minVal);
fRunInfo->SetMsrStatisticNdf(ndf); fRunInfo->SetMsrStatisticNdf(ndf);
fConverged = true;
return true; return true;
} }

View File

@ -609,9 +609,9 @@ bool PRunAsymmetry::PrepareFitData(PRawRunData* runData, unsigned int histoNo[2]
// transform raw histo data. This is done the following way (for details see the manual): // transform raw histo data. This is done the following way (for details see the manual):
// first rebin the data, than calculate the asymmetry // first rebin the data, than calculate the asymmetry
// first get start data, end data, and t0 // first get start data, end data, and t0
unsigned int start[2] = {fRunInfo->fDataRange[0], fRunInfo->fDataRange[2]}; int start[2] = {fRunInfo->fDataRange[0], fRunInfo->fDataRange[2]};
unsigned int end[2] = {fRunInfo->fDataRange[1], fRunInfo->fDataRange[3]}; int end[2] = {fRunInfo->fDataRange[1], fRunInfo->fDataRange[3]};
double t0[2] = {fT0s[0], fT0s[1]}; double t0[2] = {fT0s[0], fT0s[1]};
// check if start, end, and t0 make any sense // check if start, end, and t0 make any sense
// 1st check if start and end are in proper order // 1st check if start and end are in proper order
for (unsigned int i=0; i<2; i++) { for (unsigned int i=0; i<2; i++) {
@ -621,17 +621,17 @@ bool PRunAsymmetry::PrepareFitData(PRawRunData* runData, unsigned int histoNo[2]
start[i] = keep; start[i] = keep;
} }
// 2nd check if start is within proper bounds // 2nd check if start is within proper bounds
if ((start[i] < 0) || (start[i] > runData->fDataBin[histoNo[i]].size())) { if ((start[i] < 0) || (start[i] > (int)runData->fDataBin[histoNo[i]].size())) {
cout << endl << "PRunAsymmetry::PrepareFitData(): **ERROR** start data bin doesn't make any sense!"; cout << endl << "PRunAsymmetry::PrepareFitData(): **ERROR** start data bin doesn't make any sense!";
return false; return false;
} }
// 3rd check if end is within proper bounds // 3rd check if end is within proper bounds
if ((end[i] < 0) || (end[i] > runData->fDataBin[histoNo[i]].size())) { if ((end[i] < 0) || (end[i] > (int)runData->fDataBin[histoNo[i]].size())) {
cout << endl << "PRunAsymmetry::PrepareFitData(): **ERROR** end data bin doesn't make any sense!"; cout << endl << "PRunAsymmetry::PrepareFitData(): **ERROR** end data bin doesn't make any sense!";
return false; return false;
} }
// 4th check if t0 is within proper bounds // 4th check if t0 is within proper bounds
if ((t0[i] < 0) || (t0[i] > runData->fDataBin[histoNo[i]].size())) { if ((t0[i] < 0) || (t0[i] > (int)runData->fDataBin[histoNo[i]].size())) {
cout << endl << "PRunAsymmetry::PrepareFitData(): **ERROR** t0 data bin doesn't make any sense!"; cout << endl << "PRunAsymmetry::PrepareFitData(): **ERROR** t0 data bin doesn't make any sense!";
return false; return false;
} }
@ -643,7 +643,7 @@ bool PRunAsymmetry::PrepareFitData(PRawRunData* runData, unsigned int histoNo[2]
double value = 0.0; double value = 0.0;
double error = 0.0; double error = 0.0;
// forward // forward
for (unsigned i=start[0]; i<end[0]; i++) { for (int i=start[0]; i<end[0]; i++) {
if (fRunInfo->fPacking == 1) { if (fRunInfo->fPacking == 1) {
forwardPacked.fValue.push_back(fForward[i]); forwardPacked.fValue.push_back(fForward[i]);
forwardPacked.fError.push_back(fForwardErr[i]); forwardPacked.fError.push_back(fForwardErr[i]);
@ -665,7 +665,7 @@ bool PRunAsymmetry::PrepareFitData(PRawRunData* runData, unsigned int histoNo[2]
} }
} }
// backward // backward
for (unsigned i=start[1]; i<end[1]; i++) { for (int i=start[1]; i<end[1]; i++) {
if (fRunInfo->fPacking == 1) { if (fRunInfo->fPacking == 1) {
backwardPacked.fValue.push_back(fBackward[i]); backwardPacked.fValue.push_back(fBackward[i]);
backwardPacked.fError.push_back(fBackwardErr[i]); backwardPacked.fError.push_back(fBackwardErr[i]);
@ -761,10 +761,10 @@ bool PRunAsymmetry::PrepareViewData(PRawRunData* runData, unsigned int histoNo[2
// transform raw histo data. This is done the following way (for details see the manual): // transform raw histo data. This is done the following way (for details see the manual):
// first rebin the data, than calculate the asymmetry // first rebin the data, than calculate the asymmetry
// first get start data, end data, and t0 // first get start data, end data, and t0
unsigned int start[2] = {fRunInfo->fDataRange[0]-fRunInfo->fPacking*(fRunInfo->fDataRange[0]/fRunInfo->fPacking), int start[2] = {fRunInfo->fDataRange[0]-fRunInfo->fPacking*(fRunInfo->fDataRange[0]/fRunInfo->fPacking),
fRunInfo->fDataRange[2]-fRunInfo->fPacking*(fRunInfo->fDataRange[2]/fRunInfo->fPacking)}; fRunInfo->fDataRange[2]-fRunInfo->fPacking*(fRunInfo->fDataRange[2]/fRunInfo->fPacking)};
unsigned int end[2]; int end[2];
double t0[2] = {fT0s[0], fT0s[1]}; double t0[2] = {fT0s[0], fT0s[1]};
// make sure that there are equal number of rebinned bins in forward and backward // make sure that there are equal number of rebinned bins in forward and backward
unsigned int noOfBins0 = (runData->fDataBin[histoNo[0]].size()-start[0])/fRunInfo->fPacking; unsigned int noOfBins0 = (runData->fDataBin[histoNo[0]].size()-start[0])/fRunInfo->fPacking;
@ -783,17 +783,17 @@ bool PRunAsymmetry::PrepareViewData(PRawRunData* runData, unsigned int histoNo[2
start[i] = keep; start[i] = keep;
} }
// 2nd check if start is within proper bounds // 2nd check if start is within proper bounds
if ((start[i] < 0) || (start[i] > runData->fDataBin[histoNo[i]].size())) { if ((start[i] < 0) || (start[i] > (int)runData->fDataBin[histoNo[i]].size())) {
cout << endl << "PRunAsymmetry::PrepareViewData(): **ERROR** start data bin doesn't make any sense!"; cout << endl << "PRunAsymmetry::PrepareViewData(): **ERROR** start data bin doesn't make any sense!";
return false; return false;
} }
// 3rd check if end is within proper bounds // 3rd check if end is within proper bounds
if ((end[i] < 0) || (end[i] > runData->fDataBin[histoNo[i]].size())) { if ((end[i] < 0) || (end[i] > (int)runData->fDataBin[histoNo[i]].size())) {
cout << endl << "PRunAsymmetry::PrepareViewData(): **ERROR** end data bin doesn't make any sense!"; cout << endl << "PRunAsymmetry::PrepareViewData(): **ERROR** end data bin doesn't make any sense!";
return false; return false;
} }
// 4th check if t0 is within proper bounds // 4th check if t0 is within proper bounds
if ((t0[i] < 0) || (t0[i] > runData->fDataBin[histoNo[i]].size())) { if ((t0[i] < 0) || (t0[i] > (int)runData->fDataBin[histoNo[i]].size())) {
cout << endl << "PRunAsymmetry::PrepareViewData(): **ERROR** t0 data bin doesn't make any sense!"; cout << endl << "PRunAsymmetry::PrepareViewData(): **ERROR** t0 data bin doesn't make any sense!";
return false; return false;
} }
@ -805,7 +805,7 @@ bool PRunAsymmetry::PrepareViewData(PRawRunData* runData, unsigned int histoNo[2
double value = 0.0; double value = 0.0;
double error = 0.0; double error = 0.0;
// forward // forward
for (unsigned i=start[0]; i<end[0]; i++) { for (int i=start[0]; i<end[0]; i++) {
if (((i-start[0]) % fRunInfo->fPacking == 0) && (i != start[0])) { // fill data if (((i-start[0]) % fRunInfo->fPacking == 0) && (i != start[0])) { // fill data
// in order that after rebinning the fit does not need to be redone (important for plots) // in order that after rebinning the fit does not need to be redone (important for plots)
// the value is normalize to per bin // the value is normalize to per bin
@ -822,7 +822,7 @@ bool PRunAsymmetry::PrepareViewData(PRawRunData* runData, unsigned int histoNo[2
error += fForwardErr[i]*fForwardErr[i]; error += fForwardErr[i]*fForwardErr[i];
} }
// backward // backward
for (unsigned i=start[1]; i<end[1]; i++) { for (int i=start[1]; i<end[1]; i++) {
if (((i-start[1]) % fRunInfo->fPacking == 0) && (i != start[1])) { // fill data if (((i-start[1]) % fRunInfo->fPacking == 0) && (i != start[1])) { // fill data
// in order that after rebinning the fit does not need to be redone (important for plots) // in order that after rebinning the fit does not need to be redone (important for plots)
// the value is normalize to per bin // the value is normalize to per bin

View File

@ -449,128 +449,6 @@ bool PRunSingleHisto::PrepareData()
*/ */
bool PRunSingleHisto::PrepareFitData(PRawRunData* runData, const unsigned int histoNo) bool PRunSingleHisto::PrepareFitData(PRawRunData* runData, const unsigned int histoNo)
{ {
/*
// get the proper run
PRawRunData* runData = fRawData->GetRunData(fRunInfo->fRunName[0]);
if (runData == 0) { // couldn't get run
cout << endl << "PRunSingleHisto::PrepareFitData(): **ERROR** Couldn't get run " << fRunInfo->fRunName[0].Data() << "!";
return false;
}
// get the proper histo number and check if post pile up data shall be used (LEM)
unsigned int histoNo;
if (fRunInfo->fFileFormat[0].Contains("ppc")) {
histoNo = runData->fDataBin.size()/2 + fRunInfo->fForwardHistoNo-1;
} else {
histoNo = fRunInfo->fForwardHistoNo-1;
}
if ((runData->fDataBin.size() < histoNo) || (histoNo < 0)) {
cout << endl << "PRunSingleHisto::PrepareFitData(): **PANIC ERROR**:";
cout << endl << " histoNo found = " << histoNo << ", but there are only " << runData->fDataBin.size() << " runs!?!?";
cout << endl << " Will quit :-(";
cout << endl;
return false;
}
// check if the t0's are given in the msr-file
if (fRunInfo->fT0[0] == -1) { // t0's are NOT in the msr-file
// check if the t0's are in the data file
if (runData->fT0s.size() != 0) { // t0's in the run data
// keep the proper t0's. For single histo runs, forward is holding the histo no
// fForwardHistoNo starts with 1 not with 0 ;-)
fT0s.push_back(runData->fT0s[fRunInfo->fForwardHistoNo-1]);
} else { // t0's are neither in the run data nor in the msr-file -> not acceptable!
cout << endl << "PRunSingleHisto::PrepareFitData(): **ERROR** NO t0's found, neither in the run data nor in the msr-file!";
cout << endl << " run: " << fRunInfo->fRunName[0].Data();
return false;
}
} else { // t0's in the msr-file
// check if t0's are given in the data file
if (runData->fT0s.size() != 0) {
// compare t0's of the msr-file with the one in the data file
if (fabs(fRunInfo->fT0[0]-runData->fT0s[fRunInfo->fForwardHistoNo-1])>5.0) { // given in bins!!
cout << endl << "PRunSingleHisto::PrepareFitData(): **WARNING**:";
cout << endl << " t0 from the msr-file is " << fRunInfo->fT0[0];
cout << endl << " t0 from the data file is " << runData->fT0s[fRunInfo->fForwardHistoNo-1];
cout << endl << " This is quite a deviation! Is this done intentionally??";
cout << endl;
}
}
fT0s.push_back(fRunInfo->fT0[0]);
}
// check if t0 is within proper bounds
int t0 = fT0s[0];
if ((t0 < 0) || (t0 > (int)runData->fDataBin[histoNo].size())) {
cout << endl << "PRunSingleHisto::PrepareFitData(): **ERROR** t0 data bin doesn't make any sense!";
return false;
}
// check if there are runs to be added to the current one
if (fRunInfo->fRunName.size() > 1) { // runs to be added present
PRawRunData *addRunData;
for (unsigned int i=1; i<fRunInfo->fRunName.size(); i++) {
// get run to be added to the main one
addRunData = fRawData->GetRunData(fRunInfo->fRunName[i]);
if (addRunData == 0) { // couldn't get run
cout << endl << "PRunSingleHisto::PrepareFitData(): **ERROR** Couldn't get addrun " << fRunInfo->fRunName[i].Data() << "!";
return false;
}
// get T0's of the to be added run
int t0Add;
// check if the t0's are given in the msr-file
if (fRunInfo->fT0[i] == -1) { // t0's are NOT in the msr-file
// check if the t0's are in the data file
if (addRunData->fT0s.size() != 0) { // t0's in the run data
// keep the proper t0's. For single histo runs, forward is holding the histo no
// fForwardHistoNo starts with 1 not with 0 ;-)
t0Add = addRunData->fT0s[fRunInfo->fForwardHistoNo-1];
} else { // t0's are neither in the run data nor in the msr-file -> not acceptable!
cout << endl << "PRunSingleHisto::PrepareFitData(): **ERROR** NO t0's found, neither in the addrun data nor in the msr-file!";
cout << endl << " addrun: " << fRunInfo->fRunName[i].Data();
return false;
}
} else { // t0's in the msr-file
// check if t0's are given in the data file
if (addRunData->fT0s.size() != 0) {
// compare t0's of the msr-file with the one in the data file
if (fabs(fRunInfo->fT0[i]-addRunData->fT0s[fRunInfo->fForwardHistoNo-1])>5.0) { // given in bins!!
cout << endl << "PRunSingleHisto::PrepareFitData(): **WARNING**:";
cout << endl << " t0 from the msr-file is " << fRunInfo->fT0[i];
cout << endl << " t0 from the data file is " << addRunData->fT0s[fRunInfo->fForwardHistoNo-1];
cout << endl << " This is quite a deviation! Is this done intentionally??";
cout << endl;
}
}
if (i < fRunInfo->fT0.size()) {
t0Add = fRunInfo->fT0[i];
} else {
cout << endl << "PRunSingleHisto::PrepareFitData(): **WARNING** NO t0's found, neither in the addrun data (";
cout << fRunInfo->fRunName[i].Data();
cout << "), nor in the msr-file! Will try to use the T0 of the run data (";
cout << fRunInfo->fRunName[i].Data();
cout << ") without any warranty!";
t0Add = fRunInfo->fT0[0];
}
}
// add run
for (unsigned int j=0; j<runData->fDataBin[histoNo].size(); j++) {
// make sure that the index stays in the proper range
if ((j-t0Add+t0 >= 0) && (j-t0Add+t0 < addRunData->fDataBin[histoNo].size())) {
runData->fDataBin[histoNo][j] += addRunData->fDataBin[histoNo][j-t0Add+t0];
}
}
}
}
// keep the time resolution in (us)
fTimeResolution = runData->fTimeResolution/1.0e3;
*/
// keep start/stop time for fit // keep start/stop time for fit
fFitStartTime = fRunInfo->fFitRange[0]; fFitStartTime = fRunInfo->fFitRange[0];
fFitStopTime = fRunInfo->fFitRange[1]; fFitStopTime = fRunInfo->fFitRange[1];
@ -580,8 +458,8 @@ bool PRunSingleHisto::PrepareFitData(PRawRunData* runData, const unsigned int hi
// for the single histo fit, just the rebinned raw data are copied // for the single histo fit, just the rebinned raw data are copied
// first get start data, end data, and t0 // first get start data, end data, and t0
unsigned int start; int start;
unsigned int end; int end;
start = fRunInfo->fDataRange[0]; start = fRunInfo->fDataRange[0];
end = fRunInfo->fDataRange[1]; end = fRunInfo->fDataRange[1];
// check if start, end, and t0 make any sense // check if start, end, and t0 make any sense
@ -592,12 +470,12 @@ bool PRunSingleHisto::PrepareFitData(PRawRunData* runData, const unsigned int hi
start = keep; start = keep;
} }
// 2nd check if start is within proper bounds // 2nd check if start is within proper bounds
if ((start < 0) || (start > runData->fDataBin[histoNo].size())) { if ((start < 0) || (start > (int)runData->fDataBin[histoNo].size())) {
cout << endl << "PRunSingleHisto::PrepareFitData(): **ERROR** start data bin doesn't make any sense!"; cout << endl << "PRunSingleHisto::PrepareFitData(): **ERROR** start data bin doesn't make any sense!";
return false; return false;
} }
// 3rd check if end is within proper bounds // 3rd check if end is within proper bounds
if ((end < 0) || (end > runData->fDataBin[histoNo].size())) { if ((end < 0) || (end > (int)runData->fDataBin[histoNo].size())) {
cout << endl << "PRunSingleHisto::PrepareFitData(): **ERROR** end data bin doesn't make any sense!"; cout << endl << "PRunSingleHisto::PrepareFitData(): **ERROR** end data bin doesn't make any sense!";
return false; return false;
} }
@ -623,9 +501,9 @@ bool PRunSingleHisto::PrepareFitData(PRawRunData* runData, const unsigned int hi
double normalizer = 1.0; double normalizer = 1.0;
// data start at data_start-t0 // data start at data_start-t0
// time shifted so that packing is included correctly, i.e. t0 == t0 after packing // time shifted so that packing is included correctly, i.e. t0 == t0 after packing
fData.fDataTimeStart = fTimeResolution*((double)(start-t0)+(double)(fRunInfo->fPacking-1)/2.0); fData.fDataTimeStart = fTimeResolution*(((double)start-(double)t0)+(double)(fRunInfo->fPacking-1)/2.0);
fData.fDataTimeStep = fTimeResolution*fRunInfo->fPacking; fData.fDataTimeStep = fTimeResolution*fRunInfo->fPacking;
for (unsigned i=start; i<end; i++) { for (int i=start; i<end; i++) {
if (fRunInfo->fPacking == 1) { if (fRunInfo->fPacking == 1) {
value = runData->fDataBin[histoNo][i]; value = runData->fDataBin[histoNo][i];
fData.fValue.push_back(value); fData.fValue.push_back(value);
@ -673,16 +551,11 @@ bool PRunSingleHisto::PrepareFitData(PRawRunData* runData, const unsigned int hi
*/ */
bool PRunSingleHisto::PrepareRawViewData(PRawRunData* runData, const unsigned int histoNo) bool PRunSingleHisto::PrepareRawViewData(PRawRunData* runData, const unsigned int histoNo)
{ {
// transform raw histo data. This is done the following way (for details see the manual):
// for the single histo fit, just the rebinned raw data are copied
// first get start data, end data, and t0
unsigned int start;
unsigned int end;
// raw data, since PMusrCanvas is doing ranging etc. // raw data, since PMusrCanvas is doing ranging etc.
// start = the first bin which is a multiple of packing backward from first good data bin // start = the first bin which is a multiple of packing backward from first good data bin
start = fRunInfo->fDataRange[0] - (fRunInfo->fDataRange[0]/fRunInfo->fPacking)*fRunInfo->fPacking; int start = fRunInfo->fDataRange[0] - (fRunInfo->fDataRange[0]/fRunInfo->fPacking)*fRunInfo->fPacking;
// end = last bin starting from start which is a multipl of packing and still within the data // end = last bin starting from start which is a multipl of packing and still within the data
end = start + ((runData->fDataBin[histoNo].size()-start-1)/fRunInfo->fPacking)*fRunInfo->fPacking; int end = start + ((runData->fDataBin[histoNo].size()-start-1)/fRunInfo->fPacking)*fRunInfo->fPacking;
// check if start, end, and t0 make any sense // check if start, end, and t0 make any sense
// 1st check if start and end are in proper order // 1st check if start and end are in proper order
if (end < start) { // need to swap them if (end < start) { // need to swap them
@ -691,12 +564,12 @@ bool PRunSingleHisto::PrepareRawViewData(PRawRunData* runData, const unsigned in
start = keep; start = keep;
} }
// 2nd check if start is within proper bounds // 2nd check if start is within proper bounds
if ((start < 0) || (start > runData->fDataBin[histoNo].size())) { if ((start < 0) || (start > (int)runData->fDataBin[histoNo].size())) {
cout << endl << "PRunSingleHisto::PrepareRawViewData(): **ERROR** start data bin doesn't make any sense!"; cout << endl << "PRunSingleHisto::PrepareRawViewData(): **ERROR** start data bin doesn't make any sense!";
return false; return false;
} }
// 3rd check if end is within proper bounds // 3rd check if end is within proper bounds
if ((end < 0) || (end > runData->fDataBin[histoNo].size())) { if ((end < 0) || (end > (int)runData->fDataBin[histoNo].size())) {
cout << endl << "PRunSingleHisto::PrepareRawViewData(): **ERROR** end data bin doesn't make any sense!"; cout << endl << "PRunSingleHisto::PrepareRawViewData(): **ERROR** end data bin doesn't make any sense!";
return false; return false;
} }
@ -715,7 +588,7 @@ cout << endl << ">> data start time = " << fData.fDataTimeStart;
*/ */
double normalizer = 1.0; double normalizer = 1.0;
for (unsigned i=start; i<end; i++) { for (int i=start; i<end; i++) {
if (((i-start) % fRunInfo->fPacking == 0) && (i != start)) { // fill data if (((i-start) % fRunInfo->fPacking == 0) && (i != start)) { // fill data
// in order that after rebinning the fit does not need to be redone (important for plots) // in order that after rebinning the fit does not need to be redone (important for plots)
// the value is normalize to per 1 nsec // the value is normalize to per 1 nsec
@ -826,14 +699,12 @@ bool PRunSingleHisto::PrepareViewData(PRawRunData* runData, const unsigned int h
// transform raw histo data. This is done the following way (for details see the manual): // transform raw histo data. This is done the following way (for details see the manual):
// for the single histo fit, just the rebinned raw data are copied // for the single histo fit, just the rebinned raw data are copied
// first get start data, end data, and t0 // first get start data, end data, and t0
unsigned int start;
unsigned int end;
int t0 = fT0s[0]; int t0 = fT0s[0];
// start = the first bin which is a multiple of packing backward from first good data bin // start = the first bin which is a multiple of packing backward from first good data bin
start = fRunInfo->fDataRange[0] - (fRunInfo->fDataRange[0]/fRunInfo->fPacking)*fRunInfo->fPacking; int start = fRunInfo->fDataRange[0] - (fRunInfo->fDataRange[0]/fRunInfo->fPacking)*fRunInfo->fPacking;
// end = last bin starting from start which is a multipl of packing and still within the data // end = last bin starting from start which is a multipl of packing and still within the data
end = start + ((runData->fDataBin[histoNo].size()-start-1)/fRunInfo->fPacking)*fRunInfo->fPacking; int end = start + ((runData->fDataBin[histoNo].size()-start-1)/fRunInfo->fPacking)*fRunInfo->fPacking;
// check if start, end, and t0 make any sense // check if start, end, and t0 make any sense
// 1st check if start and end are in proper order // 1st check if start and end are in proper order
@ -843,12 +714,12 @@ bool PRunSingleHisto::PrepareViewData(PRawRunData* runData, const unsigned int h
start = keep; start = keep;
} }
// 2nd check if start is within proper bounds // 2nd check if start is within proper bounds
if ((start < 0) || (start > runData->fDataBin[histoNo].size())) { if ((start < 0) || (start > (int)runData->fDataBin[histoNo].size())) {
cout << endl << "PRunSingleHisto::PrepareViewData(): **ERROR** start data bin doesn't make any sense!"; cout << endl << "PRunSingleHisto::PrepareViewData(): **ERROR** start data bin doesn't make any sense!";
return false; return false;
} }
// 3rd check if end is within proper bounds // 3rd check if end is within proper bounds
if ((end < 0) || (end > runData->fDataBin[histoNo].size())) { if ((end < 0) || (end > (int)runData->fDataBin[histoNo].size())) {
cout << endl << "PRunSingleHisto::PrepareViewData(): **ERROR** end data bin doesn't make any sense!"; cout << endl << "PRunSingleHisto::PrepareViewData(): **ERROR** end data bin doesn't make any sense!";
return false; return false;
} }
@ -911,7 +782,7 @@ cout << endl << ">> start = " << start << ", end = " << end;
cout << endl << "--------------------------------"; cout << endl << "--------------------------------";
*/ */
double normalizer = 1.0; double normalizer = 1.0;
for (unsigned int i=start; i<end; i++) { for (int i=start; i<end; i++) {
if (((i-start) % fRunInfo->fPacking == 0) && (i != start)) { // fill data if (((i-start) % fRunInfo->fPacking == 0) && (i != start)) { // fill data
// in order that after rebinning the fit does not need to be redone (important for plots) // in order that after rebinning the fit does not need to be redone (important for plots)
// the value is normalize to per 1 nsec // the value is normalize to per 1 nsec

View File

@ -1949,7 +1949,7 @@ void PTheory::CalculateDynKTLF(const double *val, int tag) const
double sum; double sum;
double a; double a;
double preFactor = dt*val[2]; double preFactor = dt*val[2];
for (unsigned i=1; i<N; i++) { for (unsigned int i=1; i<N; i++) {
sum = p0exp[i]; sum = p0exp[i];
sum += 0.5*preFactor*p0exp[i]*fDynLFFuncValue[0]; sum += 0.5*preFactor*p0exp[i]*fDynLFFuncValue[0];
for (unsigned int j=1; j<i; j++) { for (unsigned int j=1; j<i; j++) {

View File

@ -67,10 +67,12 @@ class PFitter
virtual ~PFitter(); virtual ~PFitter();
bool IsValid() { return fIsValid; } bool IsValid() { return fIsValid; }
bool HasConverged() { return fConverged; }
bool DoFit(); bool DoFit();
private: private:
bool fIsValid; bool fIsValid;
bool fConverged;
bool fChisqOnly; bool fChisqOnly;
bool fUseChi2; bool fUseChi2;

View File

@ -75,6 +75,7 @@ class PMsrHandler
virtual void SetMsrDataRangeEntry(unsigned int runNo, unsigned int idx, int bin); virtual void SetMsrDataRangeEntry(unsigned int runNo, unsigned int idx, int bin);
virtual void SetMsrBkgRangeEntry(unsigned int runNo, unsigned int idx, int bin); virtual void SetMsrBkgRangeEntry(unsigned int runNo, unsigned int idx, int bin);
virtual void SetMsrStatisticConverged(bool converged) { fStatistic.fValid = converged; }
virtual void SetMsrStatisticMin(double min) { fStatistic.fMin = min; } virtual void SetMsrStatisticMin(double min) { fStatistic.fMin = min; }
virtual void SetMsrStatisticNdf(unsigned int ndf) { fStatistic.fNdf = ndf; } virtual void SetMsrStatisticNdf(unsigned int ndf) { fStatistic.fNdf = ndf; }

View File

@ -635,9 +635,10 @@ int main(int argc, char *argv[])
PFitter *fitter = 0; PFitter *fitter = 0;
if (success) { if (success) {
fitter = new PFitter(msrHandler, runListCollection, chisq_only); fitter = new PFitter(msrHandler, runListCollection, chisq_only);
success = fitter->IsValid(); if (fitter->IsValid()) {
if (success)
fitter->DoFit(); fitter->DoFit();
msrHandler->SetMsrStatisticConverged(fitter->HasConverged());
}
} }
// write log file // write log file

View File

@ -1171,7 +1171,8 @@ void PTextEdit::musrSwapMsrMlog()
swapFileName.replace(idx, 5, ".mlog"); swapFileName.replace(idx, 5, ".mlog");
} else if ((idx = currentFileName.find(".mlog")) > 0) { // mlog-file } else if ((idx = currentFileName.find(".mlog")) > 0) { // mlog-file
swapFileName = currentFileName; swapFileName = currentFileName;
swapFileName.replace(idx, 5, ".msr ").stripWhiteSpace(); swapFileName.replace(idx, 5, ".msr ");
swapFileName = swapFileName.stripWhiteSpace();
} else { // neither a msr- nor a mlog-file } else { // neither a msr- nor a mlog-file
QMessageBox::information( this, "musrSwapMsrMlog", QMessageBox::information( this, "musrSwapMsrMlog",
"This is neither a msr- nor a mlog-file, hence nothing to be swapped.\n", "This is neither a msr- nor a mlog-file, hence nothing to be swapped.\n",