ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigT1
TrigT1ResultByteStream
src
ExampleL1TriggerByteStreamTool.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
// Local includes
6
#include "
ExampleL1TriggerByteStreamTool.h
"
7
8
// Trigger includes
9
#include "
xAODTrigger/MuonRoI.h
"
10
#include "
xAODTrigger/MuonRoIAuxContainer.h
"
11
12
13
// TDAQ includes
14
#include "eformat/SourceIdentifier.h"
15
#include "eformat/Status.h"
16
#include <span>
17
18
using
ROBF
=
OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment
;
19
using
WROBF
=
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment
;
20
21
ExampleL1TriggerByteStreamTool::ExampleL1TriggerByteStreamTool
(
const
std::string&
type
,
22
const
std::string& name,
23
const
IInterface* parent)
24
: base_class(
type
, name, parent) {}
25
26
StatusCode
ExampleL1TriggerByteStreamTool::initialize
() {
27
ConversionMode mode = getConversionMode(
m_roiReadKey
,
m_roiWriteKey
,
msg
());
28
ATH_CHECK
(mode!=ConversionMode::Undefined);
29
ATH_CHECK
(
m_roiWriteKey
.initialize(mode==ConversionMode::Decoding));
30
ATH_CHECK
(
m_roiReadKey
.initialize(mode==ConversionMode::Encoding));
31
ATH_MSG_DEBUG
((mode==ConversionMode::Encoding ?
"Encoding"
:
"Decoding"
) <<
" ROB IDs: "
32
<< MSG::hex <<
m_robIds
.value() << MSG::dec);
33
return
StatusCode::SUCCESS;
34
}
35
36
// BS->xAOD conversion
37
StatusCode
ExampleL1TriggerByteStreamTool::convertFromBS
(
const
std::vector<const ROBF*>& vrobf,
38
const
EventContext& eventContext)
const
{
39
if
(
m_roiWriteKey
.empty()) {
40
ATH_MSG_ERROR
(
"Conversion from BS to xAOD RoI requested but RoI WriteHandleKey is empty"
);
41
return
StatusCode::FAILURE;
42
}
43
44
// Create and record the RoI container
45
auto
handle =
SG::makeHandle
(
m_roiWriteKey
, eventContext);
46
auto
cont = std::make_unique<xAOD::MuonRoIContainer>();
47
auto
auxcont = std::make_unique<xAOD::MuonRoIAuxContainer>();
48
cont->setStore(auxcont.get());
49
ATH_CHECK
(handle.record(std::move(cont), std::move(auxcont)));
50
ATH_MSG_DEBUG
(
"Recorded MuonRoIContainer with key "
<<
m_roiWriteKey
.key());
51
52
// Find the ROB fragment to decode
53
const
eformat::helper::SourceIdentifier sid(
m_robIds
.value().at(0));
54
auto
it = std::find_if(vrobf.begin(), vrobf.end(), [&sid](
const
ROBF
* rob){return rob->rob_source_id() == sid.code();});
55
if
(it == vrobf.end()) {
56
ATH_MSG_DEBUG
(
"No MUCTPI ROB fragment with ID 0x"
<< std::hex << sid.code() << std::dec
57
<<
" was found, MuonRoIContainer will be empty"
);
58
return
StatusCode::SUCCESS;
59
}
60
61
// Iterate over ROD words and decode
62
const
ROBF
* rob = *it;
63
const
uint32_t ndata = rob->rod_ndata();
64
const
uint32_t* data = rob->rod_data();
65
ATH_MSG_DEBUG
(
"Starting to decode "
<< ndata <<
" ROD words"
);
66
for
(
const
uint32_t word : std::span{data, ndata}) {
67
ATH_MSG_DEBUG
(
"Muon RoI raw word: 0x"
<< std::hex << word << std::dec);
68
// Here comes the decoding
69
// Using some dummy values as this is not real decoding, just an example
70
handle->push_back(
new
xAOD::MuonRoI
);
71
handle->back()->initialize(word, 99, 99,
"DummyThreshold"
, 99);
72
}
73
74
ATH_MSG_DEBUG
(
"Decoded "
<< handle->size() <<
" Muon RoIs"
);
75
return
StatusCode::SUCCESS;
76
}
77
79
StatusCode
ExampleL1TriggerByteStreamTool::convertToBS
(std::vector<WROBF*>& vrobf,
80
const
xAOD::TrigCompositeContainer
*
/*tc*/
,
81
const
EventContext& eventContext) {
82
// Retrieve the RoI container
83
auto
muonRoIs =
SG::makeHandle
(
m_roiReadKey
, eventContext);
84
ATH_CHECK
(muonRoIs.isValid());
85
86
// Clear BS data cache
87
clearCache(eventContext);
88
89
// Create raw ROD data words
90
ATH_MSG_DEBUG
(
"Converting "
<< muonRoIs->size() <<
" L1 Muon RoIs to ByteStream"
);
91
uint32_t* data = newRodData(eventContext, muonRoIs->size());
92
for
(
size_t
i=0; i<muonRoIs->size(); ++i) {
93
data[i] = muonRoIs->at(i)->roiWord();
94
}
95
96
// Create ROBFragment containing the ROD words
97
const
eformat::helper::SourceIdentifier sid(
m_robIds
.value().at(0));
98
vrobf.push_back(newRobFragment(eventContext, sid.code(), muonRoIs->size(), data));
99
100
return
StatusCode::SUCCESS;
101
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
ROBF
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment ROBF
Definition
ByteStreamMergeOutputSvc.cxx:16
ExampleL1TriggerByteStreamTool.h
WROBF
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment WROBF
Definition
MCEventInfoByteStreamTool.cxx:21
MuonRoIAuxContainer.h
MuonRoI.h
ExampleL1TriggerByteStreamTool::convertToBS
virtual StatusCode convertToBS(std::vector< OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment * > &vrobf, const xAOD::TrigCompositeContainer *tc, const EventContext &eventContext) override
xAOD->BS conversion
Definition
ExampleL1TriggerByteStreamTool.cxx:79
ExampleL1TriggerByteStreamTool::m_roiReadKey
SG::ReadHandleKey< xAOD::MuonRoIContainer > m_roiReadKey
Definition
ExampleL1TriggerByteStreamTool.h:56
ExampleL1TriggerByteStreamTool::convertFromBS
virtual StatusCode convertFromBS(const std::vector< const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * > &vrobf, const EventContext &eventContext) const override
BS->xAOD conversion.
Definition
ExampleL1TriggerByteStreamTool.cxx:37
ExampleL1TriggerByteStreamTool::ExampleL1TriggerByteStreamTool
ExampleL1TriggerByteStreamTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition
ExampleL1TriggerByteStreamTool.cxx:21
ExampleL1TriggerByteStreamTool::m_robIds
Gaudi::Property< std::vector< uint32_t > > m_robIds
Definition
ExampleL1TriggerByteStreamTool.h:49
ExampleL1TriggerByteStreamTool::initialize
virtual StatusCode initialize() override
Definition
ExampleL1TriggerByteStreamTool.cxx:26
ExampleL1TriggerByteStreamTool::m_roiWriteKey
SG::WriteHandleKey< xAOD::MuonRoIContainer > m_roiWriteKey
Definition
ExampleL1TriggerByteStreamTool.h:53
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment
eformat::write::ROBFragment ROBFragment
Definition
RawEvent.h:33
OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment
eformat::ROBFragment< PointerType > ROBFragment
Definition
RawEvent.h:27
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition
ReadCondHandle.h:269
xAOD::TrigCompositeContainer
TrigCompositeContainer_v1 TrigCompositeContainer
Declare the latest version of the container.
Definition
TrigCompositeContainer.h:17
xAOD::MuonRoI
MuonRoI_v1 MuonRoI
Definition
MuonRoI.h:15
type
msg
MsgStream & msg
Definition
testRead.cxx:32
Generated on
for ATLAS Offline Software by
1.17.0