StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
DSMAlgo_EE101_2013.cc
1 #include "DSM.hh"
2 #include "DSMAlgo_EE101_2013.hh"
3 
4 void DSMAlgo_EE101_2013::operator()(DSM& dsm)
5 {
6  // INPUT:
7 
8  // EE101 - ch0 - EE001
9  // ch1 - EE002 - (0-15) jp0 anti-clockwise
10  // ch2 - EE002 - (16-31) jp1 clockwise
11  // ch3 - EE003
12  // ch4 - EE004
13  // ch5 - EE005 - (0-15) jp0 anti-clockwise
14 
15  // From E001/003/004:
16 
17  // (0-5) TP sum for low-eta group (6)
18  // (6-11) TP sum for high-eta group (6)
19  // (12-13) HT bits (2)
20  // (14-15) Unused (2)
21 
22  // From E002/005:
23 
24  // (0-5) TP sum (6)
25  // (6-11) Unused (2)
26  // (12-13) HT bits (2)
27  // (14-15) Unused (2)
28 
29  // REGISTERS:
30 
31  // R0: EEMC-Jet-Patch-Th0 (8)
32  // R1: EEMC-Jet-Patch-Th1 (8)
33  // R2: EEMC-Jet-Patch-Th2 (8)
34  // R3: EEMC-JP-th-dijet (8)
35 
36  // ACTION:
37 
38  // Make jet patch sums
39  // Low eta single-output DSM boards
40 
41  int lowEtaSumA = dsm.channels[0] & 0x3f; // 4 o'clock
42  int lowEtaSumB = dsm.channels[3] & 0x3f; // 6 o'clock
43  int lowEtaSumC = dsm.channels[4] & 0x3f; // 8 o'clock
44 
45  int highEtaSumA = (dsm.channels[0] >> 6 & 0x3f) + (dsm.channels[1] & 0x3f); // 4 o'clock
46  int highEtaSumB = (dsm.channels[3] >> 6 & 0x3f) + (dsm.channels[2] & 0x3f); // 6 o'clock
47  int highEtaSumC = (dsm.channels[4] >> 6 & 0x3f) + (dsm.channels[5] & 0x3f); // 8 o'clock
48 
49  int jpa = lowEtaSumA + highEtaSumA; // JP3 - 4 o'clock
50  int jpb = lowEtaSumB + highEtaSumB; // JP4 - 6 o'clock
51  int jpc = lowEtaSumC + highEtaSumC; // JP5 - 8 o'clock
52 
53  // Place jet patch thresholds on sums
54 
55  int jpaBits = 0;
56  int jpbBits = 0;
57  int jpcBits = 0;
58 
59  int jpCmbBits = 0;
60 
61  //jpa, jpb, jpb and combined jpCmb output for jp thresholds 0:2
62  for(int chn = 0; chn < 3; ++chn)
63  {
64  if(jpa > dsm.registers[chn]) jpaBits++;
65  if(jpb > dsm.registers[chn]) jpbBits++;
66  if(jpc > dsm.registers[chn]) jpcBits++;
67 
68  if(jpa > dsm.registers[chn] || jpb > dsm.registers[chn] || jpc > dsm.registers[chn]) jpCmbBits++;
69  //printf("r%d = %d ", chn, dsm.registers[chn]);
70  }
71  //printf("\n");
72  //jpa, jpb, jpc di-jet output
73  int r3 = dsm.registers[3];
74 
75  int jpaDijetBits = jpa > r3;
76  int jpbDijetBits = jpb > r3;
77  int jpcDijetBits = jpc > r3;
78  //printf("jpa = %d jpb = %d jpc = %d R3 = %d\n", jpa, jpb, jpc, r3);
79  // OR HT bits
80 
81  int highTowerBits = 0;
82 
83  for (int ch = 0; ch < 6; ++ch)
84  highTowerBits |= dsm.channels[ch] >> 12 & 0x3;
85 
86  // Find largest sum for 1.09 < eta < 1.4 (low eta)
87 
88  int maxA = (lowEtaSumA > lowEtaSumB) && !(lowEtaSumC > lowEtaSumA);
89  int maxB = (lowEtaSumB > lowEtaSumC) && !(lowEtaSumA > lowEtaSumB);
90  int maxC = (lowEtaSumC > lowEtaSumA) && !(lowEtaSumB > lowEtaSumC);
91 
92  int maxId = 0;
93  int maxSum = 0;
94 
95  if (maxA) {
96  maxId = 1;
97  maxSum = lowEtaSumA;
98  }
99  else if (maxB) {
100  maxId = 2;
101  maxSum = lowEtaSumB;
102  }
103  else if (maxC) {
104  maxId = 3;
105  maxSum = lowEtaSumC;
106  }
107  else {
108  maxId = 1;
109  maxSum = lowEtaSumA;
110  }
111 
112  // If overflow, set to max
113 
114  if (maxSum > 63) maxSum = 63;
115 
116  // OUTPUT (16):
117 
118  // 0:1 JP threshold (JPA, B and C combined)
119  // 2 JPA th-dijet bit
120  // 3 JPB th-dijet bit
121  // 4 JPC th-dijet bit
122  // 5 Unused
123  // 6:11 Selected partial jet patch sum
124  // 12:13 Partial jet patch ID
125  // 14:15 HT bits
126 
127  dsm.output = jpCmbBits;
128  dsm.output |= jpaDijetBits << 2;
129  dsm.output |= jpbDijetBits << 3;
130  dsm.output |= jpcDijetBits << 4;
131  dsm.output |= maxSum << 6;
132  dsm.output |= maxId << 12;
133  dsm.output |= highTowerBits << 14;
134 
135  // INFO:
136 
137  // I0: JP3 (4 o'clock) ADC sum
138  // I1: JP4 (6 o'clock) ADC sum
139  // I2: JP5 (8 o'clock) ADC sum
140 
141  dsm.info[0] = jpa;
142  dsm.info[1] = jpb;
143  dsm.info[2] = jpc;
144 
145  //low partial eta sum
146  dsm.info[3] = lowEtaSumA; //4 o'clock
147  dsm.info[4] = lowEtaSumB; //6 o'clock
148  dsm.info[5] = lowEtaSumC; //8 o'clock
149 }
Definition: DSM.hh:16