ATLAS Offline Software
Loading...
Searching...
No Matches
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
6
7#include "AthViews/View.h"
9
11MuonPRDCacheCreator::MuonPRDCacheCreator(const std::string& name, ISvcLocator* pSvcLocator) :
12 IDCCacheCreatorBase(name, pSvcLocator),
13 m_CscCacheKey(""),
15 m_MdtCacheKey(""),
16 m_RpcCacheKey(""),
18 m_MmCacheKey(""),
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
92StatusCode 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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
unsigned bcTag(unsigned bcBitMap)
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
IDCCacheCreatorBase(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
StatusCode checkInsideViewOnce(const EventContext &) const
StatusCode createContainer(const SG::WriteHandleKey< T > &, long unsigned int, const EventContext &) const
SG::WriteHandleKey< CscPrepDataCollection_Cache > m_CscCacheKey
Write handle keys for the PRD caches.
virtual StatusCode execute(const EventContext &ctx) const override
Execture the algorithm.
MuonPRDCacheCreator(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
virtual StatusCode initialize() override
Initialize the algorithm.
Gaudi::Property< std::string > m_tgcPrdCacheKeyStr
Name for the TGC PRD cache containers.
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
SG::WriteHandleKeyArray< TgcCoinDataCollection_Cache > m_TgcCoinCacheKeys
SG::WriteHandleKey< MMPrepDataCollection_Cache > m_MmCacheKey
SG::WriteHandleKey< CscStripPrepDataCollection_Cache > m_CscStripCacheKey
Gaudi::Property< std::string > m_tgcCoinCacheKeyStr
Name for the TGC Coin cache containers.
SG::WriteHandleKey< RpcCoinDataCollection_Cache > m_RpcCoinCacheKey
SG::WriteHandleKey< RpcPrepDataCollection_Cache > m_RpcCacheKey
SG::WriteHandleKeyArray< TgcPrepDataCollection_Cache > m_TgcCacheKeys
SG::WriteHandleKey< MdtPrepDataCollection_Cache > m_MdtCacheKey
SG::WriteHandleKey< sTgcPrepDataCollection_Cache > m_sTgcCacheKey
@ BC_NEXT
Definition TgcDigit.h:37
@ BC_PREVIOUS
Definition TgcDigit.h:37
@ BC_NEXTNEXT
Definition TgcDigit.h:37