ATLAS Offline Software
Loading...
Searching...
No Matches
STGC_RawDataProviderToolCore.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include <atomic>
8
9//================ Constructor =================================================
10Muon::STGC_RawDataProviderToolCore::STGC_RawDataProviderToolCore(const std::string& t, const std::string& n, const IInterface* p)
11: AthAlgTool(t, n, p)
12, m_robDataProvider("ROBDataProviderSvc",n)
13{ }
14
15//================ Initialisation ==============================================
17{
18 ATH_CHECK(m_idHelperSvc.retrieve());
19 ATH_CHECK(m_decoder.retrieve());
20 ATH_CHECK(m_robDataProvider.retrieve()); // ROBDataProviderSvc
21 ATH_CHECK(m_rdoContainerKey.initialize());
22
23 m_maxhashtoUse = m_idHelperSvc->stgcIdHelper().module_hash_max();
24 return StatusCode::SUCCESS;
25}
26
27//==============================================================================
29 const std::vector<const ROBFragment*>& vecRobs,
30 const std::vector<IdentifierHash>& rdoIdhVect,
31 STGC_RawDataContainer& stgcRdoContainer) const
32{
33 // Since there can be multiple ROBFragments contributing to the same RDO collection a temporary cache is setup and passed to fillCollection by reference. Once all ROBFragments are processed the collections are added into the rdo container
34 std::unordered_map<IdentifierHash, std::unique_ptr<STGC_RawDataCollection>> rdo_map;
35
36
37 // Loop on the passed ROB fragments, and call the decoder for each one to fill the RDO container.
38 for (const ROBFragment* fragment : vecRobs)
39 ATH_CHECK( m_decoder->fillCollection(ctx, *fragment, rdoIdhVect, rdo_map) ); // always returns StatusCode::SUCCESS
40
41
42 // error counters
43 int nerr_duplicate{0}, nerr_rdo{0};
44
45 // add the RDO collections created from the data of this ROB into the identifiable container.
46 for (auto& [hash, collection]: rdo_map) {
47
48 if ((!collection) or collection->empty()) continue; // skip empty collections
49
50 STGC_RawDataContainer::IDC_WriteHandle lock = stgcRdoContainer.getWriteHandle(hash);
51
52 if (lock.alreadyPresent()) {
53 ++nerr_duplicate;
54 } else if (!lock.addOrDelete(std::move(collection)).isSuccess()) {
55 // since we prevent duplicates above, this error should never happen.
56 ++nerr_rdo;
57 }
58 }
59
60
61 // error summary (to reduce the number of messages)
62 if (nerr_duplicate) ATH_MSG_WARNING(nerr_duplicate << " elinks skipped since the same module hash has been added by a previous ROB fragment");
63 if (nerr_rdo) {
64 ATH_MSG_ERROR("Failed to add "<<nerr_rdo<<" RDOs into the identifiable container");
65 return StatusCode::FAILURE;
66 }
67
68 ATH_MSG_DEBUG("Size of sTgcRdoContainer is " << stgcRdoContainer.size());
69 return StatusCode::SUCCESS;
70}
71
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
StatusCode addOrDelete(std::unique_ptr< T > ptr)
IDC_WriteHandle getWriteHandle(IdentifierHash hash)
size_t size() const
Duplicate of fullSize for backwards compatability.
virtual StatusCode convertIntoContainer(const EventContext &ctx, const std::vector< const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * > &, const std::vector< IdentifierHash > &, STGC_RawDataContainer &) const
Method that converts the ROBFragments into the passed container.
STGC_RawDataProviderToolCore(const std::string &t, const std::string &n, const IInterface *p)
Default constructor.
ToolHandle< ISTGC_ROD_Decoder > m_decoder
Decoder for ROB fragment RDO conversion.
SG::WriteHandleKey< STGC_RawDataContainer > m_rdoContainerKey
RDO container key.
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
Rob Data Provider handle.
virtual StatusCode initialize() override
Standard AlgTool method.
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
The ID helper.
eformat::ROBFragment< PointerType > ROBFragment
Definition RawEvent.h:27