Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef EventFilter_CSCRawToDigi_CSCTMBHeader2020_CCLUT_h
0002 #define EventFilter_CSCRawToDigi_CSCTMBHeader2020_CCLUT_h
0003 #include "EventFilter/CSCRawToDigi/interface/CSCVTMBHeaderFormat.h"
0004 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
0005 
0006 struct CSCTMBHeader2020_CCLUT : public CSCVTMBHeaderFormat {
0007   enum { NWORDS = 43 };
0008   CSCTMBHeader2020_CCLUT();
0009   CSCTMBHeader2020_CCLUT(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   // == Run 3 CSC-GEM Trigger Format
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 0; }
0044   uint16_t gem_fifo_tbins() const override { return 0; }
0045   uint16_t gem_fifo_pretrig() const override { return 0; }
0046   uint16_t gem_zero_suppress() const override { return 0; }
0047   uint16_t gem_sync_dataword() const override { return 0; }
0048   uint16_t gem_timing_dataword() const override { return 0; }
0049 
0050   uint16_t run3_CLCT_patternID() const override {
0051     return (bits.MPC_Muon_clct_pattern_low | (bits.MPC_Muon_clct_pattern_bit5 << 4));
0052   }
0053   // ==
0054 
0055   ///returns CLCT digis
0056   std::vector<CSCCLCTDigi> CLCTDigis(uint32_t idlayer) override;
0057   ///returns CorrelatedLCT digis
0058   std::vector<CSCCorrelatedLCTDigi> CorrelatedLCTDigis(uint32_t idlayer) const override;
0059   ///returns lct HMT Shower digi
0060   CSCShowerDigi showerDigi(uint32_t idlayer) const override;
0061   ///returns anode HMT Shower digi
0062   CSCShowerDigi anodeShowerDigi(uint32_t idlayer) const override;
0063   ///returns cathode HMT Shower digi
0064   CSCShowerDigi cathodeShowerDigi(uint32_t idlayer) const override;
0065 
0066   /// in 16-bit words.  Add olne because we include beginning(b0c) and
0067   /// end (e0c) flags
0068   unsigned short int sizeInWords() const override { return NWORDS; }
0069 
0070   unsigned short int NHeaderFrames() const override { return bits.nHeaderFrames; }
0071   /// returns the first data word
0072   unsigned short* data() override { return (unsigned short*)(&bits); }
0073   bool check() const override { return bits.e0bline == 0x6e0b; }
0074 
0075   /// for data packing
0076   void addCLCT0(const CSCCLCTDigi& digi) override;
0077   void addCLCT1(const CSCCLCTDigi& digi) override;
0078   void addALCT0(const CSCALCTDigi& digi) override;
0079   void addALCT1(const CSCALCTDigi& digi) override;
0080   void addCorrelatedLCT0(const CSCCorrelatedLCTDigi& digi) override;
0081   void addCorrelatedLCT1(const CSCCorrelatedLCTDigi& digi) override;
0082   void addShower(const CSCShowerDigi& digi) override;
0083   void addAnodeShower(const CSCShowerDigi& digi) override;
0084   void addCathodeShower(const CSCShowerDigi& digi) override;
0085 
0086   void swapCLCTs(CSCCLCTDigi& digi1, CSCCLCTDigi& digi2);
0087 
0088   void print(std::ostream& os) const override;
0089 
0090   struct {
0091     // 0
0092     unsigned b0cline : 16;
0093     unsigned bxnCount : 12, dduCode1 : 3, flag1 : 1;
0094     unsigned l1aNumber : 12, dduCode2 : 3, flag2 : 1;
0095     unsigned readoutCounter : 12, dduCode3 : 3, flag3 : 1;
0096     // 4
0097     unsigned boardID : 5, cscID : 4, runID : 4, stackOvf : 1, syncError : 1, flag4 : 1;
0098     unsigned nHeaderFrames : 6, fifoMode : 3, r_type : 2, l1atype : 2, hasBuf : 1, bufFull : 1, flag5 : 1;
0099     unsigned bd_status : 15, flag6 : 1;
0100     unsigned firmRevCode : 15, flag7 : 1;
0101     // 8
0102     unsigned bxnPreTrigger : 12, tmb_clct0_discard : 1, tmb_clct1_discard : 1, clock_lock_lost : 1, flag8 : 1;
0103     unsigned preTrigCounter : 15, flag9 : 1;
0104     unsigned clct0_comparator_code : 12, clct0_xky : 2, hmt_nhits_bit0 : 1, flag10 : 1;  // 12-bits comp code fw version
0105     unsigned clctCounterLow : 15, flag11 : 1;
0106     // 12
0107     unsigned clctCounterHigh : 15, flag12 : 1;
0108     unsigned trigCounter : 15, flag13 : 1;
0109     unsigned clct1_comparator_code : 12, clct1_xky : 2, hmt_nhits_bit1 : 1, flag14 : 1;  // 12-bits comp code fw version
0110     unsigned alctCounterLow : 15, flag15 : 1;
0111     // 16
0112     unsigned alctCounterHigh : 15, flag16 : 1;
0113     unsigned uptimeCounterLow : 15, flag17 : 1;
0114     unsigned uptimeCounterHigh : 15, flag18 : 1;
0115     unsigned nCFEBs : 3, nTBins : 5, fifoPretrig : 5, scopeExists : 1, vmeExists : 1, flag19 : 1;
0116     // 20
0117     unsigned hitThresh : 3, pidThresh : 4, nphThresh : 3, pid_thresh_postdrift : 4, staggerCSC : 1, flag20 : 1;
0118     unsigned triadPersist : 4, dmbThresh : 3, alct_delay : 4, clct_width : 4, flag21 : 1;
0119     unsigned trigSourceVect : 9, clct0_slope : 4, clct0_LR_bend : 1, clct1_LR_bend : 1, flag22 : 1;
0120     unsigned activeCFEBs : 5, readCFEBs : 5, pop_l1a_match_win : 4, aff_source : 1, flag23 : 1;
0121     // 24
0122     unsigned tmbMatch : 1, alctOnly : 1, clctOnly : 1, matchWin : 4, noALCT : 1, oneALCT : 1, oneCLCT : 1, twoALCT : 1,
0123         twoCLCT : 1, dupeALCT : 1, dupeCLCT : 1, lctRankErr : 1, flag24 : 1;
0124     unsigned clct0_valid : 1, clct0_quality : 3, clct0_shape : 4, clct0_key_low : 7, flag25 : 1;
0125     unsigned clct1_valid : 1, clct1_quality : 3, clct1_shape : 4, clct1_key_low : 7, flag26 : 1;
0126     unsigned clct0_key_high : 1, clct1_key_high : 1, clct_bxn : 2, clct_sync_err : 1, clct0Invalid : 1,
0127         clct1Invalid : 1, clct1Busy : 1, parity_err_cfeb_ram : 5, parity_err_rpc : 1, parity_err_summary : 1,
0128         flag27 : 1;
0129     // 28
0130     unsigned alct0Valid : 1, alct0Quality : 2, alct0Amu : 1, alct0Key : 7, clct1_slope : 4, flag28 : 1;
0131     unsigned alct1Valid : 1, alct1Quality : 2, alct1Amu : 1, alct1Key : 7, drift_delay : 2, bcb_read_enable : 1,
0132         hs_layer_trig : 1, flag29 : 1;
0133     unsigned hmt_nhits_bits_high : 5, alct_ecc_err : 2, cfeb_badbits_found : 5, cfeb_badbits_blocked : 1, alctCfg : 1,
0134         bx0_match : 1, flag30 : 1;
0135     unsigned MPC_Muon0_alct_key_wire : 7, MPC_Muon_clct_pattern_low : 4, MPC_Muon0_lct_quality : 3,
0136         MPC_Muon0_clct_QuarterStrip : 1, flag31 : 1;
0137     // 32
0138     unsigned MPC_Muon0_clct_key_halfstrip : 8, MPC_Muon0_clct_LR : 1, MPC_Muon0_clct_EighthStrip : 1,
0139         MPC_Muon_alct_bxn : 1, MPC_Muon0_clct_bx0 : 1, MPC_Muon0_clct_bend_low : 3, flag32 : 1;
0140     unsigned MPC_Muon1_alct_key_wire : 7, MPC_Muon_clct_pattern_bit5 : 1, MPC_Muon_HMT_high : 3,
0141         MPC_Muon1_lct_quality : 3, MPC_Muon1_clct_QuarterStrip : 1, flag33 : 1;
0142     unsigned MPC_Muon1_clct_key_halfstrip : 8, MPC_Muon1_clct_LR : 1, MPC_Muon1_clct_EighthStrip : 1,
0143         MPC_Muon_HMT_bit0 : 1, MPC_Muon1_clct_bx0 : 1, MPC_Muon1_clct_bend_low : 3, flag34 : 1;
0144     unsigned MPC_Muon0_lct_vpf : 1, MPC_Muon0_clct_bend_bit4 : 1, MPC_Muon1_lct_vpf : 1, MPC_Muon1_clct_bend_bit4 : 1,
0145         MPCDelay : 4, MPCAccept : 2, CFEBsEnabled : 5, flag35 : 1;
0146     // 36
0147     unsigned RPCList : 2, NRPCs : 2, RPCEnable : 1, fifo_tbins_rpc : 5, fifo_pretrig_rpc : 5, flag36 : 1;
0148     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;
0149     unsigned r_buf_fence_dist : 11, buf_q_ovf_err : 1, buf_q_udf_err : 1, buf_q_adr_err : 1, buf_stalled : 1,
0150         flag38 : 1;
0151     unsigned buf_fence_cnt : 12, reverse_hs_csc : 1, reverse_hs_me1a : 1, reverse_hs_me1b : 1, flag39 : 1;
0152     // 40
0153     unsigned activeCFEBs_2 : 2, readCFEBs_2 : 2, cfeb_badbits_found_2 : 2, parity_err_cfeb_ram_2 : 2,
0154         CFEBsEnabled_2 : 2, buf_fence_cnt_is_peak : 1, mxcfeb : 1, trig_source_vec : 2, tmb_trig_pulse : 1, flag40 : 1;
0155     unsigned run3_trig_df : 1, gem_enable : 1, hmt_match_win : 4, tmb_alct_only_ro : 1, tmb_clct_only_ro : 1,
0156         tmb_match_ro : 1, tmb_trig_keep : 1, tmb_non_trig_keep : 1, cathode_hmt : 2, anode_hmt : 2, flag41 : 1;
0157     unsigned e0bline : 16;
0158   } bits;
0159 };
0160 
0161 #endif