StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
fms_fm103_2015_a.cc
1 #include "bits.hh"
2 #include "fms_fm103_2015_a.hh"
3 #include "fms_fm005_2015_a.hh"
4 #include "fms_fm006_2015_a.hh"
5 #include <stdio.h>
6 
7 //#include "registerHack.hh"
8 
9 void fms_fm103_2015_a(Board& fm103, int t, int simdat){
10  const int BSThr1=fm103.registers[0];
11  const int BSThr2=fm103.registers[1];
12  const int BSThr3=fm103.registers[2];
13  //Hack until we know details of registers
14  //int BSThr1=Lg_BSThr1;
15  //int BSThr2=Lg_BSThr2;
16  //int BSThr3=Lg_BSThr3;
17  //printf("%s BSthr1=%d BSthr2=%d BSthr3=%d\n",fm103.name,BSThr1,BSThr2,BSThr3);
18 
19  //input
20  int* in;
21  if(simdat==0) {in=(int*)fm103.channels[t];}
22  else {in=(int*)fm103.dsmdata[t];}
23  int T1=in[0]; //fm005,fm009
24  int T2=in[1]; //fm006,fm010
25  int B1=in[2]; //fm007,fm011
26  int B2=in[3]; //fm008,fm012
27 
28  //From another 2*4 sum
29  int JJ=getFM005_J23(T1) + getFM005_J23(B1);
30  fm103.userdata[t][0]=JJ;
31 
32  //BS bits
33  int BS3 = getFM005_BS3(T1) | getFM006_BS3(T2) | getFM005_BS3(B1) | getFM006_BS3(B2) | (JJ>BSThr3);
34  int BS2 = getFM005_BS2(T1) | getFM006_BS2(T2) | getFM005_BS2(B1) | getFM006_BS2(B2) | (JJ>BSThr2);
35  int BS1JJ=(JJ>BSThr1);
36  int BS1T=getFM006_BS1E(T2);
37  int BS1M=getFM006_BS1F(T2) | getFM005_BS1GHIJ(T1) | BS1JJ | getFM005_BS1GHIJ(B1) | getFM006_BS1F(B2);
38  int BS1B=getFM006_BS1E(B2);
39  fm103.userdata[t][7]=(JJ>BSThr3);
40  fm103.userdata[t][8]=(JJ>BSThr2);
41  fm103.userdata[t][9]=BS1JJ;
42  //printf("BBB %s %d %d %d\n",fm103.name,fm103.userdata[t][7],fm103.userdata[t][8],fm103.userdata[t][9]);
43 
44  //Jp
45  int JpT=getFM006_JpEF(T2)+getFM005_JpGH(T1)+getFM005_JpIJ(T1);
46  int JpM=getFM005_JpIJ(T1)+getFM005_JpIJ(B1);
47  int JpB=getFM006_JpEF(B2)+getFM005_JpGH(B1)+getFM005_JpIJ(B1);
48  if(JpT >0xFF) JpT =0xFF;
49  if(JpM >0xFF) JpM =0xFF;
50  if(JpB >0xFF) JpB =0xFF;
51 
52  fm103.output[t] = BS3 | BS2 << 1
53  | BS1T << 2 | BS1M << 3 | BS1B <<4
54  | JpT << 5 | JpM << 16 | JpB <<24;
55 
56  if(PRINT){
57  printf("%s input T1=%08x T2=%08x B1=%08x B2=%08x\n",fm103.name,T1,T2,B1,B2);
58  printf("%s out=%08x BS3=%1d BS2=%1d BS1T/M/B=%1d %1d %1d JpT/M/B %3d %3d %3d\n",
59  fm103.name,fm103.output[t],
60  BS3,BS2,BS1T,BS1M,BS1B,JpT,JpM,JpB);
61  }
62 }
63 
64 int getFM103_2015a_BS3(int out) {return getbits(out, 0, 1);}
65 int getFM103_2015a_BS2(int out) {return getbits(out, 1, 1);}
66 int getFM103_2015a_BS1T(int out) {return getbits(out, 2, 1);}
67 int getFM103_2015a_BS1M(int out) {return getbits(out, 3, 1);}
68 int getFM103_2015a_BS1B(int out) {return getbits(out, 4, 1);}
69 int getFM103_2015a_JpT(int out) {return getbits(out, 5, 8);}
70 int getFM103_2015a_JpM(int out) {return getbits(out,16, 8);}
71 int getFM103_2015a_JpB(int out) {return getbits(out,24, 8);}
Definition: Board.hh:14