fixed a varity of unsigned int bugs. Furthermore fixed the swap msr<->mlog bug
This commit is contained in:
parent
8a5501ed71
commit
659ab86f15
@ -66,20 +66,7 @@ using namespace std;
|
||||
PFitter::PFitter(PMsrHandler *runInfo, PRunListCollection *runListCollection, bool chisq_only) :
|
||||
fChisqOnly(chisq_only), fRunInfo(runInfo)
|
||||
{
|
||||
/*
|
||||
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();
|
||||
*/
|
||||
|
||||
fConverged = false;
|
||||
fUseChi2 = true; // chi^2 is the default
|
||||
|
||||
fStrategy = 1; // 0=low, 1=default, 2=high
|
||||
@ -460,12 +447,6 @@ bool PFitter::ExecuteMigrad()
|
||||
ROOT::Minuit2::FunctionMinimum min = migrad(maxfcn, tolerance);
|
||||
if (!min.IsValid()) {
|
||||
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;
|
||||
return false;
|
||||
}
|
||||
@ -501,6 +482,8 @@ bool PFitter::ExecuteMigrad()
|
||||
fRunInfo->SetMsrStatisticMin(minVal);
|
||||
fRunInfo->SetMsrStatisticNdf(ndf);
|
||||
|
||||
fConverged = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -532,12 +515,6 @@ bool PFitter::ExecuteMinimize()
|
||||
ROOT::Minuit2::FunctionMinimum min = minimize(maxfcn, tolerance);
|
||||
if (!min.IsValid()) {
|
||||
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;
|
||||
return false;
|
||||
}
|
||||
@ -573,6 +550,8 @@ bool PFitter::ExecuteMinimize()
|
||||
fRunInfo->SetMsrStatisticMin(minVal);
|
||||
fRunInfo->SetMsrStatisticNdf(ndf);
|
||||
|
||||
fConverged = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -596,7 +575,7 @@ bool PFitter::ExecuteMinos()
|
||||
|
||||
// check if minimum was valid
|
||||
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;
|
||||
return false;
|
||||
}
|
||||
@ -927,5 +906,7 @@ bool PFitter::ExecuteSimplex()
|
||||
fRunInfo->SetMsrStatisticMin(minVal);
|
||||
fRunInfo->SetMsrStatisticNdf(ndf);
|
||||
|
||||
fConverged = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -609,8 +609,8 @@ bool PRunAsymmetry::PrepareFitData(PRawRunData* runData, unsigned int histoNo[2]
|
||||
// transform raw histo data. This is done the following way (for details see the manual):
|
||||
// first rebin the data, than calculate the asymmetry
|
||||
// first get start data, end data, and t0
|
||||
unsigned int start[2] = {fRunInfo->fDataRange[0], fRunInfo->fDataRange[2]};
|
||||
unsigned int end[2] = {fRunInfo->fDataRange[1], fRunInfo->fDataRange[3]};
|
||||
int start[2] = {fRunInfo->fDataRange[0], fRunInfo->fDataRange[2]};
|
||||
int end[2] = {fRunInfo->fDataRange[1], fRunInfo->fDataRange[3]};
|
||||
double t0[2] = {fT0s[0], fT0s[1]};
|
||||
// check if start, end, and t0 make any sense
|
||||
// 1st check if start and end are in proper order
|
||||
@ -621,17 +621,17 @@ bool PRunAsymmetry::PrepareFitData(PRawRunData* runData, unsigned int histoNo[2]
|
||||
start[i] = keep;
|
||||
}
|
||||
// 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!";
|
||||
return false;
|
||||
}
|
||||
// 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!";
|
||||
return false;
|
||||
}
|
||||
// 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!";
|
||||
return false;
|
||||
}
|
||||
@ -643,7 +643,7 @@ bool PRunAsymmetry::PrepareFitData(PRawRunData* runData, unsigned int histoNo[2]
|
||||
double value = 0.0;
|
||||
double error = 0.0;
|
||||
// forward
|
||||
for (unsigned i=start[0]; i<end[0]; i++) {
|
||||
for (int i=start[0]; i<end[0]; i++) {
|
||||
if (fRunInfo->fPacking == 1) {
|
||||
forwardPacked.fValue.push_back(fForward[i]);
|
||||
forwardPacked.fError.push_back(fForwardErr[i]);
|
||||
@ -665,7 +665,7 @@ bool PRunAsymmetry::PrepareFitData(PRawRunData* runData, unsigned int histoNo[2]
|
||||
}
|
||||
}
|
||||
// backward
|
||||
for (unsigned i=start[1]; i<end[1]; i++) {
|
||||
for (int i=start[1]; i<end[1]; i++) {
|
||||
if (fRunInfo->fPacking == 1) {
|
||||
backwardPacked.fValue.push_back(fBackward[i]);
|
||||
backwardPacked.fError.push_back(fBackwardErr[i]);
|
||||
@ -761,9 +761,9 @@ bool PRunAsymmetry::PrepareViewData(PRawRunData* runData, unsigned int histoNo[2
|
||||
// transform raw histo data. This is done the following way (for details see the manual):
|
||||
// first rebin the data, than calculate the asymmetry
|
||||
// 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)};
|
||||
unsigned int end[2];
|
||||
int end[2];
|
||||
double t0[2] = {fT0s[0], fT0s[1]};
|
||||
|
||||
// make sure that there are equal number of rebinned bins in forward and backward
|
||||
@ -783,17 +783,17 @@ bool PRunAsymmetry::PrepareViewData(PRawRunData* runData, unsigned int histoNo[2
|
||||
start[i] = keep;
|
||||
}
|
||||
// 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!";
|
||||
return false;
|
||||
}
|
||||
// 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!";
|
||||
return false;
|
||||
}
|
||||
// 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!";
|
||||
return false;
|
||||
}
|
||||
@ -805,7 +805,7 @@ bool PRunAsymmetry::PrepareViewData(PRawRunData* runData, unsigned int histoNo[2
|
||||
double value = 0.0;
|
||||
double error = 0.0;
|
||||
// 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
|
||||
// in order that after rebinning the fit does not need to be redone (important for plots)
|
||||
// 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];
|
||||
}
|
||||
// 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
|
||||
// in order that after rebinning the fit does not need to be redone (important for plots)
|
||||
// the value is normalize to per bin
|
||||
|
@ -449,128 +449,6 @@ bool PRunSingleHisto::PrepareData()
|
||||
*/
|
||||
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
|
||||
fFitStartTime = fRunInfo->fFitRange[0];
|
||||
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
|
||||
|
||||
// first get start data, end data, and t0
|
||||
unsigned int start;
|
||||
unsigned int end;
|
||||
int start;
|
||||
int end;
|
||||
start = fRunInfo->fDataRange[0];
|
||||
end = fRunInfo->fDataRange[1];
|
||||
// check if start, end, and t0 make any sense
|
||||
@ -592,12 +470,12 @@ bool PRunSingleHisto::PrepareFitData(PRawRunData* runData, const unsigned int hi
|
||||
start = keep;
|
||||
}
|
||||
// 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!";
|
||||
return false;
|
||||
}
|
||||
// 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!";
|
||||
return false;
|
||||
}
|
||||
@ -623,9 +501,9 @@ bool PRunSingleHisto::PrepareFitData(PRawRunData* runData, const unsigned int hi
|
||||
double normalizer = 1.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-1)/2.0);
|
||||
fData.fDataTimeStart = fTimeResolution*(((double)start-(double)t0)+(double)(fRunInfo->fPacking-1)/2.0);
|
||||
fData.fDataTimeStep = fTimeResolution*fRunInfo->fPacking;
|
||||
for (unsigned i=start; i<end; i++) {
|
||||
for (int i=start; i<end; i++) {
|
||||
if (fRunInfo->fPacking == 1) {
|
||||
value = runData->fDataBin[histoNo][i];
|
||||
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)
|
||||
{
|
||||
// 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.
|
||||
// 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 = 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
|
||||
// 1st check if start and end are in proper order
|
||||
if (end < start) { // need to swap them
|
||||
@ -691,12 +564,12 @@ bool PRunSingleHisto::PrepareRawViewData(PRawRunData* runData, const unsigned in
|
||||
start = keep;
|
||||
}
|
||||
// 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!";
|
||||
return false;
|
||||
}
|
||||
// 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!";
|
||||
return false;
|
||||
}
|
||||
@ -715,7 +588,7 @@ cout << endl << ">> data start time = " << fData.fDataTimeStart;
|
||||
*/
|
||||
|
||||
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
|
||||
// in order that after rebinning the fit does not need to be redone (important for plots)
|
||||
// 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):
|
||||
// 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;
|
||||
int t0 = fT0s[0];
|
||||
|
||||
// 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 = 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
|
||||
// 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;
|
||||
}
|
||||
// 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!";
|
||||
return false;
|
||||
}
|
||||
// 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!";
|
||||
return false;
|
||||
}
|
||||
@ -911,7 +782,7 @@ cout << endl << ">> start = " << start << ", end = " << end;
|
||||
cout << endl << "--------------------------------";
|
||||
*/
|
||||
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
|
||||
// in order that after rebinning the fit does not need to be redone (important for plots)
|
||||
// the value is normalize to per 1 nsec
|
||||
|
@ -1949,7 +1949,7 @@ void PTheory::CalculateDynKTLF(const double *val, int tag) const
|
||||
double sum;
|
||||
double a;
|
||||
double preFactor = dt*val[2];
|
||||
for (unsigned i=1; i<N; i++) {
|
||||
for (unsigned int i=1; i<N; i++) {
|
||||
sum = p0exp[i];
|
||||
sum += 0.5*preFactor*p0exp[i]*fDynLFFuncValue[0];
|
||||
for (unsigned int j=1; j<i; j++) {
|
||||
|
@ -67,10 +67,12 @@ class PFitter
|
||||
virtual ~PFitter();
|
||||
|
||||
bool IsValid() { return fIsValid; }
|
||||
bool HasConverged() { return fConverged; }
|
||||
bool DoFit();
|
||||
|
||||
private:
|
||||
bool fIsValid;
|
||||
bool fConverged;
|
||||
bool fChisqOnly;
|
||||
bool fUseChi2;
|
||||
|
||||
|
@ -75,6 +75,7 @@ class PMsrHandler
|
||||
virtual void SetMsrDataRangeEntry(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 SetMsrStatisticNdf(unsigned int ndf) { fStatistic.fNdf = ndf; }
|
||||
|
||||
|
@ -635,9 +635,10 @@ int main(int argc, char *argv[])
|
||||
PFitter *fitter = 0;
|
||||
if (success) {
|
||||
fitter = new PFitter(msrHandler, runListCollection, chisq_only);
|
||||
success = fitter->IsValid();
|
||||
if (success)
|
||||
if (fitter->IsValid()) {
|
||||
fitter->DoFit();
|
||||
msrHandler->SetMsrStatisticConverged(fitter->HasConverged());
|
||||
}
|
||||
}
|
||||
|
||||
// write log file
|
||||
|
@ -1171,7 +1171,8 @@ void PTextEdit::musrSwapMsrMlog()
|
||||
swapFileName.replace(idx, 5, ".mlog");
|
||||
} else if ((idx = currentFileName.find(".mlog")) > 0) { // mlog-file
|
||||
swapFileName = currentFileName;
|
||||
swapFileName.replace(idx, 5, ".msr ").stripWhiteSpace();
|
||||
swapFileName.replace(idx, 5, ".msr ");
|
||||
swapFileName = swapFileName.stripWhiteSpace();
|
||||
} else { // neither a msr- nor a mlog-file
|
||||
QMessageBox::information( this, "musrSwapMsrMlog",
|
||||
"This is neither a msr- nor a mlog-file, hence nothing to be swapped.\n",
|
||||
|
Loading…
x
Reference in New Issue
Block a user