ATLAS Offline Software
RPC_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 
8 #include "GaudiKernel/ServiceHandle.h"
9 #include "GaudiKernel/ThreadLocalContext.h"
10 
12 
13 Muon::RPC_RawDataProviderToolMT::RPC_RawDataProviderToolMT(const std::string& t, const std::string& n, const IInterface* p) :
14  base_class(t, n, p) {
15 }
16 
19 
20  ATH_CHECK(m_rdoContainerCacheKey.initialize(!m_rdoContainerCacheKey.key().empty()));
21  ATH_CHECK(m_idHelperSvc.retrieve());
22 
23  // We should only turn off the sector logic when running with cached data a la trigger mode
24  if (!m_rdoContainerCacheKey.key().empty() && m_WriteOutRpcSectorLogic) {
26  "Cannot write out RpcSectorLogic while running with cached RpcPad containers"
27  " as the RpcSectorLogic is not cached at the same time and the written containers will desync."
28  " Please turn off RpcSectorLogic writing when running with cached bytestream container");
29  return StatusCode::FAILURE;
30  }
31 
32  ATH_MSG_INFO("initialize() successful in " << name());
33 
34  return StatusCode::SUCCESS;
35 }
36 
37 // the new one
38 StatusCode Muon::RPC_RawDataProviderToolMT::convert() const { return this->convert(Gaudi::Hive::currentContext()); }
39 
40 StatusCode Muon::RPC_RawDataProviderToolMT::convert(const EventContext& ctx) const {
41  SG::ReadCondHandle<RpcCablingCondData> readHandle{m_readKey, ctx};
42  const RpcCablingCondData* readCdo{*readHandle};
43  // CALLGRIND_START_INSTRUMENTATION
45  std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> vecOfRobf;
46  std::vector<uint32_t> robIds = readCdo->giveFullListOfRobIds();
47  m_robDataProvider->getROBData(robIds, vecOfRobf);
48  // CALLGRIND_STOP_INSTRUMENTATION
49  return convert(vecOfRobf, ctx); // using the old one
50 }
51 // the old one
52 StatusCode Muon::RPC_RawDataProviderToolMT::convert(const ROBFragmentList& vecRobs) const {
53  return this->convert(vecRobs, Gaudi::Hive::currentContext());
54 }
55 
56 StatusCode Muon::RPC_RawDataProviderToolMT::convert(const ROBFragmentList& vecRobs, const EventContext& ctx) const {
57  // CALLGRIND_START_INSTRUMENTATION
58  std::vector<IdentifierHash> collections;
59  // CALLGRIND_STOP_INSTRUMENTATION
60  return convert(vecRobs, collections, ctx);
61 }
62 
63 // the new one
64 StatusCode Muon::RPC_RawDataProviderToolMT::convert(const std::vector<uint32_t>& robIds) const {
65  return this->convert(robIds, Gaudi::Hive::currentContext());
66 }
67 
68 StatusCode Muon::RPC_RawDataProviderToolMT::convert(const std::vector<uint32_t>& robIds, const EventContext& ctx) const {
69  // CALLGRIND_START_INSTRUMENTATION
70  std::vector<IdentifierHash> collections;
71  std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> vecOfRobf;
72  m_robDataProvider->getROBData(robIds, vecOfRobf);
73  // CALLGRIND_STOP_INSTRUMENTATION
74  return convert(vecOfRobf, collections, ctx);
75 }
76 
77 // the new one
78 StatusCode Muon::RPC_RawDataProviderToolMT::convert(const std::vector<IdentifierHash>& rdoIdhVect) const {
79  return this->convert(rdoIdhVect, Gaudi::Hive::currentContext());
80 }
81 
82 StatusCode Muon::RPC_RawDataProviderToolMT::convert(const std::vector<IdentifierHash>& rdoIdhVect, const EventContext& ctx) const {
83  SG::ReadCondHandle<RpcCablingCondData> readHandle{m_readKey, ctx};
84  const RpcCablingCondData* readCdo{*readHandle};
85  // CALLGRIND_START_INSTRUMENTATION
86  std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> vecOfRobf;
87  std::vector<uint32_t> robIds;
88  CHECK(readCdo->giveROB_fromRDO(rdoIdhVect, robIds));
89  m_robDataProvider->getROBData(robIds, vecOfRobf);
90  // CALLGRIND_STOP_INSTRUMENTATION
91  return convert(vecOfRobf, rdoIdhVect, ctx); // using the old one
92 }
93 // the old one
94 StatusCode Muon::RPC_RawDataProviderToolMT::convert(const ROBFragmentList& vecRobs, const std::vector<IdentifierHash>& collections) const {
95  return this->convert(vecRobs, collections, Gaudi::Hive::currentContext());
96 }
97 
98 StatusCode Muon::RPC_RawDataProviderToolMT::convert(const ROBFragmentList& vecRobs, const std::vector<IdentifierHash>& collections,
99  const EventContext& ctx) const {
100  // CALLGRIND_START_INSTRUMENTATION
101 
102  SG::WriteHandle<RpcPadContainer> rdoContainerHandle(m_containerKey, ctx);
103  SG::WriteHandle<RpcSectorLogicContainer> logicHandle(m_sec, ctx);
104 
105  // run 3 mode, here we always try to write the containers
106 
107  // Split the methods to have one where we use the cache and one where we just setup the container
108  const bool externalCacheRDO = !m_rdoContainerCacheKey.key().empty();
109  if (!externalCacheRDO) {
110  ATH_CHECK(rdoContainerHandle.record(std::make_unique<RpcPadContainer>(m_idHelperSvc->rpcIdHelper().module_hash_max())));
111  ATH_MSG_DEBUG("Created RpcPadContainer");
112  } else {
113  SG::UpdateHandle<RpcPad_Cache> update(m_rdoContainerCacheKey, ctx);
114  ATH_CHECK(update.isValid());
115  ATH_CHECK(rdoContainerHandle.record(std::make_unique<RpcPadContainer>(update.ptr())));
116  ATH_MSG_DEBUG("Created container using cache for " << m_rdoContainerCacheKey.key());
117  }
118  RpcPadContainer* pad = rdoContainerHandle.ptr();
119 
120  RpcSectorLogicContainer* logic = nullptr;
121  if (m_WriteOutRpcSectorLogic) {
122  ATH_MSG_DEBUG("Writing out RpcSectorLogicContainer");
123  ATH_CHECK(logicHandle.record(std::make_unique<RpcSectorLogicContainer>()));
124  logic = logicHandle.ptr();
125  }
126 
127  // pass the containers to the convertIntoContainers function in the RPC_RawDataProviderToolCore base class
128  ATH_CHECK(convertIntoContainers(vecRobs, collections, pad, logic, true));
129 
130  return StatusCode::SUCCESS;
131 }
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
RpcCablingCondData
Definition: RpcCablingCondData.h:21
RPC_RawDataProviderToolMT.h
Muon::RPC_RawDataProviderToolCore::initialize
virtual StatusCode initialize() override
Definition: RPC_RawDataProviderToolCore.cxx:14
Muon::RPC_RawDataProviderToolMT::RPC_RawDataProviderToolMT
RPC_RawDataProviderToolMT(const std::string &t, const std::string &n, const IInterface *p)
Definition: RPC_RawDataProviderToolMT.cxx:13
Muon::RPC_RawDataProviderToolMT::initialize
virtual StatusCode initialize() override
Definition: RPC_RawDataProviderToolMT.cxx:17
Muon::RPC_RawDataProviderToolMT::convert
virtual StatusCode convert() const override
the new ones
Definition: RPC_RawDataProviderToolMT.cxx:38
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
RpcSectorLogicContainer
Definition: RpcSectorLogicContainer.h:20
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
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
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.
RpcCablingCondData::giveFullListOfRobIds
const std::vector< uint32_t > & giveFullListOfRobIds() const
Definition: RpcCablingCondData.cxx:108
IROBDataProviderSvc.h
RpcPadContainer
Use IdentifiableContainer with RpcPad.
Definition: RpcPadContainer.h:23