ATLAS Offline Software
Loading...
Searching...
No Matches
CSC_RawDataProviderTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
16
18
19namespace Muon{
20
21//================ Destructor =================================================
22
24
25//================ Initialisation =================================================
26
28 ATH_CHECK(m_cabling.retrieve());
29 ATH_CHECK(m_robDataProvider.retrieve());
30 ATH_MSG_INFO("Retrieved service " << m_robDataProvider);
31
32 ATH_CHECK(m_idHelperSvc.retrieve());
33 m_hid2re.set(m_cabling.get(), &m_idHelperSvc->cscIdHelper());
34
35 // Retrieve decoder
36 ATH_CHECK(m_decoder.retrieve());
37 ATH_MSG_INFO("Retrieved tool " << m_decoder);
38
39 ATH_CHECK(m_containerKey.initialize());
40 ATH_CHECK(m_eventInfoKey.initialize());
41
42 // Initialise the container cache if available
44
45 ATH_MSG_INFO("initialize() successful in " << name());
46 return StatusCode::SUCCESS;
47}
48
49//============================================================================================
50
52 const ROBFragmentList& vecRobs, const EventContext& ctx) const {
53 std::set<uint32_t> robIdSet;
54
55 SG::WriteHandle rdoContainerHandle{m_containerKey, ctx};
56
57 // Split the methods to have one where we use the cache and one where we just setup the container
58 const bool externalCacheRDO = !m_rdoContainerCacheKey.key().empty();
59 if (!externalCacheRDO) {
60 ATH_CHECK(rdoContainerHandle.record(std::make_unique<CscRawDataContainer>(m_idHelperSvc->cscIdHelper().module_hash_max())));
61 ATH_MSG_DEBUG("Created CSCRawDataContainer");
62 } else {
64 ATH_CHECK(update.isValid());
65 ATH_CHECK(rdoContainerHandle.record(std::make_unique<CscRawDataContainer>(update.ptr())));
66 ATH_MSG_DEBUG("Created container using cache for " << m_rdoContainerCacheKey.key());
67 }
68
69 CscRawDataContainer* container = rdoContainerHandle.ptr();
70
71 if (!container) {
72 ATH_MSG_ERROR("CSC RDO container pointer is null, cannot decode data");
73 return StatusCode::FAILURE;
74 }
75 const xAOD::EventInfo* eventInfo{nullptr};
76 ATH_CHECK(SG::get(eventInfo, m_eventInfoKey, ctx));
77
78 ATH_MSG_DEBUG("Before processing numColls=" << container->numberOfCollections());
79
80 ATH_MSG_DEBUG("vector of ROB ID to decode: size = " << vecRobs.size());
81
82 for (const ROBFragment* frag : vecRobs) {
83 uint32_t robid = frag->rod_source_id();
84
85 // check if this ROBFragment was already decoded (EF case in ROIs
86 if (!robIdSet.insert(robid).second) {
87 ATH_MSG_DEBUG(" ROB Fragment with ID " << std::hex << robid << std::dec << " already decoded, skip");
88 } else {
89 m_decoder->fillCollection(*eventInfo, *frag, *container);
90 }
91 }
92
93 ATH_MSG_DEBUG("After processing numColls=" << container->numberOfCollections());
94
95 return StatusCode::SUCCESS;
96}
97
98//============================================================================================
99// New EventContext-based convert methods
100
101StatusCode CSC_RawDataProviderTool::convert(const std::vector<IdentifierHash>& rdoIdhVect,
102 const EventContext& ctx) const {
103 ROBFragmentList vecOfRobf;
104 std::vector<uint32_t> robIds;
105
106 for (unsigned int i = 0; i < rdoIdhVect.size(); ++i) {
107 uint32_t rob_id = 0xffff;
108 m_cabling->hash2RobFull(rdoIdhVect[i], rob_id);
109 robIds.push_back(rob_id);
110 }
111 m_robDataProvider->getROBData(ctx, robIds, vecOfRobf);
112 ATH_MSG_VERBOSE("Number of ROB fragments " << vecOfRobf.size());
113
114 // This would be passed to the function which does not use the IdentifierHash further
115 return convertIntoContainer(vecOfRobf, ctx);
116}
117
118StatusCode CSC_RawDataProviderTool::convert(const EventContext& ctx) const {
119 return convert(m_hid2re.allRobIds(), ctx);
120}
121
122StatusCode CSC_RawDataProviderTool::convert(const std::vector<uint32_t>& robIds,
123 const EventContext& ctx) const {
124 ROBFragmentList vecOfRobf;
125
126 ATH_MSG_VERBOSE("Number of ROB ids " << robIds.size());
127 // ask ROBDataProviderSvc for the vector of ROBFragment for all CSC ROBIDs
128 m_robDataProvider->getROBData(ctx, robIds, vecOfRobf);
129 ATH_MSG_VERBOSE("Number of ROB fragments " << vecOfRobf.size());
130
131 return convertIntoContainer(vecOfRobf, ctx);
132
133}
134}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
Defines the ROB data entity. The ROB data is an abstract entity that is used to decouple the raw even...
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
This container provides access to collections of CSC RDOs and a mechanism for recording them.
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
ServiceHandle< CSCcablingSvc > m_cabling
ToolHandle< ICSC_ROD_Decoder > m_decoder
member variables for algorithm properties:
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
virtual StatusCode convert(const EventContext &ctx) const override
virtual ~CSC_RawDataProviderTool()
default destructor
StatusCode convertIntoContainer(const ROBFragmentList &vecRobs, const EventContext &ctx) const
function to decode the passed ROB fragments into the passed container
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
SG::WriteHandleKey< CscRawDataContainer > m_containerKey
virtual StatusCode initialize() override
standard Athena-Algorithm method
SG::UpdateHandleKey< CscRawDataCollection_Cache > m_rdoContainerCacheKey
CSC container cache key.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
eformat::ROBFragment< PointerType > ROBFragment
Definition RawEvent.h:27
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
EventInfo_v1 EventInfo
Definition of the latest event info version.