42 {
43
44
45 SG::ReadCondHandle<gFEXDBCondData> myDBTool = SG::ReadCondHandle<gFEXDBCondData>(
m_DBToolKey, ctx);
48 throw std::runtime_error("Could not retrieve DB tool");
49 }
50
51 std::string fwVersion = myDBTool->get_FWVersion();
52 int major = std::stoi(fwVersion);
53 bool SumETfast = (major >= 1);
54 bool metRho = (major >= 2);
55
56
57 SG::ReadHandle<TrigConf::L1Menu> l1Menu (
m_l1MenuKey, ctx);
58 if (!l1Menu.isValid()) {
60 throw std::runtime_error("Could not retrieve L1Menu");
61 }
62
63
64 const auto & thr_gXE = l1Menu->thrExtraInfo().gXE();
65 int gBlockthresholdA = thr_gXE.seedThr('A');
66 int gBlockthresholdB = thr_gXE.seedThr('B');
67 int gBlockthresholdC = thr_gXE.seedThr('C');
68 int aFPGA_A = thr_gXE.JWOJ_param('A','a');
69 int bFPGA_A = thr_gXE.JWOJ_param('A','b');
70 int aFPGA_B = thr_gXE.JWOJ_param('B','a');
71 int bFPGA_B = thr_gXE.JWOJ_param('B','b');
72 int aFPGA_C = thr_gXE.JWOJ_param('C','a');
73 int bFPGA_C = thr_gXE.JWOJ_param('C','b');
74
75
78
81
84
86
87 gBlockAB(Atwr, AgBlk, hasSeed, gBlockthresholdA);
88 gBlockAB(Btwr, BgBlk, hasSeed, gBlockthresholdB);
89 gBlockAB(Ctwr, CgBlk, hasSeed, gBlockthresholdC);
90
91
92
93
94
97 Ascaled[irow][jcolumn] = Atwr[irow][jcolumn] >> 2;
98 AgBlk[irow][jcolumn] = AgBlk[irow][jcolumn] >> 2;
99
100 Bscaled[irow][jcolumn] = Btwr[irow][jcolumn] >> 2;
101 BgBlk[irow][jcolumn] = BgBlk[irow][jcolumn] >> 2;
102
103 Cscaled[irow][jcolumn] = Ctwr[irow][jcolumn] >> 2;
104 CgBlk[irow][jcolumn] = CgBlk[irow][jcolumn] >> 2;
105
106 }
107 }
108
109
110
111 int A_MHT_x = 0x0;
112 int A_MHT_y = 0x0;
113 int A_MST_x = 0x0;
114 int A_MST_y = 0x0;
115 int A_MET_x = 0x0;
116 int A_MET_y = 0x0;
117
118 int A_eth = 0x0;
119 int A_ets = 0x0;
120 int A_etw = 0x0;
121
122
123 int B_MHT_x = 0x0;
124 int B_MHT_y = 0x0;
125 int B_MST_x = 0x0;
126 int B_MST_y = 0x0;
127 int B_MET_x = 0x0;
128 int B_MET_y = 0x0;
129
130 int B_eth = 0x0;
131 int B_ets = 0x0;
132 int B_etw = 0x0;
133
134
135 int C_MHT_x = 0x0;
136 int C_MHT_y = 0x0;
137 int C_MST_x = 0x0;
138 int C_MST_y = 0x0;
139 int C_MET_x = 0x0;
140 int C_MET_y = 0x0;
141
142 int C_eth = 0x0;
143 int C_ets = 0x0;
144 int C_etw = 0x0;
145
146
147 int MHT_x = 0x0;
148 int MHT_y = 0x0;
149 int MST_x = 0x0;
150 int MST_y = 0x0;
151 int MET_x = 0x0;
152 int MET_y = 0x0;
153
154 int ETH = 0x0;
155 int ETS = 0x0;
156 int ETW = 0x0;
157
158 int total_sumEt = 0x0;
160
161
162 int etBprime = 0;
163
164 if (metRho)
metFPGA_rho(0, Ascaled, pucA_JWJ, AgBlk, gBlockthresholdA, aFPGA_A, bFPGA_A, A_MHT_x, A_MHT_y, A_MST_x, A_MST_y, A_MET_x, A_MET_y);
165 else metFPGA(0, Ascaled, AgBlk, gBlockthresholdA, aFPGA_A, bFPGA_A, A_MHT_x, A_MHT_y, A_MST_x, A_MST_y, A_MET_x, A_MET_y);
166 if (SumETfast)
etFastFPGA(0, Ascaled, AgBlk, gBlockthresholdA, aFPGA_A, etBprime, A_eth, A_ets, A_etw);
167 else etFPGA(0, Ascaled, AgBlk, gBlockthresholdA, aFPGA_A, etBprime, A_eth, A_ets, A_etw);
168
169 if (metRho)
metFPGA_rho(1, Bscaled, pucB_JWJ, BgBlk, gBlockthresholdB, aFPGA_B, bFPGA_B, B_MHT_x, B_MHT_y, B_MST_x, B_MST_y, B_MET_x, B_MET_y);
170 else metFPGA(1, Bscaled, BgBlk, gBlockthresholdB, aFPGA_B, bFPGA_B, B_MHT_x, B_MHT_y, B_MST_x, B_MST_y, B_MET_x, B_MET_y);
171 if (SumETfast)
etFastFPGA(1, Bscaled, BgBlk, gBlockthresholdB, aFPGA_B, etBprime, B_eth, B_ets, B_etw);
172 else etFPGA(1, Bscaled, BgBlk, gBlockthresholdB, aFPGA_B, etBprime, B_eth, B_ets, B_etw);
173
174 if (metRho)
metFPGA_rho(2, Cscaled, pucC_JWJ, CgBlk, gBlockthresholdC, aFPGA_C, bFPGA_C, C_MHT_x, C_MHT_y, C_MST_x, C_MST_y, C_MET_x, C_MET_y);
175 else metFPGA(2, Cscaled, CgBlk, gBlockthresholdC, aFPGA_C, bFPGA_C, C_MHT_x, C_MHT_y, C_MST_x, C_MST_y, C_MET_x, C_MET_y);
176 if (SumETfast)
etFastFPGA(2, Cscaled, CgBlk, gBlockthresholdC, aFPGA_C, etBprime, C_eth, C_ets, C_etw);
177 else etFPGA(2, Cscaled, CgBlk, gBlockthresholdC, aFPGA_C, etBprime, C_eth, C_ets, C_etw);
178
179 metTotal(A_MHT_x, A_MHT_y, B_MHT_x, B_MHT_y, C_MHT_x, C_MHT_y, MHT_x, MHT_y);
180 metTotal(A_MST_x, A_MST_y, B_MST_x, B_MST_y, C_MST_x, C_MST_y, MST_x, MST_y);
181 metTotal(A_MET_x, A_MET_y, B_MET_x, B_MET_y, C_MET_x, C_MET_y, MET_x, MET_y);
182
183 etTotal(A_eth, B_eth, C_eth, ETH);
184 etTotal(A_ets, B_ets, C_ets, ETS);
185 etTotal(A_etw, B_etw, C_etw, ETW);
186 total_sumEt = ETW;
187
188
189 int MET2 = MET_x * MET_x + MET_y * MET_y;
190
191 if (MET2 > 0x0FFFFFF) {
193 } else {
194
195 MET = std::sqrt(MET2);
196
197
198
199
200
201
202
203 }
204
205
206
207 std::vector<std::unique_ptr<gFEXJwoJTOB>> tobs_v;
208 tobs_v.resize(4);
209
210
211
212
213
214
215 outTOB[0] = (total_sumEt & 0x00000FFF) << 0;
216 outTOB[0] = outTOB[0] | (
MET & 0x00000FFF) << 12;
217 if (total_sumEt != 0) outTOB[0] = outTOB[0] | 0x00000001 << 24;
218 if (MET != 0) outTOB[0] = outTOB[0] | 0x00000001 << 25;
219 outTOB[0] = outTOB[0] | (1 & 0x0000001F) << 26;
220
221
222
223
224 outTOB[1] = (MET_y & 0x00000FFF) << 0;
225 outTOB[1] = outTOB[1] | (MET_x & 0x00000FFF) << 12;
226 if (MET_y != 0) outTOB[1] = outTOB[1] | 0x00000001 << 24;
227 if (MET_x != 0) outTOB[1] = outTOB[1] | 0x00000001 << 25;
228 outTOB[1] = outTOB[1] | (2 & 0x0000001F) << 26;
229
230
231 outTOB[2] = (MHT_y & 0x00000FFF) << 0;
232 outTOB[2] = outTOB[2] | (MHT_x & 0x00000FFF) << 12;
233 if (MHT_y != 0) outTOB[2] = outTOB[2] | 0x00000001 << 24;
234 if (MHT_x != 0) outTOB[2] = outTOB[2] | 0x00000001 << 25;
235 outTOB[2] = outTOB[2] | (3 & 0x0000001F) << 26;
236
237
238 outTOB[3] = (MST_y & 0x00000FFF) << 0;
239 outTOB[3] = outTOB[3] | (MST_x & 0x00000FFF) << 12;
240 if (MST_y != 0) outTOB[3] = outTOB[3] | 0x00000001 << 24;
241 if (MST_x != 0) outTOB[3] = outTOB[3] | 0x00000001 << 25;
242 outTOB[3] = outTOB[3] | (4 & 0x0000001F) << 26;
243
244
245 tobs_v[0] = std::make_unique<gFEXJwoJTOB>();
246 tobs_v[0]->setWord(outTOB[0]);
247 tobs_v[0]->setQuantity1(MET);
248 tobs_v[0]->setQuantity2(total_sumEt);
249 tobs_v[0]->setSaturation(0);
250 tobs_v[0]->setTobID(1);
251 if( MET != 0 ) tobs_v[0]->setStatus1(1);
252 else tobs_v[0]->setStatus1(0);
253 if(total_sumEt!= 0) tobs_v[0]->setStatus2(1);
254 else tobs_v[0]->setStatus2(0);
255
256 tobs_v[1] = std::make_unique<gFEXJwoJTOB>();
257 tobs_v[1]->setWord(outTOB[1]);
258 tobs_v[1]->setQuantity1(MET_x);
259 tobs_v[1]->setQuantity2(MET_y);
260 tobs_v[1]->setSaturation(0);
261 tobs_v[1]->setTobID(2);
262 if( MET_x != 0 ) tobs_v[1]->setStatus1(1);
263 else tobs_v[1]->setStatus1(0);
264 if(MET_y!= 0) tobs_v[1]->setStatus2(1);
265 else tobs_v[1]->setStatus2(0);
266
267 tobs_v[2] = std::make_unique<gFEXJwoJTOB>();
268 tobs_v[2]->setWord(outTOB[2]);
269 tobs_v[2]->setQuantity1(MHT_x);
270 tobs_v[2]->setQuantity2(MHT_y);
271 tobs_v[2]->setSaturation(0);
272 tobs_v[2]->setTobID(3);
273 if( MHT_x != 0 ) tobs_v[2]->setStatus1(1);
274 else tobs_v[2]->setStatus1(0);
275 if(MHT_y!= 0) tobs_v[2]->setStatus2(1);
276 else tobs_v[2]->setStatus2(0);
277
278 tobs_v[3] = std::make_unique<gFEXJwoJTOB>();
279 tobs_v[3]->setWord(outTOB[3]);
280 tobs_v[3]->setQuantity1(MST_x);
281 tobs_v[3]->setQuantity2(MST_y);
282 tobs_v[3]->setSaturation(0);
283 tobs_v[3]->setTobID(4);
284 if( MST_x != 0 ) tobs_v[3]->setStatus1(1);
285 else tobs_v[2]->setStatus1(0);
286 if(MST_y!= 0) tobs_v[3]->setStatus2(1);
287 else tobs_v[3]->setStatus2(0);
288
289
290 return tobs_v;
291
292}
static constexpr int ABcolumns
void etFastFPGA(int FPGAnum, const gTowersType &twrs, gTowersType &gBlkSum, int gBlockthreshold, int A, int B, int ð, int &ets, int &etw) const
void metFPGA(int FPGAnum, const gTowersType &twrs, const gTowersType &gBlkSum, int gBlockthreshold, int aFPGA, int bFPGA, int &MHT_x, int &MHT_y, int &MST_x, int &MST_y, int &MET_x, int &MET_y) const
void etFPGA(int FPGAnum, const gTowersType &twrs, gTowersType &gBlkSum, int gBlockthreshold, int A, int B, int ð, int &ets, int &etw) const
void metFPGA_rho(int FPGAnum, const gTowersType &twrs, int puc_jwj, const gTowersType &gBlkSum, int gBlockthreshold, int aFPGA, int bFPGA, int &MHT_x, int &MHT_y, int &MST_x, int &MST_y, int &MET_x, int &MET_y) const
void metTotal(int A_MET_x, int A_MET_y, int B_MET_x, int B_MET_y, int C_MET_x, int C_MET_y, int &MET_x, int &MET_y) const
void gBlockAB(const gTowersType &twrs, gTowersType &gBlkSum, gTowersType &hasSeed, int seedThreshold) const
void etTotal(int A_ET, int B_ET, int C_ET, int &ET) const
std::array< std::array< int, 12 >, 32 > gTowersType