some changes concerning proper scaling

This commit is contained in:
nemu 2009-06-03 06:16:25 +00:00
parent a2844ad03d
commit 6e7b2fa1b2
3 changed files with 13 additions and 12 deletions

View File

@ -471,7 +471,8 @@ bool PRunAsymmetry::PrepareData()
// SubtractFixBkg
//--------------------------------------------------------------------------
/**
* <p>Subtracts a fixed background from the raw data. The error propagation
* <p>Subtracts a fixed background from the raw data. The background is given
* in units of (1/ns). The error propagation
* is done the following way: it is assumed that the error of the background
* is Poisson like, i.e. \f$\Delta\mathrm{bkg} = \sqrt{\mathrm{bkg}}\f$.
*
@ -482,14 +483,14 @@ bool PRunAsymmetry::PrepareData()
* and \f$ \mathrm{bkg} \f$ the fix given background.
*/
bool PRunAsymmetry::SubtractFixBkg()
{
{
for (unsigned int i=0; i<fForward.size(); i++) {
fForwardErr.push_back(TMath::Sqrt(fForward[i]+fRunInfo->fBkgFix[0]));
fForward[i] -= fRunInfo->fBkgFix[0];
fBackwardErr.push_back(TMath::Sqrt(fBackward[i]+fRunInfo->fBkgFix[1]));
fBackward[i] -= fRunInfo->fBkgFix[1];
fForwardErr.push_back(TMath::Sqrt(fForward[i]+fRunInfo->fBkgFix[0] * fTimeResolution * 1.0e3));
fForward[i] -= fRunInfo->fBkgFix[0] * fTimeResolution * 1.0e3; // bkg per ns -> bkg per bin; 1.0e3: us -> ns
fBackwardErr.push_back(TMath::Sqrt(fBackward[i]+fRunInfo->fBkgFix[1] * fTimeResolution * 1.0e3));
fBackward[i] -= fRunInfo->fBkgFix[1] * fTimeResolution * 1.0e3; // bkg per ns -> bkg per bin; 1.0e3: us -> ns
}
return true;
}
@ -575,12 +576,14 @@ bool PRunAsymmetry::SubtractEstimatedBkg()
bkg[0] += fForward[i];
errBkg[0] = TMath::Sqrt(bkg[0])/(end[0] - start[0] + 1);
bkg[0] /= static_cast<double>(end[0] - start[0] + 1);
//cout << endl << ">> bkg[0] = " << bkg[0];
// backward
for (unsigned int i=start[1]; i<end[1]; i++)
bkg[1] += fBackward[i];
errBkg[1] = TMath::Sqrt(bkg[1])/(end[0] - start[0] + 1);
bkg[1] /= static_cast<double>(end[1] - start[1] + 1);
//cout << endl << ">> bkg[1] = " << bkg[1] << endl;
// correct error for forward, backward
for (unsigned int i=0; i<fForward.size(); i++) {

View File

@ -752,7 +752,6 @@ bool PRunSingleHisto::PrepareViewData(PRawRunData* runData, const unsigned int h
// evaluate function
N0 = fMsrInfo->EvalFunc(funNo,fRunInfo->fMap,par);
}
//cout << endl << ">> N0 = " << N0;
// get tau
double tau;
@ -775,7 +774,6 @@ bool PRunSingleHisto::PrepareViewData(PRawRunData* runData, const unsigned int h
} else { // bkg fitted
bkg = par[fRunInfo->fBkgFitParamNo-1];
}
//cout << endl << ">> bkg = " << bkg;
double value = 0.0;
double expval;
@ -796,9 +794,9 @@ cout << endl << "--------------------------------" << endl;
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
normalizer = fRunInfo->fPacking * (fTimeResolution * 1e3); // fTimeResolution us->ns
normalizer = fRunInfo->fPacking * (fTimeResolution * 1.0e3); // fTimeResolution us->ns
value /= normalizer;
time = ((double)(i-fRunInfo->fPacking)-t0)*fTimeResolution;
time = (((double)i-(double)(fRunInfo->fPacking-1)/2.0)-t0)*fTimeResolution;
expval = TMath::Exp(+time/tau)/N0;
fData.fValue.push_back(-1.0+expval*(value-bkg));
//cout << endl << ">> i=" << i << ",t0=" << t0 << ",time=" << time << ",expval=" << expval << ",value=" << value << ",bkg=" << bkg << ",expval*(value-bkg)-1=" << expval*(value-bkg)-1.0;

View File

@ -87,7 +87,7 @@ class PRunBase
PIntVector fParamNo; ///< vector of parameter numbers for the specifc run
PRunData fData; ///< data to be fitted, viewed, i.e. binned data
double fTimeResolution; ///< time resolution
double fTimeResolution; ///< time resolution in (us)
PIntVector fT0s; ///< all t0's of a run! The derived classes will handle it
virtual bool PrepareData() = 0; // pure virtual, i.e. needs to be implemented by the deriving class!!