ATLAS Offline Software
MuonPRDCacheCreator.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 #include "MuonPRDCacheCreator.h"
6 
7 #include "AthViews/View.h"
9 
11 MuonPRDCacheCreator::MuonPRDCacheCreator(const std::string& name, ISvcLocator* pSvcLocator) :
12  IDCCacheCreatorBase(name, pSvcLocator),
13  m_CscCacheKey(""),
14  m_CscStripCacheKey(""),
15  m_MdtCacheKey(""),
16  m_RpcCacheKey(""),
17  m_sTgcCacheKey(""),
18  m_MmCacheKey(""),
19  m_RpcCoinCacheKey("") {
20  declareProperty("CscCacheKey", m_CscCacheKey);
21  declareProperty("CscStripCacheKey", m_CscStripCacheKey);
22  declareProperty("MdtCacheKey", m_MdtCacheKey);
23  declareProperty("RpcCacheKey", m_RpcCacheKey);
24  declareProperty("sTgcCacheKey", m_sTgcCacheKey);
25  declareProperty("MmCacheKey", m_MmCacheKey);
26  declareProperty("RpcCoinCacheKey", m_RpcCoinCacheKey);
27  declareProperty("DisableViewWarning", m_disableWarning);
28 }
29 
38 
39  // build the TGC PRD and Coin cache keys (multiple due to reading out multiple BC)
40  const bool doTgcPrdCache = not m_tgcPrdCacheKeyStr.empty();
41  if (doTgcPrdCache) {
43  for (int ibc = 0; ibc < TgcDigit::BC_NEXT + 1; ibc++) {
44  const int bcTag = ibc + 1;
45  std::ostringstream location;
46  location << m_tgcPrdCacheKeyStr.value() << (bcTag == TgcDigit::BC_PREVIOUS ? "PriorBC" : "")
47  << (bcTag == TgcDigit::BC_NEXT ? "NextBC" : "") << (bcTag == (TgcDigit::BC_NEXT + 1) ? "AllBCs" : "");
48  m_TgcCacheKeys.at(ibc) = location.str();
49  ATH_MSG_INFO("Setting next TGC PRD Cache to " << location.str());
50  }
51  }
52  const bool doTgcCoinCache = not m_tgcCoinCacheKeyStr.empty();
53  if (doTgcCoinCache) {
55  for (int ibc = 0; ibc < TgcDigit::BC_NEXTNEXT; ibc++) {
56  const int bcTag = ibc + 1;
57  std::ostringstream location;
58  location << m_tgcCoinCacheKeyStr.value() << (bcTag == TgcDigit::BC_PREVIOUS ? "PriorBC" : "")
59  << (bcTag == TgcDigit::BC_NEXT ? "NextBC" : "") << (bcTag == TgcDigit::BC_NEXTNEXT ? "NextNextBC" : "");
60  m_TgcCoinCacheKeys.at(ibc) = location.str();
61  ATH_MSG_INFO("Setting next TGC Coin Cache to " << location.str());
62  } // BC loop
63  }
64  ATH_CHECK(m_TgcCacheKeys.initialize(doTgcPrdCache));
65  ATH_CHECK(m_TgcCoinCacheKeys.initialize(doTgcCoinCache));
66 
67  ATH_CHECK(m_idHelperSvc.retrieve());
68 
69  // Check we have the tools to allow us to setup cache
70  if (!m_idHelperSvc->hasCSC() && !m_CscCacheKey.key().empty()) {
71  ATH_MSG_WARNING("CSC ID Helper is not available and CSC PRD cache was requested - This will not be created");
72  }
73  if (!m_idHelperSvc->hasMDT() && !m_MdtCacheKey.key().empty()) {
74  ATH_MSG_WARNING("MDT ID Helper is not available and MDT PRD cache was requested - This will not be created");
75  }
76  if (!m_idHelperSvc->hasRPC() && !m_RpcCacheKey.key().empty()) {
77  ATH_MSG_WARNING("RPC ID Helper is not available and RPC PRD cache was requested - This will not be created");
78  }
79  if (!m_idHelperSvc->hasTGC() && (doTgcPrdCache || doTgcCoinCache)) {
80  ATH_MSG_WARNING("TGC ID Helper is not available and TGC cache was requested - This will not be created");
81  }
82  if (!m_idHelperSvc->hasSTGC() && !m_sTgcCacheKey.key().empty()) {
83  ATH_MSG_WARNING("STGC ID Helper is not available and STGC PRD cache was requested - This will not be created");
84  }
85  if (!m_idHelperSvc->hasMM() && !m_MmCacheKey.key().empty()) {
86  ATH_MSG_WARNING("MM ID Helper is not available and MM PRD cache was requested - This will not be created");
87  }
88  if (m_disableWarning) m_disableWarningCheck.test_and_set(std::memory_order_relaxed);
89  return StatusCode::SUCCESS;
90 }
91 
92 StatusCode MuonPRDCacheCreator::execute(const EventContext& ctx) const {
94 
95  // Create all the cache containers (if the tools are available)
96  // CSC
97  if (m_idHelperSvc->hasCSC()) {
98  ATH_CHECK(createContainer(m_CscCacheKey, m_idHelperSvc->cscIdHelper().module_hash_max(), ctx));
99  ATH_CHECK(createContainer(m_CscStripCacheKey, m_idHelperSvc->cscIdHelper().module_hash_max(), ctx));
100  }
101 
102  // MDT
103  if (m_idHelperSvc->hasMDT()) {
104  auto maxHashMDTs = m_idHelperSvc->mdtIdHelper().stationNameIndex("BME") != -1
105  ? m_idHelperSvc->mdtIdHelper().detectorElement_hash_max()
106  : m_idHelperSvc->mdtIdHelper().module_hash_max();
107  ATH_CHECK(createContainer(m_MdtCacheKey, maxHashMDTs, ctx));
108  }
109 
110  // RPC
111  if (m_idHelperSvc->hasRPC()) {
112  ATH_CHECK(createContainer(m_RpcCacheKey, m_idHelperSvc->rpcIdHelper().module_hash_max(), ctx));
113  ATH_CHECK(createContainer(m_RpcCoinCacheKey, m_idHelperSvc->rpcIdHelper().module_hash_max(), ctx));
114  }
115 
116  // TGC
117  if (m_idHelperSvc->hasTGC()) {
118  for (const auto& tgcCacheKey : m_TgcCacheKeys) {
119  ATH_CHECK(createContainer(tgcCacheKey, m_idHelperSvc->tgcIdHelper().module_hash_max(), ctx));
120  }
121  for (const auto& tgcCoinCacheKey : m_TgcCoinCacheKeys) {
122  ATH_CHECK(createContainer(tgcCoinCacheKey, m_idHelperSvc->tgcIdHelper().module_hash_max(), ctx));
123  }
124  }
125 
126  // NSW STGC
127  if (m_idHelperSvc->hasSTGC()) { ATH_CHECK(createContainer(m_sTgcCacheKey, m_idHelperSvc->stgcIdHelper().module_hash_max(), ctx)); }
128 
129  // NSW MM
130  if (m_idHelperSvc->hasMM()) { ATH_CHECK(createContainer(m_MmCacheKey, m_idHelperSvc->mmIdHelper().module_hash_max(), ctx)); }
131 
132  return StatusCode::SUCCESS;
133 }
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
MuonPRDCacheCreator::m_RpcCoinCacheKey
SG::WriteHandleKey< RpcCoinDataCollection_Cache > m_RpcCoinCacheKey
Definition: MuonPRDCacheCreator.h:36
IDCCacheCreatorBase::createContainer
StatusCode createContainer(const SG::WriteHandleKey< T > &, long unsigned int, const EventContext &) const
Definition: IDCCacheCreatorBase.h:31
MuonPRDCacheCreator.h
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
MuonPRDCacheCreator::m_MdtCacheKey
SG::WriteHandleKey< MdtPrepDataCollection_Cache > m_MdtCacheKey
Definition: MuonPRDCacheCreator.h:31
IDCCacheCreatorBase::checkInsideViewOnce
StatusCode checkInsideViewOnce(const EventContext &) const
Definition: IDCCacheCreatorBase.cxx:21
TgcDigit::BC_PREVIOUS
@ BC_PREVIOUS
Definition: TgcDigit.h:37
MuonPRDCacheCreator::initialize
virtual StatusCode initialize() override
Initialize the algorithm.
Definition: MuonPRDCacheCreator.cxx:30
MuonPRDCacheCreator::m_CscStripCacheKey
SG::WriteHandleKey< CscStripPrepDataCollection_Cache > m_CscStripCacheKey
Definition: MuonPRDCacheCreator.h:30
MuonPRDCacheCreator::MuonPRDCacheCreator
MuonPRDCacheCreator(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition: MuonPRDCacheCreator.cxx:11
MuonPRDCacheCreator::m_tgcCoinCacheKeyStr
Gaudi::Property< std::string > m_tgcCoinCacheKeyStr
Name for the TGC Coin cache containers.
Definition: MuonPRDCacheCreator.h:42
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
python.sizes.location
string location
Definition: sizes.py:11
TgcDigit.h
TgcDigit::BC_NEXT
@ BC_NEXT
Definition: TgcDigit.h:37
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MuonPRDCacheCreator::m_sTgcCacheKey
SG::WriteHandleKey< sTgcPrepDataCollection_Cache > m_sTgcCacheKey
Definition: MuonPRDCacheCreator.h:34
MuonPRDCacheCreator::m_RpcCacheKey
SG::WriteHandleKey< RpcPrepDataCollection_Cache > m_RpcCacheKey
Definition: MuonPRDCacheCreator.h:32
MuonPRDCacheCreator::m_MmCacheKey
SG::WriteHandleKey< MMPrepDataCollection_Cache > m_MmCacheKey
Definition: MuonPRDCacheCreator.h:35
TgcDigit::BC_NEXTNEXT
@ BC_NEXTNEXT
Definition: TgcDigit.h:37
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
MuonPRDCacheCreator::m_TgcCoinCacheKeys
SG::WriteHandleKeyArray< TgcCoinDataCollection_Cache > m_TgcCoinCacheKeys
Definition: MuonPRDCacheCreator.h:37
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
MuonPRDCacheCreator::m_CscCacheKey
SG::WriteHandleKey< CscPrepDataCollection_Cache > m_CscCacheKey
Write handle keys for the PRD caches.
Definition: MuonPRDCacheCreator.h:29
bcTag
unsigned bcTag(unsigned bcBitMap)
Definition: TgcByteStreamData.h:367
IDCCacheCreatorBase
Definition: IDCCacheCreatorBase.h:13
MuonPRDCacheCreator::m_tgcPrdCacheKeyStr
Gaudi::Property< std::string > m_tgcPrdCacheKeyStr
Name for the TGC PRD cache containers.
Definition: MuonPRDCacheCreator.h:40
View.h
MuonPRDCacheCreator::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: MuonPRDCacheCreator.h:44
MuonPRDCacheCreator::m_TgcCacheKeys
SG::WriteHandleKeyArray< TgcPrepDataCollection_Cache > m_TgcCacheKeys
Definition: MuonPRDCacheCreator.h:33
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
MuonPRDCacheCreator::execute
virtual StatusCode execute(const EventContext &ctx) const override
Execture the algorithm.
Definition: MuonPRDCacheCreator.cxx:92
MuonPRDCacheCreator::m_disableWarning
bool m_disableWarning
Definition: MuonPRDCacheCreator.h:46