StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
fms_fm102_2011_a.cc
1 //
2 // Pibero Djawotho <pibero@tamu.edu>
3 // Texas A&M University
4 // 14 Jan 2011
5 //
6 
7 #include "bits.hh"
8 #include "fms_fm102_2011_a.hh"
9 
10 void fms_fm102_2011_a(Board& fm102, int t){
11  int* channels = (int*)fm102.channels[t];
12 
13  // Board sum thresholds
14  const int R0 = fm102.registers[0];
15  const int R1 = fm102.registers[1];
16  const int R2 = fm102.registers[2];
17 
18  // High tower bits
19  int HT0 = 0;
20  int HT1 = 0;
21 
22  // Board sum bits
23  int BS0 = 0;
24  int BS1 = 0;
25  int BS2 = 0;
26 
27  // Quadrant sums
28  int Sum[4];
29 
30  for (int i = 0; i < 4; i += 2) {
31  int fm005out = channels[i];
32  int fm006out = channels[i+1];
33 
34  // OR the HT0 bits from the four Layer-0 DSM boards together, and
35  // likewise for the HT1 bits. Output the results to the Layer-2 DSM (2 bits)
36  HT0 |= btest(fm005out,30);
37  HT0 |= btest(fm006out,30);
38 
39  HT1 |= btest(fm005out,31);
40  HT1 |= btest(fm006out,31);
41 
42  // Compare the 18 5-bit Sum values to three thresholds (BSum0,
43  // BSum1, BSum2). OR the results together, and output them to the
44  // Layer-2 DSM (3 bits, not muxed)
45  int SumH = getbits(fm005out,0 ,5);
46  int SumGH = getbits(fm005out,5 ,5);
47  int SumG = getbits(fm005out,10,5);
48  int SumF = getbits(fm005out,15,5);
49  int SumEF = getbits(fm005out,20,5);
50  int SumE = getbits(fm005out,25,5);
51 
52  int SumJ = getbits(fm006out,15,5);
53  int SumIJ = getbits(fm006out,20,5);
54  int SumI = getbits(fm006out,25,5);
55 
56  BS0 |= SumE > R0 || SumEF > R0 || SumF > R0 || SumG > R0 || SumGH > R0 || SumH > R0;
57  BS1 |= SumE > R1 || SumEF > R1 || SumF > R1 || SumG > R1 || SumGH > R1 || SumH > R1;
58  BS2 |= SumE > R2 || SumEF > R2 || SumF > R2 || SumG > R2 || SumGH > R2 || SumH > R2;
59  BS0 |= SumI > R0 || SumIJ > R0 || SumJ > R0;
60  BS1 |= SumI > R1 || SumIJ > R1 || SumJ > R1;
61  BS2 |= SumI > R2 || SumIJ > R2 || SumJ > R2;
62 
63  // Compute the 8-bit total SumE+SumF+SumG+SumH+SumI+SumJ for each of
64  // the two quadrants
65  Sum[i] = SumE+SumF+SumG+SumH+SumI+SumJ;
66 
67  // Extract the low-order 6 bits from each of the 8-bit sums. If
68  // either of the two high-order bits is 1, set the result to 111111.
69  if (Sum[i] > 63) Sum[i] = 63;
70  }
71 
72  // Output the resulting 2 6-bit sums to the Layer-2 DSM (12 bits)
73  fm102.output[t] = Sum[0] | Sum[2] << 6 | BS0 << 24 | BS1 << 25 | BS2 << 26 | HT0 << 27 | HT1 << 28;
74 }
Definition: Board.hh:14