|  | 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_ICpmRoiByteStreamV1Tool(
"CpmRoiByteStreamV1Tool",
 
   33   return IID_ICpmRoiByteStreamV1Tool;
 
   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<CpmRoiByteStreamV1Tool>(
this);
 
   49                   "Tool to collect errors for monitoring");
 
   51                   "Offset of CP crate numbers in bytestream");
 
   53                   "Offset of CP crate numbers in RDOs");
 
   57                   "ROB fragment source identifiers");
 
   59                   "ROB fragment source identifiers for RoIBs");
 
   63                   "Format version number in sub-block header");
 
   65                   "Format identifier (0-1) in sub-block header");
 
   67                   "The number of S-Links per crate");
 
   69                   "Minimum crate number, allows partial output");
 
   71                   "Maximum crate number, allows partial output");
 
   91   return StatusCode::SUCCESS;
 
  109   std::set<uint32_t> dupCheck;
 
  110   std::set<uint32_t> dupRoiCheck;
 
  113   for (; rob != robEnd; ++rob) {
 
  117       msg() << 
"Treating ROB fragment " << robCount << 
endmsg;
 
  122     uint32_t robid = (*rob)->source_id();
 
  123     if ((*rob)->nstatus() > 0) {
 
  125       (*rob)->status(robData);
 
  128     if (
debug) 
msg() << 
"ROB status error - skipping fragment" << 
endmsg;
 
  135     if (!dupCheck.insert(robid).second) {
 
  146     (*rob)->rod_data(payloadBeg);
 
  147     payloadEnd = payloadBeg + (*rob)->rod_ndata();
 
  155     const uint32_t sourceID = (*rob)->rod_source_id();
 
  164         msg() << 
"Wrong source identifier in data: " 
  165               << MSG::hex << sourceID << MSG::dec << 
endmsg;
 
  171     const int minorVersion = (*rob)->rod_version() & 0xffff;
 
  178       msg() << 
"Treating crate " << rodCrate 
 
  186       const int headerWords = userHeader.
words();
 
  187       if (headerWords != 1 ) {
 
  189         if (
debug) 
msg() << 
"Unexpected number of user header words: " 
  193       for (
int i = 0; 
i < headerWords; ++
i) ++
payload;
 
  199     while (
payload != payloadEnd) {
 
  205           msg() << 
"CPM RoI sub-block: Crate " << subBlock.
crate()
 
  212         msg() << 
"CPM RoI sub-block unpacking failed: " << errMsg << 
endmsg;
 
  217     const int numChips = 8;
 
  218     const int numLocs  = 2;
 
  219     for (
int chip = 0; chip < numChips; ++chip) {
 
  220       for (
int loc = 0; loc < numLocs; ++loc) {
 
  232         if (
debug) 
msg() << 
"Inconsistent RoI crate number: " 
  238         if (
debug) 
msg() << 
"Invalid CPM number: " 
  243       const uint32_t location = (*payload) & 0xfffc0000;
 
  244           if (dupRoiCheck.insert(location).second) {
 
  249         if (
debug) 
msg() << 
"Duplicate RoI word " 
  255       if (
debug) 
msg() << 
"Invalid RoI word " 
  267   return StatusCode::SUCCESS;
 
  282                                                         "CpmRoiByteStreamV1") );
 
  298   CpmRoiMap::const_iterator mapIter    = roiMap.begin();
 
  299   CpmRoiMap::const_iterator mapIterEnd = roiMap.end();
 
  314       if (
mod%modulesPerSlink == 0) {
 
  315     const int daqOrRoi = 1;
 
  316     const int slink = (
m_slinks == 2) ? 2*(
mod/modulesPerSlink)
 
  317                                       : 
mod/modulesPerSlink;
 
  319           msg() << 
"Treating crate " << hwCrate
 
  320                 << 
" slink " << slink << 
endmsg 
  329       theROD->push_back(userHeader.
header());
 
  343       for (; mapIter != mapIterEnd; ++mapIter) {
 
  345     if (roi->
crate() < crate)  
continue;
 
  346     if (roi->
crate() > crate)  
break;
 
  350       if (neutralFormat) subBlock.
fillRoi(*roi);
 
  351           else theROD->push_back(roi->
roiWord());
 
  358         if ( !subBlock.
pack()) {
 
  359           msg(MSG::ERROR) << 
"CPMRoI sub-block packing failed" << 
endmsg;
 
  360       return StatusCode::FAILURE;
 
  363       msg() << 
"CPMRoI sub-block data words: " 
  366         subBlock.
write(theROD);
 
  371   return StatusCode::SUCCESS;
 
  392             for (
int slink = 0; slink < maxSlinks; ++slink)
 
  394                 const int daqOrRoi = 1;
 
  400                     if (slink < 2) 
sourceIDs.push_back(robId);
 
  402                 else if (slink >= 2) 
sourceIDs.push_back(robId);
 
  411                                                       const std::string& sgKey)
 const 
  413   const std::string 
flag(
"RoIB");
 
  414   const std::string::size_type 
pos = sgKey.find(
flag);
 
  416            (
pos == std::string::npos || 
pos != sgKey.length() - 
flag.length());
 
  423     static const std::vector<uint32_t> sourceIDsRoIB = 
makeSourceIDs(roiDaq);
 
  424     return sourceIDsRoIB;
 
  438     for (; 
pos != pose; ++
pos) {
 
  441       roiMap.insert(std::make_pair(
key, roi));
 
  
uint16_t minorVersionPreLS1() const
Return last ROD header minor version for pre-LS1 data.
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.
void fillRoi(LVL1::CPMRoI roi)
Store RoI.
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.
void clear()
Clear all data.
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.
LVL1::CPMRoI roi(int chip, int loc) const
Return RoI for given chip and location (left/right)
int cpm() const
Return CPM number (1-14)
::StatusCode StatusCode
StatusCode definition for legacy code.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
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.
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 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.
Sub-Block class for CPM RoI data (neutral format).
std::vector< uint32_t > RODDATA
ROD data as a vector of unsigned int.
bool unpack()
Unpack data.
int maxSlinks() const
Return the maximum possible number of slinks.
int crate() const
Return crate number (0-1)
void setRoiHeader(int version, int crate, int module)
Store header.
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.