diff --git a/InnerDetector/InDetDigitization/TRT_Digitization/CMakeLists.txt b/InnerDetector/InDetDigitization/TRT_Digitization/CMakeLists.txt index 4c6340a28227d399e04b87250b4c38a8456b4883..5fe6725f6bc37d3a19729d370a0e4537271b2bf2 100644 --- a/InnerDetector/InDetDigitization/TRT_Digitization/CMakeLists.txt +++ b/InnerDetector/InDetDigitization/TRT_Digitization/CMakeLists.txt @@ -29,7 +29,6 @@ atlas_depends_on_subdirs( PUBLIC InnerDetector/InDetRawEvent/InDetSimData InnerDetector/InDetSimEvent InnerDetector/InDetSimUtils/TRT_PAI_Process - MagneticField/MagFieldInterfaces Simulation/HitManagement MagneticField/MagFieldElements MagneticField/MagFieldConditions ) @@ -45,7 +44,7 @@ atlas_add_component( TRT_Digitization src/*.cxx src/components/*.cxx INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${HEPPDT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} ${HEPPDT_LIBRARIES} ${CLHEP_LIBRARIES} ${EIGEN_LIBRARIES} GaudiKernel AthenaBaseComps AthenaKernel PileUpToolsLib AthenaPoolUtilities GeoModelUtilities GeoPrimitives Identifier EventInfo GeneratorObjects TRT_ConditionsData TRT_ConditionsServicesLib InDetIdentifier InDetReadoutGeometry TRT_ReadoutGeometry InDetRawData InDetSimData InDetSimEvent MagFieldInterfaces HitManagement MagFieldElements MagFieldConditions) + LINK_LIBRARIES ${ROOT_LIBRARIES} ${HEPPDT_LIBRARIES} ${CLHEP_LIBRARIES} ${EIGEN_LIBRARIES} GaudiKernel AthenaBaseComps AthenaKernel PileUpToolsLib AthenaPoolUtilities GeoModelUtilities GeoPrimitives Identifier EventInfo GeneratorObjects TRT_ConditionsData TRT_ConditionsServicesLib InDetIdentifier InDetReadoutGeometry TRT_ReadoutGeometry InDetRawData InDetSimData InDetSimEvent HitManagement MagFieldElements MagFieldConditions) # Install files from the package: atlas_install_python_modules( python/*.py ) diff --git a/InnerDetector/InDetDigitization/TRT_Digitization/src/TRTDigitizationTool.cxx b/InnerDetector/InDetDigitization/TRT_Digitization/src/TRTDigitizationTool.cxx index 5063ecfaf8ef2a37cbe19863c7cc87a766647879..3f8f6c5d3abb51e13475f72b9268eff4376e6d8e 100644 --- a/InnerDetector/InDetDigitization/TRT_Digitization/src/TRTDigitizationTool.cxx +++ b/InnerDetector/InDetDigitization/TRT_Digitization/src/TRTDigitizationTool.cxx @@ -155,9 +155,6 @@ StatusCode TRTDigitizationTool::initialize() //Retrieve TRT_CalDbTool ATH_CHECK(m_calDbTool.retrieve()); - // Get the magnetic field service - ATH_CHECK(m_magneticfieldsvc.retrieve()); - m_minpileuptruthEkin = m_settings->pileUpSDOsMinEkin(); // Set SDO readout range @@ -186,7 +183,7 @@ StatusCode TRTDigitizationTool::initialize() } ////////////////////////////////////////////////////////////////////////////////////////////////////////////// - ATH_CHECK( m_fieldCondObjInputKey.initialize() ); + ATH_CHECK( m_fieldCacheCondObjInputKey.initialize() ); ////////////////////////////////////////////////////////////////////////////////////////////////////////////// return StatusCode::SUCCESS; @@ -321,14 +318,12 @@ StatusCode TRTDigitizationTool::lateInitialize(const EventContext& ctx) { ITRT_SimDriftTimeTool *pTRTsimdrifttimetool = &(*m_TRTsimdrifttimetool); - MagField::IMagFieldSvc *pMagfieldsvc = &(*m_magneticfieldsvc); const ITRT_CalDbTool* calDbTool=m_calDbTool.get(); m_pProcessingOfStraw = new TRTProcessingOfStraw( m_settings, m_manager, TRTpaiToolXe, pTRTsimdrifttimetool, - pMagfieldsvc, m_pElectronicsProcessing, m_pNoise, m_pDigConditions, @@ -361,11 +356,11 @@ StatusCode TRTDigitizationTool::processStraws(const EventContext& ctx, if (m_settings->useMagneticFieldMap()) { // Get field cache object - SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCondObjInputKey, ctx}; + SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; if (fieldCondObj == nullptr) { - ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCondObjInputKey.key()); + ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); return StatusCode::FAILURE; } fieldCondObj->getInitializedCache (fieldCache); diff --git a/InnerDetector/InDetDigitization/TRT_Digitization/src/TRTDigitizationTool.h b/InnerDetector/InDetDigitization/TRT_Digitization/src/TRTDigitizationTool.h index d4f4f520a5878b6b4107623ff27574fb7fc1985a..9ad824c3832a4c68d545fcc5a31a7c98b379b499 100644 --- a/InnerDetector/InDetDigitization/TRT_Digitization/src/TRTDigitizationTool.h +++ b/InnerDetector/InDetDigitization/TRT_Digitization/src/TRTDigitizationTool.h @@ -27,7 +27,6 @@ #include "TRTDigit.h" // For magneticfield -#include "MagFieldInterfaces/IMagFieldSvc.h" #include "MagFieldConditions/AtlasFieldCacheCondObj.h" #include "StoreGate/ReadHandleKey.h" @@ -133,10 +132,9 @@ private: ServiceHandle<PileUpMergeSvc> m_mergeSvc{this, "MergeSvc", "PileUpMergeSvc", "Merge service"}; ServiceHandle<IAthRNGSvc> m_rndmSvc{this, "RndmSvc", "AthRNGSvc", ""}; //!< Random number service ServiceHandle<ITRT_StrawNeighbourSvc> m_TRTStrawNeighbourSvc{this, "TRT_StrawNeighbourSvc", "TRT_StrawNeighbourSvc", ""}; - ServiceHandle < MagField::IMagFieldSvc > m_magneticfieldsvc{this, "MagFieldSvc", "AtlasFieldSvc", "MagFieldSvc used by TRTProcessingOfStraw"}; // Read handle for conditions object to get the field cache - SG::ReadCondHandleKey<AtlasFieldCacheCondObj> m_fieldCondObjInputKey {this, "AtlasFieldCacheCondObj", "fieldCondObj", - "Name of the Magnetic Field conditions object key"}; + SG::ReadCondHandleKey<AtlasFieldCacheCondObj> m_fieldCacheCondObjInputKey {this, "AtlasFieldCacheCondObj", "fieldCondObj", + "Name of the Magnetic Field conditions object key"}; Gaudi::Property<bool> m_onlyUseContainerName{this, "OnlyUseContainerName", true, "Don't use the ReadHandleKey directly. Just extract the container name from it."}; SG::ReadHandleKey<TRTUncompressedHitCollection> m_hitsContainerKey{this, "DataObjectName", "TRTUncompressedHits", "Data Object Name"}; std::string m_dataObjectName{""}; diff --git a/InnerDetector/InDetDigitization/TRT_Digitization/src/TRTProcessingOfStraw.cxx b/InnerDetector/InDetDigitization/TRT_Digitization/src/TRTProcessingOfStraw.cxx index 0747a150eefee9626cdc12eb8e657d5a0311c2b6..2a5154bc67f6b7301e977c4e5b8fe599627ba574 100644 --- a/InnerDetector/InDetDigitization/TRT_Digitization/src/TRTProcessingOfStraw.cxx +++ b/InnerDetector/InDetDigitization/TRT_Digitization/src/TRTProcessingOfStraw.cxx @@ -41,9 +41,6 @@ #include <cmath> #include <cstdlib> //Always include this when including cmath! -// For magneticfield -#include "MagFieldInterfaces/IMagFieldSvc.h" - // Logging #include "AthenaBaseComps/AthMsgStreamMacros.h" @@ -52,7 +49,6 @@ TRTProcessingOfStraw::TRTProcessingOfStraw(const TRTDigSettings* digset, const InDetDD::TRT_DetectorManager* detmgr, ITRT_PAITool* paitoolXe, ITRT_SimDriftTimeTool* simdrifttool, - MagField::IMagFieldSvc * magfieldsvc, TRTElectronicsProcessing * ep, TRTNoise * noise, TRTDigCondBase* digcond, @@ -76,7 +72,6 @@ TRTProcessingOfStraw::TRTProcessingOfStraw(const TRTDigSettings* digset, m_pDigConditions(digcond), m_pParticleTable(pdt), m_alreadywarnedagainstpdg0(false), - m_magneticfieldsvc(magfieldsvc), m_msg("TRTProcessingOfStraw"), m_id_helper(trt_id) @@ -609,11 +604,8 @@ void TRTProcessingOfStraw::ClustersToDeposits (MagField::AtlasFieldCache& fieldC globalPosition[1]=TRThitGlobalPos[1]*CLHEP::mm; globalPosition[2]=TRThitGlobalPos[2]*CLHEP::mm; - // MT Field cache is stored in cache - - // MT version uses cache, temporarily keep old version - if (fieldCache.useNewBfieldCache()) fieldCache.getField (globalPosition.data(), mField.data()); - else m_magneticfieldsvc->getField(&globalPosition, &mField); + // MT Field cache is stored in cache + fieldCache.getField (globalPosition.data(), mField.data()); map_x2 = mField.x()*mField.x(); // would be zero for a uniform field map_y2 = mField.y()*mField.y(); // would be zero for a uniform field diff --git a/InnerDetector/InDetDigitization/TRT_Digitization/src/TRTProcessingOfStraw.h b/InnerDetector/InDetDigitization/TRT_Digitization/src/TRTProcessingOfStraw.h index 9f860212f343df8c3fd42486056484318d12484d..fd4702e88957f16d243e5fffd8e76c9e3b665f19 100644 --- a/InnerDetector/InDetDigitization/TRT_Digitization/src/TRTProcessingOfStraw.h +++ b/InnerDetector/InDetDigitization/TRT_Digitization/src/TRTProcessingOfStraw.h @@ -39,8 +39,6 @@ class TRTUncompressedHit; class ITRT_PAITool; class ITRT_SimDriftTimeTool; -namespace MagField { class IMagFieldSvc; } - namespace InDetDD { class TRT_DetectorManager; } class TRTDigSettings; @@ -57,7 +55,6 @@ public: const InDetDD::TRT_DetectorManager*, ITRT_PAITool*, ITRT_SimDriftTimeTool*, - MagField::IMagFieldSvc * magfieldsvc, TRTElectronicsProcessing * ep, TRTNoise * noise, TRTDigCondBase* digcond, @@ -237,8 +234,6 @@ private: Amg::Vector3D getGlobalPosition( int hitID, const TimedHitPtr<TRTUncompressedHit> *theHit ); - //Magnetic field stuff - MagField::IMagFieldSvc* m_magneticfieldsvc; mutable Athena::MsgStreamMember m_msg; protected: diff --git a/InnerDetector/InDetExample/InDetAlignExample/share/jobOption_ConditionsOverrider.py b/InnerDetector/InDetExample/InDetAlignExample/share/jobOption_ConditionsOverrider.py index 83272832e54f51a2f7a1bbbb49ac4b636ef27be1..46d17ae2b7559ac62c153bb32c2c92c9ee72e0f5 100644 --- a/InnerDetector/InDetExample/InDetAlignExample/share/jobOption_ConditionsOverrider.py +++ b/InnerDetector/InDetExample/InDetAlignExample/share/jobOption_ConditionsOverrider.py @@ -166,12 +166,6 @@ if loadInDetRec_Options["TRTCalibT0TagCos"]: if loadInDetRec_Options["TRTCalibRtTagCos"]: conddb.addOverride('/TRT/Calib/RT',loadInDetRec_Options["TRTCalibRtTagCos"]) -#Trying to fix the Database problem -if loadInDetRec_Options["globalTag"] == "OFLCOND-RUN12-SDR-14": - conddb.addOverride('/PIXEL/PixdEdx','PixdEdx_January2011_mc-000-00') - from AthenaCommon.CfgGetter import getService - getService("AtlasFieldSvc").UseDCS = False - doJiveXML=False if doJiveXML: ToolSvc.TrackRetriever.OtherTrackCollections =["CombinedInDetTracks", "CombinedInDetTracks_CTB"] diff --git a/InnerDetector/InDetRecAlgs/InDetLowBetaFinder/CMakeLists.txt b/InnerDetector/InDetRecAlgs/InDetLowBetaFinder/CMakeLists.txt index b86f1adf2ed4c2297702a793ed9fc27cb8f529f9..51a7228809b56d3da6c015826f918b52c8174330 100644 --- a/InnerDetector/InDetRecAlgs/InDetLowBetaFinder/CMakeLists.txt +++ b/InnerDetector/InDetRecAlgs/InDetLowBetaFinder/CMakeLists.txt @@ -10,7 +10,6 @@ atlas_depends_on_subdirs( PUBLIC Control/AthenaBaseComps GaudiKernel InnerDetector/InDetConditions/TRT_ConditionsServices - MagneticField/MagFieldInterfaces PRIVATE Control/StoreGate InnerDetector/InDetConditions/TRT_ConditionsData @@ -21,7 +20,10 @@ atlas_depends_on_subdirs( PUBLIC Tracking/TrkEvent/TrkParameters Event/xAOD/xAODTracking Tracking/TrkEvent/TrkRIO_OnTrack - Tracking/TrkEvent/TrkTrack ) + Tracking/TrkEvent/TrkTrack + MagneticField/MagFieldElements + MagneticField/MagFieldConditions + ) # External dependencies: find_package( ROOT COMPONENTS Minuit RIO Core Tree MathCore Hist pthread MathMore Minuit2 Matrix Physics HistPainter Rint ) @@ -31,7 +33,7 @@ atlas_add_component( InDetLowBetaFinder src/*.cxx src/components/*.cxx INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaBaseComps GaudiKernel TRT_ConditionsServicesLib MagFieldInterfaces StoreGateLib SGtests TRT_ConditionsData InDetIdentifier InDetLowBetaInfo InDetRIO_OnTrack TrkParameters xAODTracking TrkRIO_OnTrack TrkTrack ) + LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaBaseComps GaudiKernel TRT_ConditionsServicesLib StoreGateLib SGtests TRT_ConditionsData InDetIdentifier InDetLowBetaInfo InDetRIO_OnTrack TrkParameters xAODTracking TrkRIO_OnTrack TrkTrack MagFieldElements MagFieldConditions ) # Install files from the package: atlas_install_headers( InDetLowBetaFinder ) diff --git a/InnerDetector/InDetRecAlgs/InDetLowBetaFinder/InDetLowBetaFinder/LowBetaAlg.h b/InnerDetector/InDetRecAlgs/InDetLowBetaFinder/InDetLowBetaFinder/LowBetaAlg.h index 646454acfc8c9a1f15de36fa595b8f8c1d3bfb39..15a424e165196cccb4216799d8dc14baa81ad71b 100644 --- a/InnerDetector/InDetRecAlgs/InDetLowBetaFinder/InDetLowBetaFinder/LowBetaAlg.h +++ b/InnerDetector/InDetRecAlgs/InDetLowBetaFinder/InDetLowBetaFinder/LowBetaAlg.h @@ -24,7 +24,9 @@ author Christopher.Marino <Christopher.Marino@cern.ch> #include "AthenaBaseComps/AthAlgorithm.h" #include "TRT_ConditionsServices/ITRT_CalDbTool.h" #include "GaudiKernel/ToolHandle.h" -#include "MagFieldInterfaces/IMagFieldSvc.h" +// MagField cache +#include "MagFieldConditions/AtlasFieldCacheCondObj.h" +#include "MagFieldElements/AtlasFieldCache.h" #include "xAODTracking/TrackParticleContainer.h" #include "InDetLowBetaInfo/InDetLowBetaContainer.h" #include "TrkTrack/TrackCollection.h" @@ -84,7 +86,8 @@ namespace InDet /** trying to get ahold of the TRT calib DB: */ ToolHandle<ITRT_CalDbTool> m_trtconddbTool; - ServiceHandle<MagField::IMagFieldSvc> m_fieldServiceHandle; + // Read handle for conditions object to get the field cache + SG::ReadCondHandleKey<AtlasFieldCacheCondObj> m_fieldCacheCondObjInputKey {this, "AtlasFieldCacheCondObj", "fieldCondObj", "Name of the Magnetic Field conditions object key"}; private: // Functions/variables for using TrtToolsBetaLiklihood, see TrtToolsWrapper.cxx diff --git a/InnerDetector/InDetRecAlgs/InDetLowBetaFinder/src/LowBetaAlg.cxx b/InnerDetector/InDetRecAlgs/InDetLowBetaFinder/src/LowBetaAlg.cxx index 14a43596e32aa9c24cd45d24af45ec15440e55ee..bf4f0d3c9a262b811fea7d36d3ba70b050df91d6 100644 --- a/InnerDetector/InDetRecAlgs/InDetLowBetaFinder/src/LowBetaAlg.cxx +++ b/InnerDetector/InDetRecAlgs/InDetLowBetaFinder/src/LowBetaAlg.cxx @@ -43,7 +43,6 @@ namespace InDet m_trackParticleCollection("InDetTrackParticles"), m_InDetLowBetaOutputName("InDetLowBetaCandidates"), m_trtconddbTool("TRT_CalDbTool",this), - m_fieldServiceHandle("AtlasFieldSvc",name), m_TrtTool(0), m_TRTdEdxTool(), m_TrtToolsSuccess{}, @@ -58,7 +57,6 @@ namespace InDet declareProperty("CSMP_TimingOffset", m_TimingOffset); declareProperty("InDetLowBetaOutputName", m_InDetLowBetaOutputName); declareProperty("MC_flag", m_mcswitch); - declareProperty("AtlasFieldSvc", m_fieldServiceHandle, "Magnet Field used by this algorithm"); declareProperty("TRTCalDbTool", m_trtconddbTool); declareProperty("TRT_ToT_dEdx_Tool", m_TRTdEdxTool); @@ -66,7 +64,6 @@ namespace InDet // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * StatusCode LowBetaAlg::initialize(){ - ATH_CHECK( m_fieldServiceHandle.retrieve() ); ATH_CHECK(detStore()->retrieve(m_trtId, "TRT_ID")); m_TrtToolInitSuccess = !(initializeTrtToolBetaLiklihood().isFailure()); @@ -75,6 +72,9 @@ namespace InDet ATH_CHECK( m_trackParticleCollection.initialize() ); ATH_CHECK( m_UnslimmedTracksContainerName.initialize() ); ATH_CHECK( m_InDetLowBetaOutputName.initialize() ); + // Read handle for AtlasFieldCacheCondObj + ATH_CHECK( m_fieldCacheCondObjInputKey.initialize() ); + return StatusCode::SUCCESS; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @@ -87,7 +87,17 @@ namespace InDet return StatusCode::FAILURE; } - if (m_fieldServiceHandle->solenoidOn()){//B field + EventContext ctx = Gaudi::Hive::currentContext(); + SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + if (fieldCondObj == nullptr) { + ATH_MSG_ERROR("execute: Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); + return StatusCode::FAILURE; + } + MagField::AtlasFieldCache fieldCache; + fieldCondObj->getInitializedCache (fieldCache); + + if (fieldCache.solenoidOn()){//B field if (!m_trackParticleCollection.key().empty()){ diff --git a/InnerDetector/InDetRecTools/InDetTrackScoringTools/CMakeLists.txt b/InnerDetector/InDetRecTools/InDetTrackScoringTools/CMakeLists.txt index 1152422aa3a92ab34cc2c2c9b17916908f762449..e67789668db9308fca41341294e738d1bbc6e07e 100644 --- a/InnerDetector/InDetRecTools/InDetTrackScoringTools/CMakeLists.txt +++ b/InnerDetector/InDetRecTools/InDetTrackScoringTools/CMakeLists.txt @@ -19,13 +19,15 @@ atlas_depends_on_subdirs( PUBLIC InnerDetector/InDetDetDescr/InDetIdentifier InnerDetector/InDetRecEvent/InDetRIO_OnTrack InnerDetector/InDetRecTools/InDetRecToolInterfaces - MagneticField/MagFieldInterfaces Tracking/TrkEvent/TrkParameters Tracking/TrkEvent/TrkPseudoMeasurementOnTrack Tracking/TrkEvent/TrkTrack Tracking/TrkEvent/TrkTrackSummary Tracking/TrkExtrapolation/TrkExInterfaces - Tracking/TrkEvent/TrkCaloClusterROI ) + Tracking/TrkEvent/TrkCaloClusterROI + MagneticField/MagFieldElements + MagneticField/MagFieldConditions + ) @@ -41,7 +43,7 @@ atlas_add_component( InDetTrackScoringTools src/*.cxx src/components/*.cxx INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} ${EIGEN_LIBRARIES} AthenaBaseComps AthenaKernel GaudiKernel TrkEventPrimitives TrkToolInterfaces GeoPrimitives InDetIdentifier InDetRIO_OnTrack InDetRecToolInterfaces MagFieldInterfaces TrkParameters TrkPseudoMeasurementOnTrack TrkTrack TrkTrackSummary TrkExInterfaces TrkCaloClusterROI) + LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} ${EIGEN_LIBRARIES} AthenaBaseComps AthenaKernel GaudiKernel TrkEventPrimitives TrkToolInterfaces GeoPrimitives InDetIdentifier InDetRIO_OnTrack InDetRecToolInterfaces TrkParameters TrkPseudoMeasurementOnTrack TrkTrack TrkTrackSummary TrkExInterfaces TrkCaloClusterROI MagFieldElements MagFieldConditions) # Install files from the package: atlas_install_headers( InDetTrackScoringTools ) diff --git a/InnerDetector/InDetRecTools/InDetTrackScoringTools/InDetTrackScoringTools/InDetAmbiScoringTool.h b/InnerDetector/InDetRecTools/InDetTrackScoringTools/InDetTrackScoringTools/InDetAmbiScoringTool.h index a6bbacd6374b1ad738f8ae88ab7d6306e8bd7a3f..3534b80f36fc19550a37c76b71c02629a3c03039 100755 --- a/InnerDetector/InDetRecTools/InDetTrackScoringTools/InDetTrackScoringTools/InDetAmbiScoringTool.h +++ b/InnerDetector/InDetRecTools/InDetTrackScoringTools/InDetTrackScoringTools/InDetAmbiScoringTool.h @@ -20,6 +20,9 @@ #include "TrkParameters/TrackParameters.h" #include "AthenaKernel/CLASS_DEF.h" #include "AthenaKernel/IOVSvcDefs.h" +// MagField cache +#include "MagFieldConditions/AtlasFieldCacheCondObj.h" +#include "MagFieldElements/AtlasFieldCache.h" #include <vector> #include <string> #include "BeamSpotConditionsData/BeamSpotData.h" @@ -32,10 +35,6 @@ namespace Trk { } -namespace MagField { - class IMagFieldSvc; -} - namespace InDet { class ITrtDriftCircleCutTool; @@ -85,7 +84,9 @@ class InDetAmbiScoringTool : virtual public Trk::ITrackScoringTool, SG::ReadCondHandleKey<InDet::BeamSpotData> m_beamSpotKey { this, "BeamSpotKey", "BeamSpotData", "SG key for beam spot" }; ToolHandle<Trk::IExtrapolator> m_extrapolator; - ServiceHandle<MagField::IMagFieldSvc> m_magFieldSvc; + + // Read handle for conditions object to get the field cache + SG::ReadCondHandleKey<AtlasFieldCacheCondObj> m_fieldCacheCondObjInputKey {this, "AtlasFieldCacheCondObj", "fieldCondObj", "Name of the Magnetic Field conditions object key"}; /** use the scoring tuned to Ambiguity processing or not */ diff --git a/InnerDetector/InDetRecTools/InDetTrackScoringTools/InDetTrackScoringTools/InDetTrtTrackScoringTool.h b/InnerDetector/InDetRecTools/InDetTrackScoringTools/InDetTrackScoringTools/InDetTrtTrackScoringTool.h index 40a0c6b8624fb8a882e82e6d13d7386e4ed95aac..3656ca2f99adfa76826004815ffc3456dce800b6 100755 --- a/InnerDetector/InDetRecTools/InDetTrackScoringTools/InDetTrackScoringTools/InDetTrtTrackScoringTool.h +++ b/InnerDetector/InDetRecTools/InDetTrackScoringTools/InDetTrackScoringTools/InDetTrtTrackScoringTool.h @@ -12,6 +12,9 @@ #include "TrkEventPrimitives/TrackScore.h" #include "TrkToolInterfaces/ITrackScoringTool.h" #include "TrkToolInterfaces/ITrackSummaryTool.h" +// MagField cache +#include "MagFieldConditions/AtlasFieldCacheCondObj.h" +#include "MagFieldElements/AtlasFieldCache.h" #include <vector> #include <string> @@ -20,9 +23,6 @@ namespace Trk { class TrackSummary; } -namespace MagField { - class IMagFieldSvc; -} class TRT_ID ; @@ -77,9 +77,9 @@ private: ToolHandle<Trk::ITrackSummaryTool> m_trkSummaryTool; /** Returns minimum number of expected TRT drift circles depending on eta. */ ToolHandle<ITrtDriftCircleCutTool> m_selectortool; - /** to query magnetic field configuration */ - ServiceHandle<MagField::IMagFieldSvc> m_magFieldSvc; + // Read handle for conditions object to get the field cache + SG::ReadCondHandleKey<AtlasFieldCacheCondObj> m_fieldCacheCondObjInputKey {this, "AtlasFieldCacheCondObj", "fieldCondObj", "Name of the Magnetic Field conditions object key"}; /** cuts for selecting good tracks*/ int m_minTRTonTrk; //!< minimum number of TRT hits diff --git a/InnerDetector/InDetRecTools/InDetTrackScoringTools/src/InDetAmbiScoringTool.cxx b/InnerDetector/InDetRecTools/InDetTrackScoringTools/src/InDetAmbiScoringTool.cxx index 2c6058585271310ff07ffc833c88970a059c07d4..2ae8ce75a52f876e8a3655c1e6a7cd88b3a214f2 100755 --- a/InnerDetector/InDetRecTools/InDetTrackScoringTools/src/InDetAmbiScoringTool.cxx +++ b/InnerDetector/InDetRecTools/InDetTrackScoringTools/src/InDetAmbiScoringTool.cxx @@ -16,7 +16,6 @@ #include "CLHEP/GenericFunctions/CumulativeChiSquare.hh" #include "TMath.h" #include <vector> -#include "MagFieldInterfaces/IMagFieldSvc.h" #include "GeoPrimitives/GeoPrimitives.h" #include "TrkCaloClusterROI/CaloClusterROI.h" #include "TrkCaloClusterROI/CaloClusterROI_Collection.h" @@ -46,8 +45,7 @@ InDet::InDetAmbiScoringTool::InDetAmbiScoringTool(const std::string& t, m_trkSummaryTool("Trk::TrackSummaryTool", this), m_selectortool("InDet::InDetTrtDriftCircleCutTool", this), m_summaryTypeScore(Trk::numberOfTrackSummaryTypes), - m_extrapolator("Trk::Extrapolator", this), - m_magFieldSvc("AtlasFieldSvc",n) + m_extrapolator("Trk::Extrapolator", this) { declareInterface<Trk::ITrackScoringTool>(this); @@ -82,7 +80,6 @@ InDet::InDetAmbiScoringTool::InDetAmbiScoringTool(const std::string& t, declareProperty("Extrapolator", m_extrapolator); declareProperty("SummaryTool" , m_trkSummaryTool); declareProperty("DriftCircleCutTool",m_selectortool ); - declareProperty("MagFieldSvc", m_magFieldSvc); declareProperty("maxRPhiImpEM", m_maxRPhiImpEM = 50. ); declareProperty("doEmCaloSeed", m_useEmClusSeed = true ); @@ -154,20 +151,13 @@ StatusCode InDet::InDetAmbiScoringTool::initialize() ATH_CHECK(m_beamSpotKey.initialize()); - sc = m_magFieldSvc.retrieve(); - if (sc.isFailure()){ - msg(MSG::FATAL) << "Failed to retrieve " << m_magFieldSvc << endmsg; - return StatusCode::FAILURE; - } - else { - msg(MSG::DEBUG) << "Retrieved " << m_magFieldSvc << endmsg; - } - if (m_useAmbigFcn && m_useTRT_AmbigFcn) { msg(MSG::FATAL) << "Both on, normal ambi funciton and the one for back tracking, configuration problem, not recoverable" << endmsg; return StatusCode::FAILURE; } + // Read handle for AtlasFieldCacheCondObj + ATH_CHECK( m_fieldCacheCondObjInputKey.initialize() ); if (m_useAmbigFcn || m_useTRT_AmbigFcn) setupScoreModifiers(); @@ -310,7 +300,17 @@ Trk::TrackScore InDet::InDetAmbiScoringTool::simpleScore( const Trk::Track& trac const Trk::TrackParameters* input = track.trackParameters()->front(); // cuts on parameters - if (m_magFieldSvc->solenoidOn()) { + EventContext ctx = Gaudi::Hive::currentContext(); + SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + if (fieldCondObj == nullptr) { + ATH_MSG_ERROR("simpleScore: Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); + return Trk::TrackScore(0); + } + MagField::AtlasFieldCache fieldCache; + fieldCondObj->getInitializedCache (fieldCache); + + if (fieldCache.solenoidOn()){ if (fabs(input->pT()) < m_minPt) { ATH_MSG_DEBUG ("Track pt < "<<m_minPt<<", reject it"); return Trk::TrackScore(0); diff --git a/InnerDetector/InDetRecTools/InDetTrackScoringTools/src/InDetTrtTrackScoringTool.cxx b/InnerDetector/InDetRecTools/InDetTrackScoringTools/src/InDetTrtTrackScoringTool.cxx index 32efae3af46e82f23417106b1465812ed70c0853..7418d8c3df470cafceacd71b2aa30465965a1541 100755 --- a/InnerDetector/InDetRecTools/InDetTrackScoringTools/src/InDetTrtTrackScoringTool.cxx +++ b/InnerDetector/InDetRecTools/InDetTrackScoringTools/src/InDetTrtTrackScoringTool.cxx @@ -14,7 +14,6 @@ #include "InDetIdentifier/TRT_ID.h" #include "TMath.h" #include <vector> -#include "MagFieldInterfaces/IMagFieldSvc.h" //--------------------------------------------------------------------------------------------------------------------- @@ -31,8 +30,7 @@ InDet::InDetTrtTrackScoringTool::InDetTrtTrackScoringTool(const std::string& t, m_maxTrtFittedRatio(-1), m_summaryTypeScore(Trk::numberOfTrackSummaryTypes), m_trkSummaryTool("Trk::TrackSummaryTool"), - m_selectortool("InDet::InDetTrtDriftCircleCutTool"), - m_magFieldSvc("AtlasFieldSvc",n) + m_selectortool("InDet::InDetTrtDriftCircleCutTool") { declareInterface<Trk::ITrackScoringTool>(this); @@ -50,7 +48,6 @@ InDet::InDetTrtTrackScoringTool::InDetTrtTrackScoringTool(const std::string& t, declareProperty("UseParameterization", m_parameterization = true); declareProperty("OldTransitionLogic" , m_oldLogic = false); declareProperty("minTRTPrecisionFraction", m_minTRTprecision = 0.5); - declareProperty("MagFieldSvc", m_magFieldSvc); m_summaryTypeScore[Trk::numberOfTRTHits] = 1; // 10 straws ~ 1 SCT m_summaryTypeScore[Trk::numberOfTRTHighThresholdHits] = 0; // addition for being TR @@ -87,15 +84,6 @@ StatusCode InDet::InDetTrtTrackScoringTool::initialize() msg(MSG::DEBUG) << "Retrieved tool " << m_selectortool << endmsg; } - sc = m_magFieldSvc.retrieve(); - if (sc.isFailure()){ - msg(MSG::FATAL) << "Failed to retrieve " << m_magFieldSvc << endmsg; - return StatusCode::FAILURE; - } - else { - msg(MSG::DEBUG) << "Retrieved " << m_magFieldSvc << endmsg; - } - sc = detStore()->retrieve(m_trtId, "TRT_ID"); if (sc.isFailure()){ msg(MSG::FATAL) << "Could not get TRT_ID helper !" << endmsg; @@ -104,6 +92,9 @@ StatusCode InDet::InDetTrtTrackScoringTool::initialize() if(m_useAmbigFcn) setupTRT_ScoreModifiers(); + // Read handle for AtlasFieldCacheCondObj + ATH_CHECK( m_fieldCacheCondObjInputKey.initialize() ); + return StatusCode::SUCCESS; } @@ -163,7 +154,18 @@ Trk::TrackScore InDet::InDetTrtTrackScoringTool::simpleScore( const Trk::Track& const Trk::TrackParameters* input = track.trackParameters()->front(); ///Reject track below the pT cut - if (m_magFieldSvc->solenoidOn()) { + + EventContext ctx = Gaudi::Hive::currentContext(); + SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + if (fieldCondObj == nullptr) { + ATH_MSG_ERROR("simpleScore: Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); + return Trk::TrackScore(0); + } + MagField::AtlasFieldCache fieldCache; + fieldCondObj->getInitializedCache (fieldCache); + + if (fieldCache.solenoidOn()){//B field if(input->pT() < m_ptmin) { ATH_MSG_DEBUG( "Reject track below Pt cut !"); return Trk::TrackScore(0); diff --git a/InnerDetector/InDetRecTools/InDetTrackSelectorTool/CMakeLists.txt b/InnerDetector/InDetRecTools/InDetTrackSelectorTool/CMakeLists.txt index 1545b9f81fd310564a22411497e995c45a6069ce..10381ef7f69c3dca629ccb54065b8e320d9ed17b 100644 --- a/InnerDetector/InDetRecTools/InDetTrackSelectorTool/CMakeLists.txt +++ b/InnerDetector/InDetRecTools/InDetTrackSelectorTool/CMakeLists.txt @@ -21,14 +21,15 @@ atlas_depends_on_subdirs( PUBLIC Event/EventPrimitives InnerDetector/InDetConditions/TRT_ConditionsServices InnerDetector/InDetRecEvent/InDetRIO_OnTrack - MagneticField/MagFieldInterfaces Tracking/TrkDetDescr/TrkSurfaces Tracking/TrkEvent/TrkParticleBase Tracking/TrkEvent/TrkRIO_OnTrack Tracking/TrkEvent/TrkTrack Tracking/TrkEvent/TrkTrackSummary Tracking/TrkEvent/VxVertex - Tracking/TrkExtrapolation/TrkExInterfaces ) + Tracking/TrkExtrapolation/TrkExInterfaces + MagneticField/MagFieldElements + MagneticField/MagFieldConditions ) # External dependencies: find_package( CLHEP ) @@ -40,7 +41,7 @@ atlas_add_component( InDetTrackSelectorTool src/*.cxx src/components/*.cxx INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} ${EIGEN_LIBRARIES} AthenaBaseComps xAODTracking GaudiKernel InDetRecToolInterfaces TrkEventPrimitives TrkParameters TrkToolInterfaces AthContainers GeoPrimitives EventPrimitives TRT_ConditionsServicesLib InDetRIO_OnTrack MagFieldInterfaces TrkSurfaces TrkParticleBase TrkRIO_OnTrack TrkTrack TrkTrackSummary VxVertex TrkExInterfaces ) + LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} ${EIGEN_LIBRARIES} AthenaBaseComps xAODTracking GaudiKernel InDetRecToolInterfaces TrkEventPrimitives TrkParameters TrkToolInterfaces AthContainers GeoPrimitives EventPrimitives TRT_ConditionsServicesLib InDetRIO_OnTrack TrkSurfaces TrkParticleBase TrkRIO_OnTrack TrkTrack TrkTrackSummary VxVertex TrkExInterfaces MagFieldElements MagFieldConditions ) # Install files from the package: atlas_install_headers( InDetTrackSelectorTool ) diff --git a/InnerDetector/InDetRecTools/InDetTrackSelectorTool/InDetTrackSelectorTool/InDetCosmicTrackSelectorTool.h b/InnerDetector/InDetRecTools/InDetTrackSelectorTool/InDetTrackSelectorTool/InDetCosmicTrackSelectorTool.h index 33b7281ebe3bd81b621d8ce3273351991cea2643..cca93adf1f110f164b432826d8d8cdb29de05fae 100644 --- a/InnerDetector/InDetRecTools/InDetTrackSelectorTool/InDetTrackSelectorTool/InDetCosmicTrackSelectorTool.h +++ b/InnerDetector/InDetRecTools/InDetTrackSelectorTool/InDetTrackSelectorTool/InDetCosmicTrackSelectorTool.h @@ -11,19 +11,18 @@ #include "TrkToolInterfaces/ITrackSelectorTool.h" #include "TrkEventPrimitives/ParticleHypothesis.h" #include "TrkParameters/TrackParameters.h" +// MagField cache +#include "MagFieldConditions/AtlasFieldCacheCondObj.h" +#include "MagFieldElements/AtlasFieldCache.h" namespace Trk { - class IMagneticFieldTool; class ITrackSummaryTool; class Vertex; class TrackParticleBase; class Track; } -namespace MagField { - class IMagFieldSvc; -} namespace InDet { @@ -67,8 +66,8 @@ namespace InDet ToolHandle<Trk::ITrackSummaryTool> m_trackSumTool; bool m_trackSumToolAvailable; - ServiceHandle<MagField::IMagFieldSvc> m_magFieldSvc; - + // Read handle for conditions object to get the field cache + SG::ReadCondHandleKey<AtlasFieldCacheCondObj> m_fieldCacheCondObjInputKey {this, "AtlasFieldCacheCondObj", "fieldCondObj", "Name of the Magnetic Field conditions object key"}; }; //end of class definitions diff --git a/InnerDetector/InDetRecTools/InDetTrackSelectorTool/InDetTrackSelectorTool/InDetDetailedTrackSelectorTool.h b/InnerDetector/InDetRecTools/InDetTrackSelectorTool/InDetTrackSelectorTool/InDetDetailedTrackSelectorTool.h index f2843391c792a9e000c4fa0e360ef8a006558ce3..1d6522b977a43c0d9a7b6fd120cbb3ac40449c38 100644 --- a/InnerDetector/InDetRecTools/InDetTrackSelectorTool/InDetTrackSelectorTool/InDetDetailedTrackSelectorTool.h +++ b/InnerDetector/InDetRecTools/InDetTrackSelectorTool/InDetTrackSelectorTool/InDetDetailedTrackSelectorTool.h @@ -13,6 +13,9 @@ #include "xAODTracking/TrackParticle.h" #include "xAODTracking/VertexFwd.h" #include "BeamSpotConditionsData/BeamSpotData.h" +// MagField cache +#include "MagFieldConditions/AtlasFieldCacheCondObj.h" +#include "MagFieldElements/AtlasFieldCache.h" /** * @file InDetDetailedTrackSelectorTool.h @@ -30,13 +33,9 @@ */ -namespace MagField { - class IMagFieldSvc; -} namespace Trk { - class IMagneticFieldTool; class ITrackSummaryTool; class IExtrapolator; class Vertex; @@ -153,10 +152,11 @@ namespace InDet ToolHandle<Trk::ITrackSummaryTool> m_trackSumTool; //!< Track summary tool ToolHandle<Trk::IExtrapolator> m_extrapolator; //!< Extrapolator tool SG::ReadCondHandleKey<InDet::BeamSpotData> m_beamSpotKey { this, "BeamSpotKey", "BeamSpotData", "SG key for beam spot" }; - ServiceHandle<MagField::IMagFieldSvc> m_magFieldSvc; ToolHandle<ITrtDriftCircleCutTool> m_trtDCTool; //!< Tool to get eta dependent cut on number of TRT hits ToolHandle< InDet::IInDetTestBLayerTool > m_inDetTestBLayerTool; //Tool to test if the track crosses a dead module on the b-layer + // Read handle for conditions object to get the field cache + SG::ReadCondHandleKey<AtlasFieldCacheCondObj> m_fieldCacheCondObjInputKey {this, "AtlasFieldCacheCondObj", "fieldCondObj", "Name of the Magnetic Field conditions object key"}; bool m_trackSumToolAvailable; diff --git a/InnerDetector/InDetRecTools/InDetTrackSelectorTool/src/InDetCosmicTrackSelectorTool.cxx b/InnerDetector/InDetRecTools/InDetTrackSelectorTool/src/InDetCosmicTrackSelectorTool.cxx index 49c81b0b2566cad15784256e213cd0f2d9564257..4bc59141999383fdb055c0ba5693c7aa2cc4504e 100644 --- a/InnerDetector/InDetRecTools/InDetTrackSelectorTool/src/InDetCosmicTrackSelectorTool.cxx +++ b/InnerDetector/InDetRecTools/InDetTrackSelectorTool/src/InDetCosmicTrackSelectorTool.cxx @@ -6,7 +6,6 @@ // forward declares #include "TrkToolInterfaces/ITrackSummaryTool.h" -#include "MagFieldInterfaces/IMagFieldSvc.h" #include "VxVertex/Vertex.h" #include "TrkTrack/Track.h" #include "TrkParticleBase/TrackParticleBase.h" @@ -24,8 +23,7 @@ namespace InDet //---------------------------------------------------------------------------- InDetCosmicTrackSelectorTool::InDetCosmicTrackSelectorTool(const std::string& t, const std::string& n, const IInterface* p) : AthAlgTool(t,n,p), - m_trackSumToolAvailable(false), - m_magFieldSvc("AtlasFieldSvc",n) + m_trackSumToolAvailable(false) { declareInterface<ITrackSelectorTool>(this); declareProperty("maxZ0", m_maxZ0 = 150.); @@ -38,7 +36,6 @@ namespace InDet declareProperty("numberOfSiliconHitsTop", m_numberOfSiHitsTop = -1); declareProperty("numberOfSiliconHitsBottom", m_numberOfSiHitsBottom = -1); declareProperty("TrackSummaryTool", m_trackSumTool); - declareProperty("MagFieldSvc", m_magFieldSvc); } //---------------------------------------------------------------------------- @@ -64,11 +61,8 @@ namespace InDet m_trackSumToolAvailable = true; } - if (m_magFieldSvc.retrieve().isFailure()) { - msg(MSG::FATAL) << "Failed to retrieve tool " << m_magFieldSvc << endmsg; - return StatusCode::FAILURE; - } - ATH_MSG_INFO("Retrieved tool "<<m_magFieldSvc); + // Read handle for AtlasFieldCacheCondObj + ATH_CHECK( m_fieldCacheCondObjInputKey.initialize() ); return StatusCode::SUCCESS; } @@ -236,7 +230,17 @@ namespace InDet } // only check pt if mag. field is on - if (m_magFieldSvc->solenoidOn()) { + EventContext ctx = Gaudi::Hive::currentContext(); + SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + if (fieldCondObj == nullptr) { + ATH_MSG_ERROR("execute: Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); + return false; + } + MagField::AtlasFieldCache fieldCache; + fieldCondObj->getInitializedCache (fieldCache); + + if (fieldCache.solenoidOn()){//B field if (trackParameters[Trk::qOverP] == 0.) { ATH_MSG_DEBUG("Track rejected because of qOverP == 0."); return false; diff --git a/InnerDetector/InDetRecTools/InDetTrackSelectorTool/src/InDetDetailedTrackSelectorTool.cxx b/InnerDetector/InDetRecTools/InDetTrackSelectorTool/src/InDetDetailedTrackSelectorTool.cxx index 20e1028bac3417eb54634c20b1877b6149ecd462..aa9374e1e9d1ef36754a95c7af4fafee30a11802 100644 --- a/InnerDetector/InDetRecTools/InDetTrackSelectorTool/src/InDetDetailedTrackSelectorTool.cxx +++ b/InnerDetector/InDetRecTools/InDetTrackSelectorTool/src/InDetDetailedTrackSelectorTool.cxx @@ -12,7 +12,6 @@ #include "TrkTrack/Track.h" #include "TrkTrackSummary/TrackSummary.h" #include "TrkParticleBase/TrackParticleBase.h" -#include "MagFieldInterfaces/IMagFieldSvc.h" #include "InDetRecToolInterfaces/ITrtDriftCircleCutTool.h" #include "InDetRecToolInterfaces/IInDetTestBLayerTool.h" @@ -39,7 +38,6 @@ namespace InDet : AthAlgTool(t,n,p) , m_trackSumTool("Trk::TrackSummaryTool", this) , m_extrapolator("Trk::Extrapolator", this) - , m_magFieldSvc("AtlasFieldSvc",n) , m_trtDCTool("InDet::InDetTrtDriftCircleCutTool", this) , m_inDetTestBLayerTool("", this) , m_trackSumToolAvailable(true) @@ -107,7 +105,6 @@ namespace InDet declareProperty("TrackSummaryTool" , m_trackSumTool); declareProperty("Extrapolator" , m_extrapolator); - declareProperty("MagFieldSvc", m_magFieldSvc); declareProperty("TrtDCCutTool" , m_trtDCTool); declareProperty("InDetTestBLayerTool", m_inDetTestBLayerTool); @@ -153,12 +150,10 @@ namespace InDet }else{ m_trtDCTool.disable(); } - ATH_CHECK(m_magFieldSvc.retrieve()); - if(m_inDetTestBLayerTool.empty()){ - ATH_MSG_INFO(" The BLayerTool not specified, turning off cut. "); - } else { - ATH_CHECK( m_inDetTestBLayerTool.retrieve()); - } + + // Read handle for AtlasFieldCacheCondObj + ATH_CHECK( m_fieldCacheCondObjInputKey.initialize() ); + ATH_MSG_INFO("Using cuts on the number of Silicon hits"); if(m_usePtDependentCuts) { //checking whether sizes of cuts and pt interval expressed in vectors match @@ -688,7 +683,18 @@ namespace InDet const AmgVector(5)& perigeeParms = track->parameters(); - if (m_magFieldSvc->solenoidOn()) { + // only check pt if mag. field is on + EventContext ctx = Gaudi::Hive::currentContext(); + SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + if (fieldCondObj == nullptr) { + ATH_MSG_ERROR("execute: Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); + return false; + } + MagField::AtlasFieldCache fieldCache; + fieldCondObj->getInitializedCache (fieldCache); + + if (fieldCache.solenoidOn()){//B field if (perigeeParms[Trk::qOverP] == 0.) { ATH_MSG_DEBUG("Track rejected because of qOverP == 0."); return false; @@ -1072,7 +1078,18 @@ namespace InDet { const AmgVector(5)& perigeeParms = myPerigee.parameters(); - if (m_magFieldSvc->solenoidOn()) { + // only check pt if mag. field is on + EventContext ctx = Gaudi::Hive::currentContext(); + SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + if (fieldCondObj == nullptr) { + ATH_MSG_ERROR("execute: Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); + return false; + } + MagField::AtlasFieldCache fieldCache; + fieldCondObj->getInitializedCache (fieldCache); + + if (fieldCache.solenoidOn()){//B field if (perigeeParms[Trk::qOverP] == 0.) { ATH_MSG_DEBUG("Track rejected because of perigee qOverP == 0."); return false; diff --git a/InnerDetector/InDetRecTools/TRT_SegmentToTrackTool/CMakeLists.txt b/InnerDetector/InDetRecTools/TRT_SegmentToTrackTool/CMakeLists.txt index 0a359dbd9b2033b2130895d9646a67eb3d314f0e..996ce28a2b30a416193fa3935bd494a064e1faf2 100644 --- a/InnerDetector/InDetRecTools/TRT_SegmentToTrackTool/CMakeLists.txt +++ b/InnerDetector/InDetRecTools/TRT_SegmentToTrackTool/CMakeLists.txt @@ -14,7 +14,6 @@ atlas_depends_on_subdirs( PUBLIC PRIVATE InnerDetector/InDetDetDescr/InDetIdentifier InnerDetector/InDetRecEvent/InDetRIO_OnTrack - MagneticField/MagFieldInterfaces Tracking/TrkEvent/TrkPseudoMeasurementOnTrack Tracking/TrkExtrapolation/TrkExInterfaces Tracking/TrkFitter/TrkFitterInterfaces @@ -28,7 +27,7 @@ atlas_depends_on_subdirs( PUBLIC atlas_add_component( TRT_SegmentToTrackTool src/*.cxx src/components/*.cxx - LINK_LIBRARIES AthenaBaseComps GaudiKernel InDetRecToolInterfaces TrkEventPrimitives InDetIdentifier InDetRIO_OnTrack MagFieldInterfaces TrkPseudoMeasurementOnTrack TrkExInterfaces TrkFitterInterfaces TrkToolInterfaces MagFieldElements MagFieldConditions) + LINK_LIBRARIES AthenaBaseComps GaudiKernel InDetRecToolInterfaces TrkEventPrimitives InDetIdentifier InDetRIO_OnTrack TrkPseudoMeasurementOnTrack TrkExInterfaces TrkFitterInterfaces TrkToolInterfaces MagFieldElements MagFieldConditions) # Install files from the package: atlas_install_headers( TRT_SegmentToTrackTool ) diff --git a/InnerDetector/InDetRecTools/TRT_SegmentToTrackTool/TRT_SegmentToTrackTool/TRT_SegmentToTrackTool.h b/InnerDetector/InDetRecTools/TRT_SegmentToTrackTool/TRT_SegmentToTrackTool/TRT_SegmentToTrackTool.h index 37374984bd1edd067e376e5c6031dccd7d83897d..3604bbafe593ea0c4965eec904dc57d3f83df420 100644 --- a/InnerDetector/InDetRecTools/TRT_SegmentToTrackTool/TRT_SegmentToTrackTool/TRT_SegmentToTrackTool.h +++ b/InnerDetector/InDetRecTools/TRT_SegmentToTrackTool/TRT_SegmentToTrackTool/TRT_SegmentToTrackTool.h @@ -53,12 +53,6 @@ namespace Trk { } -namespace MagField { - - class IMagFieldSvc; - -} - namespace InDet { //class TrackSegment; @@ -111,12 +105,11 @@ namespace InDet { {this, "TrackSummaryTool", "InDetTrackSummaryToolNoHoleSearch"}; ToolHandle<Trk::ITrackScoringTool> m_scoringTool ; //!< Track scoring tool - ServiceHandle<MagField::IMagFieldSvc> m_magFieldSvc ; //!< Magnetic field service //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Read handle for conditions object to get the field cache - SG::ReadCondHandleKey<AtlasFieldCacheCondObj> m_fieldCondObjInputKey {this, "AtlasFieldCacheCondObj", "fieldCondObj", - "Name of the Magnetic Field conditions object key"}; + SG::ReadCondHandleKey<AtlasFieldCacheCondObj> m_fieldCacheCondObjInputKey {this, "AtlasFieldCacheCondObj", "fieldCondObj", + "Name of the Magnetic Field conditions object key"}; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/InnerDetector/InDetRecTools/TRT_SegmentToTrackTool/src/TRT_SegmentToTrackTool.cxx b/InnerDetector/InDetRecTools/TRT_SegmentToTrackTool/src/TRT_SegmentToTrackTool.cxx index 77d6dadc382105e9247ea0e2ded06c17ee0ec2a0..3afdb7a568965ca9c18b8a8b1fe65dd6c048417e 100644 --- a/InnerDetector/InDetRecTools/TRT_SegmentToTrackTool/src/TRT_SegmentToTrackTool.cxx +++ b/InnerDetector/InDetRecTools/TRT_SegmentToTrackTool/src/TRT_SegmentToTrackTool.cxx @@ -14,8 +14,6 @@ #include "TrkExInterfaces/IExtrapolator.h" //Scoring tool #include "TrkToolInterfaces/ITrackScoringTool.h" -//Magnetic field tool -#include "MagFieldInterfaces/IMagFieldSvc.h" using Amg::Vector3D; using CLHEP::mm; @@ -31,7 +29,6 @@ namespace InDet { m_fitterTool("Trk::KalmanFitter/InDetTrackFitter"), m_extrapolator ("Trk::Extrapolator/InDetExtrapolator"), m_scoringTool("Trk::TrackScoringTool/TrackScoringTool"), - m_magFieldSvc("AtlasFieldSvc", name), m_trtId(nullptr) { declareInterface<InDet::ITRT_SegmentToTrackTool>( this ); @@ -49,9 +46,6 @@ namespace InDet { declareProperty("RefitterTool" ,m_fitterTool ); //Track refit tool declareProperty("Extrapolator" ,m_extrapolator ); //Extrapolator tool declareProperty("ScoringTool" ,m_scoringTool ); //Track scoring tool - - declareProperty( "MagFieldSvc" ,m_magFieldSvc ); //Magnetic field tool - } TRT_SegmentToTrackTool::~TRT_SegmentToTrackTool() @@ -82,11 +76,9 @@ namespace InDet { // ATH_CHECK( m_scoringTool.retrieve() ); - ATH_CHECK( m_magFieldSvc.retrieve() ); - ATH_CHECK( detStore()->retrieve(m_trtId, "TRT_ID") ); //////////////////////////////////////////////////////////////////////////////// - ATH_CHECK( m_fieldCondObjInputKey.initialize()); + ATH_CHECK( m_fieldCacheCondObjInputKey.initialize()); //////////////////////////////////////////////////////////////////////////////// // Get output print level @@ -164,7 +156,7 @@ namespace InDet { // if (!tS.fitQuality()) { ATH_MSG_DEBUG ("Segment has no fit quality ! Discard..."); - return 0; + return nullptr; } const Trk::FitQuality* fq = tS.fitQuality()->clone(); @@ -186,7 +178,7 @@ namespace InDet { // clean up delete fq; fq = 0; delete ep; ep = 0; - return 0; + return nullptr; } // --- create new track state on surface vector @@ -211,7 +203,7 @@ namespace InDet { delete ntsos; ntsos = 0; delete segPar; segPar = 0; delete fq; fq = 0; - return 0; + return nullptr; } // now create a perigee TSOS @@ -351,7 +343,7 @@ namespace InDet { ATH_MSG_DEBUG ("Could not produce perigee"); delete newTrack; newTrack = 0; delete segPar; segPar = 0; - return 0; + return nullptr; } // keep some values @@ -462,17 +454,16 @@ namespace InDet { MagField::AtlasFieldCache fieldCache; // Get field cache object - SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCondObjInputKey, ctx}; + SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; if (fieldCondObj == nullptr) { - ATH_MSG_ERROR("segToTrack: Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCondObjInputKey.key()); - return 0; + ATH_MSG_ERROR("segToTrack: Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); + return nullptr; } fieldCondObj->getInitializedCache (fieldCache); - // MT version uses cache, temporarily keep old version - if (fieldCache.useNewBfieldCache()) fieldCache.getField (Amg::Vector3D(.5*(pos1+pos2)).data(),field1.data()); - else m_magFieldSvc->getField(Amg::Vector3D(.5*(pos1+pos2)).data(),field1.data()); + // MT version uses cache + fieldCache.getField (Amg::Vector3D(.5*(pos1+pos2)).data(),field1.data()); field1 *= m_fieldUnitConversion; // field in Tesla @@ -550,7 +541,7 @@ namespace InDet { if(!fitTrack){ ATH_MSG_DEBUG ("Refit of TRT track segment failed!"); - return 0; + return nullptr; } // @@ -570,7 +561,7 @@ namespace InDet { if (!perTrack || !perTrack->covariance() ){ ATH_MSG_ERROR ("Cast of perigee fails, should never happen !"); - return 0; + return nullptr; }else { ATH_MSG_VERBOSE ("Perigee after refit with fudges to make it converge : " << (*perTrack) ); @@ -625,7 +616,7 @@ namespace InDet { const AmgSymMatrix(5)& CM = *perTrack->covariance(); if( CM(1,1)==0.||CM(3,3)==0. ) { ATH_MSG_DEBUG ("Hacked perigee covariance is CRAP, reject track"); - delete fitTrack; return 0; + delete fitTrack; return nullptr; } else { ATH_MSG_VERBOSE ("Perigee after fit with scaled covariance matrix : " << *perTrack); } diff --git a/MagneticField/MagFieldConditions/CMakeLists.txt b/MagneticField/MagFieldConditions/CMakeLists.txt index 1a0c270a9d278cba049e4e26b37b0e4a888e5cbb..70586fd0b15e883e703c7c5e61aceb94c44b2176 100644 --- a/MagneticField/MagFieldConditions/CMakeLists.txt +++ b/MagneticField/MagFieldConditions/CMakeLists.txt @@ -8,7 +8,6 @@ atlas_subdir( MagFieldConditions ) # Declare the package's dependencies: atlas_depends_on_subdirs( PUBLIC Control/StoreGate - MagneticField/MagFieldInterfaces GaudiKernel PRIVATE MagneticField/MagFieldElements diff --git a/MagneticField/MagFieldElements/CMakeLists.txt b/MagneticField/MagFieldElements/CMakeLists.txt index 13dde183f9d9d9a5eb0842117929b9b3479e73f0..f556de2b9ab150f402a61bb52297c8190596a8c3 100644 --- a/MagneticField/MagFieldElements/CMakeLists.txt +++ b/MagneticField/MagFieldElements/CMakeLists.txt @@ -8,7 +8,6 @@ atlas_subdir( MagFieldElements ) # Declare the package's dependencies: atlas_depends_on_subdirs( PUBLIC Control/AthenaBaseComps - MagneticField/MagFieldInterfaces Control/CxxUtils Event/EventPrimitives PRIVATE diff --git a/MuonSpectrometer/MuonConfig/python/MuonTrackBuildingConfig.py b/MuonSpectrometer/MuonConfig/python/MuonTrackBuildingConfig.py index 5b9fd569662189f20e8463494c4e79c494171585..d5f33006a23fddc4989e5f07f2556e3a8ec3e2f1 100644 --- a/MuonSpectrometer/MuonConfig/python/MuonTrackBuildingConfig.py +++ b/MuonSpectrometer/MuonConfig/python/MuonTrackBuildingConfig.py @@ -146,8 +146,6 @@ def MooTrackBuilderCfg(flags, name="MooTrackBuilderTemplate", **kwargs): kwargs.setdefault("ChamberHoleRecoveryTool", hole_recovery_tool) # FIXME? Remove duplicate from cxx? acc = MagneticFieldSvcCfg(flags) - magfieldsvc = acc.getPrimary() - kwargs.setdefault( "MagFieldSvc", magfieldsvc ) result.merge(acc) acc = MuonTrackToSegmentToolCfg(flags) diff --git a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/CMakeLists.txt b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/CMakeLists.txt index 01a5c1ab2dd4518489bda5ecd5c4c401eed53820..4bf979636196ee86b5cb0a825bb4d4e51771535d 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/CMakeLists.txt +++ b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/CMakeLists.txt @@ -16,7 +16,6 @@ atlas_depends_on_subdirs( PRIVATE DetectorDescription/RoiDescriptor Event/EventPrimitives GaudiKernel - MagneticField/MagFieldInterfaces MuonSpectrometer/MuonAlignment/MuonAlignError/MuonAlignErrorBase MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry MuonSpectrometer/MuonIdHelpers @@ -50,7 +49,10 @@ atlas_depends_on_subdirs( PRIVATE Tracking/TrkFitter/TrkFitterInterfaces Tracking/TrkTools/TrkToolInterfaces Tracking/TrkUtilityPackages/TrkDriftCircleMath - MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondData ) + MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondData + MagneticField/MagFieldElements + MagneticField/MagFieldConditions + ) # External dependencies: find_package( Eigen ) @@ -61,5 +63,5 @@ atlas_add_component( MuonTrackFinderTools src/*.cxx src/components/*.cxx INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} ${EIGEN_LIBRARIES} AthenaBaseComps AthenaKernel StoreGateLib SGtests GeoPrimitives IRegionSelector Identifier RoiDescriptor EventPrimitives GaudiKernel MagFieldInterfaces MuonAlignErrorBase MuonReadoutGeometry MuonIdHelpersLib MuonCompetingRIOsOnTrack MuonPrepRawData MuonRIO_OnTrack MuonSegment MuonRecHelperToolsLib MuonRecToolInterfaces MuonStationIntersectSvcLib MuonSegmentMakerUtils TrkDetDescrInterfaces TrkDetElementBase TrkGeometry TrkSurfaces TrkVolumes TrkEventPrimitives TrkEventUtils TrkMaterialOnTrack TrkMeasurementBase TrkParameters TrkPseudoMeasurementOnTrack TrkRIO_OnTrack TrkRoad TrkTrack TrkSegment TrkTrackSummary TrkExInterfaces TrkFitterInterfaces TrkToolInterfaces TrkDriftCircleMath MuonCondData ) + LINK_LIBRARIES ${ROOT_LIBRARIES} ${EIGEN_LIBRARIES} AthenaBaseComps AthenaKernel StoreGateLib SGtests GeoPrimitives IRegionSelector Identifier RoiDescriptor EventPrimitives GaudiKernel MuonAlignErrorBase MuonReadoutGeometry MuonIdHelpersLib MuonCompetingRIOsOnTrack MuonPrepRawData MuonRIO_OnTrack MuonSegment MuonRecHelperToolsLib MuonRecToolInterfaces MuonStationIntersectSvcLib MuonSegmentMakerUtils TrkDetDescrInterfaces TrkDetElementBase TrkGeometry TrkSurfaces TrkVolumes TrkEventPrimitives TrkEventUtils TrkMaterialOnTrack TrkMeasurementBase TrkParameters TrkPseudoMeasurementOnTrack TrkRIO_OnTrack TrkRoad TrkTrack TrkSegment TrkTrackSummary TrkExInterfaces TrkFitterInterfaces TrkToolInterfaces TrkDriftCircleMath MuonCondData MagFieldElements MagFieldConditions ) diff --git a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonTrackCleaner.cxx b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonTrackCleaner.cxx index 6d435c4271b11d9b1ab021aea3f5212a9ee078cc..a7bd1a1de08d96f3420850cde01b51872a4db611 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonTrackCleaner.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonTrackCleaner.cxx @@ -56,7 +56,7 @@ namespace Muon { ATH_CHECK( m_mdtRotCreator.retrieve() ); ATH_CHECK( m_compRotCreator.retrieve() ); ATH_CHECK( m_measurementUpdator.retrieve() ); - ATH_CHECK( m_magFieldSvc.retrieve() ); + ATH_CHECK( m_fieldCacheCondObjInputKey.initialize() ); return StatusCode::SUCCESS; } @@ -883,7 +883,20 @@ namespace Muon { state.nIdHits = 0; state.nPseudoMeasurements = 0; state.nPhiConstraints = 0; - state.slFit = !m_magFieldSvc->toroidOn() || m_edmHelperSvc->isSLTrack( track ); + + MagField::AtlasFieldCache fieldCache; + // Get field cache object + EventContext ctx = Gaudi::Hive::currentContext(); + SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + + if (fieldCondObj == nullptr) { + ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); + return; + } + fieldCondObj->getInitializedCache (fieldCache); + + state.slFit = !fieldCache.toroidOn() || m_edmHelperSvc->isSLTrack( track ); // loop over track and calculate residuals const DataVector<const Trk::TrackStateOnSurface>* states = track.trackStateOnSurfaces(); @@ -1319,7 +1332,7 @@ namespace Muon { } // update sl fit configuration if track has ID hits or vertex constraint - if( state.slFit && (state.hasVertexConstraint || state.nIdHits > 0 ) && m_magFieldSvc->solenoidOn() ) { + if( state.slFit && (state.hasVertexConstraint || state.nIdHits > 0 ) && fieldCache.solenoidOn() ) { state.slFit = false; } @@ -1327,9 +1340,9 @@ namespace Muon { if(state.hasVertexConstraint || state.nIdHits ) { if( state.hasVertexConstraint ) ATH_MSG_DEBUG(" Track has vertex contraint:"); if( state.nIdHits > 0 ) ATH_MSG_DEBUG(" Track has ID Hits: " << state.nIdHits); - if( m_magFieldSvc->solenoidOn() ) ATH_MSG_DEBUG(" Solenoid On"); + if( fieldCache.solenoidOn() ) ATH_MSG_DEBUG(" Solenoid On"); else ATH_MSG_DEBUG(" Solenoid Off"); - if( m_magFieldSvc->toroidOn() ) ATH_MSG_DEBUG(" Toroid On"); + if( fieldCache.toroidOn() ) ATH_MSG_DEBUG(" Toroid On"); else ATH_MSG_DEBUG(" Toroid Off"); if( state.slFit ) ATH_MSG_DEBUG(" Use SL fit"); else ATH_MSG_DEBUG(" Use curved fit"); diff --git a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonTrackCleaner.h b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonTrackCleaner.h index 86a81d42839516cc9badf6a010d3e7809d98e8ec..f06d4927d2c7cdbcd4410c722a54f493a1d795e1 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonTrackCleaner.h +++ b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonTrackCleaner.h @@ -23,7 +23,8 @@ #include "TrkToolInterfaces/IResidualPullCalculator.h" #include "TrkToolInterfaces/IUpdator.h" -#include "MagFieldInterfaces/IMagFieldSvc.h" +// For magneticfield +#include "MagFieldConditions/AtlasFieldCacheCondObj.h" #include "TrkParameters/TrackParameters.h" #include <string> @@ -289,8 +290,10 @@ namespace Muon { "Handle to the service providing the IMuonEDMHelperSvc interface" }; ToolHandle<Muon::MuonEDMPrinterTool> m_printer {this, "Printer", "Muon::MuonEDMPrinterTool/MuonEDMPrinterTool"}; ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; - ServiceHandle<MagField::IMagFieldSvc> m_magFieldSvc {this, "MagFieldSvc", "AtlasFieldSvc"}; ToolHandle<Trk::IExtrapolator> m_extrapolator {this, "Extrapolator", "Trk::Extrapolator/AtlasExtrapolator"}; + // Read handle for conditions object to get the field cache + SG::ReadCondHandleKey<AtlasFieldCacheCondObj> m_fieldCacheCondObjInputKey {this, "AtlasFieldCacheCondObj", "fieldCondObj", + "Name of the Magnetic Field conditions object key"}; Gaudi::Property<bool> m_useMdtResiCut {this, "UseMdtResiCut", false}; Gaudi::Property<double> m_chi2Cut {this, "Chi2Cut", 100.}; diff --git a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonTrackExtrapolationTool.cxx b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonTrackExtrapolationTool.cxx index fca2de882fd6248575e3cb56c7bb4f05e0ba2eeb..d28e275676e13494707b462069d79c9044e33eef 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonTrackExtrapolationTool.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonTrackExtrapolationTool.cxx @@ -32,12 +32,10 @@ namespace Muon { m_atlasExtrapolator("Trk::Extrapolator/AtlasExtrapolator"), m_muonExtrapolator("Trk::Extrapolator/MuonExtrapolator"), m_muonExtrapolator2("Trk::Extrapolator/MuonExtrapolator"), - m_magFieldSvc("AtlasFieldSvc",na), m_trackingGeometrySvc("TrackingGeometrySvc/AtlasTrackingGeometrySvc",na), m_printer("Muon::MuonEDMPrinterTool/MuonEDMPrinterTool") { declareInterface<IMuonTrackExtrapolationTool>(this); - declareProperty( "MagFieldSvc", m_magFieldSvc ); declareProperty( "TrackingGeometrySvc", m_trackingGeometrySvc); declareProperty( "MuonExtrapolator", m_muonExtrapolator); declareProperty( "MuonExtrapolator2", m_muonExtrapolator2); @@ -57,7 +55,7 @@ namespace Muon { if( !m_muonExtrapolator.empty() ) ATH_CHECK( m_muonExtrapolator.retrieve() ); if( !m_muonExtrapolator2.empty() ) ATH_CHECK( m_muonExtrapolator2.retrieve() ); ATH_CHECK( m_trackingGeometrySvc.retrieve() ); - ATH_CHECK( m_magFieldSvc.retrieve() ); + ATH_CHECK( m_fieldCacheCondObjInputKey.initialize() ); if( m_cosmics ) ATH_MSG_DEBUG("Running in cosmics mode" ); @@ -67,15 +65,15 @@ namespace Muon { const Trk::TrackParameters* MuonTrackExtrapolationTool::extrapolateToMuonEntryRecord( const Trk::TrackParameters& pars, Trk::ParticleHypothesis particleHypo ) const { - if( m_muonExtrapolator.empty() ) return 0; + if( m_muonExtrapolator.empty() ) return nullptr; if( !m_trackingGeometrySvc->trackingGeometry() ){ ATH_MSG_WARNING(" " << m_trackingGeometrySvc << " has no valid trackingGeometry pointer" ); - return 0; + return nullptr; } const Trk::TrackingVolume* msEntrance = m_trackingGeometrySvc->trackingGeometry()->trackingVolume(m_msEntranceName.c_str()); if( !msEntrance ) { ATH_MSG_WARNING(" MS entrance not found" ); - return 0; + return nullptr; } Trk::PropDirection dir = Trk::oppositeMomentum; @@ -101,7 +99,7 @@ namespace Muon { const Trk::TrackParameters* MuonTrackExtrapolationTool::extrapolateToIP( const Trk::TrackParameters& pars, Trk::ParticleHypothesis particleHypo ) const { - if( m_atlasExtrapolator.empty() ) return 0; + if( m_atlasExtrapolator.empty() ) return nullptr; // temporary hack to avoid crashes in Muid. Amg::Vector3D refPos(0.1,0.1,0.1); @@ -139,10 +137,10 @@ namespace Muon { const Trk::TrackingVolume* msEntrance = m_trackingGeometrySvc->trackingGeometry()->trackingVolume(m_msEntranceName.c_str()); if( !msEntrance ) { ATH_MSG_WARNING("Failed to obtain muon entry volume"); - return 0; + return nullptr; } const Trk::Perigee* pp = track.perigeeParameters(); - if( !pp ) return 0; + if( !pp ) return nullptr; const Trk::TrackParameters* closestPars = pp; const Trk::TrackParameters* closestMeasPars = pp->covariance() ? pp : 0; @@ -319,20 +317,33 @@ namespace Muon { Trk::Track* MuonTrackExtrapolationTool::extrapolate( const Trk::Track& track ) const { - if( m_muonExtrapolator.empty() ) return 0; - // if straightline track and the field is on return 0 + if( m_muonExtrapolator.empty() ) return nullptr; + // if straightline track and the field is on return nullptr bool isSL = m_edmHelperSvc->isSLTrack(track); - if( m_magFieldSvc->toroidOn() && isSL ) { - return 0; + if( isSL ) { // check isSL first to limit access overhead + MagField::AtlasFieldCache fieldCache; + // Get field cache object + EventContext ctx = Gaudi::Hive::currentContext(); + SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + + if (fieldCondObj == nullptr) { + ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); + return nullptr; + } + fieldCondObj->getInitializedCache (fieldCache); + if( fieldCache.toroidOn() ) { + return nullptr; + } } const Trk::Perigee* pp = track.perigeeParameters(); - if( !pp ) return 0; + if( !pp ) return nullptr; const Trk::TrackParameters* firstPars = findClosestParametersToMuonEntry(track); if( !firstPars ){ ATH_MSG_WARNING("failed to find closest parameters to muon entry "); - return 0; + return nullptr; } // extrapolate to muon entry record @@ -354,7 +365,7 @@ namespace Muon { // check mometum, this should always work for high pt track but low momentum track could get stuck if( firstPars->momentum().mag() < 7000. ) ATH_MSG_DEBUG("lower energy muon lost during extrapolation "); else ATH_MSG_WARNING("failed to extrapolate parameters to muon entry and perigee "); - return 0; + return nullptr; } // sanity check for cosmics, if we are at the IP we should not @@ -379,7 +390,7 @@ namespace Muon { // double check if( !perigee ){ ATH_MSG_WARNING(" failed to create perigee "); - return 0; + return nullptr; } // direction of perigee diff --git a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonTrackExtrapolationTool.h b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonTrackExtrapolationTool.h index 70001a69b0166b782348314f135c710a3d600943..2c67bd9fddc6ced7346ceeeb41b8af9469acac0b 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonTrackExtrapolationTool.h +++ b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonTrackExtrapolationTool.h @@ -17,7 +17,8 @@ #include "TrkDetDescrInterfaces/ITrackingGeometrySvc.h" #include "TrkExInterfaces/IExtrapolator.h" -#include "MagFieldInterfaces/IMagFieldSvc.h" +// For magneticfield +#include "MagFieldConditions/AtlasFieldCacheCondObj.h" #include "TrkParameters/TrackParameters.h" @@ -78,7 +79,9 @@ namespace Muon { ToolHandle<Trk::IExtrapolator> m_muonExtrapolator; ToolHandle<Trk::IExtrapolator> m_muonExtrapolator2; // Moved from MuonEDMHelperSvc, not sure if it should be private/separate from m_muonExtrapolator - ServiceHandle<MagField::IMagFieldSvc> m_magFieldSvc; + // Read handle for conditions object to get the field cache + SG::ReadCondHandleKey<AtlasFieldCacheCondObj> m_fieldCacheCondObjInputKey {this, "AtlasFieldCacheCondObj", "fieldCondObj", + "Name of the Magnetic Field conditions object key"}; ServiceHandle<Trk::ITrackingGeometrySvc> m_trackingGeometrySvc; ServiceHandle<Muon::IMuonEDMHelperSvc> m_edmHelperSvc {this, "edmHelper", diff --git a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/CMakeLists.txt b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/CMakeLists.txt index b6027c22fc02af26c7173e98642985fba879ea8f..6c850c2f9b118cc93e25adaa6fa06965dae28115 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/CMakeLists.txt +++ b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/CMakeLists.txt @@ -14,7 +14,6 @@ atlas_depends_on_subdirs( PRIVATE DetectorDescription/Identifier Event/EventPrimitives GaudiKernel - MagneticField/MagFieldInterfaces MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry MuonSpectrometer/MuonIdHelpers MuonSpectrometer/MuonStationIndex @@ -41,7 +40,10 @@ atlas_depends_on_subdirs( PRIVATE Tracking/TrkExtrapolation/TrkExUtils Tracking/TrkFitter/TrkFitterInterfaces Tracking/TrkTools/TrkToolInterfaces - Tracking/TrkUtilityPackages/TrkDriftCircleMath ) + Tracking/TrkUtilityPackages/TrkDriftCircleMath + MagneticField/MagFieldElements + MagneticField/MagFieldConditions + ) # External dependencies: find_package( Eigen ) @@ -51,7 +53,7 @@ atlas_add_component( MuonTrackSteeringTools src/*.cxx src/components/*.cxx INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS} - LINK_LIBRARIES ${EIGEN_LIBRARIES} AthenaBaseComps AthenaKernel CxxUtils GeoPrimitives Identifier EventPrimitives GaudiKernel MagFieldInterfaces MuonReadoutGeometry MuonIdHelpersLib MuonStationIndexLib MuonCompetingRIOsOnTrack MuonPrepRawData MuonRIO_OnTrack MuonSegment MuonRecHelperToolsLib MuonRecToolInterfaces MuonSegmentMakerUtils TrkDetDescrUtils TrkGeometry TrkSurfaces TrkEventPrimitives TrkMeasurementBase TrkParameters TrkPseudoMeasurementOnTrack TrkSegment TrkTrack TrkTrackSummary TrkExInterfaces TrkExUtils TrkFitterInterfaces TrkToolInterfaces TrkDriftCircleMath ) + LINK_LIBRARIES ${EIGEN_LIBRARIES} AthenaBaseComps AthenaKernel CxxUtils GeoPrimitives Identifier EventPrimitives GaudiKernel MuonReadoutGeometry MuonIdHelpersLib MuonStationIndexLib MuonCompetingRIOsOnTrack MuonPrepRawData MuonRIO_OnTrack MuonSegment MuonRecHelperToolsLib MuonRecToolInterfaces MuonSegmentMakerUtils TrkDetDescrUtils TrkGeometry TrkSurfaces TrkEventPrimitives TrkMeasurementBase TrkParameters TrkPseudoMeasurementOnTrack TrkSegment TrkTrack TrkTrackSummary TrkExInterfaces TrkExUtils TrkFitterInterfaces TrkToolInterfaces TrkDriftCircleMath MagFieldElements MagFieldConditions ) # Install files from the package: atlas_install_joboptions( share/*.py ) diff --git a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MooCandidateMatchingTool.cxx b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MooCandidateMatchingTool.cxx index 5b48ab2a9d7d93e513656fba3fe839e31eb6dc06..869f98fd664eab2d8923d30e54a988fb27296a4b 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MooCandidateMatchingTool.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MooCandidateMatchingTool.cxx @@ -107,7 +107,7 @@ namespace Muon { ATH_CHECK( m_idHelperSvc.retrieve() ); ATH_CHECK( m_edmHelperSvc.retrieve() ); ATH_CHECK( m_printer.retrieve() ); - ATH_CHECK( m_magFieldSvc.retrieve() ); + ATH_CHECK( m_fieldCacheCondObjInputKey.initialize() ); ATH_CHECK( m_segmentMatchingTool.retrieve() ); ATH_CHECK( m_segmentMatchingToolTight.retrieve() ); ATH_CHECK( m_candidateTool.retrieve() ); @@ -723,6 +723,18 @@ namespace Muon { Identifier closestId; double closestIdDist = 1E9; bool trackHasPhi = true; + + MagField::AtlasFieldCache fieldCache; + // Get field cache object + EventContext ctx = Gaudi::Hive::currentContext(); + SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + + if (fieldCondObj == nullptr) { + ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); + return; + } + fieldCondObj->getInitializedCache (fieldCache); // loop over TSOS const DataVector<const Trk::TrackStateOnSurface>* tsoses = entry1.track().trackStateOnSurfaces(); @@ -816,7 +828,7 @@ namespace Muon { msg(MSG::DEBUG) << endmsg; } - bool straightLineMatch = !m_magFieldSvc->toroidOn(); + bool straightLineMatch = !fieldCache.toroidOn(); if ( hasStereoAngle && !trackHasPhi && (straightLineMatch || entry1.hasMomentum() ) ) { // can not do any extrapolation (not reliable) info.reason = TrackSegmentMatchResult::StereoAngleWithoutPhi; diff --git a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MooCandidateMatchingTool.h b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MooCandidateMatchingTool.h index b232d2bca007a8650007326223f104b64682bd18..8a0dc1ec89f38c4e5ff83ba91b22374acde8a334 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MooCandidateMatchingTool.h +++ b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MooCandidateMatchingTool.h @@ -15,7 +15,8 @@ #include "CxxUtils/checker_macros.h" #include "EventPrimitives/EventPrimitives.h" #include "GeoPrimitives/GeoPrimitives.h" -#include "MagFieldInterfaces/IMagFieldSvc.h" +// For magneticfield +#include "MagFieldConditions/AtlasFieldCacheCondObj.h" #include "MuonRecToolInterfaces/IMuonTrackSegmentMatchingTool.h" #include "MuonIdHelpers/IMuonIdHelperSvc.h" #include "MuonRecHelperTools/IMuonEDMHelperSvc.h" @@ -186,8 +187,9 @@ namespace Muon { {this, "SegmentMatchingTool", "Muon::MuonSegmentMatchingTool/MuonSegmentMatchingTool"}; ToolHandle<IMuonSegmentMatchingTool> m_segmentMatchingToolTight {this, "SegmentMatchingToolTight", "Muon::MuonSegmentMatchingTool/MuonSegmentMatchingToolTight"}; - ServiceHandle<MagField::IMagFieldSvc> m_magFieldSvc - {this, "MagFieldSvc", "AtlasFieldSvc"}; + // Read handle for conditions object to get the field cache + SG::ReadCondHandleKey<AtlasFieldCacheCondObj> m_fieldCacheCondObjInputKey {this, "AtlasFieldCacheCondObj", "fieldCondObj", + "Name of the Magnetic Field conditions object key"}; ToolHandle<MuPatCandidateTool> m_candidateTool {this, "MuPatCandidateTool", "Muon::MuPatCandidateTool/MuPatCandidateTool"}; diff --git a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MooTrackBuilder.cxx b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MooTrackBuilder.cxx index 5dbec3416b87b78d7ebea2d94a0898dbe17162b7..fb74810927293883e9ff6125b5baf54066485a92 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MooTrackBuilder.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MooTrackBuilder.cxx @@ -42,7 +42,7 @@ namespace Muon { ATH_CHECK( m_fitter.retrieve() ); ATH_CHECK( m_slFitter.retrieve() ); - ATH_CHECK(m_magFieldSvc.retrieve() ); + ATH_CHECK( m_fieldCacheCondObjInputKey.initialize() ); if( !m_errorOptimisationTool.empty() ) ATH_CHECK( m_errorOptimisationTool.retrieve() ); ATH_CHECK( m_candidateHandler.retrieve() ); ATH_CHECK( m_candidateMatchingTool.retrieve() ); @@ -74,7 +74,21 @@ namespace Muon { Trk::Track* MooTrackBuilder::refit( const Trk::Track& track ) const { - if( m_edmHelperSvc->isSLTrack(track) || !m_magFieldSvc->toroidOn() ) return m_slFitter->refit(track); + if( m_edmHelperSvc->isSLTrack(track)) { // check isSL first to limit access overhead + MagField::AtlasFieldCache fieldCache; + // Get field cache object + EventContext ctx = Gaudi::Hive::currentContext(); + SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + + if (fieldCondObj == nullptr) { + ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); + return nullptr; + } + fieldCondObj->getInitializedCache (fieldCache); + if( !fieldCache.toroidOn() ) return m_slFitter->refit(track); + } + // if not refit tool specified do a pure refit if( m_errorOptimisationTool.empty() ) return m_fitter->refit(track); @@ -86,7 +100,7 @@ namespace Muon { Trk::Track* finalTrack = m_hitRecoverTool->recover(track.track()); if( !finalTrack ) { ATH_MSG_WARNING(" final track lost, this should not happen " ); - return 0; + return nullptr; } ATH_MSG_VERBOSE("refine: after recovery " << std::endl << m_printer->print(*finalTrack) << std::endl @@ -147,7 +161,7 @@ namespace Muon { // try to get track Trk::Track* track = combine( seg1, seg2, externalPhiHits ); - if( !track ) return 0; + if( !track ) return nullptr; // create MuonSegment MuonSegment* seg = m_trackToSegmentTool->convert(*track); @@ -164,12 +178,12 @@ namespace Muon { Trk::Track* MooTrackBuilder::combine( const MuonSegment& seg1, const MuonSegment& seg2, const PrepVec* externalPhiHits ) const { // convert segments MuPatSegment* segInfo1 = m_candidateHandler->createSegInfo(seg1); - if( !segInfo1 ) return 0; + if( !segInfo1 ) return nullptr; MuPatSegment* segInfo2 = m_candidateHandler->createSegInfo(seg2); if( !segInfo2 ) { delete segInfo1; - return 0; + return nullptr; } // call fit() @@ -186,7 +200,7 @@ namespace Muon { // try to get track Trk::Track* track = combine( firstCandidate, secondCandidate, externalPhiHits ); - if( !track ) return 0; + if( !track ) return nullptr; // create MuonSegment MuonSegment* seg = m_trackToSegmentTool->convert(*track); @@ -208,7 +222,7 @@ namespace Muon { if (m_doTimeOutChecks && Athena::Timeout::instance().reached() ) { ATH_MSG_DEBUG("Timeout reached. Aborting sequence." ); ++m_nTimedOut; - return 0; + return nullptr; } @@ -255,7 +269,7 @@ namespace Muon { esit != candidate->excludedSegments().end(); ++esit ) { if(*esit == segment) { ATH_MSG_DEBUG(" Rejected segment based on exclusion list" ); - return 0; + return nullptr; } } } @@ -297,7 +311,7 @@ namespace Muon { // if all segments are already part of an existing track, don't perform the fit if( foundSegments.size() == segments.size() ){ ATH_MSG_DEBUG("Combination already part of an existing track"); - return 0; + return nullptr; } // if all segments but one are already part of an existing track, check the exclusion list @@ -317,13 +331,13 @@ namespace Muon { if( unassociatedSegments.size() != 1 ) { ATH_MSG_DEBUG("Inconsistent result from set difference: size result " << unassociatedSegments.size() << " candidate " << segments.size() << " found " << foundSegments.size() ); - return 0; + return nullptr; } // check that the result is indeed part of the original set if( !segments.count(unassociatedSegments.front()) ){ ATH_MSG_DEBUG("Segment point not part of the original set, aborting!"); - return 0; + return nullptr; } // now check whether the segment is part of the excluded segments @@ -332,7 +346,7 @@ namespace Muon { unassociatedSegments.front() ); if( pos != candidate->excludedSegments().end() ){ ATH_MSG_DEBUG("Segment found in exclusion list, not performing fit"); - return 0; + return nullptr; } } } @@ -341,8 +355,20 @@ namespace Muon { //ATH_MSG_INFO(" Performing fit" ); } - if( slFit || !m_magFieldSvc->toroidOn() ) return m_slFitter->fit(firstCandidate,secondCandidate,externalPhiHits); - else return m_fitter->fit(firstCandidate,secondCandidate,externalPhiHits); + EventContext ctx = Gaudi::Hive::currentContext(); + MagField::AtlasFieldCache fieldCache; + // Get field cache object + SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + + if (fieldCondObj == nullptr) { + ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); + return nullptr; + } + fieldCondObj->getInitializedCache (fieldCache); + + if( slFit || !fieldCache.toroidOn() ) return m_slFitter->fit(firstCandidate,secondCandidate,externalPhiHits); + else return m_fitter->fit(firstCandidate,secondCandidate,externalPhiHits); } @@ -350,12 +376,12 @@ namespace Muon { const PrepVec* externalPhiHits ) const { // convert segments MuPatTrack* candidate = m_candidateHandler->createCandidate(new Trk::Track(track)); - if( !candidate ) return 0; + if( !candidate ) return nullptr; MuPatSegment* segInfo = m_candidateHandler->createSegInfo(seg); if( !segInfo ) { delete candidate; - return 0; + return nullptr; } // call fit() @@ -372,12 +398,12 @@ namespace Muon { const PrepVec* externalPhiHits ) const { // convert segments MuPatTrack* candidate = m_candidateHandler->createCandidate(new Trk::Track(track)); - if( !candidate ) return 0; + if( !candidate ) return nullptr; MuPatSegment* segInfo = m_candidateHandler->createSegInfo(seg); if( !segInfo ) { delete candidate; - return 0; + return nullptr; } // call fit() @@ -406,7 +432,7 @@ namespace Muon { const DataVector<const Trk::TrackStateOnSurface>* states = track.trackStateOnSurfaces(); if( !states ){ ATH_MSG_DEBUG(" track without states! " ); - return 0; + return nullptr; } // loop over TSOSs @@ -450,7 +476,7 @@ namespace Muon { // return clone of parameters if( closestParameters ) return closestParameters->clone(); - return 0; + return nullptr; } @@ -477,7 +503,7 @@ namespace Muon { const PrepVec* patternPhiHits ) const { // convert track MuPatTrack* can = m_candidateHandler->createCandidate(new Trk::Track(track)); - if( !can ) return 0; + if( !can ) return nullptr; std::vector<Trk::Track*>* tracks = combineWithSegmentFinding(*can,pars,chIds,patternPhiHits); delete can; @@ -500,19 +526,19 @@ namespace Muon { // get chamber Id of segment std::set<Identifier> chIds = m_edmHelperSvc->chamberIds(seg); - if( chIds.empty() ) return 0; + if( chIds.empty() ) return nullptr; // for now do not redo segment making for CSCs if( m_idHelperSvc->isCsc( *chIds.begin() ) ){ if( m_candidateMatchingTool->match(candidate,segInfo,true) ) { Trk::Track* newtrack = m_fitter->fit(candidate,segInfo,externalPhiHits); - if( !newtrack ) return 0; + if( !newtrack ) return nullptr; std::vector<Trk::Track*>* newTracks = new std::vector<Trk::Track*>; newTracks->push_back(newtrack); return newTracks; }else{ - return 0; + return nullptr; } } @@ -525,7 +551,7 @@ namespace Muon { if( !closestPars ) { ATH_MSG_WARNING( " unable to find closest TrackParameters " ); - return 0; + return nullptr; } ATH_MSG_VERBOSE(" closest parameter " << m_printer->print(*closestPars) ); @@ -539,7 +565,7 @@ namespace Muon { if( !exPars ) { ATH_MSG_WARNING( " Propagation failed!! " ); - return 0; + return nullptr; } ATH_MSG_VERBOSE(" extrapolated parameter " << m_printer->print(*exPars) ); @@ -619,11 +645,11 @@ namespace Muon { const std::set<Identifier>& chIds, const PrepVec* externalPhiHits ) const { - if( chIds.empty() ) return 0; + if( chIds.empty() ) return nullptr; if( !m_idHelperSvc->isMdt(*chIds.begin()) ) { ATH_MSG_WARNING("combineWithSegmentFinding called with CSC hits!! retuning zero pointer"); - return 0; + return nullptr; } // redo segment finding @@ -632,11 +658,11 @@ namespace Muon { // check whether we got segments if( !segments ) { ATH_MSG_DEBUG(" failed to find new segments " ); - return 0; + return nullptr; } if( segments->empty() ){ ATH_MSG_DEBUG(" got empty vector!! " ); - return 0; + return nullptr; } unsigned int nseg=segments->size(); @@ -698,7 +724,7 @@ namespace Muon { if( !newTracks || newTracks->empty() ){ delete newTracks; - return 0; + return nullptr; } ATH_MSG_DEBUG(" found new tracks for segment " << newTracks->size() ); @@ -712,7 +738,7 @@ namespace Muon { const DataVector<const Trk::TrackStateOnSurface>* states = track.trackStateOnSurfaces(); if( !states ){ ATH_MSG_DEBUG(" track without states, discarding track " ); - return 0; + return nullptr; } if( msgLvl(MSG::DEBUG) ) { msg(MSG::DEBUG) << MSG::DEBUG << " recalibrating hits on track " << std::endl @@ -1013,13 +1039,25 @@ namespace Muon { } std::pair<Trk::Track*,Trk::Track*> MooTrackBuilder::splitTrack( const Trk::Track& track ) const { - return m_edmHelperSvc->isSLTrack(track) || !m_magFieldSvc->toroidOn() ? m_slFitter->splitTrack(track) : m_fitter->splitTrack(track); + EventContext ctx = Gaudi::Hive::currentContext(); + MagField::AtlasFieldCache fieldCache; + // Get field cache object + SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + + if (fieldCondObj == nullptr) { + ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); + std::pair<Trk::Track*,Trk::Track*> emptyPair; + return emptyPair; + } + fieldCondObj->getInitializedCache (fieldCache); + return m_edmHelperSvc->isSLTrack(track) || !fieldCache.toroidOn() ? m_slFitter->splitTrack(track) : m_fitter->splitTrack(track); } std::vector<MuPatTrack*>* MooTrackBuilder::find( MuPatCandidateBase& candidate, const std::vector<MuPatSegment*>& segVec ) const { // check whether we have segments - if( segVec.empty() ) return 0; + if( segVec.empty() ) return nullptr; std::vector<MuPatTrack*>* candidates = new std::vector<MuPatTrack*>(); std::set<MuPatSegment*> usedSegments; @@ -1523,7 +1561,7 @@ namespace Muon { } // did we find any? - if( !foundSplitTracks ) return 0; + if( !foundSplitTracks ) return nullptr; // loop over the new track vector and create a new TrackCollection TrackCollection* newTracks = new TrackCollection(); newTracks->reserve(goodTracks.size()); diff --git a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MooTrackBuilder.h b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MooTrackBuilder.h index 072557066c786e9cb9337ee9a933649e7ab3f58d..fe5165bd708add71215d1a6528e02656ef22b69f 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MooTrackBuilder.h +++ b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MooTrackBuilder.h @@ -25,7 +25,8 @@ #include "MuonRecToolInterfaces/IMdtDriftCircleOnTrackCreator.h" #include "TrkExInterfaces/IPropagator.h" #include "TrkToolInterfaces/IResidualPullCalculator.h" -#include "MagFieldInterfaces/IMagFieldSvc.h" +// For magneticfield +#include "MagFieldConditions/AtlasFieldCacheCondObj.h" #include "TrkToolInterfaces/IExtendedTrackSummaryTool.h" #include "TrkTrackSummary/MuonTrackSummary.h" @@ -280,7 +281,9 @@ namespace Muon { ToolHandle<IMuonErrorOptimisationTool> m_errorOptimisationTool {this, "ErrorOptimisationTool", ""}; ToolHandle<Trk::IExtendedTrackSummaryTool> m_trackSummaryTool {this, "TrackSummaryTool", "MuonTrackSummaryTool"}; - ServiceHandle<MagField::IMagFieldSvc> m_magFieldSvc {this, "MagFieldSvc", "AtlasFieldSvc"}; + // Read handle for conditions object to get the field cache + SG::ReadCondHandleKey<AtlasFieldCacheCondObj> m_fieldCacheCondObjInputKey {this, "AtlasFieldCacheCondObj", "fieldCondObj", + "Name of the Magnetic Field conditions object key"}; Trk::MagneticFieldProperties m_magFieldProperties {Trk::FullField}; //!< magnetic field properties Gaudi::Property<bool> m_doTimeOutChecks {this,"UseTimeOutGuard" , true }; //!< on/off time out check diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkFlavourTag/python/SoftBtagCommon.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkFlavourTag/python/SoftBtagCommon.py index 91f7b6f471cfba4e7941d34a447c9d1df0cb375a..851ac74ec106b9fef716027fb460cbf1196523db 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkFlavourTag/python/SoftBtagCommon.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkFlavourTag/python/SoftBtagCommon.py @@ -53,8 +53,7 @@ def applySoftBtagging(algname,sequence): from TrkVKalVrtFitter.TrkVKalVrtFitterConf import Trk__TrkVKalVrtFitter InclusiveVxFitterTool = Trk__TrkVKalVrtFitter(name = "InclusiveVxFitter", Extrapolator = ToolSvc.AtlasExtrapolator, - IterationNumber = 30, - AtlasMagFieldSvc = "AtlasFieldSvc" + IterationNumber = 30 ) ToolSvc += InclusiveVxFitterTool; diff --git a/PhysicsAnalysis/EventTag/EventTagRawAlgs/CMakeLists.txt b/PhysicsAnalysis/EventTag/EventTagRawAlgs/CMakeLists.txt index 04dfbddcbd7589f618a1295bb3034a38dc3e85bd..f16ce190126aa7cb5ff417388ceff6e39eceb284 100644 --- a/PhysicsAnalysis/EventTag/EventTagRawAlgs/CMakeLists.txt +++ b/PhysicsAnalysis/EventTag/EventTagRawAlgs/CMakeLists.txt @@ -10,7 +10,6 @@ atlas_depends_on_subdirs( PUBLIC Control/AthenaBaseComps Control/AthenaKernel GaudiKernel - MagneticField/MagFieldInterfaces Tracking/TrkEvent/TrkSegment PRIVATE Calorimeter/CaloEvent @@ -25,7 +24,10 @@ atlas_depends_on_subdirs( PUBLIC TileCalorimeter/TileIdentifier Tracking/TrkEvent/TrkSpacePoint Tracking/TrkEvent/TrkTrack - Tracking/TrkEvent/TrkTrackSummary ) + Tracking/TrkEvent/TrkTrackSummary + MagneticField/MagFieldElements + MagneticField/MagFieldConditions + ) # External dependencies: find_package( CLHEP ) @@ -35,7 +37,7 @@ atlas_add_component( EventTagRawAlgs src/*.cxx src/components/*.cxx INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} - LINK_LIBRARIES ${CLHEP_LIBRARIES} AthenaBaseComps AthenaKernel GaudiKernel MagFieldInterfaces TrkSegment CaloEvent CommissionEvent StoreGateLib SGtests xAODCaloEvent InDetBCM_RawData InDetPrepRawData LArRecEvent TagEvent TileEvent TileIdentifier TrkSpacePoint TrkTrack TrkTrackSummary ) + LINK_LIBRARIES ${CLHEP_LIBRARIES} AthenaBaseComps AthenaKernel GaudiKernel TrkSegment CaloEvent CommissionEvent StoreGateLib SGtests xAODCaloEvent InDetBCM_RawData InDetPrepRawData LArRecEvent TagEvent TileEvent TileIdentifier TrkSpacePoint TrkTrack TrkTrackSummary MagFieldElements MagFieldConditions ) # Install files from the package: atlas_install_joboptions( share/*.py ) diff --git a/PhysicsAnalysis/EventTag/EventTagRawAlgs/src/RawInfoSummaryForTagWriter.cxx b/PhysicsAnalysis/EventTag/EventTagRawAlgs/src/RawInfoSummaryForTagWriter.cxx index ed61707fad9e1184548b41b277b752cf24d0bcfe..d7e2d09bcabe7118131b95d3425e79a0604e7c67 100644 --- a/PhysicsAnalysis/EventTag/EventTagRawAlgs/src/RawInfoSummaryForTagWriter.cxx +++ b/PhysicsAnalysis/EventTag/EventTagRawAlgs/src/RawInfoSummaryForTagWriter.cxx @@ -22,8 +22,7 @@ RawInfoSummaryForTagWriter::RawInfoSummaryForTagWriter(const std::string& name, ISvcLocator* pSvcLocator) : - AthAlgorithm(name,pSvcLocator), - m_fieldServiceHandle("AtlasFieldSvc",name) + AthAlgorithm(name,pSvcLocator) { declareProperty("IDTrackKey",m_sgKeyIDtrack); declareProperty("CaloCellContKey", m_cellContKey="AllCalo"); @@ -38,7 +37,6 @@ RawInfoSummaryForTagWriter::RawInfoSummaryForTagWriter(const std::string& name, declareProperty("MBTSName",m_mbtsName="MBTSContainer"); declareProperty("MBTSCollTimeKey",m_MBTSCollTimeKey="MBTSCollisionTime"); declareProperty("MBTS_Threshold", m_mbts_threshold = 40.0/222.0 ); // Value in pC - declareProperty("MagFieldSvc" , m_fieldServiceHandle); declareProperty("OutputKey", m_RISFTKey="RawInfoSummaryForTag"); } @@ -63,7 +61,6 @@ StatusCode RawInfoSummaryForTagWriter::initialize() return StatusCode::FAILURE; } - ATH_CHECK(m_fieldServiceHandle.retrieve()); ATH_CHECK(m_sgKeyIDtrack.initialize()); ATH_CHECK(m_cellContKey.initialize()); if(m_doClusterSums) { @@ -82,6 +79,7 @@ StatusCode RawInfoSummaryForTagWriter::initialize() ATH_CHECK(m_trtPhaseName.initialize()); } ATH_CHECK(m_RISFTKey.initialize()); + ATH_CHECK( m_fieldCacheCondObjInputKey.initialize() ); return StatusCode::SUCCESS; } @@ -115,6 +113,17 @@ StatusCode RawInfoSummaryForTagWriter::execute() // input Track Collection int totNPixHits(0),totNSCTHits(0),totNTRTHits(0); + MagField::AtlasFieldCache fieldCache; + // Get field cache object + EventContext ctx = Gaudi::Hive::currentContext(); + SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + + if (fieldCondObj == nullptr) { + ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); + return StatusCode::FAILURE; + } + fieldCondObj->getInitializedCache (fieldCache); SG::ReadHandle<TrackCollection> tracks{m_sgKeyIDtrack}; for (const Trk::Track* track : *tracks) { @@ -128,7 +137,7 @@ StatusCode RawInfoSummaryForTagWriter::execute() if (nSCTHits>0) totNSCTHits++; if (nTRTHits>0) totNTRTHits++; - if(m_fieldServiceHandle->solenoidOn()){ + if(fieldCache.solenoidOn()){ const Trk::Perigee* perigee = track->perigeeParameters(); if(!perigee) continue; if(perigee->parameters()[Trk::qOverP]!=0){ diff --git a/PhysicsAnalysis/EventTag/EventTagRawAlgs/src/RawInfoSummaryForTagWriter.h b/PhysicsAnalysis/EventTag/EventTagRawAlgs/src/RawInfoSummaryForTagWriter.h index 41f6d4cc74e32dbc4d4936e034686ad374aee7ca..0b8ff99c63651a41b710b10623ca797c6121fe1a 100644 --- a/PhysicsAnalysis/EventTag/EventTagRawAlgs/src/RawInfoSummaryForTagWriter.h +++ b/PhysicsAnalysis/EventTag/EventTagRawAlgs/src/RawInfoSummaryForTagWriter.h @@ -17,7 +17,8 @@ Jamie Boyd 21 Jan 2008 (Jamie.Boyd@cern.ch) #include "GaudiKernel/ToolHandle.h" #include "AthenaKernel/IOVSvcDefs.h" #include "GaudiKernel/ServiceHandle.h" -#include "MagFieldInterfaces/IMagFieldSvc.h" +// For magneticfield +#include "MagFieldConditions/AtlasFieldCacheCondObj.h" #include <string> #include <vector> @@ -85,7 +86,8 @@ class RawInfoSummaryForTagWriter : public AthAlgorithm //coral::AttributeListSpecification* m_attribListSpec; - ServiceHandle<MagField::IMagFieldSvc> m_fieldServiceHandle; + // Read handle for conditions object to get the field cache + SG::ReadCondHandleKey<AtlasFieldCacheCondObj> m_fieldCacheCondObjInputKey {this, "AtlasFieldCacheCondObj", "fieldCondObj", "Name of the Magnetic Field conditions object key"}; }; #endif diff --git a/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/BTagging/JetBTaggerAlg.h b/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/BTagging/JetBTaggerAlg.h index b74d9fd3dac5611f98a17c30c435692ca7055f25..61ee38e22928796ebfb13d4a38d38424c0873660 100644 --- a/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/BTagging/JetBTaggerAlg.h +++ b/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/BTagging/JetBTaggerAlg.h @@ -20,7 +20,8 @@ #include "BTagging/IBTagTrackAssociation.h" #include "BTagging/IBTagSecVertexing.h" -#include "MagFieldInterfaces/IMagFieldSvc.h" +// For magneticfield +#include "MagFieldConditions/AtlasFieldCacheCondObj.h" namespace Analysis{ @@ -53,7 +54,8 @@ class JetBTaggerAlg: ToolHandle< IBTagTool > m_bTagTool; ToolHandle< IBTagTrackAssociation > m_BTagTrackAssocTool; ToolHandle< IBTagSecVertexing > m_bTagSecVtxTool; - ServiceHandle<MagField::IMagFieldSvc> m_magFieldSvc; + // Read handle for conditions object to get the field cache + SG::ReadCondHandleKey<AtlasFieldCacheCondObj> m_fieldCacheCondObjInputKey {this, "AtlasFieldCacheCondObj", "fieldCondObj", "Name of the Magnetic Field conditions object key"}; }; diff --git a/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/BTagging/JetBTaggerTool.h b/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/BTagging/JetBTaggerTool.h index d7784fdfac728de06513a327bbca9e5ce40bcc43..293b5ccd12ed2e0706e74663510ce4b91084a248 100644 --- a/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/BTagging/JetBTaggerTool.h +++ b/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/BTagging/JetBTaggerTool.h @@ -19,7 +19,8 @@ #include "StoreGate/WriteHandleKey.h" #include "StoreGate/WriteDecorHandleKey.h" -#include "MagFieldInterfaces/IMagFieldSvc.h" +// For magneticfield +#include "MagFieldConditions/AtlasFieldCacheCondObj.h" namespace Analysis{ @@ -45,6 +46,8 @@ class JetBTaggerTool: private: SG::ReadHandleKey<xAOD::JetContainer > m_JetCollectionName { this, "JetCollectionName", "", "Input jet container"}; + // Read handle for conditions object to get the field cache + SG::ReadCondHandleKey<AtlasFieldCacheCondObj> m_fieldCacheCondObjInputKey {this, "AtlasFieldCacheCondObj", "fieldCondObj", "Name of the Magnetic Field conditions object key"}; Gaudi::Property<SG::WriteDecorHandleKey<xAOD::JetContainer> >m_jetBTaggingLinkName{this,"JetContainerName","","Element link form jet to BTagging container"}; SG::WriteHandleKey<xAOD::BTaggingContainer> m_BTaggingCollectionName { this, "BTaggingCollectionName", "", "Output BTagging container"} ; @@ -54,7 +57,6 @@ class JetBTaggerTool: ToolHandle< IBTagTrackAssociation > m_BTagTrackAssocTool; ToolHandle< IBTagSecVertexing > m_bTagSecVtxTool; bool m_augment; - ServiceHandle<MagField::IMagFieldSvc> m_magFieldSvc; }; diff --git a/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/BTagging/JetBTaggingAlg.h b/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/BTagging/JetBTaggingAlg.h index 64969d14122d060ea30af5c100cabddb2cb3cb05..061b1fd3fc5a38c4dad372983d9cb62f96dfd4f0 100644 --- a/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/BTagging/JetBTaggingAlg.h +++ b/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/BTagging/JetBTaggingAlg.h @@ -22,7 +22,8 @@ #include "BTagging/IBTagTool.h" #include "BTagging/IBTagLightSecVertexing.h" -#include "MagFieldInterfaces/IMagFieldSvc.h" +// For magneticfield +#include "MagFieldConditions/AtlasFieldCacheCondObj.h" namespace Analysis{ class IJetFitterVariablesFactory; @@ -47,6 +48,8 @@ class JetBTaggingAlg: //SG::ReadHandleKey<xAOD::VertexContainer> m_VertexCollectionName {this, "vxPrimaryCollectionName", "", "Input primary vertex container"}; SG::ReadHandleKey<xAOD::VertexContainer> m_BTagSVCollectionName {this, "BTagSVCollectionName", "", "Input BTagging secondary vertex container"}; SG::ReadHandleKey<xAOD::BTagVertexContainer> m_BTagJFVtxCollectionName {this, "BTagJFVtxCollectionName", "", "Input BTagging Jet Fitter container"}; + // Read handle for conditions object to get the field cache + SG::ReadCondHandleKey<AtlasFieldCacheCondObj> m_fieldCacheCondObjInputKey {this, "AtlasFieldCacheCondObj", "fieldCondObj", "Name of the Magnetic Field conditions object key"}; SG::WriteDecorHandleKey<xAOD::JetContainer> m_jetBTaggingLinkName {this, "BTaggingLinkName", "", "Element link from jet to BTagging container"}; SG::WriteHandleKey<xAOD::BTaggingContainer> m_BTaggingCollectionName {this, "BTaggingCollectionName", "", "Output BTagging container"}; SG::WriteDecorHandleKey<xAOD::BTaggingContainer> m_bTagJetDecorLinkName {this, "JetLinkName", "", "Element Link from BTagging to Jet container"}; @@ -55,7 +58,6 @@ class JetBTaggingAlg: ToolHandle< IBTagTool > m_bTagTool; ToolHandle< IBTagLightSecVertexing > m_bTagSecVtxTool; - ServiceHandle<MagField::IMagFieldSvc> m_magFieldSvc; }; diff --git a/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/CMakeLists.txt b/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/CMakeLists.txt index e295aa977188748b9a1340a1c6def617502a047b..7b4db02be98369920740ce0e69f058bf5b82380e 100644 --- a/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/CMakeLists.txt +++ b/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/CMakeLists.txt @@ -12,7 +12,6 @@ atlas_depends_on_subdirs( PUBLIC Event/xAOD/xAODBTagging Event/xAOD/xAODJet GaudiKernel - MagneticField/MagFieldInterfaces Reconstruction/Jet/JetInterface Tracking/TrkEvent/VxVertex PRIVATE @@ -31,7 +30,10 @@ atlas_depends_on_subdirs( PUBLIC Reconstruction/Particle Tracking/TrkEvent/TrkLinks Tracking/TrkEvent/VxJetVertex - Tracking/TrkEvent/VxSecVertex ) + Tracking/TrkEvent/VxSecVertex + MagneticField/MagFieldElements + MagneticField/MagFieldConditions + ) # External dependencies: find_package( Eigen ) @@ -55,13 +57,13 @@ atlas_add_library( BTaggingLib src/HighLevelBTagAlg.cxx PUBLIC_HEADERS BTagging PRIVATE_INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS} - LINK_LIBRARIES AsgTools AthenaBaseComps xAODBTagging xAODJet GaudiKernel MagFieldInterfaces JetInterface VxVertex ParticleJetToolsLib JetTagToolsLib FlavorTagDiscriminants - PRIVATE_LINK_LIBRARIES ${EIGEN_LIBRARIES} GeoPrimitives xAODBase xAODCore xAODMuon xAODTracking InDetRecToolInterfaces JetTagEvent JetTagInfo Particle TrkLinks VxJetVertex VxSecVertex ) + LINK_LIBRARIES AsgTools AthenaBaseComps xAODBTagging xAODJet GaudiKernel JetInterface VxVertex ParticleJetToolsLib JetTagToolsLib FlavorTagDiscriminants + PRIVATE_LINK_LIBRARIES ${EIGEN_LIBRARIES} GeoPrimitives xAODBase xAODCore xAODMuon xAODTracking InDetRecToolInterfaces JetTagEvent JetTagInfo Particle TrkLinks VxJetVertex VxSecVertex MagFieldElements MagFieldConditions ) atlas_add_component( BTagging src/components/*.cxx INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS} - LINK_LIBRARIES ${EIGEN_LIBRARIES} AsgTools AthenaBaseComps xAODBTagging xAODJet GaudiKernel MagFieldInterfaces JetInterface VxVertex GeoPrimitives xAODBase xAODCore xAODMuon xAODTracking InDetRecToolInterfaces ParticleJetToolsLib JetTagEvent JetTagInfo JetTagToolsLib FlavorTagDiscriminants Particle TrkLinks VxJetVertex VxSecVertex BTaggingLib ) + LINK_LIBRARIES ${EIGEN_LIBRARIES} AsgTools AthenaBaseComps xAODBTagging xAODJet GaudiKernel JetInterface VxVertex GeoPrimitives xAODBase xAODCore xAODMuon xAODTracking InDetRecToolInterfaces ParticleJetToolsLib JetTagEvent JetTagInfo JetTagToolsLib FlavorTagDiscriminants Particle TrkLinks VxJetVertex VxSecVertex BTaggingLib ) # Install files from the package: atlas_install_python_modules( python/*.py ) diff --git a/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/python/BTagRun3Config.py b/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/python/BTagRun3Config.py index e9b86a8b570bcd0ea043f8da3b6a6043b01bf9db..85353641822b3f9a29d5fcdf25df96d88967c8c9 100644 --- a/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/python/BTagRun3Config.py +++ b/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/python/BTagRun3Config.py @@ -171,17 +171,12 @@ def BTagCfg(inputFlags,**kwargs): from PixelGeoModel.PixelGeoModelConfig import PixelGeometryCfg result.merge(PixelGeometryCfg( inputFlags )) + # get standard config for magnetic field - map and cache + from MagFieldServices.MagFieldServicesConfig import MagneticFieldSvcCfg + result.merge(MagneticFieldSvcCfg( inputFlags )) + from IOVDbSvc.IOVDbSvcConfig import addFolders, addFoldersSplitOnline - result.merge(addFolders(inputFlags,['/GLOBAL/BField/Maps <noover/>'],'GLOBAL_OFL')) - #result.merge(addFolders(inputFlags,['/GLOBAL/BField/Maps <noover/>'],'GLOBAL_ONL')) - #result.merge(addFolders(inputFlags,['/GLOBAL/TrackingGeo/LayerMaterialV2'],'GLOBAL_ONL')) - result.merge(addFolders(inputFlags,['/EXT/DCS/MAGNETS/SENSORDATA'],'DCS_OFL')) - MagField__AtlasFieldSvc=CompFactory.MagField.AtlasFieldSvc - kwargs.setdefault( "UseDCS", True ) - result.addService(MagField__AtlasFieldSvc("AtlasFieldSvc",**kwargs)) - del kwargs['UseDCS'] - #load folders needed for Run2 ID alignment result.merge(addFoldersSplitOnline(inputFlags,"INDET","/Indet/Onl/Align","/Indet/Align",className="AlignableTransformContainer")) result.merge(addFolders(inputFlags,['/TRT/Align'],'TRT_OFL')) diff --git a/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/src/JetBTaggerAlg.cxx b/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/src/JetBTaggerAlg.cxx index 717f65cf2db2de556e019e78e032181fe5b8a716..8aa94602b096ff5bc118ace173bdd573b93e1693 100644 --- a/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/src/JetBTaggerAlg.cxx +++ b/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/src/JetBTaggerAlg.cxx @@ -28,15 +28,13 @@ namespace Analysis { m_BTagLink(".btaggingLink"), m_bTagTool("Analysis::BTagTool",this), m_BTagTrackAssocTool("Analysis::BTagTrackAssociation",this), - m_bTagSecVtxTool("Analysis::BTagSecVertexing",this), - m_magFieldSvc("AtlasFieldSvc",n) + m_bTagSecVtxTool("Analysis::BTagSecVertexing",this) { declareProperty("JetCalibrationName", m_JetName); declareProperty("BTaggingLink", m_BTagLink); declareProperty("BTagTool", m_bTagTool); declareProperty("BTagTrackAssocTool", m_BTagTrackAssocTool); declareProperty("BTagSecVertexing", m_bTagSecVtxTool); - declareProperty("MagFieldSvc", m_magFieldSvc ); } JetBTaggerAlg::~JetBTaggerAlg() @@ -83,11 +81,8 @@ namespace Analysis { ATH_MSG_DEBUG("#BTAGVTX# Retrieved tool " << m_bTagSecVtxTool); } - /// retrieve the magnetic field service - if (m_magFieldSvc.retrieve().isFailure()){ - ATH_MSG_ERROR("Could not get " << m_magFieldSvc); - return StatusCode::FAILURE; - } + /// handle to the magnetic field cache + ATH_CHECK( m_fieldCacheCondObjInputKey.initialize() ); return StatusCode::SUCCESS; } @@ -120,7 +115,19 @@ namespace Analysis { ATH_CHECK( h_BTaggingCollectionName.record(std::make_unique<xAOD::BTaggingContainer>(), std::make_unique<xAOD::BTaggingAuxContainer>()) ); - if (!m_magFieldSvc->solenoidOn()) { + MagField::AtlasFieldCache fieldCache; + // Get field cache object + EventContext ctx = Gaudi::Hive::currentContext(); + SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + + if (fieldCondObj == nullptr) { + ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); + return StatusCode::FAILURE; + } + fieldCondObj->getInitializedCache (fieldCache); + + if (!fieldCache.solenoidOn()) { for (size_t jetIndex=0; jetIndex < h_JetCollectionName->size() ; ++jetIndex) { const xAOD::Jet * jet = h_JetCollectionName->at(jetIndex); ElementLink< xAOD::BTaggingContainer> linkBTagger; diff --git a/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/src/JetBTaggerTool.cxx b/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/src/JetBTaggerTool.cxx index 7e56b9a45c9c9f8f1aad62f8da4cb6f70eea4058..fceedffcb570489b981adfdc5df4218016e48974 100644 --- a/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/src/JetBTaggerTool.cxx +++ b/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/src/JetBTaggerTool.cxx @@ -34,15 +34,13 @@ namespace Analysis { m_bTagTool("Analysis::BTagTool",this), m_BTagTrackAssocTool("Analysis::BTagTrackAssociation", this), m_bTagSecVtxTool("Analysis::BTagSecVertexing", this), - m_augment(false), - m_magFieldSvc("AtlasFieldSvc",n) + m_augment(false) { declareProperty( "JetCalibrationName", m_JetName); declareProperty( "BTagTool", m_bTagTool); declareProperty( "BTagTrackAssocTool", m_BTagTrackAssocTool); declareProperty( "BTagSecVertexing", m_bTagSecVtxTool); declareProperty( "BTagAugmentation", m_augment, "switch to decide whether to merely extend the BTagging information as opposed to re-tagging from scratch"); - declareProperty("MagFieldSvc", m_magFieldSvc ); } JetBTaggerTool::~JetBTaggerTool() @@ -88,11 +86,8 @@ namespace Analysis { ATH_MSG_DEBUG("#BTAGVTX# Retrieved tool " << m_bTagSecVtxTool); } - /// retrieve the magnetic field service - if (m_magFieldSvc.retrieve().isFailure()){ - ATH_MSG_ERROR("Could not get " << m_magFieldSvc); - return StatusCode::FAILURE; - } + /// handle to the magnetic field cache + ATH_CHECK( m_fieldCacheCondObjInputKey.initialize() ); return StatusCode::SUCCESS; } @@ -125,7 +120,19 @@ namespace Analysis { ATH_CHECK( h_BTaggingCollectionName.record(std::make_unique<xAOD::BTaggingContainer>(), std::make_unique<xAOD::BTaggingAuxContainer>()) ); - if (!m_magFieldSvc->solenoidOn()) { + MagField::AtlasFieldCache fieldCache; + // Get field cache object + EventContext ctx = Gaudi::Hive::currentContext(); + SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + + if (fieldCondObj == nullptr) { + ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); + return StatusCode::FAILURE; + } + fieldCondObj->getInitializedCache (fieldCache); + + if (!fieldCache.solenoidOn()) { for (size_t jetIndex=0; jetIndex < h_JetCollectionName->size() ; ++jetIndex) { const xAOD::Jet * jet = h_JetCollectionName->at(jetIndex); ElementLink< xAOD::BTaggingContainer> linkBTagger; @@ -214,9 +221,21 @@ namespace Analysis { ATH_CHECK(sc); + MagField::AtlasFieldCache fieldCache; + // Get field cache object + EventContext ctx = Gaudi::Hive::currentContext(); + SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + + if (fieldCondObj == nullptr) { + ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); + return StatusCode::FAILURE; + } + fieldCondObj->getInitializedCache (fieldCache); + xAOD::JetContainer::const_iterator itB = jets.begin(); xAOD::JetContainer::const_iterator itE = jets.end(); - if (m_magFieldSvc->solenoidOn()) { + if (fieldCache.solenoidOn()) { for (xAOD::JetContainer::const_iterator it = itB ; it != itE; ++it) { xAOD::BTagging * newBTagMT = new xAOD::BTagging(); h_BTaggingCollectionName->push_back(newBTagMT); diff --git a/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/src/JetBTaggingAlg.cxx b/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/src/JetBTaggingAlg.cxx index b381bcd2383a8a4632a9e20651cb511222d454a6..1b93075c87f0768619eebb0be394a3ea903a8ceb 100644 --- a/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/src/JetBTaggingAlg.cxx +++ b/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/src/JetBTaggingAlg.cxx @@ -29,13 +29,11 @@ namespace Analysis { AthAlgorithm(n,p), m_JetName(""), m_bTagTool("Analysis::BTagTool",this), - m_bTagSecVtxTool("Analysis::BTagSecVertexing",this), - m_magFieldSvc("AtlasFieldSvc",n) + m_bTagSecVtxTool("Analysis::BTagSecVertexing",this) { declareProperty("JetCalibrationName", m_JetName); declareProperty("BTagTool", m_bTagTool); declareProperty("BTagSecVertexing", m_bTagSecVtxTool); - declareProperty("MagFieldSvc", m_magFieldSvc ); } JetBTaggingAlg::~JetBTaggingAlg() @@ -79,11 +77,8 @@ namespace Analysis { ATH_MSG_DEBUG("#BTAGVTX# Retrieved tool " << m_bTagSecVtxTool); } - /// retrieve the magnetic field service - if (m_magFieldSvc.retrieve().isFailure()){ - ATH_MSG_ERROR("Could not get " << m_magFieldSvc); - return StatusCode::FAILURE; - } + /// handle to the magnetic field cache + ATH_CHECK( m_fieldCacheCondObjInputKey.initialize() ); if (m_jetParticleLinkNameList.size() == 0) { ATH_MSG_FATAL( "#BTAG# Please provide track to jet association list"); @@ -139,7 +134,19 @@ namespace Analysis { ATH_CHECK( h_BTaggingCollectionName.record(std::make_unique<xAOD::BTaggingContainer>(), std::make_unique<xAOD::BTaggingAuxContainer>()) ); - if (!m_magFieldSvc->solenoidOn()) { + MagField::AtlasFieldCache fieldCache; + // Get field cache object + EventContext ctx = Gaudi::Hive::currentContext(); + SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + + if (fieldCondObj == nullptr) { + ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); + return StatusCode::FAILURE; + } + fieldCondObj->getInitializedCache (fieldCache); + + if (!fieldCache.solenoidOn()) { for (size_t jetIndex=0; jetIndex < h_JetCollectionName->size() ; ++jetIndex) { const xAOD::Jet * jet = h_JetCollectionName->at(jetIndex); ElementLink< xAOD::BTaggingContainer> linkBTagger; diff --git a/Reconstruction/MuonIdentification/MuidCaloScatteringTools/CMakeLists.txt b/Reconstruction/MuonIdentification/MuidCaloScatteringTools/CMakeLists.txt index dee1b7f86d35c1af01f381d4f23b6dd169d9501e..5600adf499b0b784f82a17f627273126f8e86789 100644 --- a/Reconstruction/MuonIdentification/MuidCaloScatteringTools/CMakeLists.txt +++ b/Reconstruction/MuonIdentification/MuidCaloScatteringTools/CMakeLists.txt @@ -9,7 +9,6 @@ atlas_subdir( MuidCaloScatteringTools ) atlas_depends_on_subdirs( PUBLIC Control/AthenaBaseComps GaudiKernel - MagneticField/MagFieldInterfaces Reconstruction/MuonIdentification/MuidInterfaces Tracking/TrkDetDescr/TrkDetDescrInterfaces Tracking/TrkDetDescr/TrkSurfaces @@ -22,7 +21,10 @@ atlas_depends_on_subdirs( PUBLIC Tracking/TrkDetDescr/TrkGeometry Tracking/TrkEvent/TrkMaterialOnTrack Tracking/TrkEvent/TrkTrack - Tracking/TrkExtrapolation/TrkExUtils ) + Tracking/TrkExtrapolation/TrkExUtils + MagneticField/MagFieldElements + MagneticField/MagFieldConditions + ) # External dependencies: find_package( Eigen ) @@ -34,7 +36,7 @@ atlas_add_component( MuidCaloScatteringTools src/MuidMaterialEffectsOnTrackProvider.cxx src/components/*.cxx INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS} - LINK_LIBRARIES ${EIGEN_LIBRARIES} AthenaBaseComps GaudiKernel MagFieldInterfaces MuidInterfaces TrkDetDescrInterfaces TrkSurfaces TrkParameters TrkExInterfaces GeoPrimitives MuidEvent muonEvent TrkGeometry TrkMaterialOnTrack TrkTrack TrkExUtils ) + LINK_LIBRARIES ${EIGEN_LIBRARIES} AthenaBaseComps GaudiKernel MuidInterfaces TrkDetDescrInterfaces TrkSurfaces TrkParameters TrkExInterfaces GeoPrimitives MuidEvent muonEvent TrkGeometry TrkMaterialOnTrack TrkTrack TrkExUtils MagFieldElements MagFieldConditions ) # Install files from the package: atlas_install_headers( MuidCaloScatteringTools ) diff --git a/Reconstruction/MuonIdentification/MuidCaloScatteringTools/MuidCaloScatteringTools/MuidCaloTrackStateOnSurface.h b/Reconstruction/MuonIdentification/MuidCaloScatteringTools/MuidCaloScatteringTools/MuidCaloTrackStateOnSurface.h index 65ad0b3e3d06254cc16edabb9b48a20f828896da..e5ba69501f5e74437c42fee75aff70365a294c7a 100755 --- a/Reconstruction/MuonIdentification/MuidCaloScatteringTools/MuidCaloScatteringTools/MuidCaloTrackStateOnSurface.h +++ b/Reconstruction/MuonIdentification/MuidCaloScatteringTools/MuidCaloScatteringTools/MuidCaloTrackStateOnSurface.h @@ -23,7 +23,8 @@ //<<<<<< INCLUDES >>>>>> #include "AthenaBaseComps/AthAlgTool.h" -#include "MagFieldInterfaces/IMagFieldSvc.h" +// For magneticfield +#include "MagFieldConditions/AtlasFieldCacheCondObj.h" #include "MuidInterfaces/IMuidCaloTrackStateOnSurface.h" #include "GaudiKernel/ServiceHandle.h" #include "GaudiKernel/ToolHandle.h" @@ -90,9 +91,9 @@ private: ToolHandle<Rec::IMuidCaloEnergy> m_caloEnergyParam; ToolHandle<Rec::IMuidCaloMaterialParam> m_caloMaterialParam; Trk::MagneticFieldProperties* m_magFieldProperties; - ServiceHandle<MagField::IMagFieldSvc> m_magFieldSvcHandle; - MagField::IMagFieldSvc* m_magFieldSvc; ToolHandle<Trk::IPropagator> m_propagator; + // Read handle for conditions object to get the field cache + SG::ReadCondHandleKey<AtlasFieldCacheCondObj> m_fieldCacheCondObjInputKey {this, "AtlasFieldCacheCondObj", "fieldCondObj", "Name of the Magnetic Field conditions object key"}; // configurable cut-off values double m_minCaloRadius; diff --git a/Reconstruction/MuonIdentification/MuidCaloScatteringTools/src/MuidCaloTrackStateOnSurface.cxx b/Reconstruction/MuonIdentification/MuidCaloScatteringTools/src/MuidCaloTrackStateOnSurface.cxx index c566ad669c050f1ba5f5040b79235ec77026fd0a..89bbe88a79f3a899be82bf415cd81af0eccdb408 100755 --- a/Reconstruction/MuonIdentification/MuidCaloScatteringTools/src/MuidCaloTrackStateOnSurface.cxx +++ b/Reconstruction/MuonIdentification/MuidCaloScatteringTools/src/MuidCaloTrackStateOnSurface.cxx @@ -47,8 +47,6 @@ MuidCaloTrackStateOnSurface::MuidCaloTrackStateOnSurface (const std::string& typ m_caloEnergyParam ("Rec::MuidCaloEnergyTool/MuidCaloEnergyToolParam", this), m_caloMaterialParam ("Rec::MuidCaloMaterialParam/MuidCaloMaterialParam", this), m_magFieldProperties (0), - m_magFieldSvcHandle ("MagField::AtlasFieldSvc/AtlasFieldSvc", name), - m_magFieldSvc (0), m_propagator ("Trk::IntersectorWrapper/IntersectorWrapper", this), m_minCaloRadius (0.4*Gaudi::Units::meter), m_minRemainingEnergy (0.5*Gaudi::Units::GeV), @@ -108,16 +106,8 @@ MuidCaloTrackStateOnSurface::initialize() { ATH_MSG_DEBUG( "Retrieved tool " << m_caloMaterialParam ); } - if (m_magFieldSvcHandle.retrieve().isFailure()) - { - ATH_MSG_FATAL( "Failed to retrieve service " << m_magFieldSvcHandle ); - return StatusCode::FAILURE; - } - else - { - ATH_MSG_DEBUG( "Retrieved service " << m_magFieldSvcHandle ); - m_magFieldSvc = &*m_magFieldSvcHandle; - } + /// handle to the magnetic field cache + ATH_CHECK( m_fieldCacheCondObjInputKey.initialize() ); if (m_propagator.retrieve().isFailure()) { ATH_MSG_FATAL( "Failed to retrieve tool " << m_propagator ); @@ -162,6 +152,18 @@ MuidCaloTrackStateOnSurface::caloTSOS(const Trk::TrackParameters& parameters) co const Trk::TrackParameters* middleParams = 0; const Trk::TrackParameters* outerParams = 0; + MagField::AtlasFieldCache fieldCache; + // Get field cache object + EventContext ctx = Gaudi::Hive::currentContext(); + SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + + if (fieldCondObj == nullptr) { + ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); + return nullptr; + } + fieldCondObj->getInitializedCache (fieldCache); + // track to calo surfaces - first decide in or outwards bool trackOutwards = true; if (dynamic_cast<const Trk::PerigeeSurface*>(¶meters.associatedSurface())) @@ -218,7 +220,7 @@ MuidCaloTrackStateOnSurface::caloTSOS(const Trk::TrackParameters& parameters) co double correctedEnergy = innerParams->momentum().mag() - energyDeposit; // fail potential loopers - if (m_magFieldSvc->toroidOn() + if (fieldCache.toroidOn() && correctedEnergy < m_minRemainingEnergy) { delete middleTS; @@ -442,7 +444,7 @@ MuidCaloTrackStateOnSurface::innerTSOS (const Trk::TrackParameters& parameters) { ATH_MSG_DEBUG( " innerTSOS: extrapolation fails " ); delete extrapolation; - return 0; + return nullptr; } return m_caloMaterialParam->trackStateOnSurface(extrapolation); @@ -456,7 +458,7 @@ MuidCaloTrackStateOnSurface::outerTSOS (const Trk::TrackParameters& parameters) { ATH_MSG_DEBUG( " outerTSOS: extrapolation fails " ); delete extrapolation; - return 0; + return nullptr; } return m_caloMaterialParam->trackStateOnSurface(extrapolation); @@ -472,7 +474,7 @@ MuidCaloTrackStateOnSurface::middleTSOS (const Trk::TrackParameters& middleParam { ATH_MSG_DEBUG( " middleTSOS: extrapolation fails " ); delete extrapolation; - return 0; + return nullptr; } const Trk::TrackStateOnSurface* TSOS = 0; @@ -521,7 +523,7 @@ MuidCaloTrackStateOnSurface::innerParameters (const Trk::TrackParameters& parame oppositeDirection = Trk::alongMomentum; } } - if (! surface) return 0; + if (! surface) return nullptr; // extrapolate to calo surface (take care to get correct cylinder intersect) unsigned extrapolations = 0; @@ -544,14 +546,14 @@ MuidCaloTrackStateOnSurface::innerParameters (const Trk::TrackParameters& parame false, *m_magFieldProperties, Trk::nonInteracting); - if (! extrapolation) return 0; + if (! extrapolation) return nullptr; // phi flip means track has crossed beam-axis (so quit) double deltaPhi = std::abs(extrapolation->position().phi() - startingPhi); if (deltaPhi > 0.5*M_PI && deltaPhi < 1.5*M_PI) { delete extrapolation; - return 0; + return nullptr; } // also quit wrong rz-direction in endcap @@ -563,7 +565,7 @@ MuidCaloTrackStateOnSurface::innerParameters (const Trk::TrackParameters& parame { ATH_MSG_VERBOSE( " wrong way in endcap " ); delete extrapolation; - return 0; + return nullptr; } } @@ -609,7 +611,7 @@ MuidCaloTrackStateOnSurface::innerParameters (const Trk::TrackParameters& parame if (oldParameters == ¶meters) { ATH_MSG_VERBOSE( " innerParameters: extrap fails " ); - return 0; + return nullptr; } if (restart) { @@ -645,7 +647,7 @@ MuidCaloTrackStateOnSurface::innerParameters (const Trk::TrackParameters& parame if (deltaPhi > 0.5*M_PI && deltaPhi < 1.5*M_PI) { delete extrapolation; - return 0; + return nullptr; } ATH_MSG_VERBOSE( " innerParameters: success after " @@ -688,7 +690,7 @@ MuidCaloTrackStateOnSurface::middleParameters (const Trk::TrackParameters& param oppositeDirection = Trk::alongMomentum; } } - if (! surface) return 0; + if (! surface) return nullptr; // extrapolate to calo surface (take care to get correct cylinder intersect) unsigned extrapolations = 0; @@ -711,14 +713,14 @@ MuidCaloTrackStateOnSurface::middleParameters (const Trk::TrackParameters& param false, *m_magFieldProperties, Trk::nonInteracting); - if (! extrapolation) return 0; + if (! extrapolation) return nullptr; // phi flip means track has crossed beam-axis (so quit) double deltaPhi = std::abs(extrapolation->position().phi() - startingPhi); if (deltaPhi > 0.5*M_PI && deltaPhi < 1.5*M_PI) { delete extrapolation; - return 0; + return nullptr; } // also quit wrong rz-direction in endcap @@ -730,7 +732,7 @@ MuidCaloTrackStateOnSurface::middleParameters (const Trk::TrackParameters& param { ATH_MSG_VERBOSE( " wrong way in endcap " ); delete extrapolation; - return 0; + return nullptr; } } @@ -776,7 +778,7 @@ MuidCaloTrackStateOnSurface::middleParameters (const Trk::TrackParameters& param if (oldParameters == ¶meters) { ATH_MSG_VERBOSE( " middleParameters: extrap fails " ); - return 0; + return nullptr; } // arbitrary choice for oscillating solutions (i.e. following restart) if (restart) @@ -813,7 +815,7 @@ MuidCaloTrackStateOnSurface::middleParameters (const Trk::TrackParameters& param if (deltaPhi > 0.5*M_PI && deltaPhi < 1.5*M_PI) { delete extrapolation; - return 0; + return nullptr; } ATH_MSG_VERBOSE( " middleParameters: success after " @@ -856,7 +858,7 @@ MuidCaloTrackStateOnSurface::outerParameters (const Trk::TrackParameters& parame oppositeDirection = Trk::alongMomentum; } } - if (! surface) return 0; + if (! surface) return nullptr; // extrapolate to calo surface (take care to get correct cylinder intersect) unsigned extrapolations = 0; @@ -879,14 +881,14 @@ MuidCaloTrackStateOnSurface::outerParameters (const Trk::TrackParameters& parame false, *m_magFieldProperties, Trk::nonInteracting); - if (! extrapolation) return 0; + if (! extrapolation) return nullptr; // phi flip means track has crossed beam-axis (so quit) double deltaPhi = std::abs(extrapolation->position().phi() - startingPhi); if (deltaPhi > 0.5*M_PI && deltaPhi < 1.5*M_PI) { delete extrapolation; - return 0; + return nullptr; } // also quit wrong rz-direction in endcap @@ -898,7 +900,7 @@ MuidCaloTrackStateOnSurface::outerParameters (const Trk::TrackParameters& parame { ATH_MSG_VERBOSE( " wrong way in endcap " ); delete extrapolation; - return 0; + return nullptr; } } @@ -944,7 +946,7 @@ MuidCaloTrackStateOnSurface::outerParameters (const Trk::TrackParameters& parame if (oldParameters == ¶meters) { ATH_MSG_VERBOSE( " outerParameters: extrap fails " ); - return 0; + return nullptr; } // arbitrary choice for oscillating solutions (i.e. following restart) if (restart) @@ -981,7 +983,7 @@ MuidCaloTrackStateOnSurface::outerParameters (const Trk::TrackParameters& parame if (deltaPhi > 0.5*M_PI && deltaPhi < 1.5*M_PI) { delete extrapolation; - return 0; + return nullptr; } ATH_MSG_VERBOSE( " outerParameters: success after " diff --git a/Reconstruction/MuonIdentification/MuidTrackBuilder/CMakeLists.txt b/Reconstruction/MuonIdentification/MuidTrackBuilder/CMakeLists.txt index 1b4cb2cabdc3df9120e07989b430c689a71134bb..9278bf88b0f17bd1ebc90c578755ecf5a1785b65 100644 --- a/Reconstruction/MuonIdentification/MuidTrackBuilder/CMakeLists.txt +++ b/Reconstruction/MuonIdentification/MuidTrackBuilder/CMakeLists.txt @@ -19,7 +19,6 @@ atlas_depends_on_subdirs( PUBLIC Control/AthenaKernel Event/EventPrimitives InnerDetector/InDetRecEvent/InDetRIO_OnTrack - MagneticField/MagFieldInterfaces MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry MuonSpectrometer/MuonIdHelpers MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonCompetingRIOsOnTrack @@ -41,7 +40,10 @@ atlas_depends_on_subdirs( PUBLIC Tracking/TrkExtrapolation/TrkExUtils Tracking/TrkFitter/TrkFitterInterfaces Tracking/TrkFitter/TrkiPatFitterUtils - Tracking/TrkTools/TrkToolInterfaces ) + Tracking/TrkTools/TrkToolInterfaces + MagneticField/MagFieldElements + MagneticField/MagFieldConditions + ) # External dependencies: find_package( CLHEP ) @@ -55,7 +57,7 @@ atlas_add_component( MuidTrackBuilder src/OutwardsCombinedMuonTrackBuilder.cxx src/components/*.cxx INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} - LINK_LIBRARIES ${CLHEP_LIBRARIES} AthenaBaseComps AtlasDetDescr GaudiKernel MuidInterfaces TrkDetDescrInterfaces TrkGeometry TrkParameters TrkTrack InDetRIO_OnTrack MagFieldInterfaces MuonReadoutGeometry MuonIdHelpersLib MuonCompetingRIOsOnTrack MuonRIO_OnTrack MuonRecHelperToolsLib MuonRecToolInterfaces MuonCombinedToolInterfaces muonEvent TrkSurfaces TrkCompetingRIOsOnTrack TrkEventPrimitives TrkEventUtils TrkMaterialOnTrack TrkMeasurementBase TrkPseudoMeasurementOnTrack TrkTrackSummary VxVertex TrkExInterfaces TrkExUtils TrkFitterInterfaces TrkiPatFitterUtils TrkToolInterfaces ) + LINK_LIBRARIES ${CLHEP_LIBRARIES} AthenaBaseComps AtlasDetDescr GaudiKernel MuidInterfaces TrkDetDescrInterfaces TrkGeometry TrkParameters TrkTrack InDetRIO_OnTrack MuonReadoutGeometry MuonIdHelpersLib MuonCompetingRIOsOnTrack MuonRIO_OnTrack MuonRecHelperToolsLib MuonRecToolInterfaces MuonCombinedToolInterfaces muonEvent TrkSurfaces TrkCompetingRIOsOnTrack TrkEventPrimitives TrkEventUtils TrkMaterialOnTrack TrkMeasurementBase TrkPseudoMeasurementOnTrack TrkTrackSummary VxVertex TrkExInterfaces TrkExUtils TrkFitterInterfaces TrkiPatFitterUtils TrkToolInterfaces MagFieldElements MagFieldConditions ) # Install files from the package: atlas_install_headers( MuidTrackBuilder ) diff --git a/Reconstruction/MuonIdentification/MuidTrackBuilder/MuidTrackBuilder/CombinedMuonTrackBuilder.h b/Reconstruction/MuonIdentification/MuidTrackBuilder/MuidTrackBuilder/CombinedMuonTrackBuilder.h index fab109ace9273bf16d9ce6257574f58ae4484cb3..32a3cc6e9ed3e8652617dfbf87ee2ed7e94e45e3 100755 --- a/Reconstruction/MuonIdentification/MuidTrackBuilder/MuidTrackBuilder/CombinedMuonTrackBuilder.h +++ b/Reconstruction/MuonIdentification/MuidTrackBuilder/MuidTrackBuilder/CombinedMuonTrackBuilder.h @@ -21,7 +21,8 @@ #include "AthenaBaseComps/AthAlgTool.h" #include "GaudiKernel/ServiceHandle.h" #include "GaudiKernel/ToolHandle.h" -#include "MagFieldInterfaces/IMagFieldSvc.h" +// For magneticfield +#include "MagFieldConditions/AtlasFieldCacheCondObj.h" #include "MuidInterfaces/ICombinedMuonTrackBuilder.h" #include "MuidInterfaces/IMuidCaloEnergy.h" #include "MuidInterfaces/IMuidCaloTrackStateOnSurface.h" @@ -223,7 +224,8 @@ class CombinedMuonTrackBuilder : public AthAlgTool, virtual public ICombinedMuon ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc{this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; - ServiceHandle<MagField::IMagFieldSvc> m_magFieldSvc; + // Read handle for conditions object to get the field cache + SG::ReadCondHandleKey<AtlasFieldCacheCondObj> m_fieldCacheCondObjInputKey {this, "AtlasFieldCacheCondObj", "fieldCondObj", "Name of the Magnetic Field conditions object key"}; ServiceHandle<Trk::ITrackingGeometrySvc> m_trackingGeometrySvc; // init with callback ServiceHandle<Trk::ITrackingVolumesSvc> m_trackingVolumesSvc; diff --git a/Reconstruction/MuonIdentification/MuidTrackBuilder/src/CombinedMuonTrackBuilder.cxx b/Reconstruction/MuonIdentification/MuidTrackBuilder/src/CombinedMuonTrackBuilder.cxx index b81678f01a40614fb930a16be0cedfee4a81d9b9..bbeeef5eb042e93df0f9f5600f9e1942b97d045f 100755 --- a/Reconstruction/MuonIdentification/MuidTrackBuilder/src/CombinedMuonTrackBuilder.cxx +++ b/Reconstruction/MuonIdentification/MuidTrackBuilder/src/CombinedMuonTrackBuilder.cxx @@ -77,7 +77,6 @@ CombinedMuonTrackBuilder::CombinedMuonTrackBuilder(const std::string& type, cons m_trackQuery("Rec::MuonTrackQuery/MuonTrackQuery", this), m_trackSummary("Trk::TrackSummaryTool/MuidTrackSummaryTool", this), m_materialUpdator("Trk::TrkMaterialProviderTool/TrkMaterialProviderTool", this), - m_magFieldSvc("AtlasFieldSvc", name), m_trackingGeometrySvc("TrackingGeometrySvc/AtlasTrackingGeometrySvc", name), m_trackingVolumesSvc("TrackingVolumesSvc/TrackingVolumesSvc", name), m_magFieldProperties(Trk::FullField), @@ -173,8 +172,6 @@ CombinedMuonTrackBuilder::CombinedMuonTrackBuilder(const std::string& type, cons declareProperty("IDMS_xySigma", m_IDMS_xySigma); declareProperty("IDMS_rzSigma", m_IDMS_rzSigma); - declareProperty("MagFieldSvc", m_magFieldSvc); - // deprecated declareProperty("IndetSlimming", m_indetSlimming); declareProperty("InputSlimming", m_inputSlimming); @@ -296,8 +293,9 @@ CombinedMuonTrackBuilder::initialize() ATH_MSG_DEBUG("Retrieved tool " << m_idHelperSvc); ATH_CHECK(m_intersector.retrieve()); ATH_MSG_DEBUG("Retrieved tool " << m_intersector); - ATH_CHECK(m_magFieldSvc.retrieve()); - ATH_MSG_DEBUG("Retrieved service " << m_magFieldSvc); + /// handle to the magnetic field cache + ATH_CHECK( m_fieldCacheCondObjInputKey.initialize() ); + ATH_MSG_DEBUG("Setup handle for key " << m_fieldCacheCondObjInputKey); if (!m_materialAllocator.empty()) { ATH_CHECK(m_materialAllocator.retrieve()); @@ -442,7 +440,19 @@ CombinedMuonTrackBuilder::combinedFit(const Trk::Track& indetTrack, const Trk::T // match extrapolated indet track to inner calorimeter scattering surface // provided momentum defined (solenoid on) - if (surface && m_magFieldSvc->solenoidOn() && !m_updateWithCaloTG) { + MagField::AtlasFieldCache fieldCache; + // Get field cache object + EventContext ctx = Gaudi::Hive::currentContext(); + SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + + if (fieldCondObj == nullptr) { + ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); + return nullptr; + } + fieldCondObj->getInitializedCache (fieldCache); + + if (surface && fieldCache.solenoidOn() && !m_updateWithCaloTG) { const Trk::TrackStateOnSurface* innerTSOS = nullptr; if (m_useCaloTG) { @@ -488,7 +498,7 @@ CombinedMuonTrackBuilder::combinedFit(const Trk::Track& indetTrack, const Trk::T Trk::Track* muonTrack = nullptr; - if (!m_magFieldSvc->toroidOn()) { + if (!fieldCache.toroidOn()) { ATH_MSG_VERBOSE(" SL MS track: Calling createMuonTrack from " << __func__ << " at line " << __LINE__); muonTrack = createMuonTrack( indetTrack, indetTrack.perigeeParameters(), nullptr, extrapolatedTrack.trackStateOnSurfaces()->begin(), @@ -790,10 +800,22 @@ CombinedMuonTrackBuilder::indetExtension(const Trk::Track& indetTrack, // fail when solenoid off and toroid on (as extrapolation from ID is not the correct strategy) ToolHandle<Trk::IPropagator> propagator = m_propagatorSL; - if (m_magFieldSvc->toroidOn()) { + MagField::AtlasFieldCache fieldCache; + // Get field cache object + EventContext ctx = Gaudi::Hive::currentContext(); + SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + + if (fieldCondObj == nullptr) { + ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); + return 0; + } + fieldCondObj->getInitializedCache (fieldCache); + + if (fieldCache.toroidOn()) { // fail when solenoid off and toroid on - as extrapolation from ID is not the correct strategy // for material effects, fit starting value etc - if (!m_magFieldSvc->solenoidOn()) { + if (!fieldCache.solenoidOn()) { ATH_MSG_VERBOSE("indetExtension: method switched off when solenoid 'off' / toroid 'on'"); return nullptr; } @@ -943,8 +965,20 @@ Trk::Track* CombinedMuonTrackBuilder::standaloneFit(const Trk::Track& inputSpectrometerTrack, const Trk::Vertex* inputVertex, float bs_x, float bs_y, float bs_z) const { + MagField::AtlasFieldCache fieldCache; + // Get field cache object + EventContext ctx = Gaudi::Hive::currentContext(); + SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + + if (fieldCondObj == nullptr) { + ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); + return 0; + } + fieldCondObj->getInitializedCache (fieldCache); + // no SA fit with vertex constraint for Toroid off data - if (m_trackQuery->isLineFit(inputSpectrometerTrack) && !m_magFieldSvc->toroidOn()) { + if (m_trackQuery->isLineFit(inputSpectrometerTrack) && !fieldCache.toroidOn()) { return nullptr; } @@ -1110,7 +1144,7 @@ CombinedMuonTrackBuilder::standaloneFit(const Trk::Track& inputSpectrometerTrack if (vertex) { // vertex association only makes sense for magnet-on tracks with measured curvature - if (!m_magFieldSvc->toroidOn() || m_trackQuery->isLineFit(spectrometerTrack) || errorP > m_largeMomentumError) { + if (!fieldCache.toroidOn() || m_trackQuery->isLineFit(spectrometerTrack) || errorP > m_largeMomentumError) { ATH_MSG_VERBOSE("standaloneFit: vertex fit not attempted as curvature badly measured"); ATH_MSG_VERBOSE(" SA::failed (6)"); @@ -1202,7 +1236,7 @@ CombinedMuonTrackBuilder::standaloneFit(const Trk::Track& inputSpectrometerTrack // FIXME: missing prefit case for excessive spectrometer eloss WARNING // spot from line starting approx from vertex?? if (inCSCregion || m_trackQuery->numberPseudoMeasurements(spectrometerTrack) - || (m_magFieldSvc->toroidOn() + || (fieldCache.toroidOn() && (badlyDeterminedCurvature || errorPhi > m_largePhiError || measuredPerigee->momentum().mag() < m_lowMomentum))) { @@ -1383,7 +1417,7 @@ CombinedMuonTrackBuilder::standaloneFit(const Trk::Track& inputSpectrometerTrack particleHypothesis = Trk::muon; bool returnAfterCleaner = false; - if (!m_magFieldSvc->toroidOn()) returnAfterCleaner = true; + if (!fieldCache.toroidOn()) returnAfterCleaner = true; ATH_MSG_VERBOSE("Calling createExtrapolatedTrack from " << __func__ << " at line " << __LINE__); Trk::Track* extrapolated = @@ -1672,7 +1706,19 @@ CombinedMuonTrackBuilder::standaloneRefit(const Trk::Track& combinedTrack, float countAEOTs(&combinedTrack, " in standalone Refit input combinedTrack "); - if (!m_magFieldSvc->toroidOn()) { + MagField::AtlasFieldCache fieldCache; + // Get field cache object + EventContext ctx = Gaudi::Hive::currentContext(); + SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + + if (fieldCondObj == nullptr) { + ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); + return 0; + } + fieldCondObj->getInitializedCache (fieldCache); + + if (!fieldCache.toroidOn()) { // no standalone refit for Toroid off return nullptr; } @@ -2218,7 +2264,19 @@ CombinedMuonTrackBuilder::fit(const Trk::Track& track, const Trk::RunOutlierRemo bool isCombined = m_trackQuery->isCombined(track); // select straightLine fitter when magnets downstream of leading measurement are off ToolHandle<Trk::ITrackFitter> fitter = m_fitter; - if (!m_magFieldSvc->toroidOn() && !(isCombined && m_magFieldSvc->solenoidOn())) { + MagField::AtlasFieldCache fieldCache; + // Get field cache object + EventContext ctx = Gaudi::Hive::currentContext(); + SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + + if (fieldCondObj == nullptr) { + ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); + return 0; + } + fieldCondObj->getInitializedCache (fieldCache); + + if (!fieldCache.toroidOn() && !(isCombined && fieldCache.solenoidOn())) { fitter = m_fitterSL; ATH_MSG_VERBOSE(" fit (track refit method): select SL fitter "); @@ -2401,8 +2459,20 @@ CombinedMuonTrackBuilder::fit(const Trk::MeasurementSet& measurementSet, const T } // select straightLine fitter when magnets downstream of leading measurement are off + MagField::AtlasFieldCache fieldCache; + // Get field cache object + EventContext ctx = Gaudi::Hive::currentContext(); + SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + + if (fieldCondObj == nullptr) { + ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); + return 0; + } + fieldCondObj->getInitializedCache (fieldCache); + ToolHandle<Trk::ITrackFitter> fitter = m_fitter; - if (!m_magFieldSvc->toroidOn() || std::abs(perigeeStartValue.position().z()) > m_zECToroid) { + if (!fieldCache.toroidOn() || std::abs(perigeeStartValue.position().z()) > m_zECToroid) { fitter = m_fitterSL; ATH_MSG_VERBOSE(" fit (track refit method): select SL fitter "); @@ -2523,7 +2593,19 @@ CombinedMuonTrackBuilder::fit(const Trk::Track& indetTrack, const Trk::Track& ex // select straightLine fitter when solenoid and toroid are off ToolHandle<Trk::ITrackFitter> fitter = m_fitter; - if (!m_magFieldSvc->toroidOn() && !m_magFieldSvc->solenoidOn()) { + MagField::AtlasFieldCache fieldCache; + // Get field cache object + EventContext ctx = Gaudi::Hive::currentContext(); + SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + + if (fieldCondObj == nullptr) { + ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); + return 0; + } + fieldCondObj->getInitializedCache (fieldCache); + + if (!fieldCache.toroidOn() && !fieldCache.solenoidOn()) { fitter = m_fitterSL; ATH_MSG_VERBOSE(" fit (combined muon fit method): select SL fitter "); @@ -3163,7 +3245,19 @@ CombinedMuonTrackBuilder::createExtrapolatedTrack(const Trk::Track& sp // if association OK, create perigee surface and back-track to it if (caloAssociated) { - if (m_magFieldSvc->toroidOn()) { + MagField::AtlasFieldCache fieldCache; + // Get field cache object + EventContext ctx = Gaudi::Hive::currentContext(); + SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + + if (fieldCondObj == nullptr) { + ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); + return 0; + } + fieldCondObj->getInitializedCache (fieldCache); + + if (fieldCache.toroidOn()) { const Trk::TrackParameters* oldParameters = caloTSOS->front()->trackParameters(); if (oldParameters && !oldParameters->covariance()) { @@ -3908,7 +4002,18 @@ CombinedMuonTrackBuilder::extrapolatedParameters(bool& badlyDeterminedCurvature, bool curvatureOK = false; ToolHandle<Trk::IPropagator> propagator = m_propagator; - if (!m_magFieldSvc->toroidOn()) { + MagField::AtlasFieldCache fieldCache; + // Get field cache object + EventContext ctx = Gaudi::Hive::currentContext(); + SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + + if (fieldCondObj == nullptr) { + ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); + return 0; + } + fieldCondObj->getInitializedCache (fieldCache); + if (!fieldCache.toroidOn()) { curvatureOK = true; propagator = m_propagatorSL; } else if (std::abs(parameters->position().z()) < m_zECToroid @@ -3995,7 +4100,7 @@ CombinedMuonTrackBuilder::extrapolatedParameters(bool& badlyDeterminedCurvature, } // large impact: set phi to be projective (note iteration) - if (std::abs(perigee->parameters()[Trk::d0]) < m_largeImpact || !m_magFieldSvc->toroidOn()) { + if (std::abs(perigee->parameters()[Trk::d0]) < m_largeImpact || !fieldCache.toroidOn()) { if (correctedParameters == parameters) { ATH_MSG_WARNING( "deleting parameters pointer that could be used further down in execution, setting it to zero!"); diff --git a/Reconstruction/MuonIdentification/MuonCombinedBaseTools/CMakeLists.txt b/Reconstruction/MuonIdentification/MuonCombinedBaseTools/CMakeLists.txt index b71f6720cf84f3f3ac056e5562130719f5b29347..3a3cae1250c7602c01bdc55c999171376f2964ed 100644 --- a/Reconstruction/MuonIdentification/MuonCombinedBaseTools/CMakeLists.txt +++ b/Reconstruction/MuonIdentification/MuonCombinedBaseTools/CMakeLists.txt @@ -23,7 +23,6 @@ atlas_depends_on_subdirs( PUBLIC Event/xAOD/xAODTracking Event/xAOD/xAODTruth GaudiKernel - MagneticField/MagFieldInterfaces MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry MuonSpectrometer/MuonIdHelpers MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonCompetingRIOsOnTrack @@ -56,7 +55,10 @@ atlas_depends_on_subdirs( PUBLIC Tracking/TrkEvent/TrkTrackSummary Tracking/TrkExtrapolation/TrkExInterfaces Tracking/TrkTools/TrkToolInterfaces - Generators/AtlasHepMC ) + Generators/AtlasHepMC + MagneticField/MagFieldElements + MagneticField/MagFieldConditions + ) # External dependencies: find_package( CLHEP ) @@ -67,5 +69,5 @@ atlas_add_component( MuonCombinedBaseTools src/*.cxx src/components/*.cxx INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} AtlasHepMCLib CaloEvent AthLinks AthenaBaseComps Identifier EventPrimitives FourMomUtils xAODCaloEvent xAODEventInfo xAODMuon xAODTracking xAODTruth GaudiKernel MagFieldInterfaces MuonReadoutGeometry MuonIdHelpersLib MuonCompetingRIOsOnTrack MuonRIO_OnTrack MuonSegment MuonRecHelperToolsLib MuonRecToolInterfaces MuonSegmentMakerUtils MuonSelectorToolsLib ICaloTrkMuIdTools MuidInterfaces MuonCombinedEvent MuonCombinedToolInterfaces muonEvent MuidEvent ParticleTruth RecoToolInterfaces TrackToCaloLib TrkGeometry TrkSurfaces TrkCaloExtension TrkEventPrimitives TrkEventUtils TrkMaterialOnTrack TrkParameters TrkParametersIdentificationHelpers TrkSegment TrkTrack TrkTrackSummary TrkExInterfaces TrkToolInterfaces BeamSpotConditionsData ) + LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} AtlasHepMCLib CaloEvent AthLinks AthenaBaseComps Identifier EventPrimitives FourMomUtils xAODCaloEvent xAODEventInfo xAODMuon xAODTracking xAODTruth GaudiKernel MuonReadoutGeometry MuonIdHelpersLib MuonCompetingRIOsOnTrack MuonRIO_OnTrack MuonSegment MuonRecHelperToolsLib MuonRecToolInterfaces MuonSegmentMakerUtils MuonSelectorToolsLib ICaloTrkMuIdTools MuidInterfaces MuonCombinedEvent MuonCombinedToolInterfaces muonEvent MuidEvent ParticleTruth RecoToolInterfaces TrackToCaloLib TrkGeometry TrkSurfaces TrkCaloExtension TrkEventPrimitives TrkEventUtils TrkMaterialOnTrack TrkParameters TrkParametersIdentificationHelpers TrkSegment TrkTrack TrkTrackSummary TrkExInterfaces TrkToolInterfaces BeamSpotConditionsData MagFieldElements MagFieldConditions ) diff --git a/Reconstruction/MuonIdentification/MuonCombinedBaseTools/src/MuonCombinedFitTagTool.cxx b/Reconstruction/MuonIdentification/MuonCombinedBaseTools/src/MuonCombinedFitTagTool.cxx index 5480cc257ec02433908096222220becc934a2d49..89c8a5734b9ba51b41b226c6bf8e17979f06578c 100644 --- a/Reconstruction/MuonIdentification/MuonCombinedBaseTools/src/MuonCombinedFitTagTool.cxx +++ b/Reconstruction/MuonIdentification/MuonCombinedBaseTools/src/MuonCombinedFitTagTool.cxx @@ -39,7 +39,6 @@ #include "Identifier/Identifier.h" #include "TrkEventUtils/IdentifierExtractor.h" #include "TrkMaterialOnTrack/ScatteringAngles.h" -#include "MagFieldInterfaces/IMagFieldSvc.h" #include "xAODTracking/Vertex.h" namespace MuonCombined { @@ -57,7 +56,6 @@ namespace MuonCombined { m_muonRecovery(""), m_matchQuality("Rec::MuonMatchQuality/MuonMatchQuality", this), m_trackScoringTool("Muon::MuonTrackScoringTool/MuonTrackScoringTool"), - m_magFieldSvc("AtlasFieldSvc",name), m_DetID(0) { declareInterface<IMuonCombinedTagTool>(this); @@ -74,7 +72,6 @@ namespace MuonCombined { declareProperty("MomentumBalanceCut", m_momentumBalanceCut = 6.0); declareProperty("IndetPullCut", m_indetPullCut = 6.0); declareProperty("MatchChiSquaredCut", m_matchChiSquaredCut = 30.0); - declareProperty("MagFieldSvc", m_magFieldSvc); } MuonCombinedFitTagTool::~MuonCombinedFitTagTool() @@ -94,7 +91,8 @@ namespace MuonCombined { if(! m_muonRecovery.empty() ) ATH_CHECK(m_muonRecovery.retrieve()); ATH_CHECK(m_matchQuality.retrieve()); ATH_CHECK(m_trackScoringTool.retrieve()); - ATH_CHECK(m_magFieldSvc.retrieve()); + /// handle to the magnetic field cache + ATH_CHECK( m_fieldCacheCondObjInputKey.initialize() ); if (detStore()->retrieve(m_DetID, "AtlasID").isFailure()) { ATH_MSG_ERROR ("Could not get AtlasDetectorID helper" ); @@ -314,7 +312,7 @@ namespace MuonCombined { } delete combinedTrack; - return 0; + return nullptr; } @@ -385,7 +383,18 @@ namespace MuonCombined { bool dorefit = true; // no SA refit for Toroid off - if (!m_magFieldSvc->toroidOn()) dorefit = false; + MagField::AtlasFieldCache fieldCache; + // Get field cache object + EventContext ctx = Gaudi::Hive::currentContext(); + SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + + if (fieldCondObj == nullptr) { + ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); + return nullptr; + } + fieldCondObj->getInitializedCache (fieldCache); + if (!fieldCache.toroidOn()) dorefit = false; float bs_x = 0.; float bs_y = 0.; diff --git a/Reconstruction/MuonIdentification/MuonCombinedBaseTools/src/MuonCombinedFitTagTool.h b/Reconstruction/MuonIdentification/MuonCombinedBaseTools/src/MuonCombinedFitTagTool.h index b0c05ec4e0eb46414274d59d23715f6532cd1cd3..d299d68f194922f22763ce5f32fe4f085e9849e8 100644 --- a/Reconstruction/MuonIdentification/MuonCombinedBaseTools/src/MuonCombinedFitTagTool.h +++ b/Reconstruction/MuonIdentification/MuonCombinedBaseTools/src/MuonCombinedFitTagTool.h @@ -15,6 +15,8 @@ #include "TrkParameters/TrackParameters.h" #include "TrkSegment/SegmentCollection.h" #include "xAODTracking/VertexContainer.h" +// For magneticfield +#include "MagFieldConditions/AtlasFieldCacheCondObj.h" #include <vector> //<<<<<< CLASS DECLARATIONS >>>>>> @@ -36,10 +38,6 @@ namespace Muon class MuonEDMPrinterTool; } -namespace MagField { - class IMagFieldSvc; -} - namespace MuonCombined { class InDetCandidate; class MuonCandidate; @@ -94,7 +92,8 @@ namespace MuonCombined { ToolHandle<Rec::IMuidMuonRecovery> m_muonRecovery; ToolHandle<Rec::IMuonMatchQuality> m_matchQuality; ToolHandle<Trk::ITrackScoringTool> m_trackScoringTool; - ServiceHandle<MagField::IMagFieldSvc> m_magFieldSvc; + // Read handle for conditions object to get the field cache + SG::ReadCondHandleKey<AtlasFieldCacheCondObj> m_fieldCacheCondObjInputKey {this, "AtlasFieldCacheCondObj", "fieldCondObj", "Name of the Magnetic Field conditions object key"}; const AtlasDetectorID *m_DetID; SG::ReadHandleKey<xAOD::VertexContainer> m_vertexKey { this, "VertexContainer", "PrimaryVertices", "primary vertex container" }; diff --git a/Tracking/TrkExtrapolation/TrkExAlgs/TrkExAlgs/ExtrapolatorTest.h b/Tracking/TrkExtrapolation/TrkExAlgs/TrkExAlgs/ExtrapolatorTest.h index 1c5346eada7918631a0a59d794105ca921c6b90c..3d2683309a418e4f78dc137b39fb1832df1dc114 100755 --- a/Tracking/TrkExtrapolation/TrkExAlgs/TrkExAlgs/ExtrapolatorTest.h +++ b/Tracking/TrkExtrapolation/TrkExAlgs/TrkExAlgs/ExtrapolatorTest.h @@ -17,7 +17,6 @@ #include "GaudiKernel/ToolHandle.h" #include <string> #include <vector> -#include "MagFieldInterfaces/IMagFieldSvc.h" #include "TrkParameters/TrackParameters.h" namespace Trk @@ -67,8 +66,7 @@ namespace Trk /** The Extrapolator to be retrieved */ ToolHandle<IExtrapolator> m_extrapolator; ToolHandle<IPropagator> m_propagator; - ServiceHandle<MagField::IMagFieldSvc> m_magFieldSvc; //!< helper tool to get the magnetic field - MagneticFieldProperties* m_magFieldProperties; //!< magnetic field properties + MagneticFieldProperties* m_magFieldProperties; //!< magnetic field properties /** Random Number setup */ Rndm::Numbers* m_gaussDist; diff --git a/Tracking/TrkExtrapolation/TrkExAlgs/TrkExAlgs/RiddersAlgorithm.h b/Tracking/TrkExtrapolation/TrkExAlgs/TrkExAlgs/RiddersAlgorithm.h index 6098c4353d50e64ab195a89fd7d8e9857b41a3d1..0f374f1deebd8471d4f7c989e78f6af34a506bcf 100755 --- a/Tracking/TrkExtrapolation/TrkExAlgs/TrkExAlgs/RiddersAlgorithm.h +++ b/Tracking/TrkExtrapolation/TrkExAlgs/TrkExAlgs/RiddersAlgorithm.h @@ -14,7 +14,7 @@ #include "GaudiKernel/ToolHandle.h" #include "GaudiKernel/IRndmGenSvc.h" #include "GaudiKernel/RndmGenerators.h" -#include "MagFieldInterfaces/IMagFieldSvc.h" +#include "GeoPrimitives/GeoPrimitives.h" #include <string> class AtlasDetectorID; @@ -65,7 +65,6 @@ namespace Trk /** member variables for algorithm properties: */ ToolHandle<IPropagator> m_propagator; - ServiceHandle<MagField::IMagFieldSvc> m_magFieldSvc; bool m_useCustomField; bool m_useAlignedSurfaces; double m_fieldValue; diff --git a/Tracking/TrkExtrapolation/TrkExAlgs/src/ExtrapolatorTest.cxx b/Tracking/TrkExtrapolation/TrkExAlgs/src/ExtrapolatorTest.cxx index 4af2d977a619e53e04d30910e827854ea37b651e..3fead037c0706dcd7f4501b3c1506dc6ee5d93d4 100755 --- a/Tracking/TrkExtrapolation/TrkExAlgs/src/ExtrapolatorTest.cxx +++ b/Tracking/TrkExtrapolation/TrkExAlgs/src/ExtrapolatorTest.cxx @@ -14,7 +14,6 @@ #include "TrkSurfaces/DiscSurface.h" #include "TrkEventPrimitives/ParticleHypothesis.h" #include "EventPrimitives/EventPrimitives.h" -#include "MagFieldInterfaces/IMagFieldSvc.h" #include "TrkGeometry/MagneticFieldProperties.h" #include "GaudiKernel/SystemOfUnits.h" // std @@ -27,7 +26,6 @@ Trk::ExtrapolatorTest::ExtrapolatorTest(const std::string& name, ISvcLocator* pS AthAlgorithm(name,pSvcLocator), m_extrapolator("Trk::Extrapolator/AtlasExtrapolator"), m_propagator("Trk::RungeKuttaPropagator/RungeKuttaPropagator"), - m_magFieldSvc("AtlasFieldSvc",name), m_magFieldProperties(0), m_gaussDist(0), m_flatDist(0), @@ -48,7 +46,6 @@ Trk::ExtrapolatorTest::ExtrapolatorTest(const std::string& name, ISvcLocator* pS // used algorithms and alg tools declareProperty("Extrapolator", m_extrapolator); declareProperty("Propagator", m_propagator); - declareProperty("MagFieldSvc", m_magFieldSvc ); // algorithm steering declareProperty("StartPerigeeSigmaD0" , m_sigmaD0); @@ -109,10 +106,6 @@ StatusCode Trk::ExtrapolatorTest::initialize() return StatusCode::FAILURE; } - if (m_magFieldSvc.retrieve().isFailure()) { - msg(MSG::FATAL) << "Could not retrieve Tool " << m_magFieldSvc << ". Exiting."<<endmsg; - return StatusCode::FAILURE; - } m_magFieldProperties = new Trk::MagneticFieldProperties(); if (m_referenceSurfaceRadius.size() == m_referenceSurfaceHalflength.size()) { diff --git a/Tracking/TrkExtrapolation/TrkExAlgs/src/RiddersAlgorithm.cxx b/Tracking/TrkExtrapolation/TrkExAlgs/src/RiddersAlgorithm.cxx index be538cca3bd93c150dda2cd6b41e7abe5477e420..d72940c3b7d77558633a897d114aead4e7a57ef6 100755 --- a/Tracking/TrkExtrapolation/TrkExAlgs/src/RiddersAlgorithm.cxx +++ b/Tracking/TrkExtrapolation/TrkExAlgs/src/RiddersAlgorithm.cxx @@ -10,7 +10,6 @@ // Trk stuff #include "TrkExInterfaces/IPropagator.h" #include "TrkExUtils/TransportJacobian.h" -#include "MagFieldInterfaces/IMagFieldSvc.h" #include "TrkGeometry/MagneticFieldProperties.h" #include "TrkSurfaces/PlaneSurface.h" #include "TrkSurfaces/CylinderSurface.h" @@ -27,7 +26,6 @@ Trk::RiddersAlgorithm::RiddersAlgorithm(const std::string& name, ISvcLocator* pS : AthAlgorithm(name,pSvcLocator), m_propagator("Trk::RungeKuttaPropagator/RungeKuttaPropagator"), - m_magFieldSvc("AtlasFieldSvc",name), m_useCustomField(true), m_useAlignedSurfaces(true), m_fieldValue(2.*Gaudi::Units::tesla), @@ -91,7 +89,6 @@ Trk::RiddersAlgorithm::RiddersAlgorithm(const std::string& name, ISvcLocator* pS declareProperty("Propagator" , m_propagator); - declareProperty("MagFieldSvc" , m_magFieldSvc); declareProperty("CustomFieldValue" , m_fieldValue); declareProperty("UseCustomMagneticField" , m_useCustomField); declareProperty("UseAlignedSurfaces" , m_useAlignedSurfaces); @@ -143,12 +140,6 @@ StatusCode Trk::RiddersAlgorithm::initialize() return StatusCode::FAILURE; } - // Get the Magnetic Field Tool if needed - if (!m_useCustomField && m_magFieldSvc.retrieve().isFailure()) { - ATH_MSG_FATAL( "Could not retrieve Tool " << m_magFieldSvc << ". Exiting." ); - return StatusCode::FAILURE; - } - // Prepare the magnetic field properties if (!m_useCustomField) m_magFieldProperties = new Trk::MagneticFieldProperties(); diff --git a/Tracking/TrkExtrapolation/TrkExSTEP_Propagator/CMakeLists.txt b/Tracking/TrkExtrapolation/TrkExSTEP_Propagator/CMakeLists.txt index ec07ecae87684e398b8b9a85f44e8279172a4190..8f582373da5c1c8806071f59db4b79be7e596bb2 100644 --- a/Tracking/TrkExtrapolation/TrkExSTEP_Propagator/CMakeLists.txt +++ b/Tracking/TrkExtrapolation/TrkExSTEP_Propagator/CMakeLists.txt @@ -35,7 +35,7 @@ atlas_add_component( TrkExSTEP_Propagator src/*.cxx src/components/*.cxx INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS} - LINK_LIBRARIES ${CLHEP_LIBRARIES} ${EIGEN_LIBRARIES} AthenaBaseComps AthenaKernel GeoPrimitives EventPrimitives MagFieldInterfaces TrkGeometry TrkEventPrimitives TrkMaterialOnTrack TrkParameters TrkExInterfaces TrkExUtils GaudiKernel TrkDetDescrUtils TrkSurfaces TrkTrack MagFieldElements MagFieldConditions ) + LINK_LIBRARIES ${CLHEP_LIBRARIES} ${EIGEN_LIBRARIES} AthenaBaseComps AthenaKernel GeoPrimitives EventPrimitives TrkGeometry TrkEventPrimitives TrkMaterialOnTrack TrkParameters TrkExInterfaces TrkExUtils GaudiKernel TrkDetDescrUtils TrkSurfaces TrkTrack MagFieldElements MagFieldConditions ) # Install files from the package: atlas_install_headers( TrkExSTEP_Propagator ) diff --git a/Tracking/TrkTools/TrkMaterialProvider/CMakeLists.txt b/Tracking/TrkTools/TrkMaterialProvider/CMakeLists.txt index e322885cd6baa538a9dbe120edcf7ac0016d3651..922d47f5cf90b0e757bf5d2c30b8ac848d877096 100644 --- a/Tracking/TrkTools/TrkMaterialProvider/CMakeLists.txt +++ b/Tracking/TrkTools/TrkMaterialProvider/CMakeLists.txt @@ -20,13 +20,15 @@ atlas_depends_on_subdirs( PUBLIC DetectorDescription/Identifier Event/EventPrimitives GaudiKernel - MagneticField/MagFieldInterfaces Reconstruction/MuonIdentification/MuidEvent Reconstruction/MuonIdentification/MuidInterfaces Reconstruction/MuonIdentification/muonEvent Reconstruction/RecoTools/RecoToolInterfaces Tracking/TrkEvent/TrkEventUtils - Tracking/TrkEvent/TrkMaterialOnTrack ) + Tracking/TrkEvent/TrkMaterialOnTrack + MagneticField/MagFieldElements + MagneticField/MagFieldConditions + ) # External dependencies: find_package( CLHEP ) @@ -36,7 +38,7 @@ atlas_add_component( TrkMaterialProvider src/TrkMaterialProviderTool.cxx src/components/*.cxx INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} - LINK_LIBRARIES ${CLHEP_LIBRARIES} AthenaBaseComps TrkDetDescrInterfaces TrkGeometry TrkSurfaces TrkParameters TrkTrack TrkExInterfaces TrkToolInterfaces AtlasDetDescr Identifier EventPrimitives GaudiKernel MagFieldInterfaces MuidEvent MuidInterfaces muonEvent RecoToolInterfaces TrkEventUtils TrkMaterialOnTrack ) + LINK_LIBRARIES ${CLHEP_LIBRARIES} AthenaBaseComps TrkDetDescrInterfaces TrkGeometry TrkSurfaces TrkParameters TrkTrack TrkExInterfaces TrkToolInterfaces AtlasDetDescr Identifier EventPrimitives GaudiKernel MuidEvent MuidInterfaces muonEvent RecoToolInterfaces TrkEventUtils TrkMaterialOnTrack MagFieldElements MagFieldConditions ) # Install files from the package: atlas_install_headers( TrkMaterialProvider ) diff --git a/Tracking/TrkTools/TrkMaterialProvider/TrkMaterialProvider/TrkMaterialProviderTool.h b/Tracking/TrkTools/TrkMaterialProvider/TrkMaterialProvider/TrkMaterialProviderTool.h index 3d504d695acb562d6314273ab74895d6d5911efe..636a4cc0938fdab44c4ae1aa3e208a5bc3fa0f11 100644 --- a/Tracking/TrkTools/TrkMaterialProvider/TrkMaterialProvider/TrkMaterialProviderTool.h +++ b/Tracking/TrkTools/TrkMaterialProvider/TrkMaterialProvider/TrkMaterialProviderTool.h @@ -29,13 +29,11 @@ #include "TrkExInterfaces/IMultipleScatteringUpdator.h" #include "TrkGeometry/TrackingVolume.h" #include "TrkGeometry/MagneticFieldProperties.h" +// For magneticfield +#include "MagFieldConditions/AtlasFieldCacheCondObj.h" #include "RecoToolInterfaces/IMuonCaloEnergyTool.h" -namespace MagField { - class IMagFieldSvc; -} - namespace Trk { class Surface; } @@ -194,7 +192,9 @@ namespace Trk{ const Trk::Volume* m_calorimeterVolume; const Trk::Volume* m_indetVolume; - ServiceHandle<MagField::IMagFieldSvc> m_magFieldSvc; + // Read handle for conditions object to get the field cache + SG::ReadCondHandleKey<AtlasFieldCacheCondObj> m_fieldCacheCondObjInputKey {this, "AtlasFieldCacheCondObj", "fieldCondObj", + "Name of the Magnetic Field conditions object key"}; bool m_applyTGScaling; bool m_repositionTSOS; diff --git a/Tracking/TrkTools/TrkMaterialProvider/src/TrkMaterialProviderTool.cxx b/Tracking/TrkTools/TrkMaterialProvider/src/TrkMaterialProviderTool.cxx index b66cb97b6bdb359bd779470dab76bee7d6f62e7a..0c04dd1d630937ac01bc6d3b62e15dc5ad41ada3 100644 --- a/Tracking/TrkTools/TrkMaterialProvider/src/TrkMaterialProviderTool.cxx +++ b/Tracking/TrkTools/TrkMaterialProvider/src/TrkMaterialProviderTool.cxx @@ -15,7 +15,6 @@ #include "AtlasDetDescr/AtlasDetectorID.h" #include "Identifier/Identifier.h" #include "TrkEventUtils/IdentifierExtractor.h" -#include "MagFieldInterfaces/IMagFieldSvc.h" #include "muonEvent/CaloEnergy.h" @@ -50,7 +49,6 @@ Trk::TrkMaterialProviderTool::TrkMaterialProviderTool(const std::string& t, cons m_DetID(nullptr), m_calorimeterVolume(nullptr), m_indetVolume(nullptr), - m_magFieldSvc ("AtlasFieldSvc",n), m_maxNTracksIso(2), m_paramPtCut(15.0*Gaudi::Units::GeV), m_useCaloEnergyMeasurement(true), @@ -68,7 +66,6 @@ Trk::TrkMaterialProviderTool::TrkMaterialProviderTool(const std::string& t, cons declareProperty("CaloMeasTool", m_caloMeasTool); declareProperty("CaloParamTool", m_caloParamTool); declareProperty("TrackIsolationTool", m_trackIsolationTool); - declareProperty("MagFieldSvc", m_magFieldSvc); declareProperty("MaxNTracksIso", m_maxNTracksIso); declareProperty("ParamPtCut", m_paramPtCut); declareProperty("UseCaloEnergyMeasurement", m_useCaloEnergyMeasurement); @@ -110,7 +107,8 @@ Trk::TrkMaterialProviderTool::initialize() m_trackIsolationTool.disable(); } - ATH_CHECK(m_magFieldSvc.retrieve()); + /// handle to the magnetic field cache + ATH_CHECK( m_fieldCacheCondObjInputKey.initialize() ); // need an Atlas id-helper to identify sub-detectors, take the one from detStore if (detStore()->retrieve(m_DetID, "AtlasID").isFailure()) { @@ -475,13 +473,26 @@ void Trk::TrkMaterialProviderTool::getCaloMEOT(const Trk::Track& idTrack, const ATH_MSG_WARNING("Unable to find first MS TSOS with Track Parameters!"); #endif + MagField::AtlasFieldCache fieldCache; + // Get field cache object + EventContext ctx = Gaudi::Hive::currentContext(); + SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx}; + const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; + + if (fieldCondObj == nullptr) { + ATH_MSG_ERROR("SCTSiLorentzAngleCondAlg : Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key()); + return; + } + fieldCondObj->getInitializedCache (fieldCache); + + double Eloss = 0.; double X0ScaleMS = 0.; double ElossScaleMS = 0.; // get calorimeter TSOS from TG DataVector<const Trk::TrackStateOnSurface>* caloTSOS = this->getCaloTSOS (*(*lastIDwP)->trackParameters(), // idTrack, - m_magFieldSvc->toroidOn() ? msTrack : idTrack, + fieldCache.toroidOn() ? msTrack : idTrack, (*firstMSnotPerigee)->surface(), Trk::alongMomentum, Trk::muon, @@ -491,10 +502,10 @@ void Trk::TrkMaterialProviderTool::getCaloMEOT(const Trk::Track& idTrack, const true); if(!caloTSOS || caloTSOS->size()!=3) { - if((!m_magFieldSvc->toroidOn()&&fabs(idTrack.perigeeParameters()->parameters()[Trk::qOverP])*4000.<1)|| (m_magFieldSvc->toroidOn()&&msTrack.perigeeParameters()->parameters()[Trk::qOverP]!=1/100000.&&msTrack.perigeeParameters()->parameters()[Trk::qOverP]!=0)) { + if((!fieldCache.toroidOn()&&fabs(idTrack.perigeeParameters()->parameters()[Trk::qOverP])*4000.<1)|| (fieldCache.toroidOn()&&msTrack.perigeeParameters()->parameters()[Trk::qOverP]!=1/100000.&&msTrack.perigeeParameters()->parameters()[Trk::qOverP]!=0)) { // Warnings only for high momentum ID tracks and MS tracks that have measured curvature (Straight track has pq= 100000) - if(!m_magFieldSvc->toroidOn()) ATH_MSG_WARNING(" Toroid off q*momentum of ID track " << 1./idTrack.perigeeParameters()->parameters()[Trk::qOverP]); - if(m_magFieldSvc->toroidOn()) ATH_MSG_WARNING(" Toroid on q*momentum of MS track " << 1./msTrack.perigeeParameters()->parameters()[Trk::qOverP]); + if(!fieldCache.toroidOn()) ATH_MSG_WARNING(" Toroid off q*momentum of ID track " << 1./idTrack.perigeeParameters()->parameters()[Trk::qOverP]); + if(fieldCache.toroidOn()) ATH_MSG_WARNING(" Toroid on q*momentum of MS track " << 1./msTrack.perigeeParameters()->parameters()[Trk::qOverP]); ATH_MSG_WARNING("Unable to retrieve Calorimeter TSOS from extrapolateM+aggregation (null or !=3)"); if(!caloTSOS) { ATH_MSG_WARNING(" Zero Calorimeter TSOS from extrapolateM+aggregation");