diff --git a/MuonSpectrometer/MuonIdHelpers/src/MdtIdHelper.cxx b/MuonSpectrometer/MuonIdHelpers/src/MdtIdHelper.cxx index debbda5ead31d4755e27324b22e2e31a8b976f4c..5ce6f808b2f02283477dcefd7bf8fa8320186a27 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 dbf527ca2a7b7460937031bdbec7d9fc3ed1e98a..b5396811e746a4880f90bc24e4e55ca581da7411 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 791fdc43211c5ca3663e255853f793729411a172..7c97876763566e25912296828a0ad6d01815ebda 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,