31 ATH_CHECK(detStore()->retrieve(itkStripsDetManager,
"ITkStrip"));
34 if (element->swapPhiReadoutDirection()) {
39 return StatusCode::SUCCESS;
47 const EventContext& ctx,
48 const std::vector<IdentifierHash>* vecHash)
const
52 const uint32_t robID=robFrag.rod_source_id();
54 StatusCode sc = StatusCode::SUCCESS;
63 const unsigned long int vecROBDataSize{robFrag.rod_ndata()};
64 if (vecROBDataSize > robFrag.payload_size_word()) {
65 ATH_MSG_WARNING(
"The ROB data does not seem to fit in the payload. Rejecting fragment (ndata size " << vecROBDataSize <<
" !< payload size " << robFrag.payload_size_word()
66 <<
" header size: " << robFrag.rod_header_size_word()
67 <<
" trailer size: " << robFrag.rod_trailer_size_word()
68 <<
" fragment size: " << robFrag.rod_fragment_size_word()
70 return StatusCode::RECOVERABLE;
72 robFrag.rod_data(vecROBData);
77 for (uint32_t i=0; i<vecROBDataSize; i++) {
82 const uint8_t* vecROBData_8bits =
reinterpret_cast<const uint8_t*
>(vecROBData);
83 const size_t total_bytes = vecROBDataSize *
sizeof(uint32_t);
85 uint32_t nclusters = 0;
86 uint8_t isHCCHeader = 0;
88 uint16_t hccword1 = 0;
90 uint8_t HccHeadFound = 0;
91 uint16_t packetSize = 0;
92 bool noClusterTag =
false;
94 for (
size_t i=0; i < total_bytes; i+=2) {
96 bool hasError =
false;
97 bool breakNow =
false;
98 uint16_t psize=packetSize/4;
99 uint16_t word16 = (vecROBData_8bits[i] << 8) | vecROBData_8bits[i + 1];
100 ATH_MSG_DEBUG(
" 16-bit word: " << std::bitset<16>(word16) <<
" " << (uint32_t)i <<
" " << total_bytes );
102 if(i==total_bytes-2)
ATH_MSG_DEBUG(
"nClusters found (this): " << (uint32_t)nclusters);
104 ATH_MSG_DEBUG(
"Check: " << nPacket <<
" Packets: " << packetSize/4 <<
" isHCCHeader: " << (uint32_t)isHCCHeader <<
" " << nPacket);
106 if(psize != 0 && nPacket != 0){
108 if((nPacket+1) % (packetSize/2)==0) nPacket=-1;
111 if(word16 == 0 && noClusterTag){
114 }
else if((vecROBData_8bits[i] == 0 || isHCCHeader == 1) && HccHeadFound == 0 && nPacket<2){
116 ATH_MSG_DEBUG(
"HCC header found, will decode the next three 8-bit words: " <<(uint32_t)isHCCHeader);
117 if(isHCCHeader == 0){
118 hccword1 = (vecROBData_8bits[i + 1] << 8) | vecROBData_8bits[i+2];
120 }
else if(isHCCHeader == 1){
121 word8 = vecROBData_8bits[i + 1];
124 ATH_CHECK(
processHccHeader(hccword1, word8, isHCCHeader, robID,
data, rdoIDCont, dataItemsPool, cache, errs, hasError, breakNow,ctx));
125 if(isHCCHeader==0) HccHeadFound = 1;
128 }
else if((HccHeadFound==1 && vecROBData_8bits[i] == 0) || HccHeadFound==2){
129 if(HccHeadFound==1) HccHeadFound=2;
130 else if(HccHeadFound==2){
136 }
else if(((vecROBData_8bits[i] & 0xF8) == 0x18) && (((nPacket+1) % (packetSize/2)) == 5)){
143 if(word16 == 0xed6f){
155 if (
data.isStripValid()) {
156 if (not
data.isSaved(
false) and
data.isOldStripValid()) {
157 const int rdoMade{
makeRDO(
false,
data, cache, dataItemsPool)};
159 sc = StatusCode::RECOVERABLE;
163 data.setSaved(
false, rdoMade);
168 for (
auto& [hash, rdoColl] :
data.rdoCollMap) {
169 if (rdoColl==
nullptr)
continue;
171 if (rdoColl->empty()) {
177 ATH_CHECK(
data.writeHandleMap[hash].addOrDelete(std::move(rdoColl)));
180 if (sc.isFailure())
ATH_MSG_DEBUG(
"One or more ByteStream errors found ");
193 if (rdoColl==
nullptr)
return 0;
198 <<
" in collection " <<
data.linkIDHash <<
" out of range. Will not make RDO");
211 std::vector<IdentifierHash>::const_iterator hashIDIterator{
find(cache.
vecHash->begin(),
214 if (hashIDIterator == cache.
vecHash->end()) {
236 const unsigned int rawDataWord{
static_cast<unsigned int>(
data.groupSize | (
strip << 11) | (
data.timeBin <<22) | (
data.errors << 25))};
238 ATH_MSG_DEBUG(
"Output Raw Data " << std::hex <<
" Coll " <<
data.collID.getString()
239 <<
":-> " <<
m_itkStripsID->print_to_string(digitID) << std::dec);
249 rdoColl->
push_back(std::make_unique<SCT3_RawData>(digitID, rawDataWord, &(
data.errorHit)));
258 const std::unordered_set<IdentifierHash>* )
const
260 return StatusCode::SUCCESS;
269 return StatusCode::SUCCESS;
275 uint8_t &isHCCHeader,
284 const EventContext& )
const
287 StatusCode sc{StatusCode::SUCCESS};
289 if(isHCCHeader == 1){
296 uint8_t
barrel = ((hccword1 >> 8) & 0x80);
297 ATH_MSG_DEBUG(
"is barrel: " << std::bitset<16>(hccword1 >> 8) <<
" " << std::bitset<8>(
barrel));
298 uint8_t side = ((hccword1 >> 5) & 0x80);
299 ATH_MSG_DEBUG(
"side : " << std::bitset<16>(hccword1 >> 5) <<
" " << std::bitset<8>(side));
300 uint8_t disk = ((hccword1 >> 9) & 0x7);
301 ATH_MSG_DEBUG(
"disk : " << std::bitset<16>((hccword1 >> 9) & 0x7) <<
" " << std::bitset<8>(disk));
302 uint8_t inout = ((hccword1 >> 8) & 0x1);
303 ATH_MSG_DEBUG(
"inout : " << std::bitset<16>((hccword1 >> 8) & 0x1) <<
" " << std::bitset<8>(inout));
304 uint8_t petal = ((hccword1 >> 7) & 0x1);
305 ATH_MSG_DEBUG(
"petal : " << std::bitset<16>((hccword1 >> 7) & 0x1) <<
" " << std::bitset<8>(petal));
306 uint8_t phimod = hccword1 & 0x7F;
307 ATH_MSG_DEBUG(
"phimod : " << std::bitset<16>(hccword1 & 0x7F) <<
" " << std::bitset<8>(phimod));
308 uint8_t hccnum = word8 & 0x80;
309 ATH_MSG_DEBUG(
"hccnum : " << std::bitset<16>(word8 & 0x80) <<
" " << std::bitset<8>(hccnum));
310 uint8_t etamod = word8 & 0x3F;
311 ATH_MSG_DEBUG(
"etamod : " << std::bitset<16>(word8 & 0x3F) <<
" " << std::bitset<8>(etamod));
313 bool isbarrel = (
barrel != 0x0);
314 bool issideA = (side != 0x0);
315 bool isinout = (inout == 0x1);
316 bool ispetal = (petal == 0x1);
317 uint8_t hccN = (hccnum == 0x80) ? 2 : 1;
320 ATH_MSG_DEBUG(
"isBarrel: " << isbarrel <<
" isSideA: " << issideA <<
" disk: " << (uint32_t)disk);
321 ATH_MSG_DEBUG(
"isInOut: " << isinout <<
" isPetal: " << ispetal <<
" phimod: " << (uint32_t)phimod);
322 ATH_MSG_DEBUG(
"HCCNum: " << (uint32_t)hccN <<
" etamod: " << (uint32_t)etamod);
324 ATH_MSG_DEBUG(
"hccheader " << isbarrel <<
" " << issideA <<
" " << (uint32_t)disk <<
" " << (uint32_t)inout <<
" " << (uint32_t)phimod <<
" " << (uint32_t)etamod <<
" " << (uint32_t)hccN );
333 const uint32_t robID,
341 const EventContext& ctx)
const
343 StatusCode sc = StatusCode::SUCCESS;
345 data.foundHeader =
true;
348 uint8_t
type = (word16 >> 11) & 0x1F;
350 uint8_t l0tag = (word16 >> 7) & 0xF;
351 uint8_t bcid_low = (word16 >> 4) & 0x7;
352 uint8_t bcid_xor = word16 & 0xF;
354 ATH_MSG_DEBUG(
"l0tag: " << (uint32_t)l0tag <<
" bcid_low: " << (uint32_t)bcid_low <<
" bcid_xor: " << (uint32_t)bcid_xor <<
" type: " << (uint32_t)
type <<
" word16: " << std::bitset<16>(word16));
357 bool breakNow{
false};
359 if (hasError) sc = StatusCode::RECOVERABLE;
360 if (breakNow)
return sc;
367 if (
data.isStripValid()) {
368 if (not
data.isSaved(
false) and
data.isOldStripValid()) {
370 const int rdoMade{
makeRDO(
false,
data, cache, dataItemsPool)};
376 data.setSaved(
false, rdoMade);
385 const int rodlinkNumber{
static_cast<int>(word16 & 0x7F)};
388 data.linkNumber = (((rodlinkNumber >>4)&0x7)*12+(rodlinkNumber &0xF));
389 const uint32_t onlineID{(robID & 0xFFFFFF) | (
data.linkNumber << 24)};
390 ATH_MSG_DEBUG(
"OnlineID: " << (uint32_t)onlineID <<
" Link number: " <<
data.linkNumber);
392 if ((onlineID ==0) or (
data.linkNumber > 95)) {
395 ATH_MSG_DEBUG(
"Header: xxx Link number out of range (skipping following data)"
396 << std::dec <<
data.linkNumber);
401 hash =
m_cabling->getHashFromOnlineId(onlineID, ctx);
402 if (hash.is_valid()) {
407 std::stringstream
msg;
408 msg <<std::hex << onlineID;
409 ATH_MSG_WARNING(
"Rob fragment (rob=" << robID <<
") with invalid onlineID " <<
msg.str() <<
" -> " << hash <<
".");
412 if (!hasError and not hash.is_valid()) {
413 std::stringstream
msg;
414 msg <<std::hex << onlineID;
415 ATH_MSG_WARNING(
"Rob fragment (rob=" << robID <<
") with invalid onlineID " <<
msg.str() <<
" -> " << hash <<
".");
419 data.condensedMode =
static_cast<bool>(word16 & 0x100);
432 const EventContext& )
const
434 StatusCode sc = StatusCode::SUCCESS;
436 uint8_t stripNumber = 0;
437 uint8_t address = (word16 >> 3) & 0xFF;
439 ATH_MSG_DEBUG(
"Cluster address: " << std::bitset<8>(address) <<
" " << (uint32_t)address);
441 stripNumber = (address >= 128) ? 2*(address-128)+1 : 2*address;
444 uint8_t firsthit = (word16 & 0x4);
445 uint8_t secondhit = (word16 & 0x2);
446 uint8_t thirdhit = (word16 & 0x1);
450 uint8_t stripN1 = 0,stripN2 = 0,stripN3=0;
452 if(firsthit != 0x0) {
454 stripN1 = (addr >= 128) ? 2*(addr-128)+1 : 2*addr;
457 if(secondhit != 0x0) {
459 stripN2 = (addr >= 128) ? 2*(addr-128)+1 : 2*addr;
462 if(thirdhit != 0x0) {
464 stripN3 = (addr >= 128) ? 2*(addr-128)+1 : 2*addr;
468 uint8_t nchip = (word16 >> 11) & 0xF;
470 ATH_MSG_DEBUG(
"Chip number: " << (
int)nchip <<
" Strip Number: " << (uint32_t)stripNumber);
471 ATH_MSG_DEBUG(
"abcclusters " << (uint32_t)nchip <<
" " << (uint32_t)stripNumber <<
" " << (uint32_t)(stripN1) <<
" " << (uint32_t)(stripN2) <<
" " << (uint32_t)(stripN3));
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
char data[hepevt_bytes_allocation_ATLAS]
InDetRawDataCollection< SCT_RDORawData > SCT_RDO_Collection
InDetRawDataContainer< InDetRawDataCollection< SCT_RDORawData > > SCT_RDO_Container
a typed memory pool that saves time spent allocation small object.
pointer nextElementPtr()
obtain the next available element in pool by pointer pool is resized if its limit has been reached On...
value_type push_back(value_type pElem)
IDC like storage for BS errors, TODO, customise implementation further so that we store int rather th...
StatusCode addSingleError(const IdentifierHash &hashID, SCT_ByteStreamErrors::ErrorType error, SCT_RodDecoderErrorsHelper &errs) const
Add single eror.
int makeRDO(const bool isOld, SharedData &data, CacheHelper &cache, DataPool< SCT3_RawData > *dataItemsPool) const
Builds RawData RDO and adds to RDO container.
std::atomic_uint m_headNumber
Total number of decoded header data.
StatusCode processHeader(const uint16_t inData, const uint32_t robID, SharedData &data, SCT_RDO_Container &rdoIDCont, DataPool< SCT3_RawData > *dataItemsPool, CacheHelper &cache, SCT_RodDecoderErrorsHelper &errs, bool &hasError, bool &breakNow, const EventContext &ctx) const
Process header word.
StatusCode processHits(const uint16_t inData, const uint32_t robID, SharedData &data, SCT_RDO_Container &rdoIDCont, DataPool< SCT3_RawData > *dataItemsPool, CacheHelper &cache, SCT_RodDecoderErrorsHelper &errs, bool &hasError, const EventContext &ctx) const
Process raw data word.
virtual StatusCode initialize() override
Initialize.
std::atomic_uint m_nRDOs
Total number of SCT RDOs created.
ToolHandle< IITkStripCablingTool > m_cabling
Providing mappings of online and offline identifiers and also serial numbers.
const SCT_ID * m_itkStripsID
Identifier helper class for the SCT subdetector that creates compact Identifier objects and Identifie...
StatusCode processHccHeader(const uint16_t inData, const uint8_t data8, uint8_t &isHCCHeader, const uint32_t robID, SharedData &data, SCT_RDO_Container &rdoIDCont, DataPool< SCT3_RawData > *dataItemsPool, CacheHelper &cache, SCT_RodDecoderErrorsHelper &errs, bool &hasError, bool &breakNow, const EventContext &ctx) const
Process header word.
virtual StatusCode fillCollection(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment &robFrag, SCT_RDO_Container &rdoIDCont, IDCInDetBSErrContainer &errs, DataPool< SCT3_RawData > *dataItemsPool, const EventContext &ctx, const std::vector< IdentifierHash > *vecHash=nullptr) const override
Fill SCT RDO Collection with decoded ROB data.
ToolHandle< ISCT_ConfigurationConditionsTool > m_configTool
Service that keeps track of configuration conditions.
IdContext m_contextITk
"Context" of an expanded identifier (ExpandedIdentifier) for compact or hash versions (Identifier32 o...
std::vector< bool > m_swapPhiReadoutDirection
Swap phi readout direction.
StatusCode addRODError(uint32_t rodID, SCT_ByteStreamErrors::ErrorType error, SCT_RodDecoderErrorsHelper &errs, const std::unordered_set< IdentifierHash > *foundHashes=nullptr) const
Add an error for each wafer in the problematic ROD.
This is a "hash" representation of an Identifier.
Dedicated detector manager extending the functionality of the SiDetectorManager with dedicated SCT in...
virtual const SiDetectorElementCollection * getDetectorElementCollection() const override
access to whole collectiom
Class to hold the SiDetectorElement objects to be put in the detector store.
Class to hold geometrical description of a silicon detector element.
allows to accumulate errors in one fillColection call
void removeIfEmpty(const IdentifierHash id)
std::string find(const std::string &s)
return a remapped string
const DataType * PointerType
eformat::ROBFragment< PointerType > ROBFragment
ErrorType
SCT byte stream error type enums used in SCT_RodDecoder, SCT_ByteStreamErrorsTool,...
Temp object to help with trigger caching.
const std::vector< IdentifierHash > * vecHash
Struct to hold data shared in methods used in fillCollection method.