ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetEventCnv
TRT_RawDataByteStreamCnv
src
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
8
using
OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment
;
9
10
// --------------------------------------------------------------------
11
// Constructor
12
13
TRTRawDataProvider::TRTRawDataProvider
(
const
std::string& name,
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
33
StatusCode
TRTRawDataProvider::initialize
() {
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
56
ATH_CHECK
(
m_bsErrContKey
.initialize(
SG::AllowEmpty
) );
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
{
67
SG::WriteHandle<TRT_RDO_Container>
rdoContainer(
m_rdoContainerKey
, ctx);
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
{
73
SG::UpdateHandle<TRT_RDO_Cache>
updateh(
m_rdoCacheKey
, ctx);
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
86
SG::ReadHandle<TrigRoiDescriptorCollection>
roiCollection(
m_roiCollectionKey
, ctx);
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"
);
125
SG::WriteHandle<TRT_BSErrContainer>
bsErrContHdl{
m_bsErrContKey
, ctx};
126
ATH_CHECK
(bsErrContHdl.
record
(std::move(bsErrCont)));
127
}
128
129
130
return
StatusCode::SUCCESS;
131
}
132
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
TRTRawDataProvider.h
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
AthCommonAlgorithm< Gaudi::Algorithm >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
DataVector< TrigRoiDescriptor >::const_iterator
DataModel_detail::const_iterator< DataVector > const_iterator
Definition
DataVector.h:838
RoiDescriptor::push_back
void push_back(const IRoiDescriptor *roi)
add a RoiDescriptor
Definition
RoiDescriptor.h:158
RoiDescriptor::manageConstituents
bool manageConstituents() const
always manage constituents ???
Definition
RoiDescriptor.h:142
RoiDescriptor::setComposite
void setComposite(bool b=true)
Definition
RoiDescriptor.h:139
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::UpdateHandle
Definition
UpdateHandle.h:91
SG::UpdateHandle::ptr
pointer_type ptr()
Dereference the pointer.
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
SG::WriteHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
TRTRawDataProvider::TRTRawDataProvider
TRTRawDataProvider(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
TRTRawDataProvider.cxx:13
TRTRawDataProvider::m_bsErrContKey
SG::WriteHandleKey< TRT_BSErrContainer > m_bsErrContKey
Definition
TRTRawDataProvider.h:66
TRTRawDataProvider::m_roiCollectionKey
SG::ReadHandleKey< TrigRoiDescriptorCollection > m_roiCollectionKey
Definition
TRTRawDataProvider.h:64
TRTRawDataProvider::m_rawDataTool
ToolHandle< ITRTRawDataProviderTool > m_rawDataTool
Definition
TRTRawDataProvider.h:59
TRTRawDataProvider::m_robDataProvider
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
Definition
TRTRawDataProvider.h:58
TRTRawDataProvider::initialize
virtual StatusCode initialize()
Initialize.
Definition
TRTRawDataProvider.cxx:33
TRTRawDataProvider::execute
virtual StatusCode execute(const EventContext &ctx) const
Execute.
Definition
TRTRawDataProvider.cxx:65
TRTRawDataProvider::m_rdoContainerKey
SG::WriteHandleKey< TRT_RDO_Container > m_rdoContainerKey
Definition
TRTRawDataProvider.h:65
TRTRawDataProvider::m_trt_id
const TRT_ID * m_trt_id
Definition
TRTRawDataProvider.h:61
TRTRawDataProvider::m_roiSeeded
bool m_roiSeeded
Definition
TRTRawDataProvider.h:63
TRTRawDataProvider::m_regionSelector
ToolHandle< IRegSelTool > m_regionSelector
Definition
TRTRawDataProvider.h:54
TRTRawDataProvider::m_rdoCacheKey
SG::UpdateHandleKey< TRT_RDO_Cache > m_rdoCacheKey
Definition
TRTRawDataProvider.h:67
TRTRawDataProvider::m_useDataPoolWithCache
Gaudi::Property< bool > m_useDataPoolWithCache
Definition
TRTRawDataProvider.h:56
TRTRawDataProvider::m_CablingSvc
ServiceHandle< ITRT_CablingSvc > m_CablingSvc
Definition
TRTRawDataProvider.h:60
TrigRoiDescriptor
nope - should be used for standalone also, perhaps need to protect the class def bits ifndef XAOD_ANA...
Definition
TrigRoiDescriptor.h:48
EventContainers::Mode::OfflineFast
@ OfflineFast
Definition
IdentifiableContainerBase.h:13
OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment
eformat::ROBFragment< PointerType > ROBFragment
Definition
RawEvent.h:27
SG::AllowEmpty
@ AllowEmpty
Definition
StoreGate/StoreGate/VarHandleKey.h:27
Generated on
for ATLAS Offline Software by
1.17.0