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 30 of file SiStripDigiToRaw.h.

Constructor & Destructor Documentation

◆ DigiToRaw()

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

Definition at line 24 of file SiStripDigiToRaw.cc.

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

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

◆ ~DigiToRaw()

sistrip::DigiToRaw::~DigiToRaw ( )

Definition at line 39 of file SiStripDigiToRaw.cc.

References edm::isDebugEnabled(), and LogDebug.

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

Member Function Documentation

◆ createFedBuffers() [1/4]

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 55 of file SiStripDigiToRaw.cc.

References universalConfigTemplate::collection, and createFedBuffers_().

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

58  {
59  createFedBuffers_(event, cabling, collection, buffers, true);
60  }
void createFedBuffers_(edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< edm::DetSetVector< Digi_t > > &digis, std::unique_ptr< FEDRawDataCollection > &buffers, bool zeroSuppressed)
Definition: event.py:1

◆ createFedBuffers() [2/4]

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 62 of file SiStripDigiToRaw.cc.

References universalConfigTemplate::collection, and createFedBuffers_().

65  {
66  createFedBuffers_(event, cabling, collection, buffers, false);
67  }
void createFedBuffers_(edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< edm::DetSetVector< Digi_t > > &digis, std::unique_ptr< FEDRawDataCollection > &buffers, bool zeroSuppressed)
Definition: event.py:1

◆ createFedBuffers() [3/4]

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 70 of file SiStripDigiToRaw.cc.

References universalConfigTemplate::collection, and createFedBuffers_().

74  {
75  createFedBuffers_(event, cabling, rawbuffers, collection, buffers, true);
76  }
void createFedBuffers_(edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< edm::DetSetVector< Digi_t > > &digis, std::unique_ptr< FEDRawDataCollection > &buffers, bool zeroSuppressed)
Definition: event.py:1

◆ createFedBuffers() [4/4]

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 78 of file SiStripDigiToRaw.cc.

References universalConfigTemplate::collection, and createFedBuffers_().

82  {
83  createFedBuffers_(event, cabling, rawbuffers, collection, buffers, false);
84  }
void createFedBuffers_(edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< edm::DetSetVector< Digi_t > > &digis, std::unique_ptr< FEDRawDataCollection > &buffers, bool zeroSuppressed)
Definition: event.py:1

◆ createFedBuffers_() [1/2]

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 87 of file SiStripDigiToRaw.cc.

References universalConfigTemplate::collection, and apvshotsanalyzer_cfi::zeroSuppressed.

Referenced by createFedBuffers().

91  {
93  //CAMM initialise to some dummy empty buffers??? Or OK like this ?
94  createFedBuffers_(event, cabling, rawbuffers, collection, buffers, zeroSuppressed);
95  }
void createFedBuffers_(edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< edm::DetSetVector< Digi_t > > &digis, std::unique_ptr< FEDRawDataCollection > &buffers, bool zeroSuppressed)
Definition: event.py:1

◆ createFedBuffers_() [2/2]

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 98 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(), edm::DetSet< T >::data, MillePedeFileConverter_cfg::e, 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(), sistrip::invalid32_, sistrip::invalid_, edm::isDebugEnabled(), edm::HandleBase::isValid(), submitPVResolutionJobs::key, sistrip::FEDFEHeader::lengthInBytes(), mode_, sistrip::PACKET_CODE_ZERO_SUPPRESSED10, packetCode_, sistrip::preconstructCheckFEDBuffer(), 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, nano_mu_digi_cff::strip, STRIP(), sistrip::STRIPS_PER_FEDCH, sistrip::SUCCESS, sistrip::FEDBufferGenerator::trackerSpecialHeader(), useFedKey_, relativeConstraints::value, warnings_, and apvshotsanalyzer_cfi::zeroSuppressed.

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

◆ fedReadoutMode()

void sistrip::DigiToRaw::fedReadoutMode ( FEDReadoutMode  mode)
inline

◆ printWarningSummary()

void sistrip::DigiToRaw::printWarningSummary ( ) const
inline

Definition at line 59 of file SiStripDigiToRaw.h.

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

WarningSummary warnings_

◆ STRIP() [1/2]

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

Definition at line 444 of file SiStripDigiToRaw.cc.

References ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it.

Referenced by createFedBuffers_().

445  {
446  return it->strip();
447  }

◆ STRIP() [2/2]

uint16_t sistrip::DigiToRaw::STRIP ( const edm::DetSet< SiStripRawDigi >::const_iterator &  it,
const edm::DetSet< SiStripRawDigi >::const_iterator &  begin 
) const
inlineprivate

Definition at line 448 of file SiStripDigiToRaw.cc.

References ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it.

449  {
450  return it - begin;
451  }

Member Data Documentation

◆ bufferGenerator_

FEDBufferGenerator sistrip::DigiToRaw::bufferGenerator_
private

Definition at line 85 of file SiStripDigiToRaw.h.

Referenced by createFedBuffers_(), and DigiToRaw().

◆ mode_

FEDReadoutMode sistrip::DigiToRaw::mode_
private

Definition at line 82 of file SiStripDigiToRaw.h.

Referenced by createFedBuffers_(), and DigiToRaw().

◆ packetCode_

uint8_t sistrip::DigiToRaw::packetCode_
private

Definition at line 83 of file SiStripDigiToRaw.h.

Referenced by createFedBuffers_().

◆ useFedKey_

bool sistrip::DigiToRaw::useFedKey_
private

Definition at line 84 of file SiStripDigiToRaw.h.

Referenced by createFedBuffers_().

◆ warnings_

WarningSummary sistrip::DigiToRaw::warnings_
private

Definition at line 87 of file SiStripDigiToRaw.h.

Referenced by createFedBuffers_().