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

Athena Algorithm Tool that provides conversion from SCT RDO to ROD format Bytestream. More...

#include <SCT_RodEncoder.h>

Inheritance diagram for SCT_RodEncoder:
Collaboration diagram for SCT_RodEncoder:

Public Member Functions

 SCT_RodEncoder (const std::string &type, const std::string &name, const IInterface *parent)
 Constructor.
virtual ~SCT_RodEncoder ()=default
 Destructor.
virtual StatusCode initialize () override
 Initialize.
virtual StatusCode finalize () override
 Finalize.
virtual void fillROD (std::vector< uint32_t > &vec32Data, const uint32_t &robID, const std::vector< const SCT_RDORawData * > &vecRDOs) const override
 Main Convert method.

Private Types

enum  ErrorWords {
  TIMEOUT_ERR =(1<<11) , L1_ERR =(1<<10) , BCID_ERR =(1<<9) , PREAMBLE_ERR =(1<<12) ,
  FORMATTER_ERR =12 , TRAILER_ERR =(1<<12) , NULL_HEADER_ERR =0 , HEADER_TRAILER_ERR =(1<<11) ,
  TRAILER_OVFLW_ERR =(1<<10) , ABCD_ERR =0 , RAWDATA_ERR =(3<<13) , NULL_TRAILER_ERR =0
}
 Definitions of enum error words to be retrieved from SCT_ByteStreamErrorSvc in fillROD(...) method. More...

Private Member Functions

void encodeData (const std::vector< int > &vecTimeBins, std::vector< uint16_t > &vec16Words, const SCT_RDORawData *rdo, const int &groupSize, const int &strip) const
 Method to encode RDO data to vector of 16 bin words.
void packFragments (std::vector< uint16_t > &vec16Words, std::vector< uint32_t > &vec32Words) const
 Method to pack vector of 16 bit words intto a vector of 32 bit words.
uint32_t set32Bits (const unsigned short int *arr16Words, const unsigned short int *position, const unsigned short int &numWords) const
 @breif Method to set pairs of 16 bit words to a 32 bit word.
int side (const SCT_RDORawData *rdo) const
 Get the side info from the RDO.
int getTimeBin (const SCT_RDORawData *rdo) const
 Get the time bin info from the RDO.
int getStrip (const SCT_RDORawData *rdo) const
 Get the strip number info from the RDO.
Identifier offlineID (const SCT_RDORawData *rdo) const
 Get the offline Identifier from the RDO.
uint32_t onlineID (const SCT_RDORawData *rdo) const
 Get the online Identifier from the RDO.
int getRODLink (const SCT_RDORawData *rdo) const
 Get the ROD link number info in the RDO header data.
uint16_t getHeaderUsingRDO (const SCT_RDORawData *rdo) const
 Get the 16-bit word for a header for a hit.
uint16_t getHeaderUsingHash (const IdentifierHash &linkHash, const int &errorWord) const
 Get the 16-bit word for a header for a link with a ByteStream error.
uint16_t getTrailer (const int &errorWord) const
 Get the 16-bit word for a trailer, with or without ByteStream errors.
void addHeadersWithErrors (const uint32_t &robID, const std::set< IdentifierHash > *errors, const ErrorWords &errType, std::vector< uint16_t > &vec16Data) const
 Add header with errors for ROB to the vector of 16 bit words.
void addTrailersWithErrors (const uint32_t &robID, const std::set< IdentifierHash > *errors, const ErrorWords &errType, std::vector< uint16_t > &vec16Data) const
 Add trailers with errors for ROB to the vector of 16 bit words.
void addSpecificErrors (const uint32_t &robID, const std::set< IdentifierHash > *errors, const ErrorWords &errType, std::vector< uint16_t > &vec16Data) const
 Add specific errors for ROB to the vector of 16 bit words.

Private Attributes

ToolHandle< ISCT_ByteStreamErrorsToolm_bsErrTool
 Tool that keeps track of modules that give rise to errors in the bytestream.
ToolHandle< ISCT_CablingToolm_cabling
 Providing mappings of online and offline identifiers and also serial numbers.
const SCT_IDm_sctID {nullptr}
 Identifier helper class for the SCT subdetector that creates compact Identifier objects and IdentifierHash or hash IDs.
BooleanProperty m_condensed
 Boolean used to determine if fillROD(...) should use Condensed or Expanded mode when decoding.
std::set< Identifierm_swapModuleID {}
 Swap Module identifier, set by SCTRawContByteStreamTool.

Detailed Description

Athena Algorithm Tool that provides conversion from SCT RDO to ROD format Bytestream.

This class inherits from AthAlgTool and ISCT_RodEncoder.

Note from Jan 09: Make SCT_RodEncoder an AlgTool again, of which there is one instance per job, rather than the lightweight class of which there was one instance per ROD. This change is motivated by the changes to write ByteStream errors back into the bytestream, as we don't want to access the ByteStreamErrorsSvc 90 times per event if we can avoid it..

Definition at line 40 of file SCT_RodEncoder.h.

Member Enumeration Documentation

◆ ErrorWords

Definitions of enum error words to be retrieved from SCT_ByteStreamErrorSvc in fillROD(...) method.

Enumerator
TIMEOUT_ERR 
L1_ERR 
BCID_ERR 
PREAMBLE_ERR 
FORMATTER_ERR 
TRAILER_ERR 
NULL_HEADER_ERR 
HEADER_TRAILER_ERR 
TRAILER_OVFLW_ERR 
ABCD_ERR 
RAWDATA_ERR 
NULL_TRAILER_ERR 

Definition at line 73 of file SCT_RodEncoder.h.

Constructor & Destructor Documentation

◆ SCT_RodEncoder()

SCT_RodEncoder::SCT_RodEncoder ( const std::string & type,
const std::string & name,
const IInterface * parent )

Constructor.

Definition at line 45 of file SCT_RodEncoder.cxx.

46 :
47 base_class(type, name, parent)
48{
49}

◆ ~SCT_RodEncoder()

virtual SCT_RodEncoder::~SCT_RodEncoder ( )
virtualdefault

Destructor.

Member Function Documentation

◆ addHeadersWithErrors()

void SCT_RodEncoder::addHeadersWithErrors ( const uint32_t & robID,
const std::set< IdentifierHash > * errors,
const ErrorWords & errType,
std::vector< uint16_t > & vec16Data ) const
private

Add header with errors for ROB to the vector of 16 bit words.

Definition at line 416 of file SCT_RodEncoder.cxx.

418{
419 for (const IdentifierHash& linkHash: *errors) {
420 const uint32_t errROBID{m_cabling->getRobIdFromHash(linkHash)};
421 if (errROBID == robID) {
422 const uint16_t header{getHeaderUsingHash(linkHash, errType)};
423 vec16Data.push_back(header);
424 const uint16_t trailer{getTrailer(NULL_TRAILER_ERR)};
425 vec16Data.push_back(trailer);
426 }
427 }
428}
uint16_t getTrailer(const int &errorWord) const
Get the 16-bit word for a trailer, with or without ByteStream errors.
ToolHandle< ISCT_CablingTool > m_cabling
Providing mappings of online and offline identifiers and also serial numbers.
uint16_t getHeaderUsingHash(const IdentifierHash &linkHash, const int &errorWord) const
Get the 16-bit word for a header for a link with a ByteStream error.
setWord1 uint16_t
setEventNumber uint32_t

◆ addSpecificErrors()

void SCT_RodEncoder::addSpecificErrors ( const uint32_t & robID,
const std::set< IdentifierHash > * errors,
const ErrorWords & errType,
std::vector< uint16_t > & vec16Data ) const
private

Add specific errors for ROB to the vector of 16 bit words.

Definition at line 445 of file SCT_RodEncoder.cxx.

447{
448 for (const IdentifierHash& linkHash: *errors) {
449 const uint32_t errROBID{m_cabling->getRobIdFromHash(linkHash)};
450 if (errROBID == robID) {
452 const uint16_t trailer{getTrailer(NULL_TRAILER_ERR)};
453 vec16Data.push_back(header);
454 vec16Data.push_back(errType);
455 vec16Data.push_back(trailer);
456 }
457 }
458}

◆ addTrailersWithErrors()

void SCT_RodEncoder::addTrailersWithErrors ( const uint32_t & robID,
const std::set< IdentifierHash > * errors,
const ErrorWords & errType,
std::vector< uint16_t > & vec16Data ) const
private

Add trailers with errors for ROB to the vector of 16 bit words.

Definition at line 431 of file SCT_RodEncoder.cxx.

433{
434 for (const IdentifierHash& linkHash: *errors) {
435 const uint32_t errROBID{m_cabling->getRobIdFromHash(linkHash)};
436 if (errROBID == robID) {
438 const uint16_t trailer{getTrailer(errType)};
439 vec16Data.push_back(header);
440 vec16Data.push_back(trailer);
441 }
442 }
443}

◆ encodeData()

void SCT_RodEncoder::encodeData ( const std::vector< int > & vecTimeBins,
std::vector< uint16_t > & vec16Words,
const SCT_RDORawData * rdo,
const int & groupSize,
const int & strip ) const
private

Method to encode RDO data to vector of 16 bin words.

Methods used by main convert methods fillROD(...).

Parameters
vecTimeBinsVector of time bins for RDOs.
vec16WordsVector of 16 bit words to filled from encoded RDO data.
rdoRDO raw data object to be encoded.
groupSizeGroup size info from the RDO.
stripStrip number info from the RDO.

Definition at line 244 of file SCT_RodEncoder.cxx.

246{
247 const int encodedSide{side(rdo) << 14};
248
249 const Identifier idColl{offlineID(rdo)};
250 int tmpStrip{strip};
251 if (m_swapModuleID.find(idColl) != m_swapModuleID.end()) { // Check if the strip has to be swapped (swap phi readout direction)
252 tmpStrip= 767 - tmpStrip;
253 tmpStrip= tmpStrip-(groupSize-1);
254 }
255
256 const int chipNum{((tmpStrip/128) & 0x7) << 11};
257 const int clustBaseAddr{((tmpStrip-(chipNum*128)) & 0x7F) << 4};
258
259 int timeBin{0};
260 int firstHitErr{0 << 2};
261 int secondHitErr{0 << 3};
262
263 const SCT3_RawData* rdoCosmic{dynamic_cast<const SCT3_RawData*>(rdo)};
264 if (rdoCosmic != nullptr) {
265 timeBin = getTimeBin(rdoCosmic);
266 firstHitErr = ((rdoCosmic)->FirstHitError()) << 2;
267 secondHitErr = ((rdoCosmic)->SecondHitError()) << 3;
268 }
269
270 if (m_condensed.value()) { // Condensed mode
271 if (groupSize == 1) { // For single hit
272 const uint16_t hitCondSingle{static_cast<uint16_t>(0x8000 | encodedSide | chipNum | clustBaseAddr | firstHitErr)};
273 vec16Words.push_back(hitCondSingle);
274 }
275 else if (groupSize == 2) { // For paired strip Hits
276 const uint16_t hitCondPaired{static_cast<uint16_t>(0x8001 | encodedSide | chipNum | clustBaseAddr | secondHitErr | firstHitErr)};
277 vec16Words.push_back(hitCondPaired);
278 }
279 } // End of Condensed mode
280
281 else { // Expanded mode
282 const int numEven{static_cast<int>((vecTimeBins.size() - 1)/2)};
283
284 // First hit
285 const uint16_t hitExpFirst{static_cast<uint16_t>(0x8000 | encodedSide | chipNum | clustBaseAddr | timeBin)};
286 vec16Words.push_back(hitExpFirst);
287
288 // Even consecutive strips to the first one 1DDD 1st consec strip 1DDD 2nd consec strip
289 for (int i{1}; i<=numEven; i++) {
290 const uint16_t hitExpEven{static_cast<uint16_t>(0x8088 | ((vecTimeBins[(2*i-1)] & 0xF) << 4) | (vecTimeBins[2*i] & 0xF))};
291 vec16Words.push_back(hitExpEven);
292 }
293 // Last bin of the Odd next hits
294 if ((not vecTimeBins.empty()) and isEven(vecTimeBins.size())) {
295 const uint16_t hitExpLast{static_cast<uint16_t>(0x8008 | (vecTimeBins[vecTimeBins.size()-1] & 0xF))};
296 vec16Words.push_back(hitExpLast);
297 }
298 } // End of Expanded mode
299
300 return;
301}
BooleanProperty m_condensed
Boolean used to determine if fillROD(...) should use Condensed or Expanded mode when decoding.
std::set< Identifier > m_swapModuleID
Swap Module identifier, set by SCTRawContByteStreamTool.
int side(const SCT_RDORawData *rdo) const
Get the side info from the RDO.
int getTimeBin(const SCT_RDORawData *rdo) const
Get the time bin info from the RDO.
Identifier offlineID(const SCT_RDORawData *rdo) const
Get the offline Identifier from the RDO.

◆ fillROD()

void SCT_RodEncoder::fillROD ( std::vector< uint32_t > & vec32Data,
const uint32_t & robID,
const std::vector< const SCT_RDORawData * > & vecRDOs ) const
overridevirtual

Main Convert method.

Converts SCT RDO to a vector of 32 bit words. Starts by retrieving and collecting errors, then loops through RDO's and decode them to 16 bit words, and then finally it packs the 16 bit word into 32 bit words vector.

Parameters
vec32DataVector of 32 bit words to be filled with encoded RDOs from the SCT.
robIDID of the current readout buffer (ROB).
vecRDOsVector containing the RDOs to be coverted to vector of 32 bit words.

Definition at line 91 of file SCT_RodEncoder.cxx.

93{
94 // Retrieve errors from SCT_ByteStreamErrorsSvc
95 const EventContext& ctx{Gaudi::Hive::currentContext()};
96 const std::set<IdentifierHash> timeOutErrors{m_bsErrTool->getErrorSet(SCT_ByteStreamErrors::TimeOutError,ctx)};
97 const std::set<IdentifierHash> lvl1IDErrors{m_bsErrTool->getErrorSet(SCT_ByteStreamErrors::LVL1IDError,ctx)};
98 const std::set<IdentifierHash> bcIDErrors{m_bsErrTool->getErrorSet(SCT_ByteStreamErrors::BCIDError,ctx)};
99 const std::set<IdentifierHash> preambleErrors{m_bsErrTool->getErrorSet(SCT_ByteStreamErrors::PreambleError,ctx)};
100 const std::set<IdentifierHash> formatterErrors{m_bsErrTool->getErrorSet(SCT_ByteStreamErrors::FormatterError,ctx)};
101 const std::set<IdentifierHash> trailerErrors{m_bsErrTool->getErrorSet(SCT_ByteStreamErrors::TrailerError,ctx)};
102 const std::set<IdentifierHash> headerTrailerErrors{m_bsErrTool->getErrorSet(SCT_ByteStreamErrors::HeaderTrailerLimitError,ctx)};
103 const std::set<IdentifierHash> trailerOverflowErrors{m_bsErrTool->getErrorSet(SCT_ByteStreamErrors::TrailerOverflowError,ctx)};
104 const std::set<IdentifierHash> abcdErrors{m_bsErrTool->getErrorSet(SCT_ByteStreamErrors::ABCDError,ctx)};
105 const std::set<IdentifierHash> rawErrors{m_bsErrTool->getErrorSet(SCT_ByteStreamErrors::RawError,ctx)};
106
107 std::vector<uint16_t> vec16Data;
108
109 // Loop over errors here - just add headers (w/ errors), trailers (w/errors), and raw and abcd errors
110 addHeadersWithErrors(robID, &timeOutErrors, TIMEOUT_ERR, vec16Data);
111 addHeadersWithErrors(robID, &lvl1IDErrors, L1_ERR, vec16Data);
112 addHeadersWithErrors(robID, &bcIDErrors, BCID_ERR, vec16Data);
113 addHeadersWithErrors(robID, &preambleErrors, PREAMBLE_ERR, vec16Data);
114 addHeadersWithErrors(robID, &formatterErrors, FORMATTER_ERR, vec16Data);
115
116 addTrailersWithErrors(robID, &trailerErrors, TRAILER_ERR, vec16Data);
117 addTrailersWithErrors(robID, &headerTrailerErrors, HEADER_TRAILER_ERR, vec16Data);
118 addTrailersWithErrors(robID, &trailerOverflowErrors, TRAILER_OVFLW_ERR, vec16Data);
119
120 addSpecificErrors(robID, &abcdErrors, ABCD_ERR, vec16Data);
121 addSpecificErrors(robID, &rawErrors, RAWDATA_ERR, vec16Data);
122
123 std::vector<bool> vec_isDuplicated(vecRDOs.size(), false);
124
125 // Loop over RDOs to check for duplicates and fill vec_isDuplicated vector
126 for (unsigned int iRDO1{0}; iRDO1<vecRDOs.size(); iRDO1++) {
127 const SCT_RDORawData* rdo1{vecRDOs.at(iRDO1)};
128 if (rdo1 == nullptr) {
129 ATH_MSG_ERROR("RDO pointer is nullptr. skipping this hit.");
130 vec_isDuplicated.at(iRDO1) = true;
131 continue;
132 }
133
134 // Check if there is another RDO with the same first strip
135 for (unsigned int iRDO2{0}; iRDO2<iRDO1; iRDO2++) {
136 const SCT_RDORawData* rdo2{vecRDOs.at(iRDO2)};
137 if (vec_isDuplicated.at(iRDO2)) continue;
138
139 if (rdo1->identify() == rdo2->identify()) {
140 // Keep RDO with larger cluster size. If cluster sizes are the same, keep the first one.
141 if (rdo1->getGroupSize() >= rdo2->getGroupSize()) {
142 vec_isDuplicated.at(iRDO2) = true;
143 }
144 else {
145 vec_isDuplicated.at(iRDO1) = true;
146 }
147 break;
148 }
149 }
150 }
151
152 std::vector<int> vecTimeBins;
153 int strip{0};
154 int timeBin{0};
155 int groupSize{0};
156
157 uint32_t lastHeader{0};
158 bool firstInROD{true};
159 uint16_t lastTrailer{0};
160
161 // Loop over RDOs to decode to 16 bit words
162 for (unsigned int iRDO{0}; iRDO<vecRDOs.size(); iRDO++) {
163 const SCT_RDORawData* rdo{vecRDOs.at(iRDO)};
164 if (vec_isDuplicated.at(iRDO)) continue;
165
166 const uint16_t header{this->getHeaderUsingRDO(rdo)};
167 if (header != lastHeader) {
168 if (not firstInROD) {
169 vec16Data.push_back(lastTrailer);
170 }
171 firstInROD = false;
172 vec16Data.push_back(header);
173 lastHeader = header;
174 lastTrailer = getTrailer(0);
175 }
176 if (m_condensed.value()) { // Condensed mode
177 strip = getStrip(rdo);
178 groupSize = rdo->getGroupSize();
179 if (groupSize == 1) { // For single hit
180 const int constGroupSize{1};
181 const int constStrip{strip};
182 encodeData(vecTimeBins, vec16Data, rdo, constGroupSize, constStrip);
183 }
184 // Sim RDO could have groupe size > 1, then they are split 2 by 2 to built the condensed BS data.
185 else { // Encoding in condensed BS paired data from groupe size > 1.
186 const int chipFirst{strip/128};
187 const int chipLast{(strip+groupSize-1)/128};
188
189 for (int chip{chipFirst}; chip<=chipLast; chip++) {
190 int tmpGroupSize = 0;
191 if (chipFirst == chipLast) tmpGroupSize = groupSize; // In case of one chip
192 else if (chip == chipLast) tmpGroupSize = strip+groupSize-chip*128; // In case of last chip
193 else if (chip == chipFirst) tmpGroupSize = (chip+1)*128-strip; // In case of first chip
194 else tmpGroupSize = 128; // In case of middle chip
195 const int tmpStrip1{chip==chipFirst ? strip : 128*chip};
196
197 const int numPairedRDO{tmpGroupSize/2};
198 for (int i =0; i<numPairedRDO; i++) {
199 const int constGroupSize{2};
200 const int constStrip{tmpStrip1+ (2*i)};
201 encodeData(vecTimeBins, vec16Data, rdo, constGroupSize, constStrip);
202 }
203 if ((tmpGroupSize != 0) and isOdd(tmpGroupSize)) {// The last hit from a cluster with odd group size
204 const int constGroupSize{1};
205 const int constStrip{tmpStrip1+ (tmpGroupSize - 1)};
206 encodeData(vecTimeBins, vec16Data, rdo, constGroupSize, constStrip);
207 }
208 }
209 }
210
211 } // End of Condensed mode
212
213 else { // Expanded mode
214 vecTimeBins.clear();
215 const SCT_RDORawData* rdo{vecRDOs.at(iRDO)};
216 //coverity[UNUSED_VALUE:FALSE]
217 strip = getStrip(rdo);
218 timeBin = getTimeBin(rdo);
219 groupSize = rdo->getGroupSize();
220
221 for (int t{0}; t < groupSize; t++) {
222 vecTimeBins.push_back(timeBin);
223 strip++;
224 }
225 const int constStrip{getStrip(rdo)};
226 const int constGroupSize{rdo->getGroupSize()};
227 encodeData(vecTimeBins, vec16Data, rdo, constGroupSize, constStrip);
228
229 } // End of Expanded mode
230 } // End of RDO decode loop
231
232 if ((not firstInROD) and (lastTrailer != 0)) {
233 vec16Data.push_back(lastTrailer);
234 }
235
236 // 16 bits TO 32 bits and pack into 32 bit vectors
237 packFragments(vec16Data,vec32Data);
238
239 return;
240}
#define ATH_MSG_ERROR(x)
virtual Identifier identify() const override final
virtual int getGroupSize() const =0
void encodeData(const std::vector< int > &vecTimeBins, std::vector< uint16_t > &vec16Words, const SCT_RDORawData *rdo, const int &groupSize, const int &strip) const
Method to encode RDO data to vector of 16 bin words.
ToolHandle< ISCT_ByteStreamErrorsTool > m_bsErrTool
Tool that keeps track of modules that give rise to errors in the bytestream.
void addTrailersWithErrors(const uint32_t &robID, const std::set< IdentifierHash > *errors, const ErrorWords &errType, std::vector< uint16_t > &vec16Data) const
Add trailers with errors for ROB to the vector of 16 bit words.
void packFragments(std::vector< uint16_t > &vec16Words, std::vector< uint32_t > &vec32Words) const
Method to pack vector of 16 bit words intto a vector of 32 bit words.
uint16_t getHeaderUsingRDO(const SCT_RDORawData *rdo) const
Get the 16-bit word for a header for a hit.
void addSpecificErrors(const uint32_t &robID, const std::set< IdentifierHash > *errors, const ErrorWords &errType, std::vector< uint16_t > &vec16Data) const
Add specific errors for ROB to the vector of 16 bit words.
void addHeadersWithErrors(const uint32_t &robID, const std::set< IdentifierHash > *errors, const ErrorWords &errType, std::vector< uint16_t > &vec16Data) const
Add header with errors for ROB to the vector of 16 bit words.
int getStrip(const SCT_RDORawData *rdo) const
Get the strip number info from the RDO.

◆ finalize()

StatusCode SCT_RodEncoder::finalize ( )
overridevirtual

Finalize.

Definition at line 84 of file SCT_RodEncoder.cxx.

85{
86 return StatusCode::SUCCESS;
87}

◆ getHeaderUsingHash()

uint16_t SCT_RodEncoder::getHeaderUsingHash ( const IdentifierHash & linkHash,
const int & errorWord ) const
private

Get the 16-bit word for a header for a link with a ByteStream error.

Definition at line 401 of file SCT_RodEncoder.cxx.

402{
403 const int rodLink{rodLinkFromOnlineID(m_cabling->getOnlineIdFromHash(linkHash))};
404 const uint16_t linkHeader{static_cast<uint16_t>(0x2000 | errorWord | (m_condensed.value() << 8) | rodLink)};
405 return linkHeader;
406}

◆ getHeaderUsingRDO()

uint16_t SCT_RodEncoder::getHeaderUsingRDO ( const SCT_RDORawData * rdo) const
private

Get the 16-bit word for a header for a hit.

Definition at line 394 of file SCT_RodEncoder.cxx.

395{
396 const int rodLink{getRODLink(rdo)};
397 const uint16_t linkHeader{static_cast<uint16_t>(0x2000 | (m_condensed.value() << 8) | rodLink)};
398 return linkHeader;
399}
int getRODLink(const SCT_RDORawData *rdo) const
Get the ROD link number info in the RDO header data.

◆ getRODLink()

int SCT_RodEncoder::getRODLink ( const SCT_RDORawData * rdo) const
private

Get the ROD link number info in the RDO header data.

Definition at line 369 of file SCT_RodEncoder.cxx.

370{
371 return rodLinkFromOnlineID(onlineID(rdo));
372}
uint32_t onlineID(const SCT_RDORawData *rdo) const
Get the online Identifier from the RDO.

◆ getStrip()

int SCT_RodEncoder::getStrip ( const SCT_RDORawData * rdo) const
private

Get the strip number info from the RDO.

Definition at line 350 of file SCT_RodEncoder.cxx.

351{
352 const Identifier rdoID{rdo->identify()};
353 return m_sctID->strip(rdoID);
354}
const SCT_ID * m_sctID
Identifier helper class for the SCT subdetector that creates compact Identifier objects and Identifie...

◆ getTimeBin()

int SCT_RodEncoder::getTimeBin ( const SCT_RDORawData * rdo) const
private

Get the time bin info from the RDO.

Definition at line 384 of file SCT_RodEncoder.cxx.

385{
386 int timeBin{0};
387 const SCT3_RawData* rdoCosmic{dynamic_cast<const SCT3_RawData*>(rdo)};
388 if (rdoCosmic != nullptr) timeBin = rdoCosmic->getTimeBin();
389 return timeBin;
390}
int getTimeBin() const

◆ getTrailer()

uint16_t SCT_RodEncoder::getTrailer ( const int & errorWord) const
private

Get the 16-bit word for a trailer, with or without ByteStream errors.

Definition at line 408 of file SCT_RodEncoder.cxx.

409{
410 const uint16_t linkTrailer{static_cast<uint16_t>(0x4000 | errorWord)};
411 return linkTrailer;
412}

◆ initialize()

StatusCode SCT_RodEncoder::initialize ( )
overridevirtual

Initialize.

Definition at line 53 of file SCT_RodEncoder.cxx.

54{
55 ATH_MSG_DEBUG("SCT_RodEncoder::initialize()");
56
57 // Retrieve cabling tool
58 ATH_CHECK(m_cabling.retrieve());
59 ATH_MSG_DEBUG("Retrieved tool " << m_cabling);
60
61 ATH_CHECK(detStore()->retrieve(m_sctID, "SCT_ID"));
62 ATH_CHECK(m_bsErrTool.retrieve());
63
64 // See if strip numbers go from 0 to 767 or vice versa for all the wafers.
65 // swapPhiReadoutDirection will not change during a run.
66 // Since this is access to SiDetectorElement during initialization,
67 // condition object of SiDetectorElementCollection is not accessible.
68 // SCT_DetectorManager has to be used.
69 const InDetDD::SCT_DetectorManager* sctDetManager{nullptr};
70 ATH_CHECK(detStore()->retrieve(sctDetManager, "SCT"));
71
72 const InDetDD::SiDetectorElementCollection* sctDetElementColl{sctDetManager->getDetectorElementCollection()};
73 for (const InDetDD::SiDetectorElement* sctDetElement : *sctDetElementColl) {
74 if (sctDetElement->swapPhiReadoutDirection()) {
75 m_swapModuleID.insert(sctDetElement->identify());
76 }
77 }
78
79 return StatusCode::SUCCESS;
80}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
virtual const SiDetectorElementCollection * getDetectorElementCollection() const override
access to whole collectiom

◆ offlineID()

Identifier SCT_RodEncoder::offlineID ( const SCT_RDORawData * rdo) const
private

Get the offline Identifier from the RDO.

Definition at line 356 of file SCT_RodEncoder.cxx.

357{
358 const Identifier rdoId{rdo->identify()};
359 return m_sctID->wafer_id(rdoId);
360}

◆ onlineID()

uint32_t SCT_RodEncoder::onlineID ( const SCT_RDORawData * rdo) const
private

Get the online Identifier from the RDO.

Definition at line 362 of file SCT_RodEncoder.cxx.

363{
364 const Identifier waferID{offlineID(rdo)};
365 const IdentifierHash offlineIDHash{m_sctID->wafer_hash(waferID)};
366 return static_cast<uint32_t>(m_cabling->getOnlineIdFromHash(offlineIDHash));
367}

◆ packFragments()

void SCT_RodEncoder::packFragments ( std::vector< uint16_t > & vec16Words,
std::vector< uint32_t > & vec32Words ) const
private

Method to pack vector of 16 bit words intto a vector of 32 bit words.

Method us used by private method encodeData(...).

Parameters
vec16WordsVector containing 16 bit words.
vec32WordsVector for 32 bit words to be packed.

Definition at line 305 of file SCT_RodEncoder.cxx.

307{
308 int num16Words{static_cast<int>(vec16Words.size())};
309 if (isOdd(num16Words)) {
310 // Just add an additional 16bit words to make even size v16 to in the 32 bits word 0x40004000
311 vec16Words.push_back(0x4000);
312 num16Words++;
313 }
314 // Now merge 2 consecutive 16 bit words in 32 bit words
315 const unsigned short int numWords{2};
316 const unsigned short int position[numWords]{0, 16};
317 unsigned short int arr16Words[numWords]{0, 0};
318 for (int i{0}; i<num16Words; i += numWords) {
319 arr16Words[i%numWords] = vec16Words[i+1];
320 arr16Words[(i+1)%numWords] = vec16Words[i];
321 const uint32_t uint32Word{set32Bits(arr16Words, position, numWords)};
322 vec32Words.push_back(uint32Word);
323#ifdef SCT_DEBUG
324 ATH_MSG_INFO("SCT encoder -> PackFragments: Output rod 0x"<<std::hex<<uint32Word<<std::dec);
325#endif
326 }
327
328 return;
329}
#define ATH_MSG_INFO(x)
uint32_t set32Bits(const unsigned short int *arr16Words, const unsigned short int *position, const unsigned short int &numWords) const
@breif Method to set pairs of 16 bit words to a 32 bit word.
const Amg::Vector3D & position() const
Method to retrieve the position of the Intersection.

◆ set32Bits()

uint32_t SCT_RodEncoder::set32Bits ( const unsigned short int * arr16Words,
const unsigned short int * position,
const unsigned short int & numWords ) const
private

@breif Method to set pairs of 16 bit words to a 32 bit word.

Function used by the packFragments(...) method.

Parameters
arr16WordsPointer to array containing a pair of 16 bit words.
positionPointer to an array that gives the 32 bit starting positions of the 16 bit words and corresponding to arr16Words.
numWordsNumber of word to be set to a 32 bit word.

Definition at line 333 of file SCT_RodEncoder.cxx.

336{
337 uint32_t uint32Word{0};
338 uint32_t pos{0};
339 uint32_t uint16Word{0};
340 for (uint16_t i{0}; i<numWords; i++) {
341 uint16Word = static_cast<uint32_t>(*(arr16Words+i));
342 pos = static_cast<uint32_t>(*(position+i));
343 uint32Word |= (uint16Word<<pos);
344 }
345 return uint32Word;
346}

◆ side()

int SCT_RodEncoder::side ( const SCT_RDORawData * rdo) const
private

Get the side info from the RDO.

Definition at line 374 of file SCT_RodEncoder.cxx.

375{
376 const Identifier rdoID{rdo->identify()};
377 int sctSide{m_sctID->side(rdoID)};
378 // see if we need to swap sides due to cabling weirdness
379 const int linkNum{getRODLink(rdo) & 0xF};
380 if (swappedCable(sctSide,linkNum)) sctSide = 1-sctSide;
381 return sctSide;
382}

Member Data Documentation

◆ m_bsErrTool

ToolHandle<ISCT_ByteStreamErrorsTool> SCT_RodEncoder::m_bsErrTool
private
Initial value:
{this,
"SCT_ByteStreamErrorsTool",
"SCT_ByteStreamErrorsTool",
"Tool to retrieve SCT ByteStream Errors"}

Tool that keeps track of modules that give rise to errors in the bytestream.

Definition at line 163 of file SCT_RodEncoder.h.

163 {this,
164 "SCT_ByteStreamErrorsTool",
165 "SCT_ByteStreamErrorsTool",
166 "Tool to retrieve SCT ByteStream Errors"};

◆ m_cabling

ToolHandle<ISCT_CablingTool> SCT_RodEncoder::m_cabling
private
Initial value:
{this,
"SCT_CablingTool",
"SCT_CablingTool",
"Tool to retrieve SCT Cabling"}

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

Definition at line 169 of file SCT_RodEncoder.h.

169 {this,
170 "SCT_CablingTool",
171 "SCT_CablingTool",
172 "Tool to retrieve SCT Cabling"};

◆ m_condensed

BooleanProperty SCT_RodEncoder::m_condensed
private
Initial value:
{this,
"CondensedMode",
false,
"Condensed mode (true) or Expanded mode (false)"}

Boolean used to determine if fillROD(...) should use Condensed or Expanded mode when decoding.

Definition at line 179 of file SCT_RodEncoder.h.

179 {this,
180 "CondensedMode",
181 false,
182 "Condensed mode (true) or Expanded mode (false)"};

◆ m_sctID

const SCT_ID* SCT_RodEncoder::m_sctID {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 176 of file SCT_RodEncoder.h.

176{nullptr};

◆ m_swapModuleID

std::set<Identifier> SCT_RodEncoder::m_swapModuleID {}
private

Swap Module identifier, set by SCTRawContByteStreamTool.

Definition at line 185 of file SCT_RodEncoder.h.

185{};

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