StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
stage_3_202201.cxx
1 #include <stdio.h>
2 #include <sys/types.h>
3 #include <string.h>
4 
5 #include "fcs_trg_base.h"
6 
7 //#include "fcs_trg_201901.h"
8 
9 // And the last stage where North and South are combined.
10 // Output is a 12 bit value (max) which goes into STAR Trigger
11 // either LastDSM, RAT, TCU, etc.
12 
13 // Tonko: it goes first into the RAT and then to the LastDSM
14 
15 void fcs_trg_base::stage_3_202201(link_t link[], u_short *dsm_out)
16 {
17  *dsm_out = 0;
18 
19  if( (link[0].d[0] & 0x01) || (link[2].d[0] & 0x01) ) *dsm_out |= 0x1; //EM1
20  if( (link[0].d[0] & 0x02) || (link[2].d[0] & 0x02) ) *dsm_out |= 0x2; //EM2
21  if( (link[0].d[0] & 0x01) && (link[2].d[0] & 0x01) ) *dsm_out |= 0x4; //EM1 N*S
22  if( (link[0].d[1] & 0x01) || (link[2].d[1] & 0x01) ) *dsm_out |= 0x8; //ELE1
23  if( (link[0].d[1] & 0x02) || (link[2].d[1] & 0x02) ) *dsm_out |= 0x10; //ELE2
24  if( (link[0].d[1] & 0x01) && (link[2].d[1] & 0x01) ) *dsm_out |= 0x20; //ELE1 N*S
25  if( (link[0].d[2] & 0x01) || (link[2].d[2] & 0x01) ) *dsm_out |= 0x40; //GAM1
26  if( (link[0].d[2] & 0x02) || (link[2].d[2] & 0x02) ) *dsm_out |= 0x80; //GAM2
27  if( (link[0].d[3] & 0x01) || (link[2].d[3] & 0x01) ) *dsm_out |= 0x100; //HAD1
28  if( (link[0].d[4] & 0x01) || (link[2].d[4] & 0x01) ) *dsm_out |= 0x200; //JP1
29  if( (link[0].d[5] & 0x01) || (link[2].d[5] & 0x01) ) *dsm_out |= 0x400; //ETOT
30  if( (link[0].d[5] & 0x02) || (link[2].d[5] & 0x02) ) *dsm_out |= 0x800; //HTOT
31 
32  dsmout = *dsm_out;
33 
34  if(fcs_trgDebug>=1) {
35  printf("FCS STG3 input 0 = %02x %02x %02x %02x %02x %02x %02x %02x\n",
36  link[0].d[0],link[0].d[1],link[0].d[2],link[0].d[3],
37  link[0].d[4],link[0].d[5],link[0].d[6],link[0].d[7]);
38  printf("FCS STG3 input 1 = %02x %02x %02x %02x %02x %02x %02x %02x\n",
39  link[2].d[0],link[2].d[1],link[2].d[2],link[2].d[3],
40  link[2].d[4],link[2].d[5],link[2].d[6],link[2].d[7]);
41  printf("FCS STG3 output = %04x EM=%1d%1d%1d ELE=%1d%1d%1d GAM=%1d%1d HAD=%1d JP=%1d TOT=%1d%1d\n",
42  *dsm_out,
43  (*dsm_out)>>0 & 0x1,(*dsm_out)>>1 & 0x1,(*dsm_out)>>2 & 0x1,
44  (*dsm_out)>>3 & 0x1,(*dsm_out)>>4 & 0x1,(*dsm_out)>>5 & 0x1,
45  (*dsm_out)>>6 & 0x1,(*dsm_out)>>7 & 0x1,
46  (*dsm_out)>>8 & 0x1,
47  (*dsm_out)>>9 & 0x1,
48  (*dsm_out)>>10 & 0x1,(*dsm_out)>>11 & 0x1);
49  }
50 }