From ecb697166f7676109c18a5efacd163e015409ed2 Mon Sep 17 00:00:00 2001 From: Apurva Narde <58493193+Steepspace@users.noreply.github.com> Date: Mon, 11 May 2026 22:07:32 -0400 Subject: [PATCH 1/3] CaloTowerStatus: Prioritize direct URL overrides Updated the logic in InitRun to ensure that URLs provided via set_directURL_hotMap and set_directURL_chi2 take precedence over the default CDBInterface lookups. Previously, the code checked the CDB first, which caused user-specified URLs to act only as fallbacks rather than overrides. This made it difficult to test local calibration files when a CDB map already existed for the current run. The logic now: 1. Checks for a user-specified direct URL. 2. Falls back to the CDBInterface if no direct URL is provided. 3. Aborts or disables the masking if neither is found. --- offline/packages/CaloReco/CaloTowerStatus.cc | 56 ++++++++++---------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/offline/packages/CaloReco/CaloTowerStatus.cc b/offline/packages/CaloReco/CaloTowerStatus.cc index d21ea08dc2..c3a621b826 100644 --- a/offline/packages/CaloReco/CaloTowerStatus.cc +++ b/offline/packages/CaloReco/CaloTowerStatus.cc @@ -81,22 +81,23 @@ int CaloTowerStatus::InitRun(PHCompositeNode *topNode) m_calibName_chi2 = m_detector + "_hotTowers_fracBadChi2"; m_fieldname_chi2 = "fraction"; - std::string calibdir = CDBInterface::instance()->getUrl(m_calibName_chi2); - if (!calibdir.empty()) + std::string calibdir_chi2; + if (use_directURL_chi2) { - m_cdbttree_chi2 = new CDBTTree(calibdir); - if (Verbosity() > 0) - { - std::cout << "CaloTowerStatus::InitRun Found " << m_calibName_chi2 << " Doing isHot for frac bad chi2" << std::endl; - } + calibdir_chi2 = m_directURL_chi2; + std::cout << "CaloTowerStatus::InitRun: Using direct URL override for chi2: " << calibdir_chi2 << std::endl; + m_cdbttree_chi2 = new CDBTTree(calibdir_chi2); } else { - if (use_directURL_chi2) + calibdir_chi2 = CDBInterface::instance()->getUrl(m_calibName_chi2); + if (!calibdir_chi2.empty()) { - calibdir = m_directURL_chi2; - std::cout << "CaloTowerStatus::InitRun: Using default hotBadChi2" << calibdir << std::endl; - m_cdbttree_chi2 = new CDBTTree(calibdir); + m_cdbttree_chi2 = new CDBTTree(calibdir_chi2); + if (Verbosity() > 0) + { + std::cout << "CaloTowerStatus::InitRun Found " << m_calibName_chi2 << " Doing isHot for frac bad chi2" << std::endl; + } } else { @@ -117,30 +118,31 @@ int CaloTowerStatus::InitRun(PHCompositeNode *topNode) m_fieldname_hotMap = "status"; m_fieldname_z_score = m_detector + "_sigma"; - calibdir = CDBInterface::instance()->getUrl(m_calibName_hotMap); - if (!calibdir.empty()) + std::string calibdir_hotMap; + if (use_directURL_hotMap) { - m_cdbttree_hotMap = new CDBTTree(calibdir); - if (Verbosity() > 1) - { - std::cout << "CaloTowerStatus::Init " << m_detector << " hot map found " << m_calibName_hotMap << " Ddoing isHot" << std::endl; - } + calibdir_hotMap = m_directURL_hotMap; + std::cout << "CaloTowerStatus::InitRun: Using direct URL override for hot map: " << calibdir_hotMap << std::endl; + m_cdbttree_hotMap = new CDBTTree(calibdir_hotMap); } else { - if (m_doAbortNoHotMap) + calibdir_hotMap = CDBInterface::instance()->getUrl(m_calibName_hotMap); + if (!calibdir_hotMap.empty()) { - std::cout << "CaloTowerStatus::InitRun: No hot map found for " << m_calibName_hotMap << " and abort mode is set. Exiting." << std::endl; - gSystem->Exit(1); - } - if (use_directURL_hotMap) - { - calibdir = m_directURL_hotMap; - std::cout << "CaloTowerStatus::InitRun: Using default map " << calibdir << std::endl; - m_cdbttree_hotMap = new CDBTTree(calibdir); + m_cdbttree_hotMap = new CDBTTree(calibdir_hotMap); + if (Verbosity() > 1) + { + std::cout << "CaloTowerStatus::Init " << m_detector << " hot map found " << m_calibName_hotMap << " Ddoing isHot" << std::endl; + } } else { + if (m_doAbortNoHotMap) + { + std::cout << "CaloTowerStatus::InitRun: No hot map found for " << m_calibName_hotMap << " and abort mode is set. Exiting." << std::endl; + gSystem->Exit(1); + } m_doHotMap = false; if (Verbosity() > 1) { From b3467b76fb6610d0a571711955b2c56be083b27d Mon Sep 17 00:00:00 2001 From: Apurva Narde <58493193+Steepspace@users.noreply.github.com> Date: Mon, 11 May 2026 21:22:03 -0500 Subject: [PATCH 2/3] Fix Typo in Log Message "Ddoing" - > "Doing" Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- offline/packages/CaloReco/CaloTowerStatus.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/offline/packages/CaloReco/CaloTowerStatus.cc b/offline/packages/CaloReco/CaloTowerStatus.cc index c3a621b826..2d0be5a892 100644 --- a/offline/packages/CaloReco/CaloTowerStatus.cc +++ b/offline/packages/CaloReco/CaloTowerStatus.cc @@ -133,7 +133,7 @@ int CaloTowerStatus::InitRun(PHCompositeNode *topNode) m_cdbttree_hotMap = new CDBTTree(calibdir_hotMap); if (Verbosity() > 1) { - std::cout << "CaloTowerStatus::Init " << m_detector << " hot map found " << m_calibName_hotMap << " Ddoing isHot" << std::endl; + std::cout << "CaloTowerStatus::Init " << m_detector << " hot map found " << m_calibName_hotMap << " Doing isHot" << std::endl; } } else From ad25fc22e314edbeb0dbdaf01d7d2b9f0b6ee135 Mon Sep 17 00:00:00 2001 From: Apurva Narde <58493193+Steepspace@users.noreply.github.com> Date: Tue, 12 May 2026 11:28:11 -0400 Subject: [PATCH 3/3] CaloTowerStatus: Remove redundant flags - Removed 'use_directURL_hotMap' and 'use_directURL_chi2' boolean flags. - Updated InitRun to check if URL strings are non-empty to determine if a direct override should be used. - Ensured that a non-empty direct URL string takes precedence over the default CDBInterface lookup. This change prevents potential bugs where a flag could be set to true without a valid filename, and streamlines the code by relying on the string's presence as the single source of truth for the override. --- offline/packages/CaloReco/CaloTowerStatus.cc | 4 ++-- offline/packages/CaloReco/CaloTowerStatus.h | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/offline/packages/CaloReco/CaloTowerStatus.cc b/offline/packages/CaloReco/CaloTowerStatus.cc index 2d0be5a892..f9e63348b6 100644 --- a/offline/packages/CaloReco/CaloTowerStatus.cc +++ b/offline/packages/CaloReco/CaloTowerStatus.cc @@ -82,7 +82,7 @@ int CaloTowerStatus::InitRun(PHCompositeNode *topNode) m_fieldname_chi2 = "fraction"; std::string calibdir_chi2; - if (use_directURL_chi2) + if (!m_directURL_chi2.empty()) { calibdir_chi2 = m_directURL_chi2; std::cout << "CaloTowerStatus::InitRun: Using direct URL override for chi2: " << calibdir_chi2 << std::endl; @@ -119,7 +119,7 @@ int CaloTowerStatus::InitRun(PHCompositeNode *topNode) m_fieldname_z_score = m_detector + "_sigma"; std::string calibdir_hotMap; - if (use_directURL_hotMap) + if (!m_directURL_hotMap.empty()) { calibdir_hotMap = m_directURL_hotMap; std::cout << "CaloTowerStatus::InitRun: Using direct URL override for hot map: " << calibdir_hotMap << std::endl; diff --git a/offline/packages/CaloReco/CaloTowerStatus.h b/offline/packages/CaloReco/CaloTowerStatus.h index 1c50486281..9c261155c4 100644 --- a/offline/packages/CaloReco/CaloTowerStatus.h +++ b/offline/packages/CaloReco/CaloTowerStatus.h @@ -71,13 +71,11 @@ class CaloTowerStatus : public SubsysReco void set_directURL_hotMap(const std::string &str) { m_directURL_hotMap = str; - use_directURL_hotMap = true; return; } void set_directURL_chi2(const std::string &str) { m_directURL_chi2 = str; - use_directURL_chi2 = true; return; } void set_doAbortNoHotMap(bool status = true) @@ -121,8 +119,6 @@ class CaloTowerStatus : public SubsysReco std::string m_directURL_hotMap; std::string m_directURL_chi2; - bool use_directURL_hotMap{false}; - bool use_directURL_chi2{false}; float badChi2_treshold_const = {1e4}; float badChi2_treshold_quadratic = {1./100};