diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibSvc/MdtCalibSvc/MdtCalibrationDbTool.h b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibSvc/MdtCalibSvc/MdtCalibrationDbTool.h index f0fec1632a7903403e99e0485a102d967665eb4f..ec8e5c5f8b5d4af7378fa385ef8f6f66f8363b79 100644 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibSvc/MdtCalibSvc/MdtCalibrationDbTool.h +++ b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibSvc/MdtCalibSvc/MdtCalibrationDbTool.h @@ -1,28 +1,22 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef MDTCALIBSVC_MDTCALIBRATIONDBTOOL_H #define MDTCALIBSVC_MDTCALIBRATIONDBTOOL_H -#include "AthenaBaseComps/AthService.h" -#include "GaudiKernel/IInterface.h" -#include "GaudiKernel/ToolHandle.h" // for configurables -#include "AthenaKernel/IOVSvcDefs.h" +#include "AthenaBaseComps/AthAlgTool.h" +#include "GaudiKernel/ServiceHandle.h" #include "MdtCalibData/MdtRtRelationCollection.h" #include "MdtCalibData/MdtTubeCalibContainerCollection.h" #include "MdtCalibData/MdtCorFuncSetCollection.h" - -#include "GaudiKernel/AlgTool.h" -#include "AthenaBaseComps/AthAlgTool.h" - #include "StoreGate/ReadCondHandleKey.h" +#include "MuonIdHelpers/IMuonIdHelperSvc.h" + +#include <string> class MdtCalibrationRegionSvc; -class MdtIdHelper; -class Identifier; -class IdentifierHash; namespace MuonCalib{ class IMdtCalibDBTool; @@ -39,7 +33,7 @@ public: MdtCalibrationDbTool(const std::string& type, const std::string &name, const IInterface* parent); /** destructor */ - virtual ~MdtCalibrationDbTool(); + virtual ~MdtCalibrationDbTool()=default; /** IInterface implementation */ static const InterfaceID &interfaceID() { static InterfaceID s_iID("MdtCalibrationDbTool", 1, 0); @@ -79,9 +73,7 @@ public: private: /** handle to region service */ ServiceHandle<MdtCalibrationRegionSvc> m_regionSvc; - - /** Id Helper used to retrieve hashes from IDs */ - const MdtIdHelper *m_mdtIdHelper; + ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; /** create the correction functions */ void initialize_B_correction(MuonCalib::MdtCorFuncSet *funcSet, @@ -96,6 +88,8 @@ private: bool m_getTubeConstants; //<! flag to switch off loading of tube constants bool m_getCorrections; //<! flag to switch off loading of correction function constants + bool m_hasBISsMDT; + SG::ReadCondHandleKey<MdtRtRelationCollection> m_readKeyRt{this,"MdtRtRelationCollection","MdtRtRelationCollection","MDT RT relations"}; SG::ReadCondHandleKey<MdtTubeCalibContainerCollection> m_readKeyTube{this,"MdtTubeCalibContainerCollection","MdtTubeCalibContainerCollection","MDT tube calib"}; SG::ReadCondHandleKey<MdtCorFuncSetCollection> m_readKeyCor{this,"MdtCorFuncSetCollection","MdtCorFuncSetCollection","MDT cor Funcs"}; diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibSvc/src/MdtCalibrationDbTool.cxx b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibSvc/src/MdtCalibrationDbTool.cxx index f16d455e4b36c289d618a1289c2efb1be181678e..6f51e34e97c8492a78af820102a431d6ec7f16ba 100644 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibSvc/src/MdtCalibrationDbTool.cxx +++ b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibSvc/src/MdtCalibrationDbTool.cxx @@ -3,17 +3,8 @@ */ #include "MdtCalibSvc/MdtCalibrationDbTool.h" -#include "GaudiKernel/ISvcLocator.h" -#include "GaudiKernel/Bootstrap.h" -#include "GaudiKernel/MsgStream.h" -#include "GaudiKernel/IMessageSvc.h" -#include "Identifier/IdentifierHash.h" -#include "MuonIdHelpers/MdtIdHelper.h" #include "MdtCalibSvc/MdtCalibrationRegionSvc.h" - -#include <string> - #include "MdtCalibData/MdtFullCalibData.h" #include "MdtCalibData/BFieldCorFunc.h" #include "MdtCalibData/WireSagCorFunc.h" @@ -23,7 +14,7 @@ MdtCalibrationDbTool::MdtCalibrationDbTool(const std::string& type, const std::string &name, const IInterface* parent) : base_class(type, name, parent), m_regionSvc("MdtCalibrationRegionSvc", name), - m_mdtIdHelper(0) + m_hasBISsMDT(false) { declareProperty("AccessTubeConstants", m_getTubeConstants = true, "configure the Tool to retrieve the constants per tube (t0)"); @@ -37,21 +28,17 @@ MdtCalibrationDbTool::MdtCalibrationDbTool(const std::string& type, const std::s "If set to true, the slewing correction functions are initialized for each rt-relation that is loaded."); } -MdtCalibrationDbTool::~MdtCalibrationDbTool() {} - StatusCode MdtCalibrationDbTool::initialize() { if ( m_regionSvc.retrieve().isFailure() ) { ATH_MSG_ERROR( "Failed to retrieve MdtCalibrationRegionSvc" ); return StatusCode::FAILURE; } - - // initialize the MdtIdHelper - if (detStore()->retrieve(m_mdtIdHelper, "MDTIDHELPER" ).isFailure()) { - ATH_MSG_ERROR( "Can't retrieve MdtIdHelper" ); - return StatusCode::FAILURE; - } + ATH_CHECK(m_idHelperSvc.retrieve()); + int bisIndex=m_idHelperSvc->mdtIdHelper().stationNameIndex("BIS"); + Identifier bis7Id = m_idHelperSvc->mdtIdHelper().elementID(bisIndex, 7, 1); + if (m_idHelperSvc->issMdt(bis7Id)) m_hasBISsMDT=true; ATH_CHECK(m_readKeyRt.initialize()); ATH_CHECK(m_readKeyTube.initialize()); ATH_CHECK(m_readKeyCor.initialize (m_createSlewingFunction || m_createWireSagFunction || m_create_b_field_function)); @@ -65,14 +52,14 @@ StatusCode MdtCalibrationDbTool::initialize() { MuonCalib::MdtFullCalibData MdtCalibrationDbTool::getCalibration( const Identifier &idt ) const { - Identifier id = m_mdtIdHelper->elementID( idt ); + Identifier id = m_idHelperSvc->mdtIdHelper().elementID( idt ); IdentifierHash mlHash; //hash for ML (needed when using ML-RT functions) - m_mdtIdHelper->get_detectorElement_hash( id, mlHash ); //hash for the ML + m_idHelperSvc->mdtIdHelper().get_detectorElement_hash( id, mlHash ); //hash for the ML IdentifierHash chamberHash; - IdContext idCont = m_mdtIdHelper->module_context(); - m_mdtIdHelper->get_hash( id, chamberHash, &idCont ); + IdContext idCont = m_idHelperSvc->mdtIdHelper().module_context(); + m_idHelperSvc->mdtIdHelper().get_hash( id, chamberHash, &idCont ); return getCalibration( chamberHash, mlHash ); } @@ -108,9 +95,13 @@ MuonCalib::MdtFullCalibData MdtCalibrationDbTool::getCalibration( const Identifi // find t0's if( m_getTubeConstants && tubeHash.is_valid() ) { - tube = getTubeCalibContainer( tubeHash ); - if( !tube ){ - ATH_MSG_WARNING( "Not valid MdtTubeCalibContainer found " ); + if (m_hasBISsMDT) { + ATH_MSG_WARNING("skipping retrieval of TubeCalibContainer since no BIS sMDT calibrations available in conditions database"); + } else { + tube = getTubeCalibContainer( tubeHash ); + if( !tube ){ + ATH_MSG_WARNING( "Not valid MdtTubeCalibContainer found " ); + } } } @@ -118,11 +109,11 @@ MuonCalib::MdtFullCalibData MdtCalibrationDbTool::getCalibration( const Identifi } const MuonCalib::MdtTubeCalibContainer* MdtCalibrationDbTool::getTubeCalibContainer( const Identifier &idt ) const { - Identifier id = m_mdtIdHelper->elementID( idt ); + Identifier id = m_idHelperSvc->mdtIdHelper().elementID( idt ); IdentifierHash hash; - IdContext idCont = m_mdtIdHelper->module_context(); - m_mdtIdHelper->get_hash( id, hash, &idCont ); + IdContext idCont = m_idHelperSvc->mdtIdHelper().module_context(); + m_idHelperSvc->mdtIdHelper().get_hash( id, hash, &idCont ); return getTubeCalibContainer( hash ); } @@ -146,14 +137,14 @@ const MuonCalib::MdtTubeCalibContainer* MdtCalibrationDbTool::getTubeCalibContai } const MuonCalib::MdtRtRelation* MdtCalibrationDbTool::getRtCalibration( const Identifier &idt ) const { - Identifier id = m_mdtIdHelper->elementID( idt ); + Identifier id = m_idHelperSvc->mdtIdHelper().elementID( idt ); IdentifierHash hash; if( m_regionSvc->RegionType()==ONEPERMULTILAYER ) { - m_mdtIdHelper->get_detectorElement_hash( id, hash ); //hash for the ML + m_idHelperSvc->mdtIdHelper().get_detectorElement_hash( id, hash ); //hash for the ML } else { - IdContext idCont = m_mdtIdHelper->module_context(); - m_mdtIdHelper->get_hash( id, hash, &idCont ); //hash for the chamber + IdContext idCont = m_idHelperSvc->mdtIdHelper().module_context(); + m_idHelperSvc->mdtIdHelper().get_hash( id, hash, &idCont ); //hash for the chamber } hash = m_regionSvc->getRegionHash(hash); return getRtCalibration( hash ); @@ -179,14 +170,14 @@ const MuonCalib::MdtRtRelation* MdtCalibrationDbTool::getRtCalibration( const Id } const MuonCalib::MdtCorFuncSet* MdtCalibrationDbTool::getCorFunctions( const Identifier &idt ) const { - Identifier id = m_mdtIdHelper->elementID( idt ); + Identifier id = m_idHelperSvc->mdtIdHelper().elementID( idt ); IdentifierHash hash; if( m_regionSvc->RegionType()==ONEPERMULTILAYER ) { - m_mdtIdHelper->get_detectorElement_hash( id, hash ); //hash for the ML + m_idHelperSvc->mdtIdHelper().get_detectorElement_hash( id, hash ); //hash for the ML } else { - IdContext idCont = m_mdtIdHelper->module_context(); - m_mdtIdHelper->get_hash( id, hash, &idCont ); //hash for the chamber + IdContext idCont = m_idHelperSvc->mdtIdHelper().module_context(); + m_idHelperSvc->mdtIdHelper().get_hash( id, hash, &idCont ); //hash for the chamber } hash = m_regionSvc->getRegionHash(hash); return getCorFunctions( hash );