35 debug_( pset.getUntrackedParameter<
bool>(
"debug",
false) ),
37 DTTM7InputTag_( pset.getParameter<
edm::InputTag>(
"DTTM7_FED_Source") ),
38 feds_( pset.getUntrackedParameter<
std::vector<
int> >(
"feds",
std::vector<
int>()) ),
39 wheels_( pset.getUntrackedParameter<
std::vector<
int> >(
"wheels",
std::vector<
int>())),
40 amcsecmap_( pset.getUntrackedParameter<
std::vector<long long
int> >(
"amcsecmap",
std::vector<long long
int>()))
44 produces<L1MuDTChambPhContainer>(
"PhIn").setBranchAlias(
"PhIn");
45 produces<L1MuDTChambThContainer>(
"ThIn").setBranchAlias(
"ThIn");
46 produces<L1MuDTChambPhContainer>(
"PhOut").setBranchAlias(
"PhOut");
53 throw cms::Exception(
"TwinMux_unpacker") <<
"Configuration file error. Size of \'wheels\' and \'feds\' differs.\n";
56 throw cms::Exception(
"TwinMux_unpacker") <<
"Configuration file error. Size of \'wheels\' and \'amcsecmap\' differs.\n";
58 for (
size_t wh_i = 0; wh_i <
amcsecmap_.size(); ++wh_i){
59 std::array<short, 12> whmap;
60 for (
size_t amc_i = 1; amc_i < 13; ++amc_i ){
61 short shift = (12-amc_i)*4;
82 if ( !
fillRawData(e, phi_data, the_data, phi_out_data) )
return;
84 TM7phi_product->setContainer(phi_data);
85 TM7the_product->setContainer(the_data);
86 TM7phi_out_product->setContainer(phi_out_data);
103 for (
size_t w_i = 0; w_i <
nfeds_; ++w_i ) {
113 int bxNorm_ = bx_ - bxCnt_;
114 if (
abs( bxNorm_ ) < 3000 )
return bxNorm_;
116 if ( bxNorm_ > 0 )
return bxNorm_ - 3564;
117 if ( bxNorm_ < 0 )
return bxNorm_ + 3564;
143 std::array<short, 12> twinMuxAmcSec,
149 const unsigned int fw_rev_with_zerosupression = 93 ;
150 int previous_selector = -100;
152 std::vector<long> DTTM7WordContainer;
155 std::ofstream logfile;
157 std::ostringstream
fname;
158 fname <<
"eventDump_" << twinMuxFed <<
".txt";
159 logfile.open( fname.str() );
164 if ( TM7data.
size() == 0 )
return;
176 int TM7fedId = ( dataWord >> 8 ) & 0xFFF;
181 int BOEevTy = ( dataWord >> 60 ) & 0xF;
184 if (
debug_ ) logfile <<
'[' << ++linecounter <<
"]\t" 185 << std::hex << dataWord <<
std::dec <<
"\t|\t" 186 <<
"BOEevTy " << BOEevTy <<
'\t' 187 <<
"TM7fedId " << TM7fedId <<
'\n';
189 if ( (BOEevTy != 0x5) || ( TM7fedId != twinMuxFed ) ) {
192 << twinMuxFed <<
" header " 193 << std::hex << dataWord;
202 std::map<int, int> AMCsizes;
206 int nAMC = ( dataWord >> 52 ) & 0xF;
208 if (
debug_ ) logfile <<
'[' << ++linecounter <<
"]\t" << std::hex
210 <<
"nAMC " << nAMC <<
'\n';
213 for (
int j = 0; j < nAMC; ++j ) {
218 int AMCno = (dataWord >> 16 ) & 0xF;
223 if ( (AMCno < 1) || (AMCno > 12) ) {
225 <<
" out of range (1-12)";
229 AMCsizes[AMCno] = ( dataWord >> 32 ) & 0xFFFFFF;
231 if (
debug_ ) logfile <<
'[' << ++linecounter <<
"]\t" 232 << std::hex << dataWord
234 <<
"AMCsizes[" << AMCno <<
"] " 240 std::map<int,int>::iterator AMCiterator = AMCsizes.begin();
241 std::map<int,int>::iterator AMCitend = AMCsizes.end();
242 for ( ; AMCiterator != AMCitend; ++AMCiterator ) {
244 for (
int k=0;
k<AMCiterator->second; ++
k) {
248 DTTM7WordContainer.push_back( dataWord );
259 calcCRC( dataWord & 0xFFFFFFFF0000FFFF, newCRC);
262 int chkEOE = (dataWord >> 60 ) & 0xF;
263 int CRC = ( dataWord >> 16 ) & 0xFFFF;
264 int evtLgth = ( dataWord >> 32 ) & 0xFFFFFF;
266 if ( chkEOE != 0xA ) {
267 edm::LogWarning(
"TwinMux_unpacker") <<
"AMC block closing line " << std::hex << dataWord
268 <<
std::dec <<
" does not start with 0xA";
272 if (
debug_ ) logfile <<
"\tevtLgth " << std::hex
273 << evtLgth <<
"\tCRC " << CRC <<
std::dec <<
'\n';
275 if ( nline != evtLgth ) {
276 edm::LogWarning(
"TwinMux_unpacker") <<
"Number of words read " << std::dec << nline
277 <<
" and event length " << std::dec << evtLgth
282 if ( newCRC != CRC ) {
283 edm::LogWarning(
"TwinMux_unpacker") <<
"Calculated CRC " << std::hex << newCRC
284 <<
" differs from CRC in trailer " << std::hex << CRC;
289 std::vector<long>::iterator DTTM7iterator = DTTM7WordContainer.begin();
290 std::vector<long>::iterator DTTM7itend = DTTM7WordContainer.end();
293 for ( ; DTTM7iterator != DTTM7itend; ++DTTM7iterator ) {
295 dataWord = (*DTTM7iterator);
296 int dataLenght = (dataWord & 0xFFFFF);
297 int bxCounter = (dataWord >> 20 ) & 0xFFF;
298 int event = (dataWord >> 32 ) & 0xFFFFFF;
299 int AMC_ID = (dataWord >> 56 ) & 0xF;
300 int control = (dataWord >> 60 ) & 0xF;
301 int wheel = twinMuxWheel;
303 if( ( AMC_ID < 1 )
or ( AMC_ID > 12 ) ) {
305 <<
" TM7fedId " << TM7fedId
306 <<
" AMC_ID " << AMC_ID;
310 int sector = twinMuxAmcSec[AMC_ID-1];
312 if( ( sector < 1 )
or ( sector > 12 ) ) {
313 if( sector != 15 )
edm::LogWarning(
"TwinMux_unpacker") <<
"%%%%%% VALID AMC_ID POINTS TO SECTOR OUT OF RANGE \n" 314 <<
" TM7fedId " << TM7fedId
315 <<
" AMC_ID " << AMC_ID
316 <<
" wheel " << wheel
317 <<
" sector " << sector;
321 if (
debug_ ) logfile <<
'[' << ++lcounter <<
"]\t" 322 << std::hex << dataWord << std::dec <<
"\t|\t" 323 <<
"AMC_ID " << AMC_ID <<
'\t' 324 <<
"control " << control <<
'\t' 325 <<
"event " <<
event <<
'\t' 326 <<
"bxCounter " << bxCounter <<
'\t' 327 <<
"dataLenght " << dataLenght <<
'\n';
330 if( DTTM7iterator == DTTM7itend ) {
331 edm::LogInfo(
"TwinMux_unpacker") <<
"TRAILING WORD AS A PAYLOAD END in FED " 332 << std::hex << TM7fedId
333 << std::hex << dataWord
334 << std::dec<<
" [it pos " 335 <<
int(DTTM7iterator - DTTM7itend) <<
" ]";
339 dataWord = (*DTTM7iterator);
340 unsigned int firmware_rev = (dataWord >>7) & 0x1FF ;
341 int boardID = (dataWord & 0xFFFF);
342 int orbit = (dataWord >> 16 ) & 0xFFFF;
344 if ( DTTM7iterator == DTTM7itend ) {
346 <<
" control " << control
347 <<
" event " <<
event 348 <<
" bxCounter " << bxCounter
349 <<
" size " << dataLenght
350 <<
" orbit " << orbit
351 <<
" board " << boardID
352 <<
" AMCsizes " << AMCsizes[AMC_ID]
353 <<
" it pos " <<
int(DTTM7iterator - DTTM7itend);
357 if (
debug_ ) logfile <<
'[' << ++lcounter <<
"]\t" 358 << std::hex << dataWord
359 << std::dec <<
"\t|\t" 360 <<
" orbit " << orbit
361 <<
" board " << boardID <<
'\n';
363 int AMCsize = AMCsizes[AMC_ID] - 1;
369 for (
int tm7eventsize = 2; tm7eventsize < AMCsize; ++tm7eventsize ) {
372 if ( DTTM7iterator == DTTM7itend ) {
374 edm::LogWarning(
"TwinMux_unpacker") <<
"UNEXPECTED END OF PAYLOAD INSIDE CHAMBER DESCRIPTION" 375 <<
" [it pos " <<
int(DTTM7iterator - DTTM7itend) <<
" ]" ;
380 long dataWordSub = (*DTTM7iterator);
381 int selector = ( dataWordSub >> 60 ) & 0xF;
383 if (firmware_rev >= fw_rev_with_zerosupression ){
384 if ( selector == 0xC ) {
386 bc0 = ( dataWordSub >> 59 ) & 0x1;
390 int bxOffset = ( dataWordSub >> 48 ) & 0x3F;
394 bxNr = bxOffset < 32 ? bxOffset : bxOffset - 64;
400 int posBTI[7], qualBTI[7];
402 int mb3_eta = ( dataWordSub & 0xFF );
403 int mb3_eta_HQ = ( dataWordSub >> 8 ) & 0xFF;
404 int mb2_eta = ( dataWordSub >> 16 ) & 0xFF;
405 int mb2_eta_HQ = ( dataWordSub >> 24 ) & 0xFF;
406 int mb1_eta = ( dataWordSub >> 32 ) & 0xFF;
407 int mb1_eta_HQ = ( dataWordSub >> 40 ) & 0xFF;
410 for (
int i = 0 ;
i<=5;
i++){
411 posBTI[
i] = (mb1_eta >>
i) & 0x01;
412 qualBTI[
i] = (mb1_eta_HQ >>
i) & 0x01;
414 posBTI[6] = (((mb1_eta >> 6) & 0x01) || ((mb1_eta >> 7) & 0x01));
415 qualBTI[6] = (((mb1_eta_HQ >> 6) & 0x01) || ((mb1_eta_HQ >> 7) & 0x01));
417 theSegments.push_back(
L1MuDTChambThDigi( bxNr, wheel, sector-1, 1, posBTI, qualBTI) );
422 for (
int i = 0 ;
i<=5;
i++){
423 posBTI[
i] = (mb2_eta >>
i) & 0x01;
424 qualBTI[
i] = (mb2_eta_HQ >>
i) & 0x01;
426 posBTI[6] = ((mb2_eta >> 6) & 0x01) || ((mb2_eta >> 7) & 0x01);
427 qualBTI[6] = ((mb2_eta_HQ >> 6) & 0x01) || ((mb2_eta_HQ >> 7) & 0x01);
429 theSegments.push_back(
L1MuDTChambThDigi( bxNr, wheel, sector-1, 2, posBTI, qualBTI) );
432 for (
int i = 0 ;
i<=5;
i++){
433 posBTI[
i] = (mb3_eta >>
i) & 0x01;
434 qualBTI[
i] = (mb3_eta_HQ >>
i) & 0x01;
436 posBTI[6] = ((mb3_eta >> 6) & 0x01) || ((mb3_eta >> 7) & 0x01);
437 qualBTI[6] = ((mb3_eta_HQ >> 6) & 0x01) || ((mb3_eta_HQ >> 7) & 0x01);
439 theSegments.push_back(
L1MuDTChambThDigi( bxNr, wheel, sector-1, 3, posBTI, qualBTI) );
441 if (
debug_ ) logfile <<
'[' << ++lcounter <<
"]\t" << std::hex
442 << dataWordSub << std::dec
443 <<
"\t bx info word\t" 444 <<
"bxOffset " << bxOffset <<
'\t' 445 <<
"bc0 " << bc0 <<
'\t' 446 <<
"mb1_eta " << mb1_eta <<
'\t' 447 <<
"mb2_eta " << mb2_eta <<
'\t' 448 <<
"mb3_eta " << mb3_eta <<
'\t' 449 <<
"mb1_eta_HQ " << mb1_eta_HQ <<
'\t' 450 <<
"mb2_eta_HQ " << mb2_eta_HQ <<
'\t' 451 <<
"mb3_eta_HQ " << mb3_eta_HQ <<
'\n';
455 else if ( selector >= 1 && selector <= 4 ) {
457 int out_phi = ( dataWordSub >> 0 ) & 0xFFF;
458 int out_phib = ( dataWordSub >> 12 ) & 0x3FF;
459 int out_qual = ( dataWordSub >> 22 ) & 0x7;
460 int out_q3 = ( dataWordSub >> 25 ) & 0x1;
461 int out_q4 = ( dataWordSub >> 26 ) & 0x1;
462 int out_updown = ( dataWordSub >> 27 ) & 0x1;
463 int out_ts2tag = ( dataWordSub >> 28 ) & 0x1;
467 int in_phi = ( dataWordSub >> 30 ) & 0xFFF;
468 int in_phib = ( dataWordSub >> 42 ) & 0x3FF;
469 int in_qual = ( dataWordSub >> 52 ) & 0x7;
470 int in_updown = ( dataWordSub >> 57 ) & 0x1;
471 int in_ts2tag = ( dataWordSub >> 58 ) & 0x1;
481 if (previous_selector != selector ) {
486 in_phi_conv, in_phib_conv,
487 in_qual, in_ts2tag + in_updown*2, bxCounter ) );
489 if ( out_qual != 7) {
492 out_phi_conv, out_phib_conv,
493 out_qual, out_ts2tag+ out_updown*2, bxCounter,
494 out_q3 + 2*out_q4 ) );
501 in_phi_conv, in_phib_conv,
502 in_qual, in_ts2tag + in_updown*2, bxCounter ) );
505 if ( out_qual != 7) {
508 out_phi_conv, out_phib_conv,
509 out_qual, out_ts2tag + out_updown*2, bxCounter,
510 out_q3 + 2*out_q4 ) );
514 if (
debug_ ) logfile <<
'[' << ++lcounter <<
"]\t"<< std::hex
515 << dataWordSub << std::dec <<
"\t|\t" 516 <<
"in_ts2tag " << in_ts2tag <<
'\t' 517 <<
"in_updown " << in_updown <<
'\t' 518 <<
"in_qual " << in_qual <<
'\t' 519 <<
"in_phib " << in_phib_conv <<
'\t' 520 <<
"in_phi " << in_phi_conv <<
'\t' 521 <<
"out_ts2tag " << out_ts2tag <<
'\t' 522 <<
"out_updown " << out_updown <<
'\t' 523 <<
"out_qual " << out_qual <<
'\t' 524 <<
"out_q3_out " << out_q3 <<
'\t' 525 <<
"out_q4_out " << out_q4 <<
'\t' 526 <<
"out_phib " << out_phib_conv <<
'\t' 527 <<
"out_phi " << out_phi_conv <<
'\t' 528 <<
"2nd track " << ((previous_selector == selector)?1:0) <<
'\n';
531 else if ( selector == 0x9 || selector == 0xE ) {
533 edm::LogInfo(
"TwinMux_unpacker") <<
"RPC WORD [" << std::dec << tm7eventsize <<
"] : " 534 << std::hex << dataWordSub << std::dec
535 <<
" it pos " <<
int(DTTM7iterator - DTTM7itend);
537 if (
debug_ ) logfile <<
'[' << ++lcounter <<
"]\t" << std::hex
538 << dataWordSub << std::dec
543 else if ( selector == 0x6 ) {
545 edm::LogInfo(
"TwinMux_unpacker") <<
"HO WORD [" << std::dec << tm7eventsize <<
"] : " 546 << std::hex << dataWordSub << std::dec
547 <<
" it pos " <<
int(DTTM7iterator - DTTM7itend);
549 if (
debug_ ) logfile <<
'[' << ++lcounter <<
"]\t" << std::hex
550 << dataWordSub << std::dec
555 else if ( selector == 0xF ) {
557 edm::LogInfo(
"TwinMux_unpacker") <<
"ERROR WORD [" << std::dec << tm7eventsize <<
"] : " 558 << std::hex << dataWordSub << std::dec
559 <<
" it pos " <<
int(DTTM7iterator - DTTM7itend);
561 if (
debug_ ) logfile <<
'[' << ++lcounter <<
"]\t" << std::hex
562 << dataWordSub << std::dec
563 <<
"\t ERROR WORD\n";
568 edm::LogInfo(
"TwinMux_unpacker") <<
"UNKNOWN WORD received " << std::hex << dataWordSub
569 <<
" in FED " << std::hex << TM7fedId;
571 if (
debug_ ) logfile <<
'[' << ++lcounter <<
"]\t" << std::hex
572 << dataWordSub << std::dec
573 <<
"\t UNKNOWN WORD\n";
575 previous_selector = selector ;
578 if ( selector == 0x4 ) {
580 bxID = ( dataWordSub >> 48 ) & 0xFFF;
581 bc0 = ( dataWordSub >> 22 ) & 0x1;
582 bxNr =
normBx(bxID, bxCounter);
584 if (
debug_ ) logfile <<
'[' << ++lcounter <<
"]\t" << std::hex
585 << dataWordSub << std::dec
587 <<
"bxID " << bxID <<
'\t' 588 <<
"bc0 " << bc0 <<
'\n';
592 else if ( selector == 0x1 ) {
594 int mb2_phi = ( dataWordSub & 0xFFF);
595 int mb2_phib = ( dataWordSub >> 12 ) & 0x3FF;
596 int mb2_qual = ( dataWordSub >> 22 ) & 0x7;
597 int mb2_ts2tag = ( dataWordSub >> 28 ) & 0x1;
602 int mb1_phi = ( dataWordSub >> 30 ) & 0xFFF;
603 int mb1_phib = ( dataWordSub >> 42 ) & 0x3FF;
604 int mb1_qual = ( dataWordSub >> 52 ) & 0x7;
605 int mb1_ts2tag = ( dataWordSub >> 58 ) & 0x1;
617 1, mb1_phi_conv, mb1_phib_conv,
618 mb1_qual, mb1_ts2tag, bxCounter , -1) );
620 2, mb2_phi_conv, mb2_phib_conv,
621 mb2_qual, mb2_ts2tag, bxCounter , -1) );
623 if (
debug_ ) logfile <<
'[' << ++lcounter <<
"]\t"<< std::hex
624 << dataWordSub << std::dec <<
"\t|\t" 625 <<
"mb1_ts2tag " << mb1_ts2tag <<
'\t' 626 <<
"mb1_qual " << mb1_qual <<
'\t' 627 <<
"mb1_phib " << mb1_phib_conv <<
'\t' 628 <<
"mb1_phi " << mb1_phi_conv <<
'\t' 629 <<
"mb2_ts2tag " << mb2_ts2tag <<
'\t' 630 <<
"mb2_qual " << mb2_qual <<
'\t' 631 <<
"mb2_phib " << mb2_phib_conv <<
'\t' 632 <<
"mb2_phi " << mb2_phi_conv <<
'\n';
635 else if ( selector == 0x2 ) {
637 int mb4_phi = ( dataWordSub & 0xFFF);
638 int mb4_phib = ( dataWordSub >> 12 ) & 0x3FF;
639 int mb4_qual = ( dataWordSub >> 22 ) & 0x7;
640 int mb4_ts2tag = ( dataWordSub >> 28 ) & 0x1;
645 int mb3_phi = ( dataWordSub >> 30 ) & 0xFFF;
646 int mb3_phib = ( dataWordSub >> 42 ) & 0x3FF;
647 int mb3_qual = ( dataWordSub >> 52 ) & 0x7;
648 int mb3_ts2tag = ( dataWordSub >> 58 ) & 0x1;
660 3, mb3_phi_conv, mb3_phib_conv,
661 mb3_qual, mb3_ts2tag, bxCounter, -1) );
663 4, mb4_phi_conv, mb4_phib_conv,
664 mb4_qual, mb4_ts2tag, bxCounter, -1) );
666 if (
debug_ ) logfile <<
'[' << ++lcounter <<
"]\t"<< std::hex
667 << dataWordSub << std::dec <<
"\t|\t" 668 <<
"mb3_ts2tag " << mb3_ts2tag <<
'\t' 669 <<
"mb3_qual " << mb3_qual <<
'\t' 670 <<
"mb3_phib " << mb3_phib_conv <<
'\t' 671 <<
"mb3_phi " << mb3_phi_conv <<
'\t' 672 <<
"mb4_ts2tag " << mb4_ts2tag <<
'\t' 673 <<
"mb4_qual " << mb4_qual <<
'\t' 674 <<
"mb4_phib " << mb4_phib_conv <<
'\t' 675 <<
"mb4_phi " << mb4_phi_conv <<
'\n';
679 else if ( selector == 0x3 ) {
681 int posBTI[7], qualBTI[7];
683 int mb3_eta = ( dataWordSub & 0xFF );
684 int mb2_eta = ( dataWordSub >> 16 ) & 0xFF;
685 int mb1_eta = ( dataWordSub >> 40 ) & 0xFF;
687 int mb3_eta_HQ = ( dataWordSub >> 8 ) & 0xFF;
688 int mb2_eta_HQ = ( dataWordSub >> 32 ) & 0xFF;
689 int mb1_eta_HQ = ( dataWordSub >> 48 ) & 0xFF;
691 if (
debug_ ) logfile <<
'[' << ++lcounter <<
"]\t" << std::hex
692 << dataWordSub << std::dec <<
"\t|\t" 693 <<
"mb1_eta " << mb1_eta <<
'\t' 694 <<
"mb2_eta " << mb2_eta <<
'\t' 695 <<
"mb3_eta " << mb3_eta <<
'\t' 696 <<
"mb1_eta_HQ " << mb1_eta_HQ <<
'\t' 697 <<
"mb2_eta_HQ " << mb2_eta_HQ <<
'\t' 698 <<
"mb3_eta_HQ " << mb3_eta_HQ <<
'\n';
701 posBTI[0] = (mb1_eta & 0x01);
702 posBTI[1] = ((mb1_eta & 0x02)>>1);
703 posBTI[2] = ((mb1_eta & 0x04)>>2);
704 posBTI[3] = ((mb1_eta & 0x08)>>3);
705 posBTI[4] = ((mb1_eta & 0x10)>>4);
706 posBTI[5] = ((mb1_eta & 0x20)>>5);
707 posBTI[6] = (((mb1_eta & 0x40)>>6) || ((mb1_eta & 0x80)>>7));
709 qualBTI[0] = (mb1_eta_HQ & 0x01);
710 qualBTI[1] = ((mb1_eta_HQ & 0x02)>>1);
711 qualBTI[2] = ((mb1_eta_HQ & 0x04)>>2);
712 qualBTI[3] = ((mb1_eta_HQ & 0x08)>>3);
713 qualBTI[4] = ((mb1_eta_HQ & 0x10)>>4);
714 qualBTI[5] = ((mb1_eta_HQ & 0x20)>>5);
715 qualBTI[6] = (((mb1_eta_HQ & 0x40)>>6) || ((mb1_eta_HQ & 0x80)>>7));
717 theSegments.push_back(
L1MuDTChambThDigi( bxNr, wheel, sector-1, 1, posBTI, qualBTI) );
720 posBTI[0] = (mb2_eta & 0x01);
721 posBTI[1] = ((mb2_eta & 0x02)>>1);
722 posBTI[2] = ((mb2_eta & 0x04)>>2);
723 posBTI[3] = ((mb2_eta & 0x08)>>3);
724 posBTI[4] = ((mb2_eta & 0x10)>>4);
725 posBTI[5] = ((mb2_eta & 0x20)>>5);
726 posBTI[6] = (((mb2_eta & 0x40)>>6) || ((mb2_eta & 0x80)>>7));
728 qualBTI[0] = (mb2_eta_HQ & 0x01);
729 qualBTI[1] = ((mb2_eta_HQ & 0x02)>>1);
730 qualBTI[2] = ((mb2_eta_HQ & 0x04)>>2);
731 qualBTI[3] = ((mb2_eta_HQ & 0x08)>>3);
732 qualBTI[4] = ((mb2_eta_HQ & 0x10)>>4);
733 qualBTI[5] = ((mb2_eta_HQ & 0x20)>>5);
734 qualBTI[6] = (((mb2_eta_HQ & 0x40)>>6) || ((mb2_eta_HQ & 0x80)>>7));
736 theSegments.push_back(
L1MuDTChambThDigi( bxNr, wheel, sector-1, 2, posBTI, qualBTI) );
739 posBTI[0] = (mb3_eta & 0x01);
740 posBTI[1] = ((mb3_eta & 0x02)>>1);
741 posBTI[2] = ((mb3_eta & 0x04)>>2);
742 posBTI[3] = ((mb3_eta & 0x08)>>3);
743 posBTI[4] = ((mb3_eta & 0x10)>>4);
744 posBTI[5] = ((mb3_eta & 0x20)>>5);
745 posBTI[6] = (((mb3_eta & 0x40)>>6) || ((mb3_eta & 0x80)>>7));
747 qualBTI[0] = (mb3_eta_HQ & 0x01);
748 qualBTI[1] = ((mb3_eta_HQ & 0x02)>>1);
749 qualBTI[2] = ((mb3_eta_HQ & 0x04)>>2);
750 qualBTI[3] = ((mb3_eta_HQ & 0x08)>>3);
751 qualBTI[4] = ((mb3_eta_HQ & 0x10)>>4);
752 qualBTI[5] = ((mb3_eta_HQ & 0x20)>>5);
753 qualBTI[6] = (((mb3_eta_HQ & 0x40)>>6) || ((mb3_eta_HQ & 0x80)>>7));
755 theSegments.push_back(
L1MuDTChambThDigi( bxNr, wheel, sector-1, 3, posBTI, qualBTI) );
759 else if ( selector == 0xB ) {
761 int mb2_phi = ( dataWordSub & 0xFFF);
762 int mb2_phib = ( dataWordSub >> 12 ) & 0x3FF;
763 int mb2_qual = ( dataWordSub >> 22 ) & 0x7;
764 int mb2_q3 = ( dataWordSub >> 25 ) & 0x1;
765 int mb2_q4 = ( dataWordSub >> 26 ) & 0x1;
766 int mb2_ts2tag = ( dataWordSub >> 28 ) & 0x1;
771 int mb1_phi = ( dataWordSub >> 30 ) & 0xFFF;
772 int mb1_phib = ( dataWordSub >> 42 ) & 0x3FF;
773 int mb1_qual = ( dataWordSub >> 52 ) & 0x7;
774 int mb1_q3 = ( dataWordSub >> 55 ) & 0x1;
775 int mb1_q4 = ( dataWordSub >> 56 ) & 0x1;
776 int mb1_ts2tag = ( dataWordSub >> 58 ) & 0x1;
788 1, mb1_phi_conv, mb1_phib_conv,
789 mb1_qual, mb1_ts2tag, bxCounter, mb1_q3 + 2*mb1_q4 ) );
791 2, mb2_phi_conv, mb2_phib_conv,
792 mb2_qual, mb2_ts2tag, bxCounter, mb2_q3 + 2*mb2_q4 ) );
794 if (
debug_ ) logfile <<
'[' << ++lcounter <<
"]\t"<< std::hex
795 << dataWordSub << std::dec <<
"\t|\t" 796 <<
"mb1_ts2tag_out " << mb1_ts2tag <<
'\t' 797 <<
"mb1_qual_out " << mb1_qual <<
'\t' 798 <<
"mb1_q3_out " << mb1_q3 <<
'\t' 799 <<
"mb1_q4_out " << mb1_q4 <<
'\t' 800 <<
"mb1_phib_out " << mb1_phib_conv <<
'\t' 801 <<
"mb1_phi_out " << mb1_phi_conv <<
'\t' 802 <<
"mb2_ts2tag_out " << mb2_ts2tag <<
'\t' 803 <<
"mb2_qual_out " << mb2_qual <<
'\t' 804 <<
"mb2_q3_out " << mb2_q3 <<
'\t' 805 <<
"mb2_q4_out " << mb2_q4 <<
'\t' 806 <<
"mb2_phib_out " << mb2_phib_conv <<
'\t' 807 <<
"mb2_phi_out " << mb2_phi_conv <<
'\n';
812 else if ( selector == 0xC ) {
814 int mb4_phi = ( dataWordSub & 0xFFF);
815 int mb4_phib = ( dataWordSub >> 12 ) & 0x3FF;
816 int mb4_qual = ( dataWordSub >> 22 ) & 0x7;
817 int mb4_q3 = ( dataWordSub >> 25 ) & 0x1;
818 int mb4_q4 = ( dataWordSub >> 26 ) & 0x1;
819 int mb4_ts2tag = ( dataWordSub >> 28 ) & 0x1;
824 int mb3_phi = ( dataWordSub >> 30 ) & 0xFFF;
825 int mb3_phib = ( dataWordSub >> 42 ) & 0x3FF;
826 int mb3_qual = ( dataWordSub >> 52 ) & 0x7;
827 int mb3_q3 = ( dataWordSub >> 55 ) & 0x1;
828 int mb3_q4 = ( dataWordSub >> 56 ) & 0x1;
829 int mb3_ts2tag = ( dataWordSub >> 58 ) & 0x1;
841 3, mb3_phi_conv, mb3_phib_conv,
842 mb3_qual, mb3_ts2tag, bxCounter, mb3_q3 + 2*mb3_q4 ) );
844 4, mb4_phi_conv, mb4_phib_conv,
845 mb4_qual, mb4_ts2tag, bxCounter, mb4_q3 + 2*mb4_q4 ) );
847 if (
debug_ ) logfile <<
'[' << ++lcounter <<
"]\t"<< std::hex
848 << dataWordSub << std::dec <<
"\t|\t" 849 <<
"mb3_ts2tag_out " << mb3_ts2tag <<
'\t' 850 <<
"mb3_qual_out " << mb3_qual <<
'\t' 851 <<
"mb3_q3_out " << mb3_q3 <<
'\t' 852 <<
"mb3_q4_out " << mb3_q4 <<
'\t' 853 <<
"mb3_phib_out " << mb3_phib_conv <<
'\t' 854 <<
"mb3_phi_out " << mb3_phi_conv <<
'\t' 855 <<
"mb4_ts2tag_out " << mb4_ts2tag <<
'\t' 856 <<
"mb4_qual_out " << mb4_qual <<
'\t' 857 <<
"mb4_q3_out " << mb4_q3 <<
'\t' 858 <<
"mb4_q4_out " << mb4_q4 <<
'\t' 859 <<
"mb4_phib_out " << mb4_phib_conv <<
'\t' 860 <<
"mb4_phi_out " << mb4_phi_conv <<
'\n';
864 else if ( selector == 0xD ) {
866 if (
debug_ ) logfile <<
'[' << ++lcounter <<
"]\t" << std::hex
867 << dataWordSub << std::dec
868 <<
"\t ETHA OUTPUT WORD\n";
872 else if ( selector == 0x9 || selector == 0xE ) {
874 edm::LogInfo(
"TwinMux_unpacker") <<
"RPC WORD [" << std::dec << tm7eventsize <<
"] : " 875 << std::hex << dataWordSub << std::dec
876 <<
" it pos " <<
int(DTTM7iterator - DTTM7itend);
878 if (
debug_ ) logfile <<
'[' << ++lcounter <<
"]\t" << std::hex
879 << dataWordSub << std::dec
884 else if ( selector == 0x6 ) {
886 edm::LogInfo(
"TwinMux_unpacker") <<
"HO WORD [" << std::dec << tm7eventsize <<
"] : " 887 << std::hex << dataWordSub << std::dec
888 <<
" it pos " <<
int(DTTM7iterator - DTTM7itend);
890 if (
debug_ ) logfile <<
'[' << ++lcounter <<
"]\t" << std::hex
891 << dataWordSub << std::dec
896 else if ( selector == 0xF ) {
898 edm::LogInfo(
"TwinMux_unpacker") <<
"ERROR WORD [" << std::dec << tm7eventsize <<
"] : " 899 << std::hex << dataWordSub << std::dec
900 <<
" it pos " <<
int(DTTM7iterator - DTTM7itend);
902 if (
debug_ ) logfile <<
'[' << ++lcounter <<
"]\t" << std::hex
903 << dataWordSub << std::dec
904 <<
"\t ERROR WORD\n";
909 edm::LogInfo(
"TwinMux_unpacker") <<
"UNKNOWN WORD received " << std::hex << dataWordSub
910 <<
" in FED " << std::hex << TM7fedId;
912 if (
debug_ ) logfile <<
'[' << ++lcounter <<
"]\t" << std::hex
913 << dataWordSub << std::dec
914 <<
"\t UNKNOWN WORD\n";
917 if( DTTM7iterator == DTTM7itend )
break;
925 if( DTTM7iterator == DTTM7itend )
break;
936 int myCRC[16],
D[64],
C[16];
938 for (
int i = 0;
i < 64; ++
i ) { D[
i] = (word >>
i) & 0x1; }
939 for (
int i = 0;
i < 16; ++
i ) { C[
i] = (myC>>
i) & 0x1; }
941 myCRC[0] = ( D[63] + D[62] + D[61] + D[60] + D[55] + D[54] +
942 D[53] + D[52] + D[51] + D[50] + D[49] + D[48] +
943 D[47] + D[46] + D[45] + D[43] + D[41] + D[40] +
944 D[39] + D[38] + D[37] + D[36] + D[35] + D[34] +
945 D[33] + D[32] + D[31] + D[30] + D[27] + D[26] +
946 D[25] + D[24] + D[23] + D[22] + D[21] + D[20] +
947 D[19] + D[18] + D[17] + D[16] + D[15] + D[13] +
948 D[12] + D[11] + D[10] + D[9] + D[8] + D[7] +
949 D[6] + D[5] + D[4] + D[3] + D[2] + D[1] +
950 D[0] + C[0] + C[1] + C[2] + C[3] + C[4] +
951 C[5] + C[6] + C[7] + C[12] + C[13] + C[14] +
954 myCRC[1] = ( D[63] + D[62] + D[61] + D[56] + D[55] + D[54] +
955 D[53] + D[52] + D[51] + D[50] + D[49] + D[48] +
956 D[47] + D[46] + D[44] + D[42] + D[41] + D[40] +
957 D[39] + D[38] + D[37] + D[36] + D[35] + D[34] +
958 D[33] + D[32] + D[31] + D[28] + D[27] + D[26] +
959 D[25] + D[24] + D[23] + D[22] + D[21] + D[20] +
960 D[19] + D[18] + D[17] + D[16] + D[14] + D[13] +
961 D[12] + D[11] + D[10] + D[9] + D[8] + D[7] +
962 D[6] + D[5] + D[4] + D[3] + D[2] + D[1] +
963 C[0] + C[1] + C[2] + C[3] + C[4] + C[5] +
964 C[6] + C[7] + C[8] + C[13] + C[14] + C[15] )%2;
966 myCRC[2] = ( D[61] + D[60] + D[57] + D[56] + D[46] + D[42] +
967 D[31] + D[30] + D[29] + D[28] + D[16] + D[14] +
968 D[1] + D[0] + C[8] + C[9] + C[12] + C[13] )%2;
970 myCRC[3] = ( D[62] + D[61] + D[58] + D[57] + D[47] + D[43] +
971 D[32] + D[31] + D[30] + D[29] + D[17] + D[15] +
972 D[2] + D[1] + C[9] + C[10] + C[13] + C[14] )%2;
974 myCRC[4] = ( D[63] + D[62] + D[59] + D[58] + D[48] + D[44] +
975 D[33] + D[32] + D[31] + D[30] + D[18] + D[16] +
976 D[3] + D[2] + C[0] + C[10] + C[11] + C[14] +
979 myCRC[5] = ( D[63] + D[60] + D[59] + D[49] + D[45] + D[34] +
980 D[33] + D[32] + D[31] + D[19] + D[17] + D[4] +
981 D[3] + C[1] + C[11] + C[12] + C[15] )%2;
983 myCRC[6] = ( D[61] + D[60] + D[50] + D[46] + D[35] + D[34] +
984 D[33] + D[32] + D[20] + D[18] + D[5] + D[4] +
985 C[2] + C[12] + C[13] )%2;
987 myCRC[7] = ( D[62] + D[61] + D[51] + D[47] + D[36] + D[35] +
988 D[34] + D[33] + D[21] + D[19] + D[6] + D[5] +
989 C[3] + C[13] + C[14] )%2;
991 myCRC[8] = ( D[63] + D[62] + D[52] + D[48] + D[37] + D[36] +
992 D[35] + D[34] + D[22] + D[20] + D[7] + D[6] +
993 C[0] + C[4] + C[14] + C[15] )%2;
995 myCRC[9] = ( D[63] + D[53] + D[49] + D[38] + D[37] + D[36] +
996 D[35] + D[23] + D[21] + D[8] + D[7] + C[1] +
999 myCRC[10] = ( D[54] + D[50] + D[39] + D[38] + D[37] + D[36] +
1000 D[24] + D[22] + D[9] + D[8] + C[2] + C[6] )%2;
1002 myCRC[11] = ( D[55] + D[51] + D[40] + D[39] + D[38] + D[37] +
1003 D[25] + D[23] + D[10] + D[9] + C[3] + C[7] )%2;
1005 myCRC[12] = ( D[56] + D[52] + D[41] + D[40] + D[39] + D[38] +
1006 D[26] + D[24] + D[11] + D[10] + C[4] + C[8] )%2;
1008 myCRC[13] = ( D[57] + D[53] + D[42] + D[41] + D[40] + D[39] +
1009 D[27] + D[25] + D[12] + D[11] + C[5] + C[9] )%2;
1011 myCRC[14] = ( D[58] + D[54] + D[43] + D[42] + D[41] + D[40] +
1012 D[28] + D[26] + D[13] + D[12] + C[6] + C[10] )%2;
1014 myCRC[15] = ( D[63] + D[62] + D[61] + D[60] + D[59] + D[54] +
1015 D[53] + D[52] + D[51] + D[50] + D[49] + D[48] +
1016 D[47] + D[46] + D[45] + D[44] + D[42] + D[40] +
1017 D[39] + D[38] + D[37] + D[36] + D[35] + D[34] +
1018 D[33] + D[32] + D[31] + D[30] + D[29] + D[26] +
1019 D[25] + D[24] + D[23] + D[22] + D[21] + D[20] +
1020 D[19] + D[18] + D[17] + D[16] + D[15] + D[14] +
1021 D[12] + D[11] + D[10] + D[9] + D[8] + D[7] +
1022 D[6] + D[5] + D[4] + D[3] + D[2] + D[1] +
1023 D[0] + C[0] + C[1] + C[2] + C[3] + C[4] +
1024 C[5] + C[6] + C[11] + C[12] + C[13] + C[14] +
1028 for (
int i = 0;
i < 16 ; ++
i) { tempC = tempC + ( myCRC[
i] <<
i ); }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
~L1TTwinMuxRawToDigi() override
Destructor.
int normBx(int bx_, int bxCnt_)
std::vector< long long int > amcsecmap_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
std::vector< std::array< short, 12 > > amcsec_
L1TTwinMuxRawToDigi(const edm::ParameterSet &pset)
Constructor.
void processFed(int twinmuxfed, int wheel, std::array< short, 12 > twinMuxAmcSec, edm::Handle< FEDRawDataCollection > data, L1MuDTChambPhContainer::Phi_Container &phi_data, L1MuDTChambThContainer::The_Container &the_data, L1MuDTChambPhContainer::Phi_Container &phi_out_data)
int radAngConversion(int radAng_)
void readline(int &lines, long &dataWord)
bool fillRawData(edm::Event &e, L1MuDTChambPhContainer::Phi_Container &phi_data, L1MuDTChambThContainer::The_Container &the_data, L1MuDTChambPhContainer::Phi_Container &phi_out_data)
Generate and fill FED raw data for a full event.
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
Abs< T >::type abs(const T &t)
std::vector< L1MuDTChambPhDigi > Phi_Container
std::vector< L1MuDTChambThDigi > The_Container
std::vector< int > wheels_
edm::EDGetTokenT< FEDRawDataCollection > Raw_token
edm::InputTag DTTM7InputTag_
int benAngConversion(int benAng_)
DecomposeProduct< arg, typename Div::arg > D
void calcCRC(long word, int &myC)
char data[epos_bytes_allocation]
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
static unsigned int const shift
void produce(edm::Event &e, const edm::EventSetup &c) override
Produce digis out of raw data.