Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-11-12 00:01:08

0001 #include "EventFilter/CSCRawToDigi/interface/CSCTMBHeader2007_rev0x50c3.h"
0002 #include "EventFilter/CSCRawToDigi/interface/CSCDMBHeader.h"
0003 #include "FWCore/Utilities/interface/Exception.h"
0004 
0005 CSCTMBHeader2007_rev0x50c3::CSCTMBHeader2007_rev0x50c3() {
0006   bzero(data(), sizeInWords() * 2);
0007   bits.nHeaderFrames = 42;
0008   bits.e0bline = 0x6E0B;
0009   bits.b0cline = 0xDB0C;
0010   bits.firmRevCode = 0x50c3;
0011   bits.nTBins = 12;
0012   bits.nCFEBs = 5;
0013 }
0014 
0015 CSCTMBHeader2007_rev0x50c3::CSCTMBHeader2007_rev0x50c3(const unsigned short* buf) {
0016   memcpy(data(), buf, sizeInWords() * 2);
0017 }
0018 
0019 void CSCTMBHeader2007_rev0x50c3::setEventInformation(const CSCDMBHeader& dmbHeader) {
0020   bits.cscID = dmbHeader.dmbID();
0021   bits.l1aNumber = dmbHeader.l1a24() & 0xFFF;
0022 }
0023 
0024 ///returns CLCT digis
0025 std::vector<CSCCLCTDigi> CSCTMBHeader2007_rev0x50c3::CLCTDigis(uint32_t idlayer) {
0026   std::vector<CSCCLCTDigi> result;
0027   int halfstrip = bits.clct0_key_low + (bits.clct0_key_high << 7);
0028   int strip = halfstrip % CSCConstants::NUM_HALF_STRIPS_PER_CFEB;
0029   int cfeb = halfstrip / CSCConstants::NUM_HALF_STRIPS_PER_CFEB;
0030   int pattern = bits.clct0_shape;
0031   int bend = pattern & 0x1;
0032 
0033   //offlineStripNumbering(strip, cfeb, pattern, bend);
0034   CSCCLCTDigi digi0(
0035       bits.clct0_valid, bits.clct0_quality, pattern, 1, bend, strip, cfeb, bits.clct_bxn, 1, bits.bxnPreTrigger);
0036 
0037   halfstrip = bits.clct1_key_low + (bits.clct1_key_high << 7);
0038   strip = halfstrip % CSCConstants::NUM_HALF_STRIPS_PER_CFEB;
0039   cfeb = halfstrip / CSCConstants::NUM_HALF_STRIPS_PER_CFEB;
0040   pattern = bits.clct1_shape;
0041   bend = pattern & 0x1;
0042 
0043   //offlineStripNumbering(strip, cfeb, pattern, bend);
0044   CSCCLCTDigi digi1(
0045       bits.clct1_valid, bits.clct1_quality, pattern, 1, bend, strip, cfeb, bits.clct_bxn, 2, bits.bxnPreTrigger);
0046   result.push_back(digi0);
0047   result.push_back(digi1);
0048   return result;
0049 }
0050 
0051 ///returns CorrelatedLCT digis
0052 std::vector<CSCCorrelatedLCTDigi> CSCTMBHeader2007_rev0x50c3::CorrelatedLCTDigis(uint32_t idlayer) const {
0053   std::vector<CSCCorrelatedLCTDigi> result;
0054   /// for the zeroth MPC word:
0055   int strip = bits.MPC_Muon0_halfstrip_clct_pattern;  //this goes from 0-159
0056   //offlineHalfStripNumbering(strip);
0057   CSCCorrelatedLCTDigi digi(1,
0058                             bits.MPC_Muon0_vpf_,
0059                             bits.MPC_Muon0_quality_,
0060                             bits.MPC_Muon0_wire_,
0061                             strip,
0062                             bits.MPC_Muon0_clct_pattern_,
0063                             bits.MPC_Muon0_bend_,
0064                             bits.MPC_Muon0_bx_,
0065                             0,
0066                             bits.MPC_Muon0_bc0_,
0067                             bits.MPC_Muon0_SyncErr_,
0068                             bits.MPC_Muon0_cscid_low | (bits.MPC_Muon0_cscid_bit4 << 3));
0069   result.push_back(digi);
0070   /// for the first MPC word:
0071   strip = bits.MPC_Muon1_halfstrip_clct_pattern;  //this goes from 0-159
0072   //offlineHalfStripNumbering(strip);
0073   digi = CSCCorrelatedLCTDigi(2,
0074                               bits.MPC_Muon1_vpf_,
0075                               bits.MPC_Muon1_quality_,
0076                               bits.MPC_Muon1_wire_,
0077                               strip,
0078                               bits.MPC_Muon1_clct_pattern_,
0079                               bits.MPC_Muon1_bend_,
0080                               bits.MPC_Muon1_bx_,
0081                               0,
0082                               bits.MPC_Muon1_bc0_,
0083                               bits.MPC_Muon1_SyncErr_,
0084                               bits.MPC_Muon1_cscid_low | (bits.MPC_Muon1_cscid_bit4 << 3));
0085   result.push_back(digi);
0086   return result;
0087 }
0088 
0089 void CSCTMBHeader2007_rev0x50c3::addALCT0(const CSCALCTDigi& digi) {
0090   throw cms::Exception("In CSC TMBHeaderFormat 2007, ALCTs belong in  ALCT header");
0091 }
0092 
0093 void CSCTMBHeader2007_rev0x50c3::addALCT1(const CSCALCTDigi& digi) {
0094   throw cms::Exception("In CSC TMBHeaderFormat 2007, ALCTs belong in  ALCT header");
0095 }
0096 
0097 void CSCTMBHeader2007_rev0x50c3::addCLCT0(const CSCCLCTDigi& digi) {
0098   int halfStrip = digi.getKeyStrip();
0099   int pattern = digi.getPattern();
0100   //int bend = digi.getBend();
0101   //hardwareStripNumbering(strip, cfeb, pattern, bend);
0102   bits.clct0_valid = digi.isValid();
0103   bits.clct0_quality = digi.getQuality();
0104   bits.clct0_shape = pattern;
0105   // first 7 bits of halfstrip
0106   bits.clct0_key_low = halfStrip & (0x7F);
0107   // most-significant (8th) bit
0108   bits.clct0_key_high = (halfStrip >> 7) & (0x1);
0109   bits.clct_bxn = digi.getBX();
0110   bits.bxnPreTrigger = digi.getFullBX();
0111 }
0112 
0113 void CSCTMBHeader2007_rev0x50c3::addCLCT1(const CSCCLCTDigi& digi) {
0114   int halfStrip = digi.getKeyStrip();
0115   int pattern = digi.getPattern();
0116   //int bend = digi.getBend();
0117   //hardwareStripNumbering(strip, cfeb, pattern, bend);
0118   bits.clct1_valid = digi.isValid();
0119   bits.clct1_quality = digi.getQuality();
0120   bits.clct1_shape = pattern;
0121   // first 7 bits of halfstrip
0122   bits.clct1_key_low = halfStrip & (0x7F);
0123   // most-significant (8th) bit
0124   bits.clct1_key_high = (halfStrip >> 7) & (0x1);
0125   // There is just one BX field common for CLCT0 and CLCT1 (since both
0126   // are latched at the same BX); set it in addCLCT0().
0127   //bits.clct_bxn = digi.getBX();
0128   bits.bxnPreTrigger = digi.getFullBX();
0129   bits.bxnCount = (digi.getFullBX() + 167) & 0xFFF;
0130 }
0131 
0132 void CSCTMBHeader2007_rev0x50c3::addCorrelatedLCT0(const CSCCorrelatedLCTDigi& digi) {
0133   int halfStrip = digi.getStrip();
0134   //hardwareHalfStripNumbering(halfStrip);
0135 
0136   bits.MPC_Muon0_vpf_ = digi.isValid();
0137   bits.MPC_Muon0_wire_ = digi.getKeyWG();
0138   bits.MPC_Muon0_clct_pattern_ = digi.getPattern();
0139   bits.MPC_Muon0_quality_ = digi.getQuality();
0140   bits.MPC_Muon0_halfstrip_clct_pattern = halfStrip;
0141   bits.MPC_Muon0_bend_ = digi.getBend();
0142   bits.MPC_Muon0_SyncErr_ = digi.getSyncErr();
0143   bits.MPC_Muon0_bx_ = digi.getBX();
0144   bits.MPC_Muon0_bc0_ = digi.getBX0();
0145   bits.MPC_Muon0_cscid_low = digi.getCSCID() & 0x7;
0146   bits.MPC_Muon0_cscid_bit4 = (digi.getCSCID() >> 3) & 0x1;
0147 }
0148 
0149 void CSCTMBHeader2007_rev0x50c3::addCorrelatedLCT1(const CSCCorrelatedLCTDigi& digi) {
0150   int halfStrip = digi.getStrip();
0151   //hardwareHalfStripNumbering(halfStrip);
0152 
0153   bits.MPC_Muon1_vpf_ = digi.isValid();
0154   bits.MPC_Muon1_wire_ = digi.getKeyWG();
0155   bits.MPC_Muon1_clct_pattern_ = digi.getPattern();
0156   bits.MPC_Muon1_quality_ = digi.getQuality();
0157   bits.MPC_Muon1_halfstrip_clct_pattern = halfStrip;
0158   bits.MPC_Muon1_bend_ = digi.getBend();
0159   bits.MPC_Muon1_SyncErr_ = digi.getSyncErr();
0160   bits.MPC_Muon1_bx_ = digi.getBX();
0161   bits.MPC_Muon1_bc0_ = digi.getBX0();
0162   bits.MPC_Muon1_cscid_low = digi.getCSCID() & 0x7;
0163   bits.MPC_Muon1_cscid_bit4 = (digi.getCSCID() >> 3) & 0x1;
0164 }
0165 
0166 void CSCTMBHeader2007_rev0x50c3::print(std::ostream& os) const {
0167   os << "...............TMB Header.................."
0168      << "\n";
0169   os << std::hex << "BOC LINE " << bits.b0cline << " EOB " << bits.e0bline << "\n";
0170   os << std::dec << "fifoMode = " << bits.fifoMode << ", nTBins = " << bits.nTBins << "\n";
0171   os << "boardID = " << bits.boardID << ", cscID = " << bits.cscID << "\n";
0172   os << "l1aNumber = " << bits.l1aNumber << ", bxnCount = " << bits.bxnCount << "\n";
0173   os << "trigSourceVect = " << bits.trigSourceVect << ", activeCFEBs = " << bits.activeCFEBs << "\n";
0174   os << "bxnPreTrigger = " << bits.bxnPreTrigger << "\n";
0175   os << "tmbMatch = " << bits.tmbMatch << " alctOnly = " << bits.alctOnly << " clctOnly = " << bits.clctOnly << "\n";
0176   os << " bits.clct0_shape = " << bits.clct0_shape << " clct0_quality = " << bits.clct0_quality << "\n";
0177   os << "..................CLCT....................."
0178      << "\n";
0179 }