Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:20:37

0001 #include "oncsSub_idsis3300.h"
0002 #include <cstring>
0003 
0004 oncsSub_idsis3300::oncsSub_idsis3300(subevtdata_ptr data)
0005   :oncsSubevent_w4 (data)
0006 {
0007   samples = 0;
0008   wraparound = 0;
0009 
0010 }
0011   
0012 int *oncsSub_idsis3300::decode ( int *nwout)
0013 {
0014   int *p;
0015 
0016 
0017   int i,j;
0018   int *SubeventData = &SubeventHdr->data;
0019 
0020   samples = (*SubeventData) & 0xffff;
0021   wraparound = (*SubeventData) >> 16;
0022 
0023   //  cout << "Samples: " << samples << std::endl;
0024 
0025   p = new int [samples*8];
0026   j = 0;
0027   for ( i = 0; i< samples*4; i++)
0028     {
0029       p[j++] = (SubeventData[i+1] >> 16) & 0x3fff;
0030       p[j++] = SubeventData[i+1] & 0x3fff;
0031     }
0032 
0033   *nwout = j-1;
0034   return p;
0035 }
0036 
0037 int oncsSub_idsis3300::iValue(const int ch ,const int s)
0038 {
0039 
0040   if ( decoded_data1 == 0 ) decoded_data1 = decode(&data1_length);
0041 
0042   if ( ch < 0 || ch >7 ) return 0;
0043   if ( s < 0 || s >=samples ) return 0;
0044 
0045   return decoded_data1[ch + 8*s];
0046 
0047 }
0048 
0049 int oncsSub_idsis3300::iValue(const int,const char *what)
0050 {
0051 
0052   if ( decoded_data1 == 0 ) decoded_data1 = decode(&data1_length);
0053 
0054   if ( strcmp(what,"SAMPLES") == 0 )
0055   {
0056     return samples;
0057   }
0058   // see if this is a "wraparound" event, where the samples cross
0059   // over the end of the memory and continue a low memory. This is
0060   // a debugging function since we think there might be a problem with those events. 
0061   if ( strcmp(what,"WRAPAROUND") == 0 )
0062   {
0063     return wraparound;
0064   }
0065 
0066   return 0;
0067 
0068 }
0069 
0070 
0071 void  oncsSub_idsis3300::dump ( OSTREAM& os )
0072 {
0073   int i,j;
0074 
0075   os << "Samples: " << iValue(0,"SAMPLES");
0076   if ( iValue(0,"WRAPAROUND") )
0077     {
0078       os << " - wrap-around reaodut";
0079     }
0080   os << std::endl;
0081 
0082   for ( i = 0; i < iValue(0,"SAMPLES"); i++)
0083     {
0084 
0085       os << std::setw(6) << i << " |  "; 
0086       for ( j = 0; j < 8; j++)
0087     {
0088       os << std::setw(8) << iValue(j,i) << "  ";
0089     }
0090       os << std::endl;
0091     }
0092   os << std::endl;
0093 }
0094