ATLAS Offline Software
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 
14 #include "ByteStreamData/ROBData.h"
18 #include "StoreGate/ReadHandle.h"
19 #include "StoreGate/WriteHandle.h"
20 
22 
23 //================ Constructor =================================================
24 
25 Muon::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
41  ATH_CHECK(m_rdoContainerCacheKey.initialize(!m_rdoContainerCacheKey.key().empty()));
42 
43  ATH_CHECK(m_idHelperSvc.retrieve());
44 
45  return StatusCode::SUCCESS;
46 }
47 
48 //============================================================================================
49 
50 // new one
51 
52 StatusCode Muon::CSC_RawDataProviderToolMT::convert(const std::vector<IdentifierHash>& rdoIdhVect) const {
53  return this->convert(rdoIdhVect, Gaudi::Hive::currentContext());
54 }
55 
56 StatusCode 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(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 
74 StatusCode 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(robIds, vecOfRobf);
80  ATH_MSG_VERBOSE("Number of ROB fragments " << vecOfRobf.size());
81 
82  return convert(vecOfRobf, ctx);
83 }
84 
86  const std::vector<IdentifierHash>& /* collections */) const {
87  return this->convert(vecRobs, Gaudi::Hive::currentContext());
88 }
89 
90 StatusCode 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 {
99  SG::UpdateHandle<CscRawDataCollection_Cache> update(m_rdoContainerCacheKey, ctx);
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 }
CscIdHelper.h
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
CSC_RawDataProviderToolMT.h
ROBData.h
Defines the ROB data entity. The ROB data is an abstract entity that is used to discase the raw event...
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
Muon::CSC_RawDataProviderToolMT::CSC_RawDataProviderToolMT
CSC_RawDataProviderToolMT(const std::string &t, const std::string &n, const IInterface *p)
Definition: CSC_RawDataProviderToolMT.cxx:25
Muon::CSC_RawDataProviderToolMT::~CSC_RawDataProviderToolMT
virtual ~CSC_RawDataProviderToolMT()
default destructor
WriteHandle.h
Handle class for recording to StoreGate.
Muon::CSC_RawDataProviderToolMT::m_rdoContainerCacheKey
SG::UpdateHandleKey< CscRawDataCollection_Cache > m_rdoContainerCacheKey
CSC container cache key.
Definition: CSC_RawDataProviderToolMT.h:53
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:92
Muon::CSC_RawDataProviderToolCore::initialize
virtual StatusCode initialize() override
standard Athena-Algorithm method
Definition: CSC_RawDataProviderToolCore.cxx:25
beamspotman.n
n
Definition: beamspotman.py:731
RawEvent.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Muon::CSC_RawDataProviderToolMT::convert
virtual StatusCode convert() const override
Definition: CSC_RawDataProviderToolMT.h:38
ByteStreamAddress.h
SG::UpdateHandle
Definition: UpdateHandle.h:94
OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment
eformat::ROBFragment< PointerType > ROBFragment
Definition: RawEvent.h:27
TMVAToMVAUtils::convert
std::unique_ptr< MVAUtils::BDT > convert(TMVA::MethodBDT *bdt, bool isRegression=true, bool useYesNoLeaf=false)
Definition: TMVAToMVAUtils.h:114
MuonDetectorManager.h
Muon::CSC_RawDataProviderToolMT::initialize
virtual StatusCode initialize() override
standard Athena-Algorithm method
Definition: CSC_RawDataProviderToolMT.cxx:36
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
dqt_zlumi_pandas.update
update
Definition: dqt_zlumi_pandas.py:42
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
CscRawDataContainer
This container provides access to collections of CSC RDOs and a mechanism for recording them.
Definition: CscRawDataContainer.h:23
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
ByteStreamCnvSvcBase.h
ReadHandle.h
Handle class for reading from StoreGate.
IdContext
class IdContext
Definition: IdContext.h:34
IROBDataProviderSvc.h