ATLAS Offline Software
MM_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 
8 #include <atomic>
9 #include <memory> //for unique_ptr
10 #include <unordered_map>
11 
13 
14 //================ Constructor =================================================
15 Muon::MM_RawDataProviderToolCore::MM_RawDataProviderToolCore(const std::string& t, const std::string& n, const IInterface* p)
16 : AthAlgTool(t, n, p)
17 , m_robDataProvider("ROBDataProviderSvc",n)
18 { }
19 
20 //================ Initialisation ==============================================
23 {
25  ATH_CHECK(m_idHelperSvc.retrieve());
26  ATH_CHECK(m_decoder.retrieve());
27  ATH_CHECK(m_robDataProvider.retrieve());
28  ATH_CHECK(m_rdoContainerKey.initialize());
29 
30  m_maxhashtoUse = m_idHelperSvc->mmIdHelper().module_hash_max();
31 
32  return StatusCode::SUCCESS;
33 }
34 
35 //==============================================================================
37 Muon::MM_RawDataProviderToolCore::convertIntoContainer(const EventContext& ctx, const std::vector<const ROBFragment*>& vecRobs, const std::vector<IdentifierHash>& rdoIdhVect, MM_RawDataContainer& mmRdoContainer) const
38 {
39  // 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
40 
41 
42  std::unordered_map<IdentifierHash, std::unique_ptr<MM_RawDataCollection>> rdo_map;
43 
44 
45  // Loop on the passed ROB fragments, and call the decoder for each one to fill the RDO container.
46  for (const ROBFragment* fragment : vecRobs)
47  ATH_CHECK( m_decoder->fillCollection(ctx, *fragment, rdoIdhVect, rdo_map) ); // always returns StatusCode::SUCCESS
48 
49  // error counters
50  int nerr_duplicate{0}, nerr_rdo{0};
51 
52  // add the RDO collections created from the data of this ROB into the identifiable container.
53  for (auto& [hash, collection]: rdo_map) {
54 
55  if ((!collection) or collection->empty()) continue; // skip empty collections
56 
58 
59  if (lock.alreadyPresent()) {
60  ++nerr_duplicate;
61  } else if (!lock.addOrDelete(std::move(collection)).isSuccess()) {
62  // since we prevent duplicates above, this error should never happen.
63  ++nerr_rdo;
64  }
65  }
66 
67 
68  // error summary (to reduce the number of messages)
69  if (nerr_duplicate) ATH_MSG_WARNING(nerr_duplicate << " elinks skipped since the same module hash has been added by a previous ROB fragment");
70  if (nerr_rdo){
71  ATH_MSG_ERROR("Failed to add "<<nerr_rdo<<" RDOs into the identifiable container");
72  return StatusCode::FAILURE;
73  }
74 
75  ATH_MSG_DEBUG("Size of mmRdoContainer is " << mmRdoContainer.size());
76  return StatusCode::SUCCESS;
77 }
78 
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
IdentifiableContainerMT::getWriteHandle
IDC_WriteHandle getWriteHandle(IdentifierHash hash)
Definition: IdentifiableContainerMT.h:251
initialize
void initialize()
Definition: run_EoverP.cxx:894
IdentifiableContainerMT::size
size_t size() const
Duplicate of fullSize for backwards compatability.
Definition: IdentifiableContainerMT.h:209
IdentifiableContainerMT::IDC_WriteHandle::alreadyPresent
bool alreadyPresent()
Definition: IdentifiableContainerMT.h:62
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
Muon::MM_RawDataContainer
Definition: MM_RawDataContainer.h:18
Muon::MM_RawDataProviderToolCore::convertIntoContainer
virtual StatusCode convertIntoContainer(const EventContext &ctx, const std::vector< const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * > &, const std::vector< IdentifierHash > &, MM_RawDataContainer &) const
Method that converts the ROBFragments into the passed container.
Definition: MM_RawDataProviderToolCore.cxx:37
Muon::MM_RawDataProviderToolCore::MM_RawDataProviderToolCore
MM_RawDataProviderToolCore(const std::string &t, const std::string &n, const IInterface *p)
Default constructor.
Definition: MM_RawDataProviderToolCore.cxx:15
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
Muon::MM_RawDataProviderToolCore::initialize
virtual StatusCode initialize() override
Standard AlgTool method.
Definition: MM_RawDataProviderToolCore.cxx:22
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
IdentifierHash.h
OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment
eformat::ROBFragment< PointerType > ROBFragment
Definition: RawEvent.h:27
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
MM_RawDataProviderToolCore.h