91 debug =
pset.getUntrackedParameter<
bool>(
"Debug",
false);
106 produces<CSCWireDigiCollection>(
"MuonCSCWireDigi");
107 produces<CSCStripDigiCollection>(
"MuonCSCStripDigi");
108 produces<CSCComparatorDigiCollection>(
"MuonCSCComparatorDigi");
109 produces<CSCALCTDigiCollection>(
"MuonCSCALCTDigi");
110 produces<CSCCLCTDigiCollection>(
"MuonCSCCLCTDigi");
111 produces<CSCRPCDigiCollection>(
"MuonCSCRPCDigi");
112 produces<CSCCorrelatedLCTDigiCollection>(
"MuonCSCCorrelatedLCTDigi");
115 produces<CSCCFEBStatusDigiCollection>(
"MuonCSCCFEBStatusDigi");
116 produces<CSCTMBStatusDigiCollection>(
"MuonCSCTMBStatusDigi");
117 produces<CSCDMBStatusDigiCollection>(
"MuonCSCDMBStatusDigi");
118 produces<CSCALCTStatusDigiCollection>(
"MuonCSCALCTStatusDigi");
119 produces<CSCDDUStatusDigiCollection>(
"MuonCSCDDUStatusDigi");
120 produces<CSCDCCStatusDigiCollection>(
"MuonCSCDCCStatusDigi");
124 produces<CSCDCCFormatStatusDigiCollection>(
"MuonCSCDCCFormatStatusDigi");
145 ->setComment(
"# Define input to the unpacker");
146 desc.
add<
bool>(
"UseExaminer",
true)
147 ->setComment(
"# Use CSC examiner to check for corrupt or semi-corrupt data & avoid unpacker crashes");
148 desc.
add<
unsigned int>(
"ExaminerMask", 535557110)->setComment(
"# This mask is needed by the examiner");
149 desc.
add<
bool>(
"UseSelectiveUnpacking",
true)
150 ->setComment(
"# Use Examiner to unpack good chambers and skip only bad ones");
151 desc.
add<
unsigned int>(
"ErrorMask", 0)->setComment(
"# This mask simply reduces error reporting");
152 desc.
add<
bool>(
"UnpackStatusDigis",
false)->setComment(
"# Unpack general status digis?");
153 desc.
add<
bool>(
"UseFormatStatus",
true)->setComment(
"# Unpack FormatStatus digi?");
154 desc.
addUntracked<
bool>(
"Debug",
false)->setComment(
"# Turn on lots of output");
157 desc.
addUntracked<
bool>(
"VisualFEDInspect",
false)->setComment(
"# Visualization of raw data in corrupted events");
158 desc.
addUntracked<
bool>(
"VisualFEDShort",
false)->setComment(
"# Visualization of raw data in corrupted events");
161 descriptions.
add(
"muonCSCDCCUnpacker", desc);
162 descriptions.
setComment(
" This is the generic cfi file for CSC unpacking");
187 auto wireProduct = std::make_unique<CSCWireDigiCollection>();
188 auto stripProduct = std::make_unique<CSCStripDigiCollection>();
189 auto alctProduct = std::make_unique<CSCALCTDigiCollection>();
190 auto clctProduct = std::make_unique<CSCCLCTDigiCollection>();
191 auto comparatorProduct = std::make_unique<CSCComparatorDigiCollection>();
192 auto rpcProduct = std::make_unique<CSCRPCDigiCollection>();
193 auto corrlctProduct = std::make_unique<CSCCorrelatedLCTDigiCollection>();
194 auto cfebStatusProduct = std::make_unique<CSCCFEBStatusDigiCollection>();
195 auto dmbStatusProduct = std::make_unique<CSCDMBStatusDigiCollection>();
196 auto tmbStatusProduct = std::make_unique<CSCTMBStatusDigiCollection>();
197 auto dduStatusProduct = std::make_unique<CSCDDUStatusDigiCollection>();
198 auto dccStatusProduct = std::make_unique<CSCDCCStatusDigiCollection>();
199 auto alctStatusProduct = std::make_unique<CSCALCTStatusDigiCollection>();
201 auto formatStatusProduct = std::make_unique<CSCDCCFormatStatusDigiCollection>();
206 unsigned long dccBinCheckMask = 0x06080016;
209 const unsigned postLS1_map[] = {841, 842, 843, 844, 845, 846, 847, 848, 849, 831, 832, 833,
210 834, 835, 836, 837, 838, 839, 861, 862, 863, 864, 865, 866,
211 867, 868, 869, 851, 852, 853, 854, 855, 856, 857, 858, 859};
214 std::vector<unsigned int> cscFEDids;
218 cscFEDids.push_back(
id);
223 cscFEDids.push_back(
id);
226 for (
unsigned int i = 0;
i < cscFEDids.size();
i++)
228 unsigned int id = cscFEDids[
i];
236 unsigned long length = fedData.
size();
256 if (examiner !=
nullptr)
260 const short unsigned int*
data = (
short unsigned int*)fedData.
data();
262 LogTrace(
"badData") <<
"Length: " << length / 2;
292 formatStatusProduct->insertDigi(
CSCDetId(1, 1, 1, 1, 1),
306 short unsigned*
buf = (
short unsigned int*)fedData.
data();
316 ptrExaminer =
nullptr;
318 std::vector<CSCDDUEventData> fed_Data;
319 std::vector<CSCDDUEventData>* ptr_fedData = &fed_Data;
327 fed_Data.push_back(single_dduData);
343 fed_Data = dccData.dduData();
347 short unsigned* bufForDcc = (
short unsigned int*)fedData.
data();
352 dccStatusProduct->insertDigi(layer,
354 dccData.dccTrailer().data(),
356 bufForDcc[length / 2 - 4]));
360 const std::vector<CSCDDUEventData>& dduData = *ptr_fedData;
362 for (
unsigned int iDDU = 0; iDDU < dduData.size(); ++iDDU)
366 if (dduData[iDDU].trailer().errorstat() &
errorMask) {
367 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi")
368 <<
"FED ID" <<
id <<
" DDU# " << iDDU <<
" has serious error - no digis unpacked! " << std::hex
369 << dduData[iDDU].trailer().errorstat();
374 dduStatusProduct->insertDigi(
377 dduData[iDDU].trailer().
data(),
379 dduData[iDDU].trailer0()));
382 const std::vector<CSCEventData>& cscData = dduData[iDDU].cscData();
386 for (
unsigned int iCSC = 0; iCSC < cscData.size(); ++iCSC)
389 int vmecrate = cscData[iCSC].dmbHeader()->crateID();
390 int dmb = cscData[iCSC].dmbHeader()->dmbID();
396 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi") <<
"crate = " << vmecrate <<
"; dmb = " << dmb;
398 if ((vmecrate >= 1) && (vmecrate <= 60) && (dmb >= 1) && (dmb <= 10) && (dmb != 6)) {
399 layer = pcrate->
detId(vmecrate, dmb, icfeb, ilayer);
401 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi") <<
" detID input out of range!!! ";
402 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi") <<
" skipping chamber vme= " << vmecrate <<
" dmb= " << dmb;
409 unsigned int dduid = cscmapping->
ddu(layer);
410 if ((dduid >= 1) && (dduid <= 36))
411 dduid = postLS1_map[dduid - 1];
414 LogTrace(
"CSCDDUUnpacker|CSCRawToDigi") <<
" CSC->FED/DDU mapping inconsistency!!! ";
415 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi")
416 <<
"readout FED/DDU ID=" <<
id <<
" expected ID=" << dduid <<
", skipping chamber " << layer
417 <<
" vme= " << vmecrate <<
" dmb= " << dmb;
423 int nalct = cscData[iCSC].dmbHeader()->nalct();
424 bool goodALCT =
false;
426 if (nalct && cscData[iCSC].alctHeader()) {
427 if (cscData[iCSC].alctHeader()->
check()) {
430 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi") <<
"not storing ALCT digis; alct is bad or not present";
434 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi") <<
"nALCT==0 !!!";
439 std::vector<CSCALCTDigi> alctDigis = cscData[iCSC].alctHeader()->ALCTDigis();
441 std::vector<CSCALCTDigi> alctDigis_0;
442 for (
int unsigned i = 0;
i < alctDigis.size(); ++
i) {
443 if (alctDigis[
i].isValid())
444 alctDigis_0.push_back(alctDigis[
i]);
446 alctProduct->move(std::make_pair(alctDigis_0.begin(), alctDigis_0.end()), layer);
448 alctProduct->move(std::make_pair(alctDigis.begin(), alctDigis.end()), layer);
452 int nclct = cscData[iCSC].dmbHeader()->nclct();
453 bool goodTMB =
false;
455 if (nclct && cscData[iCSC].tmbData()) {
456 if (cscData[iCSC].tmbHeader()->
check()) {
457 if (cscData[iCSC].clctData()->
check())
460 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi") <<
"one of TMB checks failed! not storing TMB digis ";
464 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi") <<
"nCLCT==0 !!!";
469 std::vector<CSCCorrelatedLCTDigi> correlatedlctDigis =
470 cscData[iCSC].tmbHeader()->CorrelatedLCTDigis(layer.
rawId());
472 std::vector<CSCCorrelatedLCTDigi> correlatedlctDigis_0;
473 for (
int unsigned i = 0;
i < correlatedlctDigis.size(); ++
i) {
474 if (correlatedlctDigis[
i].isValid())
475 correlatedlctDigis_0.push_back(correlatedlctDigis[
i]);
477 corrlctProduct->move(std::make_pair(correlatedlctDigis_0.begin(), correlatedlctDigis_0.end()), layer);
479 corrlctProduct->move(std::make_pair(correlatedlctDigis.begin(), correlatedlctDigis.end()), layer);
481 std::vector<CSCCLCTDigi> clctDigis = cscData[iCSC].tmbHeader()->CLCTDigis(layer.
rawId());
483 std::vector<CSCCLCTDigi> clctDigis_0;
484 for (
int unsigned i = 0;
i < clctDigis.size(); ++
i) {
485 if (clctDigis[
i].isValid())
486 clctDigis_0.push_back(clctDigis[
i]);
488 clctProduct->move(std::make_pair(clctDigis_0.begin(), clctDigis_0.end()), layer);
490 clctProduct->move(std::make_pair(clctDigis.begin(), clctDigis.end()), layer);
493 if (cscData[iCSC].tmbData()->checkSize()) {
494 if (cscData[iCSC].tmbData()->hasRPC()) {
495 std::vector<CSCRPCDigi> rpcDigis = cscData[iCSC].tmbData()->rpcData()->digis();
496 rpcProduct->move(std::make_pair(rpcDigis.begin(), rpcDigis.end()), layer);
499 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi") <<
" TMBData check size failed!";
504 for (icfeb = 0; icfeb < 7; ++icfeb)
506 if (cscData[iCSC].cfebData(icfeb) !=
nullptr)
507 cfebStatusProduct->insertDigi(layer, cscData[iCSC].cfebData(icfeb)->statusDigi());
510 dmbStatusProduct->insertDigi(
513 tmbStatusProduct->insertDigi(
517 alctStatusProduct->insertDigi(
522 for (
int ilayer = 1; ilayer <= 6; ++ilayer) {
527 layer = pcrate->
detId(vmecrate, dmb, 0, ilayer);
529 std::vector<CSCWireDigi> wireDigis = cscData[iCSC].wireDigis(ilayer);
530 wireProduct->move(std::make_pair(wireDigis.begin(), wireDigis.end()), layer);
533 for (icfeb = 0; icfeb < 7; ++icfeb) {
534 layer = pcrate->
detId(vmecrate, dmb, icfeb, ilayer);
535 if (cscData[iCSC].cfebData(icfeb) && cscData[iCSC].cfebData(icfeb)->
check()) {
536 std::vector<CSCStripDigi> stripDigis;
537 cscData[iCSC].cfebData(icfeb)->digis(layer.
rawId(), stripDigis);
538 stripProduct->move(std::make_pair(stripDigis.begin(), stripDigis.end()), layer);
542 if (goodTMB && (cscData[iCSC].tmbHeader() !=
nullptr)) {
543 int nCFEBs = cscData[iCSC].tmbHeader()->NCFEBs();
544 for (icfeb = 0; icfeb < nCFEBs; ++icfeb) {
545 layer = pcrate->
detId(vmecrate, dmb, icfeb, ilayer);
546 std::vector<CSCComparatorDigi> comparatorDigis =
547 cscData[iCSC].clctData()->comparatorDigis(layer.
rawId(), icfeb);
550 layer = pcrate->
detId(vmecrate, dmb, 0, ilayer);
551 comparatorProduct->move(std::make_pair(comparatorDigis.begin(), comparatorDigis.end()), layer);
559 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi") <<
"ERROR! Examiner rejected FED #" <<
id;
566 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi")
567 <<
" Examiner errors:0x" << std::hex << examiner->
errors() <<
" & 0x" <<
examinerMask <<
" = "
575 if (examiner !=
nullptr)
580 e.put(
std::move(wireProduct),
"MuonCSCWireDigi");
581 e.put(
std::move(stripProduct),
"MuonCSCStripDigi");
582 e.put(
std::move(alctProduct),
"MuonCSCALCTDigi");
583 e.put(
std::move(clctProduct),
"MuonCSCCLCTDigi");
584 e.put(
std::move(comparatorProduct),
"MuonCSCComparatorDigi");
585 e.put(
std::move(rpcProduct),
"MuonCSCRPCDigi");
586 e.put(
std::move(corrlctProduct),
"MuonCSCCorrelatedLCTDigi");
589 e.put(
std::move(formatStatusProduct),
"MuonCSCDCCFormatStatusDigi");
592 e.put(
std::move(cfebStatusProduct),
"MuonCSCCFEBStatusDigi");
593 e.put(
std::move(dmbStatusProduct),
"MuonCSCDMBStatusDigi");
594 e.put(
std::move(tmbStatusProduct),
"MuonCSCTMBStatusDigi");
595 e.put(
std::move(dduStatusProduct),
"MuonCSCDDUStatusDigi");
596 e.put(
std::move(dccStatusProduct),
"MuonCSCDCCStatusDigi");
597 e.put(
std::move(alctStatusProduct),
"MuonCSCALCTStatusDigi");
600 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi") <<
"[CSCDCCUnpacker]: " <<
numOfEvents <<
" events processed ";
606 int hl,
int id,
int run,
int event,
bool fedshort,
bool fDump,
short unsigned int*
buf)
const {
607 std::cout << std::endl << std::endl << std::endl;
608 std::cout <<
"Run: " <<
run <<
" Event: " <<
event << std::endl;
612 <<
"(scroll down to see summary)" << std::endl;
614 std::cout <<
"Problem seems in FED-" <<
id <<
" "
615 <<
"(scroll down to see summary)" << std::endl;
616 std::cout <<
"********************************************************************************" << std::endl;
617 std::cout << hl <<
" words of data:" << std::endl;
621 std::vector<int> dcc_id;
624 for (
int i = 750;
i < 758;
i++)
627 for (
int i = 830;
i < 838;
i++)
630 char dcc_common[] =
"DCC-";
634 std::vector<int> ddu_id;
635 int ddu_h1_12_13 = 0;
636 for (
int i = 1;
i < 37;
i++)
639 char ddu_common[] =
"DDU-";
640 char ddu_header1[] =
"Header 1";
641 char ddu_header2[] =
"Header 2";
642 char ddu_header3[] =
"Header 3";
643 char ddu_trail1[] =
"Trailer 1", ddu_trail2[] =
"Trailer 2", ddu_trail3[] =
"Trailer 3";
645 char ddu_trailer1_bit[] = {
'8',
'0',
'0',
'0',
'f',
'f',
'f',
'f',
'8',
'0',
'0',
'0',
'8',
'0',
'0',
'0'};
646 char ddu_trailer3_bit[] = {
'a'};
648 char ddu_tr1_err_common[] =
"Incomplet";
652 char dmb_common[] =
"DMB", dmb_header1[] =
"Header 1", dmb_header2[] =
"Header 2";
653 char dmb_common_crate[] =
"crate:", dmb_common_slot[] =
"slot:";
654 char dmb_common_l1a[] =
"L1A:";
655 char dmb_header1_bit[] = {
'9',
'9',
'9',
'9'};
656 char dmb_header2_bit[] = {
'a',
'a',
'a',
'a'};
657 char dmb_tr1[] =
"Trailer 1", dmb_tr2[] =
"Trailer 2";
658 char dmb_tr1_bit[] = {
'f',
'f',
'f',
'f'}, dmb_tr2_bit[] = {
'e',
'e',
'e',
'e'};
663 char alct_common[] =
"ALCT", alct_header1[] =
"Header 1", alct_header2[] =
"Header 2";
664 char alct_common_bxn[] =
"BXN:";
665 char alct_common_wcnt2[] =
"| Actual word count:";
666 char alct_common_wcnt1[] =
"Expected word count:";
667 char alct_header1_bit[] = {
'd',
'd',
'd',
'd',
'b',
'0',
'a'};
668 char alct_header2_bit[] = {
'0',
'0',
'0',
'0'};
669 char alct_tr1[] =
"Trailer 1";
674 char tmb_common[] =
"TMB", tmb_header1[] =
"Header", tmb_tr1[] =
"Trailer";
675 char tmb_header1_bit[] = {
'd',
'd',
'd',
'd',
'b',
'0',
'c'};
676 char tmb_tr1_bit[] = {
'd',
'd',
'd',
'd',
'e',
'0',
'f'};
681 char cfeb_common[] =
"CFEB", cfeb_tr1[] =
"Trailer", cfeb_b[] =
"B-word";
682 char cfeb_common_sample[] =
"sample:";
689 int word_lines = hl / 4;
692 char tempbuf_short[17];
693 char sign1[] =
" --->| ";
696 int word_numbering = 0;
697 int ddu_inst_i = 0, ddu_inst_n = 0, ddu_inst_l1a = 0;
698 int ddu_inst_bxn = 0;
699 int dmb_inst_crate = 0, dmb_inst_slot = 0, dmb_inst_l1a = 0;
701 int alct_inst_l1a = 0;
702 int alct_inst_bxn = 0;
703 int alct_inst_wcnt1 = 0;
704 int alct_inst_wcnt2 = 0;
707 int tmb_inst_l1a = 0;
708 int tmb_inst_wcnt1 = 0;
709 int tmb_inst_wcnt2 = 0;
712 int dcc_h1_check = 0;
715 int ddu_h2_found = 0;
720 bool dcc_check =
false;
721 bool ddu_h2_check[sz1] = {
false};
722 bool ddu_h1_check =
false;
723 bool dmb_h1_check[sz1] = {
false};
724 bool dmb_h2_check[sz1] = {
false};
725 bool ddu_h2_h1 =
false;
726 bool ddu_tr1_check[sz1] = {
false};
727 bool alct_h1_check[sz1] = {
false};
728 bool alct_h2_check[sz1] = {
false};
729 bool alct_tr1_check[sz1] = {
false};
730 bool dmb_tr1_check[sz1] = {
false};
731 bool dmb_tr2_check[sz1] = {
false};
732 bool tmb_h1_check[sz1] = {
false};
733 bool tmb_tr1_check[sz1] = {
false};
734 bool cfeb_tr1_check[sz1] = {
false};
735 bool cfeb_b_check[sz1] = {
false};
736 bool ddu_tr1_bad_check[sz1] = {
false};
737 bool extraction = fedshort;
741 std::vector<int> ddu_h1_coll;
742 std::vector<int> ddu_h1_n_coll;
743 std::vector<int> ddu_h2_coll;
744 std::vector<int> ddu_h3_coll;
745 std::vector<int> ddu_t1_coll;
746 std::vector<int> ddu_t2_coll;
747 std::vector<int> ddu_t3_coll;
748 std::vector<int> ddu_l1a_coll;
749 std::vector<int> ddu_bxn_coll;
751 std::vector<int> dmb_h1_coll;
752 std::vector<int> dmb_h2_coll;
753 std::vector<int> dmb_t1_coll;
754 std::vector<int> dmb_t2_coll;
755 std::vector<int> dmb_crate_coll;
756 std::vector<int> dmb_slot_coll;
757 std::vector<int> dmb_l1a_coll;
759 std::vector<int> alct_h1_coll;
760 std::vector<int> alct_h2_coll;
761 std::vector<int> alct_t1_coll;
762 std::vector<int> alct_l1a_coll;
763 std::vector<int> alct_bxn_coll;
764 std::vector<int> alct_wcnt1_coll;
765 std::vector<int> alct_wcnt2_coll;
766 std::vector<int> alct_wcnt2_id_coll;
768 std::vector<int> tmb_h1_coll;
769 std::vector<int> tmb_t1_coll;
770 std::vector<int> tmb_l1a_coll;
771 std::vector<int> tmb_wcnt1_coll;
772 std::vector<int> tmb_wcnt2_coll;
774 std::vector<int> cfeb_t1_coll;
779 char dcc_header1[] =
"DCC Header 1";
780 char dcc_header2[] =
"DCC Header 2";
781 char dcc_trail1[] =
"DCC Trailer 1", dcc_trail1_bit[] = {
'e'};
782 char dcc_trail2[] =
"DCC Trailer 2", dcc_trail2_bit[] = {
'a'};
785 for (
int i = 0;
i < hl;
i++) {
787 for (
int j = -1;
j < 4;
j++) {
788 sprintf(tempbuf_short,
790 buf[
i + 4 * (
j - 1) + 3],
791 buf[
i + 4 * (
j - 1) + 2],
792 buf[
i + 4 * (
j - 1) + 1],
793 buf[
i + 4 * (
j - 1)]);
799 ddu_h2_check[
j] = ((
buf[
i + 4 * (
j - 1) + 1] == 0x8000) && (
buf[
i + 4 * (
j - 1) + 2] == 0x0001) &&
800 (
buf[
i + 4 * (
j - 1) + 3] == 0x8000));
802 ddu_tr1_check[
j] = ((tempbuf_short[0] == ddu_trailer1_bit[0]) && (tempbuf_short[1] == ddu_trailer1_bit[1]) &&
803 (tempbuf_short[2] == ddu_trailer1_bit[2]) && (tempbuf_short[3] == ddu_trailer1_bit[3]) &&
804 (tempbuf_short[4] == ddu_trailer1_bit[4]) && (tempbuf_short[5] == ddu_trailer1_bit[5]) &&
805 (tempbuf_short[6] == ddu_trailer1_bit[6]) && (tempbuf_short[7] == ddu_trailer1_bit[7]) &&
806 (tempbuf_short[8] == ddu_trailer1_bit[8]) && (tempbuf_short[9] == ddu_trailer1_bit[9]) &&
807 (tempbuf_short[10] == ddu_trailer1_bit[10]) && (tempbuf_short[11] == ddu_trailer1_bit[11]) &&
808 (tempbuf_short[12] == ddu_trailer1_bit[12]) && (tempbuf_short[13] == ddu_trailer1_bit[13]) &&
809 (tempbuf_short[14] == ddu_trailer1_bit[14]) && (tempbuf_short[15] == ddu_trailer1_bit[15]));
811 dmb_h1_check[
j] = ((tempbuf_short[0] == dmb_header1_bit[0]) && (tempbuf_short[4] == dmb_header1_bit[1]) &&
812 (tempbuf_short[8] == dmb_header1_bit[2]) && (tempbuf_short[12] == dmb_header1_bit[3]));
814 dmb_h2_check[
j] = ((tempbuf_short[0] == dmb_header2_bit[0]) && (tempbuf_short[4] == dmb_header2_bit[1]) &&
815 (tempbuf_short[8] == dmb_header2_bit[2]) && (tempbuf_short[12] == dmb_header2_bit[3]));
816 alct_h1_check[
j] = ((tempbuf_short[0] == alct_header1_bit[0]) && (tempbuf_short[4] == alct_header1_bit[1]) &&
817 (tempbuf_short[8] == alct_header1_bit[2]) && (tempbuf_short[12] == alct_header1_bit[3]) &&
818 (tempbuf_short[13] == alct_header1_bit[4]) && (tempbuf_short[14] == alct_header1_bit[5]) &&
819 (tempbuf_short[15] == alct_header1_bit[6]));
820 alct_h2_check[
j] = (((tempbuf_short[0] == alct_header2_bit[0]) && (tempbuf_short[1] == alct_header2_bit[1]) &&
821 (tempbuf_short[2] == alct_header2_bit[2]) && (tempbuf_short[3] == alct_header2_bit[3])) ||
822 ((tempbuf_short[4] == alct_header2_bit[0]) && (tempbuf_short[5] == alct_header2_bit[1]) &&
823 (tempbuf_short[6] == alct_header2_bit[2]) && (tempbuf_short[7] == alct_header2_bit[3])) ||
824 ((tempbuf_short[8] == alct_header2_bit[0]) && (tempbuf_short[9] == alct_header2_bit[1]) &&
825 (tempbuf_short[10] == alct_header2_bit[2]) && (tempbuf_short[11] == alct_header2_bit[3])) ||
826 ((tempbuf_short[12] == alct_header2_bit[0]) && (tempbuf_short[13] == alct_header2_bit[1]) &&
827 (tempbuf_short[14] == alct_header2_bit[2]) && (tempbuf_short[15] == alct_header2_bit[3]))
832 (((
buf[
i + 4 * (
j - 1)] & 0xFFFF) == 0xDE0D) && ((
buf[
i + 4 * (
j - 1) + 1] & 0xF800) == 0xD000) &&
833 ((
buf[
i + 4 * (
j - 1) + 2] & 0xF800) == 0xD000) && ((
buf[
i + 4 * (
j - 1) + 3] & 0xF000) == 0xD000));
835 dmb_tr1_check[
j] = ((tempbuf_short[0] == dmb_tr1_bit[0]) && (tempbuf_short[4] == dmb_tr1_bit[1]) &&
836 (tempbuf_short[8] == dmb_tr1_bit[2]) && (tempbuf_short[12] == dmb_tr1_bit[3]));
837 dmb_tr2_check[
j] = ((tempbuf_short[0] == dmb_tr2_bit[0]) && (tempbuf_short[4] == dmb_tr2_bit[1]) &&
838 (tempbuf_short[8] == dmb_tr2_bit[2]) && (tempbuf_short[12] == dmb_tr2_bit[3]));
840 tmb_h1_check[
j] = ((tempbuf_short[0] == tmb_header1_bit[0]) && (tempbuf_short[4] == tmb_header1_bit[1]) &&
841 (tempbuf_short[8] == tmb_header1_bit[2]) && (tempbuf_short[12] == tmb_header1_bit[3]) &&
842 (tempbuf_short[13] == tmb_header1_bit[4]) && (tempbuf_short[14] == tmb_header1_bit[5]) &&
843 (tempbuf_short[15] == tmb_header1_bit[6]));
844 tmb_tr1_check[
j] = ((tempbuf_short[0] == tmb_tr1_bit[0]) && (tempbuf_short[4] == tmb_tr1_bit[1]) &&
845 (tempbuf_short[8] == tmb_tr1_bit[2]) && (tempbuf_short[12] == tmb_tr1_bit[3]) &&
846 (tempbuf_short[13] == tmb_tr1_bit[4]) && (tempbuf_short[14] == tmb_tr1_bit[5]) &&
847 (tempbuf_short[15] == tmb_tr1_bit[6]));
850 (((
buf[
i + 4 * (
j - 1) + 1] & 0xF000) == 0x7000) && ((
buf[
i + 4 * (
j - 1) + 2] & 0xF000) == 0x7000) &&
851 ((
buf[
i + 4 * (
j - 1) + 1] != 0x7FFF) || (
buf[
i + 4 * (
j - 1) + 2] != 0x7FFF)) &&
852 ((
buf[
i + 4 * (
j - 1) + 3] == 0x7FFF) || ((
buf[
i + 4 * (
j - 1) + 3] &
buf[
i + 4 * (
j - 1)]) == 0x0 &&
853 (
buf[
i + 4 * (
j - 1) + 3] +
buf[
i + 4 * (
j - 1)] == 0x7FFF))));
855 (((
buf[
i + 4 * (
j - 1) + 3] & 0xF000) == 0xB000) && ((
buf[
i + 4 * (
j - 1) + 2] & 0xF000) == 0xB000) &&
856 ((
buf[
i + 4 * (
j - 1) + 1] & 0xF000) == 0xB000) && ((
buf[
i + 4 * (
j - 1)] = 3 & 0xF000) == 0xB000));
858 ddu_tr1_bad_check[
j] =
859 ((tempbuf_short[0] != ddu_trailer1_bit[0]) &&
862 (tempbuf_short[4] != ddu_trailer1_bit[4]) &&
865 (tempbuf_short[8] == ddu_trailer1_bit[8]) && (tempbuf_short[9] == ddu_trailer1_bit[9]) &&
866 (tempbuf_short[10] == ddu_trailer1_bit[10]) && (tempbuf_short[11] == ddu_trailer1_bit[11]) &&
867 (tempbuf_short[12] == ddu_trailer1_bit[12]) && (tempbuf_short[13] == ddu_trailer1_bit[13]) &&
868 (tempbuf_short[14] == ddu_trailer1_bit[14]) && (tempbuf_short[15] == ddu_trailer1_bit[15]));
872 ddu_h2_h1 = ddu_h2_check[2];
874 sprintf(tempbuf_short,
"%04x%04x%04x%04x",
buf[
i + 3],
buf[
i + 2],
buf[
i + 1],
buf[
i]);
877 ddu_h1_12_13 = (
buf[
i] >> 8);
878 for (
int kk = 0;
kk < 36;
kk++) {
879 if (((
buf[
i + 3] & 0xF000) == 0x5000) && (ddu_h1_12_13 == ddu_id[
kk]) && ddu_h2_h1) {
880 ddu_h1_coll.push_back(word_numbering);
881 ddu_h1_n_coll.push_back(ddu_id[
kk]);
882 ddu_inst_l1a = ((
buf[
i + 2] & 0xFFFF) + ((
buf[
i + 3] & 0x00FF) << 16));
883 ddu_l1a_coll.push_back(ddu_inst_l1a);
884 ddu_inst_bxn = (
buf[
i + 1] & 0xFFF0) >> 4;
885 ddu_bxn_coll.push_back(ddu_inst_bxn);
887 "%6i %04x %04x %04x %04x%s%s%i %s%s %s %i %s %i",
910 dcc_h1_id = (((
buf[
i + 1] << 12) & 0xF000) >> 4) + (
buf[
i] >> 8);
911 for (
int dcci = 0; dcci < 16; dcci++) {
912 if ((dcc_id[dcci] == dcc_h1_id) && (((
buf[
i + 3] & 0xF000) == 0x5000) && (!ddu_h1_check))) {
914 "%6i %04x %04x %04x %04x%s%s%i %s",
924 dcc_h1_check = word_numbering;
932 if (((word_numbering - 1) == dcc_h1_check) && ((
buf[
i + 3] & 0xFF00) == 0xD900)) {
934 "%6i %04x %04x %04x %04x%s%s",
944 }
else if ((word_numbering == word_lines - 1) && (tempbuf_short[0] == dcc_trail1_bit[0])) {
946 "%6i %04x %04x %04x %04x%s%s",
956 }
else if ((word_numbering == word_lines) && (tempbuf_short[0] == dcc_trail2_bit[0])) {
958 "%6i %04x %04x %04x %04x%s%s",
971 else if (ddu_h2_check[1]) {
972 ddu_inst_i = ddu_h1_n_coll.size();
973 if (ddu_inst_i > 0) {
974 ddu_inst_n = ddu_h1_n_coll[ddu_inst_i - 1];
977 "%6i %04x %04x %04x %04x%s%s%i %s",
987 ddu_h2_coll.push_back(word_numbering);
994 else if ((ddu_h2_check[0] && dmb_h1_check[2]) || (ddu_h2_check[0] && ddu_tr1_check[2])) {
995 ddu_inst_i = ddu_h1_n_coll.size();
996 if (ddu_inst_i > 0) {
997 ddu_inst_n = ddu_h1_n_coll[ddu_inst_i - 1];
1000 "%6i %04x %04x %04x %04x%s%s%i %s",
1010 ddu_h3_coll.push_back(word_numbering);
1018 else if (dmb_h1_check[1]) {
1021 dmb_inst_l1a = ((
buf[
i] & 0x0FFF) + ((
buf[
i + 1] & 0xFFF) << 12));
1022 dmb_l1a_coll.push_back(dmb_inst_l1a);
1023 if (dmb_h2_check[2]) {
1024 dmb_inst_crate = ((
buf[
i + 4 + 1] >> 4) & 0xFF);
1025 dmb_inst_slot = (
buf[
i + 4 + 1] & 0xF);
1026 dmb_crate_coll.push_back(dmb_inst_crate);
1027 dmb_slot_coll.push_back(dmb_inst_slot);
1030 "%6i %04x %04x %04x %04x%s%s %s%s%s %i %s %i %s %i",
1046 dmb_h1_coll.push_back(word_numbering);
1052 else if (dmb_h2_check[1]) {
1053 dmb_inst_crate = ((
buf[
i + 1] >> 4) & 0xFF);
1054 dmb_inst_slot = (
buf[
i + 1] & 0xF);
1055 dmb_h2_coll.push_back(word_numbering);
1056 if (dmb_h1_check[0])
1057 dmb_inst_l1a = ((
buf[
i - 4] & 0x0FFF) + ((
buf[
i - 4 + 1] & 0xFFF) << 12));
1059 "%6i %04x %04x %04x %04x%s%s %s%s%s %i %s %i %s %i",
1082 else if (ddu_tr1_check[1]) {
1083 ddu_inst_i = ddu_h1_n_coll.size();
1084 if (ddu_inst_i > 0) {
1085 ddu_inst_n = ddu_h1_n_coll[ddu_inst_i - 1];
1089 "%6i %04x %04x %04x %04x%s%s%i %s",
1099 ddu_t1_coll.push_back(word_numbering);
1105 else if (alct_h1_check[1]) {
1106 alct_start = word_numbering;
1107 alct_inst_l1a = (
buf[
i + 2] & 0x0FFF);
1108 alct_l1a_coll.push_back(alct_inst_l1a);
1110 "%6i %04x %04x %04x %04x%s%s %s%s %s %i",
1122 alct_h1_coll.push_back(word_numbering);
1127 else if ((alct_h1_check[0]) && (alct_h2_check[2])) {
1128 alct_inst_bxn = (
buf[
i] & 0x0FFF);
1129 alct_bxn_coll.push_back(alct_inst_bxn);
1131 "%6i %04x %04x %04x %04x%s%s %s%s%s %i",
1143 alct_h2_coll.push_back(word_numbering);
1149 else if (alct_tr1_check[1]) {
1150 alct_stop = word_numbering;
1151 if ((alct_start != 0) && (alct_stop != 0) && (alct_stop > alct_start)) {
1152 alct_inst_wcnt2 = 4 * (alct_stop - alct_start + 1);
1153 alct_wcnt2_coll.push_back(alct_inst_wcnt2);
1154 alct_wcnt2_id_coll.push_back(alct_start);
1156 alct_inst_wcnt1 = (
buf[
i + 3] & 0x7FF);
1157 alct_wcnt1_coll.push_back(alct_inst_wcnt1);
1159 "%6i %04x %04x %04x %04x%s%s %s%s%s %i %s %i",
1173 alct_t1_coll.push_back(word_numbering);
1176 alct_inst_wcnt2 = 0;
1182 else if ((ddu_h2_h1) && (tempbuf_short[0] == ddu_trailer3_bit[0])) {
1184 ddu_inst_i = ddu_h1_n_coll.size();
1185 if (ddu_inst_i > 0) {
1186 ddu_inst_n = ddu_h1_n_coll[ddu_inst_i - 1];
1190 "%6i %04x %04x %04x %04x%s%s%i %s",
1200 ddu_t3_coll.push_back(word_numbering);
1205 else if ((ddu_tr1_check[0]) && (tempbuf_short[0] != ddu_trailer3_bit[0])) {
1207 ddu_inst_i = ddu_h1_n_coll.size();
1208 if (ddu_inst_i > 0) {
1209 ddu_inst_n = ddu_h1_n_coll[ddu_inst_i - 1];
1213 "%6i %04x %04x %04x %04x%s%s%i %s",
1223 ddu_t2_coll.push_back(word_numbering);
1229 else if (dmb_tr1_check[1]) {
1231 "%6i %04x %04x %04x %04x%s%s %s",
1240 dmb_t1_coll.push_back(word_numbering);
1246 else if (dmb_tr2_check[1]) {
1248 "%6i %04x %04x %04x %04x%s%s %s",
1257 dmb_t2_coll.push_back(word_numbering);
1262 else if (tmb_h1_check[1]) {
1263 tmb_start = word_numbering;
1264 tmb_inst_l1a = (
buf[
i + 2] & 0x000F);
1265 tmb_l1a_coll.push_back(tmb_inst_l1a);
1267 "%6i %04x %04x %04x %04x%s%s %s%s%s %i",
1279 tmb_h1_coll.push_back(word_numbering);
1282 }
else if (tmb_tr1_check[1]) {
1283 tmb_stop = word_numbering;
1284 if ((tmb_start != 0) && (tmb_stop != 0) && (tmb_stop > tmb_start)) {
1285 tmb_inst_wcnt2 = 4 * (tmb_stop - tmb_start + 1);
1286 tmb_wcnt2_coll.push_back(tmb_inst_wcnt2);
1288 tmb_inst_wcnt1 = (
buf[
i + 3] & 0x7FF);
1289 tmb_wcnt1_coll.push_back(tmb_inst_wcnt1);
1291 "%6i %04x %04x %04x %04x%s%s %s%s%s %i %s %i",
1305 tmb_t1_coll.push_back(word_numbering);
1311 else if (cfeb_tr1_check[1]) {
1314 "%6i %04x %04x %04x %04x%s%s %s%s %s %i",
1326 cfeb_t1_coll.push_back(word_numbering);
1329 }
else if (cfeb_b_check[1]) {
1331 "%6i %04x %04x %04x %04x%s%s %s",
1346 else if (ddu_tr1_bad_check[1]) {
1347 ddu_inst_i = ddu_h1_n_coll.size();
1348 ddu_inst_n = ddu_h1_n_coll[ddu_inst_i - 1];
1350 "%6i %04x %04x %04x %04x%s%s%i %s %s",
1360 ddu_tr1_err_common);
1365 else if (extraction && (!ddu_h1_check) && (!dcc_check)) {
1367 sprintf(tempbuf,
"%6i %04x %04x %04x %04x", word_numbering,
buf[
i + 3],
buf[
i + 2],
buf[
i + 1],
buf[
i]);
1372 std::cout <<
"..................................................." << std::endl;
1377 else if ((!ddu_h1_check) && (!dcc_check)) {
1378 sprintf(tempbuf,
"%6i %04x %04x %04x %04x", word_numbering,
buf[
i + 3],
buf[
i + 2],
buf[
i + 1],
buf[
i]);
1383 ddu_h1_check =
false;
1387 std::cout <<
"********************************************************************************" << std::endl
1390 std::cout <<
"For complete output turn off VisualFEDShort in muonCSCDigis configuration file." << std::endl;
1391 std::cout <<
"********************************************************************************" << std::endl
1396 std::cout << ddu_h1_coll.size() <<
" " << ddu_common <<
" " << ddu_header1 <<
" "
1397 <<
"found" << std::endl;
1402 for (
unsigned int k = 0;
k < ddu_h1_coll.size(); ++
k) {
1409 <<
" " << ddu_h1_coll[
k] <<
" " << sign1 <<
" " << ddu_common <<
" " << ddu_h1_n_coll[
k] <<
" "
1410 << dmb_common_l1a <<
" " << ddu_l1a_coll[
k] <<
" " << alct_common_bxn <<
" " << ddu_bxn_coll[
k]
1415 std::cout <<
"||||||||||||||||||||" << std::endl;
1417 std::cout << ddu_h2_coll.size() <<
" " << ddu_common <<
" " << ddu_header2 <<
" "
1418 <<
"found" << std::endl;
1419 for (
unsigned int k = 0;
k < ddu_h2_coll.size(); ++
k)
1420 std::cout <<
"Line: " << ddu_h2_coll[
k] << std::endl;
1422 std::cout <<
"||||||||||||||||||||" << std::endl;
1424 std::cout << ddu_h3_coll.size() <<
" " << ddu_common <<
" " << ddu_header3 <<
" "
1425 <<
"found" << std::endl;
1426 for (
unsigned int k = 0;
k < ddu_h3_coll.size(); ++
k)
1427 std::cout <<
"Line: " << ddu_h3_coll[
k] << std::endl;
1429 std::cout <<
"||||||||||||||||||||" << std::endl;
1431 std::cout << ddu_t1_coll.size() <<
" " << ddu_common <<
" " << ddu_trail1 <<
" "
1432 <<
"found" << std::endl;
1433 for (
unsigned int k = 0;
k < ddu_t1_coll.size(); ++
k)
1434 std::cout <<
"Line: " << ddu_t1_coll[
k] << std::endl;
1436 std::cout <<
"||||||||||||||||||||" << std::endl;
1438 std::cout << ddu_t2_coll.size() <<
" " << ddu_common <<
" " << ddu_trail2 <<
" "
1439 <<
"found" << std::endl;
1440 for (
unsigned int k = 0;
k < ddu_t2_coll.size(); ++
k)
1441 std::cout <<
"Line: " << ddu_t2_coll[
k] << std::endl;
1443 std::cout <<
"||||||||||||||||||||" << std::endl;
1445 std::cout << ddu_t3_coll.size() <<
" " << ddu_common <<
" " << ddu_trail3 <<
" "
1446 <<
"found" << std::endl;
1447 for (
unsigned int k = 0;
k < ddu_t3_coll.size(); ++
k)
1448 std::cout <<
"Line: " << ddu_t3_coll[
k] << std::endl;
1450 std::cout <<
"||||||||||||||||||||" << std::endl;
1452 std::cout << dmb_h1_coll.size() <<
" " << dmb_common <<
" " << dmb_header1 <<
" "
1453 <<
"found" << std::endl;
1455 for (
unsigned int k = 0;
k < dmb_h1_coll.size(); ++
k) {
1462 <<
" " << dmb_h1_coll[
k] <<
" " << sign1 << dmb_common <<
" " << dmb_common_crate <<
" "
1463 << dmb_crate_coll[
k] <<
" " << dmb_common_slot <<
" " << dmb_slot_coll[
k] <<
" " << dmb_common_l1a <<
" "
1464 << dmb_l1a_coll[
k] << std::endl;
1467 std::cout <<
"||||||||||||||||||||" << std::endl;
1469 std::cout << dmb_h2_coll.size() <<
" " << dmb_common <<
" " << dmb_header2 <<
" "
1470 <<
"found" << std::endl;
1471 for (
unsigned int k = 0;
k < dmb_h2_coll.size(); ++
k)
1472 std::cout <<
"Line: " << dmb_h2_coll[
k] << std::endl;
1474 std::cout <<
"||||||||||||||||||||" << std::endl;
1476 std::cout << dmb_t1_coll.size() <<
" " << dmb_common <<
" " << dmb_tr1 <<
" "
1477 <<
"found" << std::endl;
1478 for (
unsigned int k = 0;
k < dmb_t1_coll.size(); ++
k)
1479 std::cout <<
"Line: " << dmb_t1_coll[
k] << std::endl;
1481 std::cout <<
"||||||||||||||||||||" << std::endl;
1483 std::cout << dmb_t2_coll.size() <<
" " << dmb_common <<
" " << dmb_tr2 <<
" "
1484 <<
"found" << std::endl;
1485 for (
unsigned int k = 0;
k < dmb_t2_coll.size(); ++
k)
1486 std::cout <<
"Line: " << dmb_t2_coll[
k] << std::endl;
1488 std::cout <<
"||||||||||||||||||||" << std::endl;
1490 std::cout << alct_h1_coll.size() <<
" " << alct_common <<
" " << alct_header1 <<
" "
1491 <<
"found" << std::endl;
1492 for (
unsigned int k = 0;
k < alct_h1_coll.size(); ++
k) {
1500 <<
" " << alct_h1_coll[
k] <<
" " << sign1 <<
" " << alct_common <<
" " << dmb_common_l1a <<
" "
1501 << alct_l1a_coll[
k] << std::endl;
1505 std::cout <<
"||||||||||||||||||||" << std::endl;
1507 std::cout << alct_h2_coll.size() <<
" " << alct_common <<
" " << alct_header2 <<
" "
1508 <<
"found" << std::endl;
1509 for (
unsigned int k = 0;
k < alct_h2_coll.size(); ++
k) {
1517 <<
" " << alct_h1_coll[
k] <<
" " << sign1 <<
" " << alct_common <<
" " << alct_common_bxn <<
" "
1518 << alct_bxn_coll[
k] << std::endl;
1522 std::cout <<
"||||||||||||||||||||" << std::endl;
1524 std::cout << alct_t1_coll.size() <<
" " << alct_common <<
" " << alct_tr1 <<
" "
1525 <<
"found" << std::endl;
1526 for (
unsigned int k = 0;
k < alct_t1_coll.size(); ++
k) {
1534 <<
" " << alct_t1_coll[
k] <<
" " << sign1 <<
" " << alct_common <<
" " << alct_common_wcnt1 <<
" "
1535 << alct_wcnt1_coll[
k] <<
" " << alct_common_wcnt2 <<
" ";
1536 if (!alct_wcnt2_coll.empty()) {
1537 std::cout << alct_wcnt2_coll[
k] << std::endl;
1539 std::cout <<
"Undefined (ALCT Header is not found) " << std::endl;
1544 std::cout <<
"||||||||||||||||||||" << std::endl;
1546 std::cout << tmb_h1_coll.size() <<
" " << tmb_common <<
" " << tmb_header1 <<
" "
1547 <<
"found" << std::endl;
1548 for (
unsigned int k = 0;
k < tmb_h1_coll.size(); ++
k) {
1556 <<
" " << tmb_h1_coll[
k] <<
" " << sign1 <<
" " << tmb_common <<
" " << dmb_common_l1a <<
" "
1557 << tmb_l1a_coll[
k] << std::endl;
1561 std::cout <<
"||||||||||||||||||||" << std::endl;
1563 std::cout << tmb_t1_coll.size() <<
" " << tmb_common <<
" " << tmb_tr1 <<
" "
1564 <<
"found" << std::endl;
1565 for (
unsigned int k = 0;
k < tmb_t1_coll.size(); ++
k) {
1573 <<
" " << tmb_t1_coll[
k] <<
" " << sign1 <<
" " << tmb_common <<
" " << alct_common_wcnt1 <<
" "
1574 << tmb_wcnt1_coll[
k] <<
" " << alct_common_wcnt2 <<
" " << tmb_wcnt2_coll[
k] << std::endl;
1578 std::cout <<
"||||||||||||||||||||" << std::endl;
1580 std::cout << cfeb_t1_coll.size() <<
" " << cfeb_common <<
" " << cfeb_tr1 <<
" "
1581 <<
"found" << std::endl;
1582 for (
unsigned int k = 0;
k < cfeb_t1_coll.size(); ++
k)
1583 std::cout <<
"Line: " << cfeb_t1_coll[
k] << std::endl;
1584 std::cout <<
"********************************************************************************" << std::endl;