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

@ -11,6 +11,7 @@ NEW any2many: an attempt to write the universial musr-data-file converter. Just
NEW musrt0: added the possibility to show the t0 saved in the data file 's'. Furthermore added the option
--getT0FromPromptPeak, -g with <firstGoodBinOffset>: will, in non-interactive mode estimate the t0's from
the prompt peak and write it into the msr-file (MUSR-133).
FIXED background range correction, such that it is a multiple of the proton cycle time
FIXED linking of BMWlibs on Cygwin
FIXED various bugs in msr2data
FIXED 2 little annoying problems: (i) now it is possible to zoom down to the single bin in musrview.

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);

View File

@ -31,6 +31,7 @@
#include <iostream>
#include <fstream>
using namespace std;
#include "PMusr.h"
#include "PRunSingleHisto.h"
@ -494,6 +495,8 @@ Bool_t PRunSingleHisto::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;
if (fHandleTag == kFit)
success = PrepareFitData(runData, histoNo[0]);
@ -1137,9 +1140,10 @@ Bool_t PRunSingleHisto::EstimateBkg(UInt_t histoNo)
// calculate proper background range
if (beamPeriod != 0.0) {
Double_t beamPeriodBins = beamPeriod/fRunInfo->GetPacking();
UInt_t periods = (UInt_t)((Double_t)(end - start + 1) / beamPeriodBins);
end = start + (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 = start + (UInt_t) ((fullCycles*beamPeriod)/(fTimeResolution*fRunInfo->GetPacking()));
cout << endl << "PRunSingleHisto::EstimatBkg(): Background " << start << ", " << end;
if (end == start)
end = fRunInfo->GetBkgRange(1);