ATLAS Offline Software
Loading...
Searching...
No Matches
RDOReaderDoubleSelector.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
14
15// Silicon trackers includes
17
19
20//InDetRawData includes
27
28// Event includes
30
31// DetDescr includes
33
34// Id includes
38
39// test includes
42
43// Gaudi includes
44#include "GaudiKernel/MsgStream.h"
45#include "GaudiKernel/SmartDataPtr.h"
46
47// test includes
48#include <map>
49
50// Constructor with parameters:
52 , ISvcLocator *pSvcLocator)
53 : AthAlgorithm(name, pSvcLocator)
54 , m_pixelId(nullptr)
55 , m_sctId(nullptr)
56 , m_trtId(nullptr)
57 , m_calocellId(nullptr)
58{}
59
60// Initialize method:
62{
63 ATH_MSG_INFO("RDOReaderDoubleSelector::initialize()" );
64
65 ATH_CHECK( detStore()->retrieve(m_pixelId, "PixelID") );
66 ATH_CHECK( detStore()->retrieve(m_sctId, "SCT_ID") );
67 ATH_CHECK( detStore()->retrieve(m_trtId, "TRT_ID") );
68
69 ATH_CHECK( detStore()->retrieve(m_calocellId, "CaloCell_ID") );
70 ATH_CHECK(m_caloMgrKey.initialize());
71
72 return StatusCode::SUCCESS;
73}
74
75// Execute method:
77{
78 ATH_MSG_DEBUG("RDOReaderDoubleSelector::execute()" );
79
84 return StatusCode::SUCCESS;
85}
86
88{
89 ATH_MSG_DEBUG("RDOReaderDoubleSelector::checkPixel()" );
90
91 const PixelRDO_Container* pixCont = nullptr;
92 ATH_CHECK( evtStore()->retrieve(pixCont, "PixelRDOs") );
93
94 // loop on all RDO collections read in and check them
95 int nmatch = 0;
96 bool error = false;
98 IdContext cntx = m_pixelId->wafer_context();
99
100 ATH_MSG_DEBUG("PixelRDO_Container size "
101 << pixCont->size() << " " );
102
103 // Check for non-zero length of container
104 if (pixCont->begin() == pixCont->end()) {
105 ATH_MSG_ERROR("Container '" << "PixelRDOs" << "' is EMPTY !" );
106 return StatusCode::FAILURE;
107 }
108
109 for (PixelRDO_Container::const_iterator it = pixCont->begin() ;
110 it != pixCont->end() ; ++it) {
111
112 const InDetRawDataCollection<PixelRDORawData>* RDO_Collection(&(**it));
113
114 ATH_MSG_DEBUG("Read RDO collection: size, ids "
115 << RDO_Collection->size() << " "
116 << m_pixelId->show_to_string(RDO_Collection->identify(), &cntx) << " "
117 << MSG::hex << (unsigned int)RDO_Collection->identifyHash() << MSG::dec );
118
119 // create a new pixel RDO collection
120 MsgStream log(msgSvc(), name());
122 creator.createPixelRawDataColl(RDO_Collection->identifyHash(), m_pixelId, msg());
123
124 ATH_MSG_DEBUG("Test RDO collection: size, ids "
125 << rdocoll->size() << " "
126 << m_pixelId->show_to_string(rdocoll->identify(), &cntx) << " "
127 << MSG::hex << (unsigned int)rdocoll->identifyHash() << MSG::dec );
128
129
130 // Use one of the specific clustering AlgTools to make clusters
131 //typedef InDetRawDataCollection<Pixel1RawData> RDO1_Collection_type;
132 typedef InDetRawDataCollection<PixelRDORawData> RDO_Collection_type;
133
134 // loop on all RDOs
135 RDO_Collection_type::const_iterator nextRDO = RDO_Collection->begin();
136 RDO_Collection_type::const_iterator lastRDO = RDO_Collection->end();
137 RDO_Collection_type::const_iterator nextRDO1 = rdocoll->begin();
138 RDO_Collection_type::const_iterator lastRDO1 = rdocoll->end();
139 for (; nextRDO != lastRDO && nextRDO1 != lastRDO1 ; ++nextRDO, ++nextRDO1) {
140 // Look for match
141 if (((*nextRDO)->identify() != (*nextRDO1)->identify()) ||
142 ((*nextRDO)->getWord() != (*nextRDO1)->getWord())) {
143
144 ATH_MSG_ERROR("RDO's do NOT match: ids, word "
145 << m_pixelId->show_to_string((*nextRDO)->identify()) << " "
146 << m_pixelId->show_to_string((*nextRDO1)->identify()) << " "
147 << MSG::hex << (*nextRDO)->getWord() << " "
148 << MSG::hex << (*nextRDO1)->getWord() << " "
149 );
150 error = true;
151 }
152 else {
153 nmatch++;
154 }
155 }
156 ATH_MSG_DEBUG("Matching RDOs " << nmatch );
157
158 delete rdocoll;
159 }
160
161 // print out pixel element links
162 // Retrieve the element link vector
163 const PixelRDOElemLinkVec* linkVec = nullptr;
164 ATH_CHECK( evtStore()->retrieve(linkVec, "PixelRDOELs") );
165
166 ATH_MSG_DEBUG("PixelRDOElemLinkVec found with "
167 << linkVec->pixelRDOs().size()
168 << " RDOs " );
169 for (unsigned int i = 0; i < linkVec->pixelRDOs().size(); ++i) {
170 // Print out rdos from element link
171 PixelRDOElemLinkVec::elem_type rdo = linkVec->pixelRDOs()[i];
172 const PixelRDORawData* ncrdo = *rdo;
173 ATH_MSG_DEBUG("RDO ID=" << m_pixelId->show_to_string((*rdo)->identify())
174 << "RDO ToT=" << ncrdo->getToT() );
175 }
176
177
178 if (error) {
179 ATH_MSG_INFO("ERROR reading and checking Pixel RDO collections " );
180 }
181 else {
182 ATH_MSG_INFO("Successfully read and checked Pixel RDO collections " );
183 }
184
185 return StatusCode::SUCCESS;
186}
187
189{
190 ATH_MSG_DEBUG("RDOReaderDoubleSelector::checkSCT()" );
191
192 const SCT_RDO_Container* sctCont = nullptr;
193 ATH_CHECK( evtStore()->retrieve(sctCont, "SCT_RDOs") );
194
195 // loop on all RDO collections read in and check them
196 int nmatch = 0;
197 bool error = false;
199 IdContext cntx = m_sctId->wafer_context();
200
201 ATH_MSG_DEBUG("SCT_RDO_Container size "
202 << sctCont->size() << " " );
203
204 // Check for non-zero length of container
205 if (sctCont->begin() == sctCont->end()) {
206 ATH_MSG_ERROR("Container '" << "SCT_RDOs" << "' is EMPTY !" );
207 return StatusCode::FAILURE;
208 }
209
210 for (SCT_RDO_Container::const_iterator it = sctCont->begin() ;
211 it != sctCont->end() ; ++it) {
212
213 const InDetRawDataCollection<SCT_RDORawData>* RDO_Collection(&(**it));
214
215 ATH_MSG_DEBUG("Read RDO collection: size, ids "
216 << RDO_Collection->size() << " "
217 << m_sctId->show_to_string(RDO_Collection->identify(), &cntx) << " "
218 << MSG::hex << (unsigned int)RDO_Collection->identifyHash() << MSG::dec );
219
220 // create a new sct RDO collection
221 MsgStream log(msgSvc(), name());
223 creator.createSCT_RawDataColl(RDO_Collection->identifyHash(), m_sctId, msg());
224
225 ATH_MSG_DEBUG("Test RDO collection: size, ids "
226 << rdocoll->size() << " "
227 << m_sctId->show_to_string(rdocoll->identify(), &cntx) << " "
228 << MSG::hex << (unsigned int)rdocoll->identifyHash() << MSG::dec );
229
230
231 // Use one of the specific clustering AlgTools to make clusters
232 typedef InDetRawDataCollection<SCT_RDORawData> RDO_Collection_type;
233
234 // loop on all RDOs
235 RDO_Collection_type::const_iterator nextRDO = RDO_Collection->begin();
236 RDO_Collection_type::const_iterator lastRDO = RDO_Collection->end();
237 RDO_Collection_type::const_iterator nextRDO1 = rdocoll->begin();
238 RDO_Collection_type::const_iterator lastRDO1 = rdocoll->end();
239 for (; nextRDO != lastRDO && nextRDO1 != lastRDO1 ; ++nextRDO, ++nextRDO1) {
240 // Look for match
241 if (((*nextRDO)->identify() != (*nextRDO1)->identify()) ||
242 ((*nextRDO)->getGroupSize() != (*nextRDO1)->getGroupSize())) {
243
244 ATH_MSG_ERROR("RDO's do NOT match: ids, group, strip "
245 << m_sctId->show_to_string((*nextRDO)->identify()) << " "
246 << m_sctId->show_to_string((*nextRDO1)->identify()) << " "
247 << MSG::hex
248 << (*nextRDO)->getGroupSize() << " "
249 << (*nextRDO1)->getGroupSize() << " "
250 << MSG::dec
251 );
252 error = true;
253 }
254 else {
255 nmatch++;
256 }
257 }
258 ATH_MSG_DEBUG("Matching RDOs " << nmatch );
259
260 delete rdocoll;
261 }
262
263 if (error) {
264 ATH_MSG_INFO("ERROR reading and checking SCT RDO collections " );
265 }
266 else {
267 ATH_MSG_INFO("Successfully read and checked SCT RDO collections " );
268 }
269
270 return StatusCode::SUCCESS;
271}
272
274{
275 ATH_MSG_DEBUG("RDOReaderDoubleSelector::checkTRT()" );
276
277 const TRT_RDO_Container* trtCont = nullptr;
278 ATH_CHECK( evtStore()->retrieve(trtCont, "TRT_RDOs") );
279
280 // loop on all RDO collections read in and check them
281 int nmatch = 0;
282 bool error = false;
284 IdContext cntx = m_trtId->straw_layer_context();
285
286 ATH_MSG_DEBUG("TRT_RDO_Container size "
287 << trtCont->size() << " " );
288
289 // Check for non-zero length of container
290 if (trtCont->begin() == trtCont->end()) {
291 ATH_MSG_ERROR("Container '" << "TRT_RDOs"
292 << "' is EMPTY !" );
293 return StatusCode::FAILURE;
294 }
295
296 for (TRT_RDO_Container::const_iterator it = trtCont->begin() ;
297 it != trtCont->end() ; ++it) {
298
299 const InDetRawDataCollection<TRT_RDORawData>* RDO_Collection(&(**it));
300
301 ATH_MSG_DEBUG("Read RDO collection: size, ids "
302 << RDO_Collection->size() << " "
303 << m_trtId->show_to_string(RDO_Collection->identify(), &cntx) << " "
304 << MSG::hex << (unsigned int)RDO_Collection->identifyHash() << MSG::dec );
305
306 // create a new trt RDO collection
307 MsgStream log(msgSvc(), name());
309 creator.createTRT_RawDataColl(RDO_Collection->identifyHash(), m_trtId, msg());
310
311 ATH_MSG_DEBUG("Test RDO collection: size, ids "
312 << rdocoll->size() << " "
313 << m_trtId->show_to_string(rdocoll->identify(), &cntx) << " "
314 << MSG::hex << (unsigned int)rdocoll->identifyHash() << MSG::dec );
315
316
317 // Use one of the specific clustering AlgTools to make clusters
318 typedef InDetRawDataCollection<TRT_RDORawData> RDO_Collection_type;
319
320 // loop on all RDOs
321 RDO_Collection_type::const_iterator nextRDO = RDO_Collection->begin();
322 RDO_Collection_type::const_iterator lastRDO = RDO_Collection->end();
323 RDO_Collection_type::const_iterator nextRDO1 = rdocoll->begin();
324 RDO_Collection_type::const_iterator lastRDO1 = rdocoll->end();
325 for (; nextRDO != lastRDO && nextRDO1 != lastRDO1 ; ++nextRDO, ++nextRDO1) {
326 // Look for match
327 if (((*nextRDO)->identify() != (*nextRDO1)->identify()) ||
328 ((*nextRDO)->highLevel() != (*nextRDO1)->highLevel()) ||
329 ((*nextRDO)->timeOverThreshold() != (*nextRDO1)->timeOverThreshold()) ||
330 ((*nextRDO)->driftTimeBin() != (*nextRDO1)->driftTimeBin())) {
331
332 ATH_MSG_ERROR("RDO's do NOT match: ids, highlvl, TOT, drift "
333 << m_trtId->show_to_string((*nextRDO)->identify()) << " "
334 << m_trtId->show_to_string((*nextRDO1)->identify()) << " "
335 << MSG::hex
336 << (*nextRDO)->highLevel() << " "
337 << (*nextRDO1)->highLevel() << " "
338 << (*nextRDO)->timeOverThreshold() << " "
339 << (*nextRDO1)->timeOverThreshold() << " "
340 << (*nextRDO)->driftTimeBin() << " "
341 << (*nextRDO1)->driftTimeBin() << " "
342 << MSG::dec
343 );
344 error = true;
345 }
346 else {
347 nmatch++;
348 }
349 }
350 ATH_MSG_DEBUG("Matching RDOs " << nmatch );
351
352 delete rdocoll;
353 }
354
355 if (error) {
356 ATH_MSG_INFO("ERROR reading and checking TRT RDO collections " );
357 }
358 else {
359 ATH_MSG_INFO("Successfully read and checked TRT RDO collections " );
360 }
361
362 return StatusCode::SUCCESS;
363}
364
366{
367 ATH_MSG_DEBUG("RDOReaderDoubleSelector::checkCells()" );
368
369 // Retrieve container
370 const CaloCellContainer* caloCont = nullptr;
371 ATH_CHECK( evtStore()->retrieve(caloCont, "CaloCellCont1") );
372 ATH_MSG_DEBUG( "Container '" << "CaloCellCont"
373 << "' retrieved from StoreGate" );
374
376 ATH_CHECK(caloMgrHandle.isValid());
377
379
380 // Create container
381 MsgStream log(msgSvc(), name());
382 const CaloCellContainer* caloCont1 = creator.createCaloCellContainer(m_calocellId,
383 *caloMgrHandle,
384 msg());
385
386 CaloCellContainer::const_iterator first = caloCont->begin();
387 CaloCellContainer::const_iterator last = caloCont->end();
388 CaloCellContainer::const_iterator first1 = caloCont1->begin();
389 CaloCellContainer::const_iterator last1 = caloCont1->end();
390
391 bool error = false;
392 int ncells = 0;
393 int ncellErrs = 0;
394
395 for (; first != last && first1 != last1; ++first, ++first1) {
396 if (((*first)->ID() != (*first1)->ID()) ||
397 (fabs((*first)->energy() - (*first1)->energy() ) > 0.01 * fabs((*first)->energy())) ||
398 (fabs((*first)->time() - (*first1)->time() ) > 0.0002 * fabs((*first)->time())) ||
399 (std::abs((*first)->quality() - (*first1)->quality() ) > 0) ||
400 (std::abs((*first)->provenance() - (*first1)->provenance() ) > 0) ||
401 (fabs((*first)->eta() - (*first1)->eta() ) > 0.0000001) ||
402 (fabs((*first)->phi() - (*first1)->phi() ) > 0.0000001)) {
403 ATH_MSG_ERROR("CaloCell1,2 differ: id "
404 << m_calocellId->show_to_string((*first)->ID())
405 << m_calocellId->show_to_string((*first1)->ID())
406 << " energy " << (*first)->energy() << " "
407 << (*first1)->energy()
408 << " time " << (*first)->time() << " "
409 << (*first1)->time()
410 << " quality " << (*first)->quality() << " "
411 << (*first1)->quality()
412 << " provenance " << (*first)->provenance() << " "
413 << (*first1)->provenance()
414 << " eta " << (*first)->eta() << " "
415 << (*first1)->eta()
416 << " phi " << (*first)->phi() << " "
417 << (*first1)->phi());
418 error = true;
419 ncellErrs++;
420 }
421 ncells++;
422 }
423
424 printCells(caloCont);
425
426 if (error) {
427 ATH_MSG_ERROR("Errors: " << ncellErrs );
428 return StatusCode::FAILURE;
429 }
430 else {
431 ATH_MSG_INFO("Successful check of CaloCellContainer I/O. Cells read: " << ncells );
432 }
433 return StatusCode::SUCCESS;
434}
435
436// Print cells
438{
439
440 ATH_MSG_INFO("RDOReaderDoubleSelector::printRDOs()" );
441
442 // loop on all cells
443
444 CaloCellContainer::const_iterator first = caloCont->begin();
445 CaloCellContainer::const_iterator last = caloCont->end();
446
447 for (; first != last; ++first) {
448
449 ATH_MSG_DEBUG("CaloCell: id "
450 << m_calocellId->show_to_string((*first)->ID())
451 << std::setprecision(5)
452 << " energy " << (*first)->energy()
453 << " time " << (*first)->time()
454 << " quality " << (*first)->quality()
455 << " provenance " << (*first)->provenance()
456 << " eta " << (*first)->eta()
457 << " phi " << (*first)->phi()
458 );
459 }
460
461 ATH_MSG_DEBUG("RDOReaderDoubleSelector::printCells() end" );
462
463}
464
465
466// Finalize method:
468{
469 ATH_MSG_INFO("RDOReaderDoubleSelector::finalize()" );
470 return StatusCode::SUCCESS;
471}
472
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Class which encapsulates the creation of an InDetRawDataCollection.
Create a CaloCellContainer with LArCells for POOL I/O tests algs.
This is an Identifier helper class for the Pixel subdetector.
Class definition for PixelRDOElemLinkVec.
InDetRawDataContainer< InDetRawDataCollection< PixelRDORawData > > PixelRDO_Container
Test Algorithm for POOL I/O, reads InDetRawData and CaloCells from transient store.
This is an Identifier helper class for the SCT subdetector.
InDetRawDataContainer< InDetRawDataCollection< SCT_RDORawData > > SCT_RDO_Container
This is an Identifier helper class for the TRT subdetector.
InDetRawDataContainer< InDetRawDataCollection< TRT_RDORawData > > TRT_RDO_Container
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
const ServiceHandle< StoreGateSvc > & detStore() const
MsgStream & msg() const
Container class for CaloCell.
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition IdContext.h:26
const_iterator end() const
return const_iterator for end of container
size_t size() const
Duplicate of fullSize for backwards compatability.
const_iterator begin() const
return const_iterator for first entry
virtual Identifier identify() const override final
virtual IdentifierHash identifyHash() const override final
Class which encapsulates the creation of an InDetRawDataCollection.
const InDetRawDataCollection< PixelRDORawData > * createPixelRawDataColl(IdentifierHash hashId, const PixelID *pixelId, MsgStream &log)
Create PixelRawDataCollection.
const InDetRawDataCollection< SCT_RDORawData > * createSCT_RawDataColl(IdentifierHash hashId, const SCT_ID *sctId, MsgStream &log)
Create SCT_RawDataCollection.
const InDetRawDataCollection< TRT_RDORawData > * createTRT_RawDataColl(IdentifierHash hashId, const TRT_ID *trtId, MsgStream &log)
Create TRT_RawDataCollection.
Create a CaloCellContainer with LArCells for POOL I/O tests algs.
CaloCellContainer * createCaloCellContainer(const CaloCell_ID *calocellId, const CaloDetDescrManager *caloMgr, MsgStream &log) const
Create a CaloCellContainer with LAr cells.
vector containing element links to pixel RDOs
const std::vector< elem_type > & pixelRDOs() const
ElementLink< cont_type > elem_type
virtual int getToT() const =0
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
Need DD mgr to create cells.
const TRT_ID * m_trtId
IDhelper for creating objects.
StatusCode checkPixel() const
Compare objects read with newly created ones.
StatusCode checkCells() const
Compare objects read with newly created ones.
virtual StatusCode finalize() override
Algorithm finalize at end of job.
const PixelID * m_pixelId
IDhelper for creating objects.
virtual StatusCode initialize() override
Algorithm initialize at begin of job.
StatusCode checkSCT() const
Compare objects read with newly created ones.
StatusCode checkTRT() const
Compare objects read with newly created ones.
const CaloCell_ID * m_calocellId
Need id helper to create cells.
const SCT_ID * m_sctId
IDhelper for creating objects.
void printCells(const CaloCellContainer *larCont) const
Print out cell info.
RDOReaderDoubleSelector()
Avoid use of default constructor.
virtual StatusCode execute() override
Algorithm execute once per event.