File indexing completed on 2025-08-03 08:20:47
0001 #include "oncsSub_idcaenv792.h"
0002 #include <cstring>
0003
0004 oncsSub_idcaenv792::oncsSub_idcaenv792(subevtdata_ptr data)
0005 :oncsSubevent_w4 (data)
0006 {
0007 samples = 0;
0008 }
0009
0010 int *oncsSub_idcaenv792::decode ( int *nwout)
0011 {
0012 int *p;
0013
0014
0015 int i,channel;
0016 int *SubeventData = &SubeventHdr->data;
0017
0018 samples = ( *SubeventData >> 8) & 0x3f;
0019
0020
0021
0022 p = new int [32];
0023 memset ( p, 0, 32*4);
0024
0025
0026 for ( i = 0; i< samples; i++)
0027 {
0028 if ( ( ( SubeventData[i+1] >> 24) & 7) == 0)
0029 {
0030 if ( getHitFormat() == IDCAENV785N)
0031 {
0032 channel = (SubeventData[i+1] >> 17) & 0x1f;
0033 }
0034 else
0035 {
0036 channel = (SubeventData[i+1] >> 16) & 0x3f;
0037 }
0038
0039 p[channel] = SubeventData[i+1] & 0xfff;
0040
0041
0042 }
0043 }
0044 evnr = SubeventData[samples +1] & 0xffffff;
0045
0046 *nwout = 32;
0047 return p;
0048 }
0049
0050 int oncsSub_idcaenv792::iValue(const int ch)
0051 {
0052
0053 if ( decoded_data1 == 0 ) decoded_data1 = decode(&data1_length);
0054
0055 if ( ch < 0 || ch >31 ) return 0;
0056
0057 return decoded_data1[ch];
0058
0059 }
0060
0061 int oncsSub_idcaenv792::iValue(const int,const char *what)
0062 {
0063
0064 if ( decoded_data1 == 0 ) decoded_data1 = decode(&data1_length);
0065
0066 if ( strcmp(what,"SAMPLES") == 0 )
0067 {
0068 return samples;
0069 }
0070
0071 if ( strcmp(what,"EVNR") == 0 )
0072 {
0073 return evnr;
0074 }
0075
0076 return 0;
0077
0078 }
0079
0080
0081 void oncsSub_idcaenv792::dump ( OSTREAM& os )
0082 {
0083 int i,j;
0084
0085
0086 os << "Samples: " << iValue(0,"SAMPLES") << std::endl;
0087 os << "Evt Nr: " << iValue(0,"EVNR") << std::endl;
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097 for ( i = 0; i < 32 ; i+=4)
0098 {
0099
0100 os << std::setw(6) << i << " | ";
0101 for ( j = 0; j < 4; j++)
0102 {
0103 os << std::setw(8) << iValue(j+i) << " ";
0104 }
0105 os << std::endl;
0106 }
0107 os << std::endl;
0108 }
0109