ATLAS Offline Software
Loading...
Searching...
No Matches
ITkStripsRodDecoder Class Reference

#include <ITkStripsRodDecoder.h>

Inheritance diagram for ITkStripsRodDecoder:
Collaboration diagram for ITkStripsRodDecoder:

Classes

struct  CacheHelper
 Temp object to help with trigger caching. More...
struct  SharedData
 Struct to hold data shared in methods used in fillCollection method. More...

Public Member Functions

virtual ~ITkStripsRodDecoder ()=default
 Destructor.
virtual StatusCode initialize () override
 Initialize.
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.

Private Types

enum  ITk_DecoderNumbers { N_SIDES = 2 , N_CHIPS_PER_SIDE = 6 , N_STRIPS_PER_CHIP = 128 , N_STRIPS_PER_SIDE = 9999 }
 Define frequently used magic numbers. More...

Private Member Functions

int makeRDO (SharedData &data, CacheHelper &cache, DataPool< SCT3_RawData > *dataItemsPool) const
 Builds RawData RDO and adds to RDO container.
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.
StatusCode addSingleError (const IdentifierHash &hashID, SCT_ByteStreamErrors::ErrorType error, SCT_RodDecoderErrorsHelper &errs) const
 Add single eror.
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 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.
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.

Private Attributes

const SCT_ID * m_itkStripsID {nullptr}
 Identifier helper class for the SCT subdetector that creates compact Identifier objects and IdentifierHash or hash IDs.
IdContext m_contextITk
 "Context" of an expanded identifier (ExpandedIdentifier) for compact or hash versions (Identifier32 or IdentifierHash)
ToolHandle< IITkStripCablingTool > m_cabling
 Providing mappings of online and offline identifiers and also serial numbers.
std::atomic_uint m_singleCondHitNumber {0}
 Total number of single strips with hit decoded in condensed mode.
std::atomic_uint m_pairedCondHitNumber {0}
 Total number of paired strips with hit decoded in condensed mode.
std::atomic_uint m_firstExpHitNumber {0}
 Total number of first strips with hit decoded in expanded mode.
std::atomic_uint m_evenExpHitNumber {0}
 Total number of consecutive paired strips with hit decoded in expanded mode.
std::atomic_uint m_lastExpHitNumber {0}
 Total number of last consecutive strips with hit decoded in expanded mode.
std::atomic_uint m_headNumber {0}
 Total number of decoded header data.
std::atomic_uint m_trailerNumber {0}
 Total number of decoded trailer data.
std::atomic_uint m_headErrorBCID {0}
 Total number of BCID errors in the header data.
std::atomic_uint m_headErrorLvl1ID {0}
 Total number of Lvl1ID errors in the header data.
std::atomic_uint m_headErrorTimeout {0}
 Total number of timeout errors in the header data.
std::atomic_uint m_headErrorFormatter {0}
 Total number of formatter errors in the header data.
std::atomic_uint m_headErrorPreamble {0}
 Total number of preamble errors in the header data.
std::atomic_uint m_trailerErrorOverflow {0}
 Total number of overflow errors in the trailer data.
std::atomic_uint m_trailerErrorLimit {0}
 Total number of header trailer limit errors in the trailer data.
std::atomic_uint m_trailerErrorBit {0}
 Total number of trailer bit errors.
std::atomic_uint m_configDataBit {0}
 Total number of configuration data for raw data.
std::atomic_uint m_flagErrorBit {0}
 Total number of flag error data.
std::atomic_uint m_condHit1Error {0}
 Total number of first hit data errors.
std::atomic_uint m_condHit2Error {0}
 Total number second hit data errors.
std::atomic_uint m_chipNumberError {0}
 Total number of chip number errors.
std::atomic_uint m_unknownDataFormat {0}
 Total number of unknown data formats.
std::atomic_uint m_nHits {0}
 Total number of SCT hits in ByteStream.
std::atomic_uint m_nRDOs {0}
 Total number of SCT RDOs created.
std::atomic_uint m_maskedLinkNumber {0}
 Total number of masked links in the header data.
std::atomic_uint m_maskedRODNumber {0}
 Total number of masked RDOs.
std::atomic_uint m_rodClockErrorNumber {0}
 Total number of ROD clock errors.
std::atomic_uint m_truncatedRODNumber {0}
 Total number of truncated ROBFragments.
std::atomic_uint m_numMissingLinkHeader {0}
 Total number of missing link headers.
std::vector< bool > m_swapPhiReadoutDirection {}
 Swap phi readout direction.

Detailed Description

Definition at line 72 of file ITkStripsRodDecoder.h.

Member Enumeration Documentation

◆ ITk_DecoderNumbers

Define frequently used magic numbers.

Enumerator
N_SIDES 
N_CHIPS_PER_SIDE 
N_STRIPS_PER_CHIP 
N_STRIPS_PER_SIDE 

Definition at line 114 of file ITkStripsRodDecoder.h.

Constructor & Destructor Documentation

◆ ~ITkStripsRodDecoder()

virtual ITkStripsRodDecoder::~ITkStripsRodDecoder ( )
virtualdefault

Destructor.

Member Function Documentation

◆ addRODError()

StatusCode ITkStripsRodDecoder::addRODError ( uint32_t rodID,
SCT_ByteStreamErrors::ErrorType error,
SCT_RodDecoderErrorsHelper & errs,
const std::unordered_set< IdentifierHash > * foundHashes = nullptr ) const
private

Add an error for each wafer in the problematic ROD.

Parameters
rodIDIdentifer of ROD.
errorTypeError type info.
errsByte stream error container.
foundHashesFE-links whose headers are found. Used only for MissingLinkHeaderError.

Definition at line 236 of file ITkStripsRodDecoder.cxx.

239{
240 return StatusCode::SUCCESS;
241}

◆ addSingleError()

StatusCode ITkStripsRodDecoder::addSingleError ( const IdentifierHash & hashID,
SCT_ByteStreamErrors::ErrorType error,
SCT_RodDecoderErrorsHelper & errs ) const
private

Add single eror.

Parameters
hashIDIdentifier for hash.
bsErrorTypeByte Stream error type info.
errsByte stream error container.

Definition at line 245 of file ITkStripsRodDecoder.cxx.

248{
249 return StatusCode::SUCCESS;
250}

◆ fillCollection()

StatusCode ITkStripsRodDecoder::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
overridevirtual

Fill SCT RDO Collection with decoded ROB data.

Decode the rob data fragment and fill the collection SCT_RDO_Collection with the RDO built by the makeRDO(..) method. rdoIdc, and errs are updated based on robFrag and vecHash.

Parameters
robFragROB fragment.
rdoIDContRDO ID Container to be filled.
errsByte stream error container.
vecHashVector of hashes.

Definition at line 42 of file ITkStripsRodDecoder.cxx.

48{
49 SCT_RodDecoderErrorsHelper errs = errorsIDC; // on destruction will fill the IDC
50
51 const uint32_t robID=robFrag.rod_source_id();
52
53 StatusCode sc = StatusCode::SUCCESS;
54
56 data.reset();
57
58 CacheHelper cache; // For the trigger
59 cache.vecHash = vecHash;
60
62 const unsigned long int vecROBDataSize{robFrag.rod_ndata()};
63 if (vecROBDataSize > robFrag.payload_size_word()) {
64 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()
65 << " header size: " << robFrag.rod_header_size_word()
66 << " trailer size: " << robFrag.rod_trailer_size_word()
67 << " fragment size: " << robFrag.rod_fragment_size_word()
68 << ")");
69 return StatusCode::RECOVERABLE;
70 }
71 robFrag.rod_data(vecROBData);
72
73 ATH_MSG_DEBUG("vecROBDataSize: " << vecROBDataSize);
74
75 // Loop over header, hit element, flagged ABCD error, raw data, trailer words
76 for (uint32_t i=0; i<vecROBDataSize; i++) {
77 // The data is 16-bits wide packed to a 32-bit word (rob_it1). So we unpack it here.
78 ATH_MSG_DEBUG("ROB: "<< std::bitset<32>(vecROBData[i]));
79 }
80
81 const uint8_t* vecROBData_8bits = reinterpret_cast<const uint8_t*>(vecROBData);
82 const size_t total_bytes = vecROBDataSize * sizeof(uint32_t);
83
84 uint32_t nclusters = 0;
85 uint8_t isHCCHeader = 0;
86 int nPacket = 0;
87 uint16_t hccword1 = 0;
88 uint8_t word8 = 0;
89 uint8_t HccHeadFound = 0;
90 uint16_t packetSize = 0;
91 bool noClusterTag = false;
92
93 for (size_t i=0; i < total_bytes; i+=2) {
94 //Read Header
95 bool hasError = false;
96 bool breakNow = false;
97 uint16_t psize=packetSize/4;
98 uint16_t word16 = (vecROBData_8bits[i] << 8) | vecROBData_8bits[i + 1];
99 ATH_MSG_DEBUG(" 16-bit word: " << std::bitset<16>(word16) << " " << (uint32_t)i << " " << total_bytes );
100
101 if(i==total_bytes-2) ATH_MSG_DEBUG("nClusters found (this): " << (uint32_t)nclusters);
102 ATH_MSG_DEBUG("Check: " << nPacket << " Packets: " << packetSize/4 << " isHCCHeader: " << (uint32_t)isHCCHeader << " " << nPacket);
103
104 if(psize != 0 && nPacket != 0){
105 ATH_MSG_DEBUG("check: " << (nPacket+1) % (packetSize/2));
106 if((nPacket+1) % (packetSize/2)==0) nPacket=-1;
107 }
108
109 if(word16 == 0 && noClusterTag && nPacket != 0){
110 ATH_MSG_DEBUG("Skip empty end of packet 16-bit word: ");
111 nPacket++;
112 }else if((vecROBData_8bits[i] == 0 || isHCCHeader == 1) && HccHeadFound == 0 && nPacket<2){
113 //HCC header found
114 ATH_MSG_DEBUG("HCC header found, will decode the next three 8-bit words: " <<(uint32_t)isHCCHeader);
115 if(isHCCHeader == 0){
116 hccword1 = (vecROBData_8bits[i + 1] << 8) | vecROBData_8bits[i+2];
117 ATH_MSG_DEBUG("HCC header: "<<std::bitset<16>(hccword1));
118 } else if(isHCCHeader == 1){
119 word8 = vecROBData_8bits[i + 1];
120 ATH_MSG_DEBUG("HCC header: "<<std::bitset<8>(word8));
121 }
122 ATH_CHECK(processHccHeader(hccword1, word8, isHCCHeader, robID, data, rdoIDCont, dataItemsPool, cache, errs, hasError, breakNow,ctx));
123 if(isHCCHeader==0) HccHeadFound = 1;
124 nPacket++;
125 noClusterTag=false;
126 }else if((HccHeadFound==1 && vecROBData_8bits[i] == 0) || HccHeadFound==2){
127 if(HccHeadFound==1) HccHeadFound=2;
128 else if(HccHeadFound==2){
129 packetSize = word16;
130 ATH_MSG_DEBUG("Packet size is: " << packetSize );
131 HccHeadFound=0;
132 }
133 nPacket++;
134 }else if(packetSize!=0 && ((vecROBData_8bits[i] & 0xF8) == 0x18) && (((nPacket+1) % (packetSize/2)) == 5)){
135 nPacket++;
136 ATH_MSG_DEBUG("Header found: " << std::bitset<16>(word16));
137 nclusters=0;
138 ATH_CHECK(processHeader(word16, robID, data, rdoIDCont, dataItemsPool, cache, errs, hasError, breakNow,ctx));
139 }else{
140 nPacket++;
141 if(word16 == 0xed6f){
142 ATH_MSG_DEBUG("No more clusters found");
143 noClusterTag=true;
144 continue;
145 }else{
146 nclusters+=1;
147 ATH_CHECK(processHits(word16, robID, data, rdoIDCont, dataItemsPool, cache, errs, hasError, ctx));
148 }
149 }
150 }
151
152 for (auto& [hash, rdoColl] : data.rdoCollMap) {
153 if (rdoColl==nullptr) continue; // nullptr means the collection is already filled.
154
155 if (rdoColl->empty()) { // Empty collection is not filled.
156 rdoColl.reset();
157 errs.removeIfEmpty(hash); // To get the same result as before. Not sure whether we need this.
158 continue;
159 }
160
161 ATH_CHECK(data.writeHandleMap[hash].addOrDelete(std::move(rdoColl)));
162 }
163
164 if (sc.isFailure()) ATH_MSG_DEBUG("One or more ByteStream errors found ");
165 return sc;
166}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_WARNING(x,...)
static Double_t sc
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.
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.
void removeIfEmpty(const IdentifierHash id)
::StatusCode StatusCode
StatusCode definition for legacy code.
const DataType * PointerType
Definition RawEvent.h:25
const IIntersectionCache * cache() const
Retrieve the associated cache block, if it exists.
setWord1 uint16_t
setEventNumber uint32_t
Temp object to help with trigger caching.
Struct to hold data shared in methods used in fillCollection method.

◆ initialize()

StatusCode ITkStripsRodDecoder::initialize ( )
overridevirtual

Initialize.

Definition at line 20 of file ITkStripsRodDecoder.cxx.

21{
22
23 // Retrieve cabling tool
24 ATH_CHECK(m_cabling.retrieve());
25 ATH_MSG_DEBUG("Retrieved tool " << m_cabling);
26 ATH_CHECK(detStore()->retrieve(m_itkStripsID,"SCT_ID"));
27 m_contextITk = m_itkStripsID->wafer_context();
28 m_swapPhiReadoutDirection.resize(m_itkStripsID->wafer_hash_max(), false);
29 const InDetDD::SCT_DetectorManager* itkStripsDetManager{nullptr};
30 ATH_CHECK(detStore()->retrieve(itkStripsDetManager, "ITkStrip"));
31 const InDetDD::SiDetectorElementCollection* sctDetElementColl{itkStripsDetManager->getDetectorElementCollection()};
32 for (const InDetDD::SiDetectorElement* element: *sctDetElementColl) {
33 if (element->swapPhiReadoutDirection()) {
34 m_swapPhiReadoutDirection[element->identifyHash()] = true;
35 }
36 }
37 ATH_MSG_DEBUG("Initialization was successful");
38 return StatusCode::SUCCESS;
39}
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...
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.
virtual const SiDetectorElementCollection * getDetectorElementCollection() const override
access to whole collectiom

◆ makeRDO()

int ITkStripsRodDecoder::makeRDO ( SharedData & data,
CacheHelper & cache,
DataPool< SCT3_RawData > * dataItemsPool ) const
private

Builds RawData RDO and adds to RDO container.

Method that builds the RawData RDO and add it to the collection rdoIdc and cache are updated based on other arguments.

Returns
Method has 3 possible return values: 1 if RDO was successfully created 0 if collection was deliberately skipped (for trigger) -1 if there was an error in the decoding - will be passed on as StatusCode::RECOVERABLE by fillCollection()
Parameters
dataStruct to hold data shared in methods used in fillCollection method
cacheCache.

Definition at line 170 of file ITkStripsRodDecoder.cxx.

173{
174 // If the link is already decoded, RDO will not be created.
175 SCT_RDO_Collection* rdoColl{data.rdoCollMap[data.linkIDHash].get()};
176 if (rdoColl==nullptr) {
177 ATH_MSG_WARNING("Null rdoCollection pointer found for linkIDHash: " << (uint32_t)data.linkIDHash);
178 return 0;
179 }
180
181 int strip = data.strip;
182 if (((strip & 0x7F) + (data.groupSize-1) >= 9999) or (strip<0) or (strip>=9999)) {
183 ATH_MSG_WARNING("Cluster with " << data.groupSize << " strips, starting at strip " << strip
184 << " in collection " << data.linkIDHash << " out of range. Will not make RDO");
185 return -1;
186 }
187
188 // This option is for the trigger, if there is a vecHash* given, test it!
189 if (cache.vecHash) {
190 if (data.linkIDHash == cache.skipHash) {
191 ATH_MSG_VERBOSE("Collection for Hash not to be decoded, skip");
192 return 0;
193 }
194 else if (data.linkIDHash != cache.lastHash) {
195 cache.lastHash = data.linkIDHash;
196 // Maybe the new hash is not in the list, so test it
197 std::vector<IdentifierHash>::const_iterator hashIDIterator{find(cache.vecHash->begin(),
198 cache.vecHash->end(),
199 data.linkIDHash)};
200 if (hashIDIterator == cache.vecHash->end()) {
201 ATH_MSG_VERBOSE("Collection for Hash not to be decoded, skip");
202 // Remember this one, so that we do not find(...) forever
203 cache.skipHash = data.linkIDHash;
204 return 0;
205 }
206 }
207 }
208
209 // Get identifier from the hash, this is not nice
210 const Identifier digitID{m_itkStripsID->strip_id(data.collID, strip)};
211 if (not m_itkStripsID->is_sct(digitID)) {
212 ATH_MSG_WARNING("Cluster with invalid Identifier. Will not make RDO");
213 return -1;
214 }
215
216 const unsigned int rawDataWord{static_cast<unsigned int>(data.groupSize | (strip << 11) | (data.timeBin <<22) | (data.errors << 25))};
217
218 ATH_MSG_DEBUG("Output Raw Data " << std::hex << " Coll " << data.collID.getString()
219 << ":-> " << m_itkStripsID->print_to_string(digitID) << std::dec);
220
221 // Now the Collection is there for sure. Create RDO and push it into Collection.
222 m_nRDOs++;
223
224 if(dataItemsPool){
225 SCT3_RawData* sct_rdo = dataItemsPool->nextElementPtr();
226 (*sct_rdo) = SCT3_RawData(digitID, rawDataWord, &(data.errorHit));
227 rdoColl->push_back(sct_rdo);
228 }else{
229 rdoColl->push_back(std::make_unique<SCT3_RawData>(digitID, rawDataWord, &(data.errorHit)));
230 }
231 return 1;
232}
#define ATH_MSG_VERBOSE(x,...)
InDetRawDataCollection< SCT_RDORawData > SCT_RDO_Collection
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)
std::atomic_uint m_nRDOs
Total number of SCT RDOs created.
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:140

◆ processHccHeader()

StatusCode ITkStripsRodDecoder::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
private

Process header word.

Parameters
inDatainput 16 bit data word for header
robIDROB ID
dataStruct to hold data shared in methods used in fillCollection method
rdoIDContRDO ID Container to be filled.
cacheCache.
errsSCT_RodDecoderErrorsHelper to fill IDCInDetBSErrContainer
hasErrorfalse means no error, true means at least one error
breakNowto tell if need to break after this method execution.

Definition at line 253 of file ITkStripsRodDecoder.cxx.

265{
266
267 StatusCode sc{StatusCode::SUCCESS};
268
269 if(isHCCHeader == 1){
270 isHCCHeader = 0;
271 ATH_MSG_DEBUG("Decoding HCC bits");
272 /*24 bits in total
273 bits from 24-8 are in hccword1
274 Last 8bits are in word8
275 */
276 uint8_t barrel = ((hccword1 >> 8) & 0x80);
277 ATH_MSG_DEBUG("is barrel: " << std::bitset<16>(hccword1 >> 8) << " " << std::bitset<8>(barrel));
278 uint8_t side = ((hccword1 >> 5) & 0x80);
279 ATH_MSG_DEBUG("side : " << std::bitset<16>(hccword1 >> 5) << " " << std::bitset<8>(side));
280 uint8_t disk = ((hccword1 >> 9) & 0x7);
281 ATH_MSG_DEBUG("disk : " << std::bitset<16>((hccword1 >> 9) & 0x7) << " " << std::bitset<8>(disk));
282 uint8_t inout = ((hccword1 >> 8) & 0x1);
283 ATH_MSG_DEBUG("inout : " << std::bitset<16>((hccword1 >> 8) & 0x1) << " " << std::bitset<8>(inout));
284 uint8_t phi_petal = ((hccword1 >> 7) & 0x1);
285 ATH_MSG_DEBUG("phi petal: " << std::bitset<16>((hccword1 >> 7) & 0x1) << " " << std::bitset<8>(phi_petal));
286 uint8_t phihcc = hccword1 & 0x7F;
287 ATH_MSG_DEBUG("phihcc : " << std::bitset<16>(hccword1 & 0x7F) << " " << std::bitset<8>(phihcc));
288 uint8_t hccnum = word8 & 0x80;
289 ATH_MSG_DEBUG("hccnum : " << std::bitset<16>(word8 & 0x80) << " " << std::bitset<8>(hccnum));
290 uint8_t eta_amod = word8 & 0x3F;
291 ATH_MSG_DEBUG("eta amod: " << std::bitset<16>(word8 & 0x3F) << " " << std::bitset<8>(eta_amod));
292
293 bool isbarrel = (barrel != 0x0);
294 bool issideA = (side != 0x0);
295 bool isinout = (inout == 0x1);
296 bool ispetal = (barrel == 0x0);
297 uint8_t hccN = (hccnum == 0x80) ? 2 : 1;
298
299 uint8_t phi_mod = (!isbarrel && eta_amod > 9) ? 2 * phihcc + phi_petal : phihcc;
300 int eta_module = isbarrel ? (issideA ? static_cast<int>(eta_amod) : -static_cast<int>(eta_amod)) : static_cast<int>(eta_amod);
301
302 ATH_MSG_DEBUG("isBarrel: " << isbarrel << " isSideA: " << issideA << " disk: " << (uint32_t)disk);
303 ATH_MSG_DEBUG("isInOut: " << isinout << " isPetal: " << ispetal << " phimod: " << (uint32_t)phi_mod);
304 ATH_MSG_DEBUG("HCCNum: " << (uint32_t)hccN << " etamod: " << (int)eta_module);
305
306 int barrel_ec = isbarrel ? 0 : (issideA ? 2 : -2);
307
308 const Identifier waferID = m_itkStripsID -> wafer_id(barrel_ec, disk, phi_mod, eta_module, inout);
309 const IdentifierHash offlinehash = m_itkStripsID -> wafer_hash(waferID);
310 data.setCollection(m_itkStripsID, offlinehash, rdoIDCont, dataItemsPool, errs);
311
312 data.side = inout;
313
314 ATH_MSG_DEBUG("hccheader " << isbarrel << " " << issideA << " " << (uint32_t)disk << " "
315 << (uint32_t)inout << " " << (uint32_t)phi_mod << " " << (uint32_t)eta_module << " " << (uint32_t)hccN );
316 }
317 else isHCCHeader++;
318
319 return sc;
320}

◆ processHeader()

StatusCode ITkStripsRodDecoder::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
private

Process header word.

Parameters
inDatainput 16 bit data word for header
robIDROB ID
dataStruct to hold data shared in methods used in fillCollection method
rdoIDContRDO ID Container to be filled.
cacheCache.
errsSCT_RodDecoderErrorsHelper to fill IDCInDetBSErrContainer
hasErrorfalse means no error, true means at least one error
breakNowto tell if need to break after this method execution.

Definition at line 323 of file ITkStripsRodDecoder.cxx.

333{
334 StatusCode sc = StatusCode::SUCCESS;
335
336 data.foundHeader = true;
337 m_headNumber++;
338
339 uint8_t type = (word16 >> 12) & 0xF; // bits [15:12]
340 // Useful information
341 uint8_t l0tag = (word16 >> 4) & 0x7F; // bits [10:4]
342 uint8_t bcid_low = (word16 >> 1) & 0x7; // bits [3:1]
343 uint8_t bcid_xor = word16 & 0x1; // bits [0]
344
345 ATH_MSG_DEBUG("l0tag: " << (uint32_t)l0tag << " bcid_low: " << (uint32_t)bcid_low << " bcid_xor: " << (uint32_t)bcid_xor
346 << " type: " << (uint32_t)type << " word16: " << std::bitset<16>(word16));
347
348 if (type == 0x01) { // PR Header
349 constexpr bool breakHere{false};
350 ATH_MSG_DEBUG("PR Packet Found");
351 if (hasError) sc = StatusCode::RECOVERABLE;
352 if (breakHere) return sc;
353 } else {
354 ATH_MSG_WARNING("Unexpected packet type (not PR): 0x" << std::hex << int(type));
355 return sc;
356 }
357
358 // Everything is set to default for a new hunt of RDO
359 data.reset();
360
361 // Link Number (or stream) in the ROD fragment
362 const int rodlinkNumber{static_cast<int>(word16 & 0x7F)};
363
364 // This is the real calculation for the offline
365 data.linkNumber = (((rodlinkNumber >>4)&0x7)*12+(rodlinkNumber &0xF));
366 const uint32_t onlineID{(robID & 0xFFFFFF) | (data.linkNumber << 24)};
367 ATH_MSG_DEBUG("OnlineID: " << (uint32_t)onlineID << " Link number: " << data.linkNumber);
368 IdentifierHash hash;
369 if ((onlineID ==0) or (data.linkNumber > 95)) {
370 ATH_CHECK(addSingleError(data.linkIDHash, SCT_ByteStreamErrors::ByteStreamParseError, errs));
371 hasError = true;
372 ATH_MSG_DEBUG("Header: xxx Link number out of range (skipping following data)"
373 << std::dec << data.linkNumber);
374 breakNow = true;
375 return sc;
376 }
377 else {
378 hash = m_cabling->getHashFromOnlineId(onlineID, ctx);
379 if (hash.is_valid()) {
380 ATH_MSG_DEBUG("setCollectionCall");
381 //data.setCollection(m_itkStripsID, hash, rdoIDCont, dataItemsPool, errs);
382 }
383 else {
384 std::stringstream msg;
385 msg <<std::hex << onlineID;
386 ATH_MSG_WARNING("Rob fragment (rob=" << robID << ") with invalid onlineID " << msg.str() << " -> " << hash << ".");
387 }
388 }
389 if (!hasError and not hash.is_valid()) {
390 std::stringstream msg;
391 msg <<std::hex << onlineID;
392 ATH_MSG_WARNING("Rob fragment (rob=" << robID << ") with invalid onlineID " << msg.str() << " -> " << hash << ".");
393 hasError = true;
394 }
395
396 data.condensedMode = static_cast<bool>(word16 & 0x100);
397
398 return sc;
399}
StatusCode addSingleError(const IdentifierHash &hashID, SCT_ByteStreamErrors::ErrorType error, SCT_RodDecoderErrorsHelper &errs) const
Add single eror.
std::atomic_uint m_headNumber
Total number of decoded header data.
MsgStream & msg
Definition testRead.cxx:32

◆ processHits()

StatusCode ITkStripsRodDecoder::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
private

Process raw data word.

Parameters
inDatainput 16 bit data word for header
robIDROB ID
dataStruct to hold data shared in methods used in fillCollection method
errsSCT_RodDecoderErrorsHelper to fill IDCInDetBSErrContainer
hasErrorfalse means no error, true means at least one error

Definition at line 401 of file ITkStripsRodDecoder.cxx.

410{
411 StatusCode sc = StatusCode::SUCCESS;
412
413 uint nchip = (word16 >> 11) & 0xF;
414 bool isSecondRow = (word16 >> 10) & 0x01; // Near/Far Strip selector (0 = Near, 1 = Far)
415 uint8_t address = (word16 >> 3) & 0x7F; // Strip local address in the selected row [0,127]
416
417 //Get the next three strips in the cluster
418 uint8_t firsthit = (word16 >> 2) & 0x1;
419 uint8_t secondhit = (word16 >> 1) & 0x1;
420 uint8_t thirdhit = (word16) & 0x1;
421
422 ATH_MSG_DEBUG("First hit: " << std::bitset<16>(firsthit));
423 ATH_MSG_DEBUG("Second hit: " << std::bitset<16>(secondhit));
424 ATH_MSG_DEBUG("Third hit: " << std::bitset<16>(thirdhit));
425
426 uint8_t stripN1 = 0,stripN2 = 0,stripN3=0;
427 uint8_t addr = 0;
428
429 if(firsthit) {
430 addr = address+1;
431 stripN1 = 2*addr + (isSecondRow ? 1 : 0);
432 }
433 if(secondhit) {
434 addr = address+2;
435 stripN2 = 2*addr + (isSecondRow ? 1 : 0);
436 }
437 if(thirdhit) {
438 addr = address+3;
439 stripN3 = 2*addr + (isSecondRow ? 1 : 0);
440 }
441
442 ATH_MSG_DEBUG("Consecutive strips: " << (uint32_t)stripN1 << " " << (uint32_t)stripN2 << " " << (uint32_t)stripN3);
443 const std::array<bool, 4> hits_n = {true , static_cast<bool>(firsthit),
444 static_cast<bool>(secondhit),
445 static_cast<bool>(thirdhit)};
446 //int strip_logical_channel = 2*address + (isSecondRow ? 1 : 0); // May be needed later
447
448 for (int i = 0; i < 4; i++){
449 if (!hits_n[i]){
450 continue;
451 }
452 data.strip = nchip * 128 + (address + i);
453
454 ATH_MSG_DEBUG("abcclusters " << (uint32_t)nchip << " " << (uint32_t)data.strip);
455
456 data.groupSize = 1;
457
458 const int rdoMade = makeRDO(data, cache, dataItemsPool);
459 if (rdoMade == -1) {
460 hasError = true;
461 ATH_CHECK(addSingleError(data.linkIDHash, SCT_ByteStreamErrors::ByteStreamParseError, errs));
462 } else {
463 data.setSaved(rdoMade);
464 }
465 }
466
467 return sc;
468}
unsigned int uint
int makeRDO(SharedData &data, CacheHelper &cache, DataPool< SCT3_RawData > *dataItemsPool) const
Builds RawData RDO and adds to RDO container.

Member Data Documentation

◆ m_cabling

ToolHandle<IITkStripCablingTool> ITkStripsRodDecoder::m_cabling
private
Initial value:
{this,
"ITkStripCablingTool",
"ITkStripCablingTool",
"Tool to retrieve ITkStrip Cabling"}

Providing mappings of online and offline identifiers and also serial numbers.

Definition at line 321 of file ITkStripsRodDecoder.h.

321 {this,
322 "ITkStripCablingTool",
323 "ITkStripCablingTool",
324 "Tool to retrieve ITkStrip Cabling"};

◆ m_chipNumberError

std::atomic_uint ITkStripsRodDecoder::m_chipNumberError {0}
mutableprivate

Total number of chip number errors.

Definition at line 384 of file ITkStripsRodDecoder.h.

384{0};

◆ m_condHit1Error

std::atomic_uint ITkStripsRodDecoder::m_condHit1Error {0}
mutableprivate

Total number of first hit data errors.

Definition at line 378 of file ITkStripsRodDecoder.h.

378{0};

◆ m_condHit2Error

std::atomic_uint ITkStripsRodDecoder::m_condHit2Error {0}
mutableprivate

Total number second hit data errors.

Definition at line 381 of file ITkStripsRodDecoder.h.

381{0};

◆ m_configDataBit

std::atomic_uint ITkStripsRodDecoder::m_configDataBit {0}
mutableprivate

Total number of configuration data for raw data.

Definition at line 372 of file ITkStripsRodDecoder.h.

372{0};

◆ m_contextITk

IdContext ITkStripsRodDecoder::m_contextITk
private

"Context" of an expanded identifier (ExpandedIdentifier) for compact or hash versions (Identifier32 or IdentifierHash)

Definition at line 318 of file ITkStripsRodDecoder.h.

◆ m_evenExpHitNumber

std::atomic_uint ITkStripsRodDecoder::m_evenExpHitNumber {0}
mutableprivate

Total number of consecutive paired strips with hit decoded in expanded mode.

Definition at line 336 of file ITkStripsRodDecoder.h.

336{0};

◆ m_firstExpHitNumber

std::atomic_uint ITkStripsRodDecoder::m_firstExpHitNumber {0}
mutableprivate

Total number of first strips with hit decoded in expanded mode.

Definition at line 333 of file ITkStripsRodDecoder.h.

333{0};

◆ m_flagErrorBit

std::atomic_uint ITkStripsRodDecoder::m_flagErrorBit {0}
mutableprivate

Total number of flag error data.

Definition at line 375 of file ITkStripsRodDecoder.h.

375{0};

◆ m_headErrorBCID

std::atomic_uint ITkStripsRodDecoder::m_headErrorBCID {0}
mutableprivate

Total number of BCID errors in the header data.

Definition at line 348 of file ITkStripsRodDecoder.h.

348{0};

◆ m_headErrorFormatter

std::atomic_uint ITkStripsRodDecoder::m_headErrorFormatter {0}
mutableprivate

Total number of formatter errors in the header data.

Definition at line 357 of file ITkStripsRodDecoder.h.

357{0};

◆ m_headErrorLvl1ID

std::atomic_uint ITkStripsRodDecoder::m_headErrorLvl1ID {0}
mutableprivate

Total number of Lvl1ID errors in the header data.

Definition at line 351 of file ITkStripsRodDecoder.h.

351{0};

◆ m_headErrorPreamble

std::atomic_uint ITkStripsRodDecoder::m_headErrorPreamble {0}
mutableprivate

Total number of preamble errors in the header data.

Definition at line 360 of file ITkStripsRodDecoder.h.

360{0};

◆ m_headErrorTimeout

std::atomic_uint ITkStripsRodDecoder::m_headErrorTimeout {0}
mutableprivate

Total number of timeout errors in the header data.

Definition at line 354 of file ITkStripsRodDecoder.h.

354{0};

◆ m_headNumber

std::atomic_uint ITkStripsRodDecoder::m_headNumber {0}
mutableprivate

Total number of decoded header data.

Definition at line 342 of file ITkStripsRodDecoder.h.

342{0};

◆ m_itkStripsID

const SCT_ID* ITkStripsRodDecoder::m_itkStripsID {nullptr}
private

Identifier helper class for the SCT subdetector that creates compact Identifier objects and IdentifierHash or hash IDs.

Also allows decoding of these IDs.

Definition at line 314 of file ITkStripsRodDecoder.h.

314{nullptr};

◆ m_lastExpHitNumber

std::atomic_uint ITkStripsRodDecoder::m_lastExpHitNumber {0}
mutableprivate

Total number of last consecutive strips with hit decoded in expanded mode.

Definition at line 339 of file ITkStripsRodDecoder.h.

339{0};

◆ m_maskedLinkNumber

std::atomic_uint ITkStripsRodDecoder::m_maskedLinkNumber {0}
mutableprivate

Total number of masked links in the header data.

Definition at line 396 of file ITkStripsRodDecoder.h.

396{0};

◆ m_maskedRODNumber

std::atomic_uint ITkStripsRodDecoder::m_maskedRODNumber {0}
mutableprivate

Total number of masked RDOs.

Definition at line 399 of file ITkStripsRodDecoder.h.

399{0};

◆ m_nHits

std::atomic_uint ITkStripsRodDecoder::m_nHits {0}
mutableprivate

Total number of SCT hits in ByteStream.

Definition at line 390 of file ITkStripsRodDecoder.h.

390{0};

◆ m_nRDOs

std::atomic_uint ITkStripsRodDecoder::m_nRDOs {0}
mutableprivate

Total number of SCT RDOs created.

Definition at line 393 of file ITkStripsRodDecoder.h.

393{0};

◆ m_numMissingLinkHeader

std::atomic_uint ITkStripsRodDecoder::m_numMissingLinkHeader {0}
mutableprivate

Total number of missing link headers.

Definition at line 408 of file ITkStripsRodDecoder.h.

408{0};

◆ m_pairedCondHitNumber

std::atomic_uint ITkStripsRodDecoder::m_pairedCondHitNumber {0}
mutableprivate

Total number of paired strips with hit decoded in condensed mode.

Definition at line 330 of file ITkStripsRodDecoder.h.

330{0};

◆ m_rodClockErrorNumber

std::atomic_uint ITkStripsRodDecoder::m_rodClockErrorNumber {0}
mutableprivate

Total number of ROD clock errors.

Definition at line 402 of file ITkStripsRodDecoder.h.

402{0};

◆ m_singleCondHitNumber

std::atomic_uint ITkStripsRodDecoder::m_singleCondHitNumber {0}
mutableprivate

Total number of single strips with hit decoded in condensed mode.

Definition at line 327 of file ITkStripsRodDecoder.h.

327{0};

◆ m_swapPhiReadoutDirection

std::vector<bool> ITkStripsRodDecoder::m_swapPhiReadoutDirection {}
private

Swap phi readout direction.

Definition at line 411 of file ITkStripsRodDecoder.h.

411{};

◆ m_trailerErrorBit

std::atomic_uint ITkStripsRodDecoder::m_trailerErrorBit {0}
mutableprivate

Total number of trailer bit errors.

Definition at line 369 of file ITkStripsRodDecoder.h.

369{0};

◆ m_trailerErrorLimit

std::atomic_uint ITkStripsRodDecoder::m_trailerErrorLimit {0}
mutableprivate

Total number of header trailer limit errors in the trailer data.

Definition at line 366 of file ITkStripsRodDecoder.h.

366{0};

◆ m_trailerErrorOverflow

std::atomic_uint ITkStripsRodDecoder::m_trailerErrorOverflow {0}
mutableprivate

Total number of overflow errors in the trailer data.

Definition at line 363 of file ITkStripsRodDecoder.h.

363{0};

◆ m_trailerNumber

std::atomic_uint ITkStripsRodDecoder::m_trailerNumber {0}
mutableprivate

Total number of decoded trailer data.

Definition at line 345 of file ITkStripsRodDecoder.h.

345{0};

◆ m_truncatedRODNumber

std::atomic_uint ITkStripsRodDecoder::m_truncatedRODNumber {0}
mutableprivate

Total number of truncated ROBFragments.

Definition at line 405 of file ITkStripsRodDecoder.h.

405{0};

◆ m_unknownDataFormat

std::atomic_uint ITkStripsRodDecoder::m_unknownDataFormat {0}
mutableprivate

Total number of unknown data formats.

Definition at line 387 of file ITkStripsRodDecoder.h.

387{0};

The documentation for this class was generated from the following files: