diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibDbCoolStrTool/src/MdtCalibDbAlg.cxx b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibDbCoolStrTool/src/MdtCalibDbAlg.cxx index 2d13011dbed7e1f135a4032f64a3a590c0676e36..f868b660ec308753b72180ce9fee7d04f35fd5c7 100644 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibDbCoolStrTool/src/MdtCalibDbAlg.cxx +++ b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibDbCoolStrTool/src/MdtCalibDbAlg.cxx @@ -461,7 +461,10 @@ StatusCode MdtCalibDbAlg::loadRt(){ IdentifierHash hash; //chamber hash IdContext idCont = m_muonIdHelperTool->mdtIdHelper().module_context(); idCont = m_muonIdHelperTool->mdtIdHelper().module_context(); - m_muonIdHelperTool->mdtIdHelper().get_hash( athenaId, hash, &idCont ); + if (m_muonIdHelperTool->mdtIdHelper().get_hash( athenaId, hash, &idCont )) { + ATH_MSG_ERROR("Could not retrieve module hash for identifier " << athenaId.get_compact()); + return StatusCode::FAILURE; + } ATH_MSG_VERBOSE( "Fixed region Id "<<regionId<<" converted into athena Id "<<athenaId <<" and then into hash "<<hash); regionId = hash; //reset regionId to chamber hash } @@ -717,7 +720,10 @@ StatusCode MdtCalibDbAlg::defaultT0s(std::unique_ptr<MdtTubeCalibContainerCollec ATH_MSG_VERBOSE( " set t0's done " ); IdentifierHash hash; IdContext idCont = m_muonIdHelperTool->mdtIdHelper().module_context(); - m_muonIdHelperTool->mdtIdHelper().get_hash( *it, hash, &idCont ); + if (m_muonIdHelperTool->mdtIdHelper().get_hash( *it, hash, &idCont )) { + ATH_MSG_ERROR("Could not retrieve module hash for identifier " << (*it).get_compact()); + return StatusCode::FAILURE; + } if( hash < writeCdoTube->size() ){ (*writeCdoTube)[hash] = tubes; @@ -837,15 +843,32 @@ StatusCode MdtCalibDbAlg::loadTube(){ } delete [] parameters; - // find chamber ID - Identifier chId = m_muonIdHelperTool->mdtIdHelper().elementID(name,ieta,iphi); + // need to check validity of Identifier since database contains all Run 2 MDT chambers, e.g. also EI chambers which are + // potentially replaced by NSW + bool isValid = true; // the elementID takes a bool pointer to check the validity of the Identifier + Identifier chId = m_muonIdHelperTool->mdtIdHelper().elementID(name,ieta,iphi,true,&isValid); + if (!isValid) { + ATH_MSG_WARNING("Element Identifier " << chId.get_compact() << " retrieved for station name " << name << " is not valid, skipping..."); + continue; + } MuonCalib::MdtTubeCalibContainer *tubes = NULL; // get chamber hash IdentifierHash hash; IdContext idCont = m_muonIdHelperTool->mdtIdHelper().module_context(); - m_muonIdHelperTool->mdtIdHelper().get_hash( chId , hash, &idCont ); + if (m_muonIdHelperTool->mdtIdHelper().get_hash( chId , hash, &idCont )) ATH_MSG_WARNING("Retrieving module hash for Identifier " << chId.get_compact() << " failed"); + + // we have to check whether the retrieved Identifier is valid. The problem is that the is_valid() function of the Identifier class does only check + // for the size of the number, not for the physical validity. The get_detectorElement_hash function of the MuonIdHelper however returns + // an error in case the Identifier is not part of the vector of physically valid Identifiers (the check could also be done using the module hash) + // It is important that the methods from MuonIdHelper are called which are not overwritten by the MdtIdHelper + IdentifierHash detElHash; + if (m_muonIdHelperTool->mdtIdHelper().MuonIdHelper::get_detectorElement_hash(chId, detElHash )) { + ATH_MSG_WARNING("Retrieving detector element hash for Identifier " << chId.get_compact() << " failed, thus Identifier (original information was name=" + << name << ", eta=" << ieta << ", phi=" << iphi << ") is not valid, skipping..."); + continue; + } if( msgLvl(MSG::VERBOSE) ) { ATH_MSG_VERBOSE( "name of chamber is " << pch << " station name is " << name ); diff --git a/MuonSpectrometer/MuonReconstruction/MuonRecExample/python/MooreTools.py b/MuonSpectrometer/MuonReconstruction/MuonRecExample/python/MooreTools.py index 6f36e7242dbef588f8c8088254e6a0cc40273aeb..7cbb599f09628860a3c3efe260f057698de69333 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonRecExample/python/MooreTools.py +++ b/MuonSpectrometer/MuonReconstruction/MuonRecExample/python/MooreTools.py @@ -419,7 +419,7 @@ def MuonChamberHoleRecoveryTool(name="MuonChamberHoleRecoveryTool",extraFlags=No # add in missing C++ dependency. TODO: fix in C++ getPublicTool("ResidualPullCalculator") - if (CommonGeometryFlags.Run() in ["RUN3", "RUN4"]): + if not (CommonGeometryFlags.Run() in ["RUN3", "RUN4"]): kwargs.setdefault("sTgcPrepDataContainer","") kwargs.setdefault("MMPrepDataContainer","") diff --git a/MuonSpectrometer/MuonTruthAlgs/src/MuonSegmentTruthAssociationAlg.cxx b/MuonSpectrometer/MuonTruthAlgs/src/MuonSegmentTruthAssociationAlg.cxx index b28edd5b96feb659148faf0110335c5ef7e72540..d6e4d5dd2833b332688041840554f1976eaa94c5 100644 --- a/MuonSpectrometer/MuonTruthAlgs/src/MuonSegmentTruthAssociationAlg.cxx +++ b/MuonSpectrometer/MuonTruthAlgs/src/MuonSegmentTruthAssociationAlg.cxx @@ -116,7 +116,7 @@ namespace Muon { if(!simDataMap.isPresent()) continue; muonSimData.push_back(simDataMap.cptr()); } - if(!m_hasCSC){ + if(m_hasCSC){ SG::ReadHandle<CscSimDataCollection> cscSimDataMap(m_cscSimData); if(!cscSimDataMap.isValid()){ ATH_MSG_WARNING(cscSimDataMap.key()<<" not valid"); diff --git a/Reconstruction/MuonIdentification/MuonSegmentTaggers/MuonSegmentTaggerTools/src/MuTagMatchingTool.cxx b/Reconstruction/MuonIdentification/MuonSegmentTaggers/MuonSegmentTaggerTools/src/MuTagMatchingTool.cxx index eea7ab8d9c884d45d9e40be2fa3cfef2ed020e4d..519ce4eebd55e4ad55f18812821afe755f0a7995 100644 --- a/Reconstruction/MuonIdentification/MuonSegmentTaggers/MuonSegmentTaggerTools/src/MuTagMatchingTool.cxx +++ b/Reconstruction/MuonIdentification/MuonSegmentTaggers/MuonSegmentTaggerTools/src/MuTagMatchingTool.cxx @@ -202,7 +202,7 @@ std::string MuTagMatchingTool::segmentStationString( const Muon::MuonSegment* se if( m_muonIdHelperTool->mdtIdHelper().is_mdt(segID) ){ station = m_muonIdHelperTool->mdtIdHelper().stationNameString( m_muonIdHelperTool->mdtIdHelper().stationName( segID ) ); break; - } else if( m_muonIdHelperTool->cscIdHelper().is_csc(segID) ){ + } else if( m_muonIdHelperTool->isCsc(segID) ){ station = m_muonIdHelperTool->cscIdHelper().stationNameString( m_muonIdHelperTool->cscIdHelper().stationName( segID ) ); break ; } @@ -1143,7 +1143,7 @@ bool MuTagMatchingTool::isCscSegment( const Muon::MuonSegment* seg ) const { if( !rot ) { continue; } - if( m_muonIdHelperTool->cscIdHelper().is_csc( rot->identify() ) ) isCsc=true; + if( m_muonIdHelperTool->isCsc( rot->identify() ) ) isCsc=true; } return isCsc; @@ -1164,7 +1164,7 @@ unsigned int MuTagMatchingTool::cscHits( const Muon::MuonSegment* seg ) const { if( !rot ) { continue; } - if( m_muonIdHelperTool->cscIdHelper().is_csc( rot->identify() ) ) ++nrHits; + if( m_muonIdHelperTool->isCsc( rot->identify() ) ) ++nrHits; } return nrHits ;