137 {
138 int exponent[4];
139 double mantissa[4] = {0};
141
142 double delta0(0);
143 double delta1(0);
144 double delta2(0);
145 double delta3(0);
146 int factor;
147
148 msg << MSG::VERBOSE <<
"called JetSignalStateCnv::compress() for :" <<
endmsg;
149 msg << MSG::VERBOSE <<
" raw momentum ( px | py | pz | m ) : ( "
150 << momRaw.
m_px <<
" | "
151 << momRaw.
m_py <<
" | "
152 << momRaw.
m_pz <<
" | "
154 msg << MSG::VERBOSE <<
" cal momentum ( px | py | pz | m ) : ( "
155 << momCal.
m_px <<
" | "
156 << momCal.
m_py <<
" | "
157 << momCal.
m_pz <<
" | "
159
160 bool forceNoCompression = false;
161
162
163 if (momRaw.
m_m == 0 || momCal.
m_m == 0) {
164 forceNoCompression = true;
165 }
166 if (momRaw.
m_px == 0 && momRaw.
m_py == 0) {
167 forceNoCompression = true;
168 }
169 if (momCal.
m_px == 0 && momCal.
m_py == 0) {
170 forceNoCompression = true;
171 }
172
173 if (forceNoCompression) {
174 msg << MSG::DEBUG <<
"M or PT of calibrated or raw signal state of jet zero !"
175 <<
" Switching off compression for this jet !!!" <<
endmsg;
177 }
178
179
181 double angleC = std::atan2(momCal.
m_py, momCal.
m_px);
182 double angleR = std::atan2(momRaw.
m_py, momRaw.
m_px);
183 double p_traC = std::sqrt(momCal.
m_px * momCal.
m_px + momCal.
m_py * momCal.
m_py);
184 double p_traR = std::sqrt(momRaw.
m_px * momRaw.
m_px + momRaw.
m_py * momRaw.
m_py);
185 mantissa[0] = std::frexp(momCal.
m_m / momRaw.
m_m - 1, &exponent[0]);
186 mantissa[1] = std::frexp(angleC - angleR, &exponent[1]);
187 mantissa[2] = std::frexp(momCal.
eta() - momRaw.
eta(), &exponent[2]);
188 mantissa[3] = std::frexp(p_traC / p_traR - 1, &exponent[3]);
189
190 delta0 = momCal.
m_m / momRaw.
m_m - 1;
191 delta1 = angleC - angleR;
192 delta2 = momCal.
eta() - momRaw.
eta();
193 delta3 = p_traC / p_traR - 1;
194 }
195
196 unsigned long tmp0(0);
197 unsigned long tmp1(0);
198 unsigned long tmp2(0);
199 unsigned long tmp3(0);
200
201 unsigned short vec0(0);
202 unsigned short vec1(0);
203 unsigned short vec2(0);
204
205 switch (level) {
207 factor = 0;
208 exponent[0] += 2;
209 if (exponent[0] > 0x7) {
210 exponent[0] = 0x7;
211 }
212 if (exponent[0] < 0x0) {
213 factor = -exponent[0];
214 exponent[0] = 0x0;
215 }
216 tmp0 =
int(std::fabs(mantissa[0]) * 0x10) >> factor;
217 tmp0 |= (exponent[0] & 0x7) << 5;
218 if (mantissa[0] < 0) {
219 tmp0 |= 0x10;
220 }
221
222 factor = 0;
223 exponent[1] += 5;
224 if (exponent[1] > 0x7) {
225 exponent[1] = 0x7;
226 }
227 if (exponent[1] < 0x0) {
228 factor = -exponent[1];
229 exponent[1] = 0x0;
230 }
231 tmp1 =
int(std::fabs(mantissa[1]) * 0x10) >> factor;
232 tmp1 |= (exponent[1] & 0x7) << 5;
233 if (mantissa[1] < 0) {
234 tmp1 |= 0x10;
235 }
236
237 factor = 0;
238 exponent[2] += 5;
239 if (exponent[2] > 0x7) {
240 exponent[2] = 0x7;
241 }
242 if (exponent[2] < 0x0) {
243 factor = -exponent[2];
244 exponent[2] = 0x0;
245 }
246 tmp2 =
int(std::fabs(mantissa[2]) * 0x10) >> factor;
247 tmp2 |= (exponent[2] & 0x7) << 5;
248 if (mantissa[2] < 0) {
250 }
251
252 factor = 0;
253 exponent[3] += 5;
254 if (exponent[3] > 0x7) {
255 exponent[3] = 0x7;
256 }
257 if (exponent[3] < 0x0) {
258 factor = -exponent[3];
259 exponent[3] = 0x0;
260 }
261 tmp3 =
int(std::fabs(mantissa[3]) * 0x10) >> factor;
262 tmp3 |= (exponent[3] & 0x7) << 5;
263 if (mantissa[3] < 0) {
264 tmp3 |= 0x10;
265 }
266
267 vec0 = tmp0;
268 vec0 += tmp1 << 8;
270 vec1 += tmp3 << 8;
273 break;
274
276 factor = 0;
277 exponent[0] += 3;
278 if (exponent[0] > 0xF) {
279 exponent[0] = 0xF;
280 }
281 if (exponent[0] < 0x0) {
282 factor = -exponent[0];
283 exponent[0] = 0;
284 }
285 tmp0 =
int(std::fabs(mantissa[0]) * 0x80) >> factor;
286 if (mantissa[0] < 0) {
287 tmp0 |= 0x80;
288 }
289
290 factor = 0;
291 exponent[1] += 6;
292 if (exponent[1] > 0xF) {
293 exponent[1] = 0xF;
294 }
295 if (exponent[1] < 0x0) {
296 factor = -exponent[1];
297 exponent[1] = 0;
298 }
299 tmp1 =
int(std::fabs(mantissa[1]) * 0x80) >> factor;
300 if (mantissa[1] < 0) {
301 tmp1 |= 0x80;
302 }
303
304 factor = 0;
305 exponent[2] += 6;
306 if (exponent[2] > 0xF) {
307 exponent[2] = 0xF;
308 }
309 if (exponent[2] < 0x0) {
310 factor = -exponent[2];
311 exponent[2] = 0;
312 }
313 tmp2 =
int(std::fabs(mantissa[2]) * 0x80) >> factor;
314 if (mantissa[2] < 0) {
316 }
317
318 factor = 0;
319 exponent[3] += 6;
320 if (exponent[3] > 0xF) {
321 exponent[3] = 0xF;
322 }
323 if (exponent[3] < 0x0) {
324 factor = -exponent[3];
325 exponent[3] = 0;
326 }
327 tmp3 =
int(std::fabs(mantissa[3]) * 0x80) >> factor;
328 if (mantissa[3] < 0) {
329 tmp3 |= 0x80;
330 }
331
332 vec0 = (tmp0 & 0xFF);
333 vec0 += (tmp1 & 0xFF) << 8;
334 vec1 = (
tmp2 & 0xFF);
335 vec1 += (tmp3 & 0xFF) << 8;
337 vec2 |= exponent[1] << 4;
338 vec2 |= exponent[2] << 8;
339 vec2 |= exponent[3] << 12;
343 break;
344
346 factor = 0;
347 exponent[0] += 5;
348 if (exponent[0] > 31) {
349 exponent[0] = 31;
350 }
351 if (exponent[0] < 0) {
352 factor = -exponent[0];
353 exponent[0] = 0;
354 }
355 tmp0 =
int(std::fabs(mantissa[0]) * 0x400) >> factor;
356 tmp0 |= exponent[0] << 11;
357 if (mantissa[0] < 0) {
358 tmp0 |= 0x400;
359 }
360
361 factor = 0;
362 exponent[1] += 7;
363 if (exponent[1] > 31) {
364 exponent[1] = 31;
365 }
366 if (exponent[1] < 0) {
367 factor = -exponent[1];
368 exponent[1] = 0;
369 }
370 tmp1 =
int(std::fabs(mantissa[1]) * 0x400) >> factor;
371 tmp1 |= exponent[1] << 11;
372 if (mantissa[1] < 0) {
373 tmp1 |= 0x400;
374 }
375
376 factor = 0;
377 exponent[2] += 7;
378 if (exponent[2] > 31) {
379 exponent[2] = 31;
380 }
381 if (exponent[2] < 0) {
382 factor = -exponent[2];
383 exponent[2] = 0;
384 }
385 tmp2 =
int(std::fabs(mantissa[2]) * 0x400) >> factor;
386 tmp2 |= exponent[2] << 11;
387 if (mantissa[2] < 0) {
389 }
390
391 factor = 0;
392 exponent[3] += 7;
393 if (exponent[3] > 31) {
394 exponent[3] = 31;
395 }
396 if (exponent[3] < 0) {
397 factor = -exponent[3];
398 exponent[3] = 0;
399 }
400 tmp3 =
int(std::fabs(mantissa[3]) * 0x400) >> factor;
401 tmp3 |= exponent[3] << 11;
402 if (mantissa[3] < 0) {
403 tmp3 |= 0x400;
404 }
405
410 break;
411
413 default:
414 {
418
422
426
428 ps.push_back(mass[0]);
429 ps.push_back(mass[1]);
430
431 msg << MSG::VERBOSE <<
" compress x : " << momRaw.
m_px
432 <<
" = " <<
px[0] <<
" = " <<
px[1] <<
endmsg;
433 msg << MSG::VERBOSE <<
" compress y : " << momRaw.
m_py
434 <<
" = " <<
py[0] <<
" = " <<
py[1] <<
endmsg;
435 msg << MSG::VERBOSE <<
" compress z : " << momRaw.
m_pz
436 <<
" = " <<
pz[0] <<
" = " <<
pz[1] <<
endmsg;
437 msg << MSG::VERBOSE <<
" compress m : " << momRaw.
m_m
439 break;
440 }
441 }
442
443 if (
msg.level() <= MSG::VERBOSE) {
444 msg << MSG::VERBOSE <<
" compress # ps : " <<
ps.size() <<
" : ";
445 for (JetConverterTypes::signalState_pers_t::const_iterator it =
ps.begin(); it !=
ps.end(); ++it) {
446 msg << std::hex << *
it <<
" ";
447 }
449 msg << MSG::VERBOSE <<
" compress x : " << momRaw.
m_px <<
endmsg;
450 msg << MSG::VERBOSE <<
" compress y : " << momRaw.
m_py <<
endmsg;
451 msg << MSG::VERBOSE <<
" compress z : " << momRaw.
m_pz <<
endmsg;
452 msg << MSG::VERBOSE <<
" compress m : " << momRaw.
m_m <<
endmsg;
453
456
457 switch (level) {
461 break;
465 break;
469 break;
471 default:
472 break;
473 }
474
475 msg << MSG::DEBUG <<
" compress M : " << delta0 <<
" = "
476 << mantissa[0] <<
" *2^ " << exponent[0] -
d0 <<
endmsg;
477 msg << MSG::DEBUG <<
" compress phi : " << delta1 <<
" = "
478 << mantissa[1] <<
" *2^ " << exponent[1] -
d1 <<
endmsg;
479 msg << MSG::DEBUG <<
" compress eta : " << delta2 <<
" = "
480 << mantissa[2] <<
" *2^ " << exponent[2] -
d1 <<
endmsg;
481 msg << MSG::DEBUG <<
" compress pT : " << delta3 <<
" = "
482 << mantissa[3] <<
" *2^ " << exponent[3] -
d1 <<
endmsg;
483 }
485 }
std::vector< D3PDTest::MyVec2 > vec2
std::vector< unsigned short > signalState_pers_t
std::array< std::uint16_t, 2 > shortsFromFloat(float value)