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