diff --git a/src/classes/PRunAsymmetry.cpp b/src/classes/PRunAsymmetry.cpp index c19ed6c5..8ffe3fdb 100644 --- a/src/classes/PRunAsymmetry.cpp +++ b/src/classes/PRunAsymmetry.cpp @@ -81,10 +81,12 @@ PRunAsymmetry::PRunAsymmetry() : PRunBase() PRunAsymmetry::PRunAsymmetry(PMsrHandler *msrInfo, PRunDataHandler *rawData, UInt_t runNo, EPMusrHandleTag tag, Bool_t theoAsData) : PRunBase(msrInfo, rawData, runNo, tag), fTheoAsData(theoAsData) { - // the 2 following variables are need in case fit range is given in bins, and since + // the following variables are need in case fit range is given in bins, and since // the fit range can be changed in the command block, these variables need to be accessible fGoodBins[0] = -1; fGoodBins[1] = -1; + fGoodBins[2] = -1; + fGoodBins[3] = -1; fStartTimeBin = -1; fEndTimeBin = -1; @@ -853,7 +855,7 @@ Bool_t PRunAsymmetry::SubtractEstimatedBkg() Int_t end[2] = {fRunInfo->GetBkgRange(1), fRunInfo->GetBkgRange(3)}; for (UInt_t i=0; i<2; i++) { if (end[i] < start[i]) { - std::cout << std::endl << "PRunAsymmetry::SubtractEstimatedBkg(): end = " << end[i] << " > start = " << start[i] << "! Will swap them!"; + std::cout << std::endl << ">> PRunAsymmetry::SubtractEstimatedBkg(): end = " << end[i] << " > start = " << start[i] << "! Will swap them!"; UInt_t keep = end[i]; end[i] = start[i]; start[i] = keep; @@ -867,7 +869,7 @@ Bool_t PRunAsymmetry::SubtractEstimatedBkg() UInt_t fullCycles = static_cast(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] + static_cast((fullCycles*beamPeriod)/(fTimeResolution*fPacking)); - std::cout << "PRunAsymmetry::SubtractEstimatedBkg(): Background " << start[i] << ", " << end[i] << std::endl; + std::cout << ">> PRunAsymmetry::SubtractEstimatedBkg(): Background " << start[i] << ", " << end[i] << std::endl; if (end[i] == start[i]) end[i] = fRunInfo->GetBkgRange(2*i+1); } @@ -1975,6 +1977,22 @@ Bool_t PRunAsymmetry::GetProperDataRange(PRawRunData* runData, UInt_t histoNo[2] fGoodBins[2] = start[1]; fGoodBins[3] = end[1]; + // make sure that fGoodBins are in proper range for fForward and fBackward + if (fGoodBins[0] < 0) + fGoodBins[0]=0; + if (fGoodBins[1] > fForward.size()) { + std::cerr << std::endl << ">> PRunAsymmetry::GetProperDataRange **WARNING** needed to shift forward lgb,"; + std::cerr << std::endl << ">> from " << fGoodBins[1] << " to " << fForward.size()-1 << std::endl; + fGoodBins[1]=fForward.size()-1; + } + if (fGoodBins[2] < 0) + fGoodBins[2]=0; + if (fGoodBins[3] > fBackward.size()) { + std::cerr << std::endl << ">> PRunAsymmetry::GetProperDataRange **WARNING** needed to shift backward lgb,"; + std::cerr << std::endl << ">> from " << fGoodBins[1] << " to " << fForward.size()-1 << std::endl; + fGoodBins[3]=fBackward.size()-1; + } + return true; } diff --git a/src/classes/PRunAsymmetryRRF.cpp b/src/classes/PRunAsymmetryRRF.cpp index 21676c3e..59ef5570 100644 --- a/src/classes/PRunAsymmetryRRF.cpp +++ b/src/classes/PRunAsymmetryRRF.cpp @@ -1556,6 +1556,22 @@ Bool_t PRunAsymmetryRRF::GetProperDataRange(PRawRunData* runData, UInt_t histoNo fGoodBins[2] = start[1]; fGoodBins[3] = end[1]; + // make sure that fGoodBins are in proper range for fForward and fBackward + if (fGoodBins[0] < 0) + fGoodBins[0]=0; + if (fGoodBins[1] > fForward.size()) { + std::cerr << std::endl << ">> PRunAsymmetry::GetProperDataRange **WARNING** needed to shift forward lgb,"; + std::cerr << std::endl << ">> from " << fGoodBins[1] << " to " << fForward.size()-1 << std::endl; + fGoodBins[1]=fForward.size()-1; + } + if (fGoodBins[2] < 0) + fGoodBins[2]=0; + if (fGoodBins[3] > fBackward.size()) { + std::cerr << std::endl << ">> PRunAsymmetry::GetProperDataRange **WARNING** needed to shift backward lgb,"; + std::cerr << std::endl << ">> from " << fGoodBins[1] << " to " << fForward.size()-1 << std::endl; + fGoodBins[3]=fBackward.size()-1; + } + return true; } diff --git a/src/classes/PRunSingleHisto.cpp b/src/classes/PRunSingleHisto.cpp index ecc54987..4fa357da 100644 --- a/src/classes/PRunSingleHisto.cpp +++ b/src/classes/PRunSingleHisto.cpp @@ -1593,6 +1593,15 @@ Bool_t PRunSingleHisto::GetProperDataRange() fGoodBins[0] = start; fGoodBins[1] = end; + // make sure that fGoodBins are in proper range for fForward + if (fGoodBins[0] < 0) + fGoodBins[0]=0; + if (fGoodBins[1] > fForward.size()) { + std::cerr << std::endl << ">> PRunSingleHisto::GetProperDataRange **WARNING** needed to shift forward lgb,"; + std::cerr << std::endl << ">> from " << fGoodBins[1] << " to " << fForward.size()-1 << std::endl; + fGoodBins[1]=fForward.size()-1; + } + return true; } diff --git a/src/classes/PRunSingleHistoRRF.cpp b/src/classes/PRunSingleHistoRRF.cpp index 9f5ca781..befaf683 100644 --- a/src/classes/PRunSingleHistoRRF.cpp +++ b/src/classes/PRunSingleHistoRRF.cpp @@ -1003,6 +1003,15 @@ Bool_t PRunSingleHistoRRF::GetProperDataRange() fGoodBins[0] = start; fGoodBins[1] = end; + // make sure that fGoodBins are in proper range for fForward + if (fGoodBins[0] < 0) + fGoodBins[0]=0; + if (fGoodBins[1] > fForward.size()) { + std::cerr << std::endl << ">> PRunSingleHisto::GetProperDataRange **WARNING** needed to shift forward lgb,"; + std::cerr << std::endl << ">> from " << fGoodBins[1] << " to " << fForward.size()-1 << std::endl; + fGoodBins[1]=fForward.size()-1; + } + return true; }