CMS 3D CMS Logo

SiStripFEDSpyBuffer.cc
Go to the documentation of this file.
3 
4 namespace sistrip {
5 
7 
9  : FEDBufferBase(fedBuffer),
10  payloadPointer_(getPointerToDataAfterTrackerSpecialHeader() + 16),
11  payloadLength_(getPointerToByteAfterEndOfPayload() - payloadPointer_),
12  versionId_(*(getPointerToDataAfterTrackerSpecialHeader() + 3)) {
13  //Check the buffer format version ID and take action for any exceptions
14  if (versionId_ == 0x00) {
16  }
17  //find the channel start positions
18  findChannels();
19  }
20 
22 
24  size_t delayChipStartByteIndex = 0;
25  //Loop over delay chips checking their data fits into buffer and setting up channel objects with correct offset
26  for (uint8_t iDelayChip = 0; iDelayChip < DELAY_CHIPS_PER_FED; ++iDelayChip) {
27  if (delayChipStartByteIndex + SPY_DELAY_CHIP_BUFFER_SIZE_IN_BYTES > payloadLength_) {
28  throw cms::Exception("FEDSpyBuffer") << "Delay chip " << uint16_t(iDelayChip) << " does not fit into buffer. "
29  << "Buffer size is " << bufferSize() << " delay chip data starts at "
30  << delayChipStartByteIndex + 8 + 8 + 8 + 8 << ". ";
31  }
32  for (uint8_t i = 0; i < FEDCH_PER_DELAY_CHIP; i++) {
33  const uint8_t chanelIndexInDataOrder = channelPositionsInData_[i];
34  const uint8_t fedCh = iDelayChip * FEDCH_PER_DELAY_CHIP + i;
35  const size_t channelOffsetInBits = SPY_DELAYCHIP_DATA_OFFSET_IN_BITS + 10 * chanelIndexInDataOrder;
36  channels_[fedCh] =
37  FEDChannel(payloadPointer_ + delayChipStartByteIndex, channelOffsetInBits, SPY_SAMPLES_PER_CHANNEL);
38  }
39  delayChipStartByteIndex += SPY_DELAY_CHIP_BUFFER_SIZE_IN_BYTES;
40  }
41  }
42 
43  uint32_t FEDSpyBuffer::globalRunNumber() const {
44  if (versionId_ < 0x02) {
45  return 0;
46  }
47  const uint8_t* runNumberPointer = getPointerToDataAfterTrackerSpecialHeader() + 4;
48  uint32_t result = 0;
49  result |= runNumberPointer[0];
50  result |= (uint32_t(runNumberPointer[1]) << 8);
51  result |= (uint32_t(runNumberPointer[2]) << 16);
52  result |= (uint32_t(runNumberPointer[3]) << 24);
53  return result;
54  }
55 
56  uint32_t FEDSpyBuffer::spyHeaderL1ID() const {
57  if (versionId_ == 0x00) {
58  return delayChipL1ID(0);
59  }
60  uint32_t result = 0;
61  const uint8_t* spyCounters = payloadPointer_ - 8;
62  result |= spyCounters[4];
63  result |= (uint32_t(spyCounters[5]) << 8);
64  result |= (uint32_t(spyCounters[6]) << 16);
65  result |= (uint32_t(spyCounters[7]) << 24);
66  return result;
67  }
68 
70  if (versionId_ == 0x00) {
71  return delayChipTotalEventCount(0);
72  }
73  uint32_t result = 0;
74  const uint8_t* spyCounters = payloadPointer_ - 8;
75  result |= spyCounters[0];
76  result |= (uint32_t(spyCounters[1]) << 8);
77  result |= (uint32_t(spyCounters[2]) << 16);
78  result |= (uint32_t(spyCounters[3]) << 24);
79  return result;
80  }
81 
82  uint32_t FEDSpyBuffer::delayChipL1ID(const uint8_t delayChip) const {
83  const uint8_t* delayChipCounters = payloadPointer_ + ((SPY_DELAY_CHIP_BUFFER_SIZE_IN_BYTES) * (delayChip + 1) - 8);
84  uint32_t result = 0;
85  result |= delayChipCounters[4];
86  result |= (uint32_t(delayChipCounters[5]) << 8);
87  result |= (uint32_t(delayChipCounters[6]) << 16);
88  result |= (uint32_t(delayChipCounters[7]) << 24);
89  return result;
90  }
91 
92  uint32_t FEDSpyBuffer::delayChipTotalEventCount(const uint8_t delayChip) const {
93  const uint8_t* delayChipCounters = payloadPointer_ + ((SPY_DELAY_CHIP_BUFFER_SIZE_IN_BYTES) * (delayChip + 1) - 8);
94  uint32_t result = 0;
95  result |= delayChipCounters[0];
96  result |= (uint32_t(delayChipCounters[1]) << 8);
97  result |= (uint32_t(delayChipCounters[2]) << 16);
98  result |= (uint32_t(delayChipCounters[3]) << 24);
99  return result;
100  }
101 
102  void FEDSpyBuffer::print(std::ostream& os) const {
104  //TODO
105  }
106 
107  bool FEDSpyBuffer::delayChipGood(const uint8_t delayChip) const {
108  if (versionId_ == 0x00) {
109  if (delayChip == 0)
110  return true;
111  }
112  uint32_t l1CountBefore = 0;
113  uint32_t totalEventCountBefore = 0;
114  if (delayChip == 0) {
115  l1CountBefore = spyHeaderL1ID();
116  totalEventCountBefore = spyHeaderTotalEventCount();
117  } else {
118  l1CountBefore = delayChipL1ID(delayChip - 1);
119  totalEventCountBefore = delayChipTotalEventCount(delayChip - 1);
120  }
121  const uint32_t l1CountAfter = delayChipL1ID(delayChip);
122  const uint32_t totalEventCountAfter = delayChipTotalEventCount(delayChip);
123  const bool eventMatches = ((l1CountBefore == l1CountAfter) && (totalEventCountBefore == totalEventCountAfter));
124  if (!eventMatches) {
125  std::ostringstream ss;
126  ss << "Delay chip data was overwritten on chip " << uint16_t(delayChip) << " L1A before: " << l1CountBefore
127  << " after: " << l1CountAfter << " Total event count before: " << totalEventCountBefore
128  << " after: " << totalEventCountAfter << std::endl;
129  dump(ss);
130  edm::LogInfo("FEDSpyBuffer") << ss.str();
131  }
132  return eventMatches;
133  }
134 
137  }
138 
139  uint16_t FEDSpyChannelUnpacker::adc() const {
140  const size_t offsetWords = currentOffset_ / 32;
141  const uint8_t offsetBits = currentOffset_ % 32;
142  if (offsetBits < 23) {
143  return ((data_[offsetWords] >> (32 - 10 - offsetBits)) & 0x3FF);
144  } else {
145  return (((data_[offsetWords] << (10 - 32 + offsetBits)) & 0x3FF) |
146  ((data_[offsetWords + 1] & (0xFFC00000 << (32 - offsetBits))) >> (64 - 10 - offsetBits)));
147  }
148  }
149 
150 } // namespace sistrip
mps_fire.i
i
Definition: mps_fire.py:428
sistrip::FEDSpyBuffer::payloadLength_
uint16_t payloadLength_
Definition: SiStripFEDSpyBuffer.h:72
sistrip::FEDBufferBase::dump
void dump(std::ostream &os) const
Definition: SiStripFEDBufferComponents.h:1395
MessageLogger.h
sistrip::FEDSpyChannelUnpacker::adc
uint16_t adc() const
Definition: SiStripFEDSpyBuffer.cc:139
sistrip::FEDSpyBuffer::findChannels
void findChannels()
Definition: SiStripFEDSpyBuffer.cc:23
sistrip::FEDSpyBuffer::delayChipTotalEventCount
uint32_t delayChipTotalEventCount(const uint8_t delayChip) const
Definition: SiStripFEDSpyBuffer.cc:92
sistrip::FEDBufferBase::getPointerToDataAfterTrackerSpecialHeader
const uint8_t * getPointerToDataAfterTrackerSpecialHeader() const
Definition: SiStripFEDBufferComponents.h:1550
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
sistrip::FEDBufferBase
Definition: SiStripFEDBufferComponents.h:643
FEDRawData
Definition: FEDRawData.h:19
sistrip::FEDSpyBuffer::delayChipL1ID
uint32_t delayChipL1ID(const uint8_t delayChip) const
Definition: SiStripFEDSpyBuffer.cc:82
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
sistrip::internalFEDChannelNum
uint8_t internalFEDChannelNum(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum)
Definition: SiStripFEDBufferComponents.h:785
sistrip::FEDSpyBuffer::globalRunNumber
uint32_t globalRunNumber() const
Definition: SiStripFEDSpyBuffer.cc:43
sistrip::FEDSpyBuffer::delayChipGood
bool delayChipGood(const uint8_t delayChip) const
Definition: SiStripFEDSpyBuffer.cc:107
sistrip::SPY_SAMPLES_PER_CHANNEL
static const uint16_t SPY_SAMPLES_PER_CHANNEL
Definition: SiStripFEDSpyBuffer.h:23
sistrip::FEDCH_PER_DELAY_CHIP
static const uint16_t FEDCH_PER_DELAY_CHIP
Definition: SiStripFEDSpyBuffer.h:15
sistrip::SPY_DELAY_CHIP_BUFFER_SIZE_IN_BYTES
static const uint16_t SPY_DELAY_CHIP_BUFFER_SIZE_IN_BYTES
Definition: SiStripFEDSpyBuffer.h:18
sistrip::FEDSpyChannelUnpacker::currentOffset_
size_t currentOffset_
Definition: SiStripFEDSpyBuffer.h:87
sistrip::FEDSpyBuffer::spyHeaderTotalEventCount
uint32_t spyHeaderTotalEventCount() const
Definition: SiStripFEDSpyBuffer.cc:69
sistrip::FEDSpyBuffer::~FEDSpyBuffer
~FEDSpyBuffer() override
Definition: SiStripFEDSpyBuffer.cc:21
sistrip::FEDBufferBase::channels_
std::vector< FEDChannel > channels_
Definition: SiStripFEDBufferComponents.h:730
sistrip::FEDSpyBuffer::print
void print(std::ostream &os) const override
Definition: SiStripFEDSpyBuffer.cc:102
sistrip::DELAY_CHIPS_PER_FED
static const uint16_t DELAY_CHIPS_PER_FED
Definition: SiStripFEDSpyBuffer.h:16
sistrip::FEDBufferBase::print
virtual void print(std::ostream &os) const
Definition: SiStripFEDBufferComponents.cc:1310
sistrip::FEDBufferBase::bufferSize
size_t bufferSize() const
Definition: SiStripFEDBufferComponents.h:1405
sistrip::FEDSpyBuffer::payloadPointer_
const uint8_t * payloadPointer_
Definition: SiStripFEDSpyBuffer.h:71
sistrip::FEDSpyBuffer::channelPositionsInData_
static const uint8_t channelPositionsInData_[FEDCH_PER_DELAY_CHIP]
Definition: SiStripFEDSpyBuffer.h:66
sistrip::SPY_DELAYCHIP_DATA_OFFSET_IN_BITS
static const uint16_t SPY_DELAYCHIP_DATA_OFFSET_IN_BITS
Definition: SiStripFEDSpyBuffer.h:20
sistrip::FEDSpyChannelUnpacker::data_
const uint32_t * data_
Definition: SiStripFEDSpyBuffer.h:86
Exception
Definition: hltDiff.cc:245
sistrip::FEDSpyBuffer::FEDSpyBuffer
FEDSpyBuffer(const FEDRawData &fedBuffer)
Definition: SiStripFEDSpyBuffer.cc:8
sistrip::FEDSpyBuffer::channelGood
bool channelGood(const uint8_t internalFEDannelNum) const override
Definition: SiStripFEDSpyBuffer.cc:135
mps_fire.result
result
Definition: mps_fire.py:311
sistrip
sistrip classes
Definition: EnsembleCalibrationLA.cc:10
sistrip::FEDSpyBuffer::versionId_
uint8_t versionId_
Definition: SiStripFEDSpyBuffer.h:73
sistrip::FEDChannel
Definition: SiStripFEDBufferComponents.h:616
SiStripFEDSpyBuffer.h
sistrip::FEDSpyBuffer::spyHeaderL1ID
uint32_t spyHeaderL1ID() const
Definition: SiStripFEDSpyBuffer.cc:56