ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigT1
L1Topo
L1TopoByteStream
src
L1TopoPhase1ByteStreamTool.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
//author: @asonay
6
//email: anil.sonay@cern.ch
7
8
#include "
L1TopoPhase1ByteStreamTool.h
"
9
10
//L1TopoRDO
11
#include "
L1TopoRDO/Error.h
"
12
13
//xAOD
14
#include "
xAODTrigL1Calo/L1TopoRawData.h
"
15
16
using
ROBF
=
OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment
;
17
using
WROBF
=
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment
;
18
19
20
L1TopoPhase1ByteStreamTool::L1TopoPhase1ByteStreamTool
(
const
std::string&
type
,
21
const
std::string& name,
22
const
IInterface* parent)
23
: base_class(
type
, name, parent) {}
24
25
26
StatusCode
L1TopoPhase1ByteStreamTool::initialize
() {
27
28
ConversionMode topoRawMode = getConversionMode(
m_topoRawReadKey
,
m_topoRawWriteKey
,
msg
());
29
ATH_CHECK
(topoRawMode!=ConversionMode::Undefined);
30
ATH_CHECK
(
m_topoRawWriteKey
.initialize(topoRawMode==ConversionMode::Decoding));
31
ATH_CHECK
(
m_topoRawReadKey
.initialize(topoRawMode==ConversionMode::Encoding));
32
ATH_MSG_DEBUG
((topoRawMode==ConversionMode::Encoding ?
"Encoding"
:
"Decoding"
) <<
" topoRaw ROB IDs: "
33
<< std::hex << std::showbase <<
m_robIds
.value() << std::dec);
34
35
36
return
StatusCode::SUCCESS;
37
38
}
39
40
// BS->xAOD conversion
41
StatusCode
L1TopoPhase1ByteStreamTool::convertFromBS
(
const
std::vector<const ROBF*>& vrobf,
const
EventContext& ctx)
const
{
42
43
// prepare container
44
auto
l1topoContainer = std::make_unique<xAOD::L1TopoRawDataContainer> ();
45
auto
l1topoAuxContainer = std::make_unique<xAOD::L1TopoRawDataAuxContainer> ();
46
l1topoContainer->setStore(l1topoAuxContainer.get());
47
48
// Iterate over ROBFragments to decode
49
for
(
const
ROBF
* rob : vrobf) {
50
ATH_CHECK
(
convert
(rob, l1topoContainer) );
51
}
52
53
SG::WriteHandle<xAOD::L1TopoRawDataContainer>
l1topo_cont(
m_topoRawWriteKey
, ctx);
54
ATH_CHECK
(l1topo_cont.
record
(std::move(l1topoContainer),std::move(l1topoAuxContainer)));
55
ATH_MSG_DEBUG
(
"Recorded L1TopoRawDataContainer with key "
<< l1topo_cont.
key
());
56
57
return
StatusCode::SUCCESS;
58
}
59
60
61
// xAOD->BS conversion
62
StatusCode
L1TopoPhase1ByteStreamTool::convertToBS
(std::vector<WROBF*>& ,
63
const
xAOD::TrigCompositeContainer
*
/*tc*/
,
64
const
EventContext& ) {
65
return
StatusCode::FAILURE;
66
}
67
68
StatusCode
L1TopoPhase1ByteStreamTool::convert
(
const
ROBF
* rob,
const
std::unique_ptr<xAOD::L1TopoRawDataContainer> &container)
const
{
69
ATH_MSG_DEBUG
(
"executing convert() from ROBFragment to xAOD::L1TopoRawData"
);
70
71
uint32_t rodId = rob->rob_source_id();
72
73
ATH_MSG_DEBUG
(
"ROD sub-detector ID: 0x"
<< MSG::hex << rodId << MSG::dec);
74
75
// First use ROB & ROD error check methods
76
bool
error_rob(
false
);
77
bool
error_rod(
false
);
78
try
{
79
if
(rob->check_rob()) {
80
ATH_MSG_VERBOSE
(
"ROB fragment checked ok"
);
81
}
82
}
catch
(std::exception
const
& ex) {
83
ATH_MSG_WARNING
(
"ROB fragment not valid: "
<< ex.what());
84
error_rob =
true
;
85
}
86
try
{
87
if
(rob->check_rod()) {
88
ATH_MSG_VERBOSE
(
"ROD fragment checked ok"
);
89
}
90
}
catch
(std::exception
const
& ex) {
91
ATH_MSG_WARNING
(
"ROD fragment not valid: "
<< ex.what());
92
error_rod =
true
;
93
}
94
95
// Print some header info
96
ATH_MSG_VERBOSE
(
97
MSG::hex <<
" \n"
98
<<
" rod_version 0x"
<< rob->rod_version() <<
" \n"
99
<<
" rod_run_no 0x"
<< MSG::dec
100
<< rob->rod_run_no() <<
" \n"
101
<<
" rod_lvl1_id 0x"
<< MSG::hex
102
<< rob->rod_lvl1_id() <<
" \n"
103
<<
" rod_bc_id 0x"
<< rob->rod_bc_id() <<
" \n"
104
<<
" rod_lvl1_trigger_type 0x"
<< rob->rod_lvl1_trigger_type()
105
<<
" \n"
106
<<
" nchildren 0x"
<< rob->nchildren() <<
" \n"
107
<< MSG::dec);
108
109
// print and check status words
110
OFFLINE_FRAGMENTS_NAMESPACE::PointerType
it_status = rob->rod_status();
111
const
uint32_t nstatus = rob->rod_nstatus();
112
ATH_MSG_VERBOSE
(
"Number of status words: "
<< nstatus);
113
std::vector<uint32_t> vStatusWords;
114
vStatusWords.reserve(nstatus);
115
ATH_MSG_VERBOSE
(
"Dumping ROD status words:"
);
116
for
(uint32_t i = 0; i < nstatus; ++i, ++it_status) {
117
vStatusWords.push_back(
static_cast<
uint32_t
>
(*it_status));
118
ATH_MSG_VERBOSE
(
" 0x"
<< MSG::hex << std::setfill(
'0'
) << std::setw(8)
119
<< *it_status << MSG::dec);
120
}
121
// for definition of first status word see:
122
// - bits 00-15: https://edms.cern.ch/document/445840/5.0a section 5.8
123
// - bits 16-31: bits 16-31:
124
// https://twiki.cern.ch/twiki/bin/viewauth/Atlas/ROBINFragmentErrors
125
// Can do something more specific eventually.
126
bool
error_status(
false
);
127
if
(vStatusWords.size() == 0) {
128
ATH_MSG_WARNING
(
"ROD has no status word"
);
129
}
130
if
(vStatusWords.size() > 0 && vStatusWords.at(0) != 0) {
131
ATH_MSG_WARNING
(
"Non-zero first status word, payload may not be valid"
);
132
error_status =
true
;
133
}
134
135
// print and interpret data words and save them for RDO
136
OFFLINE_FRAGMENTS_NAMESPACE::PointerType
it_data = rob->rod_data();
137
const
uint32_t ndata = rob->rod_ndata();
138
ATH_MSG_VERBOSE
(
"Number of data words: "
<< ndata);
139
140
ATH_MSG_VERBOSE
(
"Dumping L1Topo data words:"
);
141
std::vector<uint32_t> vDataWords;
142
vDataWords.reserve(ndata);
143
for
(uint32_t i = 0; i < ndata; ++i, ++it_data) {
144
vDataWords.push_back(
static_cast<
uint32_t
>
(*it_data));
145
ATH_MSG_VERBOSE
(
" 0x"
<< MSG::hex << std::setfill(
'0'
) << std::setw(8)
146
<< *it_data << MSG::dec);
147
}
148
149
//Set Error
150
uint32_t
error
= 0;
151
if
(error_status) {
152
error
|= (1 <<
static_cast<
unsigned
int
>
(
L1Topo::Error::SLINK_STATUS_ERROR
));
153
}
154
if
(error_rob) {
155
error
|= (1 <<
static_cast<
unsigned
int
>
(
L1Topo::Error::ROB_ERROR
));
156
}
157
if
(error_rod) {
158
error
|= (1 <<
static_cast<
unsigned
int
>
(
L1Topo::Error::ROD_ERROR
));
159
}
160
161
// Fill xAOD
162
container->push_back(std::make_unique<xAOD::L1TopoRawData>());
163
container->back()->initialize(vDataWords,vStatusWords,
error
,rodId);
164
165
return
StatusCode::SUCCESS;
166
167
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
ROBF
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment ROBF
Definition
ByteStreamMergeOutputSvc.cxx:16
Error.h
L1TopoPhase1ByteStreamTool.h
L1TopoRawData.h
WROBF
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment WROBF
Definition
MCEventInfoByteStreamTool.cxx:21
L1TopoPhase1ByteStreamTool::initialize
virtual StatusCode initialize() override
Definition
L1TopoPhase1ByteStreamTool.cxx:26
L1TopoPhase1ByteStreamTool::m_robIds
Gaudi::Property< std::vector< uint32_t > > m_robIds
Definition
L1TopoPhase1ByteStreamTool.h:52
L1TopoPhase1ByteStreamTool::convertToBS
virtual StatusCode convertToBS(std::vector< OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment * > &vrobf, const xAOD::TrigCompositeContainer *tc, const EventContext &eventContext) override
xAOD->BS conversion
Definition
L1TopoPhase1ByteStreamTool.cxx:62
L1TopoPhase1ByteStreamTool::convertFromBS
virtual StatusCode convertFromBS(const std::vector< const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * > &vrobf, const EventContext &eventContext) const override
BS->xAOD conversion.
Definition
L1TopoPhase1ByteStreamTool.cxx:41
L1TopoPhase1ByteStreamTool::L1TopoPhase1ByteStreamTool
L1TopoPhase1ByteStreamTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition
L1TopoPhase1ByteStreamTool.cxx:20
L1TopoPhase1ByteStreamTool::m_topoRawWriteKey
SG::WriteHandleKey< xAOD::L1TopoRawDataContainer > m_topoRawWriteKey
Definition
L1TopoPhase1ByteStreamTool.h:55
L1TopoPhase1ByteStreamTool::m_topoRawReadKey
SG::ReadHandleKey< xAOD::L1TopoRawDataContainer > m_topoRawReadKey
Definition
L1TopoPhase1ByteStreamTool.h:58
L1TopoPhase1ByteStreamTool::convert
StatusCode convert(const ROBF *rob, const std::unique_ptr< xAOD::L1TopoRawDataContainer > &container) const
Definition
L1TopoPhase1ByteStreamTool.cxx:68
SG::VarHandleBase::key
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
Definition
AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:64
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.
L1Topo::Error::ROB_ERROR
@ ROB_ERROR
Definition
Error.h:16
L1Topo::Error::ROD_ERROR
@ ROD_ERROR
Definition
Error.h:16
L1Topo::Error::SLINK_STATUS_ERROR
@ SLINK_STATUS_ERROR
Definition
Error.h:16
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment
eformat::write::ROBFragment ROBFragment
Definition
RawEvent.h:33
OFFLINE_FRAGMENTS_NAMESPACE::PointerType
const DataType * PointerType
Definition
RawEvent.h:25
OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment
eformat::ROBFragment< PointerType > ROBFragment
Definition
RawEvent.h:27
error
Definition
IImpactPoint3dEstimator.h:72
xAOD::TrigCompositeContainer
TrigCompositeContainer_v1 TrigCompositeContainer
Declare the latest version of the container.
Definition
TrigCompositeContainer.h:17
type
msg
MsgStream & msg
Definition
testRead.cxx:32
Generated on
for ATLAS Offline Software by
1.17.0