Skip to content
Snippets Groups Projects
Commit 9ab4bc69 authored by scott snyder's avatar scott snyder Committed by scott snyder
Browse files

MuonTGC_CnvTools: Preparing to make TGC_RawDataProviderTool* const.

Update TGC_RawDataProviderTool and TGC_RawDataProviderToolMT so that the
interfaces can be made const.
parent 65bfd49d
No related branches found
No related tags found
No related merge requests found
...@@ -19,7 +19,7 @@ atlas_add_component( MuonTGC_CnvTools ...@@ -19,7 +19,7 @@ atlas_add_component( MuonTGC_CnvTools
src/*.cxx src/*.cxx
src/components/*.cxx src/components/*.cxx
INCLUDE_DIRS ${TDAQ-COMMON_INCLUDE_DIRS} INCLUDE_DIRS ${TDAQ-COMMON_INCLUDE_DIRS}
LINK_LIBRARIES ${TDAQ-COMMON_LIBRARIES} ByteStreamCnvSvcBaseLib ByteStreamData ByteStreamData_test GaudiKernel AthenaBaseComps Identifier EventPrimitives TGCcablingInterfaceLib MuonReadoutGeometry MuonDigitContainer MuonIdHelpersLib MuonRDO MuonPrepRawData MuonTrigCoinData TrkSurfaces MuonCnvToolInterfacesLib MuonTGC_CnvToolsLib ByteStreamCnvSvcLib ) LINK_LIBRARIES ${TDAQ-COMMON_LIBRARIES} ByteStreamCnvSvcBaseLib ByteStreamData ByteStreamData_test GaudiKernel AthenaBaseComps Identifier EventPrimitives TGCcablingInterfaceLib MuonReadoutGeometry MuonDigitContainer MuonIdHelpersLib MuonRDO MuonPrepRawData MuonTrigCoinData TrkSurfaces MuonCnvToolInterfacesLib MuonTGC_CnvToolsLib ByteStreamCnvSvcLib CxxUtils )
# Install files from the package: # Install files from the package:
atlas_install_joboptions( share/*.py ) atlas_install_joboptions( share/*.py )
......
/* /*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/ */
#include "TGC_Hid2RESrcID.h" #include "TGC_Hid2RESrcID.h"
...@@ -12,15 +12,8 @@ ...@@ -12,15 +12,8 @@
#include "eformat/SourceIdentifier.h" #include "eformat/SourceIdentifier.h"
using eformat::helper::SourceIdentifier; using eformat::helper::SourceIdentifier;
// Initialize the cabling service.
void Muon::TGC_Hid2RESrcID::set(const ITGCcablingSvc* p_cabling) {
m_cabling=p_cabling;
m_robIDs.clear();
this->fillAllRobIds();
}
// get source ID for a RDO // get source ID for a RDO
uint32_t Muon::TGC_Hid2RESrcID::getRodID(const TgcRdo *rdo) uint32_t Muon::TGC_Hid2RESrcID::getRodID(const TgcRdo *rdo) const
{ {
// get Source ID // get Source ID
SourceIdentifier sid(static_cast<eformat::SubDetector>(rdo->subDetectorId()), SourceIdentifier sid(static_cast<eformat::SubDetector>(rdo->subDetectorId()),
...@@ -31,7 +24,7 @@ uint32_t Muon::TGC_Hid2RESrcID::getRodID(const TgcRdo *rdo) ...@@ -31,7 +24,7 @@ uint32_t Muon::TGC_Hid2RESrcID::getRodID(const TgcRdo *rdo)
} }
// get source ID for a RDO // get source ID for a RDO
uint32_t Muon::TGC_Hid2RESrcID::getRodID(uint16_t subDetectorId, uint16_t rodId) uint32_t Muon::TGC_Hid2RESrcID::getRodID(uint16_t subDetectorId, uint16_t rodId) const
{ {
// get Source ID // get Source ID
SourceIdentifier sid(static_cast<eformat::SubDetector>(subDetectorId), rodId); SourceIdentifier sid(static_cast<eformat::SubDetector>(subDetectorId), rodId);
...@@ -41,11 +34,12 @@ uint32_t Muon::TGC_Hid2RESrcID::getRodID(uint16_t subDetectorId, uint16_t rodId) ...@@ -41,11 +34,12 @@ uint32_t Muon::TGC_Hid2RESrcID::getRodID(uint16_t subDetectorId, uint16_t rodId)
} }
// get source ID for an TgcDigitCollection // get source ID for an TgcDigitCollection
uint32_t Muon::TGC_Hid2RESrcID::getRodID(const Identifier& offlineId) const uint32_t Muon::TGC_Hid2RESrcID::getRodID(const Identifier& offlineId,
const ITGCcablingSvc* cabling) const
{ {
int subDetectorId; int subDetectorId;
int rodId; int rodId;
m_cabling->getReadoutIDfromElementID(offlineId,subDetectorId,rodId); cabling->getReadoutIDfromElementID(offlineId,subDetectorId,rodId);
// get Source ID // get Source ID
SourceIdentifier sid(static_cast<eformat::SubDetector>(subDetectorId), SourceIdentifier sid(static_cast<eformat::SubDetector>(subDetectorId),
...@@ -64,7 +58,7 @@ uint32_t Muon::TGC_Hid2RESrcID::getRobID(uint32_t rod_id) const ...@@ -64,7 +58,7 @@ uint32_t Muon::TGC_Hid2RESrcID::getRobID(uint32_t rod_id) const
} }
// mapping SrcID from ROB to ROS // mapping SrcID from ROB to ROS
uint32_t Muon::TGC_Hid2RESrcID::getRosID(uint32_t rob_id) uint32_t Muon::TGC_Hid2RESrcID::getRosID(uint32_t rob_id) const
{ {
// Change Module Type to ROS, moduleid = 0 // Change Module Type to ROS, moduleid = 0
SourceIdentifier id(rob_id); SourceIdentifier id(rob_id);
...@@ -75,7 +69,7 @@ uint32_t Muon::TGC_Hid2RESrcID::getRosID(uint32_t rob_id) ...@@ -75,7 +69,7 @@ uint32_t Muon::TGC_Hid2RESrcID::getRosID(uint32_t rob_id)
} }
// mapping SrcID from ROS to Det // mapping SrcID from ROS to Det
uint32_t Muon::TGC_Hid2RESrcID::getDetID(uint32_t ros_id) uint32_t Muon::TGC_Hid2RESrcID::getDetID(uint32_t ros_id) const
{ {
// ROS to DET // ROS to DET
SourceIdentifier id(ros_id); SourceIdentifier id(ros_id);
......
/* /*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/ */
#ifndef MUONTGC_CNVTOOLS_TGC_HID2RESRCID #ifndef MUONTGC_CNVTOOLS_TGC_HID2RESRCID
...@@ -30,36 +30,32 @@ namespace Muon ...@@ -30,36 +30,32 @@ namespace Muon
public: public:
/** Constrcutor */ /** Constrcutor */
TGC_Hid2RESrcID () : m_cabling(0) {} TGC_Hid2RESrcID () {}
/** Destrcutor */ /** Destrcutor */
~TGC_Hid2RESrcID () {} ~TGC_Hid2RESrcID () {}
/** Initialize the cabling service. */
void set(const ITGCcablingSvc* p_cabling);
/** Make a ROD Source ID for TGC RDO. */ /** Make a ROD Source ID for TGC RDO. */
uint32_t getRodID(const TgcRdo *rdo); uint32_t getRodID(const TgcRdo *rdo) const;
/** Make a ROD Source ID for SubDetector ID and ROD ID. */ /** Make a ROD Source ID for SubDetector ID and ROD ID. */
uint32_t getRodID(uint16_t subDetectorId, uint16_t rodId); uint32_t getRodID(uint16_t subDetectorId, uint16_t rodId) const;
/** Make a ROD Source ID for TgcDigitCollection. */ /** Make a ROD Source ID for TgcDigitCollection. */
uint32_t getRodID(const Identifier & offlineId) const; uint32_t getRodID(const Identifier & offlineId,
const ITGCcablingSvc* cabling) const;
/** Make a ROB Source ID from a ROD source ID. */ /** Make a ROB Source ID from a ROD source ID. */
uint32_t getRobID (uint32_t rod_id) const; uint32_t getRobID (uint32_t rod_id) const;
/** Make a ROS Source ID from a ROB source ID. */ /** Make a ROS Source ID from a ROB source ID. */
uint32_t getRosID (uint32_t rob_id); uint32_t getRosID (uint32_t rob_id) const;
/** Make a SubDetector ID from ROS source ID. */ /** Make a SubDetector ID from ROS source ID. */
uint32_t getDetID (uint32_t ros_id); uint32_t getDetID (uint32_t ros_id) const;
/** Return all the ROB IDs. */ /** Return all the ROB IDs. */
const std::vector<uint32_t>& allRobIds() const { return m_robIDs; } const std::vector<uint32_t>& allRobIds() const { return m_robIDs; }
private:
/** Fill all the ROB IDs. */ /** Fill all the ROB IDs. */
void fillAllRobIds(); void fillAllRobIds();
private: private:
const ITGCcablingSvc * m_cabling;
std::vector<uint32_t> m_robIDs; std::vector<uint32_t> m_robIDs;
}; };
......
...@@ -77,11 +77,6 @@ StatusCode Muon::TGC_RawDataProviderTool::convert(){ ...@@ -77,11 +77,6 @@ StatusCode Muon::TGC_RawDataProviderTool::convert(){
StatusCode Muon::TGC_RawDataProviderTool::convert(const EventContext& ctx) const StatusCode Muon::TGC_RawDataProviderTool::convert(const EventContext& ctx) const
{ {
if(!m_cabling) {
ATH_MSG_ERROR("Tgc cabling is not available and needs to be set in initialise");
return StatusCode::FAILURE;
}
std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> vecOfRobf; std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> vecOfRobf;
const std::vector<uint32_t>& robIds = m_hid2re.allRobIds(); const std::vector<uint32_t>& robIds = m_hid2re.allRobIds();
......
...@@ -14,7 +14,6 @@ Muon::TGC_RawDataProviderToolCore::TGC_RawDataProviderToolCore( ...@@ -14,7 +14,6 @@ Muon::TGC_RawDataProviderToolCore::TGC_RawDataProviderToolCore(
const std::string& n, const std::string& n,
const IInterface* p) : const IInterface* p) :
AthAlgTool(t, n, p), AthAlgTool(t, n, p),
m_cabling(nullptr),
m_robDataProvider("ROBDataProviderSvc",n) m_robDataProvider("ROBDataProviderSvc",n)
{ {
} }
...@@ -38,11 +37,12 @@ StatusCode Muon::TGC_RawDataProviderToolCore::initialize() ...@@ -38,11 +37,12 @@ StatusCode Muon::TGC_RawDataProviderToolCore::initialize()
ATH_CHECK(m_rdoContainerKey.initialize()); ATH_CHECK(m_rdoContainerKey.initialize());
//try to configure the cabling service //try to configure the cabling service
StatusCode sc = getCabling(); if (!getCabling()) {
if(sc.isFailure()) { // ??? Is deferred initialization still needed here?
ATH_MSG_ERROR( "TGCcablingServerSvc not yet configured, but this needs to be available when TGC_RawDataProviderToolCore is initalised as we cannot create it on the fly during event processing inside const decode functions."); ATH_MSG_INFO( "TGCcablingServerSvc not yet configured; postpone TGCcabling initialization at first event. " );
return StatusCode::FAILURE;
} }
m_hid2re.fillAllRobIds();
return StatusCode::SUCCESS; return StatusCode::SUCCESS;
} }
...@@ -72,36 +72,37 @@ StatusCode Muon::TGC_RawDataProviderToolCore::convertIntoContainer(const std::ve ...@@ -72,36 +72,37 @@ StatusCode Muon::TGC_RawDataProviderToolCore::convertIntoContainer(const std::ve
return StatusCode::SUCCESS; return StatusCode::SUCCESS;
} }
StatusCode Muon::TGC_RawDataProviderToolCore::getCabling() { const ITGCcablingSvc* Muon::TGC_RawDataProviderToolCore::getCabling() const
const ITGCcablingServerSvc* TgcCabGet = 0; {
StatusCode sc = service("TGCcablingServerSvc", TgcCabGet, true); const ITGCcablingSvc* cabling = m_cabling.get();
if(sc.isFailure()) { if (cabling) {
return cabling;
}
ServiceHandle<ITGCcablingServerSvc> TgcCabGet ("TGCcablingServerSvc", name());
if (TgcCabGet.retrieve().isFailure()) {
ATH_MSG_FATAL( "Could not get TGCcablingServerSvc !" ); ATH_MSG_FATAL( "Could not get TGCcablingServerSvc !" );
return StatusCode::FAILURE; return nullptr;
} else { }
ATH_MSG_VERBOSE( " TGCcablingServerSvc retrieved" );
}
sc = TgcCabGet->giveCabling(m_cabling); if (TgcCabGet->giveCabling(cabling).isFailure()) {
if(sc.isFailure()) {
ATH_MSG_FATAL( "Could not get ITGCcablingSvc from the Server !" ); ATH_MSG_FATAL( "Could not get ITGCcablingSvc from the Server !" );
return StatusCode::FAILURE; return nullptr;
} else { }
ATH_MSG_VERBOSE( "ITGCcablingSvc obtained" );
} m_cabling.set (cabling);
m_hid2re.set(m_cabling);
return StatusCode::SUCCESS; return cabling;
} }
std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> Muon::TGC_RawDataProviderToolCore::getROBData(const std::vector<IdentifierHash>& rdoIdhVect) const { std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> Muon::TGC_RawDataProviderToolCore::getROBData(const std::vector<IdentifierHash>& rdoIdhVect) const
{
std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> vecOfRobf; std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> vecOfRobf;
if(!m_cabling) { const ITGCcablingSvc* cabling = getCabling();
ATH_MSG_ERROR("Could not get cabling, return empty vector of ROB fragments"); if(!cabling) {
return vecOfRobf; ATH_MSG_ERROR("Could not get cabling, return empty vector of ROB fragments");
return vecOfRobf;
} }
IdContext tgcContext = m_idHelperSvc->tgcIdHelper().module_context(); IdContext tgcContext = m_idHelperSvc->tgcIdHelper().module_context();
...@@ -116,7 +117,7 @@ std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> Muon::TGC_RawDataPr ...@@ -116,7 +117,7 @@ std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> Muon::TGC_RawDataPr
continue; continue;
} }
const Identifier tgcId = Id; const Identifier tgcId = Id;
uint32_t rodId = m_hid2re.getRodID(tgcId); uint32_t rodId = m_hid2re.getRodID(tgcId, cabling);
uint32_t robId = m_hid2re.getRobID(rodId); uint32_t robId = m_hid2re.getRobID(rodId);
std::vector<uint32_t>::iterator it_robId = std::find(robIds.begin(), robIds.end(), robId); std::vector<uint32_t>::iterator it_robId = std::find(robIds.begin(), robIds.end(), robId);
if(it_robId==robIds.end()) { if(it_robId==robIds.end()) {
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "ByteStreamCnvSvcBase/IROBDataProviderSvc.h" #include "ByteStreamCnvSvcBase/IROBDataProviderSvc.h"
#include "MuonTGC_CnvTools/ITGC_RodDecoder.h" #include "MuonTGC_CnvTools/ITGC_RodDecoder.h"
#include "TGCcablingInterface/ITGCcablingSvc.h" #include "TGCcablingInterface/ITGCcablingSvc.h"
#include "CxxUtils/CachedPointer.h"
class TgcRdoContainer; class TgcRdoContainer;
...@@ -57,11 +58,11 @@ namespace Muon { ...@@ -57,11 +58,11 @@ namespace Muon {
/** ID converter */ /** ID converter */
TGC_Hid2RESrcID m_hid2re; TGC_Hid2RESrcID m_hid2re;
/** TGC cabling Svc */ /** TGC cabling Svc */
const ITGCcablingSvc *m_cabling; CxxUtils::CachedPointer<const ITGCcablingSvc> m_cabling;
/** Rob Data Provider handle */ /** Rob Data Provider handle */
ServiceHandle<IROBDataProviderSvc> m_robDataProvider; ServiceHandle<IROBDataProviderSvc> m_robDataProvider;
StatusCode getCabling(); const ITGCcablingSvc* getCabling() const;
}; };
} // end of namespace } // end of namespace
......
...@@ -83,11 +83,6 @@ StatusCode Muon::TGC_RawDataProviderToolMT::convert(){ ...@@ -83,11 +83,6 @@ StatusCode Muon::TGC_RawDataProviderToolMT::convert(){
StatusCode Muon::TGC_RawDataProviderToolMT::convert(const EventContext& ctx) const StatusCode Muon::TGC_RawDataProviderToolMT::convert(const EventContext& ctx) const
{ {
if(!m_cabling) {
ATH_MSG_ERROR("Tgc cabling is not available and needs to be set in initialise");
return StatusCode::FAILURE;
}
std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> vecOfRobf; std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> vecOfRobf;
const std::vector<uint32_t>& robIds = m_hid2re.allRobIds(); const std::vector<uint32_t>& robIds = m_hid2re.allRobIds();
......
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