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