1 #ifndef EventFilter_SiStripRawToDigi_SiStripFEDBufferGenerator_H 2 #define EventFilter_SiStripRawToDigi_SiStripFEDBufferGenerator_H 4 #include "boost/cstdint.hpp" 25 const std::pair<uint16_t,uint16_t> medians = std::make_pair<uint16_t>(0,0));
29 std::pair<uint16_t,uint16_t>
getMedians()
const;
33 uint16_t
getSample(
const uint16_t sampleNumber)
const;
37 void setSample(
const uint16_t sampleNumber,
const uint16_t adcValue);
40 const uint16_t&
operator [] (
const size_t sampleNumber)
const;
65 size_t lengthInBytes()
const;
67 const uint8_t*
data()
const;
69 uint16_t getFELength(
const uint8_t internalFEUnitNum)
const;
71 void appendToBuffer(
size_t* pIndexInBuffer,
const uint8_t
value);
72 void appendToBuffer(
size_t* pIndexInBuffer, std::vector<uint8_t>::const_iterator
start, std::vector<uint8_t>::const_iterator finish);
89 void fillChannelBuffer(std::vector<uint8_t>* channelBuffer,
const FEDReadoutMode mode,
92 void fillRawChannelBuffer(std::vector<uint8_t>* channelBuffer,
const uint8_t packetCode,
95 void fillZeroSuppressedChannelBuffer(std::vector<uint8_t>* channelBuffer,
const FEDStripData::ChannelData& data,
const bool channelEnabled)
const;
97 void fillPreMixRawChannelBuffer(std::vector<uint8_t>* channelBuffer,
const FEDStripData::ChannelData& data,
const bool channelEnabled)
const;
110 const uint16_t bxID = 0,
111 const std::vector<bool>& feUnitsEnabled = std::vector<bool>(
FEUNITS_PER_FED,
true),
112 const std::vector<bool>& channelsEnabled = std::vector<bool>(
FEDCH_PER_FED,
true),
118 uint32_t getL1ID()
const;
119 uint16_t getBXID()
const;
132 bool getFEUnitEnabled(
const uint8_t internalFEUnitNumber)
const;
133 bool getChannelEnabled(
const uint8_t internalFEDChannelNumber)
const;
135 FEDBufferGenerator& setChannelEnable(
const uint8_t internalFEDChannelNumber,
const bool enabled);
147 void generateBuffer(
FEDRawData* rawDataObject,
149 const uint16_t sourceID)
const;
153 static void fillBuffer(uint8_t* pointerToStartOfBuffer,
160 static size_t bufferSizeInBytes(
const FEDFEHeader& feHeader,
189 return channel(internalFEDChannelNum);
194 return channel(internalFEDChannelNum);
198 const std::pair<uint16_t,uint16_t> medians)
200 data_(numberOfSamples,0),
201 dataIs8Bit_(dataIsAlreadyConvertedTo8Bit)
211 return data_[sampleNumber];
217 return const_cast<uint16_t&
>(
static_cast<const ChannelData&
>(*this)[sampleNumber]);
231 return data_[sampleNumber];
245 sample = (sample>>1);
249 sample = (sample>>2);
252 throw cms::Exception(
"FEDBufferGenerator") <<
"Invalid readout mode requested for 8-bit sample retrieval";
255 return (0xFF & sample);
258 if (sample < 0xFE)
return sample;
259 else if (sample == 0x3FF)
return 0xFF;
271 if (sample < 0x3FF)
return sample;
295 data_[((*pIndexInBuffer)++)^7] = value;
300 for (std::vector<uint8_t>::const_iterator iVal = start; iVal != finish; iVal++) {
301 appendToBuffer(pIndexInBuffer,*iVal);
308 : feUnitsEnabled_(feUnitsEnabled),
309 channelsEnabled_(channelsEnabled)
321 return defaultDAQHeader_.l1ID();
326 return defaultDAQHeader_.bxID();
331 return defaultTrackerSpecialHeader_.readoutMode();
336 return defaultTrackerSpecialHeader_.headerType();
341 return defaultTrackerSpecialHeader_.bufferFormat();
346 return defaultDAQHeader_.eventType();
351 defaultDAQHeader_.
setL1ID(newL1ID);
357 defaultDAQHeader_.
setBXID(newBXID);
381 defaultDAQHeader_.setEventType(newDAQEventType);
387 return defaultDAQHeader_;
392 return defaultDAQTrailer_;
397 return defaultTrackerSpecialHeader_;
402 return *defaultFEHeader_;
414 #endif //ndef EventFilter_SiStripRawToDigi_FEDBufferGenerator_H
FEDDAQHeader defaultDAQHeader_
void setSample(const uint16_t sampleNumber, const uint16_t adcValue)
void setMedians(const std::pair< uint16_t, uint16_t > values)
FEDBufferGenerator & setReadoutMode(const FEDReadoutMode newReadoutMode)
static size_t bufferSizeInBytes(const FEDFEHeader &feHeader, const FEDBufferPayload &payload)
FEDStripData(const std::vector< ChannelData > &data)
uint8_t internalFEDChannelNum(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum)
std::vector< bool > channelsEnabled_
TrackerSpecialHeader & trackerSpecialHeader()
FEDBufferGenerator & setBufferFormat(const FEDBufferFormat newBufferFormat)
FEDReadoutMode getReadoutMode() const
numberOfSamples
threshold for setting fine grain bit
FEDBufferFormat getBufferFormat() const
ChannelData(bool dataIsAlreadyConvertedTo8Bit, const size_t numberOfSamples, const std::pair< uint16_t, uint16_t > medians=std::make_pair< uint16_t >(0, 0))
uint16_t get10BitSample(const uint16_t sampleNumber) const
FEDDAQTrailer & daqTrailer()
FEDBufferPayloadCreator(const std::vector< bool > &enabledFEUnits, const std::vector< bool > &enabledChannels)
std::vector< bool > feUnitsEnabled_
std::vector< bool > channelsEnabled_
T * createPayload(const std::string &payloadTypeName)
std::vector< uint16_t > data_
std::pair< uint16_t, uint16_t > getMedians() const
static const uint16_t FEUNITS_PER_FED
FEDDAQTrailer defaultDAQTrailer_
void appendToBuffer(size_t *pIndexInBuffer, const uint8_t value)
FEDBufferGenerator & setDAQEventType(const FEDDAQEventType newDAQEventType)
FEDBufferPayload createPayload(const FEDReadoutMode mode, const FEDStripData &data) const
static const uint16_t STRIPS_PER_FEDCH
FEDBufferGenerator & setHeaderType(const FEDHeaderType newHeaderType)
ChannelData & channel(const uint8_t internalFEDChannelNum)
ChannelData & operator[](const uint8_t internalFEDChannelNum)
FEDBufferGenerator & setL1ID(const uint32_t newL1ID)
uint16_t getSample(const uint16_t sampleNumber) const
std::auto_ptr< FEDFEHeader > defaultFEHeader_
FEDBufferPayload operator()(const FEDReadoutMode mode, const FEDStripData &data) const
char data[epos_bytes_allocation]
std::vector< bool > feUnitsEnabled_
std::vector< uint16_t > feLengths_
static const uint16_t FEDCH_PER_FED
std::vector< ChannelData > data_
std::pair< uint16_t, uint16_t > medians_
size_t lengthInBytes() const
std::vector< uint8_t > data_
FEDDAQEventType getDAQEventType() const
FEDBufferGenerator & setBXID(const uint16_t newBXID)
TrackerSpecialHeader defaultTrackerSpecialHeader_
uint8_t get8BitSample(const uint16_t sampleNumber, const FEDReadoutMode mode) const
FEDDAQHeader & daqHeader()
FEDHeaderType getHeaderType() const
uint16_t & operator[](const size_t sampleNumber)