StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
fms_fm006_2015_a.cc
1 #include "bits.hh"
2 #include "qt32b_fms_2015_a.hh"
3 #include "fms_fm006_2015_a.hh"
4 #include <stdio.h>
5 
6 #include "registerHack.hh"
7 
8 void fms_fm006_2015_a(Board& fm006, int t, int simdat){
9  // thresholds
10  int BSThr1 = fm006.registers[0];
11  int BSThr2 = fm006.registers[1];
12  int BSThr3 = fm006.registers[2];
13  int BitSelect= fm006.registers[3];
14  //Hack until we know details of registers
15  //int BSThr1=Lg_BSThr1;
16  //int BSThr2=Lg_BSThr2;
17  //int BSThr3=Lg_BSThr3;
18  //int BitSelect=Lg_BitSelect;
19 
20  //input
21  int* in;
22  if(simdat==0) {in=(int*)fm006.channels[t];}
23  else {in=(int*)fm006.dsmdata[t];}
24  int E=in[1];
25  int F=in[0];
26 
27  //2x8 sums from QT
28  int E01 = getQT01Sum(E);
29  int E23 = getQT23Sum(E);
30  int F01 = getQT01Sum(F);
31  int F23 = getQT23Sum(F);
32 
33  // Form 2x4 board sums
34  const int MAX=3;
35  int bs[MAX];
36  bs[0] = E01 + E23; //E
37  bs[1] = E23 + F01; //EF
38  bs[2] = F01 + F23; //F
39  fm006.userdata[t][0]=bs[0];
40  fm006.userdata[t][1]=bs[1];
41  fm006.userdata[t][2]=bs[2];
42 
43  //Compare BS to thresholds
44  int BS3=0, BS2=0;
45  fm006.userdata[t][7]=0;
46  fm006.userdata[t][8]=0;
47  fm006.userdata[t][9]=0;
48  for(int i=0; i<MAX; i++){
49  if(bs[i]>BSThr3) {BS3=1; fm006.userdata[t][7]+=(1<<i); }
50  if(bs[i]>BSThr2) {BS2=1; fm006.userdata[t][8]+=(1<<i); }
51  if(bs[i]>BSThr1) { fm006.userdata[t][9]+=(1<<i); }
52  }
53  int BS1E =(bs[0]>BSThr1) | (bs[1]>BSThr1);
54  int BS1F =(bs[2]>BSThr1);
55 
56  //Jp Sum
57  int JpEF = (bs[0] + bs[2])>>BitSelect; //E+F
58  if(JpEF>0xFF) JpEF =0xFF;
59 
60  // Output the resulting 6 5-bit sums to the Layer-1 DSM (30 bits)
61  fm006.output[t]
62  = BS3 | BS2 << 1
63  | BS1E << 2 | BS1F << 3
64  | JpEF << 16;
65 
66 
67  if(PRINT){
68  printf("%s input E=%08x F=%08x\n",fm006.name,E,F);
69  printf("%s out=%08x BS3=%1d BS2=%1d BS1E/F=%1d %1d sum=%4d %4d %4d JpEF=%3d\n",
70  fm006.name,fm006.output[t],BS3,BS2,BS1E,bs[0],bs[1],bs[2],BS1F,JpEF);
71  }
72 }
73 
74 int getFM006_BS3(int out) {return getbits(out, 0, 1);}
75 int getFM006_BS2(int out) {return getbits(out, 1, 1);}
76 int getFM006_BS1E(int out) {return getbits(out, 2, 1);}
77 int getFM006_BS1F(int out) {return getbits(out, 3, 1);}
78 int getFM006_JpEF(int out) {return getbits(out,16, 8);}
Definition: Board.hh:14