47 {
48
49
50
51
52 const eformat::helper::SourceIdentifier sid(
m_robIds.value().at(0));
53 auto it = std::find_if(vrobf.begin(), vrobf.end(), [&sid](
const ROBF* rob){return rob->rob_source_id() == sid.code();});
54 if (it == vrobf.end()) {
55 ATH_MSG_ERROR(
"No CTP ROB fragment with ID 0x" << std::hex << sid.code() << std::dec <<
" was found!");
56 return StatusCode::FAILURE;
57 }
58 ATH_MSG_VERBOSE(
"Found CTP ROD with source ID 0x" << MSG::hex << sid.code() << MSG::dec);
59
60
61
62
65 rob->rod_data( it_data );
66 const uint32_t ndata = rob->rod_ndata();
67
68
69
70
71 uint32_t headerMarker = eformat::ROD;
72 uint32_t formatVersion = rob->rod_version();
74 uint32_t sourceID = rob->rod_source_id();
76 uint32_t trigType = rob->rod_lvl1_trigger_type();
78 uint32_t evtType = rob->rod_detev_type();
79
80
81
82
85 dataStatus.rod_error = false;
86 dataStatus.status_word = 0;
87 dataStatus.status_info = 0;
88
89 try {
91 }
92 catch (std::exception const & ex) {
94 dataStatus.rob_error = true;
95 }
96
97 try {
99 }
100 catch (std::exception const & ex) {
102 dataStatus.rod_error = true;
103 }
104
105
107 rob->rod_status(status);
108 uint32_t nstatus = rob->rod_nstatus();
109 if (msgLvl(MSG::VERBOSE)) {
111 for (uint32_t i=0;
i<nstatus; ++
i, ++
status) {
112 ATH_MSG_VERBOSE(
" Status word: 0x" << MSG::hex << std::setw(8) << std::setfill(
'0') << *status);
113 }
114 }
115 rob->rod_status(status);
116
117 if(nstatus > 0) dataStatus.status_word =
static_cast<uint32_t>(*status);
118 if(nstatus > 1) {
120 dataStatus.status_info =
static_cast<uint32_t>(*status);
121 }
122
123 uint32_t errStatus = dataStatus.status_word;
124 uint32_t statInfo = dataStatus.status_info;
125
126
127
128
129 std::vector<uint32_t> vDataWords;
130 vDataWords.reserve(ndata);
131 if (msgLvl(MSG::VERBOSE)) {
134 ATH_MSG_VERBOSE(
" 0x" << MSG::hex << std::setfill(
'0') << std::setw(8) << word << MSG::dec);
135 }
136 }
138
140 nExtraWords=CTPfragment::numberExtraPayloadWords(rob);
141 unsigned int ctpVersionNumber = CTPfragment::ctpFormatVersion(rob);
142
143
144
145
146 auto result = std::make_unique<xAOD::CTPResult>();
147 auto resultAux = std::make_unique<xAOD::CTPResultAuxInfo>();
148 result->setStore(resultAux.get());
149
150
152
153
154 result->setHeader(headerMarker, formatVersion, sourceID, L1ID, runNum, bcid, trigType, evtType);
155 result->setTrailer(ndata, errStatus, statInfo);
156 result->setL1AcceptBunchPosition(CTPfragment::lvl1AcceptBunch(rob));
157 result->setTurnCounter(CTPfragment::turnCounter(rob));
158
159
162 ATH_CHECK( ctpResultWriteHandle.
record( std::move(result), std::move(resultAux) ));
164
165 return StatusCode::SUCCESS;
166}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment ROBF
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
void initialize(xAOD::CTPResult &ctpRes, const uint32_t ctpVersionNumber, std::vector< uint32_t > &data, const uint32_t nExtraWords)
Initialize the object using xAOD::Header, xAOD::Trailer, and the payload data.
const std::string print(const xAOD::CTPResult &ctpRes)
Print object content in human readable format in a string.
span(T *ptr, std::size_t sz) -> span< T >
A couple needed deduction guides.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
setEventNumber setTimeStamp bcid