Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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