|
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"
30 static const InterfaceID IID_ICpmRoiByteStreamV2Tool(
"CpmRoiByteStreamV2Tool",
35 return IID_ICpmRoiByteStreamV2Tool;
41 const std::string &
name,
44 m_robDataProvider(
"ROBDataProviderSvc",
name),
45 m_errorTool(
"LVL1BS::L1CaloErrorByteStreamTool/L1CaloErrorByteStreamTool"),
46 m_crates(4), m_modules(14),
47 m_subDetector (
eformat::TDAQ_CALO_CLUSTER_PROC_ROI)
49 declareInterface<CpmRoiByteStreamV2Tool>(
this);
52 "Tool to collect errors for monitoring");
54 "Offset of CP crate numbers in bytestream");
56 "Offset of CP crate numbers in RDOs");
60 "ROB fragment source identifiers");
62 "ROB fragment source identifiers for RoIBs");
66 "Format version number in sub-block header");
68 "Format identifier (0-1) in sub-block header");
70 "The number of S-Links per crate");
72 "Minimum crate number, allows partial output");
74 "Maximum crate number, allows partial output");
77 "Set it for M7 raw data");
97 return StatusCode::SUCCESS;
103 const std::string& sgKey,
106 const std::vector<uint32_t>& vID(
sourceIDs(sgKey));
109 m_robDataProvider->getROBData(Gaudi::Hive::currentContext(), vID, robFrags,
"CpmRoiByteStreamV2Tool");
110 ATH_MSG_DEBUG(
"Number of ROB fragments:" << robFrags.size());
111 return convert(robFrags, collection);
127 std::set<uint32_t> dupCheck;
128 std::set<uint32_t> dupRoiCheck;
131 for (; rob != robEnd; ++rob)
137 msg() <<
"Treating ROB fragment " << robCount <<
endmsg;
142 uint32_t robid = (*rob)->source_id();
143 if ((*rob)->nstatus() > 0)
146 (*rob)->status(robData);
150 if (
debug)
msg() <<
"ROB status error - skipping fragment" <<
endmsg;
157 if (!dupCheck.insert(robid).second)
169 (*rob)->rod_data(payloadBeg);
170 payloadEnd = payloadBeg + (*rob)->rod_ndata();
179 const uint32_t sourceID = (*rob)->rod_source_id();
190 msg() <<
"Wrong source identifier in data: "
191 << MSG::hex << sourceID << MSG::dec <<
endmsg;
197 const int minorVersion = (*rob)->rod_version() & 0xffff;
206 msg() <<
"Treating crate " << rodCrate
215 const int headerWords = userHeader.
words();
216 if (headerWords != 1 )
219 if (
debug)
msg() <<
"Unexpected number of user header words: "
223 for (
int i = 0;
i < headerWords; ++
i) ++
payload;
238 msg() <<
"CPM RoI sub-block: Crate " << subBlock.
crate()
247 msg() <<
"CPM RoI sub-block unpacking failed: " << errMsg <<
endmsg;
252 const int numChips = 8;
253 const int numLocs = 2;
254 const int numTypes = 2;
255 for (
int chip = 0; chip < numChips; ++chip)
257 for (
int loc = 0; loc < numLocs; ++loc)
282 if (
debug)
msg() <<
"Inconsistent RoI crate number: "
289 if (
debug)
msg() <<
"Invalid CPM number: "
295 if (dupRoiCheck.insert(location).second)
304 if (
debug)
msg() <<
"Duplicate RoI word "
312 if (
debug)
msg() <<
"Invalid RoI word "
325 msg() <<
"Number of RoIs read = " << roiCollection->
size() <<
endmsg;
328 return StatusCode::SUCCESS;
342 "CpmRoiByteStreamV2") );
361 msg() <<
"Number of RoIs to be written = " << roiCollection->
size()
362 <<
" (collection), " << roiMap.size() <<
" (map)"
366 CpmRoiMap::const_iterator mapIter = roiMap.begin();
367 CpmRoiMap::const_iterator mapIterEnd = roiMap.end();
384 if (
mod % modulesPerSlink == 0)
386 const int daqOrRoi = 1;
387 const int slink = (
m_slinks == 2) ? 2 * (
mod / modulesPerSlink)
388 :
mod / modulesPerSlink;
391 msg() <<
"Treating crate " << hwCrate
392 <<
" slink " << slink <<
endmsg
402 theROD->push_back(userHeader.
header());
417 for (; mapIter != mapIterEnd; ++mapIter)
420 if (roi->
crate() < crate)
continue;
421 if (roi->
crate() > crate)
break;
426 if (neutralFormat) subBlock.
fillRoi(*roi);
427 else theROD->push_back(roi->
roiWord());
436 if ( !subBlock.
pack())
438 msg(MSG::ERROR) <<
"CPMTobRoI sub-block packing failed" <<
endmsg;
439 return StatusCode::FAILURE;
443 msg() <<
"CPMTobRoI sub-block data words: "
446 subBlock.
write(theROD);
457 return StatusCode::SUCCESS;
478 for (
int slink = 0; slink < maxSlinks; ++slink)
480 const int daqOrRoi = 1;
486 if (slink < 2)
sourceIDs.push_back(robId);
488 else if (slink >= 2)
sourceIDs.push_back(robId);
497 const std::string &sgKey)
const
499 const std::string
flag(
"RoIB");
500 const std::string::size_type
pos = sgKey.find(
flag);
502 (
pos == std::string::npos ||
pos != sgKey.length() -
flag.length());
509 static const std::vector<uint32_t> sourceIDsRoIB =
makeSourceIDs(roiDaq);
510 return sourceIDsRoIB;
525 for (;
pos != pose; ++
pos)
529 const int crate = roi->
crate();
530 const int cpm = roi->
cpm();
531 const int chip = roi->
chip();
532 const int loc = roi->
location() >> 2;
533 const uint32_t key = (((((((crate << 4) | cpm) << 3) | chip) << 1) | loc) << 1) |
type;
534 roiMap.insert(std::make_pair(
key, roi));
uint16_t minorVersionPreLS1() const
Return last ROD header minor version for pre-LS1 data.
int cpm() const
Return CPM number (1-14)
int slink(uint32_t code) const
Return slink from unpacked moduleID.
int type() const
Return type em/tau (0/1)
Const iterator class for DataVector/DataList.
Sub-Block class for CPM RoI data (neutral format) post LS1.
int energy() const
Return energy.
int unpackErrorCode() const
Return the unpacking error code.
Template class for assembling a full atlas raw event from subfragments.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
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.
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.
uint32_t roiWord() const
Return packed RoI word.
LVL1::CPMTobRoI roi(int chip, int loc, int type) const
Return RoI for given chip and location (left/right) and type (em/tau)
::StatusCode StatusCode
StatusCode definition for legacy code.
int crate(uint32_t code) const
Return crate from unpacked moduleID.
std::vector< const ROBF * > VROBFRAG
int crate() const
Return crate number (0-1)
static SubBlockWordType wordType(uint32_t word)
Word identification.
bool unpack()
Unpack data.
std::string unpackErrorMsg() const
Return the unpacking error message for printing.
int chip() const
Return CP chip number (0-7)
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.
int isolation() const
Return isolation.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
int location() const
Return location (RoI local coords) (0-7)
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 setRoiHeader(int version, int crate, int module)
Store header.
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.
void clear()
Clear all data.
int maxSlinks() const
Return the maximum possible number of slinks.
size_type size() const noexcept
Returns the number of elements in the collection.
int daqOrRoi(uint32_t code) const
Return daqOrRoi from unpacked moduleID.
void fillRoi(LVL1::CPMTobRoI roi)
Store RoI.
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.