StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
fms_fm001_2012_a.cc
1 //
2 // Pibero Djawotho <pibero@tamu.edu>
3 // Texas A&M University
4 // 11 Feb 2012
5 //
6 
7 #include "qt32b_fms_2009_a.hh"
8 #include "fms_fm001_2012_a.hh"
9 #include <stdio.h>
10 
11 void fms_fm001_2012_a(Board& fm001, int t){
12  int A[4], B[4], C[4], D[4], htadc, htid;
13 
14  getQtSumAndHighTower((int*)fm001.channels[t],A,B,C,D,htadc,htid);
15 
16  // High tower thresholds
17  const int R0 = fm001.registers[0];
18  const int R1 = fm001.registers[1];
19 
20  // Compare the HT inputs from QT boards A, B, C, AND D to two HT
21  // thresholds. OR the results together, then output the HT0 and HT1
22  // results to the Layer-1 DSM (2 bits)
23  int HT0 = htadc > R0;
24  int HT1 = htadc > R1;
25 
26  // Form the following 6 7-bit sums:
27  int SumA = A[0]+A[1]+A[2]+A[3];
28  int SumAB = A[2]+A[3]+B[0]+B[1];
29  int SumB = B[0]+B[1]+B[2]+B[3];
30  int SumBC = B[2]+B[3]+C[0]+C[1];
31  int SumC = C[0]+C[1]+C[2]+C[3];
32  int SumCD = C[2]+C[3]+D[0]+D[1];
33  int SumD = D[0]+D[1]+D[2]+D[3];
34 
35  // Extract the low-order 5 bits from each of the 7-bit sums.
36  // If either of the two high-order bits is 1,
37  // set the result to 11111.
38  if (SumA > 31) SumA = 31;
39  if (SumAB > 31) SumAB = 31;
40  if (SumB > 31) SumB = 31;
41  if (SumBC > 31) SumBC = 31;
42  if (SumC > 31) SumC = 31;
43  if (SumCD > 31) SumCD = 31;
44  if (SumD > 31) SumD = 31;
45 
46  // Output the resulting 6 5-bit sums to the Layer-1 DSM (30 bits)
47  fm001.output[t] = SumD | SumC << 5 | SumBC << 10 | SumB << 15 | SumCD << 20 | SumA << 25 | HT0 << 30 | HT1 << 31;
48 
49  printf("%10s HTADC=%4d sum=%2d %2d %2d %2d %2d %2d %2d\n",fm001.name,htadc,SumA,SumAB,SumB,SumBC,SumC,SumCD,SumD);
50 }
Definition: Board.hh:14