StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
DSMAlgo_EM201_2013.cc
1 #include "DSM.hh"
2 #include "DSMAlgo_EM201_2013.hh"
3 
4 int DSMAlgo_EM201_2013::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::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 
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 
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 
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("em201: r0 = %d r1 = %d r2 = %d\n", dsm.registers[0], dsm.registers[1], dsm.registers[2]);
177  if (jpBitsBarrel > jpBits) jpBits = jpBitsBarrel;
178  if (jpBitsEndcap > jpBits) jpBits = jpBitsEndcap;
179 
180  int jp0 = jpBits > 0;
181  int jp1 = jpBits > 1;
182  int jp2 = jpBits > 2;
183 
184  // Adjacent jet patch logic
185 
186  //printf("R3 = %d\n", dsm.registers[3]);
187  int ajpx = ajpBarrel(dsm, 0);
188  int ajpy = ajpBarrel(dsm, 2);
189  int ajpz = ajpBarrel(dsm, 4);
190  int bajp = ajpx || ajpy || ajpz;
191 
192  int dijet0 = Dijet(dsm, 0);
193 
194  //printf("dijet0 = %d\n", dijet0);
195 
196  int dijet1 = Dijet(dsm, 1);
197 
198  //printf("dijet1 = %d\n", dijet1);
199 
200  int edijet = EndDijet(dsm, 0);
201  //printf("edijet = %d\n", edijet);
202 
203  int daq10k = 0;
204  //No endcap ajp in 2013
205  // int eajp = ajpEndcap(dsm);
206  // int ajp = bajp || eajp;
207 
208  // OUTPUT (16):
209 
210  // (0:3) Barrel HT bits (4)
211  // (4:5) Endcap HT bits (2)
212  // (6) JP1, unified over the BEMC+EEMC (1)
213  // (7) JP2, unified over the BEMC+EEMC (1)
214  // (8) BJP1, for the 18 BEMC-only patches (1)
215  // (9) EEMC-dijet, EEMC-only JP0-based dijet trigger bit (1)
216  // (10) EJP1, for the 6 EEMC-only patches (1)
217  // (11) JP1-dijet, JP1-based dijet trigger bit (1)
218  // (12) JP0-dijet, JP0-based dijet trigger bit (1)
219  // (13) BAJP, for the BEMC-only patches (1)
220  // (14) DAQ10k, DAQ10k trigger bit (1)
221  // (15) JP0, unified over the BEMC+EEMC (1)
222 
223  int out = 0;
224 
225  out |= htBitsBarrel;
226  out |= htBitsEndcap << 4;
227  out |= jp1 << 6;
228  out |= jp2 << 7;
229  out |= bjp1 << 8;
230  out |= edijet << 9;
231  out |= ejp1 << 10;
232  out |= dijet1 << 11;
233  out |= dijet0 << 12;
234  out |= bajp << 13;
235  out |= daq10k << 14;
236  out |= jp0 << 15;
237 
238  dsm.output = out;
239 
240  // INFO
241 
242  dsm.info[0] = jpSum1;
243  dsm.info[1] = jpSum2;
244 
245 // return 0;
246 }
247 int DSMAlgo_EM201_2013::Dijet(DSM &dsm, int jpTH = 0) const
248 {
249  // Search for BEMC JP0 & JP1 di-jet signature
250 
251  int eemcDijetBits[6];
252 
253  eemcDijetBits[0] = dsm.channels[7] >> 2 & 1; // EE102 10 o'clock
254  eemcDijetBits[1] = dsm.channels[7] >> 3 & 1; // EE102 12 o'clock
255  eemcDijetBits[2] = dsm.channels[7] >> 4 & 1; // EE102 2 o'clock
256  eemcDijetBits[3] = dsm.channels[6] >> 2 & 1; // EE101 4 o'clock
257  eemcDijetBits[4] = dsm.channels[6] >> 3 & 1; // EE101 6 o'clock
258  eemcDijetBits[5] = dsm.channels[6] >> 4 & 1; // EE101 8 o'clock
259 
260  int dijet = 0;
261  // int dijet1 = 0;
262 
263  for (int ch = 0; ch < 6; ++ch) {
264  int jpx = dsm.channels[ch] >> 0 & 0x3;
265  int jpy = dsm.channels[ch] >> 2 & 0x3;
266  int jpz = dsm.channels[ch] >> 4 & 0x3;
267 
268  int bemcDijet2 = dsm.channels[(ch+2)%6] >> 15 & 1;
269  int bemcDijet3 = dsm.channels[(ch+3)%6] >> 15 & 1;
270  int bemcDijet4 = dsm.channels[(ch+4)%6] >> 15 & 1;
271 
272  int eemcDijet2 = eemcDijetBits[(ch+2)%6];
273  int eemcDijet3 = eemcDijetBits[(ch+3)%6];
274  int eemcDijet4 = eemcDijetBits[(ch+4)%6];
275 
276  int bjp = jpx > jpTH || jpy > jpTH || jpz > jpTH;
277  // int bjp = jpx > 1 || jpy > 1 || jpz > 1;
278 
279  int bemcDijet = bemcDijet2 || bemcDijet3 || bemcDijet4;
280  int eemcDijet = eemcDijet2 || eemcDijet3 || eemcDijet4;
281 
282  dijet |= bjp && (bemcDijet || eemcDijet);
283  // dijet1 |= bjp1 && (bemcDijet || eemcDijet);
284  }
285  return dijet;
286 }
287 int DSMAlgo_EM201_2013::EndDijet(DSM &dsm, int jpTH = 0) const
288 {
289  // Search for JP0 EEMC di-jet signature
290  int eemcDijetBits[6];
291 
292  eemcDijetBits[0] = dsm.channels[7] >> 2 & 1; // EE102 10 o'clock
293  eemcDijetBits[1] = dsm.channels[7] >> 3 & 1; // EE102 12 o'clock
294  eemcDijetBits[2] = dsm.channels[7] >> 4 & 1; // EE102 2 o'clock
295  eemcDijetBits[3] = dsm.channels[6] >> 2 & 1; // EE101 4 o'clock
296  eemcDijetBits[4] = dsm.channels[6] >> 3 & 1; // EE101 6 o'clock
297  eemcDijetBits[5] = dsm.channels[6] >> 4 & 1; // EE101 8 o'clock
298 
299  int ee101_jp0 = dsm.channels[6] & 3; // 4, 6 and 8 o'clock
300  int ee102_jp0 = dsm.channels[7] & 3; // 10, 12 and 2 o'clock
301 
302  int ee101_dijet = ee101_jp0 && (eemcDijetBits[0] || eemcDijetBits[1] || eemcDijetBits[2]);
303  int ee102_dijet = ee102_jp0 && (eemcDijetBits[3] || eemcDijetBits[4] || eemcDijetBits[5]);
304 
305  int eemc_dijet = ee101_dijet || ee102_dijet;
306 
307  return eemc_dijet;
308 }
Definition: DSM.hh:16