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