ATLAS Offline Software
Loading...
Searching...
No Matches
SCTRawDataProvider.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
6
12
13#include <memory>
14
16
17// Constructor
18
19SCTRawDataProvider::SCTRawDataProvider(const std::string& name, ISvcLocator* pSvcLocator) :
20 AthReentrantAlgorithm(name, pSvcLocator)
21{
22 declareProperty("RDOCacheKey", m_rdoContainerCacheKey="");
23 declareProperty("BSErrCacheKey", m_bsErrContainerCacheKey="");
24}
25
26// Initialize
27
29{
30 // Get ROBDataProviderSvc
31 ATH_CHECK(m_robDataProvider.retrieve());
32
33 // Get the SCT ID helper
34 ATH_CHECK(detStore()->retrieve(m_sctID, "SCT_ID"));
35 if (m_roiSeeded.value()) {
36 // Don't need SCT cabling if running in RoI-seeded mode
37 ATH_CHECK(m_roiCollectionKey.initialize());
38 ATH_CHECK(m_regionSelector.retrieve());
39 m_cabling.disable();
40 }
41 else {
42 //Disable Roi requirement
43 ATH_CHECK(m_roiCollectionKey.initialize(false));
44 // Retrieve Cabling tool
45 ATH_CHECK(m_cabling.retrieve());
46 m_regionSelector.disable();
47 }
48
49 //Initialize
50 ATH_CHECK(m_rdoContainerKey.initialize());
56
57 ATH_CHECK( m_rawDataTool.retrieve() );
58
59 return StatusCode::SUCCESS;
60}
61
62// Execute
63
64StatusCode SCTRawDataProvider::execute(const EventContext& ctx) const
65{
67 bool externalCacheRDO = !m_rdoContainerCacheKey.key().empty();
68 if (not externalCacheRDO) {
69 ATH_CHECK(rdoContainer.record (std::make_unique<SCT_RDO_Container>(m_sctID->wafer_hash_max(), EventContainers::Mode::OfflineFast)));
70 ATH_MSG_DEBUG("Created container for " << m_sctID->wafer_hash_max());
71 }
72 else {
74 ATH_CHECK(rdoCache.isValid());
75 ATH_CHECK(rdoContainer.record (std::make_unique<SCT_RDO_Container>(rdoCache.ptr())));
76 ATH_MSG_DEBUG("Created container using cache for " << m_rdoContainerCacheKey.key());
77 }
78
80 if ( m_bsErrContainerCacheKey.key().empty() ) {
81 ATH_CHECK(bsIDCErrContainer.record( std::make_unique<IDCInDetBSErrContainer>(m_sctID->wafer_hash_max(), std::numeric_limits<IDCInDetBSErrContainer::ErrorCode>::min() )));
82 ATH_MSG_DEBUG("Created IDCInDetBSErrContainer w/o using external cache");
83 } else { // use cache
85 ATH_CHECK( cacheHandle.isValid() );
86 ATH_CHECK(bsIDCErrContainer.record( std::make_unique<IDCInDetBSErrContainer>(cacheHandle.ptr())) );
87 ATH_MSG_DEBUG("Created SCT IDCInDetBSErrContainer using external cache");
88 }
89
90 // Ask ROBDataProviderSvc for the vector of ROBFragment for all SCT ROBIDs
91 std::vector<const ROBFragment*> vecROBFrags;
92 std::vector<IdentifierHash> hashIDs;
93 if (not m_roiSeeded.value()) {
94 std::vector<uint32_t> rodList;
95 m_cabling->getAllRods(rodList, ctx);
96 m_robDataProvider->getROBData(ctx, rodList, vecROBFrags);
97 }
98 else {
99 // Only load ROBs from RoI
100 std::vector<uint32_t> listOfROBs;
102 ATH_CHECK(roiCollection.isValid());
103 TrigRoiDescriptor superRoI; // Add all RoIs to a super-RoI
104 superRoI.reserve(roiCollection->size());
105 superRoI.setComposite(true);
106 superRoI.manageConstituents(false);
107 for (const TrigRoiDescriptor* roi : *roiCollection) {
108 superRoI.push_back(roi);
109 }
110
111 m_regionSelector->lookup(ctx)->ROBIDList(superRoI, listOfROBs );
112 m_regionSelector->lookup(ctx)->HashIDList(superRoI, hashIDs );
113
114 m_robDataProvider->getROBData(ctx, listOfROBs, vecROBFrags);
115 }
116
117
118 ATH_MSG_DEBUG("Number of ROB fragments " << vecROBFrags.size());
119
123 lvl1Collection = SG::makeHandle(m_lvl1CollectionKey,ctx);
124 bcIDCollection = SG::makeHandle(m_bcIDCollectionKey,ctx);
125
126 ATH_CHECK(lvl1Collection.record(std::make_unique<InDetTimeCollection>()));
127 ATH_CHECK(bcIDCollection.record(std::make_unique<InDetTimeCollection>()));
128
129 lvl1Collection->reserve(vecROBFrags.size());
130 bcIDCollection->reserve(vecROBFrags.size());
131
132 for (const ROBFragment* robFrag : vecROBFrags) {
133 // Store LVL1ID and BCID information in InDetTimeCollection
134 // to be stored in StoreGate at the end of the loop.
135 // We want to store a pair<ROBID, LVL1ID> for each ROD, once per event.
136 uint32_t robID{(robFrag)->rod_source_id()};
137
138 unsigned int lvl1ID{(robFrag)->rod_lvl1_id()};
139 lvl1Collection->emplace_back(robID, lvl1ID);
140
141 unsigned int bcID{(robFrag)->rod_bc_id()};
142 bcIDCollection->emplace_back(robID, bcID);
143
144 ATH_MSG_DEBUG("Stored LVL1ID " << lvl1ID << " and BCID " << bcID << " in InDetTimeCollections");
145 }
146 }
147
148 if ( not hashIDs.empty() ) {
149 int missingCount{};
150 for ( IdentifierHash hash: hashIDs ) {
151 if ( not rdoContainer->tryAddFromCache( hash ) ) missingCount++;
152 bsIDCErrContainer->tryAddFromCache( hash );
153 }
154 ATH_MSG_DEBUG("Out of: " << hashIDs.size() << "Hash IDs missing: " << missingCount );
155 if ( missingCount == 0 ) {
156 return StatusCode::SUCCESS;
157 }
158 }
159
160 std::unique_ptr<DataPool<SCT3_RawData>> dataItemsPool = nullptr;
161 if(!externalCacheRDO){
162 dataItemsPool = std::make_unique<DataPool<SCT3_RawData>>(ctx);
163 dataItemsPool->reserve(10000); // Some large default size
164 } else if (m_useDataPoolWithCache) {
165 dataItemsPool = std::make_unique<DataPool<SCT3_RawData>>(ctx);
166 // for now a default size 1024.
167 }
168
169 // Ask SCTRawDataProviderTool to decode it and to fill the IDC
170 StatusCode statConv = m_rawDataTool->convert(vecROBFrags,
171 *(rdoContainer.ptr()),
172 *bsIDCErrContainer,
173 dataItemsPool.get(),
174 ctx);
175
176 if (statConv.isFailure() && statConv != StatusCode::RECOVERABLE) {
177 ATH_MSG_WARNING("BS conversion into RDOs failed");
178 return statConv;
179 } else {
180 return StatusCode::SUCCESS;
181 }
182
183}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Header file for abstract interface to SCT cabling tool.
This is an Identifier helper class for the SCT subdetector.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
An algorithm that can be simultaneously executed in multiple threads.
This is a "hash" representation of an Identifier.
void push_back(const IRoiDescriptor *roi)
add a RoiDescriptor
bool manageConstituents() const
always manage constituents ???
void reserve(size_t s)
reserve elements in vector
void setComposite(bool b=true)
ToolHandle< ISCT_CablingTool > m_cabling
Providing mappings of online and offline identifiers and also serial numbers.
SCTRawDataProvider(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
ROB Data Provider for accessing ROB data.
SG::WriteHandleKey< IDCInDetBSErrContainer > m_bsIDCErrContainerKey
Write handle for Inner Detector ByteStream error container.
SG::ReadHandleKey< TrigRoiDescriptorCollection > m_roiCollectionKey
Read handle for Trigger ROI descriptor collection.
virtual StatusCode initialize() override
Initialize.
SG::WriteHandleKey< InDetTimeCollection > m_bcIDCollectionKey
Write handle for BC ID Inner Detector time collection.
BooleanProperty m_roiSeeded
Boolean to determine if SCT Raw Data Provider should be run in RoI seeded mode.
virtual StatusCode execute(const EventContext &ctx) const override
Execute.
const SCT_ID * m_sctID
Identifier helper class for the SCT subdetector that creates compact Identifier objects and Identifie...
ToolHandle< ISCTRawDataProviderTool > m_rawDataTool
Tool to fill Collections of SCT RDO Containers.
SG::UpdateHandleKey< IDCInDetBSErrContainer_Cache > m_bsErrContainerCacheKey
SG::UpdateHandleKey< SCT_RDO_Cache > m_rdoContainerCacheKey
Update handle for SCT RDO and Erorrs Cache.
ToolHandle< IRegSelTool > m_regionSelector
Region Selector tool for Athena.
SG::WriteHandleKey< InDetTimeCollection > m_lvl1CollectionKey
Write handle for LVL 1 Inner Detector time collection.
Gaudi::Property< bool > m_storeInDetTimeColls
SG::WriteHandleKey< SCT_RDO_Container > m_rdoContainerKey
Write handle for SCT RDO container.
Gaudi::Property< bool > m_useDataPoolWithCache
Boolean to Use DataPool with IDC online Cache.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
virtual bool isValid() override final
Can the handle be successfully dereferenced?
pointer_type ptr()
Dereference the pointer.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
nope - should be used for standalone also, perhaps need to protect the class def bits ifndef XAOD_ANA...
eformat::ROBFragment< PointerType > ROBFragment
Definition RawEvent.h:27
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())