EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
oncsSub_iddigitizerv1.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file oncsSub_iddigitizerv1.cc
2 
3 #include <string.h>
4 
5 using namespace std;
6 
8  :oncsSubevent_w4 (data)
9 {
10 
11  _nsamples = 0;
12  _l1_delay = 0;
13  _slot_nr = 0;
14  _nr_modules = 0;
15  _clock = 0;
16  _evtnr = 0;
17  _nchannels = 0;
19  _is_decoded = 0;
20  // array = 0;
21 
22 }
23 
24 
26 {
27  // if (array) delete [][] array;
28 }
29 
30 
31 
32 const int offset=3;
33 
34 
36 {
37 
38  if (_is_decoded ) return 0;
39  _is_decoded = 1;
40 
41 
42  int *k;
43 
44 
45  // check later int dlength = ( getLength()-4) - getPadding();
46 
47  int *SubeventData = &SubeventHdr->data;
48 
49  _nsamples = (SubeventData[0] >> 24 ) & 0xff;
50  _l1_delay = (SubeventData[0] >> 16 ) & 0xff;
51  _slot_nr = (SubeventData[0] >> 8 ) & 0xff;
52  _nr_modules = SubeventData[0] & 0xff;
53 
54  _nchannels = _nr_modules * 64;
55 
56  _slot_nr_from_data = (SubeventData[1] >> 16 ) & 0xff;
57 
58  _clock = (SubeventData[2] >> 16 ) & 0xffff;
59  _evtnr = SubeventData[2] & 0xffff;
60 
61  //sanity check
62  if ( _nr_modules > 5 || _nsamples >31 || _slot_nr > 22)
63  {
64  return 0;
65  }
66 
67 
68  k = &SubeventData[offset];
69 
70  int index=0;
71  for ( int ch = 0; ch < _nchannels/2 ; ch++)
72  {
73  for ( int sample = 0; sample < _nsamples ; sample++)
74  {
75  array[sample][2*ch] = k[index] & 0xffff;
76  array[sample][2*ch+1] = (k[index]>>16) & 0xffff;
77  index++;
78  }
79  }
80 
81  return 0;
82 }
83 
84 
85 int oncsSub_iddigitizerv1::iValue(const int sample, const int ch)
86 {
88 
89  if ( sample >= _nsamples || sample < 0
90  || ch >= _nchannels || ch < 0 ) return 0;
91 
92  return array[sample][ch];
93 
94 }
95 
96 int oncsSub_iddigitizerv1::iValue(const int n, const char *what)
97 {
98 
100 
101  if ( strcmp(what,"SAMPLES") == 0 )
102  {
103  return _nsamples;
104  }
105 
106  if ( strcmp(what,"CHANNELS") == 0 )
107  {
108  return _nchannels;
109  }
110 
111  if ( strcmp(what,"L1DELAY") == 0 )
112  {
113  return _l1_delay;
114  }
115 
116  if ( strcmp(what,"SLOTNR") == 0 )
117  {
118  return _slot_nr;
119  }
120 
121  if ( strcmp(what,"NRMODULES") == 0 )
122  {
123  return _nr_modules;
124  }
125 
126  if ( strcmp(what,"CLOCK") == 0 )
127  {
128  return _clock;
129  }
130 
131  if ( strcmp(what,"EVTNR") == 0 )
132  {
133  return _evtnr;
134  }
135 
136  return 0;
137 
138 }
139 
141 {
142  identify(os);
143 
144  os << "Evt Nr: " << iValue(0,"EVTNR") << std::endl;
145  os << "Clock: " << iValue(0,"CLOCK") << std::endl;
146  os << "Channels: " << iValue(0,"CHANNELS") << std::endl;
147  os << "Samples: " << iValue(0,"SAMPLES") << std::endl;
148  os << "L1 Delay: " << iValue(0,"L1DELAY") << std::endl;
149  os << "Slot Nr: " << iValue(0,"SLOTNR") << std::endl;
150  os << "Nr Modules: " << iValue(0,"NRMODULES") << std::endl;
151  os << endl;
152 
153  // 0 | 8140 8136 8133 8136 8134 8133 8139 8135 8134 8134 8135 8130
154  // ch s01 s1 s2 s3 s4 s5 s6 s7 s8
155  for ( int c = 0; c < _nchannels; c++)
156  {
157  os << setw(4) << c << " | ";
158 
159  for ( int s = 0; s < _nsamples; s++)
160  {
161  os << setw(8) << iValue(s,c);
162  }
163  os << endl;
164  }
165 
166 }