StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
DSMAlgo_EM201_2015.cc
1 #include "DSM.hh"
2 #include "DSMAlgo_EM201_2015.hh"
3 
4 void DSMAlgo_EM201_2015::operator()(DSM& dsm)
5 {
6  // INPUT:
7 
8  // DSM - ch0 - BEMC BC101 - 10' - JP0 & JP6 (West & East)
9  // ch1 - BEMC BC102 - 12' - JP1 & JP7
10  // ch2 - BEMC BC103 - 2' - JP2 & JP8
11  // ch3 - BEMC BC104 - 4' - JP3 & JP9
12  // ch4 - BEMC BC105 - 6' - JP4 & JP10
13  // ch5 - BEMC BC106 - 8' - JP5 & JP11
14  // ch6 - EEMC EE101 - 4', 6' and 8' - JP3, JP4 & JP5
15  // ch7 - EEMC EE102 - 10', 12' and 2' - JP0, JP1 & JP2
16 
17  // From BC101-106 (16):
18 
19  // (0-1) JPX (east, -1 < eta < 0) threshold bits (2)
20  // (2-3) JPY (middle, -0.6 < eta < 0.4) threshold bits (2)
21  // (4-5) JPZ (west, 0 < eta < 1) threshold bits (2)
22  // (6-11) JPpartial (0.4 < eta < 1) sum (6)
23  // (12-14) HT bits (3)
24  // (15) HT.TP bit (1)
25 
26  // From EE101 (16):
27 
28  // (0-1) JPA (4 o'clock) threshold bits (2)
29  // (2-3) JPB (6 o'clock) threshold bits (2)
30  // (4-5) JPC (8 o'clock) threshold bits (2)
31  // (6-11) Selected partial jet patch sum (6)
32  // (12-13) Partial jet patch ID (1=A, 2=B, 3=C) (2)
33  // (14-15) HT bits (2)
34 
35  // From EE102 (16):
36 
37  // (0-1) JPA (10 o'clock) threshold bits (2)
38  // (2-3) JPB (12 o'clock) threshold bits (2)
39  // (4-5) JPC (2 o'clock) threshold bits (2)
40  // (6-11) Selected partial jet patch sum (6)
41  // (12-13) Partial jet patch ID (1=A, 2=B, 3=C) (2)
42  // (14-15) HT bits (2)
43 
44  // REGISTERS:
45 
46  // R0: Hybrid jet patch threshold-0
47  // R1: Hybrid jet patch threshold-1
48  // R2: Hybrid jet patch threshold-2
49  // R3: AJP-th-Sel (2)
50  // R4: BEMC-HTTP-Sel (2)
51  // ACTION:
52 
53  // Complete hybrid jet patches using partial jet patch ID from EEMC
54 
55  int jpSum1; // Partial sum from EE101
56  int jpSum2; // Partial sum from EE102
57 
58  getHybridJetPatchSums(dsm,jpSum1,jpSum2);
59 
60  // Combine (OR) the HT bits from the six BEMC layer 1 DSM's
61 
62  int htBitsBarrel = 0;
63 
64  for (int ch = 0; ch < 6; ++ch)
65  htBitsBarrel |= dsm.channels[ch] >> 12 & 0x7;
66 
67  // Combine (OR) the HT bits from the two EEMC layer 1 DSM's
68 
69  int htBitsEndcap = 0;
70 
71  for (int ch = 6; ch < 8; ++ch)
72  htBitsEndcap |= dsm.channels[ch] >> 14 & 0x3;
73 
74  // Combine (OR) the JP bits for the BEMC and EEMC separately
75 
76  int jpBitsBarrel = 0;
77 
78  for (int ch = 0; ch < 6; ++ch) {
79  int jpx = dsm.channels[ch] & 0x3;
80  int jpy = dsm.channels[ch] >> 2 & 0x3;
81  int jpz = dsm.channels[ch] >> 4 & 0x3;
82 
83  if (jpx > jpBitsBarrel) jpBitsBarrel = jpx;
84  if (jpy > jpBitsBarrel) jpBitsBarrel = jpy;
85  if (jpz > jpBitsBarrel) jpBitsBarrel = jpz;
86  }
87 
88  int bjp1 = jpBitsBarrel > 1;
89  int bjp2 = jpBitsBarrel > 2;
90 
91  int jpBitsEndcap = 0;
92 
93  for (int ch = 6; ch < 8; ++ch) {
94  int jpa = dsm.channels[ch] & 0x3;
95  int jpb = dsm.channels[ch] >> 2 & 0x3;
96  int jpc = dsm.channels[ch] >> 4 & 0x3;
97 
98  if (jpa > jpBitsEndcap) jpBitsEndcap = jpa;
99  if (jpb > jpBitsEndcap) jpBitsEndcap = jpb;
100  if (jpc > jpBitsEndcap) jpBitsEndcap = jpc;
101  }
102 
103  int ejp1 = jpBitsEndcap > 1;
104  int ejp2 = jpBitsEndcap > 2;
105 
106  // Compare the two completed hybrid jet patches to three thresholds
107  // and combine (OR) the results with the BEMC-only and EEMC-only bits
108 
109  int jpBits = 0;
110 
111  for (int reg = 0; reg < 3; ++reg)
112  if (jpSum1 > dsm.registers[reg] || jpSum2 > dsm.registers[reg]) ++jpBits;
113 
114  if (jpBitsBarrel > jpBits) jpBits = jpBitsBarrel;
115  if (jpBitsEndcap > jpBits) jpBits = jpBitsEndcap;
116 
117  int jp0 = jpBits > 0;
118  int jp1 = jpBits > 1;
119  int jp2 = jpBits > 2;
120 
121  // Adjacent jet patch logic
122 
123  int ajpx = ajpBarrel(dsm, 0);
124  int ajpy = ajpBarrel(dsm, 2);
125  int ajpz = ajpBarrel(dsm, 4);
126  int bajp = ajpx || ajpy || ajpz;
127  int eajp = ajpEndcap(dsm);
128  int ajp = bajp || eajp;
129 
130  // Make the DAQ10k bit
131  /*
132  int htSel = dsm.registers[4]+12;
133 
134  int oclock10 = dsm.channels[0] >> htSel & 1;
135  int oclock12 = dsm.channels[1] >> htSel & 1;
136  int oclock2 = dsm.channels[2] >> htSel & 1;
137  int oclock4 = dsm.channels[3] >> htSel & 1;
138  int oclock6 = dsm.channels[4] >> htSel & 1;
139  int oclock8 = dsm.channels[5] >> htSel & 1;
140 
141  int daq10kBackToBack = ((oclock2 && oclock8 ) ||
142  (oclock4 && oclock10) ||
143  (oclock6 && oclock12));
144 
145  unsigned int sectorCount = oclock10+oclock12+oclock2+oclock4+oclock6+oclock8;
146 
147  int reg5[2];
148 
149  reg5[0] = dsm.registers[5] >> 0 & 1;
150  reg5[1] = dsm.registers[5] >> 1 & 1;
151 
152  int daq10kBit = ((reg5[0] && sectorCount > dsm.registers[6]) ||
153  (reg5[1] && sectorCount == 2 && daq10kBackToBack));
154  */
155  int http_b2b = 0;
156  int http_nonadj = 0;
157  getHTTP(dsm, http_b2b, http_nonadj);
158 // printf("b2b=%d, nonadj=%d\n", http_b2b, http_nonadj);
159  int http = 0;
160  if(dsm.registers[4])
161  http = http_nonadj;
162  else
163  http = http_b2b;
164  // OUTPUT (16):
165 
166  // (0:3) Barrel HT bits (4)
167  // (4:5) Endcap HT bits (2)
168  // (6) JP1, unified over the BEMC+EEMC (1)
169  // (7) JP2, unified over the BEMC+EEMC (1)
170  // (8) BJP1 for the 18 BEMC-only patches (1)
171  // (9) BJP2 for the 18 BEMC-only patches (1)
172  // (10) EJP1 for the 6 EEMC-only patches (1)
173  // (11) EJP2 for the 6 EEMC-only patches (1)
174  // (12) AJP for BEMC and EEMC but NOT the boundary (1)
175  // (13) BAJP for the BEMC-only patches (1)
176  // (14) DAQ10k, DAQ10k trigger bit (1)
177  // (15) JP0, unified over the BEMC+EEMC (1)
178 
179  int eb2b = getEB2B(dsm);
180  eb2b = 0; //set to zero not triggering on this bit 05/29/15
181 // printf("eb2b=%d\n", eb2b);
182  int out = 0;
183 
184  out |= htBitsBarrel;
185  out |= http << 3;
186  out |= htBitsEndcap << 4;
187  out |= jp1 << 6;
188  out |= jp2 << 7;
189  out |= bjp1 << 8;
190  out |= bjp2 << 9;
191  out |= ejp1 << 10;
192  out |= ejp2 << 11;
193  out |= ajp << 12;
194  out |= bajp << 13;
195  out |= eb2b << 14;
196  out |= jp0 << 15;
197 
198  dsm.output = out;
199 
200  // INFO
201 
202  dsm.info[0] = jpSum1;
203  dsm.info[1] = jpSum2;
204 }
205 int DSMAlgo_EM201_2015::ajpBarrel(const DSM& dsm, int offset)
206 {
207  int jpBits[6];
208 
209  // BC101-106
210 
211  for (int ch = 0; ch < 6; ++ch)
212  jpBits[ch] = dsm.channels[ch] >> offset & 0x3;
213 
214  const int R3 = dsm.registers[3]; // AJP-th-sel
215 
216  return ((jpBits[0] > R3 && jpBits[1] > R3) ||
217  (jpBits[1] > R3 && jpBits[2] > R3) ||
218  (jpBits[2] > R3 && jpBits[3] > R3) ||
219  (jpBits[3] > R3 && jpBits[4] > R3) ||
220  (jpBits[4] > R3 && jpBits[5] > R3) ||
221  (jpBits[5] > R3 && jpBits[0] > R3));
222 }
223 int DSMAlgo_EM201_2015::ajpEndcap(const DSM& dsm)
224 {
225  int jpBits[6];
226 
227  // EE101
228 
229  jpBits[0] = dsm.channels[6] & 0x3; // JPA (4 o'clock)
230  jpBits[1] = dsm.channels[6] >> 2 & 0x3; // JPB (6 o'clock)
231  jpBits[2] = dsm.channels[6] >> 4 & 0x3; // JPC (8 o'clock)
232 
233  // EE102
234 
235  jpBits[3] = dsm.channels[7] & 0x3; // JPA (10 o'clock)
236  jpBits[4] = dsm.channels[7] >> 2 & 0x3; // JPB (12 o'clock)
237  jpBits[5] = dsm.channels[7] >> 4 & 0x3; // JPC (2 o'clock)
238 
239  const int R3 = dsm.registers[3]; // AJP-th-sel
240 
241  return ((jpBits[0] > R3 && jpBits[1] > R3) ||
242  (jpBits[1] > R3 && jpBits[2] > R3) ||
243  (jpBits[2] > R3 && jpBits[3] > R3) ||
244  (jpBits[3] > R3 && jpBits[4] > R3) ||
245  (jpBits[4] > R3 && jpBits[5] > R3) ||
246  (jpBits[5] > R3 && jpBits[0] > R3));
247 }
248 void DSMAlgo_EM201_2015::getHybridJetPatchSums(const DSM& dsm, int& jpSum1, int& jpSum2)
249 {
250  jpSum1 = dsm.channels[6] >> 6 & 0x3f; // Partial sum from EE101
251  jpSum2 = dsm.channels[7] >> 6 & 0x3f; // Partial sum from EE102
252 
253  int jpId1 = dsm.channels[6] >> 12 & 0x3; // Partial jet patch ID from EE101
254  int jpId2 = dsm.channels[7] >> 12 & 0x3; // Partial jet patch ID from EE102
255 
256  switch (jpId1) {
257  case 1: jpSum1 += dsm.channels[3] >> 6 & 0x3f; break; // Add partial sum from BC104 (4')
258  case 2: jpSum1 += dsm.channels[4] >> 6 & 0x3f; break; // Add partial sum from BC105 (6')
259  case 3: jpSum1 += dsm.channels[5] >> 6 & 0x3f; break; // Add partial sum from BC106 (8')
260  }
261 
262  switch (jpId2) {
263  case 1: jpSum2 += dsm.channels[0] >> 6 & 0x3f; break; // Add partial sum from BC101 (10')
264  case 2: jpSum2 += dsm.channels[1] >> 6 & 0x3f; break; // Add partial sum from BC102 (12')
265  case 3: jpSum2 += dsm.channels[2] >> 6 & 0x3f; break; // Add partial sum from BC103 (2')
266  }
267 }
268 
269 void DSMAlgo_EM201_2015::getHTTP(const DSM &dsm, int &b2b, int &nonadj)
270 {
271  b2b = 0;
272  for(int ichn = 0, jchn = 3; ichn < 6 && ichn < jchn; ichn++, jchn = (ichn+3)%6){
273  int ihttp = (dsm.channels[ichn] >> 15) & 0x1;
274 // jchn = (ichn + 3)%6;
275  int jhttp = (dsm.channels[jchn] >> 15) & 0x1;
276 
277  b2b |= ihttp && jhttp;
278 // printf("b2b: %d=%d, %d=%d\n", ichn, ihttp, jchn, jhttp);
279  }
280 
281  nonadj = 0;
282 
283  for(int ichn = 0; ichn < 6; ichn++){
284  int ihttp = (dsm.channels[ichn] >> 15) & 0x1;
285  for(int jchn = ichn + 2; jchn < ichn + 5 && jchn < 6; jchn++){
286  int jhttp = (dsm.channels[jchn] >> 15) & 0x1;
287  nonadj |= (ihttp && jhttp);
288 // printf("nonadj: %d=%d, %d=%d\n", ichn, ihttp, jchn, jhttp);
289  }
290  }
291 }
292 
293 int DSMAlgo_EM201_2015::getEB2B(const DSM& dsm)
294 {
295  int jpBits[6];
296 
297  // EE101
298 
299  jpBits[0] = dsm.channels[6] & 0x3; // JPA (4 o'clock)
300  jpBits[1] = dsm.channels[6] >> 2 & 0x3; // JPB (6 o'clock)
301  jpBits[2] = dsm.channels[6] >> 4 & 0x3; // JPC (8 o'clock)
302 
303  // EE102
304 
305  jpBits[3] = dsm.channels[7] & 0x3; // JPA (10 o'clock)
306  jpBits[4] = dsm.channels[7] >> 2 & 0x3; // JPB (12 o'clock)
307  jpBits[5] = dsm.channels[7] >> 4 & 0x3; // JPC (2 o'clock)
308 
309  int b2b = 0;
310  int JP = 0;
311 
312  for(int ichn = 0, jchn = 3; ichn < 6 && ichn < jchn; ichn++){
313  int iJP = jpBits[ichn];
314  jchn = (ichn + 3)%6;
315  int jJP = jpBits[jchn];
316 
317  b2b |= (iJP > JP) && (jJP > JP);
318  }
319  return b2b;
320 }
Definition: DSM.hh:16