Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:11:09

0001 #include "EventFilter/Utilities/interface/GlobalEventNumber.icc"
0002 
0003 namespace evf {
0004   namespace evtn {
0005 
0006     bool daq_board_sense(const unsigned char *p) {
0007       return (*(unsigned int *)(p + FEDHeader::length + DAQ_BOARDID_OFFSET * SLINK_WORD_SIZE / 2) >>
0008               DAQ_BOARDID_SHIFT) == DAQ_BOARDID_VALUE;
0009     }
0010 
0011     bool gtpe_board_sense(const unsigned char *p) {
0012       return (*(unsigned int *)(p + GTPE_BOARDID_OFFSET * SLINK_WORD_SIZE / 2) >> GTPE_BOARDID_SHIFT) != 0;
0013     }
0014 
0015     bool evm_board_sense(const unsigned char *p, size_t size) {
0016       switch (size) {
0017         case BST32_3BX:
0018           EVM_GTFE_BLOCK = EVM_GTFE_BLOCK_V0000;
0019           EVM_FDL_NOBX = 3;
0020           break;
0021         case BST32_5BX:
0022           EVM_GTFE_BLOCK = EVM_GTFE_BLOCK_V0000;
0023           EVM_FDL_NOBX = 5;
0024           break;
0025         case BST52_3BX:
0026           EVM_GTFE_BLOCK = EVM_GTFE_BLOCK_V0011;
0027           EVM_FDL_NOBX = 3;
0028           break;
0029         case BST52_5BX:
0030           EVM_GTFE_BLOCK = EVM_GTFE_BLOCK_V0011;
0031           EVM_FDL_NOBX = 5;
0032           break;
0033         default:
0034           EVM_GTFE_BLOCK = EVM_GTFE_BLOCK_V0000;
0035           EVM_FDL_NOBX = 3;
0036       }
0037       return (*(const unsigned int *)(p + FEDHeader::length + EVM_BOARDID_OFFSET * SLINK_WORD_SIZE / 2) >>
0038               EVM_BOARDID_SHIFT) == EVM_BOARDID_VALUE;
0039     }
0040 
0041     bool evm_tcs_board_sense(const unsigned char *p) {
0042       return (*(const unsigned int *)(p + FEDHeader::length +
0043                                       (EVM_GTFE_BLOCK * 2 + EVM_TCS_BOARDID_OFFSET) * SLINK_WORD_SIZE / 2) >>
0044               EVM_TCS_BOARDID_SHIFT) == EVM_TCS_BOARDID_VALUE;
0045     }
0046 
0047     void evm_board_setformat(size_t size) {
0048       switch (size) {
0049         case BST32_3BX:
0050           EVM_GTFE_BLOCK = EVM_GTFE_BLOCK_V0000;
0051           EVM_FDL_NOBX = 3;
0052           break;
0053         case BST32_5BX:
0054           EVM_GTFE_BLOCK = EVM_GTFE_BLOCK_V0000;
0055           EVM_FDL_NOBX = 5;
0056           break;
0057         case BST52_3BX:
0058           EVM_GTFE_BLOCK = EVM_GTFE_BLOCK_V0011;
0059           EVM_FDL_NOBX = 3;
0060           break;
0061         case BST52_5BX:
0062           EVM_GTFE_BLOCK = EVM_GTFE_BLOCK_V0011;
0063           EVM_FDL_NOBX = 5;
0064           break;
0065         default:
0066           EVM_GTFE_BLOCK = EVM_GTFE_BLOCK_V0000;
0067           EVM_FDL_NOBX = 3;
0068       }
0069     }
0070 
0071     unsigned int offset(bool evm) {
0072       if (evm)
0073         return FEDHeader::length + (EVM_GTFE_BLOCK * 2 + EVM_TCS_TRIGNR_OFFSET) * SLINK_WORD_SIZE / 2;
0074       else
0075         return FEDHeader::length + DAQ_TOTTRG_OFFSET * SLINK_WORD_SIZE / 2;
0076     }
0077     unsigned int get(const unsigned char *p, bool evm) {
0078       if (evm && evm_tcs_board_sense(p))
0079         return *(const unsigned int *)(p + offset(true));
0080       else
0081         return *(const unsigned int *)(p + offset(false));  // cover case of evm but invalid tcs info
0082     }
0083     unsigned int gtpe_get(const unsigned char *p) {
0084       return *(const unsigned int *)(p + GTPE_TRIGNR_OFFSET * SLINK_HALFWORD_SIZE);
0085     }
0086     unsigned int getlbn(const unsigned char *p) {
0087       return (*(const unsigned int *)(p + FEDHeader::length +
0088                                       (EVM_GTFE_BLOCK * 2 + EVM_TCS_LSBLNR_OFFSET) * SLINK_WORD_SIZE / 2)) &
0089              EVM_TCS_LSBLNR_MASK;
0090     }
0091     unsigned int gtpe_getlbn(const unsigned char *p) { return gtpe_getorbit(p) / 0x00100000; }
0092     unsigned int getgpslow(const unsigned char *p) {
0093       return (*(const unsigned int *)(p + FEDHeader::length + EVM_GTFE_BSTGPS_OFFSET * SLINK_WORD_SIZE / 2));
0094     }
0095     unsigned int getgpshigh(const unsigned char *p) {
0096       return (*(const unsigned int *)(p + FEDHeader::length + EVM_GTFE_BSTGPS_OFFSET * SLINK_WORD_SIZE / 2 +
0097                                       SLINK_HALFWORD_SIZE));
0098     }
0099     unsigned int getorbit(const unsigned char *p) {
0100       return (*(const unsigned int *)(p + FEDHeader::length +
0101                                       (EVM_GTFE_BLOCK * 2 + EVM_TCS_ORBTNR_OFFSET) * SLINK_WORD_SIZE / 2));
0102     }
0103     unsigned int getevtyp(const unsigned char *p) {
0104       return (((*(const unsigned int *)(p + FEDHeader::length +
0105                                         (EVM_GTFE_BLOCK * 2 + EVM_TCS_LSBLNR_OFFSET) * SLINK_WORD_SIZE / 2)) &
0106                EVM_TCS_EVNTYP_MASK) >>
0107               EVM_TCS_EVNTYP_SHIFT);
0108     }
0109     unsigned int gtpe_getorbit(const unsigned char *p) {
0110       return (*(const unsigned int *)(p + GTPE_ORBTNR_OFFSET * SLINK_HALFWORD_SIZE));
0111     }
0112     unsigned int getfdlbx(const unsigned char *p) {
0113       return (*(const unsigned int *)(p + FEDHeader::length +
0114                                       (EVM_GTFE_BLOCK + EVM_TCS_BLOCK + EVM_FDL_BLOCK * (EVM_FDL_NOBX / 2)) *
0115                                           SLINK_WORD_SIZE +
0116                                       EVM_FDL_BCNRIN_OFFSET * SLINK_HALFWORD_SIZE)) &
0117              EVM_TCS_BCNRIN_MASK;
0118     }
0119     unsigned int gtpe_getbx(const unsigned char *p) {
0120       return (*(const unsigned int *)(p + GTPE_BCNRIN_OFFSET * SLINK_HALFWORD_SIZE)) & GTPE_BCNRIN_MASK;
0121     }
0122     unsigned int getfdlpsc(const unsigned char *p) {
0123       return (*(const unsigned int *)(p + FEDHeader::length +
0124                                       (EVM_GTFE_BLOCK + EVM_TCS_BLOCK + EVM_FDL_BLOCK * (EVM_FDL_NOBX / 2)) *
0125                                           SLINK_WORD_SIZE +
0126                                       EVM_FDL_PSCVSN_OFFSET * SLINK_HALFWORD_SIZE));
0127     }
0128     unsigned long long getfdlttr(const unsigned char *p) {
0129       return (*(const unsigned long long *)(p + FEDHeader::length +
0130                                             (EVM_GTFE_BLOCK + EVM_TCS_BLOCK + EVM_FDL_BLOCK * (EVM_FDL_NOBX / 2)) *
0131                                                 SLINK_WORD_SIZE +
0132                                             EVM_FDL_TECTRG_OFFSET * SLINK_HALFWORD_SIZE));
0133     }
0134     unsigned long long getfdlta1(const unsigned char *p) {
0135       return (*(const unsigned long long *)(p + FEDHeader::length +
0136                                             (EVM_GTFE_BLOCK + EVM_TCS_BLOCK + EVM_FDL_BLOCK * (EVM_FDL_NOBX / 2)) *
0137                                                 SLINK_WORD_SIZE +
0138                                             EVM_FDL_ALGOB1_OFFSET * SLINK_HALFWORD_SIZE));
0139     }
0140     unsigned long long getfdlta2(const unsigned char *p) {
0141       return (*(const unsigned long long *)(p + FEDHeader::length +
0142                                             (EVM_GTFE_BLOCK + EVM_TCS_BLOCK + EVM_FDL_BLOCK * (EVM_FDL_NOBX / 2)) *
0143                                                 SLINK_WORD_SIZE +
0144                                             EVM_FDL_ALGOB2_OFFSET * SLINK_HALFWORD_SIZE));
0145     }
0146   }  // namespace evtn
0147 }  // namespace evf