Form clusters and record them in StoreGate by WriteHandle.
72 {
73
74 auto mnt_timer_Total = Monitored::Timer<std::chrono::milliseconds>("TIME_Total");
75 auto mnt_timer_SummaryTool = Monitored::Timer<std::chrono::milliseconds>("TIME_SummaryTool");
76 auto mnt_timer_Clusterize = Monitored::Timer<std::chrono::milliseconds>("TIME_Clusterize");
77
81 } else {
83 ATH_CHECK(clusterContainer.
record(std::make_unique<SCT_ClusterContainer>(clusterContainercache.
ptr())));
84 }
86
89 ATH_MSG_DEBUG(
"SCT clusters '" << clusterContainer.
name() <<
"' symlinked in StoreGate");
90
93 ATH_CHECK(flaggedCondData.
record( std::make_unique<IDCInDetBSErrContainer>(
m_idHelper->wafer_hash_max(), std::numeric_limits<IDCInDetBSErrContainer::ErrorCode>::min())));
94 ATH_MSG_DEBUG(
"Created IDCInDetBSErrContainer w/o using external cache");
95 } else {
97 ATH_CHECK(flaggedCondCacheHandle.isValid() );
98 ATH_CHECK(flaggedCondData.
record( std::make_unique<IDCInDetBSErrContainer>(flaggedCondCacheHandle.ptr())) );
99 ATH_MSG_DEBUG(
"Created SCT IDCInDetBSErrContainer using external cache");
100 }
101 std::unordered_map<IdentifierHash, IDCInDetBSErrContainer::ErrorCode> flaggedCondMap;
102
103
104
105
108
109
112 bool dontDoClusterization{false};
113
115 constexpr unsigned int totalNumberOfChannels{6279168};
117 unsigned int totalFiredStrips{0};
118 for (; rdoCollections != rdoCollectionsEnd; ++rdoCollections) {
119 for (const SCT_RDORawData* rdo: **rdoCollections) {
120 totalFiredStrips += rdo->getGroupSize();
121 }
122 }
123
124 rdoCollections = rdoContainer->begin();
125 if (totalFiredStrips > maxAllowableStrips) {
126 ATH_MSG_WARNING(
"This event has too many hits in the SCT: " << totalFiredStrips <<
" > " << maxAllowableStrips);
127 dontDoClusterization = true;
128 }
129 }
130 SG::ReadHandle<InDet::SiDetectorElementStatus> sctDetElStatus;
132 sctDetElStatus=SG::ReadHandle<InDet::SiDetectorElementStatus>(
m_sctDetElStatus, ctx);
133 ATH_CHECK( sctDetElStatus.
isValid() ? StatusCode::SUCCESS : StatusCode::FAILURE);
134 }
135
136 if (not dontDoClusterization) {
137 std::unique_ptr<DataPool<SCT_Cluster>> dataItemsPool = nullptr;
138 const bool hasExternalCache = rdoContainer->hasExternalCache();
139 if (!hasExternalCache) {
140 dataItemsPool = std::make_unique<DataPool<SCT_Cluster>>(ctx);
141 dataItemsPool->reserve(20000);
143 dataItemsPool = std::make_unique<DataPool<SCT_Cluster>>(ctx);
144
145 }
146
147
148
149
150 SCTClusteringCache cache;
151 cache.currentVector.reserve(32);
152 cache.idGroups.reserve(16);
153 cache.tbinGroups.reserve(16);
155
156 for (; rdoCollections != rdoCollectionsEnd; ++rdoCollections) {
157 const InDetRawDataCollection<SCT_RDORawData>* rd{*rdoCollections};
160 SCT_ClusterContainer::IDC_WriteHandle lock{
161 clusterContainer->getWriteHandle(rdoCollections.hashId())};
162 if (lock.OnlineAndPresentInAnotherView()) {
165 continue;
166 }
167 bool goodModule{
172 : true};
177
178 if (!goodModule) {
180 }
181
182
183 if ((not rd->
empty()) and goodModule) {
184
186 unsigned int nFiredStrips{0};
187 for (const SCT_RDORawData* rdo : *rd) {
188 nFiredStrips += rdo->getGroupSize();
189 }
191
192
193 constexpr int value =
195 auto [pPair, inserted] =
196 flaggedCondMap.insert({rd->identifyHash(),
value});
197 if (not inserted) {
198 pPair->second |=
value;
199 }
200 continue;
201 }
202 }
203
204 std::unique_ptr<SCT_ClusterCollection> clusterCollection{
208 cache, dataItemsPool.get(), ctx)};
209 if (clusterCollection) {
210 if (not clusterCollection->empty()) {
211 const IdentifierHash
hash{clusterCollection->identifyHash()};
212 ATH_CHECK(lock.addOrDelete(std::move(clusterCollection)));
214 << hash << "' added to Container\n");
215 } else {
217 }
218 } else {
220 }
221 }
222 }
223 } else {
224 SG::ReadHandle<TrigRoiDescriptorCollection> roiCollection{
229 std::vector<IdentifierHash> listOfSCTIds;
230 for (; roi != roiE; ++roi) {
231 listOfSCTIds.clear();
232
234
237 << " det. Elements");
238 for (
size_t i{0};
i < listOfSCTIds.size();
i++) {
239 IdentifierHash
id = listOfSCTIds[
i];
240 const InDetRawDataCollection<SCT_RDORawData>* RDO_Collection{
241 rdoContainer->indexFindPtr(id)};
242 if (RDO_Collection == nullptr){
243 continue;
244 }
245 bool goodModule;
246 {
247 Monitored::ScopedTimer time_SummaryTool(mnt_timer_SummaryTool);
250 ? sctDetElStatus->isGood(id)
252 : true};
256 if (!goodModule){
258 }
259 }
260
261
262 if ((not RDO_Collection->
empty()) and goodModule) {
263
265 unsigned int nFiredStrips{0};
266 for (const SCT_RDORawData* rdo : *RDO_Collection){
267 nFiredStrips += rdo->getGroupSize();
268 }
270
271
272 constexpr int value =
274 auto [pPair, inserted] = flaggedCondMap.insert({
id,
value});
275 if (not inserted) {
276 pPair->second |=
value;
277 }
278 continue;
279 }
280 }
281 }
282
283 SCT_ClusterContainer::IDC_WriteHandle lock{
284 clusterContainer->getWriteHandle(listOfSCTIds[i])};
285 if (lock.OnlineAndPresentInAnotherView()) {
286 ATH_MSG_DEBUG(
"Item already in cache , Hash=" << listOfSCTIds[i]);
287 continue;
288 }
289
290
291 {
292 Monitored::ScopedTimer time_Clusterize(mnt_timer_Clusterize);
293 std::unique_ptr<SCT_ClusterCollection> clusterCollection{
297 : nullptr,
298 cache, dataItemsPool.get(), ctx)};
299 if (clusterCollection and (not clusterCollection->empty())) {
300 ATH_MSG_VERBOSE(
"REGTEST: SCT : clusterCollection contains " << clusterCollection->size() <<
" clusters");
301 ATH_CHECK(lock.addOrDelete(std::move(clusterCollection)));
302 } else {
304 }
305 }
306 }
307 }
308 }
309 }
310
312
313
314 for (auto [hash, error] : flaggedCondMap) {
315 flaggedCondData->setOrDrop(hash, error);
316 }
317 auto monTime = Monitored::Group(
m_monTool, mnt_timer_Total, mnt_timer_Clusterize, mnt_timer_SummaryTool);
318 return StatusCode::SUCCESS;
319 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define VALIDATE_STATUS_ARRAY(use_info, info_val, summary_val)
DataModel_detail::const_iterator< DataVector > const_iterator
size_type size() const noexcept
Returns the number of elements in the collection.
bool empty() const noexcept
Returns true if the collection is empty.
virtual IdentifierHash identifyHash() const override final
BooleanProperty m_checkBadModules
ToolHandle< ISCT_ClusteringTool > m_clusteringTool
ToolHandle< GenericMonitoringTool > m_monTool
BooleanProperty m_roiSeeded
const SCT_ID * m_idHelper
SG::WriteHandleKey< SiClusterContainer > m_clusterContainerLinkKey
ToolHandle< IInDetConditionsTool > m_pSummaryTool
SG::ReadHandleKey< SCT_RDO_Container > m_rdoContainerKey
SG::UpdateHandleKey< IDCInDetBSErrContainer_Cache > m_flaggedCondCacheKey
For HLT cache.
SG::WriteHandleKey< IDCInDetBSErrContainer > m_flaggedCondDataKey
ToolHandle< IRegSelTool > m_regionSelector
SG::ReadHandleKey< InDet::SiDetectorElementStatus > m_sctDetElStatus
Optional read handle to get status data to test whether a SCT detector element is good.
UnsignedIntegerProperty m_maxTotalOccupancyPercent
Gaudi::Property< bool > m_useDataPoolWithCache
SG::WriteHandleKey< SCT_ClusterContainer > m_clusterContainerKey
UnsignedIntegerProperty m_maxFiredStrips
SG::UpdateHandleKey< SCT_ClusterContainerCache > m_clusterContainerCacheKey
For HLT cache.
SG::ReadHandleKey< TrigRoiDescriptorCollection > m_roiCollectionKey
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
pointer_type ptr()
Dereference the pointer.
StatusCode setConst()
Set the 'const' bit for the bound proxy in the store.
const std::string & name() const
Return the StoreGate ID for the referenced object.
StatusCode symLink(const WriteHandleKey< U > &key)
Make an explicit link.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
virtual bool isValid() override final
Can the handle be successfully dereferenced?