CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 <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
FEDSpyChannelUnpacker(const FEDChannel &channel)
FEDBufferStatusCode preconstructCheckFEDSpyBuffer(const FEDRawData &fedBuffer)
static const uint16_t SPY_BUFFER_SIZE_IN_BYTES
static const uint16_t SPY_SAMPLES_PER_CHANNEL
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
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]
void print(std::ostream &os) const override
uint32_t spyHeaderTotalEventCount() const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
uint32_t delayChipL1ID(const uint8_t delayChip) const
static const uint16_t FEDCH_PER_FED
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
bool channelGood(const uint8_t internalFEDannelNum) const override
FEDSpyBuffer(const FEDRawData &fedBuffer)
FEDBufferStatusCode preconstructCheckFEDBufferBase(const FEDRawData &fedBuffer, bool checkRecognizedFormat=true)
bool delayChipGood(const uint8_t delayChip) const
static const uint16_t SPY_DELAYCHIP_DATA_OFFSET_IN_BITS
FEDSpyChannelUnpacker & operator++()