CMS 3D CMS Logo

Classes | Typedefs | Enumerations | Functions
hgcal::econd Namespace Reference

Classes

class  Emulator
 Pure virtual base class for a ECON-D event emulator implementation. More...
 
struct  EmulatorParameters
 
struct  ERxData
 parsed e-rx data More...
 
class  HGCalModuleTreeReader
 
class  TrivialEmulator
 A "trivial" ECON-D emulator emulating non-empty ECON-D events. More...
 

Typedefs

typedef std::pair< EventId, ERxInputECONDInput
 ECON-D inputs for a given event. More...
 
typedef std::map< EventId, ERxInputECONDInputColl
 collection of ECON-D inputs More...
 
typedef std::vector< bool > ERxChannelEnable
 list of channels enabled in eRx More...
 
typedef std::pair< uint8_t, uint8_t > ERxId_t
 chip/half More...
 
typedef std::map< ERxId_t, ERxDataERxInput
 eRx data maps More...
 
typedef std::tuple< uint32_t, uint32_t, uint32_t > EventId
 Event index (L1A/BX/orbit) More...
 

Enumerations

enum  ToTStatus { ZeroSuppressed = 0x0, noZeroSuppressed_TOASuppressed = 0x1, invalid = 0x2, AutomaticFull = 0x3 }
 

Functions

uint32_t buildIdleWord (uint8_t bufStat, uint8_t err, uint8_t rr, uint32_t progPattern)
 
std::vector< uint32_t > eRxSubPacketHeader (uint8_t stat, uint8_t ham, bool bitE, uint16_t common_mode0, uint16_t common_mode1, const ERxChannelEnable &channel_enable)
 
std::vector< uint32_t > eRxSubPacketHeader (uint8_t stat, uint8_t ham, bool bitE, uint16_t common_mode0, uint16_t common_mode1, uint64_t channels_map)
 
std::vector< uint32_t > eventPacketHeader (uint16_t header, uint16_t payload, bool bitP, bool bitE, uint8_t ht, uint8_t ebo, bool bitM, bool bitT, uint8_t hamming, uint16_t bx, uint16_t l1a, uint8_t orb, bool bitS, uint8_t RR)
 
std::vector< uint32_t > produceERxData (const ERxChannelEnable &, const ERxData &, bool passZS, bool passZSm1, bool hasToA, bool char_mode)
 

Typedef Documentation

◆ ECONDInput

ECON-D inputs for a given event.

Definition at line 32 of file SlinkTypes.h.

◆ ECONDInputColl

collection of ECON-D inputs

Definition at line 35 of file SlinkTypes.h.

◆ ERxChannelEnable

typedef std::vector<bool> hgcal::econd::ERxChannelEnable

list of channels enabled in eRx

Definition at line 38 of file SlinkTypes.h.

◆ ERxId_t

typedef std::pair<uint8_t, uint8_t> hgcal::econd::ERxId_t

chip/half

Definition at line 17 of file SlinkTypes.h.

◆ ERxInput

eRx data maps

Definition at line 29 of file SlinkTypes.h.

◆ EventId

typedef std::tuple<uint32_t, uint32_t, uint32_t> hgcal::econd::EventId

Event index (L1A/BX/orbit)

Definition at line 14 of file SlinkTypes.h.

Enumeration Type Documentation

◆ ToTStatus

Function Documentation

◆ buildIdleWord()

uint32_t hgcal::econd::buildIdleWord ( uint8_t  bufStat,
uint8_t  err,
uint8_t  rr,
uint32_t  progPattern 
)

builds a trailing idle word

Note
based on Fig. 33 of the ECON-D specs
Returns
a 32b word with the idle word

Definition at line 159 of file HGCalRawDataPackingTools.cc.

References submitPVResolutionJobs::err, and findQualityFiles::rr.

Referenced by hgcal::HGCalFrameGenerator::produceECONEvent().

159  {
160  return (progPattern & 0xffffff) << 8 | (rr & 0x3) << 6 | (err & 0x7) << 3 | (bufStat & 0x7) << 0;
161 }

◆ eRxSubPacketHeader() [1/2]

std::vector< uint32_t > hgcal::econd::eRxSubPacketHeader ( uint8_t  stat,
uint8_t  ham,
bool  bitE,
uint16_t  common_mode0,
uint16_t  common_mode1,
const ERxChannelEnable channel_enable 
)

returns the words for a new eRx header

Note
based on Fig. 33 of ECON-D specifications
Returns
a vector with 1 or 2 32b words

Definition at line 80 of file HGCalRawDataPackingTools.cc.

References mps_fire::i.

Referenced by hgcal::HGCalFrameGenerator::generateERxData().

85  {
86  uint64_t channels_map64b(0);
87  size_t i = 0;
88  for (const auto& ch : channel_enable)
89  channels_map64b |= (ch << i++);
90  return hgcal::econd::eRxSubPacketHeader(stat, hamming, bitE, common_mode0, common_mode1, channels_map64b);
91 }
std::vector< uint32_t > eRxSubPacketHeader(uint8_t stat, uint8_t ham, bool bitE, uint16_t common_mode0, uint16_t common_mode1, const ERxChannelEnable &channel_enable)
unsigned long long uint64_t
Definition: Time.h:13

◆ eRxSubPacketHeader() [2/2]

std::vector< uint32_t > hgcal::econd::eRxSubPacketHeader ( uint8_t  stat,
uint8_t  ham,
bool  bitE,
uint16_t  common_mode0,
uint16_t  common_mode1,
uint64_t  channels_map 
)

Definition at line 94 of file HGCalRawDataPackingTools.cc.

References hgcal::CHMAP0_MASK, hgcal::CHMAP0_POS, hgcal::CHMAP32_MASK, hgcal::CHMAP32_POS, hgcal::COMMONMODE0_MASK, hgcal::COMMONMODE0_POS, hgcal::COMMONMODE1_MASK, hgcal::COMMONMODE1_POS, hgcal::ERX_E_POS, hgcal::ERXFORMAT_POS, hgcal::ERXHAM_MASK, hgcal::ERXHAM_POS, hgcal::ERXSTAT_MASK, hgcal::ERXSTAT_POS, and RecoTauValidation_cfi::header.

95  {
96  std::vector<uint32_t> header = {
101 
102  //summarize the channel status map
103  const uint32_t chmapw0(channels_map & hgcal::ECOND_FRAME::CHMAP0_MASK),
104  chmapw1((channels_map >> 32) & hgcal::ECOND_FRAME::CHMAP32_MASK);
105 
106  //add the channel map
107  if (chmapw0 == 0 && chmapw1 == 0) { // empty channels map (empty eRx)
108  header[0] |= (bitE << hgcal::ECOND_FRAME::ERX_E_POS);
109  header[0] |= (1 << hgcal::ECOND_FRAME::ERXFORMAT_POS); //raise the F bit (empty eRX)
110  } else {
113  }
114 
115  return header;
116 }

◆ eventPacketHeader()

std::vector< uint32_t > hgcal::econd::eventPacketHeader ( uint16_t  header,
uint16_t  payload,
bool  bitP,
bool  bitE,
uint8_t  ht,
uint8_t  ebo,
bool  bitM,
bool  bitT,
uint8_t  hamming,
uint16_t  bx,
uint16_t  l1a,
uint8_t  orb,
bool  bitS,
uint8_t  RR 
)

builds the two ECON-D header words

Note
based on Fig. 33 of the ECON-D specs
Returns
a vector of size 2 with the ECON-D header

Definition at line 124 of file HGCalRawDataPackingTools.cc.

References hgcal::BITE_POS, hgcal::BITM_POS, hgcal::BITP_POS, hgcal::BITS_POS, hgcal::BITT_POS, nano_mu_digi_cff::bx, hgcal::BX_MASK, hgcal::BX_POS, computeCRC8bit(), hgcal::EBO_MASK, hgcal::EBO_POS, hgcal::EHCRC_MASK, hgcal::EHCRC_POS, hgcal::EHHAM_MASK, hgcal::EHHAM_POS, RecoTauValidation_cfi::header, hgcal::HEADER_MASK, hgcal::HEADER_POS, hgcal::HT_MASK, hgcal::HT_POS, hgcal::L1A_MASK, hgcal::L1A_POS, hgcal::ORBIT_MASK, hgcal::ORBIT_POS, jetsAK4_Puppi_cff::payload, hgcal::PAYLOAD_MASK, hgcal::PAYLOAD_POS, findQualityFiles::rr, hgcal::RR_MASK, and hgcal::RR_POS.

Referenced by hgcal::HGCalFrameGenerator::produceECONEvent().

137  {
138  std::vector<uint32_t> words(2, 0);
139 
147 
152 
153  const auto crc = computeCRC8bit(words);
155 
156  return words;
157 }
static uint8_t computeCRC8bit(const std::vector< uint32_t > &event_header)

◆ produceERxData()

std::vector< uint32_t > hgcal::econd::produceERxData ( const ERxChannelEnable channel_enable,
const ERxData erx,
bool  passZS,
bool  passZSm1,
bool  hasToA,
bool  char_mode 
)

pack the ROC data to the ECON-D format dependending on:

  • characterization mode : (TcTp + ADC + TOT + TOA) fixed 32b
  • normal mode : size and fields depend on the TcTp flags
    Note
    based on Fig. 20 of ECON-D specifications
    Returns
    a vector of new words

Definition at line 6 of file HGCalRawDataPackingTools.cc.

References hgcal::econd::ERxData::adc, hgcal::econd::ERxData::adcm, AutomaticFull, data, Exception, mps_fire::i, createfilelist::int, noZeroSuppressed_TOASuppressed, hgcal::econd::ERxData::tctp, hgcal::econd::ERxData::toa, hgcal::econd::ERxData::tot, testProducerWithPsetDescEmpty_cfi::x1, testProducerWithPsetDescEmpty_cfi::x2, and siStripShotFilter_cfi::ZeroSuppressed.

Referenced by hgcal::HGCalFrameGenerator::generateERxData().

11  {
12  auto format_word = [&erx, &passZS, &passZSm1, &hasToA, &char_mode](size_t i) -> std::pair<uint32_t, uint8_t> {
13  if (i >= erx.tctp.size())
14  throw cms::Exception("HGCalEmulator")
15  << "Not enough channels in eRx data payload: " << i << " >= " << erx.tctp.size() << ".";
16  if (char_mode) // characterisation mode is easy
17  return std::make_pair(((uint8_t)erx.tctp.at(i) & 0x3) << 30 | (erx.adc.at(i) & 0x3ff) << 20 |
18  (erx.tot.at(i) & 0x3ff) << 10 | (erx.toa.at(i) & 0x3ff),
19  32);
20  switch (erx.tctp.at(i)) {
22  if (!passZS)
23  throw cms::Exception("HGCalEmulator") << "ToT status is ZeroSuppressed, but event frame does not pass ZS.";
24  if (passZSm1) {
25  if (hasToA)
26  return std::make_pair((0x1 << 30) | ((erx.adcm.at(i) & 0x3ff) << 20) | ((erx.adc.at(i) & 0x3ff) << 10) |
27  (erx.toa.at(i) & 0x3ff),
28  32);
29  else
30  return std::make_pair(((erx.adcm.at(i) & 0x3ff) << 10) | (erx.adc.at(i) & 0x3ff), 24);
31  }
32  // at this point, does not have any BX-1 ZS info
33  if (hasToA)
34  return std::make_pair((0x3 << 20) | ((erx.adc.at(i) & 0x3ff) << 10) | (erx.toa.at(i) & 0x3ff), 24);
35  return std::make_pair((0x1 << 10) | (erx.adc.at(i) & 0x3ff), 16);
36  }
38  return std::make_pair((0x2 << 20) | ((erx.adcm.at(i) & 0x3ff) << 10) | (erx.adc.at(i) & 0x3ff), 24);
39  case ToTStatus::invalid:
40  return std::make_pair(
41  (0x2 << 30) | ((erx.adcm.at(i) & 0x3ff) << 20) | ((erx.adc.at(i) & 0x3ff) << 10) | (erx.toa.at(i) & 0x3ff),
42  32);
44  return std::make_pair(
45  (0x3 << 30) | ((erx.adcm.at(i) & 0x3ff) << 20) | ((erx.tot.at(i) & 0x3ff) << 10) | (erx.toa.at(i) & 0x3ff),
46  32);
47  default:
48  throw cms::Exception("HGCalEmulator")
49  << "Invalid ToT status retrieved for channel " << i << ": " << (int)erx.tctp.at(i) << ".";
50  }
51  };
52 
53  std::vector<uint32_t> data{0};
54  std::vector<uint32_t>::iterator it_data = data.begin();
55 
56  uint8_t msb = 0;
57  for (size_t i = 0; i < channel_enable.size(); ++i) {
58  if (!channel_enable.at(i))
59  continue;
60  const auto [word, nbits] = format_word(i); // retrieve the channel word in its proper formatting
61 
62  if (msb >= 32) // if we are already at the next word
63  it_data = data.insert(data.end(), 0);
64  msb %= 32; // 0 <= msb < 32
65 
66  if (msb > 0) // do we have some room for additional information?
67  *it_data &= ((1 << msb) - 1);
68  if (msb + nbits > 32) { // spilling onto the next word
69  uint8_t nbits_word1 = 32 - msb - nbits;
70  *it_data |= (word & ((1 << nbits_word1) - 1)) << msb;
71  it_data = data.insert(data.end(), word >> nbits_word1);
72  } else // everything fits into one word
73  *it_data |= word << msb;
74  msb += nbits;
75  }
76  return data;
77 }
uint64_t word
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80