CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
sistrip::DigiToRaw Class Reference

Input: edm::DetSetVector<SiStripDigi>. Output: FEDRawDataCollection. More...

#include <SiStripDigiToRaw.h>

Public Member Functions

void createFedBuffers (edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< edm::DetSetVector< SiStripDigi > > &digis, std::unique_ptr< FEDRawDataCollection > &buffers)
 
void createFedBuffers (edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< edm::DetSetVector< SiStripRawDigi > > &digis, std::unique_ptr< FEDRawDataCollection > &buffers)
 
void createFedBuffers (edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< FEDRawDataCollection > &rawbuffers, edm::Handle< edm::DetSetVector< SiStripDigi > > &digis, std::unique_ptr< FEDRawDataCollection > &buffers)
 
void createFedBuffers (edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< FEDRawDataCollection > &rawbuffers, edm::Handle< edm::DetSetVector< SiStripRawDigi > > &digis, std::unique_ptr< FEDRawDataCollection > &buffers)
 
 DigiToRaw (FEDReadoutMode mode, uint8_t packetCode, bool use_fed_key)
 
void fedReadoutMode (FEDReadoutMode mode)
 
void printWarningSummary () const
 
 ~DigiToRaw ()
 

Private Member Functions

template<class Digi_t >
void createFedBuffers_ (edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< edm::DetSetVector< Digi_t > > &digis, std::unique_ptr< FEDRawDataCollection > &buffers, bool zeroSuppressed)
 
template<class Digi_t >
void createFedBuffers_ (edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< FEDRawDataCollection > &rawbuffers, edm::Handle< edm::DetSetVector< Digi_t > > &digis, std::unique_ptr< FEDRawDataCollection > &buffers, bool zeroSuppressed)
 
uint16_t STRIP (const edm::DetSet< SiStripDigi >::const_iterator &it, const edm::DetSet< SiStripDigi >::const_iterator &begin) const
 
uint16_t STRIP (const edm::DetSet< SiStripRawDigi >::const_iterator &it, const edm::DetSet< SiStripRawDigi >::const_iterator &begin) const
 

Private Attributes

FEDBufferGenerator bufferGenerator_
 
FEDReadoutMode mode_
 
uint8_t packetCode_
 
bool useFedKey_
 
WarningSummary warnings_
 

Detailed Description

Input: edm::DetSetVector<SiStripDigi>. Output: FEDRawDataCollection.

Definition at line 29 of file SiStripDigiToRaw.h.

Constructor & Destructor Documentation

sistrip::DigiToRaw::DigiToRaw ( FEDReadoutMode  mode,
uint8_t  packetCode,
bool  use_fed_key 
)

Definition at line 22 of file SiStripDigiToRaw.cc.

References bufferGenerator_, edm::isDebugEnabled(), LogDebug, mode_, and sistrip::FEDBufferGenerator::setReadoutMode().

23  : mode_(mode),
24  packetCode_(packetCode),
25  useFedKey_(useFedKey),
27  warnings_("DigiToRaw", "[sistrip::DigiToRaw::createFedBuffers_]", edm::isDebugEnabled()) {
28  if (edm::isDebugEnabled()) {
29  LogDebug("DigiToRaw") << "[sistrip::DigiToRaw::DigiToRaw]"
30  << " Constructing object...";
31  }
33  }
#define LogDebug(id)
bool isDebugEnabled()
FEDBufferGenerator & setReadoutMode(const FEDReadoutMode newReadoutMode)
WarningSummary warnings_
FEDReadoutMode mode_
FEDBufferGenerator bufferGenerator_
sistrip::DigiToRaw::~DigiToRaw ( )

Definition at line 37 of file SiStripDigiToRaw.cc.

References edm::isDebugEnabled(), and LogDebug.

37  {
38  if (edm::isDebugEnabled()) {
39  LogDebug("DigiToRaw") << "[sistrip::DigiToRaw::~DigiToRaw]"
40  << " Destructing object...";
41  }
42  }
#define LogDebug(id)
bool isDebugEnabled()

Member Function Documentation

void sistrip::DigiToRaw::createFedBuffers ( edm::Event event,
edm::ESHandle< SiStripFedCabling > &  cabling,
edm::Handle< edm::DetSetVector< SiStripDigi > > &  collection,
std::unique_ptr< FEDRawDataCollection > &  buffers 
)

Input: DetSetVector of SiStripDigis. Output: FEDRawDataCollection. Retrieves and iterates through FED buffers, extract FEDRawData from collection and (optionally) dumps raw data to stdout, locates start of FED buffer by identifying DAQ header, creates new Fed9UEvent object using current FEDRawData buffer, dumps FED buffer to stdout, retrieves data from various header fields

Definition at line 53 of file SiStripDigiToRaw.cc.

References universalConfigTemplate::collection, and createFedBuffers_().

Referenced by sistrip::DigiToRawModule::produce().

56  {
57  createFedBuffers_(event, cabling, collection, buffers, true);
58  }
void createFedBuffers_(edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< edm::DetSetVector< Digi_t > > &digis, std::unique_ptr< FEDRawDataCollection > &buffers, bool zeroSuppressed)
void sistrip::DigiToRaw::createFedBuffers ( edm::Event event,
edm::ESHandle< SiStripFedCabling > &  cabling,
edm::Handle< edm::DetSetVector< SiStripRawDigi > > &  digis,
std::unique_ptr< FEDRawDataCollection > &  buffers 
)

Definition at line 60 of file SiStripDigiToRaw.cc.

References universalConfigTemplate::collection, and createFedBuffers_().

63  {
64  createFedBuffers_(event, cabling, collection, buffers, false);
65  }
void createFedBuffers_(edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< edm::DetSetVector< Digi_t > > &digis, std::unique_ptr< FEDRawDataCollection > &buffers, bool zeroSuppressed)
void sistrip::DigiToRaw::createFedBuffers ( edm::Event event,
edm::ESHandle< SiStripFedCabling > &  cabling,
edm::Handle< FEDRawDataCollection > &  rawbuffers,
edm::Handle< edm::DetSetVector< SiStripDigi > > &  digis,
std::unique_ptr< FEDRawDataCollection > &  buffers 
)

Definition at line 68 of file SiStripDigiToRaw.cc.

References universalConfigTemplate::collection, and createFedBuffers_().

72  {
73  createFedBuffers_(event, cabling, rawbuffers, collection, buffers, true);
74  }
void createFedBuffers_(edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< edm::DetSetVector< Digi_t > > &digis, std::unique_ptr< FEDRawDataCollection > &buffers, bool zeroSuppressed)
void sistrip::DigiToRaw::createFedBuffers ( edm::Event event,
edm::ESHandle< SiStripFedCabling > &  cabling,
edm::Handle< FEDRawDataCollection > &  rawbuffers,
edm::Handle< edm::DetSetVector< SiStripRawDigi > > &  digis,
std::unique_ptr< FEDRawDataCollection > &  buffers 
)

Definition at line 76 of file SiStripDigiToRaw.cc.

References universalConfigTemplate::collection, and createFedBuffers_().

80  {
81  createFedBuffers_(event, cabling, rawbuffers, collection, buffers, false);
82  }
void createFedBuffers_(edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< edm::DetSetVector< Digi_t > > &digis, std::unique_ptr< FEDRawDataCollection > &buffers, bool zeroSuppressed)
template<class Digi_t >
void sistrip::DigiToRaw::createFedBuffers_ ( edm::Event event,
edm::ESHandle< SiStripFedCabling > &  cabling,
edm::Handle< edm::DetSetVector< Digi_t > > &  digis,
std::unique_ptr< FEDRawDataCollection > &  buffers,
bool  zeroSuppressed 
)
private

Definition at line 85 of file SiStripDigiToRaw.cc.

References universalConfigTemplate::collection.

Referenced by createFedBuffers().

89  {
91  //CAMM initialise to some dummy empty buffers??? Or OK like this ?
92  createFedBuffers_(event, cabling, rawbuffers, collection, buffers, zeroSuppressed);
93  }
void createFedBuffers_(edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< edm::DetSetVector< Digi_t > > &digis, std::unique_ptr< FEDRawDataCollection > &buffers, bool zeroSuppressed)
template<class Digi_t >
void sistrip::DigiToRaw::createFedBuffers_ ( edm::Event event,
edm::ESHandle< SiStripFedCabling > &  cabling,
edm::Handle< FEDRawDataCollection > &  rawbuffers,
edm::Handle< edm::DetSetVector< Digi_t > > &  digis,
std::unique_ptr< FEDRawDataCollection > &  buffers,
bool  zeroSuppressed 
)
private

Definition at line 96 of file SiStripDigiToRaw.cc.

References sistrip::WarningSummary::add(), sistrip::TrackerSpecialHeader::apvAddressErrorRegister(), sistrip::TrackerSpecialHeader::apveAddress(), sistrip::TrackerSpecialHeader::bufferFormat(), bufferGenerator_, universalConfigTemplate::collection, gather_cfg::cout, sistrip::FEDBufferGenerator::daqHeader(), sistrip::FEDBufferGenerator::daqTrailer(), FEDRawData::data(), edm::DetSet< T >::data, MillePedeFileConverter_cfg::e, edm::EventID::event(), cppFunctionSkipper::exception, sistrip::FEDCH_PER_FEUNIT, SiStripFedCabling::fedConnections(), FEDRawDataCollection::FEDData(), SiStripFedCabling::fedIds(), sistrip::TrackerSpecialHeader::fedStatusRegister(), sistrip::TrackerSpecialHeader::feEnableRegister(), sistrip::FEDBufferGenerator::feHeader(), sistrip::TrackerSpecialHeader::feOverflowRegister(), sistrip::FEUNITS_PER_FED, dqm-mbProfile::format, sistrip::FEDBufferGenerator::generateBuffer(), sistrip::FEDBufferGenerator::getBufferFormat(), sistrip::FEDBufferGenerator::getDAQEventType(), sistrip::HEADER_TYPE_FULL_DEBUG, sistrip::HEADER_TYPE_INVALID, sistrip::TrackerSpecialHeader::headerType(), edm::EventBase::id(), sistrip::invalid32_, sistrip::invalid_, edm::isDebugEnabled(), edm::HandleBase::isValid(), crabWrapper::key, sistrip::FEDFEHeader::lengthInBytes(), mode_, sistrip::PACKET_CODE_ZERO_SUPPRESSED10, packetCode_, sistrip::TrackerSpecialHeader::print(), sistrip::FEDFEHeader::print(), sistrip::READOUT_MODE_PREMIX_RAW, sistrip::READOUT_MODE_SCOPE, sistrip::READOUT_MODE_ZERO_SUPPRESSED, sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE10, sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE10_CMOVERRIDE, sistrip::TrackerSpecialHeader::readoutMode(), sistrip::FEDBufferGenerator::setFEUnitEnables(), sistrip::FEDBufferGenerator::setHeaderType(), sistrip::FEDBufferGenerator::setL1ID(), sistrip::FEDBufferGenerator::setReadoutMode(), FEDRawData::size(), contentValuesCheck::ss, str, digitizers_cfi::strip, STRIP(), sistrip::STRIPS_PER_FEDCH, sistrip::FEDBufferGenerator::trackerSpecialHeader(), useFedKey_, relativeConstraints::value, and warnings_.

101  {
102  const bool dataIsAlready8BitTruncated =
103  zeroSuppressed &&
104  (!(
105  //for special mode premix raw, data is zero-suppressed but not converted to 8 bit
107  // the same goes for 10bit ZS modes
111  try {
112  //set the L1ID to use in the buffers
113  bufferGenerator_.setL1ID(0xFFFFFF & event.id().event());
114  auto fed_ids = cabling->fedIds();
115 
116  //copy header if valid rawbuffers handle
117  if (rawbuffers.isValid()) {
118  if (edm::isDebugEnabled()) {
119  edm::LogWarning("DigiToRaw") << "[sistrip::DigiToRaw::createFedBuffers_]"
120  << " Valid raw buffers, getting headers from them..."
121  << " Number of feds: " << fed_ids.size() << " between " << *(fed_ids.begin())
122  << " and " << *(fed_ids.end());
123  }
124 
125  const FEDRawDataCollection& rawDataCollection = *rawbuffers;
126 
127  for (auto ifed = fed_ids.begin(); ifed != fed_ids.end(); ++ifed) {
128  const FEDRawData& rawfedData = rawDataCollection.FEDData(*ifed);
129 
130  if (edm::isDebugEnabled()) {
131  edm::LogWarning("DigiToRaw") << "[sistrip::DigiToRaw::createFedBuffers_]"
132  << "Fed " << *ifed << " : size of buffer = " << rawfedData.size();
133  }
134 
135  //need to construct full object to copy full header
136  std::unique_ptr<const sistrip::FEDBuffer> fedbuffer;
137  if (rawfedData.size() == 0) {
138  warnings_.add("Invalid raw data for FED, skipping", (boost::format("id %1%") % *ifed).str());
139  } else {
140  try {
141  fedbuffer.reset(new sistrip::FEDBuffer(rawfedData.data(), rawfedData.size(), true));
142  } catch (const cms::Exception& e) {
143  edm::LogWarning("DigiToRaw") << "[sistrip::DigiToRaw::createFedBuffers_]"
144  << " Could not construct FEDBuffer for FED " << *ifed << std::endl;
145  }
146 
147  if (fedbuffer->headerType() == sistrip::HEADER_TYPE_INVALID) {
148  warnings_.add("Invalid header type for FED, skipping", (boost::format("id %1%") % *ifed).str());
149  continue;
150  }
151 
152  if (edm::isDebugEnabled()) {
153  edm::LogWarning("DigiToRaw") << "[sistrip::DigiToRaw::createFedBuffers_]"
154  << " Original header type: " << fedbuffer->headerType();
155  }
156 
158  //fedbuffer->headerType());
159  bufferGenerator_.daqHeader() = fedbuffer->daqHeader();
160  bufferGenerator_.daqTrailer() = fedbuffer->daqTrailer();
161 
162  bufferGenerator_.trackerSpecialHeader() = fedbuffer->trackerSpecialHeader();
164 
165  if (edm::isDebugEnabled()) {
166  std::ostringstream debugStream;
167  if (ifed == fed_ids.begin()) {
169  std::cout << std::endl;
170  }
172  edm::LogWarning("DigiToRaw")
173  << "[sistrip::DigiToRaw::createFedBuffers_]"
174  << " Tracker special header apveAddress: "
175  << static_cast<int>(bufferGenerator_.trackerSpecialHeader().apveAddress())
176  << " - event type = " << bufferGenerator_.getDAQEventType()
177  << " - buffer format = " << bufferGenerator_.getBufferFormat() << "\n"
178  << " - SpecialHeader bufferformat " << bufferGenerator_.trackerSpecialHeader().bufferFormat()
179  << " - headertype " << bufferGenerator_.trackerSpecialHeader().headerType() << " - readoutmode "
180  << bufferGenerator_.trackerSpecialHeader().readoutMode() << " - apvaddrregister " << std::hex
182  << " - feenabledregister " << std::hex
184  << " - feoverflowregister " << std::hex
186  << " - statusregister " << bufferGenerator_.trackerSpecialHeader().fedStatusRegister() << "\n"
187  << " SpecialHeader: " << debugStream.str();
188  }
189 
190  std::unique_ptr<FEDFEHeader> tempFEHeader(fedbuffer->feHeader()->clone());
191  FEDFullDebugHeader* fedFeHeader = dynamic_cast<FEDFullDebugHeader*>(tempFEHeader.get());
192  if (edm::isDebugEnabled()) {
193  std::ostringstream debugStream;
194  if (ifed == fed_ids.begin()) {
195  std::cout << "FEHeader before transfer: " << std::endl;
196  fedFeHeader->print(std::cout);
197  std::cout << std::endl;
198  }
199  fedFeHeader->print(debugStream);
200  edm::LogWarning("DigiToRaw") << "[sistrip::DigiToRaw::createFedBuffers_]"
201  << " length of original feHeader: " << fedFeHeader->lengthInBytes() << "\n"
202  << debugStream.str();
203  }
204  //status registers
205  (bufferGenerator_.feHeader()).setBEStatusRegister(fedFeHeader->beStatusRegister());
206  (bufferGenerator_.feHeader()).setDAQRegister2(fedFeHeader->daqRegister2());
207  (bufferGenerator_.feHeader()).setDAQRegister(fedFeHeader->daqRegister());
208  for (uint8_t iFE = 1; iFE < 6; iFE++) {
210  .set32BitReservedRegister(iFE, fedFeHeader->get32BitWordFrom(fedFeHeader->feWord(iFE) + 10));
211  }
212 
213  std::vector<bool> feEnabledVec;
214  feEnabledVec.resize(FEUNITS_PER_FED, true);
215  for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
216  feEnabledVec[iFE] = fedbuffer->trackerSpecialHeader().feEnabled(iFE);
217  (bufferGenerator_.feHeader()).setFEUnitMajorityAddress(iFE, fedFeHeader->feUnitMajorityAddress(iFE));
218  for (uint8_t iFEUnitChannel = 0; iFEUnitChannel < FEDCH_PER_FEUNIT; iFEUnitChannel++) {
220  .setChannelStatus(iFE, iFEUnitChannel, fedFeHeader->getChannelStatus(iFE, iFEUnitChannel));
221  } //loop on channels
222  } //loop on fe units
223  bufferGenerator_.setFEUnitEnables(feEnabledVec);
224 
225  if (edm::isDebugEnabled()) {
226  std::ostringstream debugStream;
227  if (ifed == fed_ids.begin()) {
228  std::cout << "\nFEHeader after transfer: " << std::endl;
230  std::cout << std::endl;
231  }
232  bufferGenerator_.feHeader().print(debugStream);
233  edm::LogWarning("DigiToRaw")
234  << "[sistrip::DigiToRaw::createFedBuffers_]"
235  << " length of feHeader: " << bufferGenerator_.feHeader().lengthInBytes() << "\n"
236  << debugStream.str();
237  }
238  auto conns = cabling->fedConnections(*ifed);
239 
240  FEDStripData fedData(dataIsAlready8BitTruncated);
241 
242  for (auto iconn = conns.begin(); iconn != conns.end(); iconn++) {
243  // Determine FED key from cabling
244  uint32_t fed_key = ((iconn->fedId() & sistrip::invalid_) << 16) | (iconn->fedCh() & sistrip::invalid_);
245 
246  // Determine whether DetId or FED key should be used to index digi containers
247  uint32_t key = (useFedKey_ || mode_ == READOUT_MODE_SCOPE) ? fed_key : iconn->detId();
248 
249  // Check key is non-zero and valid
250  if (!key || (key == sistrip::invalid32_)) {
251  continue;
252  }
253 
254  // Determine APV pair number (needed only when using DetId)
255  uint16_t ipair = (useFedKey_ || mode_ == READOUT_MODE_SCOPE) ? 0 : iconn->apvPairNumber();
256 
257  FEDStripData::ChannelData& chanData = fedData[iconn->fedCh()];
258 
259  // Find digis for DetID in collection
260  if (!collection.isValid()) {
261  if (edm::isDebugEnabled()) {
262  edm::LogWarning("DigiToRaw") << "[DigiToRaw::createFedBuffers] "
263  << "digis collection is not valid...";
264  }
265  break;
266  }
267  typename std::vector<edm::DetSet<Digi_t> >::const_iterator digis = collection->find(key);
268  if (digis == collection->end()) {
269  continue;
270  }
271 
272  typename edm::DetSet<Digi_t>::const_iterator idigi, digis_begin(digis->data.begin());
273  for (idigi = digis_begin; idigi != digis->data.end(); idigi++) {
274  if (STRIP(idigi, digis_begin) < ipair * 256 || STRIP(idigi, digis_begin) > ipair * 256 + 255) {
275  continue;
276  }
277  const unsigned short strip = STRIP(idigi, digis_begin) % 256;
278 
279  if (strip >= STRIPS_PER_FEDCH) {
280  if (edm::isDebugEnabled()) {
281  std::stringstream ss;
282  ss << "[sistrip::DigiToRaw::createFedBuffers]"
283  << " strip >= strips_per_fedCh";
284  edm::LogWarning("DigiToRaw") << ss.str();
285  }
286  continue;
287  }
288 
289  // check if value already exists
290  if (edm::isDebugEnabled()) {
291  const uint16_t value = 0; //chanData[strip];
292  if (value && value != (*idigi).adc()) {
293  std::stringstream ss;
294  ss << "[sistrip::DigiToRaw::createFedBuffers]"
295  << " Incompatible ADC values in buffer!"
296  << " FedId/FedCh: " << *ifed << "/" << iconn->fedCh()
297  << " DetStrip: " << STRIP(idigi, digis_begin) << " FedChStrip: " << strip
298  << " AdcValue: " << (*idigi).adc() << " RawData[" << strip << "]: " << value;
299  edm::LogWarning("DigiToRaw") << ss.str();
300  }
301  }
302 
303  // Add digi to buffer
304  chanData[strip] = (*idigi).adc();
305  }
306  }
307  // if ((*idigi).strip() >= (ipair+1)*256) break;
308 
309  if (edm::isDebugEnabled()) {
310  edm::LogWarning("DigiToRaw") << "DigiToRaw::createFedBuffers] "
311  << "Almost at the end...";
312  }
313  //create the buffer
314  FEDRawData& fedrawdata = buffers->FEDData(*ifed);
315  bufferGenerator_.generateBuffer(&fedrawdata, fedData, *ifed, packetCode_);
316 
317  if (edm::isDebugEnabled()) {
318  std::ostringstream debugStream;
319  bufferGenerator_.feHeader().print(debugStream);
320  edm::LogWarning("DigiToRaw")
321  << "[sistrip::DigiToRaw::createFedBuffers_]"
322  << " length of final feHeader: " << bufferGenerator_.feHeader().lengthInBytes() << "\n"
323  << debugStream.str();
324  }
325  }
326  } //loop on fedids
327  if (edm::isDebugEnabled()) {
328  edm::LogWarning("DigiToRaw") << "[sistrip::DigiToRaw::createFedBuffers_]"
329  << "end of first loop on feds";
330  }
331 
332  } //end of workflow for copying header, below is workflow without copying header
333  else {
334  if (edm::isDebugEnabled()) {
335  edm::LogWarning("DigiToRaw") << "[sistrip::DigiToRaw::createFedBuffers_]"
336  << "Now getting the digis..."
337  << " Number of feds: " << fed_ids.size() << " between " << *(fed_ids.begin())
338  << " and " << *(fed_ids.end());
339  }
340 
341  for (auto ifed = fed_ids.begin(); ifed != fed_ids.end(); ++ifed) {
342  auto conns = cabling->fedConnections(*ifed);
343 
344  FEDStripData fedData(dataIsAlready8BitTruncated);
345 
346  for (auto iconn = conns.begin(); iconn != conns.end(); iconn++) {
347  // Determine FED key from cabling
348  uint32_t fed_key = ((iconn->fedId() & sistrip::invalid_) << 16) | (iconn->fedCh() & sistrip::invalid_);
349 
350  // Determine whether DetId or FED key should be used to index digi containers
351  uint32_t key = (useFedKey_ || mode_ == READOUT_MODE_SCOPE) ? fed_key : iconn->detId();
352 
353  // Check key is non-zero and valid
354  if (!key || (key == sistrip::invalid32_)) {
355  continue;
356  }
357 
358  // Determine APV pair number (needed only when using DetId)
359  uint16_t ipair = (useFedKey_ || mode_ == READOUT_MODE_SCOPE) ? 0 : iconn->apvPairNumber();
360 
361  FEDStripData::ChannelData& chanData = fedData[iconn->fedCh()];
362 
363  // Find digis for DetID in collection
364  if (!collection.isValid()) {
365  if (edm::isDebugEnabled()) {
366  edm::LogWarning("DigiToRaw") << "[DigiToRaw::createFedBuffers] "
367  << "digis collection is not valid...";
368  }
369  break;
370  }
371  typename std::vector<edm::DetSet<Digi_t> >::const_iterator digis = collection->find(key);
372  if (digis == collection->end()) {
373  continue;
374  }
375 
376  typename edm::DetSet<Digi_t>::const_iterator idigi, digis_begin(digis->data.begin());
377  for (idigi = digis_begin; idigi != digis->data.end(); idigi++) {
378  if (STRIP(idigi, digis_begin) < ipair * 256 || STRIP(idigi, digis_begin) > ipair * 256 + 255) {
379  continue;
380  }
381  const unsigned short strip = STRIP(idigi, digis_begin) % 256;
382 
383  if (strip >= STRIPS_PER_FEDCH) {
384  if (edm::isDebugEnabled()) {
385  std::stringstream ss;
386  ss << "[sistrip::DigiToRaw::createFedBuffers]"
387  << " strip >= strips_per_fedCh";
388  edm::LogWarning("DigiToRaw") << ss.str();
389  }
390  continue;
391  }
392 
393  // check if value already exists
394  if (edm::isDebugEnabled()) {
395  const uint16_t value = 0; //chanData[strip];
396  if (value && value != (*idigi).adc()) {
397  std::stringstream ss;
398  ss << "[sistrip::DigiToRaw::createFedBuffers]"
399  << " Incompatible ADC values in buffer!"
400  << " FedId/FedCh: " << *ifed << "/" << iconn->fedCh()
401  << " DetStrip: " << STRIP(idigi, digis_begin) << " FedChStrip: " << strip
402  << " AdcValue: " << (*idigi).adc() << " RawData[" << strip << "]: " << value;
403  edm::LogWarning("DigiToRaw") << ss.str();
404  }
405  }
406 
407  // Add digi to buffer
408  chanData[strip] = (*idigi).adc();
409  }
410  }
411  // if ((*idigi).strip() >= (ipair+1)*256) break;
412 
413  if (edm::isDebugEnabled()) {
414  edm::LogWarning("DigiToRaw") << "DigiToRaw::createFedBuffers] "
415  << "Almost at the end...";
416  }
417  //create the buffer
418  FEDRawData& fedrawdata = buffers->FEDData(*ifed);
419  bufferGenerator_.generateBuffer(&fedrawdata, fedData, *ifed, packetCode_);
420 
421  if (edm::isDebugEnabled()) {
422  std::ostringstream debugStream;
423  bufferGenerator_.feHeader().print(debugStream);
424  edm::LogWarning("DigiToRaw") << "[sistrip::DigiToRaw::createFedBuffers_]"
425  << " length of final feHeader: " << bufferGenerator_.feHeader().lengthInBytes()
426  << "\n"
427  << debugStream.str();
428  }
429  } //loop on feds
430  } //end if-else for copying header
431  } //try
432  catch (const std::exception& e) {
433  if (edm::isDebugEnabled()) {
434  edm::LogWarning("DigiToRaw") << "DigiToRaw::createFedBuffers] "
435  << "Exception caught : " << e.what();
436  }
437  }
438  }
EventNumber_t event() const
Definition: EventID.h:40
bool isDebugEnabled()
FEDBufferGenerator & setReadoutMode(const FEDReadoutMode newReadoutMode)
static const uint32_t invalid32_
Definition: Constants.h:15
FEDStatusRegister fedStatusRegister() const
virtual void print(std::ostream &os) const =0
WarningSummary warnings_
TrackerSpecialHeader & trackerSpecialHeader()
FEDBufferFormat getBufferFormat() const
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
static const uint8_t PACKET_CODE_ZERO_SUPPRESSED10
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
FEDBufferGenerator & setFEUnitEnables(const std::vector< bool > &feUnitsEnabled)
static const uint16_t FEUNITS_PER_FED
FedsConstIterRange fedIds() const
void generateBuffer(FEDRawData *rawDataObject, const FEDStripData &data, uint16_t sourceID, uint8_t packetCode) const
Definition: value.py:1
bool isValid() const
Definition: HandleBase.h:70
void add(const std::string &message, const std::string &details="")
FEDReadoutMode mode_
void print(std::ostream &os) const
static const uint16_t STRIPS_PER_FEDCH
FEDBufferGenerator & setHeaderType(const FEDHeaderType newHeaderType)
FEDBufferGenerator & setL1ID(const uint32_t newL1ID)
static const uint16_t FEDCH_PER_FEUNIT
static const uint16_t invalid_
Definition: Constants.h:16
ConnsConstIterRange fedConnections(uint16_t fed_id) const
virtual size_t lengthInBytes() const =0
edm::EventID id() const
Definition: EventBase.h:59
collection_type data
Definition: DetSet.h:81
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
uint16_t STRIP(const edm::DetSet< SiStripDigi >::const_iterator &it, const edm::DetSet< SiStripDigi >::const_iterator &begin) const
FEDDAQEventType getDAQEventType() const
collection_type::const_iterator const_iterator
Definition: DetSet.h:32
#define str(s)
FEDBufferGenerator bufferGenerator_
void sistrip::DigiToRaw::fedReadoutMode ( FEDReadoutMode  mode)
inline
void sistrip::DigiToRaw::printWarningSummary ( ) const
inline

Definition at line 58 of file SiStripDigiToRaw.h.

References begin, and apvshotsanalyzer_cfi::zeroSuppressed.

Referenced by sistrip::DigiToRawModule::endStream().

void printSummary() const
WarningSummary warnings_
uint16_t sistrip::DigiToRaw::STRIP ( const edm::DetSet< SiStripDigi >::const_iterator &  it,
const edm::DetSet< SiStripDigi >::const_iterator &  begin 
) const
inlineprivate

Definition at line 440 of file SiStripDigiToRaw.cc.

Referenced by createFedBuffers_().

441  {
442  return it->strip();
443  }
uint16_t sistrip::DigiToRaw::STRIP ( const edm::DetSet< SiStripRawDigi >::const_iterator &  it,
const edm::DetSet< SiStripRawDigi >::const_iterator &  begin 
) const
inlineprivate

Definition at line 444 of file SiStripDigiToRaw.cc.

References begin.

445  {
446  return it - begin;
447  }
#define begin
Definition: vmac.h:32

Member Data Documentation

FEDBufferGenerator sistrip::DigiToRaw::bufferGenerator_
private

Definition at line 84 of file SiStripDigiToRaw.h.

Referenced by createFedBuffers_(), and DigiToRaw().

FEDReadoutMode sistrip::DigiToRaw::mode_
private

Definition at line 81 of file SiStripDigiToRaw.h.

Referenced by createFedBuffers_(), and DigiToRaw().

uint8_t sistrip::DigiToRaw::packetCode_
private

Definition at line 82 of file SiStripDigiToRaw.h.

Referenced by createFedBuffers_().

bool sistrip::DigiToRaw::useFedKey_
private

Definition at line 83 of file SiStripDigiToRaw.h.

Referenced by createFedBuffers_().

WarningSummary sistrip::DigiToRaw::warnings_
private

Definition at line 86 of file SiStripDigiToRaw.h.

Referenced by createFedBuffers_().