80 void visual_raw(
int hl,
int id,
int run,
int event,
bool fedshort,
bool fDump,
short unsigned int*
buf)
const;
111 crateToken = esConsumes<CSCCrateMap, CSCCrateMapRcd>();
112 cscmapToken = esConsumes<CSCChamberMap, CSCChamberMapRcd>();
128 debug =
pset.getUntrackedParameter<
bool>(
"Debug",
false);
143 produces<CSCWireDigiCollection>(
"MuonCSCWireDigi");
144 produces<CSCStripDigiCollection>(
"MuonCSCStripDigi");
145 produces<CSCComparatorDigiCollection>(
"MuonCSCComparatorDigi");
146 produces<CSCALCTDigiCollection>(
"MuonCSCALCTDigi");
147 produces<CSCCLCTDigiCollection>(
"MuonCSCCLCTDigi");
148 produces<CSCRPCDigiCollection>(
"MuonCSCRPCDigi");
149 produces<CSCCorrelatedLCTDigiCollection>(
"MuonCSCCorrelatedLCTDigi");
152 produces<CSCCFEBStatusDigiCollection>(
"MuonCSCCFEBStatusDigi");
153 produces<CSCTMBStatusDigiCollection>(
"MuonCSCTMBStatusDigi");
154 produces<CSCDMBStatusDigiCollection>(
"MuonCSCDMBStatusDigi");
155 produces<CSCALCTStatusDigiCollection>(
"MuonCSCALCTStatusDigi");
156 produces<CSCDDUStatusDigiCollection>(
"MuonCSCDDUStatusDigi");
157 produces<CSCDCCStatusDigiCollection>(
"MuonCSCDCCStatusDigi");
161 produces<CSCDCCFormatStatusDigiCollection>(
"MuonCSCDCCFormatStatusDigi");
165 produces<GEMPadDigiClusterCollection>(
"MuonGEMPadDigiCluster");
169 produces<CSCShowerDigiCollection>(
"MuonCSCShowerDigi");
191 ->setComment(
"# Define input to the unpacker");
192 desc.add<
bool>(
"UseExaminer",
true)
193 ->setComment(
"# Use CSC examiner to check for corrupt or semi-corrupt data & avoid unpacker crashes");
194 desc.add<
unsigned int>(
"ExaminerMask", 535557110)->setComment(
"# This mask is needed by the examiner");
195 desc.add<
bool>(
"UseSelectiveUnpacking",
true)
196 ->setComment(
"# Use Examiner to unpack good chambers and skip only bad ones");
197 desc.add<
unsigned int>(
"ErrorMask", 0)->setComment(
"# This mask simply reduces error reporting");
198 desc.add<
bool>(
"UnpackStatusDigis",
false)->setComment(
"# Unpack general status digis?");
199 desc.add<
bool>(
"UseFormatStatus",
true)->setComment(
"# Unpack FormatStatus digi?");
200 desc.add<
bool>(
"useGEMs",
false)->setComment(
"Unpack GEM trigger data");
201 desc.add<
bool>(
"useCSCShowers",
false)->setComment(
"Unpack CSCShower trigger data");
202 desc.addUntracked<
bool>(
"Debug",
false)->setComment(
"# Turn on lots of output");
203 desc.addUntracked<
bool>(
"PrintEventNumber",
false);
204 desc.addUntracked<
bool>(
"runDQM",
false);
205 desc.addUntracked<
bool>(
"VisualFEDInspect",
false)->setComment(
"# Visualization of raw data in corrupted events");
206 desc.addUntracked<
bool>(
"VisualFEDShort",
false)->setComment(
"# Visualization of raw data in corrupted events");
207 desc.addUntracked<
bool>(
"FormatedEventDump",
false);
208 desc.addUntracked<
bool>(
"SuppressZeroLCT",
true);
209 descriptions.
add(
"muonCSCDCCUnpacker",
desc);
210 descriptions.
setComment(
" This is the generic cfi file for CSC unpacking");
233 auto wireProduct = std::make_unique<CSCWireDigiCollection>();
234 auto stripProduct = std::make_unique<CSCStripDigiCollection>();
235 auto alctProduct = std::make_unique<CSCALCTDigiCollection>();
236 auto clctProduct = std::make_unique<CSCCLCTDigiCollection>();
237 auto comparatorProduct = std::make_unique<CSCComparatorDigiCollection>();
238 auto rpcProduct = std::make_unique<CSCRPCDigiCollection>();
239 auto corrlctProduct = std::make_unique<CSCCorrelatedLCTDigiCollection>();
240 auto cfebStatusProduct = std::make_unique<CSCCFEBStatusDigiCollection>();
241 auto dmbStatusProduct = std::make_unique<CSCDMBStatusDigiCollection>();
242 auto tmbStatusProduct = std::make_unique<CSCTMBStatusDigiCollection>();
243 auto dduStatusProduct = std::make_unique<CSCDDUStatusDigiCollection>();
244 auto dccStatusProduct = std::make_unique<CSCDCCStatusDigiCollection>();
245 auto alctStatusProduct = std::make_unique<CSCALCTStatusDigiCollection>();
247 auto formatStatusProduct = std::make_unique<CSCDCCFormatStatusDigiCollection>();
249 auto gemProduct = std::make_unique<GEMPadDigiClusterCollection>();
251 auto showerProduct = std::make_unique<CSCShowerDigiCollection>();
256 unsigned long dccBinCheckMask = 0x06080016;
259 const unsigned postLS1_map[] = {841, 842, 843, 844, 845, 846, 847, 848, 849, 831, 832, 833,
260 834, 835, 836, 837, 838, 839, 861, 862, 863, 864, 865, 866,
261 867, 868, 869, 851, 852, 853, 854, 855, 856, 857, 858, 859};
264 std::vector<unsigned int> cscFEDids;
268 cscFEDids.push_back(
id);
273 cscFEDids.push_back(
id);
276 for (
unsigned int i = 0;
i < cscFEDids.size();
i++)
278 unsigned int id = cscFEDids[
i];
286 unsigned long length = fedData.
size();
306 if (examiner !=
nullptr)
310 const short unsigned int*
data = (
short unsigned int*)fedData.
data();
312 LogTrace(
"badData") <<
"Length: " << length / 2;
342 formatStatusProduct->insertDigi(
CSCDetId(1, 1, 1, 1, 1),
356 short unsigned*
buf = (
short unsigned int*)fedData.
data();
366 ptrExaminer =
nullptr;
368 std::vector<CSCDDUEventData> fed_Data;
369 std::vector<CSCDDUEventData>* ptr_fedData = &fed_Data;
377 fed_Data.push_back(single_dduData);
393 fed_Data = dccData.dduData();
397 short unsigned* bufForDcc = (
short unsigned int*)fedData.
data();
402 dccStatusProduct->insertDigi(
layer,
404 dccData.dccTrailer().data(),
406 bufForDcc[length / 2 - 4]));
410 const std::vector<CSCDDUEventData>& dduData = *ptr_fedData;
412 for (
unsigned int iDDU = 0; iDDU < dduData.size(); ++iDDU)
416 if (dduData[iDDU].trailer().errorstat() &
errorMask) {
417 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi")
418 <<
"FED ID" <<
id <<
" DDU# " << iDDU <<
" has serious error - no digis unpacked! " << std::hex
419 << dduData[iDDU].trailer().errorstat();
424 dduStatusProduct->insertDigi(
427 dduData[iDDU].trailer().
data(),
429 dduData[iDDU].trailer0()));
432 const std::vector<CSCEventData>& cscData = dduData[iDDU].cscData();
436 for (
unsigned int iCSC = 0; iCSC < cscData.size(); ++iCSC)
439 int vmecrate = cscData[iCSC].dmbHeader()->crateID();
440 int dmb = cscData[iCSC].dmbHeader()->dmbID();
446 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi") <<
"crate = " << vmecrate <<
"; dmb = " << dmb;
448 if ((vmecrate >= 1) && (vmecrate <= 60) && (dmb >= 1) && (dmb <= 10) && (dmb != 6)) {
449 layer = pcrate->
detId(vmecrate, dmb, icfeb, ilayer);
451 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi") <<
" detID input out of range!!! ";
452 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi") <<
" skipping chamber vme= " << vmecrate <<
" dmb= " << dmb;
459 unsigned int dduid = cscmapping->
ddu(
layer);
460 if ((dduid >= 1) && (dduid <= 36))
461 dduid = postLS1_map[dduid - 1];
464 LogTrace(
"CSCDDUUnpacker|CSCRawToDigi") <<
" CSC->FED/DDU mapping inconsistency!!! ";
465 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi")
466 <<
"readout FED/DDU ID=" <<
id <<
" expected ID=" << dduid <<
", skipping chamber " <<
layer
467 <<
" vme= " << vmecrate <<
" dmb= " << dmb;
473 int nalct = cscData[iCSC].dmbHeader()->nalct();
474 bool goodALCT =
false;
476 if (nalct && cscData[iCSC].alctHeader()) {
477 if (cscData[iCSC].alctHeader()->
check()) {
480 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi") <<
"not storing ALCT digis; alct is bad or not present";
484 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi") <<
"nALCT==0 !!!";
489 std::vector<CSCALCTDigi> alctDigis = cscData[iCSC].alctHeader()->ALCTDigis();
491 std::vector<CSCALCTDigi> alctDigis_0;
492 for (
int unsigned i = 0;
i < alctDigis.size(); ++
i) {
494 alctDigis_0.push_back(alctDigis[
i]);
496 alctProduct->move(std::make_pair(alctDigis_0.begin(), alctDigis_0.end()),
layer);
498 alctProduct->move(std::make_pair(alctDigis.begin(), alctDigis.end()),
layer);
502 int nclct = cscData[iCSC].dmbHeader()->nclct();
503 bool goodTMB =
false;
505 if (nclct && cscData[iCSC].tmbData()) {
506 if (cscData[iCSC].tmbHeader()->
check()) {
507 if (cscData[iCSC].comparatorData()->
check())
510 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi") <<
"one of TMB checks failed! not storing TMB digis ";
514 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi") <<
"nCLCT==0 !!!";
519 std::vector<CSCCorrelatedLCTDigi> correlatedlctDigis =
520 cscData[iCSC].tmbHeader()->CorrelatedLCTDigis(
layer.rawId());
522 std::vector<CSCCorrelatedLCTDigi> correlatedlctDigis_0;
523 for (
int unsigned i = 0;
i < correlatedlctDigis.size(); ++
i) {
524 if (correlatedlctDigis[
i].
isValid())
525 correlatedlctDigis_0.push_back(correlatedlctDigis[
i]);
527 corrlctProduct->move(std::make_pair(correlatedlctDigis_0.begin(), correlatedlctDigis_0.end()),
layer);
529 corrlctProduct->move(std::make_pair(correlatedlctDigis.begin(), correlatedlctDigis.end()),
layer);
531 std::vector<CSCCLCTDigi> clctDigis = cscData[iCSC].tmbHeader()->CLCTDigis(
layer.rawId());
533 std::vector<CSCCLCTDigi> clctDigis_0;
534 for (
int unsigned i = 0;
i < clctDigis.size(); ++
i) {
536 clctDigis_0.push_back(clctDigis[
i]);
538 clctProduct->move(std::make_pair(clctDigis_0.begin(), clctDigis_0.end()),
layer);
540 clctProduct->move(std::make_pair(clctDigis.begin(), clctDigis.end()),
layer);
543 if (cscData[iCSC].tmbData()->checkSize()) {
544 if (cscData[iCSC].tmbData()->hasRPC()) {
545 std::vector<CSCRPCDigi> rpcDigis = cscData[iCSC].tmbData()->rpcData()->digis();
546 rpcProduct->move(std::make_pair(rpcDigis.begin(), rpcDigis.end()),
layer);
549 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi") <<
" TMBData check size failed!";
556 if (cscData[iCSC].cfebData(icfeb) !=
nullptr)
557 cfebStatusProduct->insertDigi(
layer, cscData[iCSC].cfebData(icfeb)->statusDigi());
560 dmbStatusProduct->insertDigi(
563 tmbStatusProduct->insertDigi(
567 alctStatusProduct->insertDigi(
577 layer = pcrate->
detId(vmecrate, dmb, 0, ilayer);
579 std::vector<CSCWireDigi> wireDigis = cscData[iCSC].wireDigis(ilayer);
580 wireProduct->move(std::make_pair(wireDigis.begin(), wireDigis.end()),
layer);
584 layer = pcrate->
detId(vmecrate, dmb, icfeb, ilayer);
585 if (cscData[iCSC].cfebData(icfeb) && cscData[iCSC].cfebData(icfeb)->
check()) {
586 std::vector<CSCStripDigi> stripDigis;
587 cscData[iCSC].cfebData(icfeb)->digis(
layer.rawId(), stripDigis);
588 stripProduct->move(std::make_pair(stripDigis.begin(), stripDigis.end()),
layer);
592 if (goodTMB && (cscData[iCSC].tmbHeader() !=
nullptr)) {
593 int nCFEBs = cscData[iCSC].tmbHeader()->NCFEBs();
594 for (icfeb = 0; icfeb < nCFEBs; ++icfeb) {
595 layer = pcrate->
detId(vmecrate, dmb, icfeb, ilayer);
596 std::vector<CSCComparatorDigi> comparatorDigis =
597 cscData[iCSC].comparatorData()->comparatorDigis(
layer.rawId(), icfeb);
600 layer = pcrate->
detId(vmecrate, dmb, 0, ilayer);
601 comparatorProduct->move(std::make_pair(comparatorDigis.begin(), comparatorDigis.end()),
layer);
609 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi") <<
"ERROR! Examiner rejected FED #" <<
id;
616 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi")
617 <<
" Examiner errors:0x" << std::hex << examiner->
errors() <<
" & 0x" <<
examinerMask <<
" = "
625 if (examiner !=
nullptr)
630 e.put(
std::move(wireProduct),
"MuonCSCWireDigi");
631 e.put(
std::move(stripProduct),
"MuonCSCStripDigi");
632 e.put(
std::move(alctProduct),
"MuonCSCALCTDigi");
633 e.put(
std::move(clctProduct),
"MuonCSCCLCTDigi");
634 e.put(
std::move(comparatorProduct),
"MuonCSCComparatorDigi");
635 e.put(
std::move(rpcProduct),
"MuonCSCRPCDigi");
636 e.put(
std::move(corrlctProduct),
"MuonCSCCorrelatedLCTDigi");
639 e.put(
std::move(formatStatusProduct),
"MuonCSCDCCFormatStatusDigi");
642 e.put(
std::move(cfebStatusProduct),
"MuonCSCCFEBStatusDigi");
643 e.put(
std::move(dmbStatusProduct),
"MuonCSCDMBStatusDigi");
644 e.put(
std::move(tmbStatusProduct),
"MuonCSCTMBStatusDigi");
645 e.put(
std::move(dduStatusProduct),
"MuonCSCDDUStatusDigi");
646 e.put(
std::move(dccStatusProduct),
"MuonCSCDCCStatusDigi");
647 e.put(
std::move(alctStatusProduct),
"MuonCSCALCTStatusDigi");
650 e.put(
std::move(gemProduct),
"MuonGEMPadDigiCluster");
653 e.put(
std::move(showerProduct),
"MuonCSCShowerDigi");
656 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi") <<
"[CSCDCCUnpacker]: " <<
numOfEvents <<
" events processed ";
662 int hl,
int id,
int run,
int event,
bool fedshort,
bool fDump,
short unsigned int*
buf)
const {
663 std::cout << std::endl << std::endl << std::endl;
664 std::cout <<
"Run: " <<
run <<
" Event: " <<
event << std::endl;
668 <<
"(scroll down to see summary)" << std::endl;
670 std::cout <<
"Problem seems in FED-" <<
id <<
" "
671 <<
"(scroll down to see summary)" << std::endl;
672 std::cout <<
"********************************************************************************" << std::endl;
673 std::cout << hl <<
" words of data:" << std::endl;
677 std::vector<int> dcc_id;
680 for (
int i = 750;
i < 758;
i++)
683 for (
int i = 830;
i < 838;
i++)
686 char dcc_common[] =
"DCC-";
690 std::vector<int> ddu_id;
691 int ddu_h1_12_13 = 0;
692 for (
int i = 1;
i < 37;
i++)
695 char ddu_common[] =
"DDU-";
696 char ddu_header1[] =
"Header 1";
697 char ddu_header2[] =
"Header 2";
698 char ddu_header3[] =
"Header 3";
699 char ddu_trail1[] =
"Trailer 1", ddu_trail2[] =
"Trailer 2", ddu_trail3[] =
"Trailer 3";
701 char ddu_trailer1_bit[] = {
'8',
'0',
'0',
'0',
'f',
'f',
'f',
'f',
'8',
'0',
'0',
'0',
'8',
'0',
'0',
'0'};
702 char ddu_trailer3_bit[] = {
'a'};
704 char ddu_tr1_err_common[] =
"Incomplet";
708 char dmb_common[] =
"DMB", dmb_header1[] =
"Header 1", dmb_header2[] =
"Header 2";
709 char dmb_common_crate[] =
"crate:", dmb_common_slot[] =
"slot:";
710 char dmb_common_l1a[] =
"L1A:";
711 char dmb_header1_bit[] = {
'9',
'9',
'9',
'9'};
712 char dmb_header2_bit[] = {
'a',
'a',
'a',
'a'};
713 char dmb_tr1[] =
"Trailer 1", dmb_tr2[] =
"Trailer 2";
714 char dmb_tr1_bit[] = {
'f',
'f',
'f',
'f'}, dmb_tr2_bit[] = {
'e',
'e',
'e',
'e'};
719 char alct_common[] =
"ALCT", alct_header1[] =
"Header 1", alct_header2[] =
"Header 2";
720 char alct_common_bxn[] =
"BXN:";
721 char alct_common_wcnt2[] =
"| Actual word count:";
722 char alct_common_wcnt1[] =
"Expected word count:";
723 char alct_header1_bit[] = {
'd',
'd',
'd',
'd',
'b',
'0',
'a'};
724 char alct_header2_bit[] = {
'0',
'0',
'0',
'0'};
725 char alct_tr1[] =
"Trailer 1";
730 char tmb_common[] =
"TMB", tmb_header1[] =
"Header", tmb_tr1[] =
"Trailer";
731 char tmb_header1_bit[] = {
'd',
'd',
'd',
'd',
'b',
'0',
'c'};
732 char tmb_tr1_bit[] = {
'd',
'd',
'd',
'd',
'e',
'0',
'f'};
737 char cfeb_common[] =
"CFEB", cfeb_tr1[] =
"Trailer", cfeb_b[] =
"B-word";
738 char cfeb_common_sample[] =
"sample:";
745 int word_lines = hl / 4;
748 char tempbuf_short[17];
749 char sign1[] =
" --->| ";
752 int word_numbering = 0;
753 int ddu_inst_i = 0, ddu_inst_n = 0, ddu_inst_l1a = 0;
754 int ddu_inst_bxn = 0;
755 int dmb_inst_crate = 0, dmb_inst_slot = 0, dmb_inst_l1a = 0;
757 int alct_inst_l1a = 0;
758 int alct_inst_bxn = 0;
759 int alct_inst_wcnt1 = 0;
760 int alct_inst_wcnt2 = 0;
763 int tmb_inst_l1a = 0;
764 int tmb_inst_wcnt1 = 0;
765 int tmb_inst_wcnt2 = 0;
768 int dcc_h1_check = 0;
771 int ddu_h2_found = 0;
776 bool dcc_check =
false;
777 bool ddu_h2_check[sz1] = {
false};
778 bool ddu_h1_check =
false;
779 bool dmb_h1_check[sz1] = {
false};
780 bool dmb_h2_check[sz1] = {
false};
781 bool ddu_h2_h1 =
false;
782 bool ddu_tr1_check[sz1] = {
false};
783 bool alct_h1_check[sz1] = {
false};
784 bool alct_h2_check[sz1] = {
false};
785 bool alct_tr1_check[sz1] = {
false};
786 bool dmb_tr1_check[sz1] = {
false};
787 bool dmb_tr2_check[sz1] = {
false};
788 bool tmb_h1_check[sz1] = {
false};
789 bool tmb_tr1_check[sz1] = {
false};
790 bool cfeb_tr1_check[sz1] = {
false};
791 bool cfeb_b_check[sz1] = {
false};
792 bool ddu_tr1_bad_check[sz1] = {
false};
793 bool extraction = fedshort;
797 std::vector<int> ddu_h1_coll;
798 std::vector<int> ddu_h1_n_coll;
799 std::vector<int> ddu_h2_coll;
800 std::vector<int> ddu_h3_coll;
801 std::vector<int> ddu_t1_coll;
802 std::vector<int> ddu_t2_coll;
803 std::vector<int> ddu_t3_coll;
804 std::vector<int> ddu_l1a_coll;
805 std::vector<int> ddu_bxn_coll;
807 std::vector<int> dmb_h1_coll;
808 std::vector<int> dmb_h2_coll;
809 std::vector<int> dmb_t1_coll;
810 std::vector<int> dmb_t2_coll;
811 std::vector<int> dmb_crate_coll;
812 std::vector<int> dmb_slot_coll;
813 std::vector<int> dmb_l1a_coll;
815 std::vector<int> alct_h1_coll;
816 std::vector<int> alct_h2_coll;
817 std::vector<int> alct_t1_coll;
818 std::vector<int> alct_l1a_coll;
819 std::vector<int> alct_bxn_coll;
820 std::vector<int> alct_wcnt1_coll;
821 std::vector<int> alct_wcnt2_coll;
822 std::vector<int> alct_wcnt2_id_coll;
824 std::vector<int> tmb_h1_coll;
825 std::vector<int> tmb_t1_coll;
826 std::vector<int> tmb_l1a_coll;
827 std::vector<int> tmb_wcnt1_coll;
828 std::vector<int> tmb_wcnt2_coll;
830 std::vector<int> cfeb_t1_coll;
835 char dcc_header1[] =
"DCC Header 1";
836 char dcc_header2[] =
"DCC Header 2";
837 char dcc_trail1[] =
"DCC Trailer 1", dcc_trail1_bit[] = {
'e'};
838 char dcc_trail2[] =
"DCC Trailer 2", dcc_trail2_bit[] = {
'a'};
841 for (
int i = 0;
i < hl;
i++) {
843 for (
int j = -1;
j < 4;
j++) {
844 sprintf(tempbuf_short,
846 buf[
i + 4 * (
j - 1) + 3],
847 buf[
i + 4 * (
j - 1) + 2],
848 buf[
i + 4 * (
j - 1) + 1],
849 buf[
i + 4 * (
j - 1)]);
855 ddu_h2_check[
j] = ((
buf[
i + 4 * (
j - 1) + 1] == 0x8000) && (
buf[
i + 4 * (
j - 1) + 2] == 0x0001) &&
856 (
buf[
i + 4 * (
j - 1) + 3] == 0x8000));
858 ddu_tr1_check[
j] = ((tempbuf_short[0] == ddu_trailer1_bit[0]) && (tempbuf_short[1] == ddu_trailer1_bit[1]) &&
859 (tempbuf_short[2] == ddu_trailer1_bit[2]) && (tempbuf_short[3] == ddu_trailer1_bit[3]) &&
860 (tempbuf_short[4] == ddu_trailer1_bit[4]) && (tempbuf_short[5] == ddu_trailer1_bit[5]) &&
861 (tempbuf_short[6] == ddu_trailer1_bit[6]) && (tempbuf_short[7] == ddu_trailer1_bit[7]) &&
862 (tempbuf_short[8] == ddu_trailer1_bit[8]) && (tempbuf_short[9] == ddu_trailer1_bit[9]) &&
863 (tempbuf_short[10] == ddu_trailer1_bit[10]) && (tempbuf_short[11] == ddu_trailer1_bit[11]) &&
864 (tempbuf_short[12] == ddu_trailer1_bit[12]) && (tempbuf_short[13] == ddu_trailer1_bit[13]) &&
865 (tempbuf_short[14] == ddu_trailer1_bit[14]) && (tempbuf_short[15] == ddu_trailer1_bit[15]));
867 dmb_h1_check[
j] = ((tempbuf_short[0] == dmb_header1_bit[0]) && (tempbuf_short[4] == dmb_header1_bit[1]) &&
868 (tempbuf_short[8] == dmb_header1_bit[2]) && (tempbuf_short[12] == dmb_header1_bit[3]));
870 dmb_h2_check[
j] = ((tempbuf_short[0] == dmb_header2_bit[0]) && (tempbuf_short[4] == dmb_header2_bit[1]) &&
871 (tempbuf_short[8] == dmb_header2_bit[2]) && (tempbuf_short[12] == dmb_header2_bit[3]));
872 alct_h1_check[
j] = ((tempbuf_short[0] == alct_header1_bit[0]) && (tempbuf_short[4] == alct_header1_bit[1]) &&
873 (tempbuf_short[8] == alct_header1_bit[2]) && (tempbuf_short[12] == alct_header1_bit[3]) &&
874 (tempbuf_short[13] == alct_header1_bit[4]) && (tempbuf_short[14] == alct_header1_bit[5]) &&
875 (tempbuf_short[15] == alct_header1_bit[6]));
876 alct_h2_check[
j] = (((tempbuf_short[0] == alct_header2_bit[0]) && (tempbuf_short[1] == alct_header2_bit[1]) &&
877 (tempbuf_short[2] == alct_header2_bit[2]) && (tempbuf_short[3] == alct_header2_bit[3])) ||
878 ((tempbuf_short[4] == alct_header2_bit[0]) && (tempbuf_short[5] == alct_header2_bit[1]) &&
879 (tempbuf_short[6] == alct_header2_bit[2]) && (tempbuf_short[7] == alct_header2_bit[3])) ||
880 ((tempbuf_short[8] == alct_header2_bit[0]) && (tempbuf_short[9] == alct_header2_bit[1]) &&
881 (tempbuf_short[10] == alct_header2_bit[2]) && (tempbuf_short[11] == alct_header2_bit[3])) ||
882 ((tempbuf_short[12] == alct_header2_bit[0]) && (tempbuf_short[13] == alct_header2_bit[1]) &&
883 (tempbuf_short[14] == alct_header2_bit[2]) && (tempbuf_short[15] == alct_header2_bit[3]))
888 (((
buf[
i + 4 * (
j - 1)] & 0xFFFF) == 0xDE0D) && ((
buf[
i + 4 * (
j - 1) + 1] & 0xF800) == 0xD000) &&
889 ((
buf[
i + 4 * (
j - 1) + 2] & 0xF800) == 0xD000) && ((
buf[
i + 4 * (
j - 1) + 3] & 0xF000) == 0xD000));
891 dmb_tr1_check[
j] = ((tempbuf_short[0] == dmb_tr1_bit[0]) && (tempbuf_short[4] == dmb_tr1_bit[1]) &&
892 (tempbuf_short[8] == dmb_tr1_bit[2]) && (tempbuf_short[12] == dmb_tr1_bit[3]));
893 dmb_tr2_check[
j] = ((tempbuf_short[0] == dmb_tr2_bit[0]) && (tempbuf_short[4] == dmb_tr2_bit[1]) &&
894 (tempbuf_short[8] == dmb_tr2_bit[2]) && (tempbuf_short[12] == dmb_tr2_bit[3]));
896 tmb_h1_check[
j] = ((tempbuf_short[0] == tmb_header1_bit[0]) && (tempbuf_short[4] == tmb_header1_bit[1]) &&
897 (tempbuf_short[8] == tmb_header1_bit[2]) && (tempbuf_short[12] == tmb_header1_bit[3]) &&
898 (tempbuf_short[13] == tmb_header1_bit[4]) && (tempbuf_short[14] == tmb_header1_bit[5]) &&
899 (tempbuf_short[15] == tmb_header1_bit[6]));
900 tmb_tr1_check[
j] = ((tempbuf_short[0] == tmb_tr1_bit[0]) && (tempbuf_short[4] == tmb_tr1_bit[1]) &&
901 (tempbuf_short[8] == tmb_tr1_bit[2]) && (tempbuf_short[12] == tmb_tr1_bit[3]) &&
902 (tempbuf_short[13] == tmb_tr1_bit[4]) && (tempbuf_short[14] == tmb_tr1_bit[5]) &&
903 (tempbuf_short[15] == tmb_tr1_bit[6]));
906 (((
buf[
i + 4 * (
j - 1) + 1] & 0xF000) == 0x7000) && ((
buf[
i + 4 * (
j - 1) + 2] & 0xF000) == 0x7000) &&
907 ((
buf[
i + 4 * (
j - 1) + 1] != 0x7FFF) || (
buf[
i + 4 * (
j - 1) + 2] != 0x7FFF)) &&
908 ((
buf[
i + 4 * (
j - 1) + 3] == 0x7FFF) || ((
buf[
i + 4 * (
j - 1) + 3] &
buf[
i + 4 * (
j - 1)]) == 0x0 &&
909 (
buf[
i + 4 * (
j - 1) + 3] +
buf[
i + 4 * (
j - 1)] == 0x7FFF))));
911 (((
buf[
i + 4 * (
j - 1) + 3] & 0xF000) == 0xB000) && ((
buf[
i + 4 * (
j - 1) + 2] & 0xF000) == 0xB000) &&
912 ((
buf[
i + 4 * (
j - 1) + 1] & 0xF000) == 0xB000) && ((
buf[
i + 4 * (
j - 1)] = 3 & 0xF000) == 0xB000));
914 ddu_tr1_bad_check[
j] =
915 ((tempbuf_short[0] != ddu_trailer1_bit[0]) &&
918 (tempbuf_short[4] != ddu_trailer1_bit[4]) &&
921 (tempbuf_short[8] == ddu_trailer1_bit[8]) && (tempbuf_short[9] == ddu_trailer1_bit[9]) &&
922 (tempbuf_short[10] == ddu_trailer1_bit[10]) && (tempbuf_short[11] == ddu_trailer1_bit[11]) &&
923 (tempbuf_short[12] == ddu_trailer1_bit[12]) && (tempbuf_short[13] == ddu_trailer1_bit[13]) &&
924 (tempbuf_short[14] == ddu_trailer1_bit[14]) && (tempbuf_short[15] == ddu_trailer1_bit[15]));
928 ddu_h2_h1 = ddu_h2_check[2];
930 sprintf(tempbuf_short,
"%04x%04x%04x%04x",
buf[
i + 3],
buf[
i + 2],
buf[
i + 1],
buf[
i]);
933 ddu_h1_12_13 = (
buf[
i] >> 8);
934 for (
int kk = 0;
kk < 36;
kk++) {
935 if (((
buf[
i + 3] & 0xF000) == 0x5000) && (ddu_h1_12_13 == ddu_id[
kk]) && ddu_h2_h1) {
936 ddu_h1_coll.push_back(word_numbering);
937 ddu_h1_n_coll.push_back(ddu_id[
kk]);
938 ddu_inst_l1a = ((
buf[
i + 2] & 0xFFFF) + ((
buf[
i + 3] & 0x00FF) << 16));
939 ddu_l1a_coll.push_back(ddu_inst_l1a);
940 ddu_inst_bxn = (
buf[
i + 1] & 0xFFF0) >> 4;
941 ddu_bxn_coll.push_back(ddu_inst_bxn);
943 "%6i %04x %04x %04x %04x%s%s%i %s%s %s %i %s %i",
966 dcc_h1_id = (((
buf[
i + 1] << 12) & 0xF000) >> 4) + (
buf[
i] >> 8);
967 for (
int dcci = 0; dcci < 16; dcci++) {
968 if ((dcc_id[dcci] == dcc_h1_id) && (((
buf[
i + 3] & 0xF000) == 0x5000) && (!ddu_h1_check))) {
970 "%6i %04x %04x %04x %04x%s%s%i %s",
980 dcc_h1_check = word_numbering;
988 if (((word_numbering - 1) == dcc_h1_check) && ((
buf[
i + 3] & 0xFF00) == 0xD900)) {
990 "%6i %04x %04x %04x %04x%s%s",
1000 }
else if ((word_numbering == word_lines - 1) && (tempbuf_short[0] == dcc_trail1_bit[0])) {
1002 "%6i %04x %04x %04x %04x%s%s",
1012 }
else if ((word_numbering == word_lines) && (tempbuf_short[0] == dcc_trail2_bit[0])) {
1014 "%6i %04x %04x %04x %04x%s%s",
1027 else if (ddu_h2_check[1]) {
1028 ddu_inst_i = ddu_h1_n_coll.size();
1029 if (ddu_inst_i > 0) {
1030 ddu_inst_n = ddu_h1_n_coll[ddu_inst_i - 1];
1033 "%6i %04x %04x %04x %04x%s%s%i %s",
1043 ddu_h2_coll.push_back(word_numbering);
1050 else if ((ddu_h2_check[0] && dmb_h1_check[2]) || (ddu_h2_check[0] && ddu_tr1_check[2])) {
1051 ddu_inst_i = ddu_h1_n_coll.size();
1052 if (ddu_inst_i > 0) {
1053 ddu_inst_n = ddu_h1_n_coll[ddu_inst_i - 1];
1056 "%6i %04x %04x %04x %04x%s%s%i %s",
1066 ddu_h3_coll.push_back(word_numbering);
1074 else if (dmb_h1_check[1]) {
1077 dmb_inst_l1a = ((
buf[
i] & 0x0FFF) + ((
buf[
i + 1] & 0xFFF) << 12));
1078 dmb_l1a_coll.push_back(dmb_inst_l1a);
1079 if (dmb_h2_check[2]) {
1080 dmb_inst_crate = ((
buf[
i + 4 + 1] >> 4) & 0xFF);
1081 dmb_inst_slot = (
buf[
i + 4 + 1] & 0xF);
1082 dmb_crate_coll.push_back(dmb_inst_crate);
1083 dmb_slot_coll.push_back(dmb_inst_slot);
1086 "%6i %04x %04x %04x %04x%s%s %s%s%s %i %s %i %s %i",
1102 dmb_h1_coll.push_back(word_numbering);
1108 else if (dmb_h2_check[1]) {
1109 dmb_inst_crate = ((
buf[
i + 1] >> 4) & 0xFF);
1110 dmb_inst_slot = (
buf[
i + 1] & 0xF);
1111 dmb_h2_coll.push_back(word_numbering);
1112 if (dmb_h1_check[0])
1113 dmb_inst_l1a = ((
buf[
i - 4] & 0x0FFF) + ((
buf[
i - 4 + 1] & 0xFFF) << 12));
1115 "%6i %04x %04x %04x %04x%s%s %s%s%s %i %s %i %s %i",
1138 else if (ddu_tr1_check[1]) {
1139 ddu_inst_i = ddu_h1_n_coll.size();
1140 if (ddu_inst_i > 0) {
1141 ddu_inst_n = ddu_h1_n_coll[ddu_inst_i - 1];
1145 "%6i %04x %04x %04x %04x%s%s%i %s",
1155 ddu_t1_coll.push_back(word_numbering);
1161 else if (alct_h1_check[1]) {
1162 alct_start = word_numbering;
1163 alct_inst_l1a = (
buf[
i + 2] & 0x0FFF);
1164 alct_l1a_coll.push_back(alct_inst_l1a);
1166 "%6i %04x %04x %04x %04x%s%s %s%s %s %i",
1178 alct_h1_coll.push_back(word_numbering);
1183 else if ((alct_h1_check[0]) && (alct_h2_check[2])) {
1184 alct_inst_bxn = (
buf[
i] & 0x0FFF);
1185 alct_bxn_coll.push_back(alct_inst_bxn);
1187 "%6i %04x %04x %04x %04x%s%s %s%s%s %i",
1199 alct_h2_coll.push_back(word_numbering);
1205 else if (alct_tr1_check[1]) {
1206 alct_stop = word_numbering;
1207 if ((alct_start != 0) && (alct_stop != 0) && (alct_stop > alct_start)) {
1208 alct_inst_wcnt2 = 4 * (alct_stop - alct_start + 1);
1209 alct_wcnt2_coll.push_back(alct_inst_wcnt2);
1210 alct_wcnt2_id_coll.push_back(alct_start);
1212 alct_inst_wcnt1 = (
buf[
i + 3] & 0x7FF);
1213 alct_wcnt1_coll.push_back(alct_inst_wcnt1);
1215 "%6i %04x %04x %04x %04x%s%s %s%s%s %i %s %i",
1229 alct_t1_coll.push_back(word_numbering);
1232 alct_inst_wcnt2 = 0;
1238 else if ((ddu_h2_h1) && (tempbuf_short[0] == ddu_trailer3_bit[0])) {
1240 ddu_inst_i = ddu_h1_n_coll.size();
1241 if (ddu_inst_i > 0) {
1242 ddu_inst_n = ddu_h1_n_coll[ddu_inst_i - 1];
1246 "%6i %04x %04x %04x %04x%s%s%i %s",
1256 ddu_t3_coll.push_back(word_numbering);
1261 else if ((ddu_tr1_check[0]) && (tempbuf_short[0] != ddu_trailer3_bit[0])) {
1263 ddu_inst_i = ddu_h1_n_coll.size();
1264 if (ddu_inst_i > 0) {
1265 ddu_inst_n = ddu_h1_n_coll[ddu_inst_i - 1];
1269 "%6i %04x %04x %04x %04x%s%s%i %s",
1279 ddu_t2_coll.push_back(word_numbering);
1285 else if (dmb_tr1_check[1]) {
1287 "%6i %04x %04x %04x %04x%s%s %s",
1296 dmb_t1_coll.push_back(word_numbering);
1302 else if (dmb_tr2_check[1]) {
1304 "%6i %04x %04x %04x %04x%s%s %s",
1313 dmb_t2_coll.push_back(word_numbering);
1318 else if (tmb_h1_check[1]) {
1319 tmb_start = word_numbering;
1320 tmb_inst_l1a = (
buf[
i + 2] & 0x000F);
1321 tmb_l1a_coll.push_back(tmb_inst_l1a);
1323 "%6i %04x %04x %04x %04x%s%s %s%s%s %i",
1335 tmb_h1_coll.push_back(word_numbering);
1338 }
else if (tmb_tr1_check[1]) {
1339 tmb_stop = word_numbering;
1340 if ((tmb_start != 0) && (tmb_stop != 0) && (tmb_stop > tmb_start)) {
1341 tmb_inst_wcnt2 = 4 * (tmb_stop - tmb_start + 1);
1342 tmb_wcnt2_coll.push_back(tmb_inst_wcnt2);
1344 tmb_inst_wcnt1 = (
buf[
i + 3] & 0x7FF);
1345 tmb_wcnt1_coll.push_back(tmb_inst_wcnt1);
1347 "%6i %04x %04x %04x %04x%s%s %s%s%s %i %s %i",
1361 tmb_t1_coll.push_back(word_numbering);
1367 else if (cfeb_tr1_check[1]) {
1370 "%6i %04x %04x %04x %04x%s%s %s%s %s %i",
1382 cfeb_t1_coll.push_back(word_numbering);
1385 }
else if (cfeb_b_check[1]) {
1387 "%6i %04x %04x %04x %04x%s%s %s",
1402 else if (ddu_tr1_bad_check[1]) {
1403 ddu_inst_i = ddu_h1_n_coll.size();
1404 ddu_inst_n = ddu_h1_n_coll[ddu_inst_i - 1];
1406 "%6i %04x %04x %04x %04x%s%s%i %s %s",
1416 ddu_tr1_err_common);
1421 else if (extraction && (!ddu_h1_check) && (!dcc_check)) {
1423 sprintf(tempbuf,
"%6i %04x %04x %04x %04x", word_numbering,
buf[
i + 3],
buf[
i + 2],
buf[
i + 1],
buf[
i]);
1428 std::cout <<
"..................................................." << std::endl;
1433 else if ((!ddu_h1_check) && (!dcc_check)) {
1434 sprintf(tempbuf,
"%6i %04x %04x %04x %04x", word_numbering,
buf[
i + 3],
buf[
i + 2],
buf[
i + 1],
buf[
i]);
1439 ddu_h1_check =
false;
1443 std::cout <<
"********************************************************************************" << std::endl
1446 std::cout <<
"For complete output turn off VisualFEDShort in muonCSCDigis configuration file." << std::endl;
1447 std::cout <<
"********************************************************************************" << std::endl
1452 std::cout << ddu_h1_coll.size() <<
" " << ddu_common <<
" " << ddu_header1 <<
" "
1453 <<
"found" << std::endl;
1458 for (
unsigned int k = 0;
k < ddu_h1_coll.size(); ++
k) {
1465 <<
" " << ddu_h1_coll[
k] <<
" " << sign1 <<
" " << ddu_common <<
" " << ddu_h1_n_coll[
k] <<
" "
1466 << dmb_common_l1a <<
" " << ddu_l1a_coll[
k] <<
" " << alct_common_bxn <<
" " << ddu_bxn_coll[
k]
1471 std::cout <<
"||||||||||||||||||||" << std::endl;
1473 std::cout << ddu_h2_coll.size() <<
" " << ddu_common <<
" " << ddu_header2 <<
" "
1474 <<
"found" << std::endl;
1475 for (
unsigned int k = 0;
k < ddu_h2_coll.size(); ++
k)
1476 std::cout <<
"Line: " << ddu_h2_coll[
k] << std::endl;
1478 std::cout <<
"||||||||||||||||||||" << std::endl;
1480 std::cout << ddu_h3_coll.size() <<
" " << ddu_common <<
" " << ddu_header3 <<
" "
1481 <<
"found" << std::endl;
1482 for (
unsigned int k = 0;
k < ddu_h3_coll.size(); ++
k)
1483 std::cout <<
"Line: " << ddu_h3_coll[
k] << std::endl;
1485 std::cout <<
"||||||||||||||||||||" << std::endl;
1487 std::cout << ddu_t1_coll.size() <<
" " << ddu_common <<
" " << ddu_trail1 <<
" "
1488 <<
"found" << std::endl;
1489 for (
unsigned int k = 0;
k < ddu_t1_coll.size(); ++
k)
1490 std::cout <<
"Line: " << ddu_t1_coll[
k] << std::endl;
1492 std::cout <<
"||||||||||||||||||||" << std::endl;
1494 std::cout << ddu_t2_coll.size() <<
" " << ddu_common <<
" " << ddu_trail2 <<
" "
1495 <<
"found" << std::endl;
1496 for (
unsigned int k = 0;
k < ddu_t2_coll.size(); ++
k)
1497 std::cout <<
"Line: " << ddu_t2_coll[
k] << std::endl;
1499 std::cout <<
"||||||||||||||||||||" << std::endl;
1501 std::cout << ddu_t3_coll.size() <<
" " << ddu_common <<
" " << ddu_trail3 <<
" "
1502 <<
"found" << std::endl;
1503 for (
unsigned int k = 0;
k < ddu_t3_coll.size(); ++
k)
1504 std::cout <<
"Line: " << ddu_t3_coll[
k] << std::endl;
1506 std::cout <<
"||||||||||||||||||||" << std::endl;
1508 std::cout << dmb_h1_coll.size() <<
" " << dmb_common <<
" " << dmb_header1 <<
" "
1509 <<
"found" << std::endl;
1511 for (
unsigned int k = 0;
k < dmb_h1_coll.size(); ++
k) {
1518 <<
" " << dmb_h1_coll[
k] <<
" " << sign1 << dmb_common <<
" " << dmb_common_crate <<
" "
1519 << dmb_crate_coll[
k] <<
" " << dmb_common_slot <<
" " << dmb_slot_coll[
k] <<
" " << dmb_common_l1a <<
" "
1520 << dmb_l1a_coll[
k] << std::endl;
1523 std::cout <<
"||||||||||||||||||||" << std::endl;
1525 std::cout << dmb_h2_coll.size() <<
" " << dmb_common <<
" " << dmb_header2 <<
" "
1526 <<
"found" << std::endl;
1527 for (
unsigned int k = 0;
k < dmb_h2_coll.size(); ++
k)
1528 std::cout <<
"Line: " << dmb_h2_coll[
k] << std::endl;
1530 std::cout <<
"||||||||||||||||||||" << std::endl;
1532 std::cout << dmb_t1_coll.size() <<
" " << dmb_common <<
" " << dmb_tr1 <<
" "
1533 <<
"found" << std::endl;
1534 for (
unsigned int k = 0;
k < dmb_t1_coll.size(); ++
k)
1535 std::cout <<
"Line: " << dmb_t1_coll[
k] << std::endl;
1537 std::cout <<
"||||||||||||||||||||" << std::endl;
1539 std::cout << dmb_t2_coll.size() <<
" " << dmb_common <<
" " << dmb_tr2 <<
" "
1540 <<
"found" << std::endl;
1541 for (
unsigned int k = 0;
k < dmb_t2_coll.size(); ++
k)
1542 std::cout <<
"Line: " << dmb_t2_coll[
k] << std::endl;
1544 std::cout <<
"||||||||||||||||||||" << std::endl;
1546 std::cout << alct_h1_coll.size() <<
" " << alct_common <<
" " << alct_header1 <<
" "
1547 <<
"found" << std::endl;
1548 for (
unsigned int k = 0;
k < alct_h1_coll.size(); ++
k) {
1556 <<
" " << alct_h1_coll[
k] <<
" " << sign1 <<
" " << alct_common <<
" " << dmb_common_l1a <<
" "
1557 << alct_l1a_coll[
k] << std::endl;
1561 std::cout <<
"||||||||||||||||||||" << std::endl;
1563 std::cout << alct_h2_coll.size() <<
" " << alct_common <<
" " << alct_header2 <<
" "
1564 <<
"found" << std::endl;
1565 for (
unsigned int k = 0;
k < alct_h2_coll.size(); ++
k) {
1573 <<
" " << alct_h1_coll[
k] <<
" " << sign1 <<
" " << alct_common <<
" " << alct_common_bxn <<
" "
1574 << alct_bxn_coll[
k] << std::endl;
1578 std::cout <<
"||||||||||||||||||||" << std::endl;
1580 std::cout << alct_t1_coll.size() <<
" " << alct_common <<
" " << alct_tr1 <<
" "
1581 <<
"found" << std::endl;
1582 for (
unsigned int k = 0;
k < alct_t1_coll.size(); ++
k) {
1590 <<
" " << alct_t1_coll[
k] <<
" " << sign1 <<
" " << alct_common <<
" " << alct_common_wcnt1 <<
" "
1591 << alct_wcnt1_coll[
k] <<
" " << alct_common_wcnt2 <<
" ";
1592 if (!alct_wcnt2_coll.empty()) {
1593 std::cout << alct_wcnt2_coll[
k] << std::endl;
1595 std::cout <<
"Undefined (ALCT Header is not found) " << std::endl;
1600 std::cout <<
"||||||||||||||||||||" << std::endl;
1602 std::cout << tmb_h1_coll.size() <<
" " << tmb_common <<
" " << tmb_header1 <<
" "
1603 <<
"found" << std::endl;
1604 for (
unsigned int k = 0;
k < tmb_h1_coll.size(); ++
k) {
1612 <<
" " << tmb_h1_coll[
k] <<
" " << sign1 <<
" " << tmb_common <<
" " << dmb_common_l1a <<
" "
1613 << tmb_l1a_coll[
k] << std::endl;
1617 std::cout <<
"||||||||||||||||||||" << std::endl;
1619 std::cout << tmb_t1_coll.size() <<
" " << tmb_common <<
" " << tmb_tr1 <<
" "
1620 <<
"found" << std::endl;
1621 for (
unsigned int k = 0;
k < tmb_t1_coll.size(); ++
k) {
1629 <<
" " << tmb_t1_coll[
k] <<
" " << sign1 <<
" " << tmb_common <<
" " << alct_common_wcnt1 <<
" "
1630 << tmb_wcnt1_coll[
k] <<
" " << alct_common_wcnt2 <<
" " << tmb_wcnt2_coll[
k] << std::endl;
1634 std::cout <<
"||||||||||||||||||||" << std::endl;
1636 std::cout << cfeb_t1_coll.size() <<
" " << cfeb_common <<
" " << cfeb_tr1 <<
" "
1637 <<
"found" << std::endl;
1638 for (
unsigned int k = 0;
k < cfeb_t1_coll.size(); ++
k)
1639 std::cout <<
"Line: " << cfeb_t1_coll[
k] << std::endl;
1640 std::cout <<
"********************************************************************************" << std::endl;