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::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::auto_ptr< FEDRawDataCollection > &buffers)
 
void createFedBuffers (edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< edm::DetSetVector< SiStripRawDigi > > &digis, std::auto_ptr< FEDRawDataCollection > &buffers)
 
void createFedBuffers (edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< FEDRawDataCollection > &rawbuffers, edm::Handle< edm::DetSetVector< SiStripDigi > > &digis, std::auto_ptr< FEDRawDataCollection > &buffers)
 
void createFedBuffers (edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< FEDRawDataCollection > &rawbuffers, edm::Handle< edm::DetSetVector< SiStripRawDigi > > &digis, std::auto_ptr< FEDRawDataCollection > &buffers)
 
 DigiToRaw (FEDReadoutMode, bool use_fed_key)
 
void fedReadoutMode (FEDReadoutMode mode)
 
 ~DigiToRaw ()
 

Private Member Functions

template<class Digi_t >
void createFedBuffers_ (edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< edm::DetSetVector< Digi_t > > &digis, std::auto_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::auto_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_
 
bool useFedKey_
 

Detailed Description

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

Definition at line 28 of file SiStripDigiToRaw.h.

Constructor & Destructor Documentation

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

Definition at line 22 of file SiStripDigiToRaw.cc.

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

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

Definition at line 38 of file SiStripDigiToRaw.cc.

References edm::isDebugEnabled(), and LogDebug.

38  {
39  if ( edm::isDebugEnabled() ) {
40  LogDebug("DigiToRaw")
41  << "[sistrip::DigiToRaw::~DigiToRaw]"
42  << " Destructing object...";
43  }
44  }
#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::auto_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::auto_ptr< FEDRawDataCollection > &buffers, bool zeroSuppressed)
void sistrip::DigiToRaw::createFedBuffers ( edm::Event event,
edm::ESHandle< SiStripFedCabling > &  cabling,
edm::Handle< edm::DetSetVector< SiStripRawDigi > > &  digis,
std::auto_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::auto_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::auto_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::auto_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::auto_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::auto_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::auto_ptr< FEDRawDataCollection > &  buffers,
bool  zeroSuppressed 
)
private

Definition at line 90 of file SiStripDigiToRaw.cc.

References universalConfigTemplate::collection.

Referenced by createFedBuffers().

94  {
95 
97  //CAMM initialise to some dummy empty buffers??? Or OK like this ?
98  createFedBuffers_(event,cabling,rawbuffers,collection,buffers,zeroSuppressed);
99 
100  }
void createFedBuffers_(edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< edm::DetSetVector< Digi_t > > &digis, std::auto_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::auto_ptr< FEDRawDataCollection > &  buffers,
bool  zeroSuppressed 
)
private

Definition at line 103 of file SiStripDigiToRaw.cc.

References 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, alignCSCRings::e, edm::EventID::event(), cppFunctionSkipper::exception, sistrip::FEDCH_PER_FEUNIT, FEDRawDataCollection::FEDData(), sistrip::TrackerSpecialHeader::fedStatusRegister(), sistrip::TrackerSpecialHeader::feEnableRegister(), sistrip::FEDBufferGenerator::feHeader(), sistrip::TrackerSpecialHeader::feOverflowRegister(), sistrip::FEUNITS_PER_FED, 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(), relval_steps::key, sistrip::FEDFEHeader::lengthInBytes(), mode_, sistrip::TrackerSpecialHeader::print(), sistrip::FEDFEHeader::print(), sistrip::READOUT_MODE_PREMIX_RAW, sistrip::READOUT_MODE_SCOPE, sistrip::TrackerSpecialHeader::readoutMode(), sistrip::FEDBufferGenerator::setFEUnitEnables(), sistrip::FEDBufferGenerator::setHeaderType(), sistrip::FEDBufferGenerator::setL1ID(), sistrip::FEDBufferGenerator::setReadoutMode(), FEDRawData::size(), contentValuesCheck::ss, STRIP(), sistrip::STRIPS_PER_FEDCH, sistrip::FEDBufferGenerator::trackerSpecialHeader(), useFedKey_, and relativeConstraints::value.

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

Definition at line 436 of file SiStripDigiToRaw.cc.

Referenced by createFedBuffers_().

436 {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 437 of file SiStripDigiToRaw.cc.

References begin.

437 {return it-begin;}
#define begin
Definition: vmac.h:30

Member Data Documentation

FEDBufferGenerator sistrip::DigiToRaw::bufferGenerator_
private

Definition at line 83 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().

bool sistrip::DigiToRaw::useFedKey_
private

Definition at line 82 of file SiStripDigiToRaw.h.

Referenced by createFedBuffers_().