ATLAS Offline Software
Loading...
Searching...
No Matches
TRTRawDataProvider.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include <memory>
7
9
10// --------------------------------------------------------------------
11// Constructor
12
14 ISvcLocator* pSvcLocator) :
15 AthReentrantAlgorithm ( name, pSvcLocator ),
16 m_robDataProvider ( "ROBDataProviderSvc", name ),
17 m_rawDataTool ( "TRTRawDataProviderTool",this ),
18 m_CablingSvc ( "TRT_CablingSvc", name ),
19 m_trt_id ( nullptr ),
21{
22 declareProperty("RoIs", m_roiCollectionKey = std::string(""), "RoIs to read in");
23 declareProperty("isRoI_Seeded", m_roiSeeded = false, "Use RoI");
24 declareProperty("RDOKey", m_rdoContainerKey = std::string("TRT_RDOs"));
25 declareProperty("BSErrkey",m_bsErrContKey = "TRT_ByteStreamErrs");
26 declareProperty("RDOCacheKey", m_rdoCacheKey);
27 declareProperty ("ProviderTool", m_rawDataTool );
28}
29
30// --------------------------------------------------------------------
31// Initialize
32
34
35 ATH_CHECK(m_robDataProvider.retrieve());
36
37 ATH_CHECK(m_rawDataTool.retrieve());
38
39 // Get the TRT Helper
40 ATH_CHECK(detStore()->retrieve(m_trt_id, "TRT_ID"));
41
42
43 if (m_roiSeeded) {
44 ATH_CHECK( m_roiCollectionKey.initialize() );
45 ATH_CHECK(m_regionSelector.retrieve());
46 }
47 else {//Only need cabling if not using RoIs
48 // Retrieve id mapping
49 ATH_CHECK(m_CablingSvc.retrieve());
50 ATH_CHECK( m_roiCollectionKey.initialize(false) ); //Clear if unneeded
51 m_regionSelector.disable();
52 }
53
54 ATH_CHECK( m_rdoContainerKey.initialize() );
55
58
59 return StatusCode::SUCCESS;
60}
61
62// --------------------------------------------------------------------
63// Execute
64
65StatusCode TRTRawDataProvider::execute(const EventContext& ctx) const
66{
68 if( m_rdoCacheKey.empty() ) {
69 rdoContainer = std::make_unique<TRT_RDO_Container>(m_trt_id->straw_hash_max(), EventContainers::Mode::OfflineFast);
70
71 }
72 else{
74 rdoContainer = std::make_unique<TRT_RDO_Container>(updateh.ptr());
75 ATH_MSG_DEBUG("Created container " << m_rdoContainerKey.key() << " using external cache " << m_rdoCacheKey.key());
76 }
77 ATH_CHECK(rdoContainer.isValid());
78
79 std::unique_ptr<TRT_BSErrContainer> bsErrCont=std::make_unique<TRT_BSErrContainer>();
80
81 std::vector<uint32_t> listOfRobs;
82 if (!m_roiSeeded) {
83 listOfRobs = m_CablingSvc->getAllRods();
84 }
85 else {//Enter RoI-seeded mode
87 ATH_CHECK(roiCollection.isValid());
88
89 TrigRoiDescriptorCollection::const_iterator roi = roiCollection->begin();
90 TrigRoiDescriptorCollection::const_iterator roiE = roiCollection->end();
91 TrigRoiDescriptor superRoI;//add all RoIs to a super-RoI
92 superRoI.setComposite(true);
93 superRoI.manageConstituents(false);
94 for (; roi!=roiE; ++roi) {
95 superRoI.push_back(*roi);
96 }
97
98 m_regionSelector->lookup(ctx)->ROBIDList( superRoI, listOfRobs );
99
100 }
101 std::vector<const ROBFragment*> listOfRobf;
102 m_robDataProvider->getROBData( ctx, listOfRobs, listOfRobf);
103
104 ATH_MSG_DEBUG( "Number of ROB fragments " << listOfRobf.size() );
105
106 // ask TRTRawDataProviderTool to decode it and to fill the IDC
107 const bool hasExternalCache = rdoContainer->hasExternalCache();
108 std::unique_ptr<DataPool<TRT_LoLumRawData>> dataItemsPool = nullptr;
109 if (!hasExternalCache) {
110 dataItemsPool = std::make_unique<DataPool<TRT_LoLumRawData>>(ctx);
111 dataItemsPool->reserve(100000); // Some large default size
112 }else if(m_useDataPoolWithCache){
113 dataItemsPool = std::make_unique<DataPool<TRT_LoLumRawData>>(ctx);
114 //this is per view so let it expand on its own in blocks
115 }
116
117 if (m_rawDataTool->convert(listOfRobf,&(*rdoContainer),bsErrCont.get(), dataItemsPool.get(), ctx).isFailure()){
118 ATH_MSG_WARNING( "BS conversion into RDOs failed" );
119 }
120 ATH_MSG_DEBUG( "Number of Collections in IDC " << rdoContainer->numberOfCollections() );
121
122
123 if (!m_bsErrContKey.empty()) {
124 ATH_MSG_DEBUG("Recording BS error container");
126 ATH_CHECK(bsErrContHdl.record(std::move(bsErrCont)));
127 }
128
129
130 return StatusCode::SUCCESS;
131}
132
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
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
void push_back(const IRoiDescriptor *roi)
add a RoiDescriptor
bool manageConstituents() const
always manage constituents ???
void setComposite(bool b=true)
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?
TRTRawDataProvider(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
SG::WriteHandleKey< TRT_BSErrContainer > m_bsErrContKey
SG::ReadHandleKey< TrigRoiDescriptorCollection > m_roiCollectionKey
ToolHandle< ITRTRawDataProviderTool > m_rawDataTool
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
virtual StatusCode initialize()
Initialize.
virtual StatusCode execute(const EventContext &ctx) const
Execute.
SG::WriteHandleKey< TRT_RDO_Container > m_rdoContainerKey
const TRT_ID * m_trt_id
ToolHandle< IRegSelTool > m_regionSelector
SG::UpdateHandleKey< TRT_RDO_Cache > m_rdoCacheKey
Gaudi::Property< bool > m_useDataPoolWithCache
ServiceHandle< ITRT_CablingSvc > m_CablingSvc
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