Skip to content
Snippets Groups Projects
Commit 30542ee6 authored by Adam Edward Barton's avatar Adam Edward Barton
Browse files

migrate InDetBeamSpotFinder away from IBeamCondSvc service

parent 6765fdd1
No related branches found
No related tags found
No related merge requests found
...@@ -13,7 +13,7 @@ atlas_depends_on_subdirs( PUBLIC ...@@ -13,7 +13,7 @@ atlas_depends_on_subdirs( PUBLIC
Control/AthenaBaseComps Control/AthenaBaseComps
Event/EventInfo Event/EventInfo
Event/xAOD/xAODEventInfo Event/xAOD/xAODEventInfo
InnerDetector/InDetConditions/InDetBeamSpotService InnerDetector/InDetConditions/BeamSpotConditionsData
Tracking/TrkEvent/TrkEventPrimitives Tracking/TrkEvent/TrkEventPrimitives
Tracking/TrkEvent/VxVertex Tracking/TrkEvent/VxVertex
Trigger/TrigAnalysis/TrigAnalysisInterfaces Trigger/TrigAnalysis/TrigAnalysisInterfaces
......
...@@ -7,27 +7,19 @@ ...@@ -7,27 +7,19 @@
#include "VxVertex/VxCandidate.h" #include "VxVertex/VxCandidate.h"
//#include "TrkEventPrimitives/VertexType.h" //#include "TrkEventPrimitives/VertexType.h"
#include "InDetBeamSpotService/IBeamCondSvc.h"
#include "GaudiKernel/ToolHandle.h"
#include "EventInfo/EventID.h" #include "EventInfo/EventID.h"
InDet::InDetBeamSpotReader::InDetBeamSpotReader(const std::string& name, ISvcLocator* pSvcLocator): InDet::InDetBeamSpotReader::InDetBeamSpotReader(const std::string& name, ISvcLocator* pSvcLocator):
AthAlgorithm(name, pSvcLocator), AthReentrantAlgorithm(name, pSvcLocator)
m_toolSvc("ToolSvc",name),
m_beamSpotSvc("BeamCondSvc",name)
{ {
declareProperty("ToolSvc", m_toolSvc);
declareProperty("BeamCondSvc", m_beamSpotSvc);
} }
StatusCode InDet::InDetBeamSpotReader::initialize() { StatusCode InDet::InDetBeamSpotReader::initialize() {
ATH_MSG_DEBUG( "in initialize()" ); ATH_MSG_DEBUG( "in initialize()" );
ATH_CHECK( m_toolSvc.retrieve() ); ATH_CHECK( m_beamSpotKey.initialize() );
ATH_CHECK( m_beamSpotSvc.retrieve() );
ATH_CHECK( m_eventInfo.initialize() ); ATH_CHECK( m_eventInfo.initialize() );
ATH_CHECK( m_vxContainer.initialize() ); ATH_CHECK( m_vxContainer.initialize() );
...@@ -35,26 +27,27 @@ StatusCode InDet::InDetBeamSpotReader::initialize() { ...@@ -35,26 +27,27 @@ StatusCode InDet::InDetBeamSpotReader::initialize() {
return StatusCode::SUCCESS; return StatusCode::SUCCESS;
} }
StatusCode InDet::InDetBeamSpotReader::execute(){ StatusCode InDet::InDetBeamSpotReader::execute_r(const EventContext& ctx) const {
ATH_MSG_DEBUG( "in execute()"); ATH_MSG_DEBUG( "in execute()");
//get the set of //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(); EventID* eventID = eventInfo->event_ID();
ATH_MSG_INFO( "In event " << (*eventID) ); ATH_MSG_INFO( "In event " << (*eventID) );
ATH_MSG_INFO("BeamSpot Position: \n " ATH_MSG_INFO("BeamSpot Position: \n "
<< m_beamSpotSvc->beamPos() ); << beamSpotHandle->beamPos() );
ATH_MSG_INFO("BeamSpot Sigma\n\t" ATH_MSG_INFO("BeamSpot Sigma\n\t"
<< m_beamSpotSvc->beamSigma(0) << "\n\t" << beamSpotHandle->beamSigma(0) << "\n\t"
<< m_beamSpotSvc->beamSigma(1) << "\n\t" << beamSpotHandle->beamSigma(1) << "\n\t"
<< m_beamSpotSvc->beamSigma(2) << "\n\t"); << beamSpotHandle->beamSigma(2) << "\n\t");
ATH_MSG_INFO("BeamSpot Tilt\n\t" ATH_MSG_INFO("BeamSpot Tilt\n\t"
<< m_beamSpotSvc->beamTilt(0) << "\n\t" << beamSpotHandle->beamTilt(0) << "\n\t"
<< m_beamSpotSvc->beamTilt(1) << "\n\t"); << beamSpotHandle->beamTilt(1) << "\n\t");
ATH_MSG_INFO("Beamspot position at PV z-position"); ATH_MSG_INFO("Beamspot position at PV z-position");
//get list of PVs //get list of PVs
SG::ReadHandle<VxContainer> importedVxContainer(m_vxContainer); SG::ReadHandle<VxContainer> importedVxContainer(m_vxContainer, ctx);
VxContainer::const_iterator vtxItr; VxContainer::const_iterator vtxItr;
for(vtxItr=importedVxContainer->begin(); for(vtxItr=importedVxContainer->begin();
vtxItr!=importedVxContainer->end(); ++vtxItr) { vtxItr!=importedVxContainer->end(); ++vtxItr) {
...@@ -63,12 +56,12 @@ StatusCode InDet::InDetBeamSpotReader::execute(){ ...@@ -63,12 +56,12 @@ StatusCode InDet::InDetBeamSpotReader::execute(){
<< (*vtxItr)->recVertex().position() ); << (*vtxItr)->recVertex().position() );
double z = (*vtxItr)->recVertex().position().z(); double z = (*vtxItr)->recVertex().position().z();
if (msgLvl(MSG::INFO)) ATH_MSG_INFO("\n\t" if (msgLvl(MSG::INFO)) ATH_MSG_INFO("\n\t"
<< m_beamSpotSvc->beamPos()(0) << beamSpotHandle->beamPos()(0)
+ (z - m_beamSpotSvc->beamPos()(2)) + (z - beamSpotHandle->beamPos()(2))
*m_beamSpotSvc->beamTilt(0) << "\n\t" *beamSpotHandle->beamTilt(0) << "\n\t"
<< m_beamSpotSvc->beamPos()(1) << beamSpotHandle->beamPos()(1)
+ (z - m_beamSpotSvc->beamPos()(2)) + (z - beamSpotHandle->beamPos()(2))
*m_beamSpotSvc->beamTilt(1) ); *beamSpotHandle->beamTilt(1) );
} }
return StatusCode::SUCCESS; return StatusCode::SUCCESS;
......
...@@ -10,36 +10,29 @@ ...@@ -10,36 +10,29 @@
////////////////////////////// //////////////////////////////
#include <string> #include "AthenaBaseComps/AthReentrantAlgorithm.h"
#include <vector>
#include <map>
#include "AthenaBaseComps/AthAlgorithm.h"
#include "GaudiKernel/ServiceHandle.h"
#include "StoreGate/ReadHandleKey.h" #include "StoreGate/ReadHandleKey.h"
#include "VxVertex/VxContainer.h" #include "VxVertex/VxContainer.h"
#include "EventInfo/EventInfo.h" #include "EventInfo/EventInfo.h"
#include "BeamSpotConditionsData/BeamSpotData.h"
class IBeamCondSvc;
namespace InDet { namespace InDet {
/** An example class of how to read beamspot position. /** An example class of how to read beamspot position.
Currently there must be a valid beamspot entry for the IOV of data that is Currently there must be a valid beamspot entry for the IOV of data that is
being read. Otherwise an error will occur. being read. Otherwise an error will occur.
*/ */
class InDetBeamSpotReader : public AthAlgorithm { class InDetBeamSpotReader : public AthReentrantAlgorithm {
public: public:
//Standard constructor and methods //Standard constructor and methods
InDetBeamSpotReader (const std::string& name, ISvcLocator* pSvcLocator); InDetBeamSpotReader (const std::string& name, ISvcLocator* pSvcLocator);
StatusCode initialize(); StatusCode initialize() override;
StatusCode execute(); StatusCode execute_r(const EventContext& ctx) const override;
StatusCode finalize(); StatusCode finalize() override;
private: private:
ServiceHandle<IToolSvc> m_toolSvc; SG::ReadCondHandleKey<InDet::BeamSpotData> m_beamSpotKey { this, "BeamSpotKey", "BeamSpotData", "SG key for beam spot" };
ServiceHandle<IBeamCondSvc> m_beamSpotSvc;
SG::ReadHandleKey<EventInfo> m_eventInfo SG::ReadHandleKey<EventInfo> m_eventInfo
{this, "EvtInfo", "EventInfo", "EventInfo name"}; {this, "EvtInfo", "EventInfo", "EventInfo name"};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment