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