00001 #ifndef EVF_FEDINTERFACE_GLOBALEVENTNUMBER_H 00002 #define EVF_FEDINTERFACE_GLOBALEVENTNUMBER_H 00003 00004 00005 #include <stddef.h> 00006 #include "interface/shared/fed_header.h" // from xdaq 00007 00008 #include "EventFilter/FEDInterface/interface/FEDConstants.h" 00009 00010 namespace evf{ 00011 namespace evtn{ 00012 00013 const unsigned int DAQ_TOTTRG_OFFSET = 2; //offset in 32-bit words 00014 const unsigned int DAQ_BOARDID_OFFSET = 1; 00015 const unsigned int DAQ_BOARDID_MASK = 0xffff0000; 00016 const unsigned int DAQ_BOARDID_SHIFT = 24; 00017 const unsigned int DAQ_BOARDID_VALUE = 0x11; 00018 00019 enum EvmRecordScheme { 00020 BST32_3BX = 34 * SLINK_WORD_SIZE, 00021 BST32_5BX = 48 * SLINK_WORD_SIZE, 00022 BST52_3BX = 37 * SLINK_WORD_SIZE, 00023 BST52_5BX = 51 * SLINK_WORD_SIZE 00024 }; // EvmRecordsize 00025 00026 const unsigned int EVM_BOARDID_OFFSET = 1; 00027 const unsigned int EVM_BOARDID_MASK = 0xffff0000; 00028 const unsigned int EVM_BOARDID_SHIFT = 24; 00029 const unsigned int EVM_BOARDID_VALUE = 0x11; 00030 00031 const unsigned int EVM_GTFE_BLOCK_V0000 = 6; //size in 64-bit words 00032 const unsigned int EVM_GTFE_BLOCK_V0011 = 9; //size in 64-bit words, new format, not yet in effect 00033 const unsigned int EVM_GTFE_BSTGPS_OFFSET = 4; //offset in 32-bit words 00034 00035 const unsigned int EVM_TCS_BLOCK = 5; //size in 64-bit words 00036 const unsigned int EVM_TCS_TRIGNR_OFFSET = 5; //offset in 32-bit words 00037 const unsigned int EVM_TCS_LSBLNR_OFFSET = 0; //offset in 32-bit words 00038 const unsigned int EVM_TCS_ORBTNR_OFFSET = 6; //offset in 32-bit words 00039 const unsigned int EVM_TCS_LSBLNR_MASK = 0x0000ffff; // 16 LSB 00040 const unsigned int EVM_TCS_EVNTYP_MASK = 0x00f00000; // 4 bits 00041 const unsigned int EVM_TCS_EVNTYP_SHIFT = 20; 00042 const unsigned int EVM_TCS_BCNRIN_MASK = 0x00000fff; // 12 LSB 00043 00044 const unsigned int EVM_FDL_BLOCK = 7; //size in 64-bit words 00045 const unsigned int EVM_FDL_BCNRIN_OFFSET = 1; //offset in 32-bit words 00046 const unsigned int EVM_FDL_TECTRG_OFFSET = 2; //offset in 32-bit words 00047 const unsigned int EVM_FDL_ALGOB1_OFFSET = 4; //offset in 32-bit words 00048 const unsigned int EVM_FDL_ALGOB2_OFFSET = 6; //offset in 32-bit words 00049 const unsigned int EVM_FDL_PSCVSN_OFFSET = 11; //offset in 32-bit words 00050 00051 00052 00053 const unsigned int GTPE_BOARDID_OFFSET = 16; 00054 const unsigned int GTPE_BOARDID_MASK = 0x000000ff; 00055 const unsigned int GTPE_BOARDID_SHIFT = 0; 00056 const unsigned int GTPE_BOARDID_VALUE = 0x1; 00057 const unsigned int GTPE_TRIGNR_OFFSET = 14; //offset in 32-bit words 00058 const unsigned int GTPE_ORBTNR_OFFSET = 18; //offset in 32-bit words 00059 const unsigned int GTPE_BCNRIN_OFFSET = 3; //offset in 32-bit words 00060 const unsigned int GTPE_BCNRIN_MASK = 0x00000fff; // 12 LSB 00061 00062 unsigned int offset(bool); 00063 inline bool daq_board_sense(const unsigned char *p) 00064 { 00065 return (*(unsigned int*)(p + sizeof(fedh_t) + DAQ_BOARDID_OFFSET * SLINK_WORD_SIZE / 2) >> DAQ_BOARDID_SHIFT) == DAQ_BOARDID_VALUE; 00066 } 00067 bool evm_board_sense(const unsigned char *p, size_t size); 00068 void evm_board_setformat(size_t size); 00069 00070 inline bool gtpe_board_sense(const unsigned char *p) 00071 { 00072 return (*(unsigned int*)(p + GTPE_BOARDID_OFFSET * SLINK_WORD_SIZE / 2) >> GTPE_BOARDID_SHIFT) != 0; 00073 } 00074 unsigned int get(const unsigned char *, bool); 00075 unsigned int gtpe_get(const unsigned char *); 00076 unsigned int getlbn(const unsigned char *); 00077 unsigned int gtpe_getlbn(const unsigned char *); 00078 unsigned int getgpslow(const unsigned char *); 00079 unsigned int getgpshigh(const unsigned char *); 00080 unsigned int getorbit(const unsigned char *); 00081 unsigned int getevtyp(const unsigned char *); 00082 unsigned int gtpe_getorbit(const unsigned char *); 00083 unsigned int getfdlbx(const unsigned char *); 00084 unsigned int gtpe_getbx(const unsigned char *); 00085 unsigned int getfdlpsc(const unsigned char *); 00086 unsigned long long getfdlttr(const unsigned char *); 00087 unsigned long long getfdlta1(const unsigned char *); 00088 unsigned long long getfdlta2(const unsigned char *); 00089 } 00090 } 00091 #endif