StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
fms_fm005_2011_a.cc
1 //
2 // Pibero Djawotho <pibero@tamu.edu>
3 // Texas A&M University
4 // 14 Jan 2011
5 //
6 
7 //#include <cstdio>
8 #include "qt32b_fms_2009_a.hh"
9 #include "fms_fm005_2011_a.hh"
10 
11 void fms_fm005_2011_a(Board& fm005,int t){
12  int E[4], F[4], G[4], H[4], htadc, htid;
13 
14  getQtSumAndHighTower((int*)fm005.channels[t],E,F,G,H,htadc,htid);
15 
16  // High tower thresholds
17  const int R0 = fm005.registers[0];
18  const int R1 = fm005.registers[1];
19 
20  // Compare the HT inputs from QT boards E, F, G, and H 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 SumE = E[0]+E[1]+E[2]+E[3];
28  int SumEF = E[2]+E[3]+F[0]+F[1];
29  int SumF = F[0]+F[1]+F[2]+F[3];
30  int SumG = G[0]+G[1]+G[2]+G[3];
31  int SumGH = G[2]+G[3]+H[0]+H[1];
32  int SumH = H[0]+H[1]+H[2]+H[3];
33 
34  // Extract the low-order 5 bits from each of the 7-bit sums. If
35  // either of the two high-order bits is 1, set the result to 11111.
36  if (SumE > 31) SumE = 31;
37  if (SumEF > 31) SumEF = 31;
38  if (SumF > 31) SumF = 31;
39  if (SumG > 31) SumG = 31;
40  if (SumGH > 31) SumGH = 31;
41  if (SumH > 31) SumH = 31;
42 
43  // Output the resulting 6 5-bit sums to the Layer-1 DSM (30 bits)
44  fm005.output[t] = SumH | SumGH << 5 | SumG << 10 | SumF << 15 | SumEF << 20 | SumE << 25 | HT0 << 30 | HT1 << 31;
45 
46 #if 0
47  if (strcmp(fm005.name,"FM007") == 0) {
48  int* channels = (int*)fm005.channels;
49  printf("%08x %08x %08x %08x\n",channels[0],channels[1],channels[2],channels[3]);
50  }
51 #endif
52 }
Definition: Board.hh:14