diff --git a/ChangeLog b/ChangeLog index f2abe96a..2780af44 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21,6 +21,8 @@ NEW the chi^2 calculation in single-histogram and asymmetry fits is parallelized if musrfit is built using a compiler supporting OpenMP (e.g. GCC >= 4.2) Using --disable-omp this feature can be disabled on the configure level. NEW any2many: force the user to define the exact NeXus ouput format (HDF4,HDF5,XML) +FIXED 2012-01-05 fixed a bug in PRunAsymmetry::PrepareData relevant when combining addrun's and grouping (MUSR-209). + Remove some commented out stuff from PRunSingleHisto. FIXED 2011-12-23 changed Qt parts of configure.ac in order to be compatible with BSD MacOS X FIXED 2011-12-22 some more work towards a proper NeXus muon data format support. diff --git a/src/classes/PRunAsymmetry.cpp b/src/classes/PRunAsymmetry.cpp index 6db0d6bb..edc7707e 100644 --- a/src/classes/PRunAsymmetry.cpp +++ b/src/classes/PRunAsymmetry.cpp @@ -495,11 +495,16 @@ Bool_t PRunAsymmetry::PrepareData() } } - // get raw forward/backward histo data - fForward.resize(runData->GetDataBin(forwardHistoNo[0])->size()); - fBackward.resize(runData->GetDataBin(backwardHistoNo[0])->size()); - fForward = *runData->GetDataBin(forwardHistoNo[0]); - fBackward = *runData->GetDataBin(backwardHistoNo[0]); + // keep the histo of each group at this point (addruns handled below) + vector forward, backward; + forward.resize(forwardHistoNo.size()); // resize to number of groups + backward.resize(backwardHistoNo.size()); // resize to numer of groups + for (UInt_t i=0; iGetDataBin(forwardHistoNo[i])->size()); + backward[i].resize(runData->GetDataBin(backwardHistoNo[i])->size()); + forward[i] = *runData->GetDataBin(forwardHistoNo[i]); + backward[i] = *runData->GetDataBin(backwardHistoNo[i]); + } // check if addrun's are present, and if yes add data // check if there are runs to be added to the current one @@ -579,24 +584,24 @@ Bool_t PRunAsymmetry::PrepareData() } // add forward run - UInt_t addRunSize; - for (UInt_t k=0; kGetDataBin(forwardHistoNo[k])->size(); - for (UInt_t j=0; jGetDataBin(forwardHistoNo[k])->size(); j++) { + for (UInt_t j=0; jGetDataBin(forwardHistoNo[k])->size(); j++) { // loop over the bin indices // make sure that the index stays in the proper range if ((j+t0Add[2*k]-fT0s[2*k] >= 0) && (j+t0Add[2*k]-fT0s[2*k] < addRunSize)) { - fForward[j] += addRunData->GetDataBin(forwardHistoNo[k])->at(j+t0Add[2*k]-fT0s[2*k]); + forward[k][j] += addRunData->GetDataBin(forwardHistoNo[k])->at(j+t0Add[2*k]-fT0s[2*k]); } } } // add backward run - for (UInt_t k=0; kGetDataBin(backwardHistoNo[k])->size(); - for (UInt_t j=0; jGetDataBin(backwardHistoNo[k])->size(); j++) { + for (UInt_t j=0; jGetDataBin(backwardHistoNo[k])->size(); j++) { // loop over the bin indices // make sure that the index stays in the proper range if ((j+t0Add[2*k+1]-fT0s[2*k+1] >= 0) && (j+t0Add[2*k+1]-fT0s[2*k+1] < addRunSize)) { - fBackward[j] += addRunData->GetDataBin(backwardHistoNo[k])->at(j+t0Add[2*k+1]-fT0s[2*k+1]); + backward[k][j] += addRunData->GetDataBin(backwardHistoNo[k])->at(j+t0Add[2*k+1]-fT0s[2*k+1]); } } } @@ -606,22 +611,30 @@ Bool_t PRunAsymmetry::PrepareData() } } - // group histograms, add all the forward histograms to the one with forwardHistoNo[0] - for (UInt_t i=1; iGetDataBin(forwardHistoNo[i])->size(); j++) { + // set forward/backward histo data of the first group + fForward.resize(forward[0].size()); + fBackward.resize(backward[0].size()); + for (UInt_t i=0; iGetDataBin(forwardHistoNo[i])->size(); j++) { // loop over the bin indices // make sure that the index stays within proper range if ((j+fT0s[2*i]-fT0s[0] >= 0) && (j+fT0s[2*i]-fT0s[0] < runData->GetDataBin(forwardHistoNo[i])->size())) { - fForward[j] += runData->GetDataBin(forwardHistoNo[i])->at(j+fT0s[2*i]-fT0s[0]); + fForward[j] += forward[i][j+fT0s[2*i]-fT0s[0]]; } } } - // group histograms, add all the backward histograms to the one with backwardHistoNo[0] - for (UInt_t i=1; iGetDataBin(backwardHistoNo[i])->size(); j++) { + // group histograms, add all the remaining backward histograms of the group + for (UInt_t i=1; iGetDataBin(backwardHistoNo[i])->size(); j++) { // loop over the bin indices // make sure that the index stays within proper range if ((j+fT0s[2*i+1]-fT0s[1] >= 0) && (j+fT0s[2*i+1]-fT0s[1] < runData->GetDataBin(backwardHistoNo[i])->size())) { - fBackward[j] += runData->GetDataBin(backwardHistoNo[i])->at(j+fT0s[2*i+1]-fT0s[1]); + fBackward[j] += backward[i][j+fT0s[2*i+1]-fT0s[1]]; } } } @@ -801,12 +814,14 @@ Bool_t PRunAsymmetry::SubtractEstimatedBkg() bkg[0] += fForward[i]; errBkg[0] = TMath::Sqrt(bkg[0])/(end[0] - start[0] + 1); bkg[0] /= static_cast(end[0] - start[0] + 1); + cout << endl << ">> estimated forward histo background: " << bkg[0]; // backward for (UInt_t i=start[1]; i(end[1] - start[1] + 1); + cout << endl << ">> estimated backward histo background: " << bkg[1] << endl; // correct error for forward, backward for (UInt_t i=0; iTake the pre-processed data (i.e. grouping and addrun are preformed) and form the asymmetry for fitting. * Before forming the asymmetry, the following checks will be performed: * -# check if data range is given, if not try to estimate one. - * -# check that data range is present, that it makes any sense. + * -# check that if a data range is present, that it makes any sense. * -# check that 'first good bin'-'t0' is the same for forward and backward histogram. If not adjust it. * -# pack data (rebin). * -# if packed forward size != backward size, truncate the longer one such that an asymmetry can be formed. @@ -1245,14 +1260,6 @@ Bool_t PRunAsymmetry::PrepareViewData(PRawRunData* runData, UInt_t histoNo[2]) fData.AppendErrorValue(error); } -// // count the number of bins to be fitted -// Double_t time; -// fNoOfFitBins=0; -// for (UInt_t i=0; isize(); i++) { -// time = fData.GetDataTimeStart() + (Double_t)i * fData.GetDataTimeStep(); -// if ((time >= fFitStartTime) && (time <= fFitEndTime)) -// fNoOfFitBins++; -// } CalcNoOfFitBins(); // clean up diff --git a/src/classes/PRunSingleHisto.cpp b/src/classes/PRunSingleHisto.cpp index 335e0530..d2d6a0c1 100644 --- a/src/classes/PRunSingleHisto.cpp +++ b/src/classes/PRunSingleHisto.cpp @@ -812,14 +812,6 @@ Bool_t PRunSingleHisto::PrepareFitData(PRawRunData* runData, const UInt_t histoN } } -// // count the number of bins to be fitted -// fNoOfFitBins=0; -// Double_t time; -// for (UInt_t i=0; isize(); i++) { -// time = fData.GetDataTimeStart() + (Double_t)i*fData.GetDataTimeStep(); -// if ((time >= fFitStartTime) && (time <= fFitEndTime)) -// fNoOfFitBins++; -// } CalcNoOfFitBins(); return true;