diff --git a/InnerDetector/InDetEventCnv/InDetJiveXML/CMakeLists.txt b/InnerDetector/InDetEventCnv/InDetJiveXML/CMakeLists.txt index 33d992044e8f64c8d888d5ccc48151f208f882ea..40b5343013900a8f944d8b8ec0ddcd55f38c7491 100644 --- a/InnerDetector/InDetEventCnv/InDetJiveXML/CMakeLists.txt +++ b/InnerDetector/InDetEventCnv/InDetJiveXML/CMakeLists.txt @@ -11,7 +11,7 @@ atlas_add_component( InDetJiveXML src/*.cxx src/components/*.cxx INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} - LINK_LIBRARIES ${CLHEP_LIBRARIES} AthenaBaseComps StoreGateLib GaudiKernel InDetRawData TrkSpacePoint TrkTruthData JiveXMLLib AthContainers IdDictDetDescr InDetIdentifier ReadoutGeometryBase InDetReadoutGeometry TRT_ReadoutGeometry InDetPrepRawData TrkEventPrimitives TrkPrepRawData InDetBeamSpotServiceLib InDetCondTools ) + LINK_LIBRARIES ${CLHEP_LIBRARIES} AthenaBaseComps StoreGateLib GaudiKernel InDetRawData TrkSpacePoint TrkTruthData JiveXMLLib AthContainers IdDictDetDescr InDetIdentifier ReadoutGeometryBase InDetReadoutGeometry TRT_ReadoutGeometry InDetPrepRawData TrkEventPrimitives TrkPrepRawData BeamSpotConditionsData InDetCondTools ) # Install files from the package: atlas_install_joboptions( share/*.py ) diff --git a/InnerDetector/InDetEventCnv/InDetJiveXML/InDetJiveXML/BeamSpotRetriever.h b/InnerDetector/InDetEventCnv/InDetJiveXML/InDetJiveXML/BeamSpotRetriever.h index 96bb9de9351c9433358611ac24fe2ef71e28ea5a..5b073753ac15701ca2a0f117a712221165cf2faf 100755 --- a/InnerDetector/InDetEventCnv/InDetJiveXML/InDetJiveXML/BeamSpotRetriever.h +++ b/InnerDetector/InDetEventCnv/InDetJiveXML/InDetJiveXML/BeamSpotRetriever.h @@ -7,8 +7,8 @@ #include "JiveXML/IDataRetriever.h" #include "AthenaBaseComps/AthAlgTool.h" -#include "GaudiKernel/ServiceHandle.h" -#include "InDetBeamSpotService/IBeamCondSvc.h" +#include "BeamSpotConditionsData/BeamSpotData.h" + namespace JiveXML { @@ -25,6 +25,8 @@ namespace JiveXML { public: + virtual StatusCode initialize() override; + /// Standard constructor BeamSpotRetriever(const std::string& type,const std::string& name,const IInterface* parent); @@ -39,8 +41,7 @@ namespace JiveXML { ///The data type that is generated by this retriever const std::string m_typeName; - /// A service handle for the beamspot service - ServiceHandle<IBeamCondSvc> m_beamSpotSvc; + SG::ReadCondHandleKey<InDet::BeamSpotData> m_beamSpotKey { this, "BeamSpotKey", "BeamSpotData", "SG key for beam spot" }; }; } diff --git a/InnerDetector/InDetEventCnv/InDetJiveXML/src/BeamSpotRetriever.cxx b/InnerDetector/InDetEventCnv/InDetJiveXML/src/BeamSpotRetriever.cxx index 50dd4142a700ac2f13a528688763731295fc1cd0..8e8cb25a3653ec831e7f03978fa82545c4c1b143 100755 --- a/InnerDetector/InDetEventCnv/InDetJiveXML/src/BeamSpotRetriever.cxx +++ b/InnerDetector/InDetEventCnv/InDetJiveXML/src/BeamSpotRetriever.cxx @@ -4,8 +4,6 @@ #include "InDetJiveXML/BeamSpotRetriever.h" -#include "InDetBeamSpotService/IBeamCondSvc.h" // the actual include, add this at the top - #include "JiveXML/IFormatTool.h" namespace JiveXML { @@ -17,12 +15,17 @@ namespace JiveXML { * @param parent AlgTools parent owning this tool **/ BeamSpotRetriever::BeamSpotRetriever(const std::string& type,const std::string& name,const IInterface* parent): - AthAlgTool(type,name,parent), m_typeName("BeamSpot"), m_beamSpotSvc("BeamCondSvc",name){ + AthAlgTool(type,name,parent), m_typeName("BeamSpot") { //Declare the interface declareInterface<IDataRetriever>(this); } + StatusCode BeamSpotRetriever::initialize() { + ATH_CHECK(m_beamSpotKey.initialize()); + return StatusCode::SUCCESS; + } + /** * Implementation of DataRetriever interface * - for each pixel raw data object obtain the identifier @@ -48,10 +51,10 @@ namespace JiveXML { DataVect status; status.reserve( 1 ); /// from: https://twiki.cern.ch/twiki/bin/view/Atlas/InDetBeamSpotFAQ#How_can_I_retrieve_the_beam_spot - + SG::ReadCondHandle<InDet::BeamSpotData> beamSpotHandle { m_beamSpotKey }; // add the following into the initialize routine. - if ( m_beamSpotSvc.retrieve().isFailure() ) { - if (msgLvl(MSG::ERROR)) msg(MSG::ERROR) << "Failed to retrieve service " << m_beamSpotSvc << endmsg; + if ( !beamSpotHandle.isValid() ) { + if (msgLvl(MSG::ERROR)) msg(MSG::ERROR) << "Failed to retrieve beamspot " << endmsg; return StatusCode::RECOVERABLE; } else { @@ -72,38 +75,38 @@ namespace JiveXML { // tiltX Tilt angle in x-z plane (rad) // tiltY Tilt angle in y-z plane (rad) - if (msgLvl(MSG::INFO)) msg(MSG::INFO) << "Retrieved service " << m_beamSpotSvc << endmsg; + label.push_back( "Beamspot_position_at_PV_z_position" ); - Trk::RecVertex beamposition(m_beamSpotSvc->beamVtx()); + Trk::RecVertex beamposition(beamSpotHandle->beamVtx()); Amg::Vector3D posBS(beamposition.position()); x.push_back( posBS.x() ); y.push_back( posBS.y() ); z.push_back( posBS.z() ); - sigmaX.push_back( m_beamSpotSvc->beamSigma(0) ); - sigmaY.push_back( m_beamSpotSvc->beamSigma(1) ); - sigmaZ.push_back( m_beamSpotSvc->beamSigma(2) ); - sigmaXY.push_back( m_beamSpotSvc->beamSigmaXY() ); + sigmaX.push_back( beamSpotHandle->beamSigma(0) ); + sigmaY.push_back( beamSpotHandle->beamSigma(1) ); + sigmaZ.push_back( beamSpotHandle->beamSigma(2) ); + sigmaXY.push_back( beamSpotHandle->beamSigmaXY() ); - tiltX.push_back( m_beamSpotSvc->beamTilt(0) ); - tiltY.push_back( m_beamSpotSvc->beamTilt(1) ); + tiltX.push_back( beamSpotHandle->beamTilt(0) ); + tiltY.push_back( beamSpotHandle->beamTilt(1) ); - status.push_back( m_beamSpotSvc->beamStatus() ); + status.push_back( beamSpotHandle->beamStatus() ); if (msgLvl(MSG::DEBUG)) { msg(MSG::DEBUG) << "BeamSpot Position: " - << m_beamSpotSvc->beamPos() << endmsg; + << beamSpotHandle->beamPos() << endmsg; msg(MSG::DEBUG) << "BeamSpot Sigma " - << m_beamSpotSvc->beamSigma(0) << ", " - << m_beamSpotSvc->beamSigma(1) << ", " - << m_beamSpotSvc->beamSigma(2) + << beamSpotHandle->beamSigma(0) << ", " + << beamSpotHandle->beamSigma(1) << ", " + << beamSpotHandle->beamSigma(2) << endmsg; msg(MSG::DEBUG) << "BeamSpot Tilt: " - << m_beamSpotSvc->beamTilt(0) << ", " - << m_beamSpotSvc->beamTilt(1) + << beamSpotHandle->beamTilt(0) << ", " + << beamSpotHandle->beamTilt(1) << endmsg; msg(MSG::DEBUG) << "Beamspot position at PV z-position" << endmsg; } diff --git a/InnerDetector/InDetMonitoring/InDetPerformanceMonitoring/CMakeLists.txt b/InnerDetector/InDetMonitoring/InDetPerformanceMonitoring/CMakeLists.txt index c6a91ac07fdd8f8d5330e0c19b0bf97b189959d3..e788cd3c8bc2158c9cd42c71c2cb96f78276c783 100644 --- a/InnerDetector/InDetMonitoring/InDetPerformanceMonitoring/CMakeLists.txt +++ b/InnerDetector/InDetMonitoring/InDetPerformanceMonitoring/CMakeLists.txt @@ -12,7 +12,7 @@ atlas_add_component( InDetPerformanceMonitoring src/*.cxx src/components/*.cxx INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${CLHEP_LIBRARIES} ${ROOT_LIBRARIES} AthenaBaseComps AthenaMonitoringLib AtlasHepMCLib CxxUtils ElectronPhotonSelectorToolsLib EventPrimitives GaudiKernel ITrackToVertex IdDictDetDescr InDetBeamSpotServiceLib InDetIdentifier InDetPrepRawData InDetRIO_OnTrack InDetTrackSelectionToolLib JetInterface LWHists MuonAnalysisInterfacesLib MuonMomentumCorrectionsLib StoreGateLib TRT_ReadoutGeometry TrigDecisionToolLib TrkEventPrimitives TrkExInterfaces TrkParameters TrkParticleBase TrkTrack TrkTrackSummary TrkTruthData TrkV0Vertex TrkVertexAnalysisUtilsLib TrkVertexFitterInterfaces TrackVertexAssociationToolLib egammaEvent egammaInterfacesLib xAODCaloEvent xAODEgamma xAODEventInfo xAODJet xAODMissingET xAODMuon xAODTracking xAODTruth ) + LINK_LIBRARIES ${CLHEP_LIBRARIES} ${ROOT_LIBRARIES} AthenaBaseComps AthenaMonitoringLib AtlasHepMCLib CxxUtils ElectronPhotonSelectorToolsLib EventPrimitives GaudiKernel ITrackToVertex IdDictDetDescr BeamSpotConditionsData InDetIdentifier InDetPrepRawData InDetRIO_OnTrack InDetTrackSelectionToolLib JetInterface LWHists MuonAnalysisInterfacesLib MuonMomentumCorrectionsLib StoreGateLib TRT_ReadoutGeometry TrigDecisionToolLib TrkEventPrimitives TrkExInterfaces TrkParameters TrkParticleBase TrkTrack TrkTrackSummary TrkTruthData TrkV0Vertex TrkVertexAnalysisUtilsLib TrkVertexFitterInterfaces TrackVertexAssociationToolLib egammaEvent egammaInterfacesLib xAODCaloEvent xAODEgamma xAODEventInfo xAODJet xAODMissingET xAODMuon xAODTracking xAODTruth ) # Install files from the package: atlas_install_joboptions( share/*.py ) diff --git a/InnerDetector/InDetMonitoring/InDetPerformanceMonitoring/InDetPerformanceMonitoring/IDPerfMonZmumu.h b/InnerDetector/InDetMonitoring/InDetPerformanceMonitoring/InDetPerformanceMonitoring/IDPerfMonZmumu.h index a61ccb9ede36ff51acbb259fd8b0261c0edb7899..4c7fbe61b8cc0cf5495741621a6fecd064d44cd0 100755 --- a/InnerDetector/InDetMonitoring/InDetPerformanceMonitoring/InDetPerformanceMonitoring/IDPerfMonZmumu.h +++ b/InnerDetector/InDetMonitoring/InDetPerformanceMonitoring/InDetPerformanceMonitoring/IDPerfMonZmumu.h @@ -37,6 +37,8 @@ #include "GaudiKernel/ToolHandle.h" #include "GaudiKernel/ServiceHandle.h" #include "TrkExInterfaces/IExtrapolator.h" +#include "BeamSpotConditionsData/BeamSpotData.h" + class IegammaTrkRefitterTool; class IBeamCondSvc; @@ -128,7 +130,7 @@ class IDPerfMonZmumu : public AthAlgorithm ToolHandle< Trk::ITrackToVertexIPEstimator > m_trackToVertexIPEstimator; /** used for truth parameters**/ - ServiceHandle<IBeamCondSvc> m_beamSpotSvc; + SG::ReadCondHandleKey<InDet::BeamSpotData> m_beamSpotKey { this, "BeamSpotKey", "BeamSpotData", "SG key for beam spot" }; ToolHandle<Trk::IExtrapolator> m_extrapolator; /* vertex */ diff --git a/InnerDetector/InDetMonitoring/InDetPerformanceMonitoring/src/IDPerfMonZmumu.cxx b/InnerDetector/InDetMonitoring/InDetPerformanceMonitoring/src/IDPerfMonZmumu.cxx index 95176f2c1cb186713d7b675e58aa04e605d49f04..662c8553fc6385e68a84715efaabe399c66b7f3b 100755 --- a/InnerDetector/InDetMonitoring/InDetPerformanceMonitoring/src/IDPerfMonZmumu.cxx +++ b/InnerDetector/InDetMonitoring/InDetPerformanceMonitoring/src/IDPerfMonZmumu.cxx @@ -31,7 +31,6 @@ /** needed for IP resolution studies **/ #include "TrkVertexFitterInterfaces/ITrackToVertexIPEstimator.h" -#include "InDetBeamSpotService/IBeamCondSvc.h" #include "TrigDecisionTool/TrigDecisionTool.h" #include "TrigDecisionTool/ChainGroup.h" @@ -56,7 +55,6 @@ IDPerfMonZmumu::IDPerfMonZmumu(const std::string& name, m_triggerDecision("Trig::TrigDecisionTool/TrigDecisionTool"), m_selTool( "InDet::InDetTrackSelectionTool/TrackSelectionTool"), m_trackToVertexIPEstimator("Trk::TrackToVertexIPEstimator"), - m_beamSpotSvc("BeamCondSvc",name), m_extrapolator("Trk::Extrapolator/AtlasExtrapolator"), m_validationMode(true), @@ -102,7 +100,6 @@ IDPerfMonZmumu::IDPerfMonZmumu(const std::string& name, declareProperty("isMC", m_isMC = false); declareProperty("doRefit", m_doRefit = false); declareProperty("doIPextrToPV", m_doIP = false); - declareProperty("BeamCondSvc", m_beamSpotSvc); declareProperty("Extrapolator", m_extrapolator ); declareProperty("MassWindowLow", m_MassWindowLow = 60.0, "Lower cut in mu+mu- invariant mass" ); declareProperty("MassWindowHigh", m_MassWindowHigh = 120.0, "Upper cut in mu+mu- invariant mass" ); @@ -218,7 +215,7 @@ StatusCode IDPerfMonZmumu::initialize() ATH_CHECK (m_trackToVertexIPEstimator.retrieve()); } - ATH_CHECK( m_beamSpotSvc.retrieve()); + ATH_CHECK(m_beamSpotKey.initialize()); ATH_CHECK( m_extrapolator.retrieve()); ATH_CHECK (m_vertexKey.initialize()); @@ -1598,7 +1595,8 @@ StatusCode IDPerfMonZmumu::FillTruthParameters(const xAOD::TrackParticle* trackP const Amg::Vector3D position(xPos, yPos, z_truth); const Trk::CurvilinearParameters cParameters(position, momentum, charge); - Trk::PerigeeSurface persf( m_beamSpotSvc->beamPos() ); + SG::ReadCondHandle<InDet::BeamSpotData> beamSpotHandle { m_beamSpotKey }; + Trk::PerigeeSurface persf( beamSpotHandle->beamPos() ); const Trk::TrackParameters* tP = m_extrapolator->extrapolate(cParameters,persf, Trk::anyDirection, false); diff --git a/PhysicsAnalysis/D3PDMaker/TrackD3PDMaker/CMakeLists.txt b/PhysicsAnalysis/D3PDMaker/TrackD3PDMaker/CMakeLists.txt index c83691606fe4c663034612c159e355bfde95a051..deddbc43775bed70ca8d5f517333a855035937f3 100644 --- a/PhysicsAnalysis/D3PDMaker/TrackD3PDMaker/CMakeLists.txt +++ b/PhysicsAnalysis/D3PDMaker/TrackD3PDMaker/CMakeLists.txt @@ -6,7 +6,7 @@ atlas_subdir( TrackD3PDMaker ) # Component(s) in the package: atlas_add_component( TrackD3PDMaker src/components/*.cxx - LINK_LIBRARIES TrkParameters AthenaKernel CxxUtils Identifier EventPrimitives xAODBase xAODPrimitives xAODTracking GaudiKernel InDetIdentifier InDetReadoutGeometry InDetTestBLayerLib ParticleEvent D3PDMakerInterfaces D3PDMakerUtils Particle InDetRecToolInterfaces ITrackToVertex RecoToolInterfaces TrkEventPrimitives TrkParticleBase VxVertex InDetBeamSpotServiceLib ) + LINK_LIBRARIES TrkParameters AthenaKernel CxxUtils Identifier EventPrimitives xAODBase xAODPrimitives xAODTracking GaudiKernel InDetIdentifier InDetReadoutGeometry InDetTestBLayerLib ParticleEvent D3PDMakerInterfaces D3PDMakerUtils Particle InDetRecToolInterfaces ITrackToVertex RecoToolInterfaces TrkEventPrimitives TrkParticleBase VxVertex BeamSpotConditionsData ) # Install files from the package: atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} ) diff --git a/PhysicsAnalysis/D3PDMaker/TrackD3PDMaker/src/TrackParticlePerigeeAtBSAssociationTool.cxx b/PhysicsAnalysis/D3PDMaker/TrackD3PDMaker/src/TrackParticlePerigeeAtBSAssociationTool.cxx index 2d5b006be15b0b2980e0e2ed818434c22365b883..50b172622f970c44c056e4a75f5eb86676cc48ab 100644 --- a/PhysicsAnalysis/D3PDMaker/TrackD3PDMaker/src/TrackParticlePerigeeAtBSAssociationTool.cxx +++ b/PhysicsAnalysis/D3PDMaker/TrackD3PDMaker/src/TrackParticlePerigeeAtBSAssociationTool.cxx @@ -28,26 +28,19 @@ TrackParticlePerigeeAtBSAssociationTool::TrackParticlePerigeeAtBSAssociationTool const std::string& name, const IInterface* parent) : Base (type, name, parent), - m_iBeamCondSvc(0), m_trackToVertexTool("Reco::TrackToVertex") { declareProperty ("TrackToVertexTool", m_trackToVertexTool); - declareProperty("BeamCondSvcName", m_beamCondSvcName = "BeamCondSvc"); } StatusCode TrackParticlePerigeeAtBSAssociationTool::initialize(){ CHECK( Base::initialize() ); - // Pick up the BeamConditionService - StatusCode sc = service(m_beamCondSvcName, m_iBeamCondSvc); - if (sc.isFailure() || m_iBeamCondSvc == 0) { - REPORT_MESSAGE (MSG::WARNING) << "Could not find BeamCondSvc: " << m_beamCondSvcName; - REPORT_MESSAGE (MSG::WARNING) << "Will use nominal beamspot at (0,0,0)"; - } + ATH_CHECK(m_beamSpotKey.initialize()); // Pick up the TrackToVertex tool - sc = m_trackToVertexTool.retrieve(); + StatusCode sc = m_trackToVertexTool.retrieve(); if(sc.isFailure()){ REPORT_MESSAGE (MSG::ERROR) << "Could not retrieve TrackToVertexTool"; return StatusCode::FAILURE; @@ -68,11 +61,10 @@ TrackParticlePerigeeAtBSAssociationTool::get (const Rec::TrackParticle& track) // Protect against bad tracks. if (track.measuredPerigee()->covariance() && track.measuredPerigee()->covariance()->rows()==0) return 0; - + SG::ReadCondHandle<InDet::BeamSpotData> beamSpotHandle { m_beamSpotKey }; /// Pick up the beamspot Amg::Vector3D beamSpot(0,0,0); - if (m_iBeamCondSvc) - beamSpot = m_iBeamCondSvc->beamVtx().position(); + beamSpot = beamSpotHandle->beamVtx().position(); return m_trackToVertexTool->perigeeAtVertex(track, beamSpot); } @@ -88,8 +80,8 @@ TrackParticlePerigeeAtBSAssociationTool::get (const xAOD::TrackParticle& track) { /// Pick up the beamspot Amg::Vector3D beamSpot(0,0,0); - if (m_iBeamCondSvc) - beamSpot = m_iBeamCondSvc->beamVtx().position(); + SG::ReadCondHandle<InDet::BeamSpotData> beamSpotHandle { m_beamSpotKey }; + beamSpot = beamSpotHandle->beamVtx().position(); return m_trackToVertexTool->perigeeAtVertex(track, beamSpot); } diff --git a/PhysicsAnalysis/D3PDMaker/TrackD3PDMaker/src/TrackParticlePerigeeAtBSAssociationTool.h b/PhysicsAnalysis/D3PDMaker/TrackD3PDMaker/src/TrackParticlePerigeeAtBSAssociationTool.h index 03f486a080198c48bf16946647725727710c26f1..b214717ae297ed6719aac7355420925bd106cdb5 100644 --- a/PhysicsAnalysis/D3PDMaker/TrackD3PDMaker/src/TrackParticlePerigeeAtBSAssociationTool.h +++ b/PhysicsAnalysis/D3PDMaker/TrackD3PDMaker/src/TrackParticlePerigeeAtBSAssociationTool.h @@ -19,9 +19,8 @@ #include "TrkParameters/TrackParameters.h" #include "xAODTracking/TrackParticle.h" #include "GaudiKernel/ToolHandle.h" -#include "InDetBeamSpotService/IBeamCondSvc.h" #include <vector> - +#include "BeamSpotConditionsData/BeamSpotData.h" namespace Rec { class TrackParticle; @@ -75,9 +74,7 @@ public: private: - /* the beam condition service **/ - IBeamCondSvc* m_iBeamCondSvc; - std::string m_beamCondSvcName; + SG::ReadCondHandleKey<InDet::BeamSpotData> m_beamSpotKey { this, "BeamSpotKey", "BeamSpotData", "SG key for beam spot" }; /* Track to vertex extrapolator **/ ToolHandle<Reco::ITrackToVertex> m_trackToVertexTool;