18 : theDMBHeader(format_version),
19 theALCTHeader(nullptr),
20 theAnodeData(nullptr),
21 theALCTTrailer(nullptr),
23 theDMBTrailer(format_version),
24 theChamberType(chamberType),
25 alctZSErecovered(nullptr),
27 theFormatVersion(format_version) {
43 LogTrace(
"CSCEventData|CSCRawToDigi") <<
"The event data ";
44 for (
int i = 0;
i < 16; ++
i) {
45 LogTrace(
"CSCEventData|CSCRawToDigi") << std::hex <<
pos[
i] <<
" ";
51 LogTrace(
"CSCEventData|CSCRawToDigi") <<
"Bad DMB Header??? "
52 <<
" first four words: ";
53 for (
int i = 0;
i < 4; ++
i) {
54 LogTrace(
"CSCEventData|CSCRawToDigi") << std::hex <<
pos[
i] <<
" ";
59 LogTrace(
"CSCEventData|CSCRawToDigi") <<
"nalct = " <<
nalct();
60 LogTrace(
"CSCEventData|CSCRawToDigi") <<
"nclct = " <<
nclct();
75 LogTrace(
"CSCEventData|CSCRawToDigi") <<
"+++WARNING: Corrupt ALCT data - won't attempt to decode";
102 int sizeInWord_ZSE = 0;
111 int nWG_round_up =
int(nWGs_per_layer / 12) + (nWGs_per_layer % 3 ? 1 : 0);
113 const uint16_t* posZSE =
pos;
114 std::vector<unsigned short> alctZSErecoveredVector;
115 alctZSErecoveredVector.clear();
139 int alctZSErecoveredPos = 0;
140 while (*posZSE != 0xDE0D) {
141 if ((*posZSE == 0x1000) && (*posZSE != 0x3000)) {
142 for (
int j = 0;
j < nWG_round_up;
j++) {
143 alctZSErecoveredVector.push_back(0x0000);
145 alctZSErecoveredPos += nWG_round_up;
147 alctZSErecoveredVector.push_back(*posZSE);
148 ++alctZSErecoveredPos;
157 for (
int l = 0;
l < (
int)alctZSErecoveredVector.size();
l++) {
179 pos += sizeInWord_ZSE;
190 LogTrace(
"CSCEventData|CSCRawToDigi") <<
"Error:nalct reported but no ALCT data found!!!";
200 LogTrace(
"CSCEventData|CSCRawToDigi") <<
"Error:nclct reported but no TMB data found!!!";
205 bool dmbTrailerReached =
false;
206 for (
int i = 0;
i < 12000; ++
i)
208 dmbTrailerReached = (*(
i +
pos) & 0xF000) == 0xF000 && (*(
i +
pos + 1) & 0xF000) == 0xF000 &&
209 (*(
i +
pos + 2) & 0xF000) == 0xF000 && (*(
i +
pos + 3) & 0xF000) == 0xF000 &&
210 (*(
i +
pos + 4) & 0xF000) == 0xE000 && (*(
i +
pos + 5) & 0xF000) == 0xE000 &&
211 (*(
i +
pos + 6) & 0xF000) == 0xE000 && (*(
i +
pos + 7) & 0xF000) == 0xE000;
212 if (dmbTrailerReached) {
218 if (dmbTrailerReached) {
219 for (
int icfeb = 0; icfeb <
MAX_CFEB; ++icfeb) {
224 if (cfeb_available == 1) {
225 if ((cfebTimeout >> icfeb) & 1) {
227 LogTrace(
"CSCEventData|CSCRawToDigi") <<
"CFEB Timed out! ";
233 bool isDCFEB =
false;
245 LogTrace(
"CSCEventData|CSCRawToDigi") <<
"Critical Error: DMB Trailer was not found!!! ";
252 return (((
buf[0] & 0xFFFF) == 0xDB0A) || (((
buf[0] & 0xF800) == 0x6000) && ((
buf[1] & 0xF800) == 0)));
275 for (
int icfeb = 0; icfeb <
MAX_CFEB; ++icfeb) {
287 if (
data.theALCTHeader !=
nullptr)
289 if (
data.theAnodeData !=
nullptr)
291 if (
data.theALCTTrailer !=
nullptr)
293 if (
data.theTMBData !=
nullptr)
295 for (
int icfeb = 0; icfeb <
MAX_CFEB; ++icfeb) {
297 if (
data.theCFEBData[icfeb] !=
nullptr)
312 for (
int icfeb = 0; icfeb <
MAX_CFEB; ++icfeb) {
323 std::vector<CSCStripDigi>
result;
324 for (
unsigned icfeb = 0; icfeb <
MAX_CFEB; ++icfeb) {
325 std::vector<CSCStripDigi> newDigis =
stripDigis(idlayer, icfeb);
326 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;
352 for (
int layer = 1; layer <= 6; ++layer) {
353 std::vector<CSCStripDigi> digis =
stripDigis(layer);
360 std::vector<std::vector<CSCWireDigi> >
result;
361 for (
int layer = 1; layer <= 6; ++layer) {
430 for (
unsigned cfeb = 0; cfeb < 7; cfeb++) {
469 unsigned cfeb = (digi.
getStrip() - 1) / 16;
470 bool sixteenSamples =
false;
472 sixteenSamples =
true;
474 bool isDCFEB =
false;
518 for (
int ilayer = 1; ilayer <= 6; ++ilayer) {
519 std::vector<CSCStripDigi> stripDigis = evt.
stripDigis(ilayer);
522 std::vector<CSCWireDigi> wireDigis = evt.
wireDigis(ilayer);
529 boost::dynamic_bitset<>
result =
533 std::vector<std::pair<unsigned int, unsigned short*> > crcvec;
541 boost::dynamic_bitset<> anodeData =
557 for (
int icfeb = 0; icfeb <
MAX_CFEB; ++icfeb) {
575 for (
unsigned int n = 0;
n < vec.size();
n++) {
577 for (uint16_t
j = 0,
w = 0;
j < vec[
n].first;
j++) {
578 if (vec[
n].
second !=
nullptr) {
579 w = vec[
n].second[
j] & 0xffff;
580 for (uint32_t
i = 15,
t = 0, ncrc = 0;
i < 16;
i--) {
581 t = ((
w >>
i) & 1) ^ ((
CRC >> 21) & 1);
582 ncrc = (
CRC << 1) & 0x3ffffc;
583 ncrc |= (
t ^ (
CRC & 1)) << 1;
598 std::vector<CSCCLCTDigi> clctDigis;
601 clctDigis.push_back(
CSCCLCTDigi(1, 1, 4, 1, 0, 30, 3, 2, 1));
602 clctDigis.push_back(
CSCCLCTDigi(1, 1, 2, 1, 1, 31, 1, 2, 2));
606 std::vector<CSCCorrelatedLCTDigi> corrDigis;
607 corrDigis.push_back(
CSCCorrelatedLCTDigi(1, 1, 2, 10, 98, 5, 0, 1, 0, 0, 0, 0));
608 corrDigis.push_back(
CSCCorrelatedLCTDigi(2, 1, 2, 20, 15, 9, 1, 0, 0, 0, 0, 0));
610 chamberData.
add(clctDigis);
611 chamberData.
add(corrDigis);
615 chamberData.
add(wireDigi, 3);
616 chamberData.
add(comparatorDigi, 3);
634 std::vector<int> sca(16, 600);
635 std::vector<unsigned short> overflow(16, 0),
overlap(16, 0), errorfl(16, 0);
642 forward.
add(me1a, me1adet1.
layer());
643 forward.
add(me1b, me1bdet1.
layer());
644 backward.
add(me1a, me1adet2.
layer());
645 backward.
add(me1b, me1adet2.
layer());
646 std::vector<CSCStripDigi> me1afs = forward.
stripDigis(me1adet1);
647 std::vector<CSCStripDigi> me1bfs = forward.
stripDigis(me1bdet1);
648 std::vector<CSCStripDigi> me1abs = backward.
stripDigis(me1adet2);
649 std::vector<CSCStripDigi> me1bbs = backward.
stripDigis(me1bdet2);
652 assert(me1afs.size() == 16);
653 assert(me1bfs.size() == 16);
654 assert(me1abs.size() == 16);
655 assert(me1bbs.size() == 16);
657 assert(me1afs[4].getStrip() == 5);
658 assert(me1bfs[7].getStrip() == 8);
659 assert(me1abs[4].getStrip() == 5);
660 assert(me1bbs[7].getStrip() == 8);