ATLAS Offline Software
Loading...
Searching...
No Matches
CSC_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// CSC_RawDataProviderToolMT.cxx, (c) ATLAS Detector software
8
10
20
22
23//================ Constructor =================================================
24
25Muon::CSC_RawDataProviderToolMT::CSC_RawDataProviderToolMT(const std::string& t, const std::string& n, const IInterface* p) :
26 base_class(t, n, p) {
27 declareProperty("CscContainerCacheKey", m_rdoContainerCacheKey, "Optional external cache for the CSC container");
28}
29
30//================ Destructor =================================================
31
33
34//================ Initialisation =================================================
35
37 // call initialize from base class
39
40 // Initialise the container cache if available
42
43 ATH_CHECK(m_idHelperSvc.retrieve());
44
45 return StatusCode::SUCCESS;
46}
47
48//============================================================================================
49
50// new one
51
52StatusCode Muon::CSC_RawDataProviderToolMT::convert(const std::vector<IdentifierHash>& rdoIdhVect) const {
53 return this->convert(rdoIdhVect, Gaudi::Hive::currentContext());
54}
55
56StatusCode Muon::CSC_RawDataProviderToolMT::convert(const std::vector<IdentifierHash>& rdoIdhVect, const EventContext& ctx) const {
57 IdContext cscContext = m_idHelperSvc->cscIdHelper().module_context();
58
59 std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> vecOfRobf;
60 std::vector<uint32_t> robIds;
61
62 for (unsigned int i = 0; i < rdoIdhVect.size(); ++i) {
63 uint32_t rob_id = 0xffff;
64 m_cabling->hash2RobFull(rdoIdhVect[i], rob_id);
65 robIds.push_back(rob_id);
66 }
67 m_robDataProvider->getROBData(ctx, robIds, vecOfRobf);
68 ATH_MSG_VERBOSE("Number of ROB fragments " << vecOfRobf.size());
69
70 // This would be passed to the function which does not use the IdentifierHash further
71 return convert(vecOfRobf, ctx);
72}
73
74StatusCode Muon::CSC_RawDataProviderToolMT::convert(const EventContext& ctx) const {
75 std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> vecOfRobf;
76 const std::vector<uint32_t>& robIds = m_hid2re.allRobIds();
77 ATH_MSG_VERBOSE("Number of ROB ids " << robIds.size());
78 // ask ROBDataProviderSvc for the vector of ROBFragment for all MDT ROBIDs
79 m_robDataProvider->getROBData(ctx, robIds, vecOfRobf);
80 ATH_MSG_VERBOSE("Number of ROB fragments " << vecOfRobf.size());
81
82 return convert(vecOfRobf, ctx);
83}
84
85StatusCode Muon::CSC_RawDataProviderToolMT::convert(const ROBFragmentList& vecRobs,
86 const std::vector<IdentifierHash>& /* collections */) const {
87 return this->convert(vecRobs, Gaudi::Hive::currentContext());
88}
89
90StatusCode Muon::CSC_RawDataProviderToolMT::convert(const ROBFragmentList& vecRobs, const EventContext& ctx) const {
91 SG::WriteHandle<CscRawDataContainer> rdoContainerHandle(m_containerKey, ctx);
92
93 // Split the methods to have one where we use the cache and one where we just setup the container
94 const bool externalCacheRDO = !m_rdoContainerCacheKey.key().empty();
95 if (!externalCacheRDO) {
96 ATH_CHECK(rdoContainerHandle.record(std::make_unique<CscRawDataContainer>(m_idHelperSvc->cscIdHelper().module_hash_max())));
97 ATH_MSG_DEBUG("Created CSCRawDataContainer");
98 } else {
100 ATH_CHECK(update.isValid());
101 ATH_CHECK(rdoContainerHandle.record(std::make_unique<CscRawDataContainer>(update.ptr())));
102 ATH_MSG_DEBUG("Created container using cache for " << m_rdoContainerCacheKey.key());
103 }
104
105 CscRawDataContainer* container = rdoContainerHandle.ptr();
106
107 if (!container) {
108 ATH_MSG_ERROR("CSC RDO container pointer is null, cannot decode data");
109 return StatusCode::FAILURE;
110 }
111
112 // call conversion function from the base class
113 ATH_CHECK(convertIntoContainer(vecRobs, ctx, *container));
114
115 return StatusCode::SUCCESS;
116}
#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)
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.
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition IdContext.h:26
virtual StatusCode initialize() override
standard Athena-Algorithm method
virtual StatusCode convert() const override
virtual StatusCode convert(const ROBFragmentList &vecRobs, const std::vector< IdentifierHash > &) const override
SG::UpdateHandleKey< CscRawDataCollection_Cache > m_rdoContainerCacheKey
CSC container cache key.
virtual ~CSC_RawDataProviderToolMT()
default destructor
CSC_RawDataProviderToolMT(const std::string &t, const std::string &n, const IInterface *p)
virtual StatusCode initialize() override
standard Athena-Algorithm method
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