CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
sistrip::FEDBufferPayloadCreator Class Reference

#include <SiStripFEDBufferGenerator.h>

Public Member Functions

FEDBufferPayload createPayload (const FEDReadoutMode mode, const FEDStripData &data) const
 
 FEDBufferPayloadCreator (const std::vector< bool > &enabledFEUnits, const std::vector< bool > &enabledChannels)
 
FEDBufferPayload operator() (const FEDReadoutMode mode, const FEDStripData &data) const
 

Private Member Functions

void fillChannelBuffer (std::vector< uint8_t > *channelBuffer, const FEDReadoutMode mode, const FEDStripData::ChannelData &data, const bool channelEnabled) const
 
void fillClusterData (std::vector< uint8_t > *channelBuffer, const FEDStripData::ChannelData &data) const
 
void fillRawChannelBuffer (std::vector< uint8_t > *channelBuffer, const uint8_t packetCode, const FEDStripData::ChannelData &data, const bool channelEnabled, const bool reorderData) const
 
void fillZeroSuppressedChannelBuffer (std::vector< uint8_t > *channelBuffer, const FEDStripData::ChannelData &data, const bool channelEnabled) const
 
void fillZeroSuppressedLiteChannelBuffer (std::vector< uint8_t > *channelBuffer, const FEDStripData::ChannelData &data, const bool channelEnabled) const
 

Private Attributes

std::vector< bool > channelsEnabled_
 
std::vector< bool > feUnitsEnabled_
 

Detailed Description

Definition at line 76 of file SiStripFEDBufferGenerator.h.

Constructor & Destructor Documentation

sistrip::FEDBufferPayloadCreator::FEDBufferPayloadCreator ( const std::vector< bool > &  enabledFEUnits,
const std::vector< bool > &  enabledChannels 
)
inline

Definition at line 276 of file SiStripFEDBufferGenerator.h.

277  : feUnitsEnabled_(feUnitsEnabled),
278  channelsEnabled_(channelsEnabled)
279  {}

Member Function Documentation

FEDBufferPayload sistrip::FEDBufferPayloadCreator::createPayload ( const FEDReadoutMode  mode,
const FEDStripData data 
) const

Definition at line 103 of file SiStripFEDBufferGenerator.cc.

References sistrip::FEDStripData::channel(), sistrip::FEDCH_PER_FED, and sistrip::FEDCH_PER_FEUNIT.

Referenced by operator()().

104  {
105  std::vector< std::vector<uint8_t> > channelBuffers(FEDCH_PER_FED,std::vector<uint8_t>());
106  for (size_t iCh = 0; iCh < FEDCH_PER_FED; iCh++) {
107  if (!feUnitsEnabled_[iCh/FEDCH_PER_FEUNIT]) continue;
108  fillChannelBuffer(&channelBuffers[iCh],mode,data.channel(iCh),channelsEnabled_[iCh]);
109  }
110  return FEDBufferPayload(channelBuffers);
111  }
static const uint16_t FEDCH_PER_FEUNIT
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
static const uint16_t FEDCH_PER_FED
void fillChannelBuffer(std::vector< uint8_t > *channelBuffer, const FEDReadoutMode mode, const FEDStripData::ChannelData &data, const bool channelEnabled) const
void sistrip::FEDBufferPayloadCreator::fillChannelBuffer ( std::vector< uint8_t > *  channelBuffer,
const FEDReadoutMode  mode,
const FEDStripData::ChannelData data,
const bool  channelEnabled 
) const
private

Definition at line 113 of file SiStripFEDBufferGenerator.cc.

References edm::hlt::Exception, alignBH_cfg::mode, sistrip::PACKET_CODE_PROC_RAW, sistrip::PACKET_CODE_SCOPE, sistrip::PACKET_CODE_VIRGIN_RAW, sistrip::READOUT_MODE_PROC_RAW, sistrip::READOUT_MODE_SCOPE, sistrip::READOUT_MODE_VIRGIN_RAW, sistrip::READOUT_MODE_ZERO_SUPPRESSED, and sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE.

115  {
116  switch (mode) {
117  case READOUT_MODE_SCOPE:
118  fillRawChannelBuffer(channelBuffer,PACKET_CODE_SCOPE,data,channelEnabled,false);
119  break;
121  fillRawChannelBuffer(channelBuffer,PACKET_CODE_VIRGIN_RAW,data,channelEnabled,true);
122  break;
124  fillRawChannelBuffer(channelBuffer,PACKET_CODE_PROC_RAW,data,channelEnabled,false);
125  break;
127  fillZeroSuppressedChannelBuffer(channelBuffer,data,channelEnabled);
128  break;
130  fillZeroSuppressedLiteChannelBuffer(channelBuffer,data,channelEnabled);
131  break;
132  default:
133  std::ostringstream ss;
134  ss << "Invalid readout mode " << mode;
135  throw cms::Exception("FEDBufferGenerator") << ss.str();
136  break;
137  }
138  }
void fillZeroSuppressedChannelBuffer(std::vector< uint8_t > *channelBuffer, const FEDStripData::ChannelData &data, const bool channelEnabled) const
static const uint8_t PACKET_CODE_SCOPE
void fillRawChannelBuffer(std::vector< uint8_t > *channelBuffer, const uint8_t packetCode, const FEDStripData::ChannelData &data, const bool channelEnabled, const bool reorderData) const
void fillZeroSuppressedLiteChannelBuffer(std::vector< uint8_t > *channelBuffer, const FEDStripData::ChannelData &data, const bool channelEnabled) const
static const uint8_t PACKET_CODE_PROC_RAW
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
static const uint8_t PACKET_CODE_VIRGIN_RAW
void sistrip::FEDBufferPayloadCreator::fillClusterData ( std::vector< uint8_t > *  channelBuffer,
const FEDStripData::ChannelData data 
) const
private

Definition at line 222 of file SiStripFEDBufferGenerator.cc.

References ecalMGPA::adc(), sistrip::FEDStripData::ChannelData::get8BitSample(), sistrip::FEDStripData::ChannelData::size(), strip(), and sistrip::STRIPS_PER_APV.

223  {
224  uint16_t clusterSize = 0;
225  const uint16_t nSamples = data.size();
226  for( uint16_t strip = 0; strip < nSamples; ++strip) {
227  const uint8_t adc = data.get8BitSample(strip);
228 
229  if(adc) {
230  if( clusterSize==0 || strip == STRIPS_PER_APV ) {
231  if(clusterSize) {
232  *(channelBuffer->end() - clusterSize - 1) = clusterSize ;
233  clusterSize = 0;
234  }
235  channelBuffer->push_back(strip);
236  channelBuffer->push_back(0); //clustersize
237  }
238  channelBuffer->push_back(adc);
239  ++clusterSize;
240  }
241 
242  else if(clusterSize) {
243  *(channelBuffer->end() - clusterSize - 1) = clusterSize ;
244  clusterSize = 0;
245  }
246  }
247  if(clusterSize) *(channelBuffer->end() - clusterSize - 1) = clusterSize ;
248  }
int adc(sample_type sample)
get the ADC sample (12 bits)
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
static const uint16_t STRIPS_PER_APV
void sistrip::FEDBufferPayloadCreator::fillRawChannelBuffer ( std::vector< uint8_t > *  channelBuffer,
const uint8_t  packetCode,
const FEDStripData::ChannelData data,
const bool  channelEnabled,
const bool  reorderData 
) const
private

Definition at line 140 of file SiStripFEDBufferGenerator.cc.

References sistrip::FEDStripData::ChannelData::getSample(), sistrip::FEDStripOrdering::physicalOrderForStripInChannel(), and sistrip::FEDStripData::ChannelData::size().

145  {
146  const uint16_t nSamples = data.size();
147  //2 bytes per sample + packet code + 2 bytes for length
148  const uint16_t channelLength = nSamples*2 + 3;
149  channelBuffer->reserve(channelLength);
150  //length (max length is 0xFFF)
151  channelBuffer->push_back( channelLength & 0xFF );
152  channelBuffer->push_back( (channelLength & 0xF00) >> 8 );
153  //packet code
154  channelBuffer->push_back(packetCode);
155  //channel samples
156  for (uint16_t sampleNumber = 0; sampleNumber < nSamples; sampleNumber++) {
157  const uint16_t sampleIndex = ( reorderData ? FEDStripOrdering::physicalOrderForStripInChannel(sampleNumber) : sampleNumber );
158  const uint16_t sampleValue = (channelEnabled ? data.getSample(sampleIndex) : 0);
159  channelBuffer->push_back(sampleValue & 0xFF);
160  channelBuffer->push_back((sampleValue & 0x300) >> 8);
161  }
162  }
static uint8_t physicalOrderForStripInChannel(const uint8_t readoutOrderStripIndexInChannel)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void sistrip::FEDBufferPayloadCreator::fillZeroSuppressedChannelBuffer ( std::vector< uint8_t > *  channelBuffer,
const FEDStripData::ChannelData data,
const bool  channelEnabled 
) const
private

Definition at line 164 of file SiStripFEDBufferGenerator.cc.

References sistrip::FEDStripData::ChannelData::getMedians(), and sistrip::PACKET_CODE_ZERO_SUPPRESSED.

167  {
168  channelBuffer->reserve(50);
169  //if channel is disabled then create empty channel header and return
170  if (!channelEnabled) {
171  //min length 7
172  channelBuffer->push_back(7);
173  channelBuffer->push_back(0);
174  //packet code
175  channelBuffer->push_back(PACKET_CODE_ZERO_SUPPRESSED);
176  //4 bytes of medians
177  channelBuffer->insert(channelBuffer->end(),4,0);
178  return;
179  }
180  //if channel is not empty
181  //add space for channel length
182  channelBuffer->push_back(0xFF); channelBuffer->push_back(0xFF);
183  //packet code
184  channelBuffer->push_back(PACKET_CODE_ZERO_SUPPRESSED);
185  //add medians
186  const std::pair<uint16_t,uint16_t> medians = data.getMedians();
187  channelBuffer->push_back(medians.first & 0xFF);
188  channelBuffer->push_back((medians.first & 0x300) >> 8);
189  channelBuffer->push_back(medians.second & 0xFF);
190  channelBuffer->push_back((medians.second & 0x300) >> 8);
191  //clusters
192  fillClusterData(channelBuffer,data);
193  //set length
194  const uint16_t length = channelBuffer->size();
195  (*channelBuffer)[0] = (length & 0xFF);
196  (*channelBuffer)[1] = ((length & 0x300) >> 8);
197  }
void fillClusterData(std::vector< uint8_t > *channelBuffer, const FEDStripData::ChannelData &data) const
static const uint8_t PACKET_CODE_ZERO_SUPPRESSED
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void sistrip::FEDBufferPayloadCreator::fillZeroSuppressedLiteChannelBuffer ( std::vector< uint8_t > *  channelBuffer,
const FEDStripData::ChannelData data,
const bool  channelEnabled 
) const
private

Definition at line 199 of file SiStripFEDBufferGenerator.cc.

202  {
203  channelBuffer->reserve(50);
204  //if channel is disabled then create empty channel header and return
205  if (!channelEnabled) {
206  //min length 2
207  channelBuffer->push_back(2);
208  channelBuffer->push_back(0);
209  return;
210  }
211  //if channel is not empty
212  //add space for channel length
213  channelBuffer->push_back(0xFF); channelBuffer->push_back(0xFF);
214  //clusters
215  fillClusterData(channelBuffer,data);
216  //set length
217  const uint16_t length = channelBuffer->size();
218  (*channelBuffer)[0] = (length & 0xFF);
219  (*channelBuffer)[1] = ((length & 0x300) >> 8);
220  }
void fillClusterData(std::vector< uint8_t > *channelBuffer, const FEDStripData::ChannelData &data) const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
FEDBufferPayload sistrip::FEDBufferPayloadCreator::operator() ( const FEDReadoutMode  mode,
const FEDStripData data 
) const
inline

Definition at line 281 of file SiStripFEDBufferGenerator.h.

References createPayload().

282  {
283  return createPayload(mode,data);
284  }
FEDBufferPayload createPayload(const FEDReadoutMode mode, const FEDStripData &data) const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82

Member Data Documentation

std::vector<bool> sistrip::FEDBufferPayloadCreator::channelsEnabled_
private

Definition at line 99 of file SiStripFEDBufferGenerator.h.

std::vector<bool> sistrip::FEDBufferPayloadCreator::feUnitsEnabled_
private

Definition at line 98 of file SiStripFEDBufferGenerator.h.