better handling of all the various normalization issues, expecially fixed the wrong normalization when using "SCALE_N0_BKG FALSE" together with view_packing (MUSR-184)

This commit is contained in:
suter_a 2011-10-14 05:18:52 +00:00
parent d2f01eac6d
commit 57d68e7133
2 changed files with 16 additions and 21 deletions

View File

@ -17,6 +17,7 @@ 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 the wrong normalization when using "SCALE_N0_BKG FALSE" together with view_packing (MUSR-184)
FIXED crash in non-interactive mode of musrt0 when data file doesn't exist (MUSR-133) FIXED crash in non-interactive mode of musrt0 when data file doesn't exist (MUSR-133)
FIXED wrong asymmetry fit plotting if data range is not provided (MUSR-203) FIXED wrong asymmetry fit plotting if data range is not provided (MUSR-203)
FIXED broken run-list interface to msr2data in musredit/musrgui (MUSR-202) FIXED broken run-list interface to msr2data in musredit/musrgui (MUSR-202)

View File

@ -1047,6 +1047,14 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo
packing = fMsrInfo->GetMsrPlotList()->at(0).fRRFPacking; packing = fMsrInfo->GetMsrPlotList()->at(0).fRRFPacking;
} }
// calculate necessary norms
Double_t dataNorm = 1.0, theoryNorm = 1.0;
if (fScaleN0AndBkg) {
dataNorm = 1.0/ (packing * (fTimeResolution * 1.0e3)); // fTimeResolution us->ns
} else if (!fScaleN0AndBkg && (fMsrInfo->GetMsrPlotList()->at(0).fViewPacking > 0)) {
theoryNorm = (Double_t)fMsrInfo->GetMsrPlotList()->at(0).fViewPacking/(Double_t)fRunInfo->GetPacking();
}
// 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
@ -1106,6 +1114,7 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo
// evaluate function // evaluate function
N0 = fMsrInfo->EvalFunc(funNo, *fRunInfo->GetMap(), par); N0 = fMsrInfo->EvalFunc(funNo, *fRunInfo->GetMap(), par);
} }
N0 *= theoryNorm;
// get tau // get tau
Double_t tau; Double_t tau;
@ -1138,6 +1147,7 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo
} else { // bkg fitted } else { // bkg fitted
bkg = par[fRunInfo->GetBkgFitParamNo()-1]; bkg = par[fRunInfo->GetBkgFitParamNo()-1];
} }
bkg *= theoryNorm;
Double_t value = 0.0; Double_t value = 0.0;
Double_t expval = 0.0; Double_t expval = 0.0;
@ -1148,20 +1158,15 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo
fData.SetDataTimeStart(fTimeResolution*((Double_t)start-(Double_t)t0+(Double_t)(packing-1)/2.0)); fData.SetDataTimeStart(fTimeResolution*((Double_t)start-(Double_t)t0+(Double_t)(packing-1)/2.0));
fData.SetDataTimeStep(fTimeResolution*packing); fData.SetDataTimeStep(fTimeResolution*packing);
Double_t normalizer = 1.0;
Double_t gammaRRF = 0.0, wRRF = 0.0, phaseRRF = 0.0; Double_t gammaRRF = 0.0, wRRF = 0.0, phaseRRF = 0.0;
if (fMsrInfo->GetMsrPlotList()->at(0).fRRFFreq == 0.0) { // normal Data representation if (fMsrInfo->GetMsrPlotList()->at(0).fRRFFreq == 0.0) { // normal Data representation
for (Int_t i=start; i<end; i++) { for (Int_t i=start; i<end; i++) {
if (((i-start) % packing == 0) && (i != start)) { // fill data if (((i-start) % packing == 0) && (i != start)) { // fill data
// in order that after rebinning the fit does not need to be redone (important for plots) value *= dataNorm;
// the value is normalize to per 1 nsec
if (fScaleN0AndBkg)
normalizer = packing * (fTimeResolution * 1.0e3); // fTimeResolution us->ns
value /= normalizer;
time = (((Double_t)i-(Double_t)(packing-1)/2.0)-t0)*fTimeResolution; time = (((Double_t)i-(Double_t)(packing-1)/2.0)-t0)*fTimeResolution;
expval = TMath::Exp(+time/tau)/N0; expval = TMath::Exp(+time/tau)/N0;
fData.AppendValue(-1.0+expval*(value-bkg)); fData.AppendValue(-1.0+expval*(value-bkg));
fData.AppendErrorValue(expval*TMath::Sqrt(value/normalizer)); fData.AppendErrorValue(expval*TMath::Sqrt(value*dataNorm));
value = 0.0; value = 0.0;
} }
value += runData->GetDataBin(histoNo)->at(i); value += runData->GetDataBin(histoNo)->at(i);
@ -1191,33 +1196,22 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo
wRRF = gammaRRF * fMsrInfo->GetMsrPlotList()->at(0).fRRFFreq; wRRF = gammaRRF * fMsrInfo->GetMsrPlotList()->at(0).fRRFFreq;
phaseRRF = fMsrInfo->GetMsrPlotList()->at(0).fRRFPhase / 180.0 * TMath::Pi(); phaseRRF = fMsrInfo->GetMsrPlotList()->at(0).fRRFPhase / 180.0 * TMath::Pi();
// in order that after rebinning the fit does not need to be redone (important for plots)
// the value is normalize to per 1 nsec
normalizer = (fTimeResolution * 1.0e3); // fTimeResolution us->ns
Double_t error = 0.0; Double_t error = 0.0;
for (Int_t i=start; i<end; i++) { for (Int_t i=start; i<end; i++) {
if (((i-start) % packing == 0) && (i != start)) { // fill data if (((i-start) % packing == 0) && (i != start)) { // fill data
fData.AppendValue(2.0*value/packing); // factor 2 needed because cos(a)cos(b) = 1/2(cos(a+b)+cos(a-b)) fData.AppendValue(2.0*value/packing); // factor 2 needed because cos(a)cos(b) = 1/2(cos(a+b)+cos(a-b))
fData.AppendErrorValue(expval*TMath::Sqrt(error)/normalizer/packing); fData.AppendErrorValue(expval*TMath::Sqrt(error/packing));
value = 0.0; value = 0.0;
error = 0.0; error = 0.0;
} }
time = ((Double_t)i-t0)*fTimeResolution; time = ((Double_t)i-t0)*fTimeResolution;
expval = TMath::Exp(+time/tau)/N0; expval = TMath::Exp(+time/tau)/N0;
rrf_val = (-1.0+expval*(runData->GetDataBin(histoNo)->at(i)/normalizer-bkg))*TMath::Cos(wRRF * time + phaseRRF); rrf_val = (-1.0+expval*(runData->GetDataBin(histoNo)->at(i)*dataNorm-bkg))*TMath::Cos(wRRF * time + phaseRRF);
value += rrf_val; value += rrf_val;
error += runData->GetDataBin(histoNo)->at(i); error += runData->GetDataBin(histoNo)->at(i)*dataNorm;
} }
} }
// // count the number of bins to be fitted
// 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();
// calculate functions // calculate functions