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