CMS 3D CMS Logo

SiStripFEDSpyBuffer.h
Go to the documentation of this file.
1 #ifndef DQM_SiStripMonitorHardware_SiStripFEDSpyBuffer_H
2 #define DQM_SiStripMonitorHardware_SiStripFEDSpyBuffer_H
3 
4 #include <string>
5 #include <ostream>
7 #include <cstdint>
8 
9 namespace sistrip {
10 
11  //
12  // Constants
13  //
14 
15  static const uint16_t FEDCH_PER_DELAY_CHIP = 4;
17  static const uint16_t SPY_DELAY_CHIP_PAYLOAD_SIZE_IN_BYTES = 376 * 4; // 376 32bit words
18  static const uint16_t SPY_DELAY_CHIP_BUFFER_SIZE_IN_BYTES =
19  SPY_DELAY_CHIP_PAYLOAD_SIZE_IN_BYTES + 8; // Extra 8 bytes for counters
20  static const uint16_t SPY_DELAYCHIP_DATA_OFFSET_IN_BITS = 44; // Offset to start of data
21  //static const uint16_t SPY_SAMPLES_PER_CHANNEL = ( (SPY_DELAY_CHIP_BUFFER_SIZE_IN_BYTES * 8) - SPY_DELAYCHIP_DATA_OFFSET_IN_BITS ) / 10 / FEDCH_PER_DELAY_CHIP;
22  // TW Dirty hack to lose the 3 samples from the end that screw things up...
23  static const uint16_t SPY_SAMPLES_PER_CHANNEL = 298;
25  // Delaychip data + 8 bytes header for counters + 8 bytes for word with delay chip enable bits
26  // + 16 bytes for DAQ header and trailer
27 
28  //
29  // Class definitions
30  //
31 
32  //class representing spy channel buffers
33  class FEDSpyBuffer : public FEDBufferBase {
34  public:
43  //construct from buffer
44  explicit FEDSpyBuffer(const FEDRawData& fedBuffer);
45  ~FEDSpyBuffer() override;
46  void print(std::ostream& os) const override;
47 
48  //get the run number from the corresponding global run
49  uint32_t globalRunNumber() const;
50  //get the L1 ID stored in the spy header
51  uint32_t spyHeaderL1ID() const;
52  //get the total frame count stored in the spy header
53  uint32_t spyHeaderTotalEventCount() const;
54  //get the L1 ID after reading a given delay chip
55  uint32_t delayChipL1ID(const uint8_t delayChip) const;
56  //get the total event count after reading a given delay chip
57  uint32_t delayChipTotalEventCount(const uint8_t delayChip) const;
58 
59  //checks that a delay chip is complete i.e. that it all came from the same event
60  bool delayChipGood(const uint8_t delayChip) const;
61  //checks that a channel is usable (i.e. that the delay chip it is on is good)
62  bool channelGood(const uint8_t internalFEDannelNum) const override;
63 
64  private:
65  //mapping of channel index to position in data
67 
68  //setup the channel objects
69  void findChannels();
70 
71  const uint8_t* payloadPointer_;
72  uint16_t payloadLength_;
73  uint8_t versionId_;
74  };
75 
77  public:
78  explicit FEDSpyChannelUnpacker(const FEDChannel& channel);
79  uint16_t sampleNumber() const;
80  uint16_t adc() const;
81  bool hasData() const;
84 
85  private:
86  const uint32_t* data_;
88  uint16_t currentSample_;
89  uint16_t valuesLeft_;
90  };
91 
92  //
93  // Inline function definitions
94  //
95 
109  const auto st_base = preconstructCheckFEDBufferBase(fedBuffer, true);
110  if (FEDBufferStatusCode::SUCCESS != st_base)
111  return st_base;
112  const TrackerSpecialHeader hdr{fedBuffer.data() + 8};
113  if (READOUT_MODE_SPY != hdr.readoutMode())
116  }
117 
118  //FEDSpyChannelUnpacker
119 
121  : data_(reinterpret_cast<const uint32_t*>(channel.data())),
122  currentOffset_(channel.offset()),
123  currentSample_(0),
124  valuesLeft_(channel.length()) {}
125 
126  inline uint16_t FEDSpyChannelUnpacker::sampleNumber() const { return currentSample_; }
127 
128  inline bool FEDSpyChannelUnpacker::hasData() const { return (valuesLeft_ != 0); }
129 
132  currentSample_++;
133  valuesLeft_--;
134  return (*this);
135  }
136 
138  ++(*this);
139  return *this;
140  }
141 
142 } // namespace sistrip
143 
144 #endif //ndef DQM_SiStripMonitorHardware_SiStripFEDSpyBuffer_H
sistrip::preconstructCheckFEDSpyBuffer
FEDBufferStatusCode preconstructCheckFEDSpyBuffer(const FEDRawData &fedBuffer)
Definition: SiStripFEDSpyBuffer.h:108
sistrip::SPY_BUFFER_SIZE_IN_BYTES
static const uint16_t SPY_BUFFER_SIZE_IN_BYTES
Definition: SiStripFEDSpyBuffer.h:24
sistrip::FEDSpyBuffer::payloadLength_
uint16_t payloadLength_
Definition: SiStripFEDSpyBuffer.h:72
sistrip::FEDSpyChannelUnpacker::adc
uint16_t adc() const
Definition: SiStripFEDSpyBuffer.cc:139
sistrip::FEDSpyChannelUnpacker::sampleNumber
uint16_t sampleNumber() const
Definition: SiStripFEDSpyBuffer.h:126
sistrip::FEDSpyBuffer::findChannels
void findChannels()
Definition: SiStripFEDSpyBuffer.cc:23
sistrip::FEDSpyChannelUnpacker::valuesLeft_
uint16_t valuesLeft_
Definition: SiStripFEDSpyBuffer.h:89
sistrip::FEDSpyBuffer::delayChipTotalEventCount
uint32_t delayChipTotalEventCount(const uint8_t delayChip) const
Definition: SiStripFEDSpyBuffer.cc:92
sistrip::FEDSpyChannelUnpacker::operator++
FEDSpyChannelUnpacker & operator++()
Definition: SiStripFEDSpyBuffer.h:130
sistrip::READOUT_MODE_SPY
Definition: SiStripFEDBufferComponents.h:60
sistrip::FEDSpyChannelUnpacker::hasData
bool hasData() const
Definition: SiStripFEDSpyBuffer.h:128
watchdog.const
const
Definition: watchdog.py:83
sistrip::FEDBufferBase
Definition: SiStripFEDBufferComponents.h:643
FEDRawData::data
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
FEDRawData
Definition: FEDRawData.h:19
sistrip::SPY_DELAY_CHIP_PAYLOAD_SIZE_IN_BYTES
static const uint16_t SPY_DELAY_CHIP_PAYLOAD_SIZE_IN_BYTES
Definition: SiStripFEDSpyBuffer.h:17
sistrip::FEDSpyBuffer::delayChipL1ID
uint32_t delayChipL1ID(const uint8_t delayChip) const
Definition: SiStripFEDSpyBuffer.cc:82
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::FEDSpyChannelUnpacker::currentSample_
uint16_t currentSample_
Definition: SiStripFEDSpyBuffer.h:88
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::TrackerSpecialHeader
Definition: SiStripFEDBufferComponents.h:315
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::FEDBufferStatusCode
FEDBufferStatusCode
Definition: SiStripFEDBufferComponents.h:140
SiStripFEDBufferComponents.h
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::FEDBufferStatusCode::SUCCESS
sistrip::FEDSpyBuffer::payloadPointer_
const uint8_t * payloadPointer_
Definition: SiStripFEDSpyBuffer.h:71
sistrip::FEDSpyChannelUnpacker
Definition: SiStripFEDSpyBuffer.h:76
sistrip::preconstructCheckFEDBufferBase
FEDBufferStatusCode preconstructCheckFEDBufferBase(const FEDRawData &fedBuffer, bool checkRecognizedFormat=true)
Definition: SiStripFEDBufferComponents.h:757
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
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
sistrip::FEDBufferStatusCode::EXPECT_SPY
sistrip::FEDSpyChannelUnpacker::FEDSpyChannelUnpacker
FEDSpyChannelUnpacker(const FEDChannel &channel)
Definition: SiStripFEDSpyBuffer.h:120
sistrip::FEDSpyBuffer
Definition: SiStripFEDSpyBuffer.h:33
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
sistrip::FEDCH_PER_FED
static const uint16_t FEDCH_PER_FED
Definition: ConstantsForHardwareSystems.h:30
sistrip
sistrip classes
Definition: SiStripQualityHelpers.h:14
sistrip::FEDSpyBuffer::versionId_
uint8_t versionId_
Definition: SiStripFEDSpyBuffer.h:73
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
sistrip::FEDChannel
Definition: SiStripFEDBufferComponents.h:616
sistrip::FEDSpyBuffer::spyHeaderL1ID
uint32_t spyHeaderL1ID() const
Definition: SiStripFEDSpyBuffer.cc:56