Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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