From 28c31f572e12b8d10bbbb37e6da0f0d5ed439cff Mon Sep 17 00:00:00 2001 From: Edward Moyse <edward.moyse@cern.ch> Date: Mon, 26 Sep 2022 13:29:24 +0200 Subject: [PATCH] Merge branch 'IdHelper_isValidVolII' into 'master' MuonIdHelpers -- Pick-up missed isValid protections See merge request atlas/athena!57025 (cherry picked from commit 0a2f98eb77650dd919040c775539eb4a73426dc6) 9a71348b Pick-up missed isValid protections --- .../MuonIdHelpers/src/MdtIdHelper.cxx | 9 ++++++--- .../MuonIdHelpers/src/MmIdHelper.cxx | 9 ++++++--- .../MuonIdHelpers/src/sTgcIdHelper.cxx | 18 ++++++++++++------ 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/MuonSpectrometer/MuonIdHelpers/src/MdtIdHelper.cxx b/MuonSpectrometer/MuonIdHelpers/src/MdtIdHelper.cxx index debbda5ead31..5ce6f808b2f0 100644 --- a/MuonSpectrometer/MuonIdHelpers/src/MdtIdHelper.cxx +++ b/MuonSpectrometer/MuonIdHelpers/src/MdtIdHelper.cxx @@ -693,9 +693,12 @@ Identifier MdtIdHelper::channelID(int stationName, int stationEta, int stationPh } Identifier MdtIdHelper::channelID(int stationName, int stationEta, int stationPhi, int multilayer, int tubeLayer, int tube, bool& isValid) const { - const Identifier result = channelID(stationName, stationEta, stationPhi, multilayer, tubeLayer, tube); - isValid = stationName >= 0 && validChannel(result, stationName, stationEta, stationPhi, multilayer, tubeLayer, tube); - return result; + try{ + const Identifier result = channelID(stationName, stationEta, stationPhi, multilayer, tubeLayer, tube); + isValid = stationName >= 0 && validChannel(result, stationName, stationEta, stationPhi, multilayer, tubeLayer, tube); + return result; + } catch (const std::out_of_range&) { isValid = false; } + return Identifier{0}; } Identifier MdtIdHelper::channelID(const std::string& stationNameStr, int stationEta, int stationPhi, int multilayer, int tubeLayer, diff --git a/MuonSpectrometer/MuonIdHelpers/src/MmIdHelper.cxx b/MuonSpectrometer/MuonIdHelpers/src/MmIdHelper.cxx index dbf527ca2a7b..b5396811e746 100644 --- a/MuonSpectrometer/MuonIdHelpers/src/MmIdHelper.cxx +++ b/MuonSpectrometer/MuonIdHelpers/src/MmIdHelper.cxx @@ -676,9 +676,12 @@ Identifier MmIdHelper::channelID(int stationName, int stationEta, int stationPhi } Identifier MmIdHelper::channelID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channel, bool& isValid) const { - const Identifier result = channelID(stationName, stationEta, stationPhi, multilayer, gasGap, channel); - isValid = validChannel(result, stationName, stationEta, stationPhi, multilayer, gasGap, channel); - return result; + try{ + const Identifier result = channelID(stationName, stationEta, stationPhi, multilayer, gasGap, channel); + isValid = validChannel(result, stationName, stationEta, stationPhi, multilayer, gasGap, channel); + return result; + } catch (const std::out_of_range&) { isValid = false; } + return Identifier{0}; } /*******************************************************************************/ Identifier MmIdHelper::channelID(const std::string& stationNameStr, int stationEta, int stationPhi, int multilayer, int gasGap, int channel, diff --git a/MuonSpectrometer/MuonIdHelpers/src/sTgcIdHelper.cxx b/MuonSpectrometer/MuonIdHelpers/src/sTgcIdHelper.cxx index 791fdc43211c..7c9787676356 100644 --- a/MuonSpectrometer/MuonIdHelpers/src/sTgcIdHelper.cxx +++ b/MuonSpectrometer/MuonIdHelpers/src/sTgcIdHelper.cxx @@ -827,9 +827,12 @@ Identifier sTgcIdHelper::channelID(int stationName, int stationEta, int stationP } Identifier sTgcIdHelper::channelID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channelType, int channel, bool& isValid) const { - const Identifier result = channelID(stationName, stationEta, stationPhi, multilayer, gasGap, channelType, channel); - isValid = validChannel(result, stationName, stationEta, stationPhi, multilayer, gasGap, channelType, channel); - return result; + try { + const Identifier result = channelID(stationName, stationEta, stationPhi, multilayer, gasGap, channelType, channel); + isValid = validChannel(result, stationName, stationEta, stationPhi, multilayer, gasGap, channelType, channel); + return result; + } catch (const std::out_of_range&) { isValid = false; } + return Identifier{0}; } /*******************************************************************************/ Identifier sTgcIdHelper::channelID(const std::string& stationNameStr, int stationEta, int stationPhi, int multilayer, int gasGap, @@ -851,9 +854,12 @@ Identifier sTgcIdHelper::channelID(const Identifier& id, int multilayer, int gas return result; } Identifier sTgcIdHelper::channelID(const Identifier& id, int multilayer, int gasGap, int channelType, int channel, bool& isValid) const { - const Identifier result = channelID(id, multilayer, gasGap, channelType, channel); - isValid = valid(result); - return result; + try{ + const Identifier result = channelID(id, multilayer, gasGap, channelType, channel); + isValid = valid(result); + return result; + } catch (const std::out_of_range&) { isValid = false; } + return Identifier{0}; } /*******************************************************************************/ Identifier sTgcIdHelper::padID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channelType, int padEta, -- GitLab