ATLAS Offline Software
MDT_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 
10 
11 Muon::MDT_RawDataProviderToolMT::MDT_RawDataProviderToolMT(const std::string& t, const std::string& n, const IInterface* p) :
12  base_class(t, n, p) {
13  declareInterface<Muon::IMuonRawDataProviderTool>(this);
14 
15 }
16 
18  ATH_MSG_VERBOSE("Starting init");
19 
20  ATH_MSG_VERBOSE("Getting m_robDataProvider");
21 
22  // Get ROBDataProviderSvc
23  ATH_CHECK(m_robDataProvider.retrieve());
24  ATH_CHECK(m_idHelperSvc.retrieve());
25 
26  ATH_MSG_VERBOSE("Getting m_decoder");
27 
28  // Retrieve decoder
29  ATH_CHECK(m_decoder.retrieve());
30  m_maxhashtoUse = m_idHelperSvc->mdtIdHelper().stationNameIndex("BME") != -1 ? m_idHelperSvc->mdtIdHelper().detectorElement_hash_max()
31  : m_idHelperSvc->mdtIdHelper().module_hash_max();
32 
33  ATH_CHECK(m_rdoContainerKey.initialize());
34  ATH_CHECK(m_readKey.initialize());
35  ATH_CHECK(m_rdoContainerCacheKey.initialize(!m_rdoContainerCacheKey.key().empty()));
36 
37  ATH_MSG_DEBUG("initialize() successful in " << name());
38  return StatusCode::SUCCESS;
39 }
40 
42  const std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*>& vecRobs, MdtCsmContainer& mdtContainer) const {
43  ATH_MSG_VERBOSE("convert(): " << vecRobs.size() << " ROBFragments.");
44 
45  for (const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment* frag : vecRobs) {
46  // convert only if data payload is delivered
47  if (frag->rod_ndata() != 0) {
48  m_decoder->fillCollections(*frag, mdtContainer).ignore();
49  } else {
50  ATH_MSG_DEBUG(" ROB " << MSG::hex << frag->source_id() << " is delivered with an empty payload" );
51  // store the error condition into the StatusCode and continue
52  }
53  }
54  // in presence of errors return FAILURE
55  ATH_MSG_DEBUG("After processing numColls=" << mdtContainer.numberOfCollections());
56  return StatusCode::SUCCESS;
57 }
58 
59 // the new one
60 StatusCode Muon::MDT_RawDataProviderToolMT::convert() const // call decoding function using list of all detector ROBId's
61 {
62  return convert(Gaudi::Hive::currentContext());
63 }
64 
66  const EventContext& ctx) const // call decoding function using list of all detector ROBId's
67 {
68  SG::ReadCondHandle<MuonMDT_CablingMap> readHandle{m_readKey, ctx};
69  const MuonMDT_CablingMap* readCdo{*readHandle};
70  if (!readCdo) {
71  ATH_MSG_ERROR("Null pointer to the read conditions object");
72  return StatusCode::FAILURE;
73  }
74  return convert(readCdo->getAllROBId(), ctx);
75 }
76 
77 StatusCode Muon::MDT_RawDataProviderToolMT::convert(const std::vector<IdentifierHash>& HashVec) const {
78  return convert(HashVec, Gaudi::Hive::currentContext());
79 }
80 
81 StatusCode Muon::MDT_RawDataProviderToolMT::convert(const std::vector<IdentifierHash>& HashVec, const EventContext& ctx) const {
82  SG::ReadCondHandle<MuonMDT_CablingMap> readHandle{m_readKey, ctx};
83  const MuonMDT_CablingMap* readCdo{*readHandle};
84  if (!readCdo) {
85  ATH_MSG_ERROR("Null pointer to the read conditions object");
86  return StatusCode::FAILURE;
87  }
88  return convert(readCdo->getROBId(HashVec, msgStream()), ctx);
89 }
90 
91 StatusCode Muon::MDT_RawDataProviderToolMT::convert(const std::vector<uint32_t>& robIds) const {
92  return convert(robIds, Gaudi::Hive::currentContext());
93 }
94 
95 StatusCode Muon::MDT_RawDataProviderToolMT::convert(const std::vector<uint32_t>& robIds, const EventContext& ctx) const {
96  std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> vecOfRobf;
97  m_robDataProvider->getROBData(ctx, robIds, vecOfRobf);
98  return convert(vecOfRobf, ctx); // using the old one
99 }
100 
101 StatusCode Muon::MDT_RawDataProviderToolMT::convert(const std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*>& vecRobs,
102  const std::vector<IdentifierHash>&) const {
103  return convert(vecRobs, Gaudi::Hive::currentContext());
104 }
105 
106 StatusCode Muon::MDT_RawDataProviderToolMT::convert(const std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*>& vecRobs,
107  const std::vector<IdentifierHash>& /*collection*/, const EventContext& ctx) const {
108  return convert(vecRobs, ctx);
109 }
110 
111 StatusCode Muon::MDT_RawDataProviderToolMT::convert(const std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*>& vecRobs) const {
112  return convert(vecRobs, Gaudi::Hive::currentContext());
113 }
114 
115 StatusCode Muon::MDT_RawDataProviderToolMT::convert(const std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*>& vecRobs,
116  const EventContext& ctx) const {
117  ATH_MSG_VERBOSE("convert(): " << vecRobs.size() << " ROBFragments.");
118 
119  SG::WriteHandle<MdtCsmContainer> rdoContainerHandle(m_rdoContainerKey, ctx);
120 
121  MdtCsmContainer* rdoContainer = nullptr;
122 
123  // here we have two paths. The first one we do not use an external cache, so just create
124  // the MDT CSM container and record it. For the second path, we create the container
125  // by passing in the container cache key so that the container is linked with the event
126  // wide cache.
127  const bool externalCacheRDO = !m_rdoContainerCacheKey.key().empty();
128  if (!externalCacheRDO) {
129  // without the cache we just record the container
130  ATH_CHECK(rdoContainerHandle.record(std::make_unique<MdtCsmContainer>(m_maxhashtoUse)));
131  ATH_MSG_DEBUG("Created container");
132  rdoContainer = rdoContainerHandle.ptr();
133  } else {
134  // use the cache to get the container
135  SG::UpdateHandle<MdtCsm_Cache> update(m_rdoContainerCacheKey, ctx);
136  ATH_CHECK(update.isValid());
137  ATH_CHECK(rdoContainerHandle.record(std::make_unique<MdtCsmContainer>(update.ptr())));
138  ATH_MSG_DEBUG("Created container using cache for " << m_rdoContainerCacheKey.key());
139  rdoContainer = rdoContainerHandle.ptr();
140  }
141 
142  // this should never happen, but since we dereference the pointer we should check it first
143  if (!rdoContainer) {
144  ATH_MSG_ERROR("MdtCsmContainer is null, cannot convert MDT raw data");
145  return StatusCode::FAILURE;
146  }
147 
148  // use the convert function in the MDT_RawDataProviderToolCore class
149  ATH_CHECK(convertIntoContainer(vecRobs, *rdoContainer));
150 
151  return StatusCode::SUCCESS;
152 }
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
Muon::MDT_RawDataProviderToolMT::initialize
virtual StatusCode initialize() override
standard Athena-Algorithm method
Definition: MDT_RawDataProviderToolMT.cxx:17
Muon::MDT_RawDataProviderToolMT::convert
virtual StatusCode convert() const override
the new ones
Definition: MDT_RawDataProviderToolMT.cxx:60
Muon::MDT_RawDataProviderToolMT::convertIntoContainer
virtual StatusCode convertIntoContainer(const std::vector< const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * > &vecRobs, MdtCsmContainer &mdtContainer) const
Convert method.
Definition: MDT_RawDataProviderToolMT.cxx:41
MdtCsmContainer
This container provides acces to the MDT RDOs.
Definition: MdtCsmContainer.h:22
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
MdtCsmContainer.h
IdentifiableContainerMT::empty
bool empty() const
return true if container is empty
Definition: IdentifiableContainerMT.h:244
MuonMDT_CablingMap
Definition: MuonMDT_CablingMap.h:28
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
IdentifiableContainerMT::numberOfCollections
virtual size_t numberOfCollections() const override final
return number of collections
Definition: IdentifiableContainerMT.h:213
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
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
MDT_RawDataProviderToolMT.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
SG::UpdateHandle
Definition: UpdateHandle.h:94
TMVAToMVAUtils::convert
std::unique_ptr< MVAUtils::BDT > convert(TMVA::MethodBDT *bdt, bool isRegression=true, bool useYesNoLeaf=false)
Definition: TMVAToMVAUtils.h:114
MuonDetectorManager.h
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
Muon::MDT_RawDataProviderToolMT::MDT_RawDataProviderToolMT
MDT_RawDataProviderToolMT(const std::string &, const std::string &, const IInterface *)
Definition: MDT_RawDataProviderToolMT.cxx:11
WriteBchToCool.update
update
Definition: WriteBchToCool.py:67
IROBDataProviderSvc.h