StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
DSMAlgo_EE102_2017.cc
1 #include "DSM.hh"
2 #include "sum_eemc_http.hh"
3 #include "DSMAlgo_EE102_2017.hh"
4 
5 void DSMAlgo_EE102_2017::operator()(DSM& dsm)
6 {
7  // INPUT:
8 
9  // EE102 - ch0 - EE005 - (16-31) jp1 clockwise
10  // ch1 - EE006
11  // ch2 - EE007
12  // ch3 - EE008 - (0-15) jp0 anti-clockwise
13  // ch4 - EE008 - (16-31) jp1 clockwise
14  // ch5 - EE009
15 
16  // From E006/007/009:
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 E005/008:
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; // JP0 - 10 o'clock
41  int jpb; // JP1 - 12 o'clock
42  int jpc; // JP2 - 2 o'clock
43 
44  getEemcUpperHalfJetPatchSums(dsm,jpa,jpb,jpc);
45 
46 
47  int httpa, httpb, httpc;
48  getEemcHTTP(dsm, httpa, httpb, httpc);
49 
50  // Place jet patch thresholds on sums
51 
52  int jpBits = 0;
53 
54  if(jpa > dsm.registers[2] || jpb > dsm.registers[2] || jpc > dsm.registers[2]){
55  jpBits = 3;
56  }else if(jpa > dsm.registers[1] || jpb > dsm.registers[1] || jpc > dsm.registers[1]){
57  jpBits = 2;
58  }else if(jpa > dsm.registers[0] || jpb > dsm.registers[0] || jpc > dsm.registers[0]){
59  jpBits = 1;
60  }else
61  jpBits = 0;
62 
63 
64  // OR HT bits
65 
66  int highTowerBits = 0;
67 
68  for (int ch = 0; ch < 6; ++ch)
69  highTowerBits |= dsm.channels[ch] >> 12 & 0xf;
70 
71  // Find largest sum for 1.09 < eta < 1.4 (low eta)
72 
73  int lowEtaSumA = dsm.channels[1] & 0x3f; // 10 o'clock
74  int lowEtaSumB = dsm.channels[2] & 0x3f; // 12 o'clock
75  int lowEtaSumC = dsm.channels[5] & 0x3f; // 2 o'clock
76 
77  int maxA = (lowEtaSumA > lowEtaSumB) && !(lowEtaSumC > lowEtaSumA);
78  int maxB = (lowEtaSumB > lowEtaSumC) && !(lowEtaSumA > lowEtaSumB);
79  int maxC = (lowEtaSumC > lowEtaSumA) && !(lowEtaSumB > lowEtaSumC);
80 
81  int maxId;
82  int maxSum;
83 
84  if (maxA) {
85  maxId = 1;
86  maxSum = lowEtaSumA;
87  }
88  else if (maxB) {
89  maxId = 2;
90  maxSum = lowEtaSumB;
91  }
92  else if (maxC) {
93  maxId = 3;
94  maxSum = lowEtaSumC;
95  }
96  else {
97  maxId = 1;
98  maxSum = lowEtaSumA;
99  }
100 
101  // If overflow, set to max
102 
103  if (maxSum > 63) maxSum = 63;
104 
105  // OUTPUT (16):
106 
107  // (0-1) JP threshold bits (2)
108  // (2) HT.TP-A bit (1)
109  // (3) HT.TP-B bit (1)
110  // (4) HT.TP-C bit (1)
111  // (5) Unused
112  // (6-11) Selected partial jet patch sum (6)
113  // (12-13) Partial jet patch ID (2)
114  // (14-15) HT bits (2)
115 
116  int out = 0;
117  out = jpBits;
118  out |= httpa << 2;
119  out |= httpb << 3;
120  out |= httpc << 4;
121  out |= maxSum << 6;
122  out |= maxId << 12;
123  out |= highTowerBits << 14;
124 
125  dsm.output = out;
126 
127  dsm.info[0] = jpa;
128  dsm.info[1] = jpb;
129  dsm.info[2] = jpc;
130  //low eta sum
131  dsm.info[3] = lowEtaSumA; // 10 o'clock
132  dsm.info[4] = lowEtaSumB; // 12 o'clock
133  dsm.info[5] = lowEtaSumC; // 2 o'clock
134 }
135 
136 void DSMAlgo_EE102_2017::getEemcUpperHalfJetPatchSums(const DSM& dsm, int& jpa, int& jpb, int& jpc)
137 {
138  int lowEtaSumA = dsm.channels[1] & 0x3f; // 10 o'clock
139  int lowEtaSumB = dsm.channels[2] & 0x3f; // 12 o'clock
140  int lowEtaSumC = dsm.channels[5] & 0x3f; // 2 o'clock
141 
142  int highEtaSumA = (dsm.channels[1] >> 6 & 0x3f) + (dsm.channels[0] & 0x3f); // 10 o'clock
143  int highEtaSumB = (dsm.channels[2] >> 6 & 0x3f) + (dsm.channels[3] & 0x3f); // 12 o'clock
144  int highEtaSumC = (dsm.channels[5] >> 6 & 0x3f) + (dsm.channels[4] & 0x3f); // 2 o'clock
145 
146  jpa = lowEtaSumA + highEtaSumA; // JP0 - 10 o'clock
147  jpb = lowEtaSumB + highEtaSumB; // JP1 - 12 o'clock
148  jpc = lowEtaSumC + highEtaSumC; // JP2 - 2 o'clock
149 }
150 
151 
Definition: DSM.hh:16