ATLAS Offline Software
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>
6 #include "TRTRawDataProvider.h"
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 ),
20  m_rdoContainerKey("")
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) {
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 
57  ATH_CHECK( m_rdoCacheKey.initialize(SG::AllowEmpty) );
58 
59  return StatusCode::SUCCESS;
60 }
61 
62 // --------------------------------------------------------------------
63 // Execute
64 
65 StatusCode 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 
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 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
TRTRawDataProvider::m_rdoContainerKey
SG::WriteHandleKey< TRT_RDO_Container > m_rdoContainerKey
Definition: TRTRawDataProvider.h:65
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
TRTRawDataProvider::initialize
virtual StatusCode initialize()
Initialize.
Definition: TRTRawDataProvider.cxx:33
TRTRawDataProvider::m_rdoCacheKey
SG::UpdateHandleKey< TRT_RDO_Cache > m_rdoCacheKey
Definition: TRTRawDataProvider.h:67
TRTRawDataProvider::TRTRawDataProvider
TRTRawDataProvider(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition: TRTRawDataProvider.cxx:13
TrigRoiDescriptor
nope - should be used for standalone also, perhaps need to protect the class def bits #ifndef XAOD_AN...
Definition: TrigRoiDescriptor.h:56
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
TRTRawDataProvider::m_roiCollectionKey
SG::ReadHandleKey< TrigRoiDescriptorCollection > m_roiCollectionKey
Definition: TRTRawDataProvider.h:64
SG::UpdateHandle::ptr
pointer_type ptr()
Dereference the pointer.
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
TRTRawDataProvider::m_CablingSvc
ServiceHandle< ITRT_CablingSvc > m_CablingSvc
Definition: TRTRawDataProvider.h:60
TRTRawDataProvider::execute
virtual StatusCode execute(const EventContext &ctx) const
Execute.
Definition: TRTRawDataProvider.cxx:65
IdentifiableContainerMT::hasExternalCache
virtual bool hasExternalCache() const override final
Definition: IdentifiableContainerMT.h:152
TRTRawDataProvider::m_trt_id
const TRT_ID * m_trt_id
Definition: TRTRawDataProvider.h:61
IdentifiableContainerMT::numberOfCollections
virtual size_t numberOfCollections() const override final
return number of collections
Definition: IdentifiableContainerMT.h:213
RoiDescriptor::push_back
void push_back(const IRoiDescriptor *roi)
add a RoiDescriptor
Definition: RoiDescriptor.h:157
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
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
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
TRTRawDataProvider.h
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::WriteHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
SG::UpdateHandle
Definition: UpdateHandle.h:94
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
TRT_ID::straw_hash_max
size_type straw_hash_max(void) const
Definition: TRT_ID.h:929
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
TRTRawDataProvider::m_regionSelector
ToolHandle< IRegSelTool > m_regionSelector
Definition: TRTRawDataProvider.h:54
RoiDescriptor::setComposite
void setComposite(bool b=true)
Definition: RoiDescriptor.h:138
TRTRawDataProvider::m_bsErrContKey
SG::WriteHandleKey< TRT_BSErrContainer > m_bsErrContKey
Definition: TRTRawDataProvider.h:66
TRTRawDataProvider::m_roiSeeded
bool m_roiSeeded
Definition: TRTRawDataProvider.h:63
TRTRawDataProvider::m_useDataPoolWithCache
Gaudi::Property< bool > m_useDataPoolWithCache
Definition: TRTRawDataProvider.h:56
RoiDescriptor::manageConstituents
bool manageConstituents() const
always manage constituents ???
Definition: RoiDescriptor.h:141
TRTRawDataProvider::m_robDataProvider
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
Definition: TRTRawDataProvider.h:58
TRTRawDataProvider::m_rawDataTool
ToolHandle< ITRTRawDataProviderTool > m_rawDataTool
Definition: TRTRawDataProvider.h:59
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.