StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
stage_3_202203.cxx
1 #include <stdio.h>
2 #include <sys/types.h>
3 #include <string.h>
4 
5 #include "fcs_trg_base.h"
6 
7 // And the last stage where North and South are combined.
8 // For run21, output are 9 bits
9 // it goes first into the RAT and then to the LastDSM
10 
11 void fcs_trg_base::stage_3_202203(link_t link[], u_short *dsm_out)
12 {
13  *dsm_out = 0;
14 
15  if( (link[0].d[6] & 0x01) || (link[2].d[6] & 0x01) ) *dsm_out |= 0x1; //EcalHT FCS0
16  if( (link[0].d[6] & 0x02) || (link[2].d[6] & 0x02) ) *dsm_out |= 0x2; //HcalHT FCS1
17  if( (link[0].d[5] & 0x01) || (link[2].d[5] & 0x01) ) *dsm_out |= 0x4; //ETOT FCS2
18  if( (link[0].d[5] & 0x02) || (link[2].d[5] & 0x02) ) *dsm_out |= 0x8; //HTOT FCS3
19  if( (link[0].d[4] & 0x02) || (link[2].d[4] & 0x02) ) *dsm_out |= 0x10; //JP2 FCS4
20  if( (link[0].d[0] & 0x02) || (link[2].d[0] & 0x02) ) *dsm_out |= 0x20; //EM2 FCS5
21  if( (link[0].d[3] & 0x02) || (link[2].d[3] & 0x02) ) *dsm_out |= 0x40; //HAD2 FCS6
22  if( (link[0].d[2] & 0x02) || (link[2].d[2] & 0x02) ) *dsm_out |= 0x80; //GAM2 FCS7
23  if( (link[0].d[1] & 0x02) || (link[2].d[1] & 0x02) ) *dsm_out |= 0x100; //ELE2 FCS8
24  if( (link[0].d[4] & 0x01) && (link[2].d[4] & 0x01) ) *dsm_out |= 0x200; //DiJP1 FCS9
25  if( (link[0].d[0] & 0x01) && (link[2].d[0] & 0x01) ) *dsm_out |= 0x400; //DiEM1 FCS10
26  if( (link[0].d[3] & 0x01) && (link[2].d[3] & 0x01) ) *dsm_out |= 0x800; //DiHAD1 FCS11
27  if( (link[0].d[2] & 0x01) && (link[2].d[2] & 0x01) ) *dsm_out |= 0x1000; //DiGAM1 FCS12
28  if( (link[0].d[1] & 0x01) && (link[2].d[1] & 0x01) ) *dsm_out |= 0x2000; //DiELE1 FCS13
29  if( (link[0].d[6] & 0x04) || (link[2].d[6] & 0x04) ) *dsm_out |= 0x4000; //PresOR FCS14
30 
31 // *dsm_out |= 0x8000; // always 1 as a marker FCS15
32 
33  dsmout = *dsm_out;
34 
35  if(fcs_trgDebug>=1) {
36  printf("FCS STG3 input 0 = %02x %02x %02x %02x %02x %02x %02x %02x\n",
37  link[0].d[0],link[0].d[1],link[0].d[2],link[0].d[3],
38  link[0].d[4],link[0].d[5],link[0].d[6],link[0].d[7]);
39  printf("FCS STG3 input 1 = %02x %02x %02x %02x %02x %02x %02x %02x\n",
40  link[2].d[0],link[2].d[1],link[2].d[2],link[2].d[3],
41  link[2].d[4],link[2].d[5],link[2].d[6],link[2].d[7]);
42  printf("FCS STG3 output = %04x = ", *dsm_out);
43  for(int i=7; i>=0; i--){printf("%1d", (dsmout>>i)&0x1);}
44  printf("\n");
45  }
46 }