StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
fms_fm101_2015_b.cc
1 #include "bits.hh"
2 #include "fms_fm101_2015_b.hh"
3 #include "fms_fm001_2015_a.hh"
4 #include <stdio.h>
5 
6 //#include "registerHack.hh"
7 
8 void fms_fm101_2015_b(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  fm101.userdata[t][0]=DD;
30 
31  //Compare to threshold and OR
32  int BS3 = getFM001_BS3(T) | getFM001_BS3(B) | (DD>BSThr3);
33  int BS2 = getFM001_BS2(T) | getFM001_BS2(B) | (DD>BSThr2);
34  int BS1DD=(DD>BSThr1);
35  fm101.userdata[t][7]=(DD>BSThr3);
36  fm101.userdata[t][8]=(DD>BSThr2);
37  fm101.userdata[t][9]=BS1DD;
38 
39  //BS1 bits
40  int BS1T=getFM001_BS1A(T);
41  int BS1M=getFM001_BS1BCD(T) | getFM001_BS1BCD(B) | BS1DD;
42  int BS1B=getFM001_BS1A(B);
43 
44  //Jp sums
45  int JpT=getFM001_JpAB(T)+getFM001_JpCD(T);
46  int JpM=getFM001_JpCD(T)+getFM001_JpCD(B);
47  int JpB=getFM001_JpAB(B)+getFM001_JpCD(B);
48  if(JpT>0xff) JpT=0xff;
49  if(JpM>0xff) JpM=0xff;
50  if(JpB>0xff) JpB=0xff;
51 
52  fm101.output[t] = BS3 <<13 | BS2 << 1
53  | BS1T << 2 | BS1M << 3 | BS1B <<4
54  | JpT << 5 | JpM << 16 | JpB <<24;
55 
56  if(PRINT){
57  printf("%s input T=%08x B=%08x\n",fm101.name,T,B);
58  printf("%s out=%08x BS3=%1d BS2=%1d BS1T/M/B=%1d %1d %1d JpT/M/B %3d %3d %3d\n",
59  fm101.name,fm101.output[t],
60  BS3,BS2,BS1T,BS1M,BS1B,JpT,JpM,JpB);
61  }
62 }
63 
64 int getFM101_2015b_BS3(int out) {return getbits(out,13, 1);}
65 int getFM101_2015b_BS2(int out) {return getbits(out, 1, 1);}
66 int getFM101_2015b_BS1T(int out) {return getbits(out, 2, 1);}
67 int getFM101_2015b_BS1M(int out) {return getbits(out, 3, 1);}
68 int getFM101_2015b_BS1B(int out) {return getbits(out, 4, 1);}
69 int getFM101_2015b_JpT(int out) {return getbits(out, 5, 8);}
70 int getFM101_2015b_JpM(int out) {return getbits(out,16, 8);}
71 int getFM101_2015b_JpB(int out) {return getbits(out,24, 8);}
Definition: Board.hh:14