Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:10:27

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