diff --git a/[refs] b/[refs] index 5d69ff79b4f93..87af3af3990f8 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/l1tmuon-upgrade-dev: 4df3f6787f420aa5730289e7ce41b492686b4a29 +refs/heads/l1tmuon-upgrade-dev: 70548fb4d01605718d7bfa8fddf6fd02cd5c31ad diff --git a/trunk/EventFilter/CSCRawToDigi/interface/CSCDCCExaminer.h b/trunk/EventFilter/CSCRawToDigi/interface/CSCDCCExaminer.h index 31e868a551c06..c28d113c94a4d 100644 --- a/trunk/EventFilter/CSCRawToDigi/interface/CSCDCCExaminer.h +++ b/trunk/EventFilter/CSCRawToDigi/interface/CSCDCCExaminer.h @@ -6,113 +6,24 @@ #include #include -/** DCC identifier type */ -typedef int32_t DCCIdType; - -/** DDU identifier type */ -typedef int16_t DDUIdType; - -/** CSC identifier type */ -typedef int32_t CSCIdType; - -/** Examiner status and mask type */ -typedef uint32_t ExaminerMaskType; -typedef uint32_t ExaminerStatusType; - -/** Format Error individual named flags */ -typedef enum FormatErrorFlag { - ANY_ERRORS = 0, - DDU_TRAILER_MISSING = 1, - DDU_HEADER_MISSING = 2, - DDU_CRC_ERROR = 3, - DDU_WORD_COUNT_ERROR = 4, - DMB_TRAILER_MISSING = 5, - DMB_HEADER_MISSING = 6, - ALCT_TRAILER_MISSING = 7, - ALCT_HEADER_MISSING = 8, - ALCT_WORD_COUNT_ERROR = 9, - ALCT_CRC_ERROR = 10, - ALCT_TRAILER_BIT_ERROR = 11, - TMB_TRAILER_MISSING = 12, - TMB_HEADER_MISSING = 13, - TMB_WORD_COUNT_ERROR = 14, - TMB_CRC_ERROR = 15, - CFEB_WORD_COUNT_PER_SAMPLE_ERROR = 16, - CFEB_SAMPLE_COUNT_ERROR = 17, - CFEB_CRC_ERROR = 18, - DDU_EVENT_SIZE_LIMIT_ERROR = 19, - C_WORDS = 20, - ALCT_DAV_ERROR = 21, - TMB_DAV_ERROR = 22, - CFEB_DAV_ERROR = 23, - DMB_ACTIVE_ERROR = 24, - DCC_TRAILER_MISSING = 25, - DCC_HEADER_MISSING = 26, - DMB_DAV_VS_DMB_ACTIVE_MISMATCH_ERROR = 27, - EXTRA_WORDS_BETWEEN_DDU_HEADER_AND_FIRST_DMB_HEADER = 28 -}; - -/** CSC Payload individual named flags */ -typedef enum CSCPayloadFlag { - CFEB1_ACTIVE = 0, - CFEB2_ACTIVE = 1, - CFEB3_ACTIVE = 2, - CFEB4_ACTIVE = 3, - CFEB5_ACTIVE = 4, - ALCT_DAV = 5, - TMB_DAV = 6, - CFEB1_DAV = 7, - CFEB2_DAV = 8, - CFEB3_DAV = 9, - CFEB4_DAV = 10, - CFEB5_DAV = 11 -}; - -/** CSC Status individual named flags */ -typedef enum CSCStatusFlag { - ALCT_FIFO_FULL = 0, - TMB_FIFO_FULL = 1, - CFEB1_FIFO_FULL = 2, - CFEB2_FIFO_FULL = 3, - CFEB3_FIFO_FULL = 4, - CFEB4_FIFO_FULL = 5, - CFEB5_FIFO_FULL = 6, - ALCT_START_TIMEOUT = 7, - TMB_START_TIMEOUT = 8, - CFEB1_START_TIMEOUT = 9, - CFEB2_START_TIMEOUT = 10, - CFEB3_START_TIMEOUT = 11, - CFEB4_START_TIMEOUT = 12, - CFEB5_START_TIMEOUT = 13, - ALCT_END_TIMEOUT = 14, - TMB_END_TIMEOUT = 15, - CFEB1_END_TIMEOUT = 16, - CFEB2_END_TIMEOUT = 17, - CFEB3_END_TIMEOUT = 18, - CFEB4_END_TIMEOUT = 19, - CFEB5_END_TIMEOUT = 20, - CFEB_ACTIVE_DAV_MISMATCH = 21, - B_WORDS_FOUND = 22 -}; - class CSCDCCExaminer { public: - const uint16_t nERRORS, nWARNINGS, nPAYLOADS, nSTATUSES; + const unsigned short nERRORS, nWARNINGS, nPAYLOADS, nSTATUSES; private: std::vector sERROR, sWARNING, sERROR_, sWARNING_, sDMBExpectedPayload, sDMBEventStaus; - ExaminerStatusType bERROR, bWARNING; + long bERROR, bWARNING; bool fERROR [29];//[nERRORS]; bool fWARNING[5]; //[nWARNINGS]; - std::set fCHAMB_ERR[29]; // Set of chambers which contain particular error - std::set fCHAMB_WRN[5]; // Set of chambers which contain particular warning - std::map bCHAMB_ERR; // chamber <=> errors in bits - std::map bCHAMB_WRN; // chamber <=> errors in bits - std::map bCHAMB_PAYLOAD; // - std::map bCHAMB_STATUS; // - std::map bDDU_ERR; // ddu <-> errors in bits - std::map bDDU_WRN; // ddu <-> errors in bits + std::set fCHAMB_ERR[29]; // Set of chambers which contain particular error + std::set fCHAMB_WRN[5]; // Set of chambers which contain particular warning + std::map bCHAMB_ERR; // chamber <=> errors in bits + std::map bCHAMB_WRN; // chamber <=> errors in bits + std::map bCHAMB_PAYLOAD; // + std::map bCHAMB_STATUS; // + std::map bDDU_ERR; // ddu <-> errors in bits + std::map bDDU_WRN; // ddu <-> errors in bits class OStream : public std::ostream { private: @@ -143,10 +54,10 @@ class CSCDCCExaminer { OStream cout, cerr; - CSCIdType currentChamber; // ( (CrateNumber<<4) + DMBslot ) specifies chamber + int currentChamber; // ( (CrateNumber<<4) + DMBslot ) specifies chamber - const uint16_t *buf_2, *buf_1, *buf0, *buf1, *buf2; - uint16_t tmpbuf[16]; + const unsigned short *buf_2, *buf_1, *buf0, *buf1, *buf2; + unsigned short tmpbuf[16]; bool fDCC_Header; bool fDCC_Trailer; @@ -168,10 +79,10 @@ class CSCDCCExaminer { int DMB_Active, nDMBs; // ... public: - uint32_t cntDDU_Headers; - uint32_t cntDDU_Trailers; - std::map cntCHAMB_Headers; - std::map cntCHAMB_Trailers; + long cntDDU_Headers; + long cntDDU_Trailers; + std::map cntCHAMB_Headers; + std::map cntCHAMB_Trailers; private: void clear(); @@ -179,59 +90,59 @@ class CSCDCCExaminer { /// checks DAV_ALCT, DAV_TMB, and DAV_CFEB void checkDAVs(); void checkTriggerHeadersAndTrailers(); - uint32_t DDU_WordsSinceLastHeader; - uint32_t DDU_WordCount; - uint32_t DDU_WordMismatch_Occurrences; - uint32_t DDU_WordsSinceLastTrailer; - - uint32_t ALCT_WordsSinceLastHeader; - uint32_t ALCT_WordCount; - uint32_t ALCT_WordsExpected; - - uint32_t TMB_WordsSinceLastHeader; - uint32_t TMB_WordCount; - uint32_t TMB_WordsExpected; - uint32_t TMB_Tbins; - uint32_t TMB_WordsExpectedCorrection; - uint32_t TMB_Firmware_Revision; - - uint32_t CFEB_SampleWordCount; - uint32_t CFEB_SampleCount; - uint32_t CFEB_BSampleCount; + long DDU_WordsSinceLastHeader; + long DDU_WordCount; + long DDU_WordMismatch_Occurrences; + long DDU_WordsSinceLastTrailer; + + long ALCT_WordsSinceLastHeader; + long ALCT_WordCount; + long ALCT_WordsExpected; + + long TMB_WordsSinceLastHeader; + long TMB_WordCount; + long TMB_WordsExpected; + long TMB_Tbins; + long TMB_WordsRPC; + unsigned TMB_Firmware_Revision; + + long CFEB_SampleWordCount; + long CFEB_SampleCount; + long CFEB_BSampleCount; bool checkCrcALCT; - uint32_t ALCT_CRC; + unsigned long ALCT_CRC; bool checkCrcTMB; - uint32_t TMB_CRC; + unsigned long TMB_CRC; bool checkCrcCFEB; - uint32_t CFEB_CRC; + unsigned long CFEB_CRC; bool modeDDUonly; - DDUIdType sourceID; - ExaminerMaskType examinerMask; + short sourceID; + unsigned long examinerMask; //int headerDAV_Active; // Obsolete since 16.09.05 // data blocks: - std::map dduBuffers; // < DDUsourceID, pointer > - std::map > dmbBuffers; // < DDUsourceID, < DMBid, pointer > > - std::map dduOffsets; // < DDUsourceID, pointer_offset > - std::map > dmbOffsets; // < DDUsourceID, < DMBid, pointer_offset > > - std::map dduSize; // < DDUsourceID, block_size > - std::map > dmbSize; // < DDUsourceID, < DMBid, block_size > > - const uint16_t *buffer_start; + std::map dduBuffers; // < DDUsourceID, pointer > + std::map > dmbBuffers; // < DDUsourceID, < DMBid, pointer > > + std::map dduOffsets; // < DDUsourceID, pointer_offset > + std::map > dmbOffsets; // < DDUsourceID, < DMBid, pointer_offset > > + std::map dduSize; // < DDUsourceID, block_size > + std::map > dmbSize; // < DDUsourceID, < DMBid, block_size > > + const unsigned short *buffer_start; public: OStream& output1(void){ return cout; } OStream& output2(void){ return cerr; } - int32_t check(const uint16_t* &buffer, int32_t length); + long check(const unsigned short* &buffer, long length); - void setMask(ExaminerMaskType mask) {examinerMask=mask;} - ExaminerMaskType getMask() const {return examinerMask;} + void setMask(unsigned long mask) {examinerMask=mask;} + unsigned long getMask() const {return examinerMask;} - ExaminerStatusType errors (void) const { return bERROR; } - ExaminerStatusType warnings(void) const { return bWARNING; } + long errors (void) const { return bERROR; } + long warnings(void) const { return bWARNING; } const char* errName(int num) const { if(num>=0&&num=0&&num=0&&num=0&&num chambersWithError (int num) const { if(num>=0&&num(); } - std::set chambersWithWarning(int num) const { if(num>=0&&num(); } + std::set chambersWithError (int num) const { if(num>=0&&num(); } + std::set chambersWithWarning(int num) const { if(num>=0&&num(); } - ExaminerStatusType payloadForChamber(CSCIdType chamber) const { - std::map::const_iterator item = bCHAMB_PAYLOAD.find(chamber); + long payloadForChamber(int chamber) const { + std::map::const_iterator item = bCHAMB_PAYLOAD.find(chamber); if( item != bCHAMB_PAYLOAD.end() ) return item->second; else return 0; } - ExaminerStatusType statusForChamber(CSCIdType chamber) const { - std::map::const_iterator item = bCHAMB_STATUS.find(chamber); + long statusForChamber(int chamber) const { + std::map::const_iterator item = bCHAMB_STATUS.find(chamber); if( item != bCHAMB_STATUS.end() ) return item->second; else return 0; } - ExaminerStatusType errorsForChamber(CSCIdType chamber) const { - std::map::const_iterator item = bCHAMB_ERR.find(chamber); + long errorsForChamber(int chamber) const { + std::map::const_iterator item = bCHAMB_ERR.find(chamber); if( item != bCHAMB_ERR.end() ) return item->second; else return 0; } - ExaminerStatusType warningsForChamber(CSCIdType chamber) const { - std::map::const_iterator item = bCHAMB_WRN.find(chamber); + long warningsForChamber(int chamber) const { + std::map::const_iterator item = bCHAMB_WRN.find(chamber); if( item != bCHAMB_WRN.end() ) return item->second; else return 0; } - ExaminerStatusType errorsForDDU(DDUIdType dduSourceID) const { - std::map::const_iterator item = bDDU_ERR.find(dduSourceID); + long errorsForDDU(int dduSourceID) const { + std::map::const_iterator item = bDDU_ERR.find(dduSourceID); if( item != bDDU_ERR.end() ) return item->second; else return 0; } - ExaminerStatusType warningsForDDU(DDUIdType dduSourceID) const { - std::map::const_iterator item = bDDU_WRN.find(dduSourceID); + long warningsForDDU(int dduSourceID) const { + std::map::const_iterator item = bDDU_WRN.find(dduSourceID); if( item != bDDU_WRN.end() ) return item->second; else return 0; } - std::vector listOfDDUs(void) const { - std::vector DDUs; - std::map::const_iterator item = bDDU_ERR.begin(); + std::vector listOfDDUs(void) const { + std::vector DDUs; + std::map::const_iterator item = bDDU_ERR.begin(); while( item != bDDU_ERR.end() ){ DDUs.push_back(item->first); item++; } return DDUs; } - std::map errorsDetailedDDU (void) const { return bDDU_ERR; } - - std::map errorsDetailed (void) const { return bCHAMB_ERR; } - std::map warningsDetailed(void) const { return bCHAMB_WRN; } - std::map payloadDetailed (void) const { return bCHAMB_PAYLOAD; } - std::map statusDetailed (void) const { return bCHAMB_STATUS; } - - + std::map errorsDetailed (void) const { return bCHAMB_ERR; } + std::map warningsDetailed(void) const { return bCHAMB_WRN; } + std::map payloadDetailed (void) const { return bCHAMB_PAYLOAD; } + std::map statusDetailed (void) const { return bCHAMB_STATUS; } void crcALCT(bool enable); void crcTMB (bool enable); @@ -298,18 +205,18 @@ class CSCDCCExaminer { void modeDDU(bool enable); - DDUIdType dduSourceID(void){ return sourceID; } + short dduSourceID(void){ return sourceID; } - std::map DDU_block(void) const { return dduBuffers; } - std::map > DMB_block(void) const { return dmbBuffers; } + std::map DDU_block(void) const { return dduBuffers; } + std::map > DMB_block(void) const { return dmbBuffers; } - std::map DDU_ptrOffsets(void) const { return dduOffsets; } - std::map > DMB_ptrOffsets(void) const { return dmbOffsets; } + std::map DDU_ptrOffsets(void) const { return dduOffsets; } + std::map > DMB_ptrOffsets(void) const { return dmbOffsets; } - std::map DDU_size(void) const { return dduSize; } - std::map > DMB_size(void) const { return dmbSize; } + std::map DDU_size(void) const { return dduSize; } + std::map > DMB_size(void) const { return dmbSize; } - CSCDCCExaminer(ExaminerMaskType mask=0x1); + CSCDCCExaminer(unsigned long mask=0x1); ~CSCDCCExaminer(void){} }; diff --git a/trunk/EventFilter/CSCRawToDigi/src/CSCDCCExaminer.cc b/trunk/EventFilter/CSCRawToDigi/src/CSCDCCExaminer.cc index ad1f23cbd362b..baaa44800109e 100644 --- a/trunk/EventFilter/CSCRawToDigi/src/CSCDCCExaminer.cc +++ b/trunk/EventFilter/CSCRawToDigi/src/CSCDCCExaminer.cc @@ -40,14 +40,14 @@ void CSCDCCExaminer::modeDDU(bool enable){ } -CSCDCCExaminer::CSCDCCExaminer(ExaminerMaskType mask):nERRORS(29),nWARNINGS(5),nPAYLOADS(12),nSTATUSES(23),sERROR(nERRORS),sWARNING(nWARNINGS),sERROR_(nERRORS),sWARNING_(nWARNINGS),sDMBExpectedPayload(nPAYLOADS),sDMBEventStaus(nSTATUSES),examinerMask(mask){ +CSCDCCExaminer::CSCDCCExaminer(unsigned long mask):nERRORS(29),nWARNINGS(5),nPAYLOADS(12),nSTATUSES(23),sERROR(nERRORS),sWARNING(nWARNINGS),sERROR_(nERRORS),sWARNING_(nWARNINGS),sDMBExpectedPayload(nPAYLOADS),sDMBEventStaus(nSTATUSES),examinerMask(mask){ cout.redirect(std::cout); cerr.redirect(std::cerr); sERROR[0] = " Any errors "; sERROR[1] = " DDU Trailer Missing "; sERROR[2] = " DDU Header Missing "; - sERROR[3] = " DDU CRC Error (not yet implemented) "; sERROR[4] = " DDU Word Count Error "; + sERROR[3] = " DDU CRC Error (not yet implemented) "; sERROR[5] = " DMB Trailer Missing "; sERROR[6] = " DMB Header Missing "; sERROR[7] = " ALCT Trailer Missing "; @@ -126,8 +126,8 @@ CSCDCCExaminer::CSCDCCExaminer(ExaminerMaskType mask):nERRORS(29),nWARNINGS(5),n sERROR_[0] = " Any errors: 00"; sERROR_[1] = " DDU Trailer Missing: 01"; sERROR_[2] = " DDU Header Missing: 02"; - sERROR_[3] = " DDU CRC Error (not yet implemented): 03"; sERROR_[4] = " DDU Word Count Error: 04"; + sERROR_[3] = " DDU CRC Error (not yet implemented): 03"; sERROR_[5] = " DMB Trailer Missing: 05"; sERROR_[6] = " DMB Header Missing: 06"; sERROR_[7] = " ALCT Trailer Missing: 07"; @@ -183,7 +183,7 @@ CSCDCCExaminer::CSCDCCExaminer(ExaminerMaskType mask):nERRORS(29),nWARNINGS(5),n DDU_WordMismatch_Occurrences = 0; DDU_WordsSinceLastTrailer = 0; - TMB_WordsExpectedCorrection = 0; + TMB_WordsRPC = 0; TMB_Firmware_Revision = 0; zeroCounts(); @@ -203,10 +203,10 @@ CSCDCCExaminer::CSCDCCExaminer(ExaminerMaskType mask):nERRORS(29),nWARNINGS(5),n buf1 = &(tmpbuf[8]); buf2 = &(tmpbuf[12]); - bzero(tmpbuf, sizeof(uint16_t)*16); + bzero(tmpbuf, sizeof(short)*16); } -int32_t CSCDCCExaminer::check(const uint16_t* &buffer, int32_t length){ +long CSCDCCExaminer::check(const unsigned short* &buffer, long length){ if( length<=0 ) return -1; // 'buffer' is a sliding pointer; keep track of the true buffer @@ -270,7 +270,7 @@ int32_t CSCDCCExaminer::check(const uint16_t* &buffer, int32_t length){ buf0 = &(tmpbuf[4]); // Just for safety buf1 = &(tmpbuf[8]); // Just for safety buf2 = &(tmpbuf[12]); // Just for safety - bzero(tmpbuf,sizeof(uint16_t)*16); + bzero(tmpbuf,sizeof(unsigned short)*16); return length+12; } @@ -351,7 +351,7 @@ int32_t CSCDCCExaminer::check(const uint16_t* &buffer, int32_t length){ buf0 = &(tmpbuf[4]); // Just for safety buf1 = &(tmpbuf[8]); // Just for safety buf2 = &(tmpbuf[12]); // Just for safety - bzero(tmpbuf,sizeof(uint16_t)*16); + bzero(tmpbuf,sizeof(unsigned short)*16); return length+12; } @@ -672,7 +672,7 @@ int32_t CSCDCCExaminer::check(const uint16_t* &buffer, int32_t length){ // Check calculated CRC sum against reported if( checkCrcALCT ){ - uint32_t crc = ( fALCT_Format2007 ? buf0[1] : buf0[0] ) & 0x7ff; + unsigned long crc = ( fALCT_Format2007 ? buf0[1] : buf0[0] ) & 0x7ff; crc |= ((uint32_t)( ( fALCT_Format2007 ? buf0[2] : buf0[1] ) & 0x7ff)) << 11; if( ALCT_CRC != crc ){ fERROR[10] = true; @@ -695,10 +695,10 @@ int32_t CSCDCCExaminer::check(const uint16_t* &buffer, int32_t length){ // Calculation of CRC sum ( algorithm is written by Madorsky ) if( fALCT_Header && checkCrcALCT ){ - for(uint16_t j=0, w=0; j<4; ++j){ + for(unsigned short j=0, w=0; j<4; ++j){ ///w = buf0[j] & 0x7fff; w = buf0[j] & (fALCT_Format2007 ? 0xffff : 0x7fff); - for(uint32_t i=15, t=0, ncrc=0; i<16; i--){ + for(unsigned long i=15, t=0, ncrc=0; i<16; i--){ t = ((w >> i) & 1) ^ ((ALCT_CRC >> 21) & 1); ncrc = (ALCT_CRC << 1) & 0x3ffffc; ncrc |= (t ^ (ALCT_CRC & 1)) << 1; @@ -708,17 +708,22 @@ int32_t CSCDCCExaminer::check(const uint16_t* &buffer, int32_t length){ } } - // == Find Correction for TMB_WordsExpected, + // == Find Correction for TMB_WordsExpected due to RPC raw hits, // should it turn out to be the new RPC-aware format - if( fTMB_Header && ((buf0[2]&0xFFFF)==0x6E0B) ) { - TMB_WordsExpectedCorrection = 2 + // header/trailer for block of RPC raw hits - // ((buf_1[2]&0x0800)>>11) * ((buf_1[2]&0x0700)>>8) * TMB_Tbins * 2; // RPC raw hits - ( fTMB_Format2007 ? - ( TMB_Firmware_Revision >= 0x50c3 ? - // ((buf_1[0]&0x0010)>>4) * ((buf_1[0]&0x000c)>>2) * TMB_Tbins * 2 :// RPC raw hits TMB2007 rev.0x50c3 - ((buf_1[0]&0x0010)>>4) * ((buf_1[0]&0x000c)>>2) * ((buf_1[0]>>5) & 0x1F) * 2 : // RPC raw hits TMB2007 rev.0x50c3 - ((buf_1[0]&0x0040)>>6) * ((buf_1[0]&0x0030)>>4) * TMB_Tbins * 2):// RPC raw hits TMB2007 - ((buf_1[2]&0x0040)>>6) * ((buf_1[2]&0x0030)>>4) * TMB_Tbins * 2 ); // RPC raw hits + if( fTMB_Header && ((buf0[2]&0xFFFF)==0x6E0B) ) { + if (fTMB_Format2007) { + if (TMB_Firmware_Revision >= 0x50c3) { // TMB2007 rev.0x50c3 + // On/off * nRPCs * nTimebins * 2 words/RPC/bin + TMB_WordsRPC = ((buf_1[0]&0x0010)>>4) * ((buf_1[0]&0x000c)>>2) * ((buf_1[0]>>5) & 0x1F) * 2; + } + else { // TMB2007 (may not work since TMB_Tbins != RPC_Tbins) + TMB_WordsRPC = ((buf_1[0]&0x0040)>>6) * ((buf_1[0]&0x0030)>>4) * TMB_Tbins * 2; + } + } + else { // Old format + TMB_WordsRPC = ((buf_1[2]&0x0040)>>6) * ((buf_1[2]&0x0030)>>4) * TMB_Tbins * 2; + } + TMB_WordsRPC += 2; // add header/trailer for block of RPC raw hits } // == TMB Trailer found @@ -745,7 +750,7 @@ int32_t CSCDCCExaminer::check(const uint16_t* &buffer, int32_t length){ // Check calculated CRC sum against reported if( checkCrcTMB ){ - uint32_t crc = ( fTMB_Format2007 ? buf0[1]&0x7ff : buf0[0]&0x7ff ); + unsigned long crc = ( fTMB_Format2007 ? buf0[1]&0x7ff : buf0[0]&0x7ff ); crc |= ((uint32_t)( ( fTMB_Format2007 ? buf0[2]&0x7ff : buf0[1] & 0x7ff ) )) << 11; if( TMB_CRC != crc ){ fERROR[15] = true; @@ -772,25 +777,32 @@ int32_t CSCDCCExaminer::check(const uint16_t* &buffer, int32_t length){ // trailer words are suppressed. So far, we only have data with the // empty scope content, so more corrections will be needed once // non-empty scope data is available. -SV, 5 Nov 2008. + // + // If word count is not multiple of 4, add 2 optional words and + // 4 trailer words. if( buf_1[1]==0x6E0C || buf_1[1]==0x6B05 ) { - // RPW add 4 for TMB trailer - TMB_WordsExpected = TMB_WordsExpected + 4+ 2; // + TMB_WordsExpected += 6; + // Add RPC counts if RPC raw hits included. if( buf_1[0]==0x6E04 ) - TMB_WordsExpected = TMB_WordsExpected + TMB_WordsExpectedCorrection; + TMB_WordsExpected += TMB_WordsRPC; + } + // If word count is multiple of 4, add 4 trailer words. + else if( buf_1[3]==0x6E0C || buf_1[3]==0x6B05 ) { + TMB_WordsExpected += 4; + // Add RPC counts if RPC raw hits included. + if( buf_1[2]==0x6E04 ) + TMB_WordsExpected += TMB_WordsRPC; } - - if( buf_1[3]==0x6E0C && buf_1[2]==0x6E04 ) - TMB_WordsExpected = TMB_WordsExpected + 4 + TMB_WordsExpectedCorrection; CFEB_SampleWordCount = 0; cout << "T> "; } if( fTMB_Header && checkCrcTMB ){ - for(uint16_t j=0, w=0; j<4; ++j){ + for(unsigned short j=0, w=0; j<4; ++j){ ///w = buf0[j] & 0x7fff; w = buf0[j] & (fTMB_Format2007 ? 0xffff : 0x7fff); - for(uint32_t i=15, t=0, ncrc=0; i<16; i--){ + for(unsigned long i=15, t=0, ncrc=0; i<16; i--){ t = ((w >> i) & 1) ^ ((TMB_CRC >> 21) & 1); ncrc = (TMB_CRC << 1) & 0x3ffffc; ncrc |= (t ^ (TMB_CRC & 1)) << 1; @@ -1114,7 +1126,7 @@ int32_t CSCDCCExaminer::check(const uint16_t* &buffer, int32_t length){ buf0 = &(tmpbuf[4]); // Just for safety buf1 = &(tmpbuf[8]); // Just for safety buf2 = &(tmpbuf[12]); // Just for safety - bzero(tmpbuf, sizeof(uint16_t)*16); + bzero(tmpbuf, sizeof(short)*16); return length-4; } } @@ -1143,7 +1155,7 @@ int32_t CSCDCCExaminer::check(const uint16_t* &buffer, int32_t length){ buf0 = &(tmpbuf[4]); // Just for safety buf1 = &(tmpbuf[8]); // Just for safety buf2 = &(tmpbuf[12]); // Just for safety - bzero(tmpbuf, sizeof(uint16_t)*16); + bzero(tmpbuf, sizeof(short)*16); return length-4; } } diff --git a/trunk/EventFilter/CSCRawToDigi/src/CSCDigiToRaw.cc b/trunk/EventFilter/CSCRawToDigi/src/CSCDigiToRaw.cc index 0cf92d1e8902f..498c41566d5f3 100644 --- a/trunk/EventFilter/CSCRawToDigi/src/CSCDigiToRaw.cc +++ b/trunk/EventFilter/CSCRawToDigi/src/CSCDigiToRaw.cc @@ -112,9 +112,20 @@ void CSCDigiToRaw::add(const CSCComparatorDigiCollection & comparatorDigis) CSCDetId cscDetId=(*j).first; CSCEventData & cscData = findEventData(cscDetId); + bool me1a = (cscDetId.station()==1) && (cscDetId.ring()==4); BOOST_FOREACH(CSCComparatorDigi digi, (*j).second) { - cscData.add(digi, cscDetId.layer() ); + // Move ME1/A comparators from CFEB=0 to CFEB=4 if this has not + // been done already. + if (me1a && digi.getStrip() <= 16) { + CSCComparatorDigi digi_corr(64+digi.getStrip(), + digi.getComparator(), + digi.getTimeBinWord()); + cscData.add(digi_corr, cscDetId.layer()); + } + else { + cscData.add(digi, cscDetId.layer()); + } } } } @@ -179,11 +190,11 @@ void CSCDigiToRaw::createFedBuffers(const CSCStripDigiCollection& stripDigis, int l1a=e.id().event(); //need to add increments or get it from lct digis int bx = 0;//same as above - //int startingFED = FEDNumbering::MINCSCFEDID; + //int startingFED = FEDNumbering::getCSCFEDIds().first; std::map dccMap; - for (int idcc=FEDNumbering::MINCSCFEDID; - idcc<=FEDNumbering::MAXCSCFEDID;++idcc) + for (int idcc=FEDNumbering::getCSCFEDIds().first; + idcc<=FEDNumbering::getCSCFEDIds().second;++idcc) { //idcc goes from startingFed to startingFED+7 // @@ if ReadoutMapping changes, this'll have to change