ATLAS Offline Software
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 
5 #include "PixelRawDataProvider.h"
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 
26 }
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 
55 
56  if (m_roiSeeded) {
58  ATH_CHECK(m_regionSelector.retrieve());
59  }else{
60  ATH_CHECK( m_roiCollectionKey.initialize(false) ); //clear if unneeded
61  m_regionSelector.disable();
62  }
63 
65 
66  return StatusCode::SUCCESS;
67 }
68 
69 // --------------------------------------------------------------------
70 // Execute
71 
73 
74 StatusCode 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->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 }
PixelRawDataProvider::m_condCablingKey
SG::ReadCondHandleKey< PixelCablingCondData > m_condCablingKey
Definition: PixelRawDataProvider.h:61
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...
PixelRawDataProvider::initialize
StatusCode initialize() override
Initialize.
Definition: PixelRawDataProvider.cxx:31
PixelRawDataProvider::m_rdoContainerKey
SG::WriteHandleKey< PixelRDO_Container > m_rdoContainerKey
Definition: PixelRawDataProvider.h:57
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
SG::ReadCondHandle< PixelCablingCondData >
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
PixelRawDataProvider::m_rdoCacheKey
SG::UpdateHandleKey< PixelRDO_Cache > m_rdoCacheKey
Definition: PixelRawDataProvider.h:58
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
SG::UpdateHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
TrigRoiDescriptor
nope - should be used for standalone also, perhaps need to protect the class def bits #ifndef XAOD_AN...
Definition: TrigRoiDescriptor.h:56
PixelRawDataProvider::m_pixel_id
const PixelID * m_pixel_id
Definition: PixelRawDataProvider.h:50
SG::UpdateHandle::ptr
pointer_type ptr()
Dereference the pointer.
EventContainers::IIdentifiableCont
Definition: IIdentifiableCont.h:13
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
EventContainers::IdentifiableContTemp
Definition: IdentifiableContTemp.h:17
EventContainers::IdentifiableContTemp::MergeToRealContainer
StatusCode MergeToRealContainer(IIdentifiableCont< T > *real)
Definition: IdentifiableContTemp.h:104
PixelRawDataProvider::m_robDataProvider
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
Definition: PixelRawDataProvider.h:53
IdentifiableContainerMT::numberOfCollections
virtual size_t numberOfCollections() const override final
return number of collections
Definition: IdentifiableContainerMT.h:216
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
RoiDescriptor::push_back
void push_back(const IRoiDescriptor *roi)
add a RoiDescriptor
Definition: RoiDescriptor.h:157
RoiDescriptor::reserve
void reserve(size_t s)
reserve elements in vector
Definition: RoiDescriptor.h:154
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
PixelRawDataProvider::PixelRawDataProvider
PixelRawDataProvider(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition: PixelRawDataProvider.cxx:16
PixelRawDataProvider::m_regionSelector
ToolHandle< IRegSelTool > m_regionSelector
Definition: PixelRawDataProvider.h:52
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
PixelRawDataProvider::m_bsErrorsKey
SG::WriteHandleKey< IDCInDetBSErrContainer > m_bsErrorsKey
Definition: PixelRawDataProvider.h:59
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
PixelRawDataProvider.h
PixelRawDataProvider::execute
StatusCode execute(const EventContext &ctx) const override
Execute.
Definition: PixelRawDataProvider.cxx:74
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
min
#define min(a, b)
Definition: cfImp.cxx:40
PixelRawDataProvider::m_roiSeeded
Gaudi::Property< bool > m_roiSeeded
Definition: PixelRawDataProvider.h:55
SG::WriteHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
PixelRawDataProvider::m_roiCollectionKey
SG::ReadHandleKey< TrigRoiDescriptorCollection > m_roiCollectionKey
Definition: PixelRawDataProvider.h:56
PixelCablingCondData::get_allRobs
const std::vector< uint32_t > & get_allRobs() const
Definition: PixelCablingCondData.cxx:171
SG::UpdateHandle
Definition: UpdateHandle.h:94
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
PixelID::wafer_hash_max
size_type wafer_hash_max(void) const
Definition: PixelID.cxx:912
EventContainers::Mode::OfflineFast
@ OfflineFast
OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment
eformat::ROBFragment< PointerType > ROBFragment
Definition: RawEvent.h:27
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
PixelRawDataProvider::~PixelRawDataProvider
~PixelRawDataProvider()
Don't need to override Finalize.
Definition: PixelRawDataProvider.cxx:25
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
IdentifiableContTemp.h
PixelRawDataProvider::m_bsErrorsCacheKey
SG::UpdateHandleKey< IDCInDetBSErrContainer_Cache > m_bsErrorsCacheKey
Definition: PixelRawDataProvider.h:60
PixelRawDataProvider::m_rawDataTool
ToolHandle< IPixelRawDataProviderTool > m_rawDataTool
Definition: PixelRawDataProvider.h:54
RoiDescriptor::setComposite
void setComposite(bool b=true)
Definition: RoiDescriptor.h:138
RoiDescriptor::manageConstituents
bool manageConstituents() const
always manage constituents ???
Definition: RoiDescriptor.h:141
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.