StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
DSMAlgo_EE102_2013.cc
1 #include "DSM.hh"
2 #include "DSMAlgo_EE102_2013.hh"
3 
4 void DSMAlgo_EE102_2013::operator()(DSM& dsm)
5 {
6  // INPUT:
7 
8  // EE102 - ch0 - EE005 - (16-31) jp1 clockwise
9  // ch1 - EE006
10  // ch2 - EE007
11  // ch3 - EE008 - (0-15) jp0 anti-clockwise
12  // ch4 - EE008 - (16-31) jp1 clockwise
13  // ch5 - EE009
14 
15  // From E006/007/009:
16 
17  // (0-5) TP sum for low-eta group (6)
18  // (6-11) TP sum for high-eta group (6)
19  // (12-13) HT bits (2)
20  // (14-15) Unused (2)
21 
22  // From E005/008:
23 
24  // (0-5) TP sum (6)
25  // (6-11) Unused (2)
26  // (12-13) HT bits (2)
27  // (14-15) Unused (2)
28 
29  // REGISTERS:
30 
31  // R0: EEMC-Jet-Patch-Th0 (8)
32  // R1: EEMC-Jet-Patch-Th1 (8)
33  // R2: EEMC-Jet-Patch-Th2 (8)
34  // R3: EEMC-JP-th-dijet (8)
35 
36  // ACTION:
37 
38  // Make jet patch sums
39 
40  int lowEtaSumA = dsm.channels[1] & 0x3f; // 10 o'clock
41  int lowEtaSumB = dsm.channels[2] & 0x3f; // 12 o'clock
42  int lowEtaSumC = dsm.channels[5] & 0x3f; // 2 o'clock
43 
44  int highEtaSumA = (dsm.channels[1] >> 6 & 0x3f) + (dsm.channels[0] & 0x3f); // 10 o'clock
45  int highEtaSumB = (dsm.channels[2] >> 6 & 0x3f) + (dsm.channels[3] & 0x3f); // 12 o'clock
46  int highEtaSumC = (dsm.channels[5] >> 6 & 0x3f) + (dsm.channels[4] & 0x3f); // 2 o'clock
47 
48  int jpa = lowEtaSumA + highEtaSumA; // JP0 - 10 o'clock
49  int jpb = lowEtaSumB + highEtaSumB; // JP1 - 12 o'clock
50  int jpc = lowEtaSumC + highEtaSumC; // JP2 - 2 o'clock
51 
52  // Place jet patch thresholds on sums
53 
54  int jpaBits = 0;
55  int jpbBits = 0;
56  int jpcBits = 0;
57 
58  int jpCmbBits = 0;
59 
60  //jpa, jpb, jpb and combined jpCmb output for jp thresholds 0:2
61 
62  for(int chn = 0; chn < 3; ++chn)
63  {
64  if(jpa > dsm.registers[chn]) jpaBits++;
65  if(jpb > dsm.registers[chn]) jpbBits++;
66  if(jpc > dsm.registers[chn]) jpcBits++;
67 
68  if(jpa > dsm.registers[chn] || jpb > dsm.registers[chn] || jpc > dsm.registers[chn]) jpCmbBits++;
69  //printf("r%d = %d ", chn, dsm.registers[chn]);
70  }
71  //printf("\n");
72  //jpa, jpb, jpc di-jet output
73  int r3 = dsm.registers[3];
74 
75  int jpaDijetBits = jpa > r3;
76  int jpbDijetBits = jpb > r3;
77  int jpcDijetBits = jpc > r3;
78 
79  //printf("jpa = %d jpb = %d jpc = %d r3 = %d\n", jpa, jpb, jpc, r3);
80 
81  // OR HT bits
82 
83  int highTowerBits = 0;
84 
85  for (int ch = 0; ch < 6; ++ch)
86  highTowerBits |= dsm.channels[ch] >> 12 & 0x3;
87 
88  // Find largest sum for 1.09 < eta < 1.4 (low eta)
89  //printf("lowEtaSumA = %d lowEtaSumB=%d lowEtaSumC=%d\n", lowEtaSumA, lowEtaSumB, lowEtaSumC);
90  int maxA = (lowEtaSumA > lowEtaSumB) && !(lowEtaSumC > lowEtaSumA);
91  int maxB = (lowEtaSumB > lowEtaSumC) && !(lowEtaSumA > lowEtaSumB);
92  int maxC = (lowEtaSumC > lowEtaSumA) && !(lowEtaSumB > lowEtaSumC);
93 
94  int maxId = 0;
95  int maxSum = 0;
96 
97  if (maxA) {
98  maxId = 1;
99  maxSum = lowEtaSumA;
100  }
101  else if (maxB) {
102  maxId = 2;
103  maxSum = lowEtaSumB;
104  }
105  else if (maxC) {
106  maxId = 3;
107  maxSum = lowEtaSumC;
108  }
109  else {
110  maxId = 1;
111  maxSum = lowEtaSumA;
112  }
113  //printf("maxId=%d maxSum=%d\n", maxId, maxSum);
114  // If overflow, set to max
115 
116  if (maxSum > 63) maxSum = 63;
117 
118  // OUTPUT (16):
119 
120  int out = 0;
121  // 0:1 JP threshold (JPA, B and C combined)
122  // 2 JPA th-dijet bit
123  // 3 JPB th-dijet bit
124  // 4 JPC th-dijet bit
125  // 5 Unused
126  // 6:11 Selected partial jet patch sum
127  // 12:13 Partial jet patch ID
128  // 14:15 HT bits
129 
130  out |= jpCmbBits;
131  out |= jpaDijetBits << 2;
132  out |= jpbDijetBits << 3;
133  out |= jpcDijetBits << 4;
134  out |= maxSum << 6;
135  out |= maxId << 12;
136  out |= highTowerBits << 14;
137 
138  dsm.output = out;
139  // INFO:
140 
141  // I0: JP3 (10 o'clock) ADC sum
142  // I1: JP4 (12 o'clock) ADC sum
143  // I2: JP5 (2 o'clock) ADC sum
144 
145  dsm.info[0] = jpa;
146  dsm.info[1] = jpb;
147  dsm.info[2] = jpc;
148  //
149  //low eta sum
150  dsm.info[3] = lowEtaSumA; // 10 o'clock
151  dsm.info[4] = lowEtaSumB; // 12 o'clock
152  dsm.info[5] = lowEtaSumC; // 2 o'clock
153 }
Definition: DSM.hh:16