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().

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

Definition at line 41 of file SiStripDigiToRaw.cc.

References edm::isDebugEnabled(), and LogDebug.

41  {
42  if ( edm::isDebugEnabled() ) {
43  LogDebug("DigiToRaw")
44  << "[sistrip::DigiToRaw::~DigiToRaw]"
45  << " Destructing object...";
46  }
47  }
#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 58 of file SiStripDigiToRaw.cc.

References universalConfigTemplate::collection, and createFedBuffers_().

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

61  {
62  createFedBuffers_(event, cabling, collection, buffers, true);
63  }
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 65 of file SiStripDigiToRaw.cc.

References universalConfigTemplate::collection, and createFedBuffers_().

68  {
69  createFedBuffers_(event, cabling, collection, buffers, false);
70  }
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 73 of file SiStripDigiToRaw.cc.

References universalConfigTemplate::collection, and createFedBuffers_().

77  {
78  createFedBuffers_(event, cabling, rawbuffers, collection, buffers, true);
79  }
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 81 of file SiStripDigiToRaw.cc.

References universalConfigTemplate::collection, and createFedBuffers_().

85  {
86  createFedBuffers_(event, cabling, rawbuffers, collection, buffers, false);
87  }
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 93 of file SiStripDigiToRaw.cc.

References universalConfigTemplate::collection.

Referenced by createFedBuffers().

97  {
98 
100  //CAMM initialise to some dummy empty buffers??? Or OK like this ?
101  createFedBuffers_(event,cabling,rawbuffers,collection,buffers,zeroSuppressed);
102 
103  }
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 106 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, cmsPerfStripChart::format, sistrip::FEDBufferGenerator::generateBuffer(), sistrip::FEDBufferGenerator::getBufferFormat(), sistrip::FEDBufferGenerator::getDAQEventType(), sistrip::HEADER_TYPE_FULL_DEBUG, 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(), str, digitizers_cfi::strip, STRIP(), sistrip::STRIPS_PER_FEDCH, sistrip::FEDBufferGenerator::trackerSpecialHeader(), useFedKey_, relativeConstraints::value, and warnings_.

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

Definition at line 60 of file SiStripDigiToRaw.h.

References begin.

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

Referenced by createFedBuffers_().

443 {return it->strip();}
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.

444 {return it-begin;}
#define begin
Definition: vmac.h:32

Member Data Documentation

FEDBufferGenerator sistrip::DigiToRaw::bufferGenerator_
private

Definition at line 87 of file SiStripDigiToRaw.h.

Referenced by createFedBuffers_(), and DigiToRaw().

FEDReadoutMode sistrip::DigiToRaw::mode_
private

Definition at line 84 of file SiStripDigiToRaw.h.

Referenced by createFedBuffers_(), and DigiToRaw().

uint8_t sistrip::DigiToRaw::packetCode_
private

Definition at line 85 of file SiStripDigiToRaw.h.

Referenced by createFedBuffers_().

bool sistrip::DigiToRaw::useFedKey_
private

Definition at line 86 of file SiStripDigiToRaw.h.

Referenced by createFedBuffers_().

WarningSummary sistrip::DigiToRaw::warnings_
private

Definition at line 89 of file SiStripDigiToRaw.h.

Referenced by createFedBuffers_().