9 #include "GaudiKernel/IInterface.h"
10 #include "GaudiKernel/MsgStream.h"
11 #include "GaudiKernel/StatusCode.h"
23 bool hasEnding(std::string
const &fullString, std::string
const &ending) {
24 if (fullString.length() >= ending.length()) {
25 return (0 == fullString.compare (fullString.length() - ending.length(), ending.length(), ending));
37 static const InterfaceID IID_IRodHeaderByteStreamTool(
"RodHeaderByteStreamTool", 1, 1);
41 return IID_IRodHeaderByteStreamTool;
47 const std::string&
name,
50 m_robDataProvider(
"ROBDataProviderSvc",
name),
51 m_errorTool(
"LVL1BS::L1CaloErrorByteStreamTool/L1CaloErrorByteStreamTool")
53 declareInterface<RodHeaderByteStreamTool>(
this);
58 "Tool to collect errors for monitoring");
60 "ROB fragment source identifiers - All except RoIB");
62 "ROB fragment source identifiers - PP only");
64 "ROB fragment source identifiers - CP DAQ only");
66 "ROB fragment source identifiers - JEP DAQ only");
68 "ROB fragment source identifiers - CP RoI only");
70 "ROB fragment source identifiers - JEP RoI only");
72 "ROB fragment source identifiers - CP RoIB only");
74 "ROB fragment source identifiers - JEP RoIB only");
94 return StatusCode::SUCCESS;
101 return StatusCode::SUCCESS;
108 const std::string& sgKey,
111 const std::vector<uint32_t>& vID(
sourceIDs(sgKey));
114 m_robDataProvider->getROBData(Gaudi::Hive::currentContext(), vID, robFrags,
"RodHeaderByteStreamTool");
115 ATH_MSG_DEBUG(
"Number of ROB fragments:" << robFrags.size());
116 return convert(robFrags, rhCollection);
129 std::set<uint32_t> dupCheck;
132 for (; rob != robEnd; ++rob) {
136 msg() <<
"Treating ROB fragment " << robCount <<
endmsg;
141 uint32_t robid = (*rob)->source_id();
142 if ((*rob)->nstatus() > 0) {
144 (*rob)->status(robData);
147 if (
debug)
msg() <<
"ROB status error - skipping fragment" <<
endmsg;
154 if (!dupCheck.insert(robid).second) {
163 const uint32_t sourceId = (*rob)->rod_source_id();
165 const uint32_t lvl1Id = (*rob)->rod_lvl1_id();
167 const uint32_t trigType = (*rob)->rod_lvl1_trigger_type();
168 const uint32_t detType = (*rob)->rod_detev_type();
169 const uint32_t nData = (*rob)->rod_ndata();
173 std::vector<uint32_t> statusWords;
174 unsigned int nstatus = (*rob)->rod_nstatus();
178 (*rob)->rod_status(
status);
179 statusEnd =
status + nstatus;
189 bcId, trigType, detType, statusWords, nData));
192 <<
"ROD Header version/sourceId/run/lvl1Id/bcId/trigType/detType/nData: "
193 <<
version <<
"/" << sourceId <<
"/" <<
run <<
"/" << lvl1Id <<
"/"
194 <<
bcId <<
"/" << trigType <<
"/" << detType <<
"/" << nData
195 <<
endmsg <<
"ROD Status Words:";
196 std::vector<uint32_t>::const_iterator
pos = statusWords.begin();
197 std::vector<uint32_t>::const_iterator pose = statusWords.end();
203 return StatusCode::SUCCESS;
209 const std::string& sgKey)
const
212 static const std::vector<int> slinksPP { 0, 1, 2, 3 };
213 static const std::vector<uint32_t> sourceIDsPP =
214 makeRobIds(8, 0, slinksPP, 0, eformat::TDAQ_CALO_PREPROC,
220 static const std::vector<int> slinksCP { 0, 2 };
221 static const std::vector<uint32_t> sourceIDsCP =
222 makeRobIds(4, 8, slinksCP, 0, eformat::TDAQ_CALO_CLUSTER_PROC_DAQ,
228 static const std::vector<int> slinksCPRoI { 0 };
229 static const std::vector<uint32_t> sourceIDsCPRoI =
230 makeRobIds(4, 8, slinksCPRoI, 1, eformat::TDAQ_CALO_CLUSTER_PROC_ROI,
232 return sourceIDsCPRoI;
236 static const std::vector<int> slinksJEP { 0, 1, 2, 3 };
237 static const std::vector<uint32_t> sourceIDsJEP =
238 makeRobIds(2, 12, slinksJEP, 0, eformat::TDAQ_CALO_JET_PROC_DAQ,
244 static const std::vector<int> slinksJEPRoI { 0 };
245 static const std::vector<uint32_t> sourceIDsJEPRoI =
246 makeRobIds(2, 12, slinksJEPRoI, 1, eformat::TDAQ_CALO_JET_PROC_ROI,
248 return sourceIDsJEPRoI;
252 static const std::vector<int> slinksCPRoIB { 2 };
253 static const std::vector<uint32_t> sourceIDsCPRoIB =
254 makeRobIds(4, 8, slinksCPRoIB, 1, eformat::TDAQ_CALO_CLUSTER_PROC_ROI,
256 return sourceIDsCPRoIB;
260 static const std::vector<int> slinksJEPRoIB { 2 };
261 static const std::vector<uint32_t> sourceIDsJEPRoIB =
262 makeRobIds(2, 12, slinksJEPRoIB, 1, eformat::TDAQ_CALO_JET_PROC_ROI,
264 return sourceIDsJEPRoIB;
276 std::vector<uint32_t> robIds;
278 auto append = [&robIds] (
const std::vector<uint32_t>&
v)
279 { robIds.insert (robIds.end(),
v.begin(),
v.end()); };
293 const int crateOffset,
294 const std::vector<int>& slinks,
296 const eformat::SubDetector subdet,
297 const std::vector<uint32_t>& prop)
const
299 std::vector<uint32_t>
robs;
305 for (
int crate = 0; crate < numCrates; ++crate) {
306 const int numSlinks = slinks.size();
307 for (
int i = 0;
i < numSlinks; ++
i) {
309 slinks[
i], daqOrRoi, subdet);
311 robs.push_back (robId);
321 const std::string&
flag)
const
324 return ::hasEnding(sgKey,
flag) || ::hasEnding(sgKey,
flag +
"Aux.");