CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripFEDSpyBuffer.h
Go to the documentation of this file.
1 #ifndef DQM_SiStripMonitorHardware_SiStripFEDSpyBuffer_H
2 #define DQM_SiStripMonitorHardware_SiStripFEDSpyBuffer_H
3 
4 #include "boost/cstdint.hpp"
5 #include <string>
6 #include <ostream>
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 = SPY_DELAY_CHIP_PAYLOAD_SIZE_IN_BYTES+8; // Extra 8 bytes for counters
19  static const uint16_t SPY_DELAYCHIP_DATA_OFFSET_IN_BITS = 44; // Offset to start of data
20  //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;
21  // TW Dirty hack to lose the 3 samples from the end that screw things up...
22  static const uint16_t SPY_SAMPLES_PER_CHANNEL = 298;
24  // Delaychip data + 8 bytes header for counters + 8 bytes for word with delay chip enable bits
25  // + 16 bytes for DAQ header and trailer
26 
27  //
28  // Class definitions
29  //
30 
31  //class representing spy channel buffers
32  class FEDSpyBuffer : public FEDBufferBase
33  {
34  public:
35  //construct from buffer
36  FEDSpyBuffer(const uint8_t* fedBuffer, const size_t fedBufferSize);
37  virtual ~FEDSpyBuffer();
38  virtual void print(std::ostream& os) const;
39 
40  //get the run number from the corresponding global run
41  uint32_t globalRunNumber() const;
42  //get the L1 ID stored in the spy header
43  uint32_t spyHeaderL1ID() const;
44  //get the total frame count stored in the spy header
45  uint32_t spyHeaderTotalEventCount() const;
46  //get the L1 ID after reading a given delay chip
47  uint32_t delayChipL1ID(const uint8_t delayChip) const;
48  //get the total event count after reading a given delay chip
49  uint32_t delayChipTotalEventCount(const uint8_t delayChip) const;
50 
51  //checks that a delay chip is complete i.e. that it all came from the same event
52  bool delayChipGood(const uint8_t delayChip) const;
53  //checks that a channel is usable (i.e. that the delay chip it is on is good)
54  virtual bool channelGood(const uint8_t internalFEDannelNum) const;
55  private:
56  //mapping of channel index to position in data
58 
59  //setup the channel objects
60  void findChannels();
61 
62  const uint8_t* payloadPointer_;
63  uint16_t payloadLength_;
64  uint8_t versionId_;
65  };
66 
68  {
69  public:
70  explicit FEDSpyChannelUnpacker(const FEDChannel& channel);
71  uint16_t sampleNumber() const;
72  uint16_t adc() const;
73  bool hasData() const;
76  private:
77  const uint32_t* data_;
79  uint16_t currentSample_;
80  uint16_t valuesLeft_;
81  };
82 
83  //
84  // Inline function definitions
85  //
86 
87  //FEDSpyChannelUnpacker
88 
90  : data_(reinterpret_cast<const uint32_t*>(channel.data())),
91  currentOffset_(channel.offset()),
92  currentSample_(0),
93  valuesLeft_(channel.length())
94  {
95  }
96 
97  inline uint16_t FEDSpyChannelUnpacker::sampleNumber() const
98  {
99  return currentSample_;
100  }
101 
102  inline bool FEDSpyChannelUnpacker::hasData() const
103  {
104  return (valuesLeft_ != 0);
105  }
106 
108  {
110  currentSample_++;
111  valuesLeft_--;
112  return (*this);
113  }
114 
116  {
117  ++(*this); return *this;
118  }
119 
120 }
121 
122 #endif //ndef DQM_SiStripMonitorHardware_SiStripFEDSpyBuffer_H
FEDSpyChannelUnpacker(const FEDChannel &channel)
static const uint16_t SPY_BUFFER_SIZE_IN_BYTES
static const uint16_t SPY_SAMPLES_PER_CHANNEL
virtual void print(std::ostream &os) const
uint32_t globalRunNumber() const
static const uint16_t DELAY_CHIPS_PER_FED
static const uint16_t SPY_DELAY_CHIP_PAYLOAD_SIZE_IN_BYTES
uint32_t delayChipTotalEventCount(const uint8_t delayChip) const
uint32_t spyHeaderL1ID() const
unsigned int offset(bool)
static const uint16_t FEDCH_PER_DELAY_CHIP
static const uint16_t SPY_DELAY_CHIP_BUFFER_SIZE_IN_BYTES
const uint8_t * payloadPointer_
static const uint8_t channelPositionsInData_[FEDCH_PER_DELAY_CHIP]
FEDSpyBuffer(const uint8_t *fedBuffer, const size_t fedBufferSize)
uint32_t spyHeaderTotalEventCount() const
string const
Definition: compareJSON.py:14
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
uint32_t delayChipL1ID(const uint8_t delayChip) const
static const uint16_t FEDCH_PER_FED
bool delayChipGood(const uint8_t delayChip) const
static const uint16_t SPY_DELAYCHIP_DATA_OFFSET_IN_BITS
FEDSpyChannelUnpacker & operator++()
virtual bool channelGood(const uint8_t internalFEDannelNum) const