correct the end of the background intervall such that the background is as close as possible to a multiple of the proton cylce

This commit is contained in:
nemu
2011-02-04 06:52:04 +00:00
parent aca61d4731
commit 0a422229b1
3 changed files with 15 additions and 6 deletions

View File

@ -32,6 +32,7 @@
#include <stdio.h>
#include <iostream>
using namespace std;
#include "PMusr.h"
#include "PRunAsymmetry.h"
@ -316,6 +317,8 @@ Bool_t PRunAsymmetry::PrepareData()
// keep the time resolution in (us)
fTimeResolution = runData->GetTimeResolution()/1.0e3;
cout.precision(8);
cout << endl << ">> PRunSingleHisto::PrepareData(): time resolution=" << fixed << runData->GetTimeResolution() << "(ns)" << endl;
// collect histogram numbers
PUIntVector forwardHistoNo;
@ -690,9 +693,10 @@ Bool_t PRunAsymmetry::SubtractEstimatedBkg()
// calculate proper background range
for (UInt_t i=0; i<2; i++) {
if (beamPeriod != 0.0) {
Double_t beamPeriodBins = beamPeriod/fRunInfo->GetPacking();
UInt_t periods = (UInt_t)((Double_t)(end[i] - start[i] + 1) / beamPeriodBins);
end[i] = start[i] + (UInt_t)round((Double_t)periods*beamPeriodBins);
Double_t timeBkg = (Double_t)(end-start)*(fTimeResolution*fRunInfo->GetPacking()); // length of the background intervall in time
UInt_t fullCycles = (UInt_t)(timeBkg/beamPeriod); // how many proton beam cylces can be placed within the proposed background intervall
// correct the end of the background intervall such that the background is as close as possible to a multiple of the proton cylce
end[i] = start[i] + (UInt_t) ((fullCycles*beamPeriod)/(fTimeResolution*fRunInfo->GetPacking()));
cout << "PRunAsymmetry::SubtractEstimatedBkg(): Background " << start[i] << ", " << end[i] << endl;
if (end[i] == start[i])
end[i] = fRunInfo->GetBkgRange(2*i+1);