ATLAS Offline Software
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 =================================================
10 Muon::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 
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 
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
IdentifiableContainerMT::getWriteHandle
IDC_WriteHandle getWriteHandle(IdentifierHash hash)
Definition: IdentifiableContainerMT.h:251
Muon::STGC_RawDataProviderToolCore::convertIntoContainer
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.
Definition: STGC_RawDataProviderToolCore.cxx:28
IdentifiableContainerMT::size
size_t size() const
Duplicate of fullSize for backwards compatability.
Definition: IdentifiableContainerMT.h:209
Muon::STGC_RawDataContainer
Definition: STGC_RawDataContainer.h:18
IdentifiableContainerMT::IDC_WriteHandle::alreadyPresent
bool alreadyPresent()
Definition: IdentifiableContainerMT.h:62
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
STGC_RawDataProviderToolCore.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
eformat::ROBFragment
Definition: L1CaloBsDecoderUtil.h:12
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
IdentifiableContainerMT::IDC_WriteHandle
Definition: IdentifiableContainerMT.h:34
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Muon::STGC_RawDataProviderToolCore::STGC_RawDataProviderToolCore
STGC_RawDataProviderToolCore(const std::string &t, const std::string &n, const IInterface *p)
Default constructor.
Definition: STGC_RawDataProviderToolCore.cxx:10
OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment
eformat::ROBFragment< PointerType > ROBFragment
Definition: RawEvent.h:27
Muon::STGC_RawDataProviderToolCore::initialize
virtual StatusCode initialize() override
Standard AlgTool method.
Definition: STGC_RawDataProviderToolCore.cxx:16
IdentifiableContainerMT::IDC_WriteHandle::addOrDelete
StatusCode addOrDelete(std::unique_ptr< T > ptr)
Definition: IdentifiableContainerMT.h:56
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
AthAlgTool
Definition: AthAlgTool.h:26