CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2_patch1/src/EventFilter/FEDInterface/src/GlobalEventNumber.cc

Go to the documentation of this file.
00001 #include "EventFilter/FEDInterface/interface/GlobalEventNumber.icc"
00002 
00003 namespace evf{
00004   namespace evtn{
00005 
00006 
00007     bool evm_board_sense(const unsigned char *p, size_t size)
00008     {
00009       switch(size){
00010       case BST32_3BX:
00011         EVM_GTFE_BLOCK = EVM_GTFE_BLOCK_V0000;
00012         EVM_FDL_NOBX = 3;
00013         break;
00014       case BST32_5BX:
00015         EVM_GTFE_BLOCK = EVM_GTFE_BLOCK_V0000;
00016         EVM_FDL_NOBX = 5;
00017         break;
00018       case BST52_3BX:
00019         EVM_GTFE_BLOCK = EVM_GTFE_BLOCK_V0011;
00020         EVM_FDL_NOBX = 3;
00021         break;
00022       case BST52_5BX:
00023         EVM_GTFE_BLOCK = EVM_GTFE_BLOCK_V0011;
00024         EVM_FDL_NOBX = 5;
00025         break;
00026       default:
00027         EVM_GTFE_BLOCK = EVM_GTFE_BLOCK_V0000;
00028         EVM_FDL_NOBX = 3;           
00029       }
00030       return (*(const unsigned int*)(p + sizeof(fedh_t) + EVM_BOARDID_OFFSET * SLINK_WORD_SIZE / 2) >> EVM_BOARDID_SHIFT) == EVM_BOARDID_VALUE;
00031     }
00032 
00033 
00034     void evm_board_setformat(size_t size)
00035     {
00036       switch(size){
00037       case BST32_3BX:
00038         EVM_GTFE_BLOCK = EVM_GTFE_BLOCK_V0000;
00039         EVM_FDL_NOBX = 3;
00040         break;
00041       case BST32_5BX:
00042         EVM_GTFE_BLOCK = EVM_GTFE_BLOCK_V0000;
00043         EVM_FDL_NOBX = 5;
00044         break;
00045       case BST52_3BX:
00046         EVM_GTFE_BLOCK = EVM_GTFE_BLOCK_V0011;
00047         EVM_FDL_NOBX = 3;
00048         break;
00049       case BST52_5BX:
00050         EVM_GTFE_BLOCK = EVM_GTFE_BLOCK_V0011;
00051         EVM_FDL_NOBX = 5;
00052         break;
00053       default:
00054         EVM_GTFE_BLOCK = EVM_GTFE_BLOCK_V0000;
00055         EVM_FDL_NOBX = 3;           
00056       }
00057     }
00058     
00059 
00060     unsigned int offset(bool evm)
00061     {
00062       if(evm)
00063         return sizeof(fedh_t) + (EVM_GTFE_BLOCK*2 + EVM_TCS_TRIGNR_OFFSET) * SLINK_WORD_SIZE / 2;
00064       else
00065         return sizeof(fedh_t) + DAQ_TOTTRG_OFFSET * SLINK_WORD_SIZE / 2;
00066     }
00067     unsigned int get(const unsigned char *p, bool evm)
00068     {
00069       return *(const unsigned int*)( p+offset(evm) );
00070     }
00071     unsigned int gtpe_get(const unsigned char *p)
00072     {
00073       return *(const unsigned int*)( p + GTPE_TRIGNR_OFFSET*SLINK_HALFWORD_SIZE );
00074     }
00075     unsigned int getlbn(const unsigned char *p)
00076     { 
00077       return (*(const unsigned int*)( p+sizeof(fedh_t) + (EVM_GTFE_BLOCK*2 + EVM_TCS_LSBLNR_OFFSET) * SLINK_WORD_SIZE / 2)) 
00078         & EVM_TCS_LSBLNR_MASK;
00079     }
00080     unsigned int gtpe_getlbn(const unsigned char *p)
00081     { 
00082       return gtpe_getorbit(p)/0x00100000;
00083     }
00084     unsigned int getgpslow(const unsigned char *p)
00085     { 
00086       return (*(const unsigned int*)( p+sizeof(fedh_t) + EVM_GTFE_BSTGPS_OFFSET * SLINK_WORD_SIZE / 2));
00087     }
00088     unsigned int getgpshigh(const unsigned char *p)
00089     { 
00090       return (*(const unsigned int*)( p+sizeof(fedh_t) + EVM_GTFE_BSTGPS_OFFSET * SLINK_WORD_SIZE / 2 + SLINK_HALFWORD_SIZE));
00091     }
00092     unsigned int getorbit(const unsigned char *p)
00093     { 
00094       return (*(const unsigned int*)( p+sizeof(fedh_t) + (EVM_GTFE_BLOCK*2 + EVM_TCS_ORBTNR_OFFSET) * SLINK_WORD_SIZE / 2));
00095     }
00096     unsigned int getevtyp(const unsigned char *p)
00097     { 
00098       return (((*(const unsigned int*)( p+sizeof(fedh_t) + (EVM_GTFE_BLOCK*2 + EVM_TCS_LSBLNR_OFFSET) * SLINK_WORD_SIZE / 2)) 
00099               & EVM_TCS_EVNTYP_MASK) >> EVM_TCS_EVNTYP_SHIFT);
00100     }
00101     unsigned int gtpe_getorbit(const unsigned char *p)
00102     { 
00103       return (*(const unsigned int*)( p + GTPE_ORBTNR_OFFSET * SLINK_HALFWORD_SIZE));
00104     }
00105     unsigned int getfdlbx(const unsigned char *p)
00106     { 
00107       return (*(const unsigned int*)( p+sizeof(fedh_t) + (EVM_GTFE_BLOCK + EVM_TCS_BLOCK 
00108                                                     + EVM_FDL_BLOCK * (EVM_FDL_NOBX/2) ) * SLINK_WORD_SIZE +
00109                                 EVM_FDL_BCNRIN_OFFSET * SLINK_HALFWORD_SIZE)) &  EVM_TCS_BCNRIN_MASK;
00110     }
00111     unsigned int gtpe_getbx(const unsigned char *p)
00112     { 
00113       return (*(const unsigned int*)( p + GTPE_BCNRIN_OFFSET * SLINK_HALFWORD_SIZE)) &  GTPE_BCNRIN_MASK;
00114     }
00115     unsigned int getfdlpsc(const unsigned char *p)
00116     { 
00117       return (*(const unsigned int*)( p+sizeof(fedh_t) + (EVM_GTFE_BLOCK + EVM_TCS_BLOCK 
00118                                                     + EVM_FDL_BLOCK * (EVM_FDL_NOBX/2)) * SLINK_WORD_SIZE +
00119                                 EVM_FDL_PSCVSN_OFFSET * SLINK_HALFWORD_SIZE));
00120     }
00121     unsigned long long getfdlttr(const unsigned char *p)
00122     {
00123        return (*(const unsigned long long*)( p+sizeof(fedh_t) + (EVM_GTFE_BLOCK + EVM_TCS_BLOCK 
00124                                                            + EVM_FDL_BLOCK * (EVM_FDL_NOBX/2)) * SLINK_WORD_SIZE +
00125                                 EVM_FDL_TECTRG_OFFSET * SLINK_HALFWORD_SIZE));
00126     }
00127     unsigned long long getfdlta1(const unsigned char *p)
00128     {
00129        return (*(const unsigned long long*)( p+sizeof(fedh_t) + (EVM_GTFE_BLOCK + EVM_TCS_BLOCK 
00130                                                            + EVM_FDL_BLOCK * (EVM_FDL_NOBX/2)) * SLINK_WORD_SIZE +
00131                                 EVM_FDL_ALGOB1_OFFSET * SLINK_HALFWORD_SIZE));
00132     }
00133     unsigned long long getfdlta2(const unsigned char *p)
00134     {
00135        return (*(const unsigned long long*)( p+sizeof(fedh_t) + (EVM_GTFE_BLOCK + EVM_TCS_BLOCK 
00136                                                            + EVM_FDL_BLOCK * (EVM_FDL_NOBX/2)) * SLINK_WORD_SIZE +
00137                                 EVM_FDL_ALGOB2_OFFSET * SLINK_HALFWORD_SIZE));
00138     }
00139   }
00140 }