diff --git a/InnerDetector/InDetMonitoring/InDetGlobalMonitoring/CMakeLists.txt b/InnerDetector/InDetMonitoring/InDetGlobalMonitoring/CMakeLists.txt index 5b822c2f1b82d99112bb162bf6cb5f1379c5f5ee..e44697c0ea0fa31ac00db5778074e6ff03ae5dc7 100644 --- a/InnerDetector/InDetMonitoring/InDetGlobalMonitoring/CMakeLists.txt +++ b/InnerDetector/InDetMonitoring/InDetGlobalMonitoring/CMakeLists.txt @@ -21,7 +21,7 @@ atlas_depends_on_subdirs( Event/xAOD/xAODJet Event/xAOD/xAODTracking Generators/GeneratorObjects - InnerDetector/InDetConditions/InDetBeamSpotService + InnerDetector/InDetConditions/BeamSpotConditionsData InnerDetector/InDetConditions/InDetConditionsSummaryService InnerDetector/InDetConditions/PixelConditionsServices InnerDetector/InDetConditions/SCT_ConditionsTools diff --git a/InnerDetector/InDetMonitoring/InDetGlobalMonitoring/src/InDetGlobalBeamSpotMonTool.cxx b/InnerDetector/InDetMonitoring/InDetGlobalMonitoring/src/InDetGlobalBeamSpotMonTool.cxx index 0082e6da5cb63412857534069ccef2b0171208cd..b7fcaa3bb4d041df6543b136cc828a00f03aa2a4 100755 --- a/InnerDetector/InDetMonitoring/InDetGlobalMonitoring/src/InDetGlobalBeamSpotMonTool.cxx +++ b/InnerDetector/InDetMonitoring/InDetGlobalMonitoring/src/InDetGlobalBeamSpotMonTool.cxx @@ -24,16 +24,12 @@ #include "EventPrimitives/EventPrimitivesHelpers.h" -#include "InDetBeamSpotService/IBeamCondSvc.h" - #include "AthenaMonitoring/AthenaMonManager.h" #include "InDetGlobalBeamSpotMonTool.h" InDetGlobalBeamSpotMonTool::InDetGlobalBeamSpotMonTool( const std::string & type, const std::string & name, const IInterface* parent ) :InDetGlobalMotherMonTool( type, name, parent ), - m_beamCondSvc("BeamCondSvc",name), - m_hasBeamCondSvc(false), m_hTrNPt(nullptr), m_hTrPt(nullptr), m_hTrDPhi(nullptr), @@ -61,7 +57,6 @@ InDetGlobalBeamSpotMonTool::InDetGlobalBeamSpotMonTool( const std::string & type m_hPvTrackPt(nullptr), m_hPvTrackEta(nullptr) { - declareProperty("beamCondSvc",m_beamCondSvc); declareProperty("useBeamspot",m_useBeamspot=true); declareProperty("vxContainerWithBeamConstraint",m_vxContainerWithBeamConstraint=false); declareProperty("minTracksPerVtx",m_minTracksPerVtx=4); @@ -78,13 +73,7 @@ StatusCode InDetGlobalBeamSpotMonTool::initialize() { StatusCode sc; sc = ManagedMonitorToolBase::initialize(); if(!sc.isSuccess()) return sc; - - if ( m_beamCondSvc.retrieve().isFailure() ) { - msg(MSG::WARNING) << "Failed to retrieve beamspot service " << m_beamCondSvc << " - will use nominal beamspot at (0,0,0)" << endmsg; - } else { - m_hasBeamCondSvc = true; - msg(MSG::INFO) << "Retrieved service " << m_beamCondSvc << endmsg; - } + ATH_CHECK(m_beamSpotKey.initialize(m_useBeamspot)); ATH_CHECK(m_vxContainerName.initialize()); ATH_CHECK(m_trackContainerName.initialize()); @@ -171,23 +160,25 @@ StatusCode InDetGlobalBeamSpotMonTool::fillHistograms() { float beamTiltX = 0.; float beamTiltY = 0.; float scaleFactor = 1.; - if (m_useBeamspot && m_hasBeamCondSvc) { - Amg::Vector3D bpos = m_beamCondSvc->beamPos(); + if (m_useBeamspot) { + SG::ReadCondHandle<InDet::BeamSpotData> beamSpotHandle { m_beamSpotKey }; + ATH_CHECK(beamSpotHandle.isValid()); + const Amg::Vector3D &bpos = beamSpotHandle->beamPos(); beamSpotX = bpos.x(); beamSpotY = bpos.y(); beamSpotZ = bpos.z(); - beamTiltX = m_beamCondSvc->beamTilt(0); - beamTiltY = m_beamCondSvc->beamTilt(1); + beamTiltX = beamSpotHandle->beamTilt(0); + beamTiltY = beamSpotHandle->beamTilt(1); scaleFactor = 1000.; // Use microns for some histograms when showing distance relative to beamspot m_hBsX->Fill(beamSpotX); m_hBsY->Fill(beamSpotY); m_hBsZ->Fill(beamSpotZ); m_hBsTiltX->Fill(1e6*beamTiltX); m_hBsTiltY->Fill(1e6*beamTiltY); - if (msgLvl(MSG::DEBUG)) msg() << "Beamspot from " << m_beamCondSvc << ": x0 = " << beamSpotX << ", y0 = " << beamSpotY + ATH_MSG_DEBUG("Beamspot from " << beamSpotHandle.retrieve() << ": x0 = " << beamSpotX << ", y0 = " << beamSpotY << ", z0 = " << beamSpotZ << ", tiltX = " << beamTiltX - << ", tiltY = " << beamTiltY <<endmsg; + << ", tiltY = " << beamTiltY); } SG::ReadHandle<xAOD::TrackParticleContainer> trackCollection(m_trackContainerName); diff --git a/InnerDetector/InDetMonitoring/InDetGlobalMonitoring/src/InDetGlobalBeamSpotMonTool.h b/InnerDetector/InDetMonitoring/InDetGlobalMonitoring/src/InDetGlobalBeamSpotMonTool.h index da4912f7a069e270942fc08d5df5e0a69c8098a5..9c76bc489d27d3464f98c145f0d1eab38e643ec4 100755 --- a/InnerDetector/InDetMonitoring/InDetGlobalMonitoring/src/InDetGlobalBeamSpotMonTool.h +++ b/InnerDetector/InDetMonitoring/InDetGlobalMonitoring/src/InDetGlobalBeamSpotMonTool.h @@ -29,11 +29,11 @@ #include "InDetGlobalMotherMonTool.h" #include "xAODTracking/VertexContainer.h" #include "xAODTracking/TrackParticleContainer.h" +#include "BeamSpotConditionsData/BeamSpotData.h" class TH1F_LW; class TH2F_LW; -class IBeamCondSvc; class InDetGlobalBeamSpotMonTool : public InDetGlobalMotherMonTool { @@ -48,8 +48,7 @@ public: virtual StatusCode procHistograms(); protected: - ServiceHandle<IBeamCondSvc> m_beamCondSvc; - bool m_hasBeamCondSvc; + SG::ReadCondHandleKey<InDet::BeamSpotData> m_beamSpotKey { this, "BeamSpotKey", "BeamSpotData", "SG key for beam spot" }; TH1F_LW* m_hTrNPt; TH1F_LW* m_hTrPt; diff --git a/InnerDetector/InDetRecTools/InDetVKalPriVxFinderTool/CMakeLists.txt b/InnerDetector/InDetRecTools/InDetVKalPriVxFinderTool/CMakeLists.txt index aef27a65c7b36711cf2c83466e578db58fce5dff..2eacc5281dd87a7648d3d3828f0817cf3b07a0a3 100644 --- a/InnerDetector/InDetRecTools/InDetVKalPriVxFinderTool/CMakeLists.txt +++ b/InnerDetector/InDetRecTools/InDetVKalPriVxFinderTool/CMakeLists.txt @@ -11,12 +11,12 @@ atlas_depends_on_subdirs( PUBLIC Event/xAOD/xAODTracking GaudiKernel InnerDetector/InDetRecTools/InDetRecToolInterfaces + InnerDetector/InDetConditions/BeamSpotConditionsData Tracking/TrkEvent/TrkParameters Tracking/TrkEvent/TrkParticleBase Tracking/TrkEvent/TrkTrack Tracking/TrkVertexFitter/TrkVKalVrtFitter PRIVATE - InnerDetector/InDetConditions/InDetBeamSpotService Tracking/TrkEvent/TrkEventPrimitives Tracking/TrkEvent/TrkTrackLink Tracking/TrkEvent/TrkTrackSummary diff --git a/InnerDetector/InDetRecTools/InDetVKalPriVxFinderTool/InDetVKalPriVxFinderTool/InDetVKalPriVxFinderTool.h b/InnerDetector/InDetRecTools/InDetVKalPriVxFinderTool/InDetVKalPriVxFinderTool/InDetVKalPriVxFinderTool.h index cb06513d9d14e27df8657eb4c176f37c0811045b..aaed07636282dc993838bf6a29a6116f493c68e1 100755 --- a/InnerDetector/InDetRecTools/InDetVKalPriVxFinderTool/InDetVKalPriVxFinderTool/InDetVKalPriVxFinderTool.h +++ b/InnerDetector/InDetRecTools/InDetVKalPriVxFinderTool/InDetVKalPriVxFinderTool/InDetVKalPriVxFinderTool.h @@ -47,10 +47,7 @@ #include <vector> #include <utility>//for std::pair - -class IBeamCondSvc; - - +#include "BeamSpotConditionsData/BeamSpotData.h" namespace Trk { @@ -118,7 +115,7 @@ namespace InDet { {this,"TrkVKalVrtFitter","Trk::TrkVKalVrtFitter",""}; PublicToolHandle< Trk::ITrackSummaryTool > m_sumSvc {this,"TrackSummaryTool","Trk::TrackSummaryTool/AtlasTrackSummaryTool",""}; //!< Pointer to the track summary tool - ServiceHandle< IBeamCondSvc > m_iBeamCondSvc; //!< pointer to the beam condition service + SG::ReadCondHandleKey<InDet::BeamSpotData> m_beamSpotKey { this, "BeamSpotKey", "BeamSpotData", "SG key for beam spot" }; PublicToolHandle<Trk::ITrackSelectorTool> m_trkSelector {this,"DefaultTrackSelection","DefaultTrackSelection",""}; @@ -126,7 +123,6 @@ namespace InDet { std::vector<double> m_BeamCnstWid; // int m_SummaryToolExist; - int m_BeamCondSvcExist; int m_trkSelectorExist; // // To simplify life.... diff --git a/InnerDetector/InDetRecTools/InDetVKalPriVxFinderTool/src/InDetVKalPriVxFinder.cxx b/InnerDetector/InDetRecTools/InDetVKalPriVxFinderTool/src/InDetVKalPriVxFinder.cxx index 610d7baf787c32efa42a5215e9dd35a7703dc722..a65dbc69ef467896d21c397915c64ea646049e18 100644 --- a/InnerDetector/InDetRecTools/InDetVKalPriVxFinderTool/src/InDetVKalPriVxFinder.cxx +++ b/InnerDetector/InDetRecTools/InDetVKalPriVxFinderTool/src/InDetVKalPriVxFinder.cxx @@ -8,7 +8,6 @@ // Other stuff // -#include "InDetBeamSpotService/IBeamCondSvc.h" //---- #include "TrkTrackLink/ITrackLink.h" #include "TrkTrack/LinkToTrack.h" @@ -58,9 +57,7 @@ InDetVKalPriVxFinderTool::InDetVKalPriVxFinderTool(const std::string& type, m_SecTrkChi2Cut(5.5), m_WeightCut(0.2), - m_NPVertexMax(100), - - m_iBeamCondSvc("BeamCondSvc",name) + m_NPVertexMax(100) { declareInterface<IVertexFinder>(this); @@ -95,10 +92,8 @@ InDetVKalPriVxFinderTool::InDetVKalPriVxFinderTool(const std::string& type, declareProperty("FitterTool", m_fitSvc ); declareProperty("TrackSummaryTool", m_sumSvc ); - declareProperty("BeamPositionSvc", m_iBeamCondSvc); declareProperty("TrackSelectorTool", m_trkSelector); - m_BeamCondSvcExist=0; } @@ -147,15 +142,9 @@ InDetVKalPriVxFinderTool::InDetVKalPriVxFinderTool(const std::string& type, m_BeamCnstWid[1]=0.015; m_BeamCnstWid[2]=56.; - if(m_BeamConstraint){ - //StatusCode sc = service("BeamCondSvc", m_iBeamCondSvc); - if (m_iBeamCondSvc.retrieve().isFailure() ) - { if(msgLvl(MSG::INFO))msg(MSG::INFO) << "Could not find BeamCondSvc." << endmsg; - m_BeamCondSvcExist=0; - }else{ - m_BeamCondSvcExist=1; - } - } + + ATH_CHECK(m_beamSpotKey.initialize(m_BeamConstraint)); + // //TrackSelectorTool // @@ -239,13 +228,14 @@ InDetVKalPriVxFinderTool::InDetVKalPriVxFinderTool(const std::string& type, const DataVector<Trk::Track>* newTrkCol = trackTES; if(m_BeamConstraint){ - if(m_BeamCondSvcExist){ - Amg::Vector3D beam=m_iBeamCondSvc->beamPos(); + SG::ReadCondHandle<InDet::BeamSpotData> beamSpotHandle { m_beamSpotKey }; + if(beamSpotHandle.isValid()){ + const Amg::Vector3D &beam=beamSpotHandle->beamPos(); m_BeamCnst[0]=beam.x(); m_BeamCnst[1]=beam.y(); m_BeamCnst[2]=beam.z(); - m_BeamCnstWid[0]=m_iBeamCondSvc->beamSigma(0); - m_BeamCnstWid[1]=m_iBeamCondSvc->beamSigma(1); + m_BeamCnstWid[0]=beamSpotHandle->beamSigma(0); + m_BeamCnstWid[1]=beamSpotHandle->beamSigma(1); if(msgLvl(MSG::DEBUG))msg(MSG::DEBUG) << "BeamSpot from SVC="<<m_BeamCnst[0]<<", "<<m_BeamCnst[1]<< ", "<<m_BeamCnst[2]<<" wid="<<m_BeamCnstWid[0]<<", "<<m_BeamCnstWid[1]<<endmsg; if(msgLvl(MSG::DEBUG) && m_BeamCnst[2]!=0.)msg(MSG::DEBUG) << "BeamSpot Z must be 0 in finder!!! Make Z=0."<<endmsg; @@ -419,13 +409,14 @@ InDetVKalPriVxFinderTool::InDetVKalPriVxFinderTool(const std::string& type, std::vector<double> Impact,ImpactError; if(m_BeamConstraint){ - if(m_BeamCondSvcExist){ - Amg::Vector3D beam=m_iBeamCondSvc->beamPos(); + SG::ReadCondHandle<InDet::BeamSpotData> beamSpotHandle { m_beamSpotKey }; + if(beamSpotHandle.isValid()){ + const Amg::Vector3D &beam=beamSpotHandle->beamPos(); m_BeamCnst[0]=beam.x(); m_BeamCnst[1]=beam.y(); m_BeamCnst[2]=beam.z(); - m_BeamCnstWid[0]=m_iBeamCondSvc->beamSigma(0); - m_BeamCnstWid[1]=m_iBeamCondSvc->beamSigma(1); + m_BeamCnstWid[0]=beamSpotHandle->beamSigma(0); + m_BeamCnstWid[1]=beamSpotHandle->beamSigma(1); if(msgLvl(MSG::DEBUG))msg(MSG::DEBUG) << "BeamSpot from SVC="<<m_BeamCnst[0]<<", "<<m_BeamCnst[1]<< ", "<<m_BeamCnst[2]<<" wid="<<m_BeamCnstWid[0]<<", "<<m_BeamCnstWid[1]<<endmsg; }