ATLAS Offline Software
Loading...
Searching...
No Matches
PixelRawDataProvider.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include <memory>
7
10
12
13// --------------------------------------------------------------------
14// Constructor
15
17 ISvcLocator* pSvcLocator) :
18 AthReentrantAlgorithm(name, pSvcLocator) {
19 declareProperty("RDOCacheKey", m_rdoCacheKey);
20 declareProperty("BSErrorsCacheKey", m_bsErrorsCacheKey);
21}
22
23// Destructor
24
27
28// --------------------------------------------------------------------
29// Initialize
30
32 ATH_MSG_INFO("PixelRawDataProvider::initialize");
33
34 // Get ROBDataProviderSvc
35 if (m_robDataProvider.retrieve().isFailure()) {
36 ATH_MSG_FATAL("Failed to retrieve service " << m_robDataProvider);
37 return StatusCode::FAILURE;
38 } else
39 ATH_MSG_INFO("Retrieved service " << m_robDataProvider);
40
41 // Get PixelRawDataProviderTool
42 if (m_rawDataTool.retrieve().isFailure()) {
43 ATH_MSG_FATAL("Failed to retrieve tool " << m_rawDataTool);
44 return StatusCode::FAILURE;
45 } else
46 ATH_MSG_INFO("Retrieved tool " << m_rawDataTool);
47
48 ATH_CHECK(detStore()->retrieve(m_pixel_id, "PixelID"));
49 ATH_CHECK( m_rdoContainerKey.initialize() );
50
51 ATH_CHECK( m_rdoCacheKey.initialize( SG::AllowEmpty ) );
52
53 ATH_CHECK( m_bsErrorsKey.initialize() );
55
56 if (m_roiSeeded) {
57 ATH_CHECK( m_roiCollectionKey.initialize() );
58 ATH_CHECK(m_regionSelector.retrieve());
59 }else{
60 ATH_CHECK( m_roiCollectionKey.initialize(false) ); //clear if unneeded
61 m_regionSelector.disable();
62 }
63
64 ATH_CHECK(m_condCablingKey.initialize());
65
66 return StatusCode::SUCCESS;
67}
68
69// --------------------------------------------------------------------
70// Execute
71
73
74StatusCode PixelRawDataProvider::execute(const EventContext& ctx) const {
75
76#ifdef PIXEL_DEBUG
77 ATH_MSG_DEBUG("Create Pixel RDO Container");
78#endif
79
80 // now create the container and register the collections
81
82
83 // write into StoreGate
84
86 if( m_rdoCacheKey.empty() ) rdoContainer = std::make_unique<PixelRDO_Container>(m_pixel_id->wafer_hash_max(), EventContainers::Mode::OfflineFast);
87 else{
89 if( ! updateh.isValid() ) {
90 ATH_MSG_FATAL("Failure to retrieve cache " << m_rdoCacheKey.key());
91 return StatusCode::FAILURE;
92 }
93 rdoContainer = std::make_unique<PixelRDO_Container>(updateh.ptr());
94 ATH_MSG_DEBUG("Created container " << m_rdoContainerKey.key() << " using external cache " << m_rdoCacheKey.key());
95 }
96 ATH_CHECK(rdoContainer.isValid());
97
98 // Print ROB map in m_robDataProvider
99 //m_robDataProvider->print_robmap();
100
101 // ask ROBDataProviderSvc for the vector of ROBFragment for all Pixel ROBIDs
102 std::vector<uint32_t> listOfRobs;
103
104 if (!m_roiSeeded) {
105 ATH_MSG_DEBUG("No RoI seed, fetching all ROBs");
106 listOfRobs = SG::ReadCondHandle<PixelCablingCondData>(m_condCablingKey, ctx)->get_allRobs(); // need ROB id (not ROD)
107 }
108 else {//Enter RoI-seeded mode
109 ATH_MSG_DEBUG("RoI seed, fetching regions infromation");
111 ATH_CHECK(roiCollection.isValid());
112
113 TrigRoiDescriptorCollection::const_iterator roi = roiCollection->begin();
114 TrigRoiDescriptorCollection::const_iterator roiE = roiCollection->end();
115 TrigRoiDescriptor superRoI;//add all RoIs to a super-RoI
116 superRoI.reserve(roiCollection->size());
117 superRoI.setComposite(true);
118 superRoI.manageConstituents(false);
119 for (; roi!=roiE; ++roi) {
120 superRoI.push_back(*roi);
121 }
122 m_regionSelector->lookup(ctx)->ROBIDList( superRoI, listOfRobs );
123 }
124 std::vector<const ROBFragment*> listOfRobf;
125
126 m_robDataProvider->getROBData(ctx, listOfRobs, listOfRobf);
127
128#ifdef PIXEL_DEBUG
129 ATH_MSG_DEBUG("Number of ROB fragments " << listOfRobf.size()
130 << " (out of=" << listOfRobs.size() << " expected)");
131#endif
132
133 std::unique_ptr<DummyPixelRDO> tempcont;
134 if( not m_rdoCacheKey.empty() ) tempcont = std::make_unique<DummyPixelRDO> (rdoContainer.ptr());
135
136 IPixelRDO_Container *containerInterface = tempcont ? static_cast< IPixelRDO_Container* >(tempcont.get()) :
137 static_cast< IPixelRDO_Container* >(rdoContainer.ptr());
138
139 std::unique_ptr<IDCInDetBSErrContainer> decodingErrors;
140 if ( not m_bsErrorsCacheKey.empty() ) {
142 decodingErrors = std::make_unique<IDCInDetBSErrContainer>( bsErrorsCacheHandle.ptr() );
143 } else {
144 decodingErrors = std::make_unique<IDCInDetBSErrContainer>( m_rawDataTool->SizeOfIDCInDetBSErrContainer(), std::numeric_limits<int>::min() );
145 }
146
147 // ask PixelRawDataProviderTool to decode it and to fill the IDC
148 if (m_rawDataTool->convert(listOfRobf, containerInterface, *decodingErrors, ctx).isFailure())
149 ATH_MSG_ERROR("BS conversion into RDOs failed");
150
151 if(tempcont) ATH_CHECK(tempcont->MergeToRealContainer(rdoContainer.ptr()));
152
154 ATH_CHECK( bsErrorsHandle.record( std::move( decodingErrors ) ) );
155
156#ifdef PIXEL_DEBUG
157 ATH_MSG_DEBUG("Number of Collections in IDC " << rdoContainer->numberOfCollections());
158#endif
159
160 return StatusCode::SUCCESS;
161}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
This is an Identifier helper class for the Pixel subdetector.
EventContainers::IIdentifiableCont< InDetRawDataCollection< PixelRDORawData > > IPixelRDO_Container
EventContainers::IdentifiableContTemp< InDetRawDataCollection< PixelRDORawData > > DummyPixelRDO
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.
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
SG::ReadHandleKey< TrigRoiDescriptorCollection > m_roiCollectionKey
StatusCode execute(const EventContext &ctx) const override
Execute.
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
~PixelRawDataProvider()
Don't need to override Finalize.
StatusCode initialize() override
Initialize.
SG::WriteHandleKey< IDCInDetBSErrContainer > m_bsErrorsKey
PixelRawDataProvider(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
SG::WriteHandleKey< PixelRDO_Container > m_rdoContainerKey
Gaudi::Property< bool > m_roiSeeded
SG::UpdateHandleKey< IDCInDetBSErrContainer_Cache > m_bsErrorsCacheKey
SG::ReadCondHandleKey< PixelCablingCondData > m_condCablingKey
SG::UpdateHandleKey< PixelRDO_Cache > m_rdoCacheKey
ToolHandle< IPixelRawDataProviderTool > m_rawDataTool
ToolHandle< IRegSelTool > m_regionSelector
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)
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.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
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