16 #include <boost/format.hpp>
24 packetCode_(packetCode),
25 useFedKey_(useFedKey),
27 warnings_(
"DigiToRaw",
"[sistrip::DigiToRaw::createFedBuffers_]",
edm::
isDebugEnabled()) {
29 LogDebug(
"DigiToRaw") <<
"[sistrip::DigiToRaw::DigiToRaw]"
30 <<
" Constructing object...";
39 LogDebug(
"DigiToRaw") <<
"[sistrip::DigiToRaw::~DigiToRaw]"
40 <<
" Destructing object...";
56 std::unique_ptr<FEDRawDataCollection>& buffers) {
63 std::unique_ptr<FEDRawDataCollection>& buffers) {
72 std::unique_ptr<FEDRawDataCollection>& buffers) {
80 std::unique_ptr<FEDRawDataCollection>& buffers) {
84 template <
class Digi_t>
88 std::unique_ptr<FEDRawDataCollection>& buffers,
95 template <
class Digi_t>
100 std::unique_ptr<FEDRawDataCollection>& buffers,
102 const bool dataIsAlready8BitTruncated =
114 auto fed_ids = cabling->
fedIds();
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());
127 for (
auto ifed = fed_ids.begin(); ifed != fed_ids.end(); ++ifed) {
131 edm::LogWarning(
"DigiToRaw") <<
"[sistrip::DigiToRaw::createFedBuffers_]"
132 <<
"Fed " << *ifed <<
" : size of buffer = " << rawfedData.
size();
136 if (rawfedData.
size() == 0)
140 edm::LogWarning(
"DigiToRaw") <<
"[sistrip::DigiToRaw::createFedBuffers_]"
141 <<
" Could not construct FEDBuffer for FED " << *ifed << std::endl;
145 const auto st_chan = fedbuffer.findChannels();
147 edm::LogWarning(
"DigiToRaw") <<
"[sistrip::DigiToRaw::createFedBuffers_]"
148 <<
" Could not construct FEDBuffer for FED " << *ifed << std::endl;
156 edm::LogWarning(
"DigiToRaw") <<
"[sistrip::DigiToRaw::createFedBuffers_]"
157 <<
" Original header type: " << fedbuffer.headerType();
169 std::ostringstream debugStream;
170 if (ifed == fed_ids.begin()) {
176 <<
"[sistrip::DigiToRaw::createFedBuffers_]"
177 <<
" Tracker special header apveAddress: "
185 <<
" - feenabledregister " << std::hex
187 <<
" - feoverflowregister " << std::hex
190 <<
" SpecialHeader: " << debugStream.str();
193 std::unique_ptr<FEDFEHeader> tempFEHeader(fedbuffer.feHeader()->clone());
194 FEDFullDebugHeader* fedFeHeader = dynamic_cast<FEDFullDebugHeader*>(tempFEHeader.get());
196 std::ostringstream debugStream;
197 if (ifed == fed_ids.begin()) {
198 std::cout <<
"FEHeader before transfer: " << std::endl;
202 fedFeHeader->print(debugStream);
203 edm::LogWarning(
"DigiToRaw") <<
"[sistrip::DigiToRaw::createFedBuffers_]"
204 <<
" length of original feHeader: " << fedFeHeader->lengthInBytes() <<
"\n"
205 << debugStream.str();
211 for (uint8_t iFE = 1; iFE < 6; iFE++) {
213 .set32BitReservedRegister(iFE, fedFeHeader->get32BitWordFrom(fedFeHeader->feWord(iFE) + 10));
216 std::vector<bool> feEnabledVec;
219 feEnabledVec[iFE] = fedbuffer.trackerSpecialHeader().feEnabled(iFE);
221 for (uint8_t iFEUnitChannel = 0; iFEUnitChannel <
FEDCH_PER_FEUNIT; iFEUnitChannel++) {
223 .setChannelStatus(iFE, iFEUnitChannel, fedFeHeader->getChannelStatus(iFE, iFEUnitChannel));
229 std::ostringstream debugStream;
230 if (ifed == fed_ids.begin()) {
231 std::cout <<
"\nFEHeader after transfer: " << std::endl;
236 edm::LogWarning(
"DigiToRaw") <<
"[sistrip::DigiToRaw::createFedBuffers_]"
239 << debugStream.str();
245 for (
auto iconn = conns.begin(); iconn != conns.end(); iconn++) {
266 <<
"digis collection is not valid...";
270 typename std::vector<edm::DetSet<Digi_t> >::const_iterator digis =
collection->find(
key);
276 for (idigi = digis_begin; idigi != digis->
data.end(); idigi++) {
277 if (
STRIP(idigi, digis_begin) < ipair * 256 ||
STRIP(idigi, digis_begin) > ipair * 256 + 255) {
280 const unsigned short strip =
STRIP(idigi, digis_begin) % 256;
284 std::stringstream
ss;
285 ss <<
"[sistrip::DigiToRaw::createFedBuffers]"
286 <<
" strip >= strips_per_fedCh";
294 const uint16_t
value = 0;
296 std::stringstream
ss;
297 ss <<
"[sistrip::DigiToRaw::createFedBuffers]"
298 <<
" Incompatible ADC values in buffer!"
299 <<
" FedId/FedCh: " << *ifed <<
"/" << iconn->fedCh()
300 <<
" DetStrip: " <<
STRIP(idigi, digis_begin) <<
" FedChStrip: " <<
strip
301 <<
" AdcValue: " << (*idigi).adc() <<
" RawData[" <<
strip <<
"]: " <<
value;
307 chanData[
strip] = (*idigi).adc();
314 <<
"Almost at the end...";
317 FEDRawData& fedrawdata = buffers->FEDData(*ifed);
321 std::ostringstream debugStream;
323 edm::LogWarning(
"DigiToRaw") <<
"[sistrip::DigiToRaw::createFedBuffers_]"
326 << debugStream.str();
330 edm::LogWarning(
"DigiToRaw") <<
"[sistrip::DigiToRaw::createFedBuffers_]"
331 <<
"end of first loop on feds";
337 edm::LogWarning(
"DigiToRaw") <<
"[sistrip::DigiToRaw::createFedBuffers_]"
338 <<
"Now getting the digis..."
339 <<
" Number of feds: " << fed_ids.size() <<
" between " << *(fed_ids.begin())
340 <<
" and " << *(fed_ids.end());
343 for (
auto ifed = fed_ids.begin(); ifed != fed_ids.end(); ++ifed) {
348 for (
auto iconn = conns.begin(); iconn != conns.end(); iconn++) {
369 <<
"digis collection is not valid...";
373 typename std::vector<edm::DetSet<Digi_t> >::const_iterator digis =
collection->find(
key);
379 for (idigi = digis_begin; idigi != digis->
data.end(); idigi++) {
380 if (
STRIP(idigi, digis_begin) < ipair * 256 ||
STRIP(idigi, digis_begin) > ipair * 256 + 255) {
383 const unsigned short strip =
STRIP(idigi, digis_begin) % 256;
387 std::stringstream
ss;
388 ss <<
"[sistrip::DigiToRaw::createFedBuffers]"
389 <<
" strip >= strips_per_fedCh";
397 const uint16_t
value = 0;
399 std::stringstream
ss;
400 ss <<
"[sistrip::DigiToRaw::createFedBuffers]"
401 <<
" Incompatible ADC values in buffer!"
402 <<
" FedId/FedCh: " << *ifed <<
"/" << iconn->fedCh()
403 <<
" DetStrip: " <<
STRIP(idigi, digis_begin) <<
" FedChStrip: " <<
strip
404 <<
" AdcValue: " << (*idigi).adc() <<
" RawData[" <<
strip <<
"]: " <<
value;
410 chanData[
strip] = (*idigi).adc();
417 <<
"Almost at the end...";
420 FEDRawData& fedrawdata = buffers->FEDData(*ifed);
424 std::ostringstream debugStream;
426 edm::LogWarning(
"DigiToRaw") <<
"[sistrip::DigiToRaw::createFedBuffers_]"
429 << debugStream.str();
437 <<
"Exception caught : " <<
e.what();