• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

roclib/src_nxyter/DataDebug.cxx (r4864/r680)

Go to the documentation of this file.
00001 #include "boost/format.hpp"
00002 
00003 #include "nxyter/DataDebug.h"
00004 
00005 using boost::format;
00006 
00053 //----------------------------------------------------------------------------
00055 
00099 void nxyter::DataDebug::print(std::ostream& os) const
00100 {
00101   static format fmt_01x("%01x");
00102   static format fmt_02x("%02x");
00103   static format fmt_03x("%03x");
00104   static format fmt_04x("%04x");
00105   static format fmt_08x("%08x");
00106   static format fmt_1d("%1d");
00107   static format fmt_2d("%2d");
00108   static format fmt_3d("%3d");
00109   static format fmt_4d("%4d");
00110   static format fmt_5d("%5d");
00111   static format fmt_08d("%08d");
00112   static format fmt_p4d("%+4d");
00113 
00114   uint32_t msgtyp   = getRawMessageType();
00115 
00116   uint32_t nxb3_flg = (fNx>>31) & 0x01;
00117   uint32_t nxb3_val = (fNx>>24) & 0x7f;
00118   uint32_t nxb2_flg = (fNx>>23) & 0x01;
00119   uint32_t nxb2_val = (fNx>>16) & 0x7f;
00120   uint32_t nxb1_flg = (fNx>>15) & 0x01;
00121   uint32_t nxb1_val = (fNx>>8 ) & 0x7f;
00122   uint32_t nxb0_flg = (fNx>>7 ) & 0x01;
00123   uint32_t nxb0_val = (fNx    ) & 0x7f;
00124   uint64_t ltsred   = getRawLts() % 100000000;
00125   // tsdiff is the signed difference between the nXYTER timestamp
00126   // and the corresponding 14 bits of the ROC local time stamp.
00127   // The wrapping is done such that value between -7 and + 505 cycles
00128   // at the 32 MHz clock level are produced.
00129   int      tsdiff   = int((fLtsLow&0xfff)<<2) - int(getNxTs());
00130   if (tsdiff < -224) tsdiff += 16384;        // wrap correction, see above
00131 
00132   if (msgtyp == 0) {
00133     os << "H:";
00134     os << " a:"  << fmt_4d % getNxAdcValue();
00135     os << " nx:";
00136     os << fmt_1d % nxb3_flg;
00137     os << fmt_1d % nxb2_flg;
00138     os << fmt_1d % nxb1_flg;
00139     os << fmt_1d % nxb0_flg;
00140     os << ":" << fmt_02x % nxb3_val;
00141     os << ":" << fmt_02x % nxb2_val;
00142     os << ":" << fmt_02x % nxb1_val;
00143     os << ":" << fmt_02x % nxb0_val;
00144     os << ( (getNxParity()!=getNxParityCheck()) ? "P" : " " );
00145     os << " "     << fmt_1d   % getNxNumber();
00146     os << ","     << fmt_3d   % getNxChNum();
00147     os << ","     << fmt_5d   % getNxTs();
00148     os << " lts:" << fmt_01x  % ((getRawLts()>>44) & 0xf);
00149     os << ":"     << fmt_08x  % ((getRawLts()>>12) & 0xffffffff);
00150     os << ":"     << fmt_03x  % (getRawLts() & 0xfff);
00151     os << " "     << fmt_08d  % ltsred;
00152     os << " "     << fmt_p4d  % (tsdiff>>5);       // 32 MHz clock slot
00153     os << ","     << fmt_1d   % ((tsdiff>>2)&0x7); // 256 Mhz sub-slot
00154     os << ","     << fmt_1d   % (tsdiff&0x3);      // 1 Ghz sub-slot
00155     os << std::endl;
00156   } else {
00157     os << "M: ";
00158     os << " typ:" << fmt_1d   % msgtyp;
00159     os << " dat:" << fmt_04x  % (fAdc & 0x1fff);
00160     os << ":"     << fmt_08x  % fNx;
00161     os << " lts:" << fmt_01x  % ((getRawLts()>>44) & 0xf);
00162     os << ":"     << fmt_08x  % ((getRawLts()>>12) & 0xffffffff);
00163     os << ":"     << fmt_03x  % (getRawLts() & 0xfff);
00164     os << " "     << fmt_08d  % ltsred;
00165     os << std::endl;
00166   }
00167 }
00168 
00169 //----------------------------------------------------------------------------
00171 
00177 uint32_t nxyter::DataDebug::getNxParityCheck() const
00178 {
00179   // this isn't meant to be efficient....
00180   uint32_t res = 1;
00181   for (int i=1; i<=30; i++) {
00182     if (i>2  && i<8 ) continue;
00183     if (i==15) continue;
00184     if (i>21 && i<24) continue;
00185     res ^= (fNx>>i) & 0x1;
00186   }
00187   return res;
00188 }
00189 
00190 //----------------------------------------------------------------------------
00192 
00193 uint32_t nxyter::DataDebug::ungray(uint32_t val, int n)
00194 {
00195   uint32_t b=0;
00196   uint32_t o=0;
00197   
00198   for (int i=n; i>0; i--){
00199     b = b ^ ((val & (1<<(i-1)))>>(i-1));
00200     o = o | (b << (i-1));
00201   }
00202   
00203   return o;
00204 }

Generated on Tue Dec 10 2013 04:52:23 for ROCsoft by  doxygen 1.7.1