StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
DSMAlgo_BC101_2013.cc
1 #include "DSMAlgo_BC101_2013.hh"
2 
3 void DSMAlgo_BC101_2013::operator()(DSM& dsm)
4 {
5  // INPUT:
6 
7  // ----------------------------------------------------------------------
8  // BC101 - ch0 - BE001 | B101 - ch1 - BW001 |
9  // ch2 - BE002 | ch3 - BW002 |
10  // ch4 - BE003 - JP1 (0-15) | ch5 - BW003 - JP1 (0-15) |
11  // ----------------------------------------------------------------------
12  // BC102 - ch0 - BE003 - JP6 (16-31) | B102 - ch1 - BW003 - JP6 (16-31) |
13  // ch2 - BE004 | ch3 - BW004 |
14  // ch4 - BE005 | ch5 - BW005 |
15  // ----------------------------------------------------------------------
16 
17  // From each channel:
18 
19  // (0-5) TP sum for low-eta group (6)
20  // (6-11) TP sum for high-eta group (6)
21  // (12-15) HT bits (4)
22 
23  // REGISTERS:
24 
25  // R0: BEMC-Jet-Patch-Th0 (9)
26  // R1: BEMC-Jet-Patch-Th1 (9)
27  // R2: BEMC-Jet-Patch-Th2 (9)
28  // R4: BEMC-JP-th-dijet (9)
29  // ACTION:
30 
31  int jpx = 0; // East (-1 < eta < 0)
32  int jpy = 0; // Middle (-0.6 < eta < 0.4)
33  int jpz = 0; // West (0 < eta < 1)
34  int jpPartial = 0; // Partial (0.4 < eta < 1)
35 
36  int highTowerBits = 0;
37 
38  // East (ch0/2/4 - even channels)
39 
40  for (int ch = 0; ch <= 4; ch += 2) {
41  int lowEtaSum = dsm.channels[ch] & 0x3f;
42  int highEtaSum = dsm.channels[ch] >> 6 & 0x3f;
43  jpx += lowEtaSum + highEtaSum;
44  jpy += lowEtaSum;
45  highTowerBits |= dsm.channels[ch] >> 12 & 0xf;
46  }
47 
48  // West (ch1/3/5 - odd channels)
49 
50  for (int ch = 1; ch <= 5; ch += 2) {
51  int lowEtaSum = dsm.channels[ch] & 0x3f;
52  int highEtaSum = dsm.channels[ch] >> 6 & 0x3f;
53  jpy += lowEtaSum;
54  jpz += lowEtaSum + highEtaSum;
55  jpPartial += highEtaSum;
56  highTowerBits |= dsm.channels[ch] >> 12 & 0xf;
57  }
58 
59  // If overflow, set JPpartial sum to max
60  if (jpPartial > 63) jpPartial = 63;
61 
62  // Compare each jet patch sum to three thresholds
63  // and then pack results for each jet patch into
64  // 2-bit integer.
65 
66  int jpxBits = 0;
67  int jpyBits = 0;
68  int jpzBits = 0;
69 
70  for (int reg = 0; reg < 3; ++reg) {
71  if (jpx > dsm.registers[reg]) ++jpxBits;
72  if (jpy > dsm.registers[reg]) ++jpyBits;
73  if (jpz > dsm.registers[reg]) ++jpzBits;
74  }
75  // 1-bit
76  int dijetBits = 0 ;
77  // compare jpx, jpy, jpz to di-jet threshold
78  // OR the results and produce di-jet output
79  int r4 = dsm.registers[4];
80  dijetBits = (jpx > r4) || (jpy > r4) || (jpz > r4);
81  //printf("r0 = %d r1 = %d r2 = %d r4 = %d\n", dsm.registers[0], dsm.registers[1], dsm.registers[2], r4);
82  //printf("jpx = %d jpy = %d jpz = %d\n", jpx, jpy, jpz);
83  // Pack high tower bits
84  int packedHTBits = 0;
85  for(int ibit = 0; ibit < 3; ++ibit)
86  {
87  if(highTowerBits & (1 << ibit))
88  ++packedHTBits;
89  }
90  int fourthHTBits = 0;
91  fourthHTBits |= highTowerBits >> 3;
92 
93  //printf("highTowerBits = %x packedHTBits = %d fourthHTBits = %d\n", highTowerBits, packedHTBits, fourthHTBits);
94  // OUTPUT (16):
95 
96  // (0-1) JPX threshold bits (2)
97  // (2-3) JPY threshold bits (2)
98  // (4-5) JPZ threshold bits (2)
99  // (6-11) JPpartial sum (6)
100  // (12-15) HT bits (4)
101 
102  int out = 0;
103 
104  out |= jpxBits;
105  out |= jpyBits << 2;
106  out |= jpzBits << 4;
107  out |= jpPartial << 6;
108  out |= packedHTBits << 12;
109  out |= fourthHTBits << 14;
110  out |= dijetBits << 15;
111  dsm.output = out;
112 
113  // INFO:
114 
115  dsm.info[0] = jpx;
116  dsm.info[1] = jpy;
117  dsm.info[2] = jpz;
118  //partial sum
119  dsm.info[3] = jpPartial;
120 
121 }
Definition: DSM.hh:16