19 : theDMBHeader(format_version),
20 theALCTHeader(nullptr),
21 theAnodeData(nullptr),
22 theALCTTrailer(nullptr),
24 theDMBTrailer(format_version),
25 theChamberType(chamberType),
26 alctZSErecovered(nullptr),
28 theFormatVersion(format_version) {
44 LogTrace(
"CSCEventData|CSCRawToDigi") <<
"The event data ";
45 for (
int i = 0;
i < 16; ++
i) {
46 LogTrace(
"CSCEventData|CSCRawToDigi") << std::hex <<
pos[
i] <<
" ";
52 LogTrace(
"CSCEventData|CSCRawToDigi") <<
"Bad DMB Header??? "
53 <<
" first four words: ";
54 for (
int i = 0;
i < 4; ++
i) {
55 LogTrace(
"CSCEventData|CSCRawToDigi") << std::hex <<
pos[
i] <<
" ";
60 LogTrace(
"CSCEventData|CSCRawToDigi") <<
"nalct = " <<
nalct();
61 LogTrace(
"CSCEventData|CSCRawToDigi") <<
"nclct = " <<
nclct();
76 LogTrace(
"CSCEventData|CSCRawToDigi") <<
"+++WARNING: Corrupt ALCT data - won't attempt to decode";
103 int sizeInWord_ZSE = 0;
112 int nWG_round_up =
int(nWGs_per_layer / 12) + (nWGs_per_layer % 3 ? 1 : 0);
114 const uint16_t* posZSE =
pos;
115 std::vector<unsigned short> alctZSErecoveredVector;
116 alctZSErecoveredVector.clear();
140 int alctZSErecoveredPos = 0;
141 while (*posZSE != 0xDE0D) {
142 if ((*posZSE == 0x1000) && (*posZSE != 0x3000)) {
143 for (
int j = 0;
j < nWG_round_up;
j++) {
144 alctZSErecoveredVector.push_back(0x0000);
146 alctZSErecoveredPos += nWG_round_up;
148 alctZSErecoveredVector.push_back(*posZSE);
149 ++alctZSErecoveredPos;
158 for (
int l = 0;
l < (
int)alctZSErecoveredVector.size();
l++) {
180 pos += sizeInWord_ZSE;
191 LogTrace(
"CSCEventData|CSCRawToDigi") <<
"Error:nalct reported but no ALCT data found!!!";
201 LogTrace(
"CSCEventData|CSCRawToDigi") <<
"Error:nclct reported but no TMB data found!!!";
206 bool dmbTrailerReached =
false;
207 for (
int i = 0;
i < 12000; ++
i)
209 dmbTrailerReached = (*(
i +
pos) & 0xF000) == 0xF000 && (*(
i +
pos + 1) & 0xF000) == 0xF000 &&
210 (*(
i +
pos + 2) & 0xF000) == 0xF000 && (*(
i +
pos + 3) & 0xF000) == 0xF000 &&
211 (*(
i +
pos + 4) & 0xF000) == 0xE000 && (*(
i +
pos + 5) & 0xF000) == 0xE000 &&
212 (*(
i +
pos + 6) & 0xF000) == 0xE000 && (*(
i +
pos + 7) & 0xF000) == 0xE000;
213 if (dmbTrailerReached) {
219 if (dmbTrailerReached) {
225 if (cfeb_available == 1) {
226 if ((cfebTimeout >> icfeb) & 1) {
228 LogTrace(
"CSCEventData|CSCRawToDigi") <<
"CFEB Timed out! ";
234 bool isDCFEB =
false;
246 LogTrace(
"CSCEventData|CSCRawToDigi") <<
"Critical Error: DMB Trailer was not found!!! ";
253 return (((
buf[0] & 0xFFFF) == 0xDB0A) || (((
buf[0] & 0xF800) == 0x6000) && ((
buf[1] & 0xF800) == 0)));
288 if (
data.theALCTHeader !=
nullptr)
290 if (
data.theAnodeData !=
nullptr)
292 if (
data.theALCTTrailer !=
nullptr)
294 if (
data.theTMBData !=
nullptr)
298 if (
data.theCFEBData[icfeb] !=
nullptr)
324 std::vector<CSCStripDigi>
result;
326 std::vector<CSCStripDigi> newDigis =
stripDigis(idlayer, icfeb);
327 result.insert(
result.end(), newDigis.begin(), newDigis.end());
333 std::vector<CSCStripDigi>
result;
336 result.insert(
result.end(), newDigis.begin(), newDigis.end());
344 return std::vector<CSCWireDigi>();
351 std::vector<std::vector<CSCStripDigi> >
result;
360 std::vector<std::vector<CSCWireDigi> >
result;
463 unsigned cfeb = digi.
getCFEB();
464 bool sixteenSamples =
false;
466 sixteenSamples =
true;
468 bool isDCFEB =
false;
515 std::vector<CSCStripDigi> stripDigis = evt.
stripDigis(ilayer);
518 std::vector<CSCWireDigi> wireDigis = evt.
wireDigis(ilayer);
525 boost::dynamic_bitset<>
result =
529 std::vector<std::pair<unsigned int, unsigned short*> > crcvec;
537 boost::dynamic_bitset<> anodeData =
571 for (
unsigned int n = 0;
n < vec.size();
n++) {
573 for (uint16_t
j = 0,
w = 0;
j < vec[
n].first;
j++) {
574 if (vec[
n].
second !=
nullptr) {
575 w = vec[
n].second[
j] & 0xffff;
576 for (uint32_t
i = 15,
t = 0, ncrc = 0;
i < 16;
i--) {
577 t = ((
w >>
i) & 1) ^ ((
CRC >> 21) & 1);
578 ncrc = (
CRC << 1) & 0x3ffffc;
579 ncrc |= (
t ^ (
CRC & 1)) << 1;
594 std::vector<CSCCLCTDigi> clctDigis;
597 clctDigis.push_back(
CSCCLCTDigi(1, 1, 4, 1, 0, 30, 3, 2, 1));
598 clctDigis.push_back(
CSCCLCTDigi(1, 1, 2, 1, 1, 31, 1, 2, 2));
602 std::vector<CSCCorrelatedLCTDigi> corrDigis;
603 corrDigis.push_back(
CSCCorrelatedLCTDigi(1, 1, 2, 10, 98, 5, 0, 1, 0, 0, 0, 0));
604 corrDigis.push_back(
CSCCorrelatedLCTDigi(2, 1, 2, 20, 15, 9, 1, 0, 0, 0, 0, 0));
606 chamberData.
add(clctDigis);
607 chamberData.
add(corrDigis);
611 chamberData.
add(wireDigi, 3);
612 chamberData.
add(comparatorDigi, 3);
630 std::vector<int> sca(16, 600);
631 std::vector<unsigned short> overflow(16, 0),
overlap(16, 0), errorfl(16, 0);
638 forward.
add(me1a, me1adet1.
layer());
639 forward.
add(me1b, me1bdet1.
layer());
640 backward.
add(me1a, me1adet2.
layer());
641 backward.
add(me1b, me1adet2.
layer());
642 std::vector<CSCStripDigi> me1afs = forward.
stripDigis(me1adet1);
643 std::vector<CSCStripDigi> me1bfs = forward.
stripDigis(me1bdet1);
644 std::vector<CSCStripDigi> me1abs = backward.
stripDigis(me1adet2);
645 std::vector<CSCStripDigi> me1bbs = backward.
stripDigis(me1bdet2);
648 assert(me1afs.size() == 16);
649 assert(me1bfs.size() == 16);
650 assert(me1abs.size() == 16);
651 assert(me1bbs.size() == 16);
653 assert(me1afs[4].getStrip() == 5);
654 assert(me1bfs[7].getStrip() == 8);
655 assert(me1abs[4].getStrip() == 5);
656 assert(me1bbs[7].getStrip() == 8);