ATLAS Offline Software
InDetRawDataFakeWriter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
17 // Silicon trackers includes
18 #include "InDetRawDataFakeWriter.h"
19 
21 
22 
23 //InDetRawData includes
27 
28 //#include "InDetRawData/InDetRawDataCLASS_DEF.h"
29 
30 // Id includes
32 #include "InDetIdentifier/SCT_ID.h"
33 #include "InDetIdentifier/TRT_ID.h"
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 {
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 {
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 {
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()" );
98  ATH_CHECK( createSCTs() );
99  ATH_CHECK( createTRTs() );
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 
125  InDetRawDataFakeCreator creator;
126 
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());
139  const InDetRawDataCollection<PixelRDORawData> *p_rdocoll =
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 
191  InDetRawDataFakeCreator creator;
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());
205  const InDetRawDataCollection<SCT_RDORawData> *p_rdocoll =
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 
233  InDetRawDataFakeCreator creator;
234 
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
246  const InDetRawDataCollection<TRT_RDORawData> *p_rdocoll =
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  // Retrive 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 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
PixelID.h
This is an Identifier helper class for the Pixel subdetector. This class is a factory for creating co...
InDetRawDataFakeWriter::InDetRawDataFakeWriter
InDetRawDataFakeWriter()
Avoid use of default constructor.
InDetRawDataFakeCreator
Class which encapsulates the creation of an InDetRawDataCollection.
Definition: InDetRawDataFakeCreator.h:41
TRT_ID::layer_id
Identifier layer_id(int barrel_ec, int phi_module, int layer_or_wheel, int straw_layer) const
For an individual straw layer.
Definition: TRT_ID.h:500
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
SCT_ID.h
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
PixelRDO_Container
InDetRawDataContainer< InDetRawDataCollection< PixelRDORawData > > PixelRDO_Container
Definition: PixelRDO_Container.h:25
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
IdentifiableContainerMT::addCollection
virtual StatusCode addCollection(const T *coll, IdentifierHash hashId) override final
insert collection into container with id hash if IDC should not take ownership of collection,...
Definition: IdentifiableContainerMT.h:300
InDetRawDataFakeWriter::execute
virtual StatusCode execute()
Algorithm execute once per event.
Definition: InDetRawDataFakeWriter.cxx:93
index
Definition: index.py:1
TRT_ID::straw_layer_hash_max
size_type straw_layer_hash_max(void) const
Definition: TRT_ID.h:920
TRT_RDO_Collection.h
InDetRawDataFakeWriter::createTRTs
StatusCode createTRTs()
Create trt collections.
Definition: InDetRawDataFakeWriter.cxx:216
InDetRawDataFakeWriter.h
Test Algorithm for POOL I/O, writes InDetRawData to transient store.
InDetRawDataCollection::identify
virtual Identifier identify() const override final
skel.it
it
Definition: skel.GENtoEVGEN.py:423
TRT_ID.h
This is an Identifier helper class for the TRT subdetector. This class is a factory for creating comp...
InDetRawDataFakeWriter::m_sctCont
SCT_RDO_Container * m_sctCont
Identifiable containers are created only once.
Definition: InDetRawDataFakeWriter.h:91
IdentContIndex
Identifiable container index to a contained object.
Definition: IdentContIndex.h:23
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
PixelID::wafer_id
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module) const
For a single crystal.
Definition: PixelID.h:364
InDetRawDataFakeWriter::initialize
virtual StatusCode initialize()
Algorithm initialize at begin of job.
Definition: InDetRawDataFakeWriter.cxx:54
AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
InDetRawDataCollection::identifyHash
virtual IdentifierHash identifyHash() const override final
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
PixelRDOElemLinkVec
vector containing element links to pixel RDOs
Definition: PixelRDOElemLinkVec.h:40
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
InDetRawDataFakeWriter::createPixels
StatusCode createPixels()
Create pixel collections.
Definition: InDetRawDataFakeWriter.cxx:104
lumiFormat.i
int i
Definition: lumiFormat.py:92
PixelRDO_Collection.h
TRT_ID::straw_layer_context
IdContext straw_layer_context(void) const
straw_layer id
Definition: TRT_ID.h:713
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
InDetRawDataFakeCreator::createSCT_RawDataColl
const InDetRawDataCollection< SCT_RDORawData > * createSCT_RawDataColl(IdentifierHash hashId, const SCT_ID *sctId, MsgStream &log)
Create SCT_RawDataCollection.
Definition: InDetRawDataFakeCreator.h:141
InDetRawDataCollection
Definition: InDetRawDataCollection.h:31
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
InDetRawDataFakeCreator::createTRT_RawDataColl
const InDetRawDataCollection< TRT_RDORawData > * createTRT_RawDataColl(IdentifierHash hashId, const TRT_ID *trtId, MsgStream &log)
Create TRT_RawDataCollection.
Definition: InDetRawDataFakeCreator.h:189
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
IdentifiableContainerMT::end
const_iterator end() const
return const_iterator for end of container
Definition: IdentifiableContainerMT.h:242
SCT_ID::wafer_context
IdContext wafer_context(void) const
Definition: SCT_ID.h:705
IdentifiableContainerMT::const_iterator
Definition: IdentifiableContainerMT.h:82
IdentifiableContainerMT::begin
const_iterator begin() const
return const_iterator for first entry
Definition: IdentifiableContainerMT.h:236
PixelRDOElemLinkVec.h
Class definition for PixelRDOElemLinkVec.
AthAlgorithm
Definition: AthAlgorithm.h:47
InDetRawDataFakeWriter::m_pixelId
const PixelID * m_pixelId
IDhelper needed for identifiable container.
Definition: InDetRawDataFakeWriter.h:97
InDetRawDataFakeWriter::createSCTs
StatusCode createSCTs()
Create sct collections.
Definition: InDetRawDataFakeWriter.cxx:175
TRT_RDO_Container
InDetRawDataContainer< InDetRawDataCollection< TRT_RDORawData > > TRT_RDO_Container
Definition: TRT_RDO_Container.h:26
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
SCT_ID::wafer_hash_max
size_type wafer_hash_max(void) const
Definition: SCT_ID.cxx:639
InDetRawDataFakeWriter::m_sctId
const SCT_ID * m_sctId
IDhelper needed for identifiable container.
Definition: InDetRawDataFakeWriter.h:100
SCT_RDO_Collection.h
PixelID::wafer_hash_max
size_type wafer_hash_max(void) const
Definition: PixelID.cxx:912
SCT_RDO_Container
InDetRawDataContainer< InDetRawDataCollection< SCT_RDORawData > > SCT_RDO_Container
Definition: SCT_RDO_Container.h:23
DataVector< RawDataT >::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
InDetRawDataFakeWriter::m_pixCont
PixelRDO_Container * m_pixCont
Identifiable containers are created only once.
Definition: InDetRawDataFakeWriter.h:88
InDetRawDataFakeWriter::m_trtCont
TRT_RDO_Container * m_trtCont
Identifiable containers are created only once.
Definition: InDetRawDataFakeWriter.h:94
DeMoScan.index
string index
Definition: DeMoScan.py:362
InDetRawDataFakeWriter::m_trtId
const TRT_ID * m_trtId
IDhelper needed for identifiable container.
Definition: InDetRawDataFakeWriter.h:103
AtlasDetectorID::show_to_string
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
Definition: AtlasDetectorID.cxx:574
PixelID::wafer_context
IdContext wafer_context(void) const
Definition: PixelID.h:590
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
InDetRawDataFakeWriter::printRDOs
StatusCode printRDOs() const
Print out RDOs.
Definition: InDetRawDataFakeWriter.cxx:261
InDetRawDataFakeCreator.h
Class which encapsulates the creation of an InDetRawDataCollection.
PixelRDOElemLinkVec::pixelRDOs
const std::vector< elem_type > & pixelRDOs() const
Definition: PixelRDOElemLinkVec.h:79
SCT_ID::wafer_id
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module, int side) const
For a single side of module.
Definition: SCT_ID.h:464
IdentifierHash
Definition: IdentifierHash.h:38
InDetRawDataFakeWriter::finalize
virtual StatusCode finalize()
Algorithm finalize at end of job.
Definition: InDetRawDataFakeWriter.cxx:359
IdContext
class IdContext
Definition: IdContext.h:34
DataVector< RawDataT >::size
size_type size() const noexcept
Returns the number of elements in the collection.
InDetRawDataFakeCreator::createPixelRawDataColl
const InDetRawDataCollection< PixelRDORawData > * createPixelRawDataColl(IdentifierHash hashId, const PixelID *pixelId, MsgStream &log)
Create PixelRawDataCollection.
Definition: InDetRawDataFakeCreator.h:76
IdentifiableContainerMT::cleanup
virtual void cleanup() override final
reset m_hashids and call IdentifiableCache's cleanup
Definition: IdentifiableContainerMT.h:312
DataVector< RawDataT >::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.