From 6162f683c893f125097175d01a59bdf5062eb031 Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Thu, 9 Nov 2017 09:57:53 +0100 Subject: [PATCH] Changed behaviour for the case where LGB > Histo Size. New: LGB = (Histo Size - 1) together with a warning instead of issuing an error. --- src/classes/PRunAsymmetry.cpp | 10 ++++++++-- src/classes/PRunAsymmetryRRF.cpp | 10 ++++++++-- src/classes/PRunSingleHisto.cpp | 8 +++++++- src/classes/PRunSingleHistoRRF.cpp | 8 +++++++- 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/classes/PRunAsymmetry.cpp b/src/classes/PRunAsymmetry.cpp index f86b13e2..6d253a3d 100644 --- a/src/classes/PRunAsymmetry.cpp +++ b/src/classes/PRunAsymmetry.cpp @@ -1774,11 +1774,17 @@ Bool_t PRunAsymmetry::GetProperDataRange(PRawRunData* runData, UInt_t histoNo[2] return false; } // 3rd check if end is within proper bounds - if ((end[i] < 0) || (end[i] > (Int_t)runData->GetDataBin(histoNo[i])->size())) { - cerr << endl << ">> PRunAsymmetry::GetProperDataRange(): **ERROR** end data bin doesn't make any sense!"; + if (end[i] < 0) { + cerr << endl << ">> PRunAsymmetry::GetProperDataRange(): **ERROR** end data bin (" << end[i] << ") doesn't make any sense!"; cerr << endl; return false; } + if (end[i] > (Int_t)runData->GetDataBin(histoNo[i])->size()) { + cerr << endl << ">> PRunAsymmetry::GetProperDataRange(): **WARNING** end data bin (" << end[i] << ") > histo length (" << (Int_t)runData->GetDataBin(histoNo[i])->size() << ")."; + cerr << endl << ">> Will set end = (histo length - 1). Consider to change it in the msr-file." << endl; + cerr << endl; + end[i] = (Int_t)runData->GetDataBin(histoNo[i])->size()-1; + } // 4th check if t0 is within proper bounds if ((t0[i] < 0) || (t0[i] > (Int_t)runData->GetDataBin(histoNo[i])->size())) { cerr << endl << ">> PRunAsymmetry::GetProperDataRange(): **ERROR** t0 data bin doesn't make any sense!"; diff --git a/src/classes/PRunAsymmetryRRF.cpp b/src/classes/PRunAsymmetryRRF.cpp index ba172879..7dbc4d34 100644 --- a/src/classes/PRunAsymmetryRRF.cpp +++ b/src/classes/PRunAsymmetryRRF.cpp @@ -1414,11 +1414,17 @@ Bool_t PRunAsymmetryRRF::GetProperDataRange(PRawRunData* runData, UInt_t histoNo return false; } // 3rd check if end is within proper bounds - if ((end[i] < 0) || (end[i] > (Int_t)runData->GetDataBin(histoNo[i])->size())) { - cerr << endl << ">> PRunAsymmetryRRF::GetProperDataRange(): **ERROR** end data bin doesn't make any sense!"; + if (end[i] < 0) { + cerr << endl << ">> PRunAsymmetryRRF::GetProperDataRange(): **ERROR** end data bin (" << end[i] << ") doesn't make any sense!"; cerr << endl; return false; } + if (end[i] > (Int_t)runData->GetDataBin(histoNo[i])->size()) { + cerr << endl << ">> PRunAsymmetryRRF::GetProperDataRange(): **WARNING** end data bin (" << end[i] << ") > histo length (" << (Int_t)runData->GetDataBin(histoNo[i])->size() << ")."; + cerr << endl << ">> Will set end = (histo length - 1). Consider to change it in the msr-file." << endl; + cerr << endl; + end[i] = (Int_t)runData->GetDataBin(histoNo[i])->size()-1; + } // 4th check if t0 is within proper bounds if ((t0[i] < 0) || (t0[i] > (Int_t)runData->GetDataBin(histoNo[i])->size())) { cerr << endl << ">> PRunAsymmetryRRF::GetProperDataRange(): **ERROR** t0 data bin doesn't make any sense!"; diff --git a/src/classes/PRunSingleHisto.cpp b/src/classes/PRunSingleHisto.cpp index 23738b70..e72edaab 100644 --- a/src/classes/PRunSingleHisto.cpp +++ b/src/classes/PRunSingleHisto.cpp @@ -1560,11 +1560,17 @@ Bool_t PRunSingleHisto::GetProperDataRange() return false; } // 3rd check if end is within proper bounds - if ((end < 0) || (end > (Int_t)fForward.size())) { + if (end < 0) { cerr << endl << ">> PRunSingleHisto::GetProperDataRange(): **ERROR** end data bin (" << end << ") doesn't make any sense!"; cerr << endl; return false; } + if (end > (Int_t)fForward.size()) { + cerr << endl << ">> PRunSingleHisto::GetProperDataRange(): **WARNING** end data bin (" << end << ") > histo length (" << (Int_t)fForward.size() << ")."; + cerr << endl << ">> Will set end = (histo length - 1). Consider to change it in the msr-file." << endl; + cerr << endl; + end = (Int_t)fForward.size()-1; + } // keep good bins for potential later use fGoodBins[0] = start; diff --git a/src/classes/PRunSingleHistoRRF.cpp b/src/classes/PRunSingleHistoRRF.cpp index d43546ae..aa1fb46f 100644 --- a/src/classes/PRunSingleHistoRRF.cpp +++ b/src/classes/PRunSingleHistoRRF.cpp @@ -969,11 +969,17 @@ Bool_t PRunSingleHistoRRF::GetProperDataRange() return false; } // 3rd check if end is within proper bounds - if ((end < 0) || (end > (Int_t)fForward.size())) { + if (end < 0) { cerr << endl << ">> PRunSingleHistoRRF::GetProperDataRange(): **ERROR** end data bin (" << end << ") doesn't make any sense!"; cerr << endl; return false; } + if (end > (Int_t)fForward.size()) { + cerr << endl << ">> PRunSingleHistoRRF::GetProperDataRange(): **WARNING** end data bin (" << end << ") > histo length (" << (Int_t)fForward.size() << ")."; + cerr << endl << ">> Will set end = (histo length - 1). Consider to change it in the msr-file." << endl; + cerr << endl; + end = (Int_t)fForward.size()-1; + } // keep good bins for potential later use fGoodBins[0] = start;