ATLAS Offline Software
Loading...
Searching...
No Matches
MDT_RawDataProviderToolMT.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
6
10
11Muon::MDT_RawDataProviderToolMT::MDT_RawDataProviderToolMT(const std::string& t, const std::string& n, const IInterface* p) :
12 base_class(t, n, p) {
13 declareInterface<Muon::IMuonRawDataProviderTool>(this);
14
15}
16
18 ATH_MSG_VERBOSE("Starting init");
19
20 ATH_MSG_VERBOSE("Getting m_robDataProvider");
21
22 // Get ROBDataProviderSvc
23 ATH_CHECK(m_robDataProvider.retrieve());
24 ATH_CHECK(m_idHelperSvc.retrieve());
25
26 ATH_MSG_VERBOSE("Getting m_decoder");
27
28 // Retrieve decoder
29 ATH_CHECK(m_decoder.retrieve());
30 m_maxhashtoUse = m_idHelperSvc->mdtIdHelper().stationNameIndex("BME") != -1 ? m_idHelperSvc->mdtIdHelper().detectorElement_hash_max()
31 : m_idHelperSvc->mdtIdHelper().module_hash_max();
32
33 ATH_CHECK(m_rdoContainerKey.initialize());
34 ATH_CHECK(m_readKey.initialize());
36
37 ATH_MSG_DEBUG("initialize() successful in " << name());
38 return StatusCode::SUCCESS;
39}
40
42 const std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*>& vecRobs, MdtCsmContainer& mdtContainer) const {
43 ATH_MSG_VERBOSE("convert(): " << vecRobs.size() << " ROBFragments.");
44
45 for (const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment* frag : vecRobs) {
46 // convert only if data payload is delivered
47 if (frag->rod_ndata() != 0) {
48 m_decoder->fillCollections(*frag, mdtContainer).ignore();
49 } else {
50 ATH_MSG_DEBUG(" ROB " << MSG::hex << frag->source_id() << " is delivered with an empty payload" );
51 // store the error condition into the StatusCode and continue
52 }
53 }
54 // in presence of errors return FAILURE
55 ATH_MSG_DEBUG("After processing numColls=" << mdtContainer.numberOfCollections());
56 return StatusCode::SUCCESS;
57}
58
59// the new one
60StatusCode Muon::MDT_RawDataProviderToolMT::convert() const // call decoding function using list of all detector ROBId's
61{
62 return convert(Gaudi::Hive::currentContext());
63}
64
66 const EventContext& ctx) const // call decoding function using list of all detector ROBId's
67{
69 const MuonMDT_CablingMap* readCdo{*readHandle};
70 if (!readCdo) {
71 ATH_MSG_ERROR("Null pointer to the read conditions object");
72 return StatusCode::FAILURE;
73 }
74 return convert(readCdo->getAllROBId(), ctx);
75}
76
77StatusCode Muon::MDT_RawDataProviderToolMT::convert(const std::vector<IdentifierHash>& HashVec) const {
78 return convert(HashVec, Gaudi::Hive::currentContext());
79}
80
81StatusCode Muon::MDT_RawDataProviderToolMT::convert(const std::vector<IdentifierHash>& HashVec, const EventContext& ctx) const {
83 const MuonMDT_CablingMap* readCdo{*readHandle};
84 if (!readCdo) {
85 ATH_MSG_ERROR("Null pointer to the read conditions object");
86 return StatusCode::FAILURE;
87 }
88 return convert(readCdo->getROBId(HashVec, msgStream()), ctx);
89}
90
91StatusCode Muon::MDT_RawDataProviderToolMT::convert(const std::vector<uint32_t>& robIds) const {
92 return convert(robIds, Gaudi::Hive::currentContext());
93}
94
95StatusCode Muon::MDT_RawDataProviderToolMT::convert(const std::vector<uint32_t>& robIds, const EventContext& ctx) const {
96 std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> vecOfRobf;
97 m_robDataProvider->getROBData(ctx, robIds, vecOfRobf);
98 return convert(vecOfRobf, ctx); // using the old one
99}
100
101StatusCode Muon::MDT_RawDataProviderToolMT::convert(const std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*>& vecRobs,
102 const std::vector<IdentifierHash>&) const {
103 return convert(vecRobs, Gaudi::Hive::currentContext());
104}
105
106StatusCode Muon::MDT_RawDataProviderToolMT::convert(const std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*>& vecRobs,
107 const std::vector<IdentifierHash>& /*collection*/, const EventContext& ctx) const {
108 return convert(vecRobs, ctx);
109}
110
111StatusCode Muon::MDT_RawDataProviderToolMT::convert(const std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*>& vecRobs) const {
112 return convert(vecRobs, Gaudi::Hive::currentContext());
113}
114
115StatusCode Muon::MDT_RawDataProviderToolMT::convert(const std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*>& vecRobs,
116 const EventContext& ctx) const {
117 ATH_MSG_VERBOSE("convert(): " << vecRobs.size() << " ROBFragments.");
118
120
121 MdtCsmContainer* rdoContainer = nullptr;
122
123 // here we have two paths. The first one we do not use an external cache, so just create
124 // the MDT CSM container and record it. For the second path, we create the container
125 // by passing in the container cache key so that the container is linked with the event
126 // wide cache.
127 const bool externalCacheRDO = !m_rdoContainerCacheKey.key().empty();
128 if (!externalCacheRDO) {
129 // without the cache we just record the container
130 ATH_CHECK(rdoContainerHandle.record(std::make_unique<MdtCsmContainer>(m_maxhashtoUse)));
131 ATH_MSG_DEBUG("Created container");
132 rdoContainer = rdoContainerHandle.ptr();
133 } else {
134 // use the cache to get the container
136 ATH_CHECK(update.isValid());
137 ATH_CHECK(rdoContainerHandle.record(std::make_unique<MdtCsmContainer>(update.ptr())));
138 ATH_MSG_DEBUG("Created container using cache for " << m_rdoContainerCacheKey.key());
139 rdoContainer = rdoContainerHandle.ptr();
140 }
141
142 // this should never happen, but since we dereference the pointer we should check it first
143 if (!rdoContainer) {
144 ATH_MSG_ERROR("MdtCsmContainer is null, cannot convert MDT raw data");
145 return StatusCode::FAILURE;
146 }
147
148 // use the convert function in the MDT_RawDataProviderToolCore class
149 ATH_CHECK(convertIntoContainer(vecRobs, *rdoContainer));
150
151 return StatusCode::SUCCESS;
152}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
virtual size_t numberOfCollections() const override final
return number of collections
This container provides acces to the MDT RDOs.
const ListOfROB & getAllROBId() const
return the ROD id of a given chamber
uint32_t getROBId(const IdentifierHash &stationCode, MsgStream &log) const
return the ROD id of a given chamber, given the hash id
virtual StatusCode convert() const override
the new ones
virtual StatusCode convert(const std::vector< const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * > &vecRobs) const override
Convert method - declared in Muon::IMuonRdoToPrepDataTool.
SG::UpdateHandleKey< MdtCsm_Cache > m_rdoContainerCacheKey
This is the key for the cache for the CSM containers, can be empty.
MDT_RawDataProviderToolMT(const std::string &, const std::string &, const IInterface *)
SG::ReadCondHandleKey< MuonMDT_CablingMap > m_readKey
virtual StatusCode initialize() override
standard Athena-Algorithm method
virtual StatusCode convertIntoContainer(const std::vector< const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * > &vecRobs, MdtCsmContainer &mdtContainer) const
Convert method.
ToolHandle< MdtROD_Decoder > m_decoder
SG::WriteHandleKey< MdtCsmContainer > m_rdoContainerKey
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
eformat::ROBFragment< PointerType > ROBFragment
Definition RawEvent.h:27