00001 #include "DQM/SiStripMonitorHardware/interface/Fed9UDebugEvent.hh"
00002 #include <iomanip>
00003 #define hexpart << setfill('0') << setw(8)
00004
00005
00006 Fed9U::u32 Fed9U::Fed9UDebugEvent::getFSOP(unsigned int word, unsigned int FENumber) {
00007 Fed9U::u32 result;
00008
00009
00010 switch ( word ) {
00011 case 0 :
00012 result = (d_buffer.getu32(d_SPECIAL_OFF+120-(16*FENumber), true) & 0xFFFFFFFF);
00013 break;
00014 case 1 :
00015 result = (d_buffer.getu32(d_SPECIAL_OFF+124-(16*FENumber), true) & 0xFFFFFFFF);
00016 break;
00017 case 2 :
00018 result = (d_buffer.getu32(d_SPECIAL_OFF+132-(16*FENumber), true) & 0xFFFF);
00019 break;
00020 default :
00021 std::cerr << "?!?!" << std::endl;
00022 result = 0;
00023 }
00024 return result;
00025 }
00026
00027
00028 Fed9U::u16 Fed9U::Fed9UDebugEvent::getFLEN(unsigned int FENumber) {
00029
00030 return (d_buffer.getu16(d_SPECIAL_OFF+126-(16*FENumber), true) & 0xFFFF);
00031 }
00032
00033
00034 Fed9U::u32 Fed9U::Fed9UDebugEvent::getBESR() const {
00035 return (d_buffer.getu32(d_SPECIAL_OFF+18, true) & 0xFFFFFFFF);
00036 }
00037
00038
00039 Fed9U::u32 Fed9U::Fed9UDebugEvent::getRES(unsigned int WordNumber) {
00040
00041 return (d_buffer.getu32(d_SPECIAL_OFF+98-(16*WordNumber), true) & 0xFFFFFFFF);
00042 }
00043
00044
00045 Fed9U::u32 Fed9U::Fed9UDebugEvent::getDAQ(unsigned int DaqRegisterNumber) {
00046
00047 return (d_buffer.getu32(d_SPECIAL_OFF+130-(16*DaqRegisterNumber), true) & 0xFFFFFFFF);
00048 }
00049
00050 bool Fed9U::Fed9UDebugEvent::getAPV1Error(unsigned int fpga,unsigned int fiber) {
00051 return (!getBitFSOP(fiber*6,fpga));
00052 }
00053
00054 bool Fed9U::Fed9UDebugEvent::getAPV1WrongHeader(unsigned int fpga,unsigned int fiber) {
00055 return (!getBitFSOP(fiber*6+1,fpga));
00056 }
00057
00058 bool Fed9U::Fed9UDebugEvent::getAPV2Error(unsigned int fpga,unsigned int fiber) {
00059 return (!getBitFSOP(fiber*6+2,fpga));
00060 }
00061
00062 bool Fed9U::Fed9UDebugEvent::getAPV2WrongHeader(unsigned int fpga,unsigned int fiber) {
00063 return (!getBitFSOP(fiber*6+3,fpga));
00064 }
00065
00066 bool Fed9U::Fed9UDebugEvent::getOutOfSync(unsigned int fpga,unsigned int fiber) {
00067 return (!getBitFSOP(fiber*6+4,fpga));
00068 }
00069
00070 bool Fed9U::Fed9UDebugEvent::getUnlocked(unsigned int fpga,unsigned int fiber) {
00071 return (!getBitFSOP(fiber*6+5,fpga));
00072 }
00073
00074 bool Fed9U::Fed9UDebugEvent::getFeEnabled(unsigned int fpga) {
00075 return (((getSpecialFeEnableReg()>>(7-fpga))&0x1)==0x1);
00076 }
00077
00078 bool Fed9U::Fed9UDebugEvent::getFeOverflow(unsigned int fpga) {
00079 return (((getSpecialFeOverflowReg()>>(7-fpga))&0x1)==0x1);
00080 }
00081
00082 Fed9U::u16 Fed9U::Fed9UDebugEvent::getFeMajorAddress(unsigned int fpga) {
00083
00084 return ((getFSOP(2,fpga)>>8)&0xFF);
00085 }
00086
00087 bool Fed9U::Fed9UDebugEvent::getInternalFreeze() {
00088 return (((getBESR()>>1)&0x1)==0x1);
00089 }
00090
00091 bool Fed9U::Fed9UDebugEvent::getBXError() {
00092 return (((getBESR()>>5)&0x1)==0x1);
00093 }
00094
00095
00096 bool Fed9U::Fed9UDebugEvent::getBitFSOP(unsigned int bitNumber, unsigned int fpga) {
00097 Fed9U::u32 result = 0;
00098
00099 if (bitNumber<32)
00100
00101 result = (getFSOP(1,fpga) >> bitNumber) & 0x1;
00102 if ( bitNumber>=32 && bitNumber<64 )
00103
00104 result = (getFSOP(0,fpga) >> (bitNumber-32)) & 0x1;
00105 if ( bitNumber>=64 && bitNumber <80)
00106
00107 result = (getFSOP(2,fpga) >> (bitNumber-64)) & 0x1;
00108
00109 return (result != 0x0);
00110 }
00111
00112 bool Fed9U::Fed9UDebugEvent::getBufferCorrupt() const {
00113 if (getDaqMode() != FED9U_MODE_ZERO_SUPPRESSED ) return false;
00114 else {
00115 bool ret = false;
00116 try {
00117 checkEvent();
00118 } catch (ICUtils::ICException & e) {
00119 ret = true;
00120 return ret;
00121 }
00122
00123 for (int u=0; u<feUnits(); u++) {
00124
00125 if (!feUnit(u).dataLength()) continue;
00126
00127 for (int c=0; c<CHANNELS_PER_FEUNIT; c++) {
00128 if (feUnit(u).channel(c).getIterator().getu8(2) != 0xEA) {
00129 ret = true;
00130
00131 break;
00132 }
00133 }
00134
00135 if (ret) break;
00136 }
00137 return ret;
00138 }
00139 }
00140
00141 bool Fed9U::Fed9UDebugEvent::getQDRFull() const {
00142 return (getSpecialFedStatusRegister() & (0x1 << 2));
00143 }
00144
00145 bool Fed9U::Fed9UDebugEvent::getQDRPartialFull() const {
00146 return (getSpecialFedStatusRegister() & (0x1 << 3));
00147 }
00148
00149 bool Fed9U::Fed9UDebugEvent::getQDREmpty() const {
00150 return (getSpecialFedStatusRegister() & (0x1 << 4));
00151 }
00152
00153 bool Fed9U::Fed9UDebugEvent::getL1AFull() const {
00154 return (getSpecialFedStatusRegister() & (0x1 << 5));
00155 }
00156
00157 bool Fed9U::Fed9UDebugEvent::getL1APartialFull() const {
00158 return (getSpecialFedStatusRegister() & (0x1 << 6));
00159 }
00160
00161 bool Fed9U::Fed9UDebugEvent::getL1AEmpty() const {
00162 return (getSpecialFedStatusRegister() & (0x1 << 7));
00163 }
00164
00165 bool Fed9U::Fed9UDebugEvent::getSLinkFull() const {
00166 return (getSpecialFedStatusRegister() & 0x1);
00167 }