10 unsigned short *p = pevent, sublength, plength, ptag, ID;
11 unsigned short nwords, words;
40 std::cout <<
"DecodedEvent: "
41 <<
"Wrong version of S800 sub-event. Aborting ..." << std::endl;
65 ID = ((*p) & 0xF000) >> 12;
126 UShort_t words = (*(p - 2)) - 2, ch, dum;
131 Short_t tac_obj = -1;
132 Short_t tac_xfp = -1;
134 ch = ((*p) & 0xf000) >> 12;
146 tac_obj = (tmp)&0xfff;
148 tac_xfp = (tmp)&0xfff;
149 else if (ch > 0 && ch < 8)
160 UShort_t words = (*(p - 2)) - 2, ch;
169 ch = ((*p) & 0xf000) >> 12;
171 s800 = (*p++) & 0xfff;
173 external1 = (*p++) & 0xfff;
175 external2 = (*p++) & 0xfff;
177 secondary = (*p++) & 0xfff;
180 this->
GetTrigger()->
Set(registr, s800, external1, external2, secondary);
192 if (updown % 2 == 0) {
193 de_up = (*p++) & 0xfff;
194 time_up = (*p++) & 0xfff;
196 de_down = (*p++) & 0xfff;
197 time_down = (*p++) & 0xfff;
206 UShort_t words = (*(p - 2)) - 2;
216 ch = (((*p) & 0xF000) >> 12);
217 energy = ((*p) & 0x0FFF);
222 }
else if (
id == 1) {
226 ch = (((*p) & 0xF000) >> 12) + 16;
227 energy = ((*p) & 0x0FFF);
232 }
else if (
id == 2) {
262 if (*(p + 1) == tag + 1) {
265 if (*(p + 1) == tag + 5) {
286 ch = ((*p) & 0xf000) >> 12;
287 raw = (*p++) & 0xfff;
293 UShort_t words = (*(p - 2)) - 2;
295 ch = ((*p) & 0xf000) >> 12;
296 raw = (*p++) & 0xfff;
307 static ULong_t total = 0, failed = 0;
308 Short_t sampleBegin = 0, sampleWidth, isample, ichannel, cdata[4], connector, previous_sample = 0, ch, sindex = 0,
309 previous_channel = 0, m_sampleWidth = 0;
314 unsigned short *pStore = p;
315 bool mes1 =
true, mes2 =
true, mes3 =
true, mes4 =
true;
317 UShort_t length = *p++;
318 short i = length - 3;
320 UShort_t threshold = *p++;
322 unsigned short data_test[256][32];
323 memset(data_test, 0,
sizeof(data_test));
326 if ((*p) >> 15 != 1) {
327 std::cout <<
"DecodedEvent: "
328 <<
"CRDC data is corrupted!" << std::endl;
333 isample = ((*p) & 0x7FC0) >> 6;
334 ichannel = (*p) & 0x003F;
335 if (i == length - 3) {
336 sampleBegin = isample;
337 previous_sample = isample;
339 if (previous_channel > ichannel)
341 previous_channel = ichannel;
345 memset(cdata, 0,
sizeof(cdata));
346 while ((*p) >> 15 == 0) {
347 connector = ((*p) & 0x0C00) >> 10;
348 cdata[connector] = (*p) & 0x3FF;
354 if (isample < sampleBegin || isample > sampleBegin + maxwidth) {
356 printf(
"Warning in Crdc Unpack: inconsistent sample number: %d (first: %d)\n", isample, sampleBegin);
360 if (isample < previous_sample) {
362 printf(
"Warning in Crdc Unpack: sample number lower than previous: %d (previous: %d)\n", isample,
367 previous_sample = isample;
368 for (
int j = 0; j < 4; j++) {
369 ch = ichannel + j * 64;
370 if (cdata[j] != 0 && ch < channels) {
371 if (cdata[j] < threshold) {
373 printf(
"Warning in Crdc Unpack: data lower than threshold: %d (threshold: %d)\n", cdata[j],
378 this->
GetCrdc(
id)->
Set(cdata[j], isample, ch);
379 data_test[ch][sindex] = cdata[j];
381 }
else if (cdata[j] != 0 && ch >= channels) {
383 printf(
"Warning in Crdc Unpack: channel greater than limit: %d (limit: %d)\n", ch, channels);
388 m_sampleWidth = sindex + 1;
389 sampleWidth = isample - sampleBegin + 1;
395 for (
int q = 0; q < channels; q++) {
398 for (
int s = 0; s < m_sampleWidth; s++) {
399 if (data_test[q][s] != 0) {
404 id, q, this->
GetCrdc_test()->Get_raw(
id, q) + (data_test[q][s]));
409 std::cout <<
"raw " << this->
GetCrdc_test()->
Get_raw(
id, q) <<
" nsamples " << nsamples << std::endl;
415 if (!mes1 || !mes2 || !mes3 || !mes4)
418 if (failed == 1000) {
420 printf(
"Errors in Crdc Unpackings: %g%%\n", 1.0 * failed / total * 100);
424 return (pStore + length);
432 unsigned short data[32][32];
433 signed short hits[32];
434 unsigned short raw[32];
435 for (
int i = 0; i < 32; i++) {
438 for (
int j = 0; j < 32; j++) {
443 UShort_t length, ch, hit;
450 data[ch][hit] = *p++;
454 raw[ch] = data[ch][0];
461 for (
int i = 0; i < 13; i++) {
475 for (
int j = 0; j <= hits[2]; j++) {
482 for (
int j = 0; j <= hits[3]; j++) {
489 for (
int j = 0; j <= hits[4]; j++) {
496 for (
int j = 0; j <= hits[5]; j++) {
503 for (
int j = 0; j <= hits[12]; j++) {