25 useFedKey_(useFedKey),
30 <<
"[sistrip::DigiToRaw::DigiToRaw]" 31 <<
" Constructing object...";
41 <<
"[sistrip::DigiToRaw::~DigiToRaw]" 42 <<
" Destructing object...";
58 std::unique_ptr<FEDRawDataCollection>& buffers ) {
65 std::unique_ptr<FEDRawDataCollection>& buffers ) {
74 std::unique_ptr<FEDRawDataCollection>& buffers ) {
82 std::unique_ptr<FEDRawDataCollection>& buffers ) {
89 template<
class Digi_t>
93 std::unique_ptr<FEDRawDataCollection>& buffers,
94 bool zeroSuppressed) {
102 template<
class Digi_t>
107 std::unique_ptr<FEDRawDataCollection>& buffers,
108 bool zeroSuppressed) {
113 auto fed_ids = cabling->
fedIds();
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());
127 for (
auto ifed = fed_ids.begin(); ifed != fed_ids.end(); ++ifed ) {
132 <<
"[sistrip::DigiToRaw::createFedBuffers_]" 133 <<
"Fed " << *ifed <<
" : size of buffer = " << rawfedData.
size();
137 std::unique_ptr<const sistrip::FEDBuffer> fedbuffer;
143 edm::LogWarning(
"DigiToRaw") <<
"[sistrip::DigiToRaw::createFedBuffers_]" 144 <<
" Invalid raw data, cannot get buffer..." 150 <<
"[sistrip::DigiToRaw::createFedBuffers_]" 151 <<
" Original header type: " << fedbuffer->headerType();
163 std::ostringstream debugStream;
167 <<
"[sistrip::DigiToRaw::createFedBuffers_]" 178 <<
" SpecialHeader: " << debugStream.str();
181 std::unique_ptr<FEDFEHeader> tempFEHeader(fedbuffer->feHeader()->clone());
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);
188 <<
"[sistrip::DigiToRaw::createFedBuffers_]" 189 <<
" length of original feHeader: " << fedFeHeader->lengthInBytes() <<
"\n" 190 << debugStream.str();
196 for(uint8_t iFE=1; iFE<6; iFE++) {
197 (
bufferGenerator_.
feHeader()).set32BitReservedRegister(iFE,fedFeHeader->get32BitWordFrom(fedFeHeader->feWord(iFE)+10));
200 std::vector<bool> feEnabledVec;
203 feEnabledVec[iFE]=fedbuffer->trackerSpecialHeader().feEnabled(iFE);
205 for (uint8_t iFEUnitChannel = 0; iFEUnitChannel <
FEDCH_PER_FEUNIT; iFEUnitChannel++) {
206 (
bufferGenerator_.
feHeader()).setChannelStatus(iFE,iFEUnitChannel,fedFeHeader->getChannelStatus(iFE,iFEUnitChannel));
212 std::ostringstream debugStream;
216 <<
"[sistrip::DigiToRaw::createFedBuffers_]" 218 << debugStream.str();
228 for (
auto iconn = conns.begin() ; iconn != conns.end(); iconn++ ) {
248 <<
"[DigiToRaw::createFedBuffers] " 249 <<
"digis collection is not valid...";
253 typename std::vector< edm::DetSet<Digi_t> >::const_iterator digis =
collection->find( key );
257 for ( idigi = digis_begin; idigi != digis->
data.end(); idigi++ ) {
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;
265 std::stringstream ss;
266 ss <<
"[sistrip::DigiToRaw::createFedBuffers]" 267 <<
" strip >= strips_per_fedCh";
275 const uint16_t
value = 0;
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;
290 chanData[
strip] = (*idigi).adc();
297 <<
"DigiToRaw::createFedBuffers] " 298 <<
"Almost at the end...";
301 FEDRawData& fedrawdata = buffers->FEDData( *ifed );
305 std::ostringstream debugStream;
308 <<
"[sistrip::DigiToRaw::createFedBuffers_]" 310 << debugStream.str();
315 <<
"[sistrip::DigiToRaw::createFedBuffers_]" 316 <<
"end of first loop on feds";
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());
329 for (
auto ifed = fed_ids.begin(); ifed != fed_ids.end(); ++ifed ) {
339 for (
auto iconn = conns.begin() ; iconn != conns.end(); iconn++ ) {
359 <<
"[DigiToRaw::createFedBuffers] " 360 <<
"digis collection is not valid...";
364 typename std::vector< edm::DetSet<Digi_t> >::const_iterator digis =
collection->find( key );
368 for ( idigi = digis_begin; idigi != digis->
data.end(); idigi++ ) {
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;
376 std::stringstream ss;
377 ss <<
"[sistrip::DigiToRaw::createFedBuffers]" 378 <<
" strip >= strips_per_fedCh";
386 const uint16_t
value = 0;
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;
401 chanData[
strip] = (*idigi).adc();
408 <<
"DigiToRaw::createFedBuffers] " 409 <<
"Almost at the end...";
412 FEDRawData& fedrawdata = buffers->FEDData( *ifed );
416 std::ostringstream debugStream;
419 <<
"[sistrip::DigiToRaw::createFedBuffers_]" 421 << debugStream.str();
429 <<
"DigiToRaw::createFedBuffers] " 430 <<
"Exception caught : " << e.what();
EventNumber_t event() const
void generateBuffer(FEDRawData *rawDataObject, const FEDStripData &data, const uint16_t sourceID) const
FEDBufferGenerator & setReadoutMode(const FEDReadoutMode newReadoutMode)
DigiToRaw(FEDReadoutMode, bool use_fed_key)
static const uint32_t invalid32_
TrackerSpecialHeader & trackerSpecialHeader()
FEDBufferFormat getBufferFormat() const
size_t size() const
Lenght of the data buffer in bytes.
FEDDAQTrailer & daqTrailer()
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 createFedBuffers(edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< edm::DetSetVector< SiStripDigi > > &digis, std::unique_ptr< FEDRawDataCollection > &buffers)
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_
ConnsConstIterRange fedConnections(uint16_t fed_id) const
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
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
FEDBufferGenerator bufferGenerator_
FEDDAQHeader & daqHeader()
void createFedBuffers_(edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< edm::DetSetVector< Digi_t > > &digis, std::unique_ptr< FEDRawDataCollection > &buffers, bool zeroSuppressed)