ATLAS Offline Software
Loading...
Searching...
No Matches
InDetRawDataFakeWriter.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
16
17// Silicon trackers includes
19
21
22
23//InDetRawData includes
27
28//#include "InDetRawData/InDetRawDataCLASS_DEF.h"
29
30// Id includes
34
35// test includes
37
38
39#include <map>
40
41// Constructor with parameters:
43 ISvcLocator *pSvcLocator) :
44 AthAlgorithm(name,pSvcLocator),
45 m_pixCont(nullptr),
46 m_sctCont(nullptr),
47 m_trtCont(nullptr),
48 m_pixelId(nullptr),
49 m_sctId(nullptr),
50 m_trtId(nullptr)
51{}
52
53// Initialize method:
55{
56 ATH_MSG_INFO("InDetRawDataFakeWriter::initialize()" );
57
58 ATH_CHECK( detStore()->retrieve(m_pixelId, "PixelID") );
59 ATH_CHECK( detStore()->retrieve(m_sctId, "SCT_ID") );
60 ATH_CHECK( detStore()->retrieve(m_trtId, "TRT_ID") );
61
62 // create the IdentifiableContainers to contain the rdo collections
63 try {
64 m_pixCont=new PixelRDO_Container(m_pixelId->wafer_hash_max());
65 } catch (const std::bad_alloc&) {
66 ATH_MSG_ERROR("Could not create a new Pixel RawDataContainer !");
67 return StatusCode::FAILURE;
68 }
69
70 try {
71 m_sctCont=new SCT_RDO_Container(m_sctId->wafer_hash_max());
72 } catch (const std::bad_alloc&) {
73 ATH_MSG_ERROR("Could not create a new SCT RawDataContainer !");
74 return StatusCode::FAILURE;
75 }
76
77 try {
78 m_trtCont=new TRT_RDO_Container(m_trtId->straw_layer_hash_max());
79 } catch (const std::bad_alloc&) {
80 ATH_MSG_ERROR("Could not create a new TRT RawDataContainer !");
81 return StatusCode::FAILURE;
82 }
83
84 // preventing SG from deleting object:
85 m_pixCont->addRef();
86 m_sctCont->addRef();
87 m_trtCont->addRef();
88
89 return StatusCode::SUCCESS;
90}
91
92// Execute method:
94{
95 // Get the messaging service, print where you are
96 ATH_MSG_DEBUG( "InDetRawDataFakeWriter::execute()" );
100 ATH_CHECK( printRDOs() );
101 return StatusCode::SUCCESS;
102}
103
105{
106 ATH_MSG_DEBUG("InDetRawDataFakeWriter::createPixels()" );
107
108
109 // IDC creation and registration, done once per job:
110
111 // the IDC is created in the initialize, must clear the IDC every event:
112 m_pixCont->cleanup();
113
114 // register the Pixel IdentifiableContainer into StoreGate
115 ATH_CHECK( evtStore()->record(m_pixCont,"PixelRDOs") );
116
117 // Create and record the element link vector
119 ATH_CHECK( evtStore()->record(linkVec,"PixelRDOELs") );
120
121 // loop over 10 different pixel wafers
122 int deltaWafer = m_pixelId->wafer_hash_max()/15;
123 IdentifierHash waferHash = deltaWafer;
124
126
127 IdContext cntx = m_pixelId->wafer_context();
128
129 for (int i=0; i < 10; ++i, waferHash += deltaWafer) {
130
131 // Print out contents of RDO
132 ATH_MSG_DEBUG("Creating RDO collection: "
133 << m_pixelId->show_to_string(m_pixelId->wafer_id(waferHash), &cntx) << " "
134 << MSG::hex << m_pixelId->wafer_id(waferHash) << MSG::dec << " "
135 << MSG::hex << (unsigned int)waferHash << MSG::dec );
136
137 // create a new pixel RDO collection
138 MsgStream log(msgSvc(), name());
140 creator.createPixelRawDataColl(waferHash, m_pixelId, log);
141
142 // register the rdo collection in StoreGate
143 // add rdo collection to the container
144 IdentifierHash id_hash = p_rdocoll->identifyHash();
145 ATH_CHECK( m_pixCont->addCollection(p_rdocoll, id_hash) );
146
147 // Loop over RDOs and add ELs to vector
148 for (unsigned int irdo = 0; irdo < p_rdocoll->size(); ++irdo) {
149 unsigned int itest = irdo % 3;
150 if (itest == 2) {
151 // Create el with element and container
152 ATH_MSG_VERBOSE("Pixel RDOs: create EL without index");
153 PixelRDOElemLinkVec::elem_type el((*p_rdocoll)[irdo], *m_pixCont);
154 linkVec->pixelRDOs().push_back(el);
155 }
156 else {
157 // Create el with hash and sometimes index
159 index.setCollHash(waferHash);
160 if (itest == 1) index.setObjIndex(irdo);
161 ATH_MSG_VERBOSE("Pixel RDOs: create EL - hash, index, hashAndIndex: "
162 << index.collHash() << " " << index.objIndex() << " "
163 << MSG::hex << index.hashAndIndex() << MSG::dec);
164 // Create el with element and index
166 el.setElement((*p_rdocoll)[irdo]);
167 linkVec->pixelRDOs().push_back(el);
168 }
169 }
170 }
171
172 return StatusCode::SUCCESS;
173}
174
176{
177 ATH_MSG_DEBUG("InDetRawDataFakeWriter::execute()" );
178
179 // IDC creation and registration, done once per job:
180
181 // the IDC is created in the initialize, must clear the IDC every event:
182 m_sctCont->cleanup();
183
184
185 ATH_CHECK( evtStore()->record(m_sctCont,"SCT_RDOs") );
186
187 // loop over 10 different sct wafers
188 int deltaWafer = m_sctId->wafer_hash_max()/15;
189 IdentifierHash waferHash = deltaWafer;
190
192
193 IdContext cntx = m_sctId->wafer_context();
194
195 for (int i=0; i < 10; ++i, waferHash += deltaWafer) {
196
197 // Print out contents of RDO
198 ATH_MSG_DEBUG("Creating RDO collection: "
199 << m_sctId->show_to_string(m_sctId->wafer_id(waferHash), &cntx) << " "
200 << MSG::hex << m_sctId->wafer_id(waferHash) << MSG::dec << " "
201 << MSG::hex << (unsigned int)waferHash << MSG::dec );
202
203 // create a new sct RDO collection
204 MsgStream log(msgSvc(), name());
206 creator.createSCT_RawDataColl(waferHash, m_sctId, msg());
207
208 // register the rdo collection in StoreGate
209 IdentifierHash id_hash = p_rdocoll->identifyHash();
210 ATH_CHECK( m_sctCont->addCollection(p_rdocoll, id_hash) );
211 }
212
213 return StatusCode::SUCCESS;
214}
215
217{
218 ATH_MSG_DEBUG("InDetRawDataFakeWriter::execute()" );
219
220 // IDC creation and registration, done once per job:
221
222 // the IDC is created in the initialize, must clear the IDC every event:
223 m_trtCont->cleanup();
224
225
226 // register the TRT_ IdentifiableContainer into StoreGate
227 ATH_CHECK( evtStore()->record(m_trtCont,"TRT_RDOs") );
228
229 // loop over 10 different trt straw layers
230 int deltaStrLay = m_trtId->straw_layer_hash_max()/15;
231 IdentifierHash strLayHash = deltaStrLay;
232
234
235 IdContext cntx = m_trtId->straw_layer_context();
236
237 for (int i=0; i < 10; ++i, strLayHash += deltaStrLay) {
238
239 // Print out contents of RDO
240 ATH_MSG_DEBUG("Creating RDO collection: "
241 << m_trtId->show_to_string(m_trtId->layer_id(strLayHash), &cntx) << " "
242 << MSG::hex << m_trtId->layer_id(strLayHash) << MSG::dec << " "
243 << MSG::hex << (unsigned int)strLayHash << MSG::dec );
244
245 // create a new trt RDO collection
247 creator.createTRT_RawDataColl(strLayHash, m_trtId, msg());
248
249 // register the rdo collection in StoreGate
250 IdentifierHash id_hash = p_rdocoll->identifyHash();
251 ATH_CHECK( m_trtCont->addCollection(p_rdocoll, id_hash) );
252 }
253
254 return StatusCode::SUCCESS;
255}
256
257
258
259
260// Print rdos
262{
263 ATH_MSG_INFO("InDetRawDataFakeWriter::printRDOs()" );
264
265 // loop on all RDO collections
266
267 // pixels
268
270 it!=m_pixCont->end() ; ++it) {
271
272 const InDetRawDataCollection< PixelRDORawData > *rdocoll=&(**it);
273
274 ATH_MSG_DEBUG("PixelRDORawData collection found with id "
275 << m_pixelId->show_to_string(rdocoll->identify())
276 << " and " << rdocoll->size() << " RDOs" );
277
278 // loop on all RDOs
280 for(rdo=rdocoll->begin() ;
281 rdo!=rdocoll->end() ; ++rdo) {
282
283 ATH_MSG_DEBUG("RDO ID=" << m_pixelId->show_to_string((*rdo)->identify())
284 << "RDO ToT=" << (*rdo)->getToT() << " id:"
285 << (*rdo)->identify().getString() );
286
287 }
288 }
289
290 // pixel element links
291
292 // Retrieve the element link vector
293 const PixelRDOElemLinkVec* linkVec = nullptr;
294 ATH_CHECK( evtStore()->retrieve(linkVec, "PixelRDOELs") );
295
296 ATH_MSG_DEBUG("PixelRDOElemLinkVec found with " << linkVec->pixelRDOs().size() << " RDOs " );
297 for(unsigned int i = 0; i < linkVec->pixelRDOs().size(); ++i) {
298 // Print out rdos from element link
299 PixelRDOElemLinkVec::elem_type rdo = linkVec->pixelRDOs()[i];
300 ATH_MSG_DEBUG("RDO ID=" << m_pixelId->show_to_string((*rdo)->identify())
301 << "RDO ToT=" << (*rdo)->getToT()
302 << " id:" << (*rdo)->identify().getString() );
303 }
304
305
306 // scts
307
309 it!=m_sctCont->end() ; ++it) {
310
311 const InDetRawDataCollection< SCT_RDORawData > *rdocoll=&(**it);
312
313 ATH_MSG_DEBUG("SCT_RDORawData collection found with id "
314 << m_sctId->show_to_string(rdocoll->identify())
315 << " and " << rdocoll->size() << " RDOs" );
316
317 // loop on all RDOs
319 for(rdo=rdocoll->begin() ;
320 rdo!=rdocoll->end() ; ++rdo) {
321
322 ATH_MSG_DEBUG("RDO ID=" << m_sctId->show_to_string((*rdo)->identify())
323 << "RDO grp=" << (*rdo)->getGroupSize() );
324
325 }
326 }
327
328 // trts
329
331 it!=m_trtCont->end() ; ++it) {
332
333 const InDetRawDataCollection< TRT_RDORawData > *rdocoll=&(**it);
334
335 ATH_MSG_DEBUG("TRT_RDORawData collection found with id "
336 << m_trtId->show_to_string(rdocoll->identify())
337 << " and " << rdocoll->size() << " RDOs" );
338
339 // loop on all RDOs
341 for(rdo=rdocoll->begin() ;
342 rdo!=rdocoll->end() ; ++rdo) {
343
344 ATH_MSG_DEBUG("RDO ID=" << m_trtId->show_to_string((*rdo)->identify())
345 << "RDO hilvl=" << (*rdo)->highLevel() << " ToT:"
346 << (*rdo)->timeOverThreshold() << " drift: " << (*rdo)->driftTimeBin());
347
348 }
349 }
350
351 ATH_MSG_DEBUG("InDetRawDataFakeWriter::printRDOs() end" );
352
353 return StatusCode::SUCCESS;
354
355}
356
357
358// Finalize method:
360{
361 ATH_MSG_INFO("InDetRawDataFakeWriter::finalize()" );
362 return StatusCode::SUCCESS;
363}
364
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
Class which encapsulates the creation of an InDetRawDataCollection.
Test Algorithm for POOL I/O, writes InDetRawData to transient store.
This is an Identifier helper class for the Pixel subdetector.
Class definition for PixelRDOElemLinkVec.
InDetRawDataContainer< InDetRawDataCollection< PixelRDORawData > > PixelRDO_Container
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
DataModel_detail::const_iterator< DataVector > const_iterator
Standard const_iterator.
Definition DataVector.h:838
const_iterator end() const noexcept
const_iterator begin() const noexcept
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
Identifiable container index to a contained object.
This is a "hash" representation of an Identifier.
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.
virtual StatusCode finalize()
Algorithm finalize at end of job.
const TRT_ID * m_trtId
IDhelper needed for identifiable container.
const PixelID * m_pixelId
IDhelper needed for identifiable container.
const SCT_ID * m_sctId
IDhelper needed for identifiable container.
virtual StatusCode initialize()
Algorithm initialize at begin of job.
StatusCode createTRTs()
Create trt collections.
InDetRawDataFakeWriter()
Avoid use of default constructor.
StatusCode printRDOs() const
Print out RDOs.
StatusCode createSCTs()
Create sct collections.
TRT_RDO_Container * m_trtCont
Identifiable containers are created only once.
PixelRDO_Container * m_pixCont
Identifiable containers are created only once.
StatusCode createPixels()
Create pixel collections.
virtual StatusCode execute()
Algorithm execute once per event.
SCT_RDO_Container * m_sctCont
Identifiable containers are created only once.
vector containing element links to pixel RDOs
const std::vector< elem_type > & pixelRDOs() const
ElementLink< cont_type > elem_type
Definition index.py:1