StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
fms_fm101_2015_a.cc
1 #include "bits.hh"
2 #include "fms_fm101_2015_a.hh"
3 #include "fms_fm001_2015_a.hh"
4 #include <stdio.h>
5 
6 //#include "registerHack.hh"
7 
8 void fms_fm101_2015_a(Board& fm101, int t, int simdat){
9  const int BSThr1=fm101.registers[0];
10  const int BSThr2=fm101.registers[1];
11  const int BSThr3=fm101.registers[2];
12  //Hack until we know details of registers
13  //int BSThr1=Sm_BSThr1;
14  //int BSThr2=Sm_BSThr2;
15  //int BSThr3=Sm_BSThr3;
16  //printf("%s BSthr1=%d BSthr2=%d BSthr3=%d\n",fm101.name,BSThr1,BSThr2,BSThr3);
17 
18  //input
19  int* in;
20  if(simdat==0) {in=(int*)fm101.channels[t];}
21  else {in=(int*)fm101.dsmdata[t];}
22  // int T=in[1];
23  // int B=in[0];
24  int T=in[0];
25  int B=in[1];
26 
27  //Make 1 more BS sum
28  int DD=getFM001_D23(T) + getFM001_D23(B);
29 
30  //Compare to threshold and OR
31  int BS3 = getFM001_BS3(T) | getFM001_BS3(B) | (DD>BSThr3);
32  int BS2 = getFM001_BS2(T) | getFM001_BS2(B) | (DD>BSThr2);
33  int BS1DD=(DD>BSThr1);
34 
35  //BS1 bits
36  int BS1T=getFM001_BS1A(T);
37  int BS1M=getFM001_BS1BCD(T) | getFM001_BS1BCD(B) | BS1DD;
38  int BS1B=getFM001_BS1A(B);
39 
40  //Jp sums
41  int JpT=getFM001_JpAB(T)+getFM001_JpCD(T);
42  int JpM=getFM001_JpCD(T)+getFM001_JpCD(B);
43  int JpB=getFM001_JpAB(B)+getFM001_JpCD(B);
44  if(JpT>0xff) JpT=0xff;
45  if(JpM>0xff) JpM=0xff;
46  if(JpB>0xff) JpB=0xff;
47 
48  fm101.output[t] = BS3 | BS2 << 1
49  | BS1T << 2 | BS1M << 3 | BS1B <<4
50  | JpT << 5 | JpM << 16 | JpB <<24;
51 
52  if(PRINT){
53  printf("%s input T=%08x B=%08x\n",fm101.name,T,B);
54  printf("%s out=%08x BS3=%1d BS2=%1d BS1T/M/B=%1d %1d %1d JpT/M/B %3d %3d %3d\n",
55  fm101.name,fm101.output[t],
56  BS3,BS2,BS1T,BS1M,BS1B,JpT,JpM,JpB);
57  }
58 }
59 
60 int getFM101_2015a_BS3(int out) {return getbits(out, 0, 1);}
61 int getFM101_2015a_BS2(int out) {return getbits(out, 1, 1);}
62 int getFM101_2015a_BS1T(int out) {return getbits(out, 2, 1);}
63 int getFM101_2015a_BS1M(int out) {return getbits(out, 3, 1);}
64 int getFM101_2015a_BS1B(int out) {return getbits(out, 4, 1);}
65 int getFM101_2015a_JpT(int out) {return getbits(out, 5, 8);}
66 int getFM101_2015a_JpM(int out) {return getbits(out,16, 8);}
67 int getFM101_2015a_JpB(int out) {return getbits(out,24, 8);}
Definition: Board.hh:14