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
111 bool dontDoClusterization{false};
112
114 constexpr unsigned int totalNumberOfChannels{6279168};
116 unsigned int totalFiredStrips{0};
117 for (; rdoCollections != rdoCollectionsEnd; ++rdoCollections) {
118 for (const SCT_RDORawData* rdo: **rdoCollections) {
119 totalFiredStrips += rdo->getGroupSize();
120 }
121 }
122
123 rdoCollections = rdoContainer->begin();
124 if (totalFiredStrips > maxAllowableStrips) {
125 ATH_MSG_WARNING(
"This event has too many hits in the SCT: " << totalFiredStrips <<
" > " << maxAllowableStrips);
126 dontDoClusterization = true;
127 }
128 }
129 SG::ReadHandle<InDet::SiDetectorElementStatus> sctDetElStatus;
131 sctDetElStatus=SG::ReadHandle<InDet::SiDetectorElementStatus>(
m_sctDetElStatus, ctx);
132 ATH_CHECK( sctDetElStatus.
isValid() ? StatusCode::SUCCESS : StatusCode::FAILURE);
133 }
134
135 if (not dontDoClusterization) {
136 std::unique_ptr<DataPool<SCT_Cluster>> dataItemsPool = nullptr;
137 const bool hasExternalCache = rdoContainer->hasExternalCache();
138 if (!hasExternalCache) {
139 dataItemsPool = std::make_unique<DataPool<SCT_Cluster>>(ctx);
140 dataItemsPool->reserve(20000);
142 dataItemsPool = std::make_unique<DataPool<SCT_Cluster>>(ctx);
143
144 }
145
146
147
148
149 SCTClusteringCache
cache;
150 cache.currentVector.reserve(32);
151 cache.idGroups.reserve(16);
152 cache.tbinGroups.reserve(16);
154
155 for (; rdoCollections != rdoCollectionsEnd; ++rdoCollections) {
156 const InDetRawDataCollection<SCT_RDORawData>* rd{*rdoCollections};
159 SCT_ClusterContainer::IDC_WriteHandle
lock{
160 clusterContainer->getWriteHandle(rdoCollections.hashId())};
161 if (
lock.OnlineAndPresentInAnotherView()) {
164 continue;
165 }
166 bool goodModule{
171 : true};
176
177 if (!goodModule) {
179 }
180
181
182 if ((not rd->
empty()) and goodModule) {
183
185 unsigned int nFiredStrips{0};
186 for (const SCT_RDORawData* rdo : *rd) {
187 nFiredStrips += rdo->getGroupSize();
188 }
190
191
192 constexpr int value =
194 auto [pPair, inserted] =
195 flaggedCondMap.insert({rd->identifyHash(),
value});
196 if (not inserted) {
197 pPair->second |=
value;
198 }
199 continue;
200 }
201 }
202
203 std::unique_ptr<SCT_ClusterCollection> clusterCollection{
207 cache, dataItemsPool.get(), ctx)};
208 if (clusterCollection) {
209 if (not clusterCollection->empty()) {
210 const IdentifierHash
hash{clusterCollection->identifyHash()};
213 << hash << "' added to Container\n");
214 } else {
216 }
217 } else {
219 }
220 }
221 }
222 } else {
223 SG::ReadHandle<TrigRoiDescriptorCollection> roiCollection{
228 std::vector<IdentifierHash> listOfSCTIds;
229 for (; roi != roiE; ++roi) {
230 listOfSCTIds.clear();
231
233
236 << " det. Elements");
237 for (
size_t i{0};
i < listOfSCTIds.size();
i++) {
238 IdentifierHash
id = listOfSCTIds[
i];
239 const InDetRawDataCollection<SCT_RDORawData>* RDO_Collection{
240 rdoContainer->indexFindPtr(id)};
241 if (RDO_Collection == nullptr){
242 continue;
243 }
244 bool goodModule;
245 {
246 Monitored::ScopedTimer time_SummaryTool(mnt_timer_SummaryTool);
249 ? sctDetElStatus->isGood(id)
251 : true};
255 if (!goodModule){
257 }
258 }
259
260
261 if ((not RDO_Collection->
empty()) and goodModule) {
262
264 unsigned int nFiredStrips{0};
265 for (const SCT_RDORawData* rdo : *RDO_Collection){
266 nFiredStrips += rdo->getGroupSize();
267 }
269
270
271 constexpr int value =
273 auto [pPair, inserted] = flaggedCondMap.insert({
id,
value});
274 if (not inserted) {
275 pPair->second |=
value;
276 }
277 continue;
278 }
279 }
280 }
281
282 SCT_ClusterContainer::IDC_WriteHandle
lock{
283 clusterContainer->getWriteHandle(listOfSCTIds[i])};
284 if (
lock.OnlineAndPresentInAnotherView()) {
285 ATH_MSG_DEBUG(
"Item already in cache , Hash=" << listOfSCTIds[i]);
286 continue;
287 }
288
289
290 {
291 Monitored::ScopedTimer time_Clusterize(mnt_timer_Clusterize);
292 std::unique_ptr<SCT_ClusterCollection> clusterCollection{
296 : nullptr,
297 cache, dataItemsPool.get(), ctx)};
298 if (clusterCollection and (not clusterCollection->empty())) {
299 ATH_MSG_VERBOSE(
"REGTEST: SCT : clusterCollection contains " << clusterCollection->size() <<
" clusters");
301 } else {
303 }
304 }
305 }
306 }
307 }
308 }
309
311
312
313 for (auto [hash, error] : flaggedCondMap) {
314 flaggedCondData->setOrDrop(hash, error);
315 }
316 auto monTime = Monitored::Group(
m_monTool, mnt_timer_Total, mnt_timer_Clusterize, mnt_timer_SummaryTool);
317 return StatusCode::SUCCESS;
318 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
#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?
const IIntersectionCache * cache() const
Retrieve the associated cache block, if it exists.