fixed a bug in PRunAsymmetry::PrepareData relevant when combining addrun's and grouping (MUSR-209). Removed some obsolate out-commented parts from PRunSingleHisto
This commit is contained in:
parent
8c8833f2eb
commit
d2e6eacad2
@ -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)
|
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.
|
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)
|
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
|
FIXED 2011-12-23 changed Qt parts of configure.ac in order to be compatible
|
||||||
with BSD MacOS X
|
with BSD MacOS X
|
||||||
FIXED 2011-12-22 some more work towards a proper NeXus muon data format support.
|
FIXED 2011-12-22 some more work towards a proper NeXus muon data format support.
|
||||||
|
@ -495,11 +495,16 @@ Bool_t PRunAsymmetry::PrepareData()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// get raw forward/backward histo data
|
// keep the histo of each group at this point (addruns handled below)
|
||||||
fForward.resize(runData->GetDataBin(forwardHistoNo[0])->size());
|
vector<PDoubleVector> forward, backward;
|
||||||
fBackward.resize(runData->GetDataBin(backwardHistoNo[0])->size());
|
forward.resize(forwardHistoNo.size()); // resize to number of groups
|
||||||
fForward = *runData->GetDataBin(forwardHistoNo[0]);
|
backward.resize(backwardHistoNo.size()); // resize to numer of groups
|
||||||
fBackward = *runData->GetDataBin(backwardHistoNo[0]);
|
for (UInt_t i=0; i<forwardHistoNo.size(); i++) {
|
||||||
|
forward[i].resize(runData->GetDataBin(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 addrun's are present, and if yes add data
|
||||||
// check if there are runs to be added to the current one
|
// check if there are runs to be added to the current one
|
||||||
@ -580,23 +585,23 @@ Bool_t PRunAsymmetry::PrepareData()
|
|||||||
|
|
||||||
// add forward run
|
// add forward run
|
||||||
UInt_t addRunSize;
|
UInt_t addRunSize;
|
||||||
for (UInt_t k=0; k<forwardHistoNo.size(); k++) {
|
for (UInt_t k=0; k<forwardHistoNo.size(); k++) { // fill each group
|
||||||
addRunSize = addRunData->GetDataBin(forwardHistoNo[k])->size();
|
addRunSize = addRunData->GetDataBin(forwardHistoNo[k])->size();
|
||||||
for (UInt_t j=0; j<runData->GetDataBin(forwardHistoNo[k])->size(); j++) {
|
for (UInt_t j=0; j<addRunData->GetDataBin(forwardHistoNo[k])->size(); j++) { // loop over the bin indices
|
||||||
// make sure that the index stays in the proper range
|
// 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)) {
|
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
|
// add backward run
|
||||||
for (UInt_t k=0; k<backwardHistoNo.size(); k++) {
|
for (UInt_t k=0; k<backwardHistoNo.size(); k++) { // fill each group
|
||||||
addRunSize = addRunData->GetDataBin(backwardHistoNo[k])->size();
|
addRunSize = addRunData->GetDataBin(backwardHistoNo[k])->size();
|
||||||
for (UInt_t j=0; j<runData->GetDataBin(backwardHistoNo[k])->size(); j++) {
|
for (UInt_t j=0; j<addRunData->GetDataBin(backwardHistoNo[k])->size(); j++) { // loop over the bin indices
|
||||||
// make sure that the index stays in the proper range
|
// 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)) {
|
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]
|
// set forward/backward histo data of the first group
|
||||||
for (UInt_t i=1; i<forwardHistoNo.size(); i++) {
|
fForward.resize(forward[0].size());
|
||||||
for (UInt_t j=0; j<runData->GetDataBin(forwardHistoNo[i])->size(); j++) {
|
fBackward.resize(backward[0].size());
|
||||||
|
for (UInt_t i=0; i<fForward.size(); i++) {
|
||||||
|
fForward[i] = forward[0][i];
|
||||||
|
fBackward[i] = backward[0][i];
|
||||||
|
}
|
||||||
|
|
||||||
|
// group histograms, add all the remaining forward histograms of the group
|
||||||
|
for (UInt_t i=1; i<forwardHistoNo.size(); i++) { // loop over the groupings
|
||||||
|
for (UInt_t j=0; j<runData->GetDataBin(forwardHistoNo[i])->size(); j++) { // loop over the bin indices
|
||||||
// make sure that the index stays within proper range
|
// 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())) {
|
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]
|
// group histograms, add all the remaining backward histograms of the group
|
||||||
for (UInt_t i=1; i<backwardHistoNo.size(); i++) {
|
for (UInt_t i=1; i<backwardHistoNo.size(); i++) { // loop over the groupings
|
||||||
for (UInt_t j=0; j<runData->GetDataBin(backwardHistoNo[i])->size(); j++) {
|
for (UInt_t j=0; j<runData->GetDataBin(backwardHistoNo[i])->size(); j++) { // loop over the bin indices
|
||||||
// make sure that the index stays within proper range
|
// 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())) {
|
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];
|
bkg[0] += fForward[i];
|
||||||
errBkg[0] = TMath::Sqrt(bkg[0])/(end[0] - start[0] + 1);
|
errBkg[0] = TMath::Sqrt(bkg[0])/(end[0] - start[0] + 1);
|
||||||
bkg[0] /= static_cast<Double_t>(end[0] - start[0] + 1);
|
bkg[0] /= static_cast<Double_t>(end[0] - start[0] + 1);
|
||||||
|
cout << endl << ">> estimated forward histo background: " << bkg[0];
|
||||||
|
|
||||||
// backward
|
// backward
|
||||||
for (UInt_t i=start[1]; i<end[1]; i++)
|
for (UInt_t i=start[1]; i<end[1]; i++)
|
||||||
bkg[1] += fBackward[i];
|
bkg[1] += fBackward[i];
|
||||||
errBkg[1] = TMath::Sqrt(bkg[1])/(end[0] - start[0] + 1);
|
errBkg[1] = TMath::Sqrt(bkg[1])/(end[0] - start[0] + 1);
|
||||||
bkg[1] /= static_cast<Double_t>(end[1] - start[1] + 1);
|
bkg[1] /= static_cast<Double_t>(end[1] - start[1] + 1);
|
||||||
|
cout << endl << ">> estimated backward histo background: " << bkg[1] << endl;
|
||||||
|
|
||||||
// correct error for forward, backward
|
// correct error for forward, backward
|
||||||
for (UInt_t i=0; i<fForward.size(); i++) {
|
for (UInt_t i=0; i<fForward.size(); i++) {
|
||||||
@ -833,7 +848,7 @@ Bool_t PRunAsymmetry::SubtractEstimatedBkg()
|
|||||||
* <p>Take the pre-processed data (i.e. grouping and addrun are preformed) and form the asymmetry for fitting.
|
* <p>Take 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:
|
* Before forming the asymmetry, the following checks will be performed:
|
||||||
* -# check if data range is given, if not try to estimate one.
|
* -# 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.
|
* -# check that 'first good bin'-'t0' is the same for forward and backward histogram. If not adjust it.
|
||||||
* -# pack data (rebin).
|
* -# pack data (rebin).
|
||||||
* -# if packed forward size != backward size, truncate the longer one such that an asymmetry can be formed.
|
* -# 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);
|
fData.AppendErrorValue(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
// // count the number of bins to be fitted
|
|
||||||
// Double_t time;
|
|
||||||
// fNoOfFitBins=0;
|
|
||||||
// for (UInt_t i=0; i<fData.GetValue()->size(); i++) {
|
|
||||||
// time = fData.GetDataTimeStart() + (Double_t)i * fData.GetDataTimeStep();
|
|
||||||
// if ((time >= fFitStartTime) && (time <= fFitEndTime))
|
|
||||||
// fNoOfFitBins++;
|
|
||||||
// }
|
|
||||||
CalcNoOfFitBins();
|
CalcNoOfFitBins();
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
|
@ -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; i<fData.GetValue()->size(); i++) {
|
|
||||||
// time = fData.GetDataTimeStart() + (Double_t)i*fData.GetDataTimeStep();
|
|
||||||
// if ((time >= fFitStartTime) && (time <= fFitEndTime))
|
|
||||||
// fNoOfFitBins++;
|
|
||||||
// }
|
|
||||||
CalcNoOfFitBins();
|
CalcNoOfFitBins();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user