Skip to content

Commit

Permalink
Print a warning when the range given to SetRange is invalid. (root-pr…
Browse files Browse the repository at this point in the history
…oject#14589)

* Print a warning when the range given to SetRange is invalid.

* Fix comment
  • Loading branch information
couet authored and sftnight committed Aug 19, 2024
1 parent 397fe80 commit 0f6d4cf
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions hist/hist/src/TAxis.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,9 @@ void TAxis::SetRange(Int_t first, Int_t last)
fLast = fNbins;
SetBit(kAxisRange, false);
} else {
if (first<0) Warning("TAxis::SetRange","first < 0, 0 is used");
fFirst = std::max(first, 0);
if (last>nCells) Warning("TAxis::SetRange","last > fNbins+1, fNbins+1 is used");
fLast = std::min(last, nCells);
SetBit(kAxisRange, true);
}
Expand All @@ -1087,6 +1089,8 @@ void TAxis::SetRangeUser(Double_t ufirst, Double_t ulast)
return;
}
}
if (ufirst<fXmin) Warning("TAxis::SetRangeUser","ufirst < fXmin, fXmin is used");
if (ulast>fXmax) Warning("TAxis::SetRangeUser","ulast > fXmax, fXmax is used");
Int_t ifirst = FindFixBin(ufirst);
Int_t ilast = FindFixBin(ulast);
// fixes for numerical error and for https://savannah.cern.ch/bugs/index.php?99777
Expand Down

0 comments on commit 0f6d4cf

Please sign in to comment.