From 479afe64f5da85df997589e9e9175c1231205f8b Mon Sep 17 00:00:00 2001 From: abarton <Adam.Edward.Barton@cern.ch> Date: Mon, 10 Dec 2018 15:24:18 +0000 Subject: [PATCH] migrate InDetBeamSpotFinder away from IBeamCondSvc service Former-commit-id: 30542ee63b2648365de9cbf51915ef4b8468d0fc --- .../InDetBeamSpotFinder/CMakeLists.txt | 2 +- .../src/InDetBeamSpotReader.cxx | 43 ++++++++----------- .../src/InDetBeamSpotReader.h | 21 +++------ 3 files changed, 26 insertions(+), 40 deletions(-) diff --git a/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/CMakeLists.txt b/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/CMakeLists.txt index 35df023212b..3c5aba13481 100644 --- a/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/CMakeLists.txt +++ b/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/CMakeLists.txt @@ -13,7 +13,7 @@ atlas_depends_on_subdirs( PUBLIC Control/AthenaBaseComps Event/EventInfo Event/xAOD/xAODEventInfo - InnerDetector/InDetConditions/InDetBeamSpotService + InnerDetector/InDetConditions/BeamSpotConditionsData Tracking/TrkEvent/TrkEventPrimitives Tracking/TrkEvent/VxVertex Trigger/TrigAnalysis/TrigAnalysisInterfaces diff --git a/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/InDetBeamSpotReader.cxx b/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/InDetBeamSpotReader.cxx index 72f14ee54b8..a7cee61fc80 100644 --- a/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/InDetBeamSpotReader.cxx +++ b/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/InDetBeamSpotReader.cxx @@ -7,27 +7,19 @@ #include "VxVertex/VxCandidate.h" //#include "TrkEventPrimitives/VertexType.h" -#include "InDetBeamSpotService/IBeamCondSvc.h" -#include "GaudiKernel/ToolHandle.h" - #include "EventInfo/EventID.h" InDet::InDetBeamSpotReader::InDetBeamSpotReader(const std::string& name, ISvcLocator* pSvcLocator): - AthAlgorithm(name, pSvcLocator), - m_toolSvc("ToolSvc",name), - m_beamSpotSvc("BeamCondSvc",name) + AthReentrantAlgorithm(name, pSvcLocator) { - declareProperty("ToolSvc", m_toolSvc); - declareProperty("BeamCondSvc", m_beamSpotSvc); } StatusCode InDet::InDetBeamSpotReader::initialize() { ATH_MSG_DEBUG( "in initialize()" ); - ATH_CHECK( m_toolSvc.retrieve() ); - ATH_CHECK( m_beamSpotSvc.retrieve() ); + ATH_CHECK( m_beamSpotKey.initialize() ); ATH_CHECK( m_eventInfo.initialize() ); ATH_CHECK( m_vxContainer.initialize() ); @@ -35,26 +27,27 @@ StatusCode InDet::InDetBeamSpotReader::initialize() { return StatusCode::SUCCESS; } -StatusCode InDet::InDetBeamSpotReader::execute(){ +StatusCode InDet::InDetBeamSpotReader::execute_r(const EventContext& ctx) const { ATH_MSG_DEBUG( "in execute()"); //get the set of - SG::ReadHandle<EventInfo> eventInfo(m_eventInfo); + SG::ReadCondHandle<InDet::BeamSpotData> beamSpotHandle { m_beamSpotKey, ctx }; + SG::ReadHandle<EventInfo> eventInfo(m_eventInfo, ctx); EventID* eventID = eventInfo->event_ID(); ATH_MSG_INFO( "In event " << (*eventID) ); ATH_MSG_INFO("BeamSpot Position: \n " - << m_beamSpotSvc->beamPos() ); + << beamSpotHandle->beamPos() ); ATH_MSG_INFO("BeamSpot Sigma\n\t" - << m_beamSpotSvc->beamSigma(0) << "\n\t" - << m_beamSpotSvc->beamSigma(1) << "\n\t" - << m_beamSpotSvc->beamSigma(2) << "\n\t"); + << beamSpotHandle->beamSigma(0) << "\n\t" + << beamSpotHandle->beamSigma(1) << "\n\t" + << beamSpotHandle->beamSigma(2) << "\n\t"); ATH_MSG_INFO("BeamSpot Tilt\n\t" - << m_beamSpotSvc->beamTilt(0) << "\n\t" - << m_beamSpotSvc->beamTilt(1) << "\n\t"); + << beamSpotHandle->beamTilt(0) << "\n\t" + << beamSpotHandle->beamTilt(1) << "\n\t"); ATH_MSG_INFO("Beamspot position at PV z-position"); //get list of PVs - SG::ReadHandle<VxContainer> importedVxContainer(m_vxContainer); + SG::ReadHandle<VxContainer> importedVxContainer(m_vxContainer, ctx); VxContainer::const_iterator vtxItr; for(vtxItr=importedVxContainer->begin(); vtxItr!=importedVxContainer->end(); ++vtxItr) { @@ -63,12 +56,12 @@ StatusCode InDet::InDetBeamSpotReader::execute(){ << (*vtxItr)->recVertex().position() ); double z = (*vtxItr)->recVertex().position().z(); if (msgLvl(MSG::INFO)) ATH_MSG_INFO("\n\t" - << m_beamSpotSvc->beamPos()(0) - + (z - m_beamSpotSvc->beamPos()(2)) - *m_beamSpotSvc->beamTilt(0) << "\n\t" - << m_beamSpotSvc->beamPos()(1) - + (z - m_beamSpotSvc->beamPos()(2)) - *m_beamSpotSvc->beamTilt(1) ); + << beamSpotHandle->beamPos()(0) + + (z - beamSpotHandle->beamPos()(2)) + *beamSpotHandle->beamTilt(0) << "\n\t" + << beamSpotHandle->beamPos()(1) + + (z - beamSpotHandle->beamPos()(2)) + *beamSpotHandle->beamTilt(1) ); } return StatusCode::SUCCESS; diff --git a/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/InDetBeamSpotReader.h b/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/InDetBeamSpotReader.h index be8402d25b4..3be3e5f167a 100644 --- a/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/InDetBeamSpotReader.h +++ b/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/InDetBeamSpotReader.h @@ -10,36 +10,29 @@ ////////////////////////////// -#include <string> -#include <vector> -#include <map> - -#include "AthenaBaseComps/AthAlgorithm.h" -#include "GaudiKernel/ServiceHandle.h" +#include "AthenaBaseComps/AthReentrantAlgorithm.h" #include "StoreGate/ReadHandleKey.h" #include "VxVertex/VxContainer.h" #include "EventInfo/EventInfo.h" - -class IBeamCondSvc; +#include "BeamSpotConditionsData/BeamSpotData.h" namespace InDet { /** An example class of how to read beamspot position. Currently there must be a valid beamspot entry for the IOV of data that is being read. Otherwise an error will occur. */ - class InDetBeamSpotReader : public AthAlgorithm { + class InDetBeamSpotReader : public AthReentrantAlgorithm { public: //Standard constructor and methods InDetBeamSpotReader (const std::string& name, ISvcLocator* pSvcLocator); - StatusCode initialize(); - StatusCode execute(); - StatusCode finalize(); + StatusCode initialize() override; + StatusCode execute_r(const EventContext& ctx) const override; + StatusCode finalize() override; private: - ServiceHandle<IToolSvc> m_toolSvc; - ServiceHandle<IBeamCondSvc> m_beamSpotSvc; + SG::ReadCondHandleKey<InDet::BeamSpotData> m_beamSpotKey { this, "BeamSpotKey", "BeamSpotData", "SG key for beam spot" }; SG::ReadHandleKey<EventInfo> m_eventInfo {this, "EvtInfo", "EventInfo", "EventInfo name"}; -- GitLab