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

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

#include <ITkStripsRodEncoder.h>

Inheritance diagram for ITkStripsRodEncoder:
Collaboration diagram for ITkStripsRodEncoder:

Public Member Functions

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

bool isNear (const int &eta_mod, bool isBarrel=false) const
void encodeData (const std::vector< uint16_t > &clusters, const uint16_t ichannel, std::vector< uint8_t > &data_encode, int typ, uint8_t l0tag, uint8_t bc_count, uint32_t hccKey, uint16_t &size) const
void packFragments (std::vector< uint8_t > &vec8Words, std::vector< uint32_t > &vec32Words) const
 Method to pack vector of 8 bit words intto a vector of 32 bit words.
std::vector< uint16_t > clusterFinder (const std::bitset< 256 > &inputData, const uint8_t maxCluster=63) const
 @breif Method to set pairs of 8 bit words to a 32 bit word.
uint16_t clusterFinder_sub (uint64_t &hits_high64, uint64_t &hits_low64, bool isSecondRow) const
uint32_t set32Bits (const unsigned short int *arr8Words, const unsigned short int *position, const unsigned short int &numWords) const
bool getBit_128b (uint8_t bit_addr, uint64_t data_high64, uint64_t data_low64) const
void setBit_128b (uint8_t bit_addr, bool value, uint64_t &data_high64, uint64_t &data_low64) const
bool getParity_8bits (uint8_t val) const
int getBarrelEC (const SCT_RDORawData *rdo) const
 Get the barrel/endcape info from the RDO.
uint8_t getDiskLayer (const SCT_RDORawData *rdo) const
 Get disk/layer info from the RDO.
uint8_t getPhiModule (const SCT_RDORawData *rdo) const
 Get the phi value info from the RDO.
int getEtaModule (const SCT_RDORawData *rdo) const
 Get the eta value info from the RDO.
uint16_t getStripMax (const SCT_RDORawData *rdo) const
 Get the maxumum strip value info from the RDO.
int getSide (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 EventContext &ctx) const
 Get the online Identifier from the RDO.
int getRODLink (const SCT_RDORawData *rdo, const EventContext &ctx) const
 Get the ROD link number info in the RDO header data.
uint16_t getHeaderPhysicsPacket (int typ, uint8_t l0tag, uint8_t bc_count) const
 Get the 16-bit word for a header with Type (PR or LP), L0Tag event and BCID.
uint16_t getHeaderUsingRDO (const SCT_RDORawData *rdo, const EventContext &ctx) const
 Get the 16-bit word for a header for a hit.
uint16_t getHeaderUsingHash (const IdentifierHash &linkHash, const int &errorWord, const EventContext &ctx) 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.

Private Attributes

std::atomic< uint8_t > m_bcid = 0
 Method to encode RDO data to vector of 16 bin words.
std::atomic< uint8_t > m_l0tag = 0
ToolHandle< IITkStripCablingToolm_cabling
 Providing mappings of online and offline identifiers and also serial numbers.
ToolHandle< ITkStripDataRateMonToolm_dataRateMonTool {this, "DataRateMonitoringTool", "", "Monitoring tool for data rate evaluation"}
const SCT_IDm_itkStripsID {nullptr}
 Identifier helper class for the ITkStrips subdetector that creates compact Identifier objects and IdentifierHash or hash IDs.
BooleanProperty m_condensed {this, "CondensedMode", false, "Condensed mode (true) or Expanded mode (false)"}
 Example Boolean used to determine decoding mode, maybe unused finally.
std::set< Identifierm_swapModuleID {}
 Swap Module identifier, set by SCTRawContByteStreamTool.

Detailed Description

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

Definition at line 31 of file ITkStripsRodEncoder.h.

Constructor & Destructor Documentation

◆ ~ITkStripsRodEncoder()

virtual ITkStripsRodEncoder::~ITkStripsRodEncoder ( )
virtualdefault

Destructor.

Member Function Documentation

◆ clusterFinder()

std::vector< uint16_t > ITkStripsRodEncoder::clusterFinder ( const std::bitset< 256 > & inputData,
const uint8_t maxCluster = 63 ) const
private

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

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

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

Definition at line 304 of file ITkStripsRodEncoder.cxx.

304 {
305
306 std::vector<uint16_t> clusters;
307
308 // Split into far (odd) and near (even) strips
309 std::bitset<128> dataEven;
310 std::bitset<128> dataOdd;
311 for(int i=0; i<128; ++i){
312 dataEven[i] = inputData[2*i];
313 dataOdd[i] = inputData[2*i+1];
314 }
315
316 // Split the 128-bit Even and Odd data into four 64-bit chunks for processing
317 uint64_t d0l = chunk<0>(dataEven);
318 uint64_t d0h = chunk<1>(dataEven);
319
320 uint64_t d1l = chunk<0>(dataOdd);
321 uint64_t d1h = chunk<1>(dataOdd);
322
323 while (d0l or d0h or d1l or d1h){
324 if (clusters.size() > maxCluster) break;
325
326 uint16_t cluster1 = clusterFinder_sub(d1h, d1l, true);
327 if (cluster1 != 0x3ff) // No cluster was found
328 clusters.push_back(cluster1);
329
330 if (clusters.size() > maxCluster) break;
331
332 uint16_t cluster0 = clusterFinder_sub(d0h, d0l, false);
333 if (cluster0 != 0x3ff) // No cluster was found
334 clusters.push_back(cluster0);
335 }
336
337 if (clusters.empty()) {
338 clusters.push_back(0x3fe);
339 } else {
340 clusters.back() |=1 << 11;
341 }
342
343 return clusters;
344}
uint16_t clusterFinder_sub(uint64_t &hits_high64, uint64_t &hits_low64, bool isSecondRow) const
setWord1 uint16_t

◆ clusterFinder_sub()

uint16_t ITkStripsRodEncoder::clusterFinder_sub ( uint64_t & hits_high64,
uint64_t & hits_low64,
bool isSecondRow ) const
private

Definition at line 365 of file ITkStripsRodEncoder.cxx.

365 {
366 uint8_t hit_addr = 128;
367 uint8_t hit_mask = 0;
368
369 if (hits_low64){
370 hit_addr = __builtin_ctzll(hits_low64);
371 } else if (hits_high64){
372 hit_addr = __builtin_ctzll(hits_high64) + 64;
373 }
374
375 hit_mask = getBit_128b(hit_addr+1, hits_high64, hits_low64) << 2
376 | getBit_128b(hit_addr+2, hits_high64, hits_low64) << 1
377 | getBit_128b(hit_addr+3, hits_high64, hits_low64);
378
379 for (int i=0; i<4; ++i)
380 setBit_128b(hit_addr+i, 0, hits_high64, hits_low64);
381
382 if (hit_addr == 128) {
383 return 0x3ff;
384 } else {
385 hit_addr += isSecondRow<<7;
386 return hit_addr << 3 | hit_mask;
387 }
388}
void setBit_128b(uint8_t bit_addr, bool value, uint64_t &data_high64, uint64_t &data_low64) const
bool getBit_128b(uint8_t bit_addr, uint64_t data_high64, uint64_t data_low64) const

◆ encodeData()

void ITkStripsRodEncoder::encodeData ( const std::vector< uint16_t > & clusters,
const uint16_t ichannel,
std::vector< uint8_t > & data_encode,
int typ,
uint8_t l0tag,
uint8_t bc_count,
uint32_t hccKey,
uint16_t & size ) const
private

Definition at line 264 of file ITkStripsRodEncoder.cxx.

265 {
266
267
268 if(hccKey!=0){
269 ATH_MSG_DEBUG("hccKey: " << std::bitset<32>(hccKey));
270 ATH_MSG_DEBUG("hccKey 8-bit word-4: "<<std::bitset<8>(hccKey));
271 ATH_MSG_DEBUG("hccKey 8-bit word-3: "<<std::bitset<8>(hccKey>>24));
272 ATH_MSG_DEBUG("hccKey 8-bit word-2: "<<std::bitset<8>(hccKey>>16));
273 ATH_MSG_DEBUG("hccKey 8-bit word-1: "<<std::bitset<8>(hccKey>>8));
274
275 data_encode.push_back(hccKey);
276 data_encode.push_back(hccKey>>24);
277 data_encode.push_back(hccKey>>16);
278 data_encode.push_back(hccKey>>8);
279
280 uint16_t header = getHeaderPhysicsPacket(ptyp, l0tag, bc_count);
281 ATH_MSG_DEBUG("header: " << std::bitset<16>(header));
282 data_encode.push_back((header>>8) & 0xff);
283 data_encode.push_back(header & 0xff);
284 }
285
286 for(size_t idx=0;auto &cluster : clusters){
287 if(cluster == 0x3fe) continue;
288 if(idx!=0) size++;
289
290 // cluster bits:
291 // "0" + 4-bit channel number + 11-bit cluster dropping the last cluster bit
292 uint16_t clusterbits = ((ichannel & 0xf) << 11) | (cluster & 0x7ff);
293 ATH_MSG_DEBUG("Clusters: " << idx << ": " << std::bitset<16>(clusterbits) << " size: " << size << " ichannel: " << ichannel);
294 data_encode.push_back((clusterbits>>8) & 0xff);
295 data_encode.push_back(clusterbits & 0xff);
296 idx++;
297 }
298
299 return;
300}
#define ATH_MSG_DEBUG(x,...)
size_t size() const
Number of registered mappings.
uint16_t getHeaderPhysicsPacket(int typ, uint8_t l0tag, uint8_t bc_count) const
Get the 16-bit word for a header with Type (PR or LP), L0Tag event and BCID.

◆ fillROD()

void ITkStripsRodEncoder::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 120 of file ITkStripsRodEncoder.cxx.

121 {
122 //code to be filled here
123
124 std::unordered_map<uint32_t, std::vector<std::bitset<256>>> allStripData;
125 std::unordered_map<uint32_t, IdentifierHash> keyToHash;
126
127 IdentifierHash offlineHash = 0;
128
129 for (const auto& rdo : vecRDOs) {
130 int barrelEC = getBarrelEC(rdo);
131 int eta_mod = getEtaModule(rdo);
132 uint8_t side = getSide(rdo);
133 uint8_t disk = getDiskLayer(rdo);
134 uint8_t phi_mod = getPhiModule(rdo);
135 uint16_t strip_max = getStripMax(rdo);
136
137 if (strip_max == 0xFFFF){
138 //To do: Implement workaround
139 const Identifier rdoID{rdo->identify()};
140 ATH_MSG_WARNING("Negative maximum number of strips found " << m_itkStripsID->strip_max(rdoID));
141 continue;
142 }
143
144 uint8_t sideAC = 0;
145 if((barrelEC == 0 && eta_mod > 0) || barrelEC > 0) sideAC = 1;
146
147 uint8_t eta_group=0;
148
149 if (barrelEC == 0) {
150 if(disk < 2){
151 eta_group = static_cast<uint8_t>(std::floor((std::abs(eta_mod)-1) / 4));
152 }else{
153 eta_group = static_cast<uint8_t>(std::floor((std::abs(eta_mod)-1) / 2));
154 }
155 }else {
156 if(eta_mod>=0 && eta_mod<=9) eta_group = static_cast<uint8_t>(std::floor(eta_mod / 4));
157 else if(eta_mod>=10 && eta_mod<=13) eta_group = static_cast<uint8_t>(std::floor((eta_mod+2)/4));
158 else if(eta_mod>13) eta_group = static_cast<uint8_t>(std::floor((eta_mod-6)/2));
159 }
160
161 uint8_t chips_per_module = (strip_max + 1) / 128;
162 uint32_t key = hccKey(barrelEC, side, disk, phi_mod, eta_mod, eta_group);
163
164 offlineHash = m_itkStripsID->wafer_hash(offlineID(rdo));
165 keyToHash.insert({key,offlineHash});
166 ATH_MSG_DEBUG("barrel: "<< barrelEC<<" sideAC: " << (uint32_t)sideAC << " disk: "<<(uint32_t)disk << " side: " << (uint32_t)side <<" phi_mod: "<<(uint32_t)phi_mod << " eta_mod: " << eta_mod << " eta group: "<<(uint32_t)eta_group << " chips per module: " << (uint32_t)chips_per_module << " " << (uint32_t)robID << " " << (uint32_t)m_itkStripsID->wafer_hash(offlineID(rdo)));
167 ATH_MSG_DEBUG("key: " << std::bitset<32>(key));
168 auto& StripData = allStripData[key];
169
170 if (StripData.empty()) {
171 StripData.resize(chips_per_module);
172 }
173
174 //Populate the bitset for each chip with active strips
175 int strip = getStrip(rdo);
176 int chip = static_cast<int>(std::floor(strip / 128));
177 int strip_position = strip % 128;
178 int strip_logical_channel = 2*strip_position + (isNear(eta_mod, barrelEC == 0)? 0 : 1);
179
180 ATH_MSG_DEBUG("strip N: "<< strip << " chip n: " << chip << " Strip position: " << strip_position << " Strip position logical: " << strip_logical_channel);
181 StripData[chip].set(strip_logical_channel);
182 }
183
184 std::vector<uint8_t> vec8Data;
185 uint32_t vectorSize = 0;
186 std::vector<uint16_t> clusters;
187
188 ATH_MSG_DEBUG("All strip data size: " << allStripData.size());
189
190 //Iterate over processed strip data and find clusters
191 for (const auto& [key, StripData] : allStripData) {
192
193 uint16_t ichannel = 0;
194 uint16_t size = 1;
195 int ptype = 1;
196 bool keyRecorded = false;
197 clusters.clear();
198
199 ATH_MSG_DEBUG("key is: " << std::bitset<32>(key) << " StripData size: " << StripData.size());
200
201 for (size_t i = 0; i < StripData.size(); ++i) {
202
203 std::bitset<256> hits = StripData[i];
204
205 if(hits==0){
206 ++ichannel;
207 continue;
208 }
209
210 //Use clusterFinder to extract clusters from the bitset
211 clusters = clusterFinder(hits);
212
213 if(clusters.empty()){
214 ++ichannel;
215 continue;
216 }
217 uint32_t hccKey = (keyRecorded) ? 0 : key;
218 encodeData(clusters, ichannel, vec8Data, ptype, m_l0tag , m_bcid, hccKey, size);
219 keyRecorded = true;
220 ++ichannel;++size;
221 }
222 vec8Data.push_back(0xed);
223 vec8Data.push_back(0x6f);
224 ATH_MSG_DEBUG("Add 16-0s: " << size % 2 << " " << vec8Data.size());
225
226 if(size % 2 == 0){
227 vec8Data.push_back(0);
228 vec8Data.push_back(0);
229 }
230 uint32_t packetLenght = (vec8Data.size()-vectorSize)+4;
231 ATH_MSG_DEBUG("Packet Lenght: " << (uint32_t)packetLenght << " " << std::bitset<32>(packetLenght));
232
233 std::vector<uint8_t> pktlenght = split32bitWord(packetLenght);
234
235 ATH_MSG_DEBUG("PktLenght: " << pktlenght.size() << " vec8Data size: " << vec8Data.size());
236
237 uint32_t offset = vectorSize + 4;
238 vec8Data.insert(vec8Data.begin()+offset, pktlenght.begin(), pktlenght.end());
239 vectorSize = vec8Data.size();
240
241 ATH_MSG_DEBUG("vec8Data size: " << vec8Data.size() << " size: " << size-1);
242 packFragments(vec8Data,vec32Data);
243 if (not m_dataRateMonTool.empty()) {
244 m_dataRateMonTool->fill(keyToHash[key], vec32Data, allStripData[key]);
245 }
246 vec32Data.clear();
247 }
248
249 //Update BCID and L0Tag counters
250 m_bcid = (m_bcid + 1) & 0x7F;
251 m_l0tag = (m_l0tag + 1) & 0x7F;
252
253 ATH_MSG_DEBUG("vec8Data size: " << vec8Data.size());
254
255 packFragments(vec8Data,vec32Data);
256
257 for(auto &word: vec32Data){
258 ATH_MSG_DEBUG("32-bit word: " << std::bitset<32>(word));
259 }
260 return;
261}
#define ATH_MSG_WARNING(x,...)
const SCT_ID * m_itkStripsID
Identifier helper class for the ITkStrips subdetector that creates compact Identifier objects and Ide...
uint16_t getStripMax(const SCT_RDORawData *rdo) const
Get the maxumum strip value info from the RDO.
Identifier offlineID(const SCT_RDORawData *rdo) const
Get the offline Identifier from the RDO.
int getBarrelEC(const SCT_RDORawData *rdo) const
Get the barrel/endcape info from the RDO.
std::atomic< uint8_t > m_l0tag
int getEtaModule(const SCT_RDORawData *rdo) const
Get the eta value info from the RDO.
int getSide(const SCT_RDORawData *rdo) const
Get the side info from the RDO.
int getStrip(const SCT_RDORawData *rdo) const
Get the strip number info from the RDO.
std::vector< uint16_t > clusterFinder(const std::bitset< 256 > &inputData, const uint8_t maxCluster=63) const
@breif Method to set pairs of 8 bit words to a 32 bit word.
uint8_t getPhiModule(const SCT_RDORawData *rdo) const
Get the phi value info from the RDO.
uint8_t getDiskLayer(const SCT_RDORawData *rdo) const
Get disk/layer info from the RDO.
void encodeData(const std::vector< uint16_t > &clusters, const uint16_t ichannel, std::vector< uint8_t > &data_encode, int typ, uint8_t l0tag, uint8_t bc_count, uint32_t hccKey, uint16_t &size) const
ToolHandle< ITkStripDataRateMonTool > m_dataRateMonTool
bool isNear(const int &eta_mod, bool isBarrel=false) const
void packFragments(std::vector< uint8_t > &vec8Words, std::vector< uint32_t > &vec32Words) const
Method to pack vector of 8 bit words intto a vector of 32 bit words.
std::atomic< uint8_t > m_bcid
Method to encode RDO data to vector of 16 bin words.
BySideTypeMod sideAC(0)
setEventNumber uint32_t

◆ getBarrelEC()

int ITkStripsRodEncoder::getBarrelEC ( const SCT_RDORawData * rdo) const
private

Get the barrel/endcape info from the RDO.

Definition at line 464 of file ITkStripsRodEncoder.cxx.

464 {
465 const Identifier rdoID{rdo->identify()};
466 return m_itkStripsID->barrel_ec(rdoID);
467}
virtual Identifier identify() const override final

◆ getBit_128b()

bool ITkStripsRodEncoder::getBit_128b ( uint8_t bit_addr,
uint64_t data_high64,
uint64_t data_low64 ) const
inlineprivate

Definition at line 347 of file ITkStripsRodEncoder.cxx.

347 {
348 if (bit_addr > 127) return false;
349
350 return bit_addr<64 ? data_low64>>bit_addr & 1 : data_high64>>(bit_addr-64) & 1;
351}

◆ getDiskLayer()

uint8_t ITkStripsRodEncoder::getDiskLayer ( const SCT_RDORawData * rdo) const
private

Get disk/layer info from the RDO.

Definition at line 470 of file ITkStripsRodEncoder.cxx.

470 {
471 const Identifier rdoID{rdo->identify()};
472 return m_itkStripsID->layer_disk(rdoID);
473}

◆ getEtaModule()

int ITkStripsRodEncoder::getEtaModule ( const SCT_RDORawData * rdo) const
private

Get the eta value info from the RDO.

Definition at line 482 of file ITkStripsRodEncoder.cxx.

482 {
483 const Identifier rdoID{rdo->identify()};
484 return m_itkStripsID->eta_module(rdoID);
485}

◆ getHeaderPhysicsPacket()

uint16_t ITkStripsRodEncoder::getHeaderPhysicsPacket ( int typ,
uint8_t l0tag,
uint8_t bc_count ) const
private

Get the 16-bit word for a header with Type (PR or LP), L0Tag event and BCID.

Definition at line 503 of file ITkStripsRodEncoder.cxx.

503 {
504 uint8_t bcid_low = bc_cout & 0x7; // BCID[2:0]
505 bool bc_parity = getParity_8bits(bc_cout);
506 //TYPE (4 bits) + FlagBit (1 bit) + L0tag (7 bits) + BCID (3 bits) + Parity (1 bit)
507 const uint16_t Header{static_cast<uint16_t>(((uint8_t)typ << 12) | (0x1 << 11) | (l0tag & 0x7f) << 4 | (bcid_low) << 1 | bc_parity)};
508 return Header;
509
510}
bool getParity_8bits(uint8_t val) const

◆ getHeaderUsingHash()

uint16_t ITkStripsRodEncoder::getHeaderUsingHash ( const IdentifierHash & linkHash,
const int & errorWord,
const EventContext & ctx ) const
private

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

Definition at line 522 of file ITkStripsRodEncoder.cxx.

522 {
523 const int rodLink{rodLinkFromOnlineID(m_cabling->getOnlineIdFromHash(linkHash, ctx))};
524 const uint16_t linkHeader{static_cast<uint16_t>(0x2000 | errorWord | (m_condensed.value() << 8) | rodLink)};
525 return linkHeader;
526}
ToolHandle< IITkStripCablingTool > m_cabling
Providing mappings of online and offline identifiers and also serial numbers.
BooleanProperty m_condensed
Example Boolean used to determine decoding mode, maybe unused finally.

◆ getHeaderUsingRDO()

uint16_t ITkStripsRodEncoder::getHeaderUsingRDO ( const SCT_RDORawData * rdo,
const EventContext & ctx ) const
private

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

Definition at line 515 of file ITkStripsRodEncoder.cxx.

515 {
516 const int rodLink{getRODLink(rdo, ctx)};
517 const uint16_t linkHeader{static_cast<uint16_t>(0x2000 | (m_condensed.value() << 8) | rodLink)};
518 return linkHeader;
519}
int getRODLink(const SCT_RDORawData *rdo, const EventContext &ctx) const
Get the ROD link number info in the RDO header data.

◆ getParity_8bits()

bool ITkStripsRodEncoder::getParity_8bits ( uint8_t val) const
private

Definition at line 495 of file ITkStripsRodEncoder.cxx.

495 {
496 val ^= val >> 4;
497 val ^= val >> 2;
498 val ^= val >> 1;
499 return val&1;
500}

◆ getPhiModule()

uint8_t ITkStripsRodEncoder::getPhiModule ( const SCT_RDORawData * rdo) const
private

Get the phi value info from the RDO.

Definition at line 476 of file ITkStripsRodEncoder.cxx.

476 {
477 const Identifier rdoID{rdo->identify()};
478 return m_itkStripsID->phi_module(rdoID);
479}

◆ getRODLink()

int ITkStripsRodEncoder::getRODLink ( const SCT_RDORawData * rdo,
const EventContext & ctx ) const
private

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

Definition at line 452 of file ITkStripsRodEncoder.cxx.

452 {
453 return rodLinkFromOnlineID(onlineID(rdo, ctx));
454}
uint32_t onlineID(const SCT_RDORawData *rdo, const EventContext &ctx) const
Get the online Identifier from the RDO.

◆ getSide()

int ITkStripsRodEncoder::getSide ( const SCT_RDORawData * rdo) const
private

Get the side info from the RDO.

Definition at line 457 of file ITkStripsRodEncoder.cxx.

457 {
458 const Identifier rdoID{rdo->identify()};
459 int itkSide{m_itkStripsID->side(rdoID)};
460 return itkSide;
461}

◆ getStrip()

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

Get the strip number info from the RDO.

Definition at line 433 of file ITkStripsRodEncoder.cxx.

433 {
434 const Identifier rdoID{rdo->identify()};
435 return m_itkStripsID->strip(rdoID);
436}

◆ getStripMax()

uint16_t ITkStripsRodEncoder::getStripMax ( const SCT_RDORawData * rdo) const
private

Get the maxumum strip value info from the RDO.

Definition at line 488 of file ITkStripsRodEncoder.cxx.

488 {
489 const Identifier rdoID{rdo->identify()};
490 if(m_itkStripsID->strip_max(rdoID)<0) return 0xFFFF;
491 return m_itkStripsID->strip_max(rdoID);
492}

◆ getTimeBin()

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

Get the time bin info from the RDO.

◆ getTrailer()

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

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

Definition at line 529 of file ITkStripsRodEncoder.cxx.

529 {
530 const uint16_t linkTrailer{static_cast<uint16_t>(0x4000 | errorWord)};
531 return linkTrailer;
532}

◆ initialize()

StatusCode ITkStripsRodEncoder::initialize ( )
overridevirtual

Initialize.

Definition at line 94 of file ITkStripsRodEncoder.cxx.

94 {
95 ATH_MSG_DEBUG("ITkStripsRodEncoder::initialize()");
96
97 // Retrieve cabling tool
98 ATH_CHECK(m_cabling.retrieve());
99 ATH_MSG_DEBUG("Retrieved tool " << m_cabling);
100 ATH_CHECK(detStore()->retrieve(m_itkStripsID, "SCT_ID"));
101 const InDetDD::SCT_DetectorManager* itkStripsDetManager{nullptr};
102 ATH_CHECK(detStore()->retrieve(itkStripsDetManager, "ITkStrip"));
103 const InDetDD::SiDetectorElementCollection* sctDetElementColl{itkStripsDetManager->getDetectorElementCollection()};
104 for (const InDetDD::SiDetectorElement* sctDetElement : *sctDetElementColl) {
105 if (sctDetElement->swapPhiReadoutDirection()) {
106 m_swapModuleID.insert(sctDetElement->identify());
107 }
108 }
109
110 if (not m_dataRateMonTool.empty())
111 ATH_CHECK(m_dataRateMonTool.retrieve());
112
113 ATH_MSG_DEBUG("Initialization was successful");
114 return StatusCode::SUCCESS;
115}
#define ATH_CHECK
Evaluate an expression and check for errors.
std::set< Identifier > m_swapModuleID
Swap Module identifier, set by SCTRawContByteStreamTool.
virtual const SiDetectorElementCollection * getDetectorElementCollection() const override
access to whole collectiom

◆ isNear()

bool ITkStripsRodEncoder::isNear ( const int & eta_mod,
bool isBarrel = false ) const
inlineprivate

Definition at line 75 of file ITkStripsRodEncoder.h.

75 {
76 if (isBarrel){
77 int pos = std::abs(eta_mod) % 4;
78 return (pos == 2 || pos == 3);
79 }else{
80 int pos = std::abs(eta_mod) % 4;
81 if (eta_mod >= 10) pos = (eta_mod + 2) % 4;
82 if (eta_mod >= 16) pos = (eta_mod + 4) % 4;
83 return (pos == 1 || pos == 2);
84 }
85 }

◆ offlineID()

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

Get the offline Identifier from the RDO.

Definition at line 439 of file ITkStripsRodEncoder.cxx.

439 {
440 const Identifier rdoId{rdo->identify()};
441 return m_itkStripsID->wafer_id(rdoId);
442}

◆ onlineID()

uint32_t ITkStripsRodEncoder::onlineID ( const SCT_RDORawData * rdo,
const EventContext & ctx ) const
private

Get the online Identifier from the RDO.

Definition at line 445 of file ITkStripsRodEncoder.cxx.

445 {
446 const Identifier waferID{offlineID(rdo)};
447 const IdentifierHash offlineIDHash{m_itkStripsID->wafer_hash(waferID)};
448 return static_cast<uint32_t>(m_cabling->getOnlineIdFromHash(offlineIDHash, ctx));
449}

◆ packFragments()

void ITkStripsRodEncoder::packFragments ( std::vector< uint8_t > & vec8Words,
std::vector< uint32_t > & vec32Words ) const
private

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

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

Parameters
vec8WordsVector containing 8 bit words.
vec32WordsVector for 32 bit words to be packed.

Definition at line 391 of file ITkStripsRodEncoder.cxx.

391 {
392 int num8Words{static_cast<int>(vec8Words.size())};
393 if (num8Words % 4 != 0) {
394 // Just add additional 8-bit words to make the size a multiple of 4
395 while (num8Words % 4 != 0) {
396 vec8Words.push_back(0x40); // Padding byte
397 num8Words++;
398 }
399 }
400 // Now merge 4 consecutive 8-bit words into 32-bit words
401 const unsigned short int numWords{4};
402 const unsigned short int position[numWords]{0, 8, 16, 24};
403 unsigned short int arr8Words[numWords]{0, 0, 0, 0};
404
405 for (int i{0}; i<num8Words; i += numWords) {
406 for (int j{0}; j<numWords; j++) {
407 arr8Words[j] = vec8Words[i + j];
408 }
409 const uint32_t uint32Word{set32Bits(arr8Words, position, numWords)};
410 vec32Words.push_back(uint32Word);
411 }
412 return;
413}
uint32_t set32Bits(const unsigned short int *arr8Words, const unsigned short int *position, const unsigned short int &numWords) const
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)
const Amg::Vector3D & position() const
Method to retrieve the position of the Intersection.

◆ set32Bits()

uint32_t ITkStripsRodEncoder::set32Bits ( const unsigned short int * arr8Words,
const unsigned short int * position,
const unsigned short int & numWords ) const
private

Definition at line 417 of file ITkStripsRodEncoder.cxx.

418{
419 uint32_t uint32Word{0};
420 uint32_t pos{0};
421 uint32_t uint8Word{0};
422 for (uint16_t i{0}; i<numWords; i++) {
423 uint8Word = static_cast<uint32_t>(*(arr8Words + i));
424 pos = static_cast<uint32_t>(*(position + i));
425 uint32Word |= (uint8Word << pos); // Shift the 8-bit word to its correct position and merge
426 }
427 return uint32Word;
428}

◆ setBit_128b()

void ITkStripsRodEncoder::setBit_128b ( uint8_t bit_addr,
bool value,
uint64_t & data_high64,
uint64_t & data_low64 ) const
inlineprivate

Definition at line 354 of file ITkStripsRodEncoder.cxx.

354 {
355 if (bit_addr < 64) {
356 data_low64 = (data_low64 & ~(1ULL << bit_addr)) | ((uint64_t)value << bit_addr);
357 } else if (bit_addr < 128) {
358 data_high64 =
359 (data_high64 & ~(1ULL << (bit_addr-64))) | ((uint64_t)value << (bit_addr-64));
360 }
361}

Member Data Documentation

◆ m_bcid

std::atomic<uint8_t> ITkStripsRodEncoder::m_bcid = 0
mutableprivate

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 72 of file ITkStripsRodEncoder.h.

◆ m_cabling

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

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

Definition at line 167 of file ITkStripsRodEncoder.h.

167 {this,
168 "ITkStripCablingTool",
169 "ITkStripCablingTool",
170 "Tool to retrieve ITkStrips Cabling"};

◆ m_condensed

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

Example Boolean used to determine decoding mode, maybe unused finally.

Definition at line 179 of file ITkStripsRodEncoder.h.

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

◆ m_dataRateMonTool

ToolHandle<ITkStripDataRateMonTool> ITkStripsRodEncoder::m_dataRateMonTool {this, "DataRateMonitoringTool", "", "Monitoring tool for data rate evaluation"}
private

Definition at line 172 of file ITkStripsRodEncoder.h.

172{this, "DataRateMonitoringTool", "", "Monitoring tool for data rate evaluation"};

◆ m_itkStripsID

const SCT_ID* ITkStripsRodEncoder::m_itkStripsID {nullptr}
private

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

Also allows decoding of these IDs.

Definition at line 176 of file ITkStripsRodEncoder.h.

176{nullptr};

◆ m_l0tag

std::atomic<uint8_t> ITkStripsRodEncoder::m_l0tag = 0
mutableprivate

Definition at line 73 of file ITkStripsRodEncoder.h.

◆ m_swapModuleID

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

Swap Module identifier, set by SCTRawContByteStreamTool.

Definition at line 182 of file ITkStripsRodEncoder.h.

182{};

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