StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
stage_3_202207.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_202207(link_t link[], u_short *dsm_out)
12 {
13  *dsm_out = 0;
14 
15  if( (link[1].d[0] & 0x01) || (link[3].d[0] & 0x01) ) *dsm_out |= 0x1; //HAD0
16  if( (link[1].d[0] & 0x02) || (link[3].d[0] & 0x02) ) *dsm_out |= 0x2; //HAD1
17  if( (link[1].d[0] & 0x04) || (link[3].d[0] & 0x04) ) *dsm_out |= 0x4; //HAD2
18 
19  if( (link[0].d[0] & 0x01) || (link[2].d[0] & 0x01) ) *dsm_out |= 0x8; //EM0
20  if( (link[0].d[0] & 0x02) || (link[2].d[0] & 0x02) ) *dsm_out |= 0x10; //EM1
21  if( (link[0].d[0] & 0x04) || (link[2].d[0] & 0x04) ) *dsm_out |= 0x20; //EM2
22 
23  if( (link[0].d[1] & 0x1F) || (link[2].d[1] & 0x1F) ) *dsm_out |= 0x40; //JP2
24 
25  if( (link[1].d[1] & 0x01) || (link[3].d[1] & 0x01) ) *dsm_out |= 0x80; //JPA1
26  if( (link[1].d[1] & 0x06) || (link[3].d[1] & 0x06) ) *dsm_out |= 0x100; //JPBC1
27  if( (link[1].d[1] & 0x18) || (link[3].d[1] & 0x18) ) *dsm_out |= 0x200; //JPDE1
28 
29  if( (link[0].d[2] & 0x01) || (link[2].d[2] & 0x01) ) *dsm_out |= 0x400; //JPA0
30  if( (link[0].d[2] & 0x06) || (link[2].d[2] & 0x06) ) *dsm_out |= 0x800; //JPBC0
31  if( (link[0].d[2] & 0x18) || (link[2].d[2] & 0x18) ) *dsm_out |= 0x1000; //JPDE0
32 
33  if( (link[1].d[2] & 0x02) && (link[3].d[2] & 0x1C) ) *dsm_out |= 0x2000; //DiJP
34  if( (link[1].d[2] & 0x04) && (link[3].d[2] & 0x1A) ) *dsm_out |= 0x2000; //DiJP
35  if( (link[1].d[2] & 0x18) && (link[3].d[2] & 0x1E) ) *dsm_out |= 0x2000; //DiJP
36 
37  if( (link[1].d[2] & 0x02) && (link[2].d[2] & 0x1C) ) *dsm_out |= 0x4000; //DiJPAsy
38  if( (link[1].d[2] & 0x04) && (link[2].d[2] & 0x1A) ) *dsm_out |= 0x4000; //DiJPAsy
39  if( (link[1].d[2] & 0x18) && (link[2].d[2] & 0x1E) ) *dsm_out |= 0x4000; //DiJPAsy
40  if( (link[0].d[2] & 0x02) && (link[3].d[2] & 0x1C) ) *dsm_out |= 0x4000; //DiJPAsy
41  if( (link[0].d[2] & 0x04) && (link[3].d[2] & 0x1A) ) *dsm_out |= 0x4000; //DiJPAsy
42  if( (link[0].d[2] & 0x18) && (link[3].d[2] & 0x1E) ) *dsm_out |= 0x4000; //DiJPAsy
43 
44  if( (link[0].d[0] & 0x40) && (link[2].d[0] & 0x20) ) *dsm_out |= 0x8000; //DiELEA
45  if( (link[0].d[0] & 0x20) && (link[2].d[0] & 0x40) ) *dsm_out |= 0x8000; //DiELEA
46 
47  dsmout = *dsm_out;
48 
49  if(fcs_trgDebug>=1) {
50  printf("FCS STG3 input 0 = %02x %02x %02x %02x %02x %02x %02x %02x\n",
51  link[0].d[0],link[0].d[1],link[0].d[2],link[0].d[3],
52  link[0].d[4],link[0].d[5],link[0].d[6],link[0].d[7]);
53  printf("FCS STG3 input 1 = %02x %02x %02x %02x %02x %02x %02x %02x\n",
54  link[2].d[0],link[2].d[1],link[2].d[2],link[2].d[3],
55  link[2].d[4],link[2].d[5],link[2].d[6],link[2].d[7]);
56  printf("FCS STG3 output = %04x = ", *dsm_out);
57  for(int i=7; i>=0; i--){printf("%1d", (dsmout>>i)&0x1);}
58  printf("\n");
59  }
60 }