|
ATLAS Offline Software
|
Go to the documentation of this file.
12 #include "GaudiKernel/IInterface.h"
13 #include "GaudiKernel/MsgStream.h"
14 #include "GaudiKernel/StatusCode.h"
28 static const InterfaceID IID_ICpmRoiByteStreamTool(
"CpmRoiByteStreamTool",
33 return IID_ICpmRoiByteStreamTool;
39 const std::string&
name,
42 m_errorTool(
"LVL1BS::L1CaloErrorByteStreamTool/L1CaloErrorByteStreamTool"),
43 m_crates(4), m_modules(14),
44 m_subDetector (
eformat::TDAQ_CALO_CLUSTER_PROC_ROI)
46 declareInterface<CpmRoiByteStreamTool>(
this);
49 "Offset of CP crate numbers in bytestream");
51 "Offset of CP crate numbers in RDOs");
55 "ROB fragment source identifiers");
57 "ROB fragment source identifiers for RoIBs");
61 "Format version number in sub-block header");
63 "Format identifier (0-1) in sub-block header");
65 "The number of S-Links per crate");
85 return StatusCode::SUCCESS;
103 std::set<uint32_t> dupCheck;
104 std::set<uint32_t> dupRoiCheck;
107 for (; rob != robEnd; ++rob) {
111 msg() <<
"Treating ROB fragment " << robCount <<
endmsg;
116 uint32_t robid = (*rob)->source_id();
117 if ((*rob)->nstatus() > 0) {
119 (*rob)->status(robData);
122 if (
debug)
msg() <<
"ROB status error - skipping fragment" <<
endmsg;
129 if (!dupCheck.insert(robid).second) {
140 (*rob)->rod_data(payloadBeg);
141 payloadEnd = payloadBeg + (*rob)->rod_ndata();
149 const uint32_t sourceID = (*rob)->rod_source_id();
158 msg() <<
"Wrong source identifier in data: "
159 << MSG::hex << sourceID << MSG::dec <<
endmsg;
165 msg() <<
"Treating crate " << rodCrate
172 const int minorVersion = (*rob)->rod_version() & 0xffff;
174 const int headerWords = userHeader.
words();
175 if (headerWords != 1 ) {
177 if (
debug)
msg() <<
"Unexpected number of user header words: "
181 for (
int i = 0;
i < headerWords; ++
i) ++
payload;
187 while (
payload != payloadEnd) {
193 msg() <<
"CPM RoI sub-block: Crate " << subBlock.
crate()
200 msg() <<
"CPM RoI sub-block unpacking failed: " << errMsg <<
endmsg;
205 const int numChips = 8;
206 const int numLocs = 2;
207 for (
int chip = 0; chip < numChips; ++chip) {
208 for (
int loc = 0; loc < numLocs; ++loc) {
220 if (
debug)
msg() <<
"Inconsistent RoI crate number: "
226 if (
debug)
msg() <<
"Invalid CPM number: "
231 const uint32_t location = (*payload) & 0xfffc0000;
232 if (dupRoiCheck.insert(location).second) {
237 if (
debug)
msg() <<
"Duplicate RoI word "
243 if (
debug)
msg() <<
"Invalid RoI word "
255 return StatusCode::SUCCESS;
270 "CpmRoiByteStream") );
286 CpmRoiMap::const_iterator mapIter = roiMap.begin();
287 CpmRoiMap::const_iterator mapIterEnd = roiMap.end();
293 for (
int crate=0; crate <
m_crates; ++crate) {
302 if (
mod%modulesPerSlink == 0) {
303 const int daqOrRoi = 1;
304 const int slink = (
m_slinks == 2) ? 2*(
mod/modulesPerSlink)
305 :
mod/modulesPerSlink;
307 msg() <<
"Treating crate " << hwCrate
308 <<
" slink " << slink <<
endmsg
317 theROD->push_back(userHeader.
header());
331 for (; mapIter != mapIterEnd; ++mapIter) {
333 if (roi->
crate() < crate)
continue;
334 if (roi->
crate() > crate)
break;
338 if (neutralFormat) subBlock.
fillRoi(*roi);
339 else theROD->push_back(roi->
roiWord());
346 if ( !subBlock.
pack()) {
347 msg(MSG::ERROR) <<
"CPMRoI sub-block packing failed" <<
endmsg;
348 return StatusCode::FAILURE;
351 msg() <<
"CPMRoI sub-block data words: "
354 subBlock.
write(theROD);
359 return StatusCode::SUCCESS;
380 for (
int slink = 0; slink < maxSlinks; ++slink)
382 const int daqOrRoi = 1;
388 if (slink < 2)
sourceIDs.push_back(robId);
390 else if (slink >= 2)
sourceIDs.push_back(robId);
399 const std::string& sgKey)
const
401 const std::string
flag(
"RoIB");
402 const std::string::size_type
pos = sgKey.find(
flag);
404 (
pos == std::string::npos ||
pos != sgKey.length() -
flag.length());
411 static const std::vector<uint32_t> sourceIDsRoIB =
makeSourceIDs(roiDaq);
412 return sourceIDsRoIB;
426 for (;
pos != pose; ++
pos) {
429 roiMap.insert(std::make_pair(
key, roi));
int slink(uint32_t code) const
Return slink from unpacked moduleID.
Const iterator class for DataVector/DataList.
int unpackErrorCode() const
Return the unpacking error code.
Template class for assembling a full atlas raw event from subfragments.
bool unpack()
Unpack data.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Sub-Block class for CPM RoI data (neutral format).
void write(FullEventAssembler< L1CaloSrcIdMap >::RODDATA *theROD) const
Output complete packed sub-block to ROD vector.
bool msgLvl(const MSG::Level lvl) const
uint32_t getRobID(uint32_t rod_id) const
Make a ROB Source ID from a ROD source ID.
LVL1::CPMRoI roi(int chip, int loc) const
Return RoI for given chip and location (left/right)
OFFLINE_FRAGMENTS_NAMESPACE::PointerType read(const OFFLINE_FRAGMENTS_NAMESPACE::PointerType beg, const OFFLINE_FRAGMENTS_NAMESPACE::PointerType end)
Input complete packed sub-block from ROD array.
int hits() const
Return hit thresholds map.
int cpm() const
Return CPM number (1-14)
void clear()
Clear all data.
::StatusCode StatusCode
StatusCode definition for legacy code.
int crate(uint32_t code) const
Return crate from unpacked moduleID.
std::vector< const ROBF * > VROBFRAG
int error() const
Return error flags (bit 0 Saturation, bit 1 Parity)
static SubBlockWordType wordType(uint32_t word)
Word identification.
uint32_t roiWord() const
Return packed RoI word.
std::string unpackErrorMsg() const
Return the unpacking error message for printing.
uint16_t minorVersion() const
Return ROD header minor version to use when writing BS.
bool setRoiWord(uint32_t roiWord)
Set RoI word with ID check.
int dataWords() const
Return number of data words.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
eformat::SubDetector subDet(uint32_t code) const
Return sub-detector for given ID.
void fillRoi(LVL1::CPMRoI roi)
Store RoI.
void setRodMinorVersion(uint16_t m)
change the ROD minor version
uint32_t getRodID(int crate, int slink, int daqOrRoi, eformat::SubDetector subdet) const
Make a ROD Source ID.
std::vector< uint32_t > RODDATA
ROD data as a vector of unsigned int.
int maxSlinks() const
Return the maximum possible number of slinks.
void setRoiHeader(int version, int crate, int module)
Store header.
int crate() const
Return crate number (0-1)
int daqOrRoi(uint32_t code) const
Return daqOrRoi from unpacked moduleID.
RODDATA * getRodData(uint32_t id)
get a block of ROD data
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.