142 std::vector<long> DTTM7WordContainer;
145 std::ofstream logfile;
147 std::ostringstream
fname;
148 fname <<
"eventDump_" << twinMuxFed <<
".txt";
149 logfile.open( fname.str() );
154 if ( TM7data.
size() == 0 )
return;
166 int TM7fedId = ( dataWord >> 8 ) & 0xFFF;
171 int BOEevTy = ( dataWord >> 60 ) & 0xF;
174 if (
debug_ ) logfile <<
'[' << ++linecounter <<
"]\t" 175 << std::hex << dataWord <<
std::dec <<
"\t|\t" 176 <<
"BOEevTy " << BOEevTy <<
'\t' 177 <<
"TM7fedId " << TM7fedId <<
'\n';
179 if ( (BOEevTy != 0x5) || ( TM7fedId != twinMuxFed ) ) {
182 << twinMuxFed <<
" header " 183 << std::hex << dataWord;
192 std::map<int, int> AMCsizes;
196 int nAMC = ( dataWord >> 52 ) & 0xF;
198 if (
debug_ ) logfile <<
'[' << ++linecounter <<
"]\t" << std::hex
200 <<
"nAMC " << nAMC <<
'\n';
203 for (
int j = 0; j < nAMC; ++j ) {
208 int AMCno = (dataWord >> 16 ) & 0xF;
213 if ( (AMCno < 1) || (AMCno > 12) ) {
215 <<
" out of range (1-12)";
219 AMCsizes[AMCno] = ( dataWord >> 32 ) & 0xFFFFFF;
221 if (
debug_ ) logfile <<
'[' << ++linecounter <<
"]\t" 222 << std::hex << dataWord
224 <<
"AMCsizes[" << AMCno <<
"] " 230 std::map<int,int>::iterator AMCiterator = AMCsizes.begin();
231 std::map<int,int>::iterator AMCitend = AMCsizes.end();
232 for ( ; AMCiterator != AMCitend; ++AMCiterator ) {
234 for (
int k=0;
k<AMCiterator->second; ++
k) {
238 DTTM7WordContainer.push_back( dataWord );
249 calcCRC( dataWord & 0xFFFFFFFF0000FFFF, newCRC);
252 int chkEOE = (dataWord >> 60 ) & 0xF;
253 int CRC = ( dataWord >> 16 ) & 0xFFFF;
254 int evtLgth = ( dataWord >> 32 ) & 0xFFFFFF;
256 if ( chkEOE != 0xA ) {
257 edm::LogWarning(
"TwinMux_unpacker") <<
"AMC block closing line " << std::hex << dataWord
258 <<
std::dec <<
" does not start with 0xA";
262 if (
debug_ ) logfile <<
"\tevtLgth " << std::hex
263 << evtLgth <<
"\tCRC " << CRC <<
std::dec <<
'\n';
265 if ( nline != evtLgth ) {
266 edm::LogWarning(
"TwinMux_unpacker") <<
"Number of words read " << std::dec << nline
267 <<
" and event length " << std::dec << evtLgth
272 if ( newCRC != CRC ) {
273 edm::LogWarning(
"TwinMux_unpacker") <<
"Calculated CRC " << std::hex << newCRC
274 <<
" differs from CRC in trailer " << std::hex << CRC;
279 std::vector<long>::iterator DTTM7iterator = DTTM7WordContainer.begin();
280 std::vector<long>::iterator DTTM7itend = DTTM7WordContainer.end();
283 for ( ; DTTM7iterator != DTTM7itend; ++DTTM7iterator ) {
285 dataWord = (*DTTM7iterator);
286 int dataLenght = (dataWord & 0xFFFFF);
287 int bxCounter = (dataWord >> 20 ) & 0xFFF;
288 int event = (dataWord >> 32 ) & 0xFFFFFF;
289 int AMC_ID = (dataWord >> 56 ) & 0xF;
290 int control = (dataWord >> 60 ) & 0xF;
291 int wheel = twinMuxWheel;
293 if( ( AMC_ID < 1 )
or ( AMC_ID > 12 ) ) {
295 <<
" TM7fedId " << TM7fedId
296 <<
" AMC_ID " << AMC_ID;
300 int sector = twinMuxAmcSec[AMC_ID-1];
302 if( ( sector < 1 )
or ( sector > 12 ) ) {
303 if( sector != 15 )
edm::LogWarning(
"TwinMux_unpacker") <<
"%%%%%% VALID AMC_ID POINTS TO SECTOR OUT OF RANGE \n" 304 <<
" TM7fedId " << TM7fedId
305 <<
" AMC_ID " << AMC_ID
306 <<
" wheel " << wheel
307 <<
" sector " << sector;
311 if (
debug_ ) logfile <<
'[' << ++lcounter <<
"]\t" 312 << std::hex << dataWord << std::dec <<
"\t|\t" 313 <<
"AMC_ID " << AMC_ID <<
'\t' 314 <<
"control " << control <<
'\t' 315 <<
"event " <<
event <<
'\t' 316 <<
"bxCounter " << bxCounter <<
'\t' 317 <<
"dataLenght " << dataLenght <<
'\n';
320 if( DTTM7iterator == DTTM7itend ) {
321 edm::LogInfo(
"TwinMux_unpacker") <<
"TRAILING WORD AS A PAYLOAD END in FED " 322 << std::hex << TM7fedId
323 << std::hex << dataWord
324 << std::dec<<
" [it pos " 325 <<
int(DTTM7iterator - DTTM7itend) <<
" ]";
329 dataWord = (*DTTM7iterator);
330 int boardID = (dataWord & 0xFFFF);
331 int orbit = (dataWord >> 16 ) & 0xFFFF;
333 if ( DTTM7iterator == DTTM7itend ) {
335 <<
" control " << control
336 <<
" event " <<
event 337 <<
" bxCounter " << bxCounter
338 <<
" size " << dataLenght
339 <<
" orbit " << orbit
340 <<
" board " << boardID
341 <<
" AMCsizes " << AMCsizes[AMC_ID]
342 <<
" it pos " <<
int(DTTM7iterator - DTTM7itend);
346 if (
debug_ ) logfile <<
'[' << ++lcounter <<
"]\t" 347 << std::hex << dataWord
348 << std::dec <<
"\t|\t" 349 <<
" orbit " << orbit
350 <<
" board " << boardID <<
'\n';
352 int AMCsize = AMCsizes[AMC_ID] - 1;
358 for (
int tm7eventsize = 2; tm7eventsize < AMCsize; ++tm7eventsize ) {
361 if ( DTTM7iterator == DTTM7itend ) {
363 edm::LogWarning(
"TwinMux_unpacker") <<
"UNEXPECTED END OF PAYLOAD INSIDE CHAMBER DESCRIPTION" 364 <<
" [it pos " <<
int(DTTM7iterator - DTTM7itend) <<
" ]" ;
369 long dataWordSub = (*DTTM7iterator);
370 int selector = ( dataWordSub >> 60 ) & 0xF;
372 if ( selector == 0x4 ) {
374 bxID = ( dataWordSub >> 48 ) & 0xFFF;
375 bc0 = ( dataWordSub >> 22 ) & 0x1;
376 bxNr =
normBx(bxID, bxCounter);
378 if (
debug_ ) logfile <<
'[' << ++lcounter <<
"]\t" << std::hex
379 << dataWordSub << std::dec
381 <<
"bxID " << bxID <<
'\t' 382 <<
"bc0 " << bc0 <<
'\n';
386 else if ( selector == 0x1 ) {
388 int mb2_phi = ( dataWordSub & 0xFFF);
389 int mb2_phib = ( dataWordSub >> 12 ) & 0x3FF;
390 int mb2_qual = ( dataWordSub >> 22 ) & 0x7;
391 int mb2_ts2tag = ( dataWordSub >> 28 ) & 0x1;
396 int mb1_phi = ( dataWordSub >> 30 ) & 0xFFF;
397 int mb1_phib = ( dataWordSub >> 42 ) & 0x3FF;
398 int mb1_qual = ( dataWordSub >> 52 ) & 0x7;
399 int mb1_ts2tag = ( dataWordSub >> 58 ) & 0x1;
411 1, mb1_phi_conv, mb1_phib_conv,
412 mb1_qual, mb1_ts2tag, bxCounter ) );
414 2, mb2_phi_conv, mb2_phib_conv,
415 mb2_qual, mb2_ts2tag, bxCounter ) );
417 if (
debug_ ) logfile <<
'[' << ++lcounter <<
"]\t"<< std::hex
418 << dataWordSub << std::dec <<
"\t|\t" 419 <<
"mb1_ts2tag " << mb1_ts2tag <<
'\t' 420 <<
"mb1_qual " << mb1_qual <<
'\t' 421 <<
"mb1_phib " << mb1_phib_conv <<
'\t' 422 <<
"mb1_phi " << mb1_phi_conv <<
'\t' 423 <<
"mb2_ts2tag " << mb2_ts2tag <<
'\t' 424 <<
"mb2_qual " << mb2_qual <<
'\t' 425 <<
"mb2_phib " << mb2_phib_conv <<
'\t' 426 <<
"mb2_phi " << mb2_phi_conv <<
'\n';
429 else if ( selector == 0x2 ) {
431 int mb4_phi = ( dataWordSub & 0xFFF);
432 int mb4_phib = ( dataWordSub >> 12 ) & 0x3FF;
433 int mb4_qual = ( dataWordSub >> 22 ) & 0x7;
434 int mb4_ts2tag = ( dataWordSub >> 28 ) & 0x1;
439 int mb3_phi = ( dataWordSub >> 30 ) & 0xFFF;
440 int mb3_phib = ( dataWordSub >> 42 ) & 0x3FF;
441 int mb3_qual = ( dataWordSub >> 52 ) & 0x7;
442 int mb3_ts2tag = ( dataWordSub >> 58 ) & 0x1;
454 3, mb3_phi_conv, mb3_phib_conv,
455 mb3_qual, mb3_ts2tag, bxCounter) );
457 4, mb4_phi_conv, mb4_phib_conv,
458 mb4_qual, mb4_ts2tag, bxCounter) );
460 if (
debug_ ) logfile <<
'[' << ++lcounter <<
"]\t"<< std::hex
461 << dataWordSub << std::dec <<
"\t|\t" 462 <<
"mb3_ts2tag " << mb3_ts2tag <<
'\t' 463 <<
"mb3_qual " << mb3_qual <<
'\t' 464 <<
"mb3_phib " << mb3_phib_conv <<
'\t' 465 <<
"mb3_phi " << mb3_phi_conv <<
'\t' 466 <<
"mb4_ts2tag " << mb4_ts2tag <<
'\t' 467 <<
"mb4_qual " << mb4_qual <<
'\t' 468 <<
"mb4_phib " << mb4_phib_conv <<
'\t' 469 <<
"mb4_phi " << mb4_phi_conv <<
'\n';
473 else if ( selector == 0x3 ) {
475 int posBTI[7], qualBTI[7];
477 int mb3_eta = ( dataWordSub & 0xFF );
478 int mb2_eta = ( dataWordSub >> 16 ) & 0xFF;
479 int mb1_eta = ( dataWordSub >> 40 ) & 0xFF;
481 int mb3_eta_HQ = ( dataWordSub >> 8 ) & 0xFF;
482 int mb2_eta_HQ = ( dataWordSub >> 32 ) & 0xFF;
483 int mb1_eta_HQ = ( dataWordSub >> 48 ) & 0xFF;
485 if (
debug_ ) logfile <<
'[' << ++lcounter <<
"]\t" << std::hex
486 << dataWordSub << std::dec <<
"\t|\t" 487 <<
"mb1_eta " << mb1_eta <<
'\t' 488 <<
"mb2_eta " << mb2_eta <<
'\t' 489 <<
"mb3_eta " << mb3_eta <<
'\t' 490 <<
"mb1_eta_HQ " << mb1_eta_HQ <<
'\t' 491 <<
"mb2_eta_HQ " << mb2_eta_HQ <<
'\t' 492 <<
"mb3_eta_HQ " << mb3_eta_HQ <<
'\n';
495 posBTI[0] = (mb1_eta & 0x01);
496 posBTI[1] = ((mb1_eta & 0x02)>>1);
497 posBTI[2] = ((mb1_eta & 0x04)>>2);
498 posBTI[3] = ((mb1_eta & 0x08)>>3);
499 posBTI[4] = ((mb1_eta & 0x10)>>4);
500 posBTI[5] = ((mb1_eta & 0x20)>>5);
501 posBTI[6] = (((mb1_eta & 0x40)>>6) || ((mb1_eta & 0x80)>>7));
503 qualBTI[0] = (mb1_eta_HQ & 0x01);
504 qualBTI[1] = ((mb1_eta_HQ & 0x02)>>1);
505 qualBTI[2] = ((mb1_eta_HQ & 0x04)>>2);
506 qualBTI[3] = ((mb1_eta_HQ & 0x08)>>3);
507 qualBTI[4] = ((mb1_eta_HQ & 0x10)>>4);
508 qualBTI[5] = ((mb1_eta_HQ & 0x20)>>5);
509 qualBTI[6] = (((mb1_eta_HQ & 0x40)>>6) || ((mb1_eta_HQ & 0x80)>>7));
511 theSegments.push_back(
L1MuDTChambThDigi( bxNr, wheel, sector-1, 1, posBTI, qualBTI) );
514 posBTI[0] = (mb2_eta & 0x01);
515 posBTI[1] = ((mb2_eta & 0x02)>>1);
516 posBTI[2] = ((mb2_eta & 0x04)>>2);
517 posBTI[3] = ((mb2_eta & 0x08)>>3);
518 posBTI[4] = ((mb2_eta & 0x10)>>4);
519 posBTI[5] = ((mb2_eta & 0x20)>>5);
520 posBTI[6] = (((mb2_eta & 0x40)>>6) || ((mb2_eta & 0x80)>>7));
522 qualBTI[0] = (mb2_eta_HQ & 0x01);
523 qualBTI[1] = ((mb2_eta_HQ & 0x02)>>1);
524 qualBTI[2] = ((mb2_eta_HQ & 0x04)>>2);
525 qualBTI[3] = ((mb2_eta_HQ & 0x08)>>3);
526 qualBTI[4] = ((mb2_eta_HQ & 0x10)>>4);
527 qualBTI[5] = ((mb2_eta_HQ & 0x20)>>5);
528 qualBTI[6] = (((mb2_eta_HQ & 0x40)>>6) || ((mb2_eta_HQ & 0x80)>>7));
530 theSegments.push_back(
L1MuDTChambThDigi( bxNr, wheel, sector-1, 2, posBTI, qualBTI) );
533 posBTI[0] = (mb3_eta & 0x01);
534 posBTI[1] = ((mb3_eta & 0x02)>>1);
535 posBTI[2] = ((mb3_eta & 0x04)>>2);
536 posBTI[3] = ((mb3_eta & 0x08)>>3);
537 posBTI[4] = ((mb3_eta & 0x10)>>4);
538 posBTI[5] = ((mb3_eta & 0x20)>>5);
539 posBTI[6] = (((mb3_eta & 0x40)>>6) || ((mb3_eta & 0x80)>>7));
541 qualBTI[0] = (mb3_eta_HQ & 0x01);
542 qualBTI[1] = ((mb3_eta_HQ & 0x02)>>1);
543 qualBTI[2] = ((mb3_eta_HQ & 0x04)>>2);
544 qualBTI[3] = ((mb3_eta_HQ & 0x08)>>3);
545 qualBTI[4] = ((mb3_eta_HQ & 0x10)>>4);
546 qualBTI[5] = ((mb3_eta_HQ & 0x20)>>5);
547 qualBTI[6] = (((mb3_eta_HQ & 0x40)>>6) || ((mb3_eta_HQ & 0x80)>>7));
549 theSegments.push_back(
L1MuDTChambThDigi( bxNr, wheel, sector-1, 3, posBTI, qualBTI) );
553 else if ( selector == 0xB ) {
555 int mb2_phi = ( dataWordSub & 0xFFF);
556 int mb2_phib = ( dataWordSub >> 12 ) & 0x3FF;
557 int mb2_qual = ( dataWordSub >> 22 ) & 0x7;
558 int mb2_q3 = ( dataWordSub >> 25 ) & 0x1;
559 int mb2_q4 = ( dataWordSub >> 26 ) & 0x1;
560 int mb2_ts2tag = ( dataWordSub >> 28 ) & 0x1;
565 int mb1_phi = ( dataWordSub >> 30 ) & 0xFFF;
566 int mb1_phib = ( dataWordSub >> 42 ) & 0x3FF;
567 int mb1_qual = ( dataWordSub >> 52 ) & 0x7;
568 int mb1_q3 = ( dataWordSub >> 55 ) & 0x1;
569 int mb1_q4 = ( dataWordSub >> 56 ) & 0x1;
570 int mb1_ts2tag = ( dataWordSub >> 58 ) & 0x1;
582 1, mb1_phi_conv, mb1_phib_conv,
583 mb1_qual, mb1_ts2tag, bxCounter, mb1_q3 + 2*mb1_q4 ) );
585 2, mb2_phi_conv, mb2_phib_conv,
586 mb2_qual, mb2_ts2tag, bxCounter, mb2_q3 + 2*mb2_q4 ) );
588 if (
debug_ ) logfile <<
'[' << ++lcounter <<
"]\t"<< std::hex
589 << dataWordSub << std::dec <<
"\t|\t" 590 <<
"mb1_ts2tag_out " << mb1_ts2tag <<
'\t' 591 <<
"mb1_qual_out " << mb1_qual <<
'\t' 592 <<
"mb1_q3_out " << mb1_q3 <<
'\t' 593 <<
"mb1_q4_out " << mb1_q4 <<
'\t' 594 <<
"mb1_phib_out " << mb1_phib_conv <<
'\t' 595 <<
"mb1_phi_out " << mb1_phi_conv <<
'\t' 596 <<
"mb2_ts2tag_out " << mb2_ts2tag <<
'\t' 597 <<
"mb2_qual_out " << mb2_qual <<
'\t' 598 <<
"mb2_q3_out " << mb2_q3 <<
'\t' 599 <<
"mb2_q4_out " << mb2_q4 <<
'\t' 600 <<
"mb2_phib_out " << mb2_phib_conv <<
'\t' 601 <<
"mb2_phi_out " << mb2_phi_conv <<
'\n';
606 else if ( selector == 0xC ) {
608 int mb4_phi = ( dataWordSub & 0xFFF);
609 int mb4_phib = ( dataWordSub >> 12 ) & 0x3FF;
610 int mb4_qual = ( dataWordSub >> 22 ) & 0x7;
611 int mb4_q3 = ( dataWordSub >> 25 ) & 0x1;
612 int mb4_q4 = ( dataWordSub >> 26 ) & 0x1;
613 int mb4_ts2tag = ( dataWordSub >> 28 ) & 0x1;
618 int mb3_phi = ( dataWordSub >> 30 ) & 0xFFF;
619 int mb3_phib = ( dataWordSub >> 42 ) & 0x3FF;
620 int mb3_qual = ( dataWordSub >> 52 ) & 0x7;
621 int mb3_q3 = ( dataWordSub >> 55 ) & 0x1;
622 int mb3_q4 = ( dataWordSub >> 56 ) & 0x1;
623 int mb3_ts2tag = ( dataWordSub >> 58 ) & 0x1;
635 3, mb3_phi_conv, mb3_phib_conv,
636 mb3_qual, mb3_ts2tag, bxCounter, mb3_q3 + 2*mb3_q4 ) );
638 4, mb4_phi_conv, mb4_phib_conv,
639 mb4_qual, mb4_ts2tag, bxCounter, mb4_q3 + 2*mb4_q4 ) );
641 if (
debug_ ) logfile <<
'[' << ++lcounter <<
"]\t"<< std::hex
642 << dataWordSub << std::dec <<
"\t|\t" 643 <<
"mb3_ts2tag_out " << mb3_ts2tag <<
'\t' 644 <<
"mb3_qual_out " << mb3_qual <<
'\t' 645 <<
"mb3_q3_out " << mb3_q3 <<
'\t' 646 <<
"mb3_q4_out " << mb3_q4 <<
'\t' 647 <<
"mb3_phib_out " << mb3_phib_conv <<
'\t' 648 <<
"mb3_phi_out " << mb3_phi_conv <<
'\t' 649 <<
"mb4_ts2tag_out " << mb4_ts2tag <<
'\t' 650 <<
"mb4_qual_out " << mb4_qual <<
'\t' 651 <<
"mb4_q3_out " << mb4_q3 <<
'\t' 652 <<
"mb4_q4_out " << mb4_q4 <<
'\t' 653 <<
"mb4_phib_out " << mb4_phib_conv <<
'\t' 654 <<
"mb4_phi_out " << mb4_phi_conv <<
'\n';
658 else if ( selector == 0xD ) {
660 if (
debug_ ) logfile <<
'[' << ++lcounter <<
"]\t" << std::hex
661 << dataWordSub << std::dec
662 <<
"\t ETHA OUTPUT WORD\n";
666 else if ( selector == 0x9 || selector == 0xE ) {
668 edm::LogInfo(
"TwinMux_unpacker") <<
"RPC WORD [" << std::dec << tm7eventsize <<
"] : " 669 << std::hex << dataWordSub << std::dec
670 <<
" it pos " <<
int(DTTM7iterator - DTTM7itend);
672 if (
debug_ ) logfile <<
'[' << ++lcounter <<
"]\t" << std::hex
673 << dataWordSub << std::dec
678 else if ( selector == 0x6 ) {
680 edm::LogInfo(
"TwinMux_unpacker") <<
"HO WORD [" << std::dec << tm7eventsize <<
"] : " 681 << std::hex << dataWordSub << std::dec
682 <<
" it pos " <<
int(DTTM7iterator - DTTM7itend);
684 if (
debug_ ) logfile <<
'[' << ++lcounter <<
"]\t" << std::hex
685 << dataWordSub << std::dec
690 else if ( selector == 0xF ) {
692 edm::LogInfo(
"TwinMux_unpacker") <<
"ERROR WORD [" << std::dec << tm7eventsize <<
"] : " 693 << std::hex << dataWordSub << std::dec
694 <<
" it pos " <<
int(DTTM7iterator - DTTM7itend);
696 if (
debug_ ) logfile <<
'[' << ++lcounter <<
"]\t" << std::hex
697 << dataWordSub << std::dec
698 <<
"\t ERROR WORD\n";
703 edm::LogInfo(
"TwinMux_unpacker") <<
"UNKNOWN WORD received " << std::hex << dataWordSub
704 <<
" in FED " << std::hex << TM7fedId;
706 if (
debug_ ) logfile <<
'[' << ++lcounter <<
"]\t" << std::hex
707 << dataWordSub << std::dec
708 <<
"\t UNKNOWN WORD\n";
711 if( DTTM7iterator == DTTM7itend )
break;
719 if( DTTM7iterator == DTTM7itend )
break;
int normBx(int bx_, int bxCnt_)
int radAngConversion(int radAng_)
void readline(int &lines, long &dataWord)
size_t size() const
Lenght of the data buffer in bytes.
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
int benAngConversion(int benAng_)
void calcCRC(long word, int &myC)
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.