File indexing completed on 2024-04-06 12:10:23
0001 #ifndef EventFilter_CSCRawToDigi_CSCTMBHeader2020_GEM_h
0002 #define EventFilter_CSCRawToDigi_CSCTMBHeader2020_GEM_h
0003 #include "EventFilter/CSCRawToDigi/interface/CSCVTMBHeaderFormat.h"
0004 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
0005
0006 struct CSCTMBHeader2020_GEM : public CSCVTMBHeaderFormat {
0007 enum { NWORDS = 43 };
0008 CSCTMBHeader2020_GEM();
0009 CSCTMBHeader2020_GEM(const unsigned short* buf);
0010 void setEventInformation(const CSCDMBHeader& dmbHeader) override;
0011
0012 uint16_t BXNCount() const override { return bits.bxnCount; }
0013 uint16_t ALCTMatchTime() const override { return bits.matchWin; }
0014 void setALCTMatchTime(uint16_t alctmatchtime) override { bits.matchWin = alctmatchtime & 0xF; }
0015 uint16_t CLCTOnly() const override { return bits.clctOnly; }
0016 uint16_t ALCTOnly() const override { return bits.alctOnly; }
0017 uint16_t TMBMatch() const override { return bits.tmbMatch; }
0018 uint16_t Bxn0Diff() const override { return 0; }
0019 uint16_t Bxn1Diff() const override { return 0; }
0020 uint16_t L1ANumber() const override { return bits.l1aNumber; }
0021 uint16_t NTBins() const override { return bits.nTBins; }
0022 uint16_t NCFEBs() const override { return bits.nCFEBs; }
0023 void setNCFEBs(uint16_t ncfebs) override { bits.nCFEBs = ncfebs & 0x7F; }
0024 uint16_t firmwareRevision() const override { return bits.firmRevCode; }
0025 uint16_t syncError() const override { return bits.syncError; }
0026 uint16_t syncErrorCLCT() const override { return bits.clct_sync_err; }
0027 uint16_t syncErrorMPC0() const override { return 0; }
0028 uint16_t syncErrorMPC1() const override { return 0; }
0029 uint16_t L1AMatchTime() const override { return bits.pop_l1a_match_win; }
0030
0031
0032 uint16_t clct0_ComparatorCode() const override { return bits.clct0_comparator_code; }
0033 uint16_t clct1_ComparatorCode() const override { return bits.clct1_comparator_code; }
0034 uint16_t clct0_xky() const override { return bits.clct0_xky; }
0035 uint16_t clct1_xky() const override { return bits.clct1_xky; }
0036 uint16_t hmt_nhits() const override {
0037 return ((bits.hmt_nhits_bit0 & 0x1) + ((bits.hmt_nhits_bit1 & 0x1) << 1) +
0038 ((bits.hmt_nhits_bits_high & 0x1F) << 2));
0039 }
0040 uint16_t hmt_ALCTMatchTime() const override { return bits.hmt_match_win; }
0041 uint16_t alctHMT() const override { return bits.anode_hmt; }
0042 uint16_t clctHMT() const override { return bits.cathode_hmt; }
0043 uint16_t gem_enabled_fibers() const override { return (bits.gem_enabled_fibers_ & 0xF); }
0044 uint16_t gem_fifo_tbins() const override { return bits.fifo_tbins_gem_; }
0045 uint16_t gem_fifo_pretrig() const override { return bits.fifo_pretrig_gem_; }
0046 uint16_t gem_zero_suppress() const override { return bits.gem_zero_suppression_; }
0047 uint16_t gem_sync_dataword() const override {
0048 return ((bits.lct0_nogem) + (bits.lct0_with_gemA << 1) + (bits.lct0_with_gemB << 2) + (bits.lct0_with_copad << 3) +
0049 (bits.lct1_nogem << 4) + (bits.lct1_with_gemA << 5) + (bits.lct1_with_gemB << 6) +
0050 (bits.lct1_with_copad << 7) + (bits.gemA_vpf << 8) + (bits.gemB_vpf << 9) + (bits.gemA_over_flow << 10) +
0051 (bits.gemB_over_flow << 11) + (bits.gemA_sync << 12) + (bits.gemB_sync << 13) + (bits.gems_sync << 14));
0052 }
0053 uint16_t gem_timing_dataword() const override {
0054 return ((bits.num_copad & 0xF) + ((bits.gem_delay & 0xF) << 4) + ((bits.gem_clct_win & 0xF) << 8) +
0055 ((bits.alct_gem_win & 0x7) << 12));
0056 }
0057 uint16_t run3_CLCT_patternID() const override {
0058 return (bits.MPC_Muon_clct_pattern_low | (bits.MPC_Muon_clct_pattern_bit5 << 4));
0059 }
0060
0061
0062
0063 std::vector<CSCCLCTDigi> CLCTDigis(uint32_t idlayer) override;
0064
0065 std::vector<CSCCorrelatedLCTDigi> CorrelatedLCTDigis(uint32_t idlayer) const override;
0066
0067 CSCShowerDigi showerDigi(uint32_t idlayer) const override;
0068
0069 CSCShowerDigi anodeShowerDigi(uint32_t idlayer) const override;
0070
0071 CSCShowerDigi cathodeShowerDigi(uint32_t idlayer) const override;
0072
0073
0074
0075 unsigned short int sizeInWords() const override { return NWORDS; }
0076
0077 unsigned short int NHeaderFrames() const override { return bits.nHeaderFrames; }
0078
0079 unsigned short* data() override { return (unsigned short*)(&bits); }
0080 bool check() const override { return bits.e0bline == 0x6e0b; }
0081
0082
0083 void addCLCT0(const CSCCLCTDigi& digi) override;
0084 void addCLCT1(const CSCCLCTDigi& digi) override;
0085 void addALCT0(const CSCALCTDigi& digi) override;
0086 void addALCT1(const CSCALCTDigi& digi) override;
0087 void addCorrelatedLCT0(const CSCCorrelatedLCTDigi& digi) override;
0088 void addCorrelatedLCT1(const CSCCorrelatedLCTDigi& digi) override;
0089 void addShower(const CSCShowerDigi& digi) override;
0090 void addAnodeShower(const CSCShowerDigi& digi) override;
0091 void addCathodeShower(const CSCShowerDigi& digi) override;
0092
0093 void swapCLCTs(CSCCLCTDigi& digi1, CSCCLCTDigi& digi2);
0094
0095 void print(std::ostream& os) const override;
0096
0097 struct {
0098
0099 unsigned b0cline : 16;
0100 unsigned bxnCount : 12, dduCode1 : 3, flag1 : 1;
0101 unsigned l1aNumber : 12, dduCode2 : 3, flag2 : 1;
0102 unsigned readoutCounter : 12, dduCode3 : 3, flag3 : 1;
0103
0104 unsigned boardID : 5, cscID : 4, runID : 4, stackOvf : 1, syncError : 1, flag4 : 1;
0105 unsigned nHeaderFrames : 6, fifoMode : 3, r_type : 2, l1atype : 2, hasBuf : 1, bufFull : 1, flag5 : 1;
0106 unsigned bd_status : 15, flag6 : 1;
0107 unsigned firmRevCode : 15, flag7 : 1;
0108
0109 unsigned bxnPreTrigger : 12, tmb_clct0_discard : 1, tmb_clct1_discard : 1, clock_lock_lost : 1, flag8 : 1;
0110 unsigned preTrigCounter : 15, flag9 : 1;
0111 unsigned clct0_comparator_code : 12, clct0_xky : 2, hmt_nhits_bit0 : 1, flag10 : 1;
0112 unsigned clctCounterLow : 15, flag11 : 1;
0113
0114 unsigned lct0_nogem : 1, lct0_with_gemA : 1, lct0_with_gemB : 1, lct0_with_copad : 1, lct1_nogem : 1,
0115 lct1_with_gemA : 1, lct1_with_gemB : 1, lct1_with_copad : 1, gemA_vpf : 1, gemB_vpf : 1, gemA_over_flow : 1,
0116 gemB_over_flow : 1, gemA_sync : 1, gemB_sync : 1, gems_sync : 1, flag12 : 1;
0117 unsigned trigCounter : 15, flag13 : 1;
0118 unsigned clct1_comparator_code : 12, clct1_xky : 2, hmt_nhits_bit1 : 1, flag14 : 1;
0119 unsigned alctCounterLow : 15, flag15 : 1;
0120
0121 unsigned num_copad : 4, gem_delay : 4, gem_clct_win : 4, alct_gem_win : 3, flag16 : 1;
0122 unsigned uptimeCounterLow : 15, flag17 : 1;
0123 unsigned uptimeCounterHigh : 15, flag18 : 1;
0124 unsigned nCFEBs : 3, nTBins : 5, fifoPretrig : 5, scopeExists : 1, vmeExists : 1, flag19 : 1;
0125
0126 unsigned hitThresh : 3, pidThresh : 4, nphThresh : 3, pid_thresh_postdrift : 4, staggerCSC : 1, flag20 : 1;
0127 unsigned triadPersist : 4, dmbThresh : 3, alct_delay : 4, clct_width : 4, flag21 : 1;
0128 unsigned trigSourceVect : 9, clct0_slope : 4, clct0_LR_bend : 1, clct1_LR_bend : 1, flag22 : 1;
0129 unsigned activeCFEBs : 5, readCFEBs : 5, pop_l1a_match_win : 4, aff_source : 1, flag23 : 1;
0130
0131 unsigned tmbMatch : 1, alctOnly : 1, clctOnly : 1, matchWin : 4, noALCT : 1, oneALCT : 1, oneCLCT : 1, twoALCT : 1,
0132 twoCLCT : 1, dupeALCT : 1, dupeCLCT : 1, lctRankErr : 1, flag24 : 1;
0133 unsigned clct0_valid : 1, clct0_quality : 3, clct0_shape : 4, clct0_key_low : 7, flag25 : 1;
0134 unsigned clct1_valid : 1, clct1_quality : 3, clct1_shape : 4, clct1_key_low : 7, flag26 : 1;
0135 unsigned clct0_key_high : 1, clct1_key_high : 1, clct_bxn : 2, clct_sync_err : 1, clct0Invalid : 1,
0136 clct1Invalid : 1, clct1Busy : 1, parity_err_cfeb_ram : 5, parity_err_rpc : 1, parity_err_summary : 1,
0137 flag27 : 1;
0138
0139 unsigned alct0Valid : 1, alct0Quality : 2, alct0Amu : 1, alct0Key : 7, clct1_slope : 4, flag28 : 1;
0140 unsigned alct1Valid : 1, alct1Quality : 2, alct1Amu : 1, alct1Key : 7, drift_delay : 2, bcb_read_enable : 1,
0141 hs_layer_trig : 1, flag29 : 1;
0142 unsigned hmt_nhits_bits_high : 5, alct_ecc_err : 2, cfeb_badbits_found : 5, cfeb_badbits_blocked : 1, alctCfg : 1,
0143 bx0_match : 1, flag30 : 1;
0144 unsigned MPC_Muon0_alct_key_wire : 7, MPC_Muon_clct_pattern_low : 4, MPC_Muon0_lct_quality : 3,
0145 MPC_Muon0_clct_QuarterStrip : 1, flag31 : 1;
0146
0147 unsigned MPC_Muon0_clct_key_halfstrip : 8, MPC_Muon0_clct_LR : 1, MPC_Muon0_clct_EighthStrip : 1,
0148 MPC_Muon_alct_bxn : 1, MPC_Muon0_clct_bx0 : 1, MPC_Muon0_clct_bend_low : 3, flag32 : 1;
0149 unsigned MPC_Muon1_alct_key_wire : 7, MPC_Muon_clct_pattern_bit5 : 1, MPC_Muon_HMT_high : 3,
0150 MPC_Muon1_lct_quality : 3, MPC_Muon1_clct_QuarterStrip : 1, flag33 : 1;
0151 unsigned MPC_Muon1_clct_key_halfstrip : 8, MPC_Muon1_clct_LR : 1, MPC_Muon1_clct_EighthStrip : 1,
0152 MPC_Muon_HMT_bit0 : 1, MPC_Muon1_clct_bx0 : 1, MPC_Muon1_clct_bend_low : 3, flag34 : 1;
0153 unsigned MPC_Muon0_lct_vpf : 1, MPC_Muon0_clct_bend_bit4 : 1, MPC_Muon1_lct_vpf : 1, MPC_Muon1_clct_bend_bit4 : 1,
0154 MPCDelay : 4, MPCAccept : 2, CFEBsEnabled : 5, flag35 : 1;
0155
0156 unsigned gem_enabled_fibers_ : 4, gem_zero_suppression_ : 1, fifo_tbins_gem_ : 5, fifo_pretrig_gem_ : 5, flag36 : 1;
0157 unsigned r_wr_buf_adr : 11, r_wr_buf_ready : 1, wr_buf_ready : 1, buf_q_full : 1, buf_q_empty : 1, flag37 : 1;
0158 unsigned r_buf_fence_dist : 11, buf_q_ovf_err : 1, buf_q_udf_err : 1, buf_q_adr_err : 1, buf_stalled : 1,
0159 flag38 : 1;
0160 unsigned buf_fence_cnt : 12, reverse_hs_csc : 1, reverse_hs_me1a : 1, reverse_hs_me1b : 1, flag39 : 1;
0161
0162 unsigned activeCFEBs_2 : 2, readCFEBs_2 : 2, cfeb_badbits_found_2 : 2, parity_err_cfeb_ram_2 : 2,
0163 CFEBsEnabled_2 : 2, buf_fence_cnt_is_peak : 1, gem_csc_bend_enable : 1, trig_source_vec : 2, tmb_trig_pulse : 1,
0164 flag40 : 1;
0165 unsigned run3_trig_df : 1, gem_enable : 1, hmt_match_win : 4, tmb_alct_only_ro : 1, tmb_clct_only_ro : 1,
0166 tmb_match_ro : 1, tmb_trig_keep : 1, tmb_non_trig_keep : 1, cathode_hmt : 2, anode_hmt : 2, flag41 : 1;
0167 unsigned e0bline : 16;
0168 } bits;
0169 };
0170
0171 #endif