77 void visual_raw(
int hl,
int id,
int run,
int event,
bool fedshort,
bool fDump,
short unsigned int*
buf)
const;
105 crateToken = esConsumes<CSCCrateMap, CSCCrateMapRcd>();
106 cscmapToken = esConsumes<CSCChamberMap, CSCChamberMapRcd>();
121 debug =
pset.getUntrackedParameter<
bool>(
"Debug",
false);
136 produces<CSCWireDigiCollection>(
"MuonCSCWireDigi");
137 produces<CSCStripDigiCollection>(
"MuonCSCStripDigi");
138 produces<CSCComparatorDigiCollection>(
"MuonCSCComparatorDigi");
139 produces<CSCALCTDigiCollection>(
"MuonCSCALCTDigi");
140 produces<CSCCLCTDigiCollection>(
"MuonCSCCLCTDigi");
141 produces<CSCRPCDigiCollection>(
"MuonCSCRPCDigi");
142 produces<CSCCorrelatedLCTDigiCollection>(
"MuonCSCCorrelatedLCTDigi");
145 produces<CSCCFEBStatusDigiCollection>(
"MuonCSCCFEBStatusDigi");
146 produces<CSCTMBStatusDigiCollection>(
"MuonCSCTMBStatusDigi");
147 produces<CSCDMBStatusDigiCollection>(
"MuonCSCDMBStatusDigi");
148 produces<CSCALCTStatusDigiCollection>(
"MuonCSCALCTStatusDigi");
149 produces<CSCDDUStatusDigiCollection>(
"MuonCSCDDUStatusDigi");
150 produces<CSCDCCStatusDigiCollection>(
"MuonCSCDCCStatusDigi");
154 produces<CSCDCCFormatStatusDigiCollection>(
"MuonCSCDCCFormatStatusDigi");
158 produces<GEMPadDigiClusterCollection>(
"MuonGEMPadDigiCluster");
179 ->setComment(
"# Define input to the unpacker");
180 desc.add<
bool>(
"UseExaminer",
true)
181 ->setComment(
"# Use CSC examiner to check for corrupt or semi-corrupt data & avoid unpacker crashes");
182 desc.add<
unsigned int>(
"ExaminerMask", 535557110)->setComment(
"# This mask is needed by the examiner");
183 desc.add<
bool>(
"UseSelectiveUnpacking",
true)
184 ->setComment(
"# Use Examiner to unpack good chambers and skip only bad ones");
185 desc.add<
unsigned int>(
"ErrorMask", 0)->setComment(
"# This mask simply reduces error reporting");
186 desc.add<
bool>(
"UnpackStatusDigis",
false)->setComment(
"# Unpack general status digis?");
187 desc.add<
bool>(
"UseFormatStatus",
true)->setComment(
"# Unpack FormatStatus digi?");
188 desc.add<
bool>(
"useGEMs",
false)->setComment(
"Unpack GEM trigger data");
189 desc.addUntracked<
bool>(
"Debug",
false)->setComment(
"# Turn on lots of output");
190 desc.addUntracked<
bool>(
"PrintEventNumber",
false);
191 desc.addUntracked<
bool>(
"runDQM",
false);
192 desc.addUntracked<
bool>(
"VisualFEDInspect",
false)->setComment(
"# Visualization of raw data in corrupted events");
193 desc.addUntracked<
bool>(
"VisualFEDShort",
false)->setComment(
"# Visualization of raw data in corrupted events");
194 desc.addUntracked<
bool>(
"FormatedEventDump",
false);
195 desc.addUntracked<
bool>(
"SuppressZeroLCT",
true);
196 descriptions.
add(
"muonCSCDCCUnpacker",
desc);
197 descriptions.
setComment(
" This is the generic cfi file for CSC unpacking");
220 auto wireProduct = std::make_unique<CSCWireDigiCollection>();
221 auto stripProduct = std::make_unique<CSCStripDigiCollection>();
222 auto alctProduct = std::make_unique<CSCALCTDigiCollection>();
223 auto clctProduct = std::make_unique<CSCCLCTDigiCollection>();
224 auto comparatorProduct = std::make_unique<CSCComparatorDigiCollection>();
225 auto rpcProduct = std::make_unique<CSCRPCDigiCollection>();
226 auto corrlctProduct = std::make_unique<CSCCorrelatedLCTDigiCollection>();
227 auto cfebStatusProduct = std::make_unique<CSCCFEBStatusDigiCollection>();
228 auto dmbStatusProduct = std::make_unique<CSCDMBStatusDigiCollection>();
229 auto tmbStatusProduct = std::make_unique<CSCTMBStatusDigiCollection>();
230 auto dduStatusProduct = std::make_unique<CSCDDUStatusDigiCollection>();
231 auto dccStatusProduct = std::make_unique<CSCDCCStatusDigiCollection>();
232 auto alctStatusProduct = std::make_unique<CSCALCTStatusDigiCollection>();
234 auto formatStatusProduct = std::make_unique<CSCDCCFormatStatusDigiCollection>();
236 auto gemProduct = std::make_unique<GEMPadDigiClusterCollection>();
241 unsigned long dccBinCheckMask = 0x06080016;
244 const unsigned postLS1_map[] = {841, 842, 843, 844, 845, 846, 847, 848, 849, 831, 832, 833,
245 834, 835, 836, 837, 838, 839, 861, 862, 863, 864, 865, 866,
246 867, 868, 869, 851, 852, 853, 854, 855, 856, 857, 858, 859};
249 std::vector<unsigned int> cscFEDids;
253 cscFEDids.push_back(
id);
258 cscFEDids.push_back(
id);
261 for (
unsigned int i = 0;
i < cscFEDids.size();
i++)
263 unsigned int id = cscFEDids[
i];
271 unsigned long length = fedData.
size();
291 if (examiner !=
nullptr)
295 const short unsigned int*
data = (
short unsigned int*)fedData.
data();
297 LogTrace(
"badData") <<
"Length: " << length / 2;
327 formatStatusProduct->insertDigi(
CSCDetId(1, 1, 1, 1, 1),
341 short unsigned*
buf = (
short unsigned int*)fedData.
data();
351 ptrExaminer =
nullptr;
353 std::vector<CSCDDUEventData> fed_Data;
354 std::vector<CSCDDUEventData>* ptr_fedData = &fed_Data;
362 fed_Data.push_back(single_dduData);
378 fed_Data = dccData.dduData();
382 short unsigned* bufForDcc = (
short unsigned int*)fedData.
data();
387 dccStatusProduct->insertDigi(layer,
389 dccData.dccTrailer().data(),
391 bufForDcc[length / 2 - 4]));
395 const std::vector<CSCDDUEventData>& dduData = *ptr_fedData;
397 for (
unsigned int iDDU = 0; iDDU < dduData.size(); ++iDDU)
401 if (dduData[iDDU].trailer().errorstat() &
errorMask) {
402 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi")
403 <<
"FED ID" <<
id <<
" DDU# " << iDDU <<
" has serious error - no digis unpacked! " << std::hex
404 << dduData[iDDU].trailer().errorstat();
409 dduStatusProduct->insertDigi(
412 dduData[iDDU].trailer().
data(),
414 dduData[iDDU].trailer0()));
417 const std::vector<CSCEventData>& cscData = dduData[iDDU].cscData();
421 for (
unsigned int iCSC = 0; iCSC < cscData.size(); ++iCSC)
424 int vmecrate = cscData[iCSC].dmbHeader()->crateID();
425 int dmb = cscData[iCSC].dmbHeader()->dmbID();
431 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi") <<
"crate = " << vmecrate <<
"; dmb = " << dmb;
433 if ((vmecrate >= 1) && (vmecrate <= 60) && (dmb >= 1) && (dmb <= 10) && (dmb != 6)) {
434 layer = pcrate->
detId(vmecrate, dmb, icfeb, ilayer);
436 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi") <<
" detID input out of range!!! ";
437 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi") <<
" skipping chamber vme= " << vmecrate <<
" dmb= " << dmb;
444 unsigned int dduid = cscmapping->
ddu(layer);
445 if ((dduid >= 1) && (dduid <= 36))
446 dduid = postLS1_map[dduid - 1];
449 LogTrace(
"CSCDDUUnpacker|CSCRawToDigi") <<
" CSC->FED/DDU mapping inconsistency!!! ";
450 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi")
451 <<
"readout FED/DDU ID=" <<
id <<
" expected ID=" << dduid <<
", skipping chamber " << layer
452 <<
" vme= " << vmecrate <<
" dmb= " << dmb;
458 int nalct = cscData[iCSC].dmbHeader()->nalct();
459 bool goodALCT =
false;
461 if (nalct && cscData[iCSC].alctHeader()) {
462 if (cscData[iCSC].alctHeader()->
check()) {
465 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi") <<
"not storing ALCT digis; alct is bad or not present";
469 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi") <<
"nALCT==0 !!!";
474 std::vector<CSCALCTDigi> alctDigis = cscData[iCSC].alctHeader()->ALCTDigis();
476 std::vector<CSCALCTDigi> alctDigis_0;
477 for (
int unsigned i = 0;
i < alctDigis.size(); ++
i) {
478 if (alctDigis[
i].isValid())
479 alctDigis_0.push_back(alctDigis[
i]);
481 alctProduct->move(std::make_pair(alctDigis_0.begin(), alctDigis_0.end()), layer);
483 alctProduct->move(std::make_pair(alctDigis.begin(), alctDigis.end()), layer);
487 int nclct = cscData[iCSC].dmbHeader()->nclct();
488 bool goodTMB =
false;
490 if (nclct && cscData[iCSC].tmbData()) {
491 if (cscData[iCSC].tmbHeader()->
check()) {
492 if (cscData[iCSC].comparatorData()->
check())
495 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi") <<
"one of TMB checks failed! not storing TMB digis ";
499 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi") <<
"nCLCT==0 !!!";
504 std::vector<CSCCorrelatedLCTDigi> correlatedlctDigis =
505 cscData[iCSC].tmbHeader()->CorrelatedLCTDigis(layer.
rawId());
507 std::vector<CSCCorrelatedLCTDigi> correlatedlctDigis_0;
508 for (
int unsigned i = 0;
i < correlatedlctDigis.size(); ++
i) {
509 if (correlatedlctDigis[
i].isValid())
510 correlatedlctDigis_0.push_back(correlatedlctDigis[
i]);
512 corrlctProduct->move(std::make_pair(correlatedlctDigis_0.begin(), correlatedlctDigis_0.end()), layer);
514 corrlctProduct->move(std::make_pair(correlatedlctDigis.begin(), correlatedlctDigis.end()), layer);
516 std::vector<CSCCLCTDigi> clctDigis = cscData[iCSC].tmbHeader()->CLCTDigis(layer.
rawId());
518 std::vector<CSCCLCTDigi> clctDigis_0;
519 for (
int unsigned i = 0;
i < clctDigis.size(); ++
i) {
520 if (clctDigis[
i].isValid())
521 clctDigis_0.push_back(clctDigis[
i]);
523 clctProduct->move(std::make_pair(clctDigis_0.begin(), clctDigis_0.end()), layer);
525 clctProduct->move(std::make_pair(clctDigis.begin(), clctDigis.end()), layer);
528 if (cscData[iCSC].tmbData()->checkSize()) {
529 if (cscData[iCSC].tmbData()->hasRPC()) {
530 std::vector<CSCRPCDigi> rpcDigis = cscData[iCSC].tmbData()->rpcData()->digis();
531 rpcProduct->move(std::make_pair(rpcDigis.begin(), rpcDigis.end()), layer);
534 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi") <<
" TMBData check size failed!";
539 for (icfeb = 0; icfeb < 7; ++icfeb)
541 if (cscData[iCSC].cfebData(icfeb) !=
nullptr)
542 cfebStatusProduct->insertDigi(layer, cscData[iCSC].cfebData(icfeb)->statusDigi());
545 dmbStatusProduct->insertDigi(
548 tmbStatusProduct->insertDigi(
552 alctStatusProduct->insertDigi(
557 for (
int ilayer = 1; ilayer <= 6; ++ilayer) {
562 layer = pcrate->
detId(vmecrate, dmb, 0, ilayer);
564 std::vector<CSCWireDigi> wireDigis = cscData[iCSC].wireDigis(ilayer);
565 wireProduct->move(std::make_pair(wireDigis.begin(), wireDigis.end()), layer);
568 for (icfeb = 0; icfeb < 7; ++icfeb) {
569 layer = pcrate->
detId(vmecrate, dmb, icfeb, ilayer);
570 if (cscData[iCSC].cfebData(icfeb) && cscData[iCSC].cfebData(icfeb)->
check()) {
571 std::vector<CSCStripDigi> stripDigis;
572 cscData[iCSC].cfebData(icfeb)->digis(layer.
rawId(), stripDigis);
573 stripProduct->move(std::make_pair(stripDigis.begin(), stripDigis.end()), layer);
577 if (goodTMB && (cscData[iCSC].tmbHeader() !=
nullptr)) {
578 int nCFEBs = cscData[iCSC].tmbHeader()->NCFEBs();
579 for (icfeb = 0; icfeb < nCFEBs; ++icfeb) {
580 layer = pcrate->
detId(vmecrate, dmb, icfeb, ilayer);
581 std::vector<CSCComparatorDigi> comparatorDigis =
582 cscData[iCSC].comparatorData()->comparatorDigis(layer.
rawId(), icfeb);
585 layer = pcrate->
detId(vmecrate, dmb, 0, ilayer);
586 comparatorProduct->move(std::make_pair(comparatorDigis.begin(), comparatorDigis.end()), layer);
594 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi") <<
"ERROR! Examiner rejected FED #" <<
id;
601 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi")
602 <<
" Examiner errors:0x" << std::hex << examiner->
errors() <<
" & 0x" <<
examinerMask <<
" = "
610 if (examiner !=
nullptr)
615 e.put(
std::move(wireProduct),
"MuonCSCWireDigi");
616 e.put(
std::move(stripProduct),
"MuonCSCStripDigi");
617 e.put(
std::move(alctProduct),
"MuonCSCALCTDigi");
618 e.put(
std::move(clctProduct),
"MuonCSCCLCTDigi");
619 e.put(
std::move(comparatorProduct),
"MuonCSCComparatorDigi");
620 e.put(
std::move(rpcProduct),
"MuonCSCRPCDigi");
621 e.put(
std::move(corrlctProduct),
"MuonCSCCorrelatedLCTDigi");
624 e.put(
std::move(formatStatusProduct),
"MuonCSCDCCFormatStatusDigi");
627 e.put(
std::move(cfebStatusProduct),
"MuonCSCCFEBStatusDigi");
628 e.put(
std::move(dmbStatusProduct),
"MuonCSCDMBStatusDigi");
629 e.put(
std::move(tmbStatusProduct),
"MuonCSCTMBStatusDigi");
630 e.put(
std::move(dduStatusProduct),
"MuonCSCDDUStatusDigi");
631 e.put(
std::move(dccStatusProduct),
"MuonCSCDCCStatusDigi");
632 e.put(
std::move(alctStatusProduct),
"MuonCSCALCTStatusDigi");
635 e.put(
std::move(gemProduct),
"MuonGEMPadDigiCluster");
638 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi") <<
"[CSCDCCUnpacker]: " <<
numOfEvents <<
" events processed ";
644 int hl,
int id,
int run,
int event,
bool fedshort,
bool fDump,
short unsigned int*
buf)
const {
645 std::cout << std::endl << std::endl << std::endl;
646 std::cout <<
"Run: " <<
run <<
" Event: " <<
event << std::endl;
650 <<
"(scroll down to see summary)" << std::endl;
652 std::cout <<
"Problem seems in FED-" <<
id <<
" "
653 <<
"(scroll down to see summary)" << std::endl;
654 std::cout <<
"********************************************************************************" << std::endl;
655 std::cout << hl <<
" words of data:" << std::endl;
659 std::vector<int> dcc_id;
662 for (
int i = 750;
i < 758;
i++)
665 for (
int i = 830;
i < 838;
i++)
668 char dcc_common[] =
"DCC-";
672 std::vector<int> ddu_id;
673 int ddu_h1_12_13 = 0;
674 for (
int i = 1;
i < 37;
i++)
677 char ddu_common[] =
"DDU-";
678 char ddu_header1[] =
"Header 1";
679 char ddu_header2[] =
"Header 2";
680 char ddu_header3[] =
"Header 3";
681 char ddu_trail1[] =
"Trailer 1", ddu_trail2[] =
"Trailer 2", ddu_trail3[] =
"Trailer 3";
683 char ddu_trailer1_bit[] = {
'8',
'0',
'0',
'0',
'f',
'f',
'f',
'f',
'8',
'0',
'0',
'0',
'8',
'0',
'0',
'0'};
684 char ddu_trailer3_bit[] = {
'a'};
686 char ddu_tr1_err_common[] =
"Incomplet";
690 char dmb_common[] =
"DMB", dmb_header1[] =
"Header 1", dmb_header2[] =
"Header 2";
691 char dmb_common_crate[] =
"crate:", dmb_common_slot[] =
"slot:";
692 char dmb_common_l1a[] =
"L1A:";
693 char dmb_header1_bit[] = {
'9',
'9',
'9',
'9'};
694 char dmb_header2_bit[] = {
'a',
'a',
'a',
'a'};
695 char dmb_tr1[] =
"Trailer 1", dmb_tr2[] =
"Trailer 2";
696 char dmb_tr1_bit[] = {
'f',
'f',
'f',
'f'}, dmb_tr2_bit[] = {
'e',
'e',
'e',
'e'};
701 char alct_common[] =
"ALCT", alct_header1[] =
"Header 1", alct_header2[] =
"Header 2";
702 char alct_common_bxn[] =
"BXN:";
703 char alct_common_wcnt2[] =
"| Actual word count:";
704 char alct_common_wcnt1[] =
"Expected word count:";
705 char alct_header1_bit[] = {
'd',
'd',
'd',
'd',
'b',
'0',
'a'};
706 char alct_header2_bit[] = {
'0',
'0',
'0',
'0'};
707 char alct_tr1[] =
"Trailer 1";
712 char tmb_common[] =
"TMB", tmb_header1[] =
"Header", tmb_tr1[] =
"Trailer";
713 char tmb_header1_bit[] = {
'd',
'd',
'd',
'd',
'b',
'0',
'c'};
714 char tmb_tr1_bit[] = {
'd',
'd',
'd',
'd',
'e',
'0',
'f'};
719 char cfeb_common[] =
"CFEB", cfeb_tr1[] =
"Trailer", cfeb_b[] =
"B-word";
720 char cfeb_common_sample[] =
"sample:";
727 int word_lines = hl / 4;
730 char tempbuf_short[17];
731 char sign1[] =
" --->| ";
734 int word_numbering = 0;
735 int ddu_inst_i = 0, ddu_inst_n = 0, ddu_inst_l1a = 0;
736 int ddu_inst_bxn = 0;
737 int dmb_inst_crate = 0, dmb_inst_slot = 0, dmb_inst_l1a = 0;
739 int alct_inst_l1a = 0;
740 int alct_inst_bxn = 0;
741 int alct_inst_wcnt1 = 0;
742 int alct_inst_wcnt2 = 0;
745 int tmb_inst_l1a = 0;
746 int tmb_inst_wcnt1 = 0;
747 int tmb_inst_wcnt2 = 0;
750 int dcc_h1_check = 0;
753 int ddu_h2_found = 0;
758 bool dcc_check =
false;
759 bool ddu_h2_check[sz1] = {
false};
760 bool ddu_h1_check =
false;
761 bool dmb_h1_check[sz1] = {
false};
762 bool dmb_h2_check[sz1] = {
false};
763 bool ddu_h2_h1 =
false;
764 bool ddu_tr1_check[sz1] = {
false};
765 bool alct_h1_check[sz1] = {
false};
766 bool alct_h2_check[sz1] = {
false};
767 bool alct_tr1_check[sz1] = {
false};
768 bool dmb_tr1_check[sz1] = {
false};
769 bool dmb_tr2_check[sz1] = {
false};
770 bool tmb_h1_check[sz1] = {
false};
771 bool tmb_tr1_check[sz1] = {
false};
772 bool cfeb_tr1_check[sz1] = {
false};
773 bool cfeb_b_check[sz1] = {
false};
774 bool ddu_tr1_bad_check[sz1] = {
false};
775 bool extraction = fedshort;
779 std::vector<int> ddu_h1_coll;
780 std::vector<int> ddu_h1_n_coll;
781 std::vector<int> ddu_h2_coll;
782 std::vector<int> ddu_h3_coll;
783 std::vector<int> ddu_t1_coll;
784 std::vector<int> ddu_t2_coll;
785 std::vector<int> ddu_t3_coll;
786 std::vector<int> ddu_l1a_coll;
787 std::vector<int> ddu_bxn_coll;
789 std::vector<int> dmb_h1_coll;
790 std::vector<int> dmb_h2_coll;
791 std::vector<int> dmb_t1_coll;
792 std::vector<int> dmb_t2_coll;
793 std::vector<int> dmb_crate_coll;
794 std::vector<int> dmb_slot_coll;
795 std::vector<int> dmb_l1a_coll;
797 std::vector<int> alct_h1_coll;
798 std::vector<int> alct_h2_coll;
799 std::vector<int> alct_t1_coll;
800 std::vector<int> alct_l1a_coll;
801 std::vector<int> alct_bxn_coll;
802 std::vector<int> alct_wcnt1_coll;
803 std::vector<int> alct_wcnt2_coll;
804 std::vector<int> alct_wcnt2_id_coll;
806 std::vector<int> tmb_h1_coll;
807 std::vector<int> tmb_t1_coll;
808 std::vector<int> tmb_l1a_coll;
809 std::vector<int> tmb_wcnt1_coll;
810 std::vector<int> tmb_wcnt2_coll;
812 std::vector<int> cfeb_t1_coll;
817 char dcc_header1[] =
"DCC Header 1";
818 char dcc_header2[] =
"DCC Header 2";
819 char dcc_trail1[] =
"DCC Trailer 1", dcc_trail1_bit[] = {
'e'};
820 char dcc_trail2[] =
"DCC Trailer 2", dcc_trail2_bit[] = {
'a'};
823 for (
int i = 0;
i < hl;
i++) {
825 for (
int j = -1;
j < 4;
j++) {
826 sprintf(tempbuf_short,
828 buf[
i + 4 * (
j - 1) + 3],
829 buf[
i + 4 * (
j - 1) + 2],
830 buf[
i + 4 * (
j - 1) + 1],
831 buf[
i + 4 * (
j - 1)]);
837 ddu_h2_check[
j] = ((
buf[
i + 4 * (
j - 1) + 1] == 0x8000) && (
buf[
i + 4 * (
j - 1) + 2] == 0x0001) &&
838 (
buf[
i + 4 * (
j - 1) + 3] == 0x8000));
840 ddu_tr1_check[
j] = ((tempbuf_short[0] == ddu_trailer1_bit[0]) && (tempbuf_short[1] == ddu_trailer1_bit[1]) &&
841 (tempbuf_short[2] == ddu_trailer1_bit[2]) && (tempbuf_short[3] == ddu_trailer1_bit[3]) &&
842 (tempbuf_short[4] == ddu_trailer1_bit[4]) && (tempbuf_short[5] == ddu_trailer1_bit[5]) &&
843 (tempbuf_short[6] == ddu_trailer1_bit[6]) && (tempbuf_short[7] == ddu_trailer1_bit[7]) &&
844 (tempbuf_short[8] == ddu_trailer1_bit[8]) && (tempbuf_short[9] == ddu_trailer1_bit[9]) &&
845 (tempbuf_short[10] == ddu_trailer1_bit[10]) && (tempbuf_short[11] == ddu_trailer1_bit[11]) &&
846 (tempbuf_short[12] == ddu_trailer1_bit[12]) && (tempbuf_short[13] == ddu_trailer1_bit[13]) &&
847 (tempbuf_short[14] == ddu_trailer1_bit[14]) && (tempbuf_short[15] == ddu_trailer1_bit[15]));
849 dmb_h1_check[
j] = ((tempbuf_short[0] == dmb_header1_bit[0]) && (tempbuf_short[4] == dmb_header1_bit[1]) &&
850 (tempbuf_short[8] == dmb_header1_bit[2]) && (tempbuf_short[12] == dmb_header1_bit[3]));
852 dmb_h2_check[
j] = ((tempbuf_short[0] == dmb_header2_bit[0]) && (tempbuf_short[4] == dmb_header2_bit[1]) &&
853 (tempbuf_short[8] == dmb_header2_bit[2]) && (tempbuf_short[12] == dmb_header2_bit[3]));
854 alct_h1_check[
j] = ((tempbuf_short[0] == alct_header1_bit[0]) && (tempbuf_short[4] == alct_header1_bit[1]) &&
855 (tempbuf_short[8] == alct_header1_bit[2]) && (tempbuf_short[12] == alct_header1_bit[3]) &&
856 (tempbuf_short[13] == alct_header1_bit[4]) && (tempbuf_short[14] == alct_header1_bit[5]) &&
857 (tempbuf_short[15] == alct_header1_bit[6]));
858 alct_h2_check[
j] = (((tempbuf_short[0] == alct_header2_bit[0]) && (tempbuf_short[1] == alct_header2_bit[1]) &&
859 (tempbuf_short[2] == alct_header2_bit[2]) && (tempbuf_short[3] == alct_header2_bit[3])) ||
860 ((tempbuf_short[4] == alct_header2_bit[0]) && (tempbuf_short[5] == alct_header2_bit[1]) &&
861 (tempbuf_short[6] == alct_header2_bit[2]) && (tempbuf_short[7] == alct_header2_bit[3])) ||
862 ((tempbuf_short[8] == alct_header2_bit[0]) && (tempbuf_short[9] == alct_header2_bit[1]) &&
863 (tempbuf_short[10] == alct_header2_bit[2]) && (tempbuf_short[11] == alct_header2_bit[3])) ||
864 ((tempbuf_short[12] == alct_header2_bit[0]) && (tempbuf_short[13] == alct_header2_bit[1]) &&
865 (tempbuf_short[14] == alct_header2_bit[2]) && (tempbuf_short[15] == alct_header2_bit[3]))
870 (((
buf[
i + 4 * (
j - 1)] & 0xFFFF) == 0xDE0D) && ((
buf[
i + 4 * (
j - 1) + 1] & 0xF800) == 0xD000) &&
871 ((
buf[
i + 4 * (
j - 1) + 2] & 0xF800) == 0xD000) && ((
buf[
i + 4 * (
j - 1) + 3] & 0xF000) == 0xD000));
873 dmb_tr1_check[
j] = ((tempbuf_short[0] == dmb_tr1_bit[0]) && (tempbuf_short[4] == dmb_tr1_bit[1]) &&
874 (tempbuf_short[8] == dmb_tr1_bit[2]) && (tempbuf_short[12] == dmb_tr1_bit[3]));
875 dmb_tr2_check[
j] = ((tempbuf_short[0] == dmb_tr2_bit[0]) && (tempbuf_short[4] == dmb_tr2_bit[1]) &&
876 (tempbuf_short[8] == dmb_tr2_bit[2]) && (tempbuf_short[12] == dmb_tr2_bit[3]));
878 tmb_h1_check[
j] = ((tempbuf_short[0] == tmb_header1_bit[0]) && (tempbuf_short[4] == tmb_header1_bit[1]) &&
879 (tempbuf_short[8] == tmb_header1_bit[2]) && (tempbuf_short[12] == tmb_header1_bit[3]) &&
880 (tempbuf_short[13] == tmb_header1_bit[4]) && (tempbuf_short[14] == tmb_header1_bit[5]) &&
881 (tempbuf_short[15] == tmb_header1_bit[6]));
882 tmb_tr1_check[
j] = ((tempbuf_short[0] == tmb_tr1_bit[0]) && (tempbuf_short[4] == tmb_tr1_bit[1]) &&
883 (tempbuf_short[8] == tmb_tr1_bit[2]) && (tempbuf_short[12] == tmb_tr1_bit[3]) &&
884 (tempbuf_short[13] == tmb_tr1_bit[4]) && (tempbuf_short[14] == tmb_tr1_bit[5]) &&
885 (tempbuf_short[15] == tmb_tr1_bit[6]));
888 (((
buf[
i + 4 * (
j - 1) + 1] & 0xF000) == 0x7000) && ((
buf[
i + 4 * (
j - 1) + 2] & 0xF000) == 0x7000) &&
889 ((
buf[
i + 4 * (
j - 1) + 1] != 0x7FFF) || (
buf[
i + 4 * (
j - 1) + 2] != 0x7FFF)) &&
890 ((
buf[
i + 4 * (
j - 1) + 3] == 0x7FFF) || ((
buf[
i + 4 * (
j - 1) + 3] &
buf[
i + 4 * (
j - 1)]) == 0x0 &&
891 (
buf[
i + 4 * (
j - 1) + 3] +
buf[
i + 4 * (
j - 1)] == 0x7FFF))));
893 (((
buf[
i + 4 * (
j - 1) + 3] & 0xF000) == 0xB000) && ((
buf[
i + 4 * (
j - 1) + 2] & 0xF000) == 0xB000) &&
894 ((
buf[
i + 4 * (
j - 1) + 1] & 0xF000) == 0xB000) && ((
buf[
i + 4 * (
j - 1)] = 3 & 0xF000) == 0xB000));
896 ddu_tr1_bad_check[
j] =
897 ((tempbuf_short[0] != ddu_trailer1_bit[0]) &&
900 (tempbuf_short[4] != ddu_trailer1_bit[4]) &&
903 (tempbuf_short[8] == ddu_trailer1_bit[8]) && (tempbuf_short[9] == ddu_trailer1_bit[9]) &&
904 (tempbuf_short[10] == ddu_trailer1_bit[10]) && (tempbuf_short[11] == ddu_trailer1_bit[11]) &&
905 (tempbuf_short[12] == ddu_trailer1_bit[12]) && (tempbuf_short[13] == ddu_trailer1_bit[13]) &&
906 (tempbuf_short[14] == ddu_trailer1_bit[14]) && (tempbuf_short[15] == ddu_trailer1_bit[15]));
910 ddu_h2_h1 = ddu_h2_check[2];
912 sprintf(tempbuf_short,
"%04x%04x%04x%04x",
buf[
i + 3],
buf[
i + 2],
buf[
i + 1],
buf[
i]);
915 ddu_h1_12_13 = (
buf[
i] >> 8);
916 for (
int kk = 0;
kk < 36;
kk++) {
917 if (((
buf[
i + 3] & 0xF000) == 0x5000) && (ddu_h1_12_13 == ddu_id[
kk]) && ddu_h2_h1) {
918 ddu_h1_coll.push_back(word_numbering);
919 ddu_h1_n_coll.push_back(ddu_id[
kk]);
920 ddu_inst_l1a = ((
buf[
i + 2] & 0xFFFF) + ((
buf[
i + 3] & 0x00FF) << 16));
921 ddu_l1a_coll.push_back(ddu_inst_l1a);
922 ddu_inst_bxn = (
buf[
i + 1] & 0xFFF0) >> 4;
923 ddu_bxn_coll.push_back(ddu_inst_bxn);
925 "%6i %04x %04x %04x %04x%s%s%i %s%s %s %i %s %i",
948 dcc_h1_id = (((
buf[
i + 1] << 12) & 0xF000) >> 4) + (
buf[
i] >> 8);
949 for (
int dcci = 0; dcci < 16; dcci++) {
950 if ((dcc_id[dcci] == dcc_h1_id) && (((
buf[
i + 3] & 0xF000) == 0x5000) && (!ddu_h1_check))) {
952 "%6i %04x %04x %04x %04x%s%s%i %s",
962 dcc_h1_check = word_numbering;
970 if (((word_numbering - 1) == dcc_h1_check) && ((
buf[
i + 3] & 0xFF00) == 0xD900)) {
972 "%6i %04x %04x %04x %04x%s%s",
982 }
else if ((word_numbering == word_lines - 1) && (tempbuf_short[0] == dcc_trail1_bit[0])) {
984 "%6i %04x %04x %04x %04x%s%s",
994 }
else if ((word_numbering == word_lines) && (tempbuf_short[0] == dcc_trail2_bit[0])) {
996 "%6i %04x %04x %04x %04x%s%s",
1009 else if (ddu_h2_check[1]) {
1010 ddu_inst_i = ddu_h1_n_coll.size();
1011 if (ddu_inst_i > 0) {
1012 ddu_inst_n = ddu_h1_n_coll[ddu_inst_i - 1];
1015 "%6i %04x %04x %04x %04x%s%s%i %s",
1025 ddu_h2_coll.push_back(word_numbering);
1032 else if ((ddu_h2_check[0] && dmb_h1_check[2]) || (ddu_h2_check[0] && ddu_tr1_check[2])) {
1033 ddu_inst_i = ddu_h1_n_coll.size();
1034 if (ddu_inst_i > 0) {
1035 ddu_inst_n = ddu_h1_n_coll[ddu_inst_i - 1];
1038 "%6i %04x %04x %04x %04x%s%s%i %s",
1048 ddu_h3_coll.push_back(word_numbering);
1056 else if (dmb_h1_check[1]) {
1059 dmb_inst_l1a = ((
buf[
i] & 0x0FFF) + ((
buf[
i + 1] & 0xFFF) << 12));
1060 dmb_l1a_coll.push_back(dmb_inst_l1a);
1061 if (dmb_h2_check[2]) {
1062 dmb_inst_crate = ((
buf[
i + 4 + 1] >> 4) & 0xFF);
1063 dmb_inst_slot = (
buf[
i + 4 + 1] & 0xF);
1064 dmb_crate_coll.push_back(dmb_inst_crate);
1065 dmb_slot_coll.push_back(dmb_inst_slot);
1068 "%6i %04x %04x %04x %04x%s%s %s%s%s %i %s %i %s %i",
1084 dmb_h1_coll.push_back(word_numbering);
1090 else if (dmb_h2_check[1]) {
1091 dmb_inst_crate = ((
buf[
i + 1] >> 4) & 0xFF);
1092 dmb_inst_slot = (
buf[
i + 1] & 0xF);
1093 dmb_h2_coll.push_back(word_numbering);
1094 if (dmb_h1_check[0])
1095 dmb_inst_l1a = ((
buf[
i - 4] & 0x0FFF) + ((
buf[
i - 4 + 1] & 0xFFF) << 12));
1097 "%6i %04x %04x %04x %04x%s%s %s%s%s %i %s %i %s %i",
1120 else if (ddu_tr1_check[1]) {
1121 ddu_inst_i = ddu_h1_n_coll.size();
1122 if (ddu_inst_i > 0) {
1123 ddu_inst_n = ddu_h1_n_coll[ddu_inst_i - 1];
1127 "%6i %04x %04x %04x %04x%s%s%i %s",
1137 ddu_t1_coll.push_back(word_numbering);
1143 else if (alct_h1_check[1]) {
1144 alct_start = word_numbering;
1145 alct_inst_l1a = (
buf[
i + 2] & 0x0FFF);
1146 alct_l1a_coll.push_back(alct_inst_l1a);
1148 "%6i %04x %04x %04x %04x%s%s %s%s %s %i",
1160 alct_h1_coll.push_back(word_numbering);
1165 else if ((alct_h1_check[0]) && (alct_h2_check[2])) {
1166 alct_inst_bxn = (
buf[
i] & 0x0FFF);
1167 alct_bxn_coll.push_back(alct_inst_bxn);
1169 "%6i %04x %04x %04x %04x%s%s %s%s%s %i",
1181 alct_h2_coll.push_back(word_numbering);
1187 else if (alct_tr1_check[1]) {
1188 alct_stop = word_numbering;
1189 if ((alct_start != 0) && (alct_stop != 0) && (alct_stop > alct_start)) {
1190 alct_inst_wcnt2 = 4 * (alct_stop - alct_start + 1);
1191 alct_wcnt2_coll.push_back(alct_inst_wcnt2);
1192 alct_wcnt2_id_coll.push_back(alct_start);
1194 alct_inst_wcnt1 = (
buf[
i + 3] & 0x7FF);
1195 alct_wcnt1_coll.push_back(alct_inst_wcnt1);
1197 "%6i %04x %04x %04x %04x%s%s %s%s%s %i %s %i",
1211 alct_t1_coll.push_back(word_numbering);
1214 alct_inst_wcnt2 = 0;
1220 else if ((ddu_h2_h1) && (tempbuf_short[0] == ddu_trailer3_bit[0])) {
1222 ddu_inst_i = ddu_h1_n_coll.size();
1223 if (ddu_inst_i > 0) {
1224 ddu_inst_n = ddu_h1_n_coll[ddu_inst_i - 1];
1228 "%6i %04x %04x %04x %04x%s%s%i %s",
1238 ddu_t3_coll.push_back(word_numbering);
1243 else if ((ddu_tr1_check[0]) && (tempbuf_short[0] != ddu_trailer3_bit[0])) {
1245 ddu_inst_i = ddu_h1_n_coll.size();
1246 if (ddu_inst_i > 0) {
1247 ddu_inst_n = ddu_h1_n_coll[ddu_inst_i - 1];
1251 "%6i %04x %04x %04x %04x%s%s%i %s",
1261 ddu_t2_coll.push_back(word_numbering);
1267 else if (dmb_tr1_check[1]) {
1269 "%6i %04x %04x %04x %04x%s%s %s",
1278 dmb_t1_coll.push_back(word_numbering);
1284 else if (dmb_tr2_check[1]) {
1286 "%6i %04x %04x %04x %04x%s%s %s",
1295 dmb_t2_coll.push_back(word_numbering);
1300 else if (tmb_h1_check[1]) {
1301 tmb_start = word_numbering;
1302 tmb_inst_l1a = (
buf[
i + 2] & 0x000F);
1303 tmb_l1a_coll.push_back(tmb_inst_l1a);
1305 "%6i %04x %04x %04x %04x%s%s %s%s%s %i",
1317 tmb_h1_coll.push_back(word_numbering);
1320 }
else if (tmb_tr1_check[1]) {
1321 tmb_stop = word_numbering;
1322 if ((tmb_start != 0) && (tmb_stop != 0) && (tmb_stop > tmb_start)) {
1323 tmb_inst_wcnt2 = 4 * (tmb_stop - tmb_start + 1);
1324 tmb_wcnt2_coll.push_back(tmb_inst_wcnt2);
1326 tmb_inst_wcnt1 = (
buf[
i + 3] & 0x7FF);
1327 tmb_wcnt1_coll.push_back(tmb_inst_wcnt1);
1329 "%6i %04x %04x %04x %04x%s%s %s%s%s %i %s %i",
1343 tmb_t1_coll.push_back(word_numbering);
1349 else if (cfeb_tr1_check[1]) {
1352 "%6i %04x %04x %04x %04x%s%s %s%s %s %i",
1364 cfeb_t1_coll.push_back(word_numbering);
1367 }
else if (cfeb_b_check[1]) {
1369 "%6i %04x %04x %04x %04x%s%s %s",
1384 else if (ddu_tr1_bad_check[1]) {
1385 ddu_inst_i = ddu_h1_n_coll.size();
1386 ddu_inst_n = ddu_h1_n_coll[ddu_inst_i - 1];
1388 "%6i %04x %04x %04x %04x%s%s%i %s %s",
1398 ddu_tr1_err_common);
1403 else if (extraction && (!ddu_h1_check) && (!dcc_check)) {
1405 sprintf(tempbuf,
"%6i %04x %04x %04x %04x", word_numbering,
buf[
i + 3],
buf[
i + 2],
buf[
i + 1],
buf[
i]);
1410 std::cout <<
"..................................................." << std::endl;
1415 else if ((!ddu_h1_check) && (!dcc_check)) {
1416 sprintf(tempbuf,
"%6i %04x %04x %04x %04x", word_numbering,
buf[
i + 3],
buf[
i + 2],
buf[
i + 1],
buf[
i]);
1421 ddu_h1_check =
false;
1425 std::cout <<
"********************************************************************************" << std::endl
1428 std::cout <<
"For complete output turn off VisualFEDShort in muonCSCDigis configuration file." << std::endl;
1429 std::cout <<
"********************************************************************************" << std::endl
1434 std::cout << ddu_h1_coll.size() <<
" " << ddu_common <<
" " << ddu_header1 <<
" "
1435 <<
"found" << std::endl;
1440 for (
unsigned int k = 0;
k < ddu_h1_coll.size(); ++
k) {
1447 <<
" " << ddu_h1_coll[
k] <<
" " << sign1 <<
" " << ddu_common <<
" " << ddu_h1_n_coll[
k] <<
" "
1448 << dmb_common_l1a <<
" " << ddu_l1a_coll[
k] <<
" " << alct_common_bxn <<
" " << ddu_bxn_coll[
k]
1453 std::cout <<
"||||||||||||||||||||" << std::endl;
1455 std::cout << ddu_h2_coll.size() <<
" " << ddu_common <<
" " << ddu_header2 <<
" "
1456 <<
"found" << std::endl;
1457 for (
unsigned int k = 0;
k < ddu_h2_coll.size(); ++
k)
1458 std::cout <<
"Line: " << ddu_h2_coll[
k] << std::endl;
1460 std::cout <<
"||||||||||||||||||||" << std::endl;
1462 std::cout << ddu_h3_coll.size() <<
" " << ddu_common <<
" " << ddu_header3 <<
" "
1463 <<
"found" << std::endl;
1464 for (
unsigned int k = 0;
k < ddu_h3_coll.size(); ++
k)
1465 std::cout <<
"Line: " << ddu_h3_coll[
k] << std::endl;
1467 std::cout <<
"||||||||||||||||||||" << std::endl;
1469 std::cout << ddu_t1_coll.size() <<
" " << ddu_common <<
" " << ddu_trail1 <<
" "
1470 <<
"found" << std::endl;
1471 for (
unsigned int k = 0;
k < ddu_t1_coll.size(); ++
k)
1472 std::cout <<
"Line: " << ddu_t1_coll[
k] << std::endl;
1474 std::cout <<
"||||||||||||||||||||" << std::endl;
1476 std::cout << ddu_t2_coll.size() <<
" " << ddu_common <<
" " << ddu_trail2 <<
" "
1477 <<
"found" << std::endl;
1478 for (
unsigned int k = 0;
k < ddu_t2_coll.size(); ++
k)
1479 std::cout <<
"Line: " << ddu_t2_coll[
k] << std::endl;
1481 std::cout <<
"||||||||||||||||||||" << std::endl;
1483 std::cout << ddu_t3_coll.size() <<
" " << ddu_common <<
" " << ddu_trail3 <<
" "
1484 <<
"found" << std::endl;
1485 for (
unsigned int k = 0;
k < ddu_t3_coll.size(); ++
k)
1486 std::cout <<
"Line: " << ddu_t3_coll[
k] << std::endl;
1488 std::cout <<
"||||||||||||||||||||" << std::endl;
1490 std::cout << dmb_h1_coll.size() <<
" " << dmb_common <<
" " << dmb_header1 <<
" "
1491 <<
"found" << std::endl;
1493 for (
unsigned int k = 0;
k < dmb_h1_coll.size(); ++
k) {
1500 <<
" " << dmb_h1_coll[
k] <<
" " << sign1 << dmb_common <<
" " << dmb_common_crate <<
" "
1501 << dmb_crate_coll[
k] <<
" " << dmb_common_slot <<
" " << dmb_slot_coll[
k] <<
" " << dmb_common_l1a <<
" "
1502 << dmb_l1a_coll[
k] << std::endl;
1505 std::cout <<
"||||||||||||||||||||" << std::endl;
1507 std::cout << dmb_h2_coll.size() <<
" " << dmb_common <<
" " << dmb_header2 <<
" "
1508 <<
"found" << std::endl;
1509 for (
unsigned int k = 0;
k < dmb_h2_coll.size(); ++
k)
1510 std::cout <<
"Line: " << dmb_h2_coll[
k] << std::endl;
1512 std::cout <<
"||||||||||||||||||||" << std::endl;
1514 std::cout << dmb_t1_coll.size() <<
" " << dmb_common <<
" " << dmb_tr1 <<
" "
1515 <<
"found" << std::endl;
1516 for (
unsigned int k = 0;
k < dmb_t1_coll.size(); ++
k)
1517 std::cout <<
"Line: " << dmb_t1_coll[
k] << std::endl;
1519 std::cout <<
"||||||||||||||||||||" << std::endl;
1521 std::cout << dmb_t2_coll.size() <<
" " << dmb_common <<
" " << dmb_tr2 <<
" "
1522 <<
"found" << std::endl;
1523 for (
unsigned int k = 0;
k < dmb_t2_coll.size(); ++
k)
1524 std::cout <<
"Line: " << dmb_t2_coll[
k] << std::endl;
1526 std::cout <<
"||||||||||||||||||||" << std::endl;
1528 std::cout << alct_h1_coll.size() <<
" " << alct_common <<
" " << alct_header1 <<
" "
1529 <<
"found" << std::endl;
1530 for (
unsigned int k = 0;
k < alct_h1_coll.size(); ++
k) {
1538 <<
" " << alct_h1_coll[
k] <<
" " << sign1 <<
" " << alct_common <<
" " << dmb_common_l1a <<
" "
1539 << alct_l1a_coll[
k] << std::endl;
1543 std::cout <<
"||||||||||||||||||||" << std::endl;
1545 std::cout << alct_h2_coll.size() <<
" " << alct_common <<
" " << alct_header2 <<
" "
1546 <<
"found" << std::endl;
1547 for (
unsigned int k = 0;
k < alct_h2_coll.size(); ++
k) {
1555 <<
" " << alct_h1_coll[
k] <<
" " << sign1 <<
" " << alct_common <<
" " << alct_common_bxn <<
" "
1556 << alct_bxn_coll[
k] << std::endl;
1560 std::cout <<
"||||||||||||||||||||" << std::endl;
1562 std::cout << alct_t1_coll.size() <<
" " << alct_common <<
" " << alct_tr1 <<
" "
1563 <<
"found" << std::endl;
1564 for (
unsigned int k = 0;
k < alct_t1_coll.size(); ++
k) {
1572 <<
" " << alct_t1_coll[
k] <<
" " << sign1 <<
" " << alct_common <<
" " << alct_common_wcnt1 <<
" "
1573 << alct_wcnt1_coll[
k] <<
" " << alct_common_wcnt2 <<
" ";
1574 if (!alct_wcnt2_coll.empty()) {
1575 std::cout << alct_wcnt2_coll[
k] << std::endl;
1577 std::cout <<
"Undefined (ALCT Header is not found) " << std::endl;
1582 std::cout <<
"||||||||||||||||||||" << std::endl;
1584 std::cout << tmb_h1_coll.size() <<
" " << tmb_common <<
" " << tmb_header1 <<
" "
1585 <<
"found" << std::endl;
1586 for (
unsigned int k = 0;
k < tmb_h1_coll.size(); ++
k) {
1594 <<
" " << tmb_h1_coll[
k] <<
" " << sign1 <<
" " << tmb_common <<
" " << dmb_common_l1a <<
" "
1595 << tmb_l1a_coll[
k] << std::endl;
1599 std::cout <<
"||||||||||||||||||||" << std::endl;
1601 std::cout << tmb_t1_coll.size() <<
" " << tmb_common <<
" " << tmb_tr1 <<
" "
1602 <<
"found" << std::endl;
1603 for (
unsigned int k = 0;
k < tmb_t1_coll.size(); ++
k) {
1611 <<
" " << tmb_t1_coll[
k] <<
" " << sign1 <<
" " << tmb_common <<
" " << alct_common_wcnt1 <<
" "
1612 << tmb_wcnt1_coll[
k] <<
" " << alct_common_wcnt2 <<
" " << tmb_wcnt2_coll[
k] << std::endl;
1616 std::cout <<
"||||||||||||||||||||" << std::endl;
1618 std::cout << cfeb_t1_coll.size() <<
" " << cfeb_common <<
" " << cfeb_tr1 <<
" "
1619 <<
"found" << std::endl;
1620 for (
unsigned int k = 0;
k < cfeb_t1_coll.size(); ++
k)
1621 std::cout <<
"Line: " << cfeb_t1_coll[
k] << std::endl;
1622 std::cout <<
"********************************************************************************" << std::endl;