From bfcf2b3b8c5ea1fa203a36f08b2aa618dfaf90f3 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Mon, 3 Nov 2025 14:39:28 +0100 Subject: [PATCH 1/3] [hist] Unzoom: add sanity check before casting --- hist/hist/src/TAxis.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hist/hist/src/TAxis.cxx b/hist/hist/src/TAxis.cxx index 5b6c0ae65dff9..5deed330f1982 100644 --- a/hist/hist/src/TAxis.cxx +++ b/hist/hist/src/TAxis.cxx @@ -1268,7 +1268,7 @@ void TAxis::UnZoom() //unzoom object owning this axis SetRange(0,0); - TH1 *hobj1 = (TH1*)GetParent(); + TH1 *hobj1 = GetParent() && GetParent()->InheritsFrom(TH1::Class()) ? static_cast(GetParent()) : nullptr; if (!strstr(GetName(),"xaxis")) { if (!hobj1) return; if (hobj1->GetDimension() == 2) { From 99afa679888afe8200e69f57503fd41fe2d27d3d Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Mon, 3 Nov 2025 14:42:41 +0100 Subject: [PATCH 2/3] [hist] prevent Unzoom from Zooming in Default drawing histogram option is to leave a YMARGIN range of 10% in YMAX. So if you call Unzoom, it was calling GetMaximum, which calculated the exact maximum, and then called SetMaximum, thus overwriting the stored value. Use instead GetMaximumStored to prevent recalculation if not set by user. --- hist/hist/src/TAxis.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hist/hist/src/TAxis.cxx b/hist/hist/src/TAxis.cxx index 5deed330f1982..867b59dccc6fa 100644 --- a/hist/hist/src/TAxis.cxx +++ b/hist/hist/src/TAxis.cxx @@ -1268,7 +1268,7 @@ void TAxis::UnZoom() //unzoom object owning this axis SetRange(0,0); - TH1 *hobj1 = GetParent() && GetParent()->InheritsFrom(TH1::Class()) ? static_cast(GetParent()) : nullptr; + TH1 *hobj1 = GetParent() && GetParent()->InheritsFrom(TH1::Class()) ? static_cast(GetParent()) : nullptr; if (!strstr(GetName(),"xaxis")) { if (!hobj1) return; if (hobj1->GetDimension() == 2) { @@ -1283,7 +1283,7 @@ void TAxis::UnZoom() hobj1->SetMinimum(fXmin); hobj1->SetMaximum(fXmax); } else { - if (fXmin==hobj1->GetMinimum() && fXmax==hobj1->GetMaximum()) { + if (fXmin == hobj1->GetMinimumStored() && fXmax == hobj1->GetMaximumStored()) { hobj1->SetMinimum(fXmin); hobj1->SetMaximum(fXmax); } else { From d51306aa53be523470a0b09f1c0c0ee85876bed1 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Wed, 5 Nov 2025 11:21:06 +0100 Subject: [PATCH 3/3] [hist] simplify cast thanks to silverweed --- hist/hist/src/TAxis.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hist/hist/src/TAxis.cxx b/hist/hist/src/TAxis.cxx index 867b59dccc6fa..a4fcbadaa9100 100644 --- a/hist/hist/src/TAxis.cxx +++ b/hist/hist/src/TAxis.cxx @@ -1268,7 +1268,7 @@ void TAxis::UnZoom() //unzoom object owning this axis SetRange(0,0); - TH1 *hobj1 = GetParent() && GetParent()->InheritsFrom(TH1::Class()) ? static_cast(GetParent()) : nullptr; + TH1 *hobj1 = dynamic_cast(GetParent()); if (!strstr(GetName(),"xaxis")) { if (!hobj1) return; if (hobj1->GetDimension() == 2) {