StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
l1_fp201_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 "l1_fp201_2011_a.hh"
9 
10 void l1_fp201_2011_a(Board& fp201, int t){
11  int* channels = (int*)fp201.channels[t];
12 
13  int fm101out = channels[0]; // small cells
14  int fm102out = channels[1]; // large cells south
15  int fm103out = channels[2]; // large cells north
16  int fe101out = channels[7]; // FE101, FPE
17 
18  // Combine (OR) the two FPE bits
19  int fpe0 = btest(fe101out,0);
20  int fpe1 = btest(fe101out,1);
21  int fpe = fpe0|fpe1;
22 
23  // OR the HT0 bits from the three Layer-1 DSM boards together, and
24  // likewise for the HT1 bits. Note that this combines the small and
25  // large cell HT results together. Output the results to the TCU (2
26  // bits: HT0, HT1)
27  int HT0 = btest(fm101out,27) | btest(fm102out,27) | btest(fm103out,27);
28  int HT1 = btest(fm101out,28) | btest(fm102out,28) | btest(fm103out,28);
29 
30  // Pass the small cell BSum0, BSum1, BSum2 bits to the TCU (3 bits:
31  // SBsum0, SBsum1, SBsum2)
32  int SBS0 = btest(fm101out,24);
33  int SBS1 = btest(fm101out,25);
34  int SBS2 = btest(fm101out,26);
35 
36  // OR the large cell BSum0 bits from the two large-cell Layer-1 DSM
37  // boards together, and likewise for the BSum1 and BSum2 bits. Output
38  // the results to the TCU (3 bits: LBsum0, LBsum1, LBsum2)
39  int LBS0 = btest(fm102out,24) | btest(fm103out,24);
40  int LBS1 = btest(fm102out,25) | btest(fm103out,25);
41  int LBS2 = btest(fm102out,26) | btest(fm103out,26);
42 
43  // For each quadrant:
44  // -- Addd the 6-bit quadrant sum from the small cells
45  // (SumA+SumB+SumC+SumD) to the analogous 6-bit quadrant sum from the
46  // large cells (SumE+SumF+SumG+SumH+SumI+SumJ) to produce a 7-bit number
47  // -- Compare the 7-bit result to three thresholds JP0, JP1, JP2
48  const int R0 = fp201.registers[0];
49  const int R1 = fp201.registers[1];
50  const int R2 = fp201.registers[2];
51 
52  int SumST, SumSB, SumNT, SumNB;
53  computeJetPatchSums(fp201,SumST,SumSB,SumNT,SumNB);
54 
55  // OR the JP0 bits from the four quadrants together, and likewise
56  // for the JP1 and JP2 bits. Output the results to the TCU (3 bits:
57  // JP0, JP1, JP2)
58  int JP0 = SumST > R0 || SumSB > R0 || SumNT > R0 || SumNB > R0;
59  int JP1 = SumST > R1 || SumSB > R1 || SumNT > R1 || SumNB > R1;
60  int JP2 = SumST > R2 || SumSB > R2 || SumNT > R2 || SumNB > R2;
61 
62  // If two or more quadrants satisfy the JP0 threshold, set the
63  // "di-jet" bit. Output it to the TCU (1 bit: Di-jet)
64  int dijet = (((SumST > R0) && ((SumSB > R0) || (SumNT > R0) || (SumNB > R0))) ||
65  ((SumSB > R0) && ((SumNT > R0) || (SumNB > R0))) ||
66  ((SumNT > R0) && (SumNB > R0)));
67 
68  fp201.output[t] = HT0 | HT1 << 1 | SBS0 << 2 | SBS1 << 3 | SBS2 << 4 | LBS0 << 5 | LBS1 << 6 | LBS2 << 7 | JP0 << 8 | JP1 << 9 | JP2 << 10 | dijet << 11 | fpe << 14;
69 }
70 
71 void computeJetPatchSums(const Board& fp201, int& SumST, int& SumSB, int& SumNT, int& SumNB, int t){
72  int* channels = (int*)fp201.channels[t];
73 
74  int fm101out = channels[0]; // small cells
75  int fm102out = channels[1]; // large cells south
76  int fm103out = channels[2]; // large cells north
77 
78  // small cells
79  int SumSmST = getbits(fm101out,0 ,6); // south-top
80  int SumSmSB = getbits(fm101out,6 ,6); // south-bottom
81  int SumSmNT = getbits(fm101out,12,6); // north-top
82  int SumSmNB = getbits(fm101out,18,6); // north bottom
83 
84  // large cells
85  int SumLgST = getbits(fm102out,0,6); // south-top
86  int SumLgSB = getbits(fm102out,6,6); // south-bottom
87  int SumLgNT = getbits(fm103out,0,6); // north-top
88  int SumLgNB = getbits(fm103out,6,6); // north-bottom
89 
90  // jet patch sums
91  SumST = SumSmST + SumLgST; // south-top
92  SumSB = SumSmSB + SumLgSB; // south-bottom
93  SumNT = SumSmNT + SumLgNT; // north-top
94  SumNB = SumSmNB + SumLgNB; // north-bottom
95 }
Definition: Board.hh:14