added more histo length versus fgb, lgb checks.

This commit is contained in:
2025-07-11 13:05:49 +02:00
parent 06a509a420
commit 392a0b089d
4 changed files with 55 additions and 3 deletions

View File

@ -81,10 +81,12 @@ PRunAsymmetry::PRunAsymmetry() : PRunBase()
PRunAsymmetry::PRunAsymmetry(PMsrHandler *msrInfo, PRunDataHandler *rawData, UInt_t runNo, EPMusrHandleTag tag, Bool_t theoAsData) : PRunAsymmetry::PRunAsymmetry(PMsrHandler *msrInfo, PRunDataHandler *rawData, UInt_t runNo, EPMusrHandleTag tag, Bool_t theoAsData) :
PRunBase(msrInfo, rawData, runNo, tag), fTheoAsData(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 // the fit range can be changed in the command block, these variables need to be accessible
fGoodBins[0] = -1; fGoodBins[0] = -1;
fGoodBins[1] = -1; fGoodBins[1] = -1;
fGoodBins[2] = -1;
fGoodBins[3] = -1;
fStartTimeBin = -1; fStartTimeBin = -1;
fEndTimeBin = -1; fEndTimeBin = -1;
@ -853,7 +855,7 @@ Bool_t PRunAsymmetry::SubtractEstimatedBkg()
Int_t end[2] = {fRunInfo->GetBkgRange(1), fRunInfo->GetBkgRange(3)}; Int_t end[2] = {fRunInfo->GetBkgRange(1), fRunInfo->GetBkgRange(3)};
for (UInt_t i=0; i<2; i++) { for (UInt_t i=0; i<2; i++) {
if (end[i] < start[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]; UInt_t keep = end[i];
end[i] = start[i]; end[i] = start[i];
start[i] = keep; start[i] = keep;
@ -867,7 +869,7 @@ Bool_t PRunAsymmetry::SubtractEstimatedBkg()
UInt_t fullCycles = static_cast<UInt_t>(timeBkg/beamPeriod); // how many proton beam cylces can be placed within the proposed background intervall UInt_t fullCycles = static_cast<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 // 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<UInt_t>((fullCycles*beamPeriod)/(fTimeResolution*fPacking)); end[i] = start[i] + static_cast<UInt_t>((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]) if (end[i] == start[i])
end[i] = fRunInfo->GetBkgRange(2*i+1); 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[2] = start[1];
fGoodBins[3] = end[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; return true;
} }

View File

@ -1556,6 +1556,22 @@ Bool_t PRunAsymmetryRRF::GetProperDataRange(PRawRunData* runData, UInt_t histoNo
fGoodBins[2] = start[1]; fGoodBins[2] = start[1];
fGoodBins[3] = end[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; return true;
} }

View File

@ -1593,6 +1593,15 @@ Bool_t PRunSingleHisto::GetProperDataRange()
fGoodBins[0] = start; fGoodBins[0] = start;
fGoodBins[1] = end; 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; return true;
} }

View File

@ -1003,6 +1003,15 @@ Bool_t PRunSingleHistoRRF::GetProperDataRange()
fGoodBins[0] = start; fGoodBins[0] = start;
fGoodBins[1] = end; 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; return true;
} }