103 {
104 int exponent[4];
105 double mantissa[4] = {0};
107
108 double delta0(0);
109 double delta1(0);
110 double delta2(0);
111 double delta3(0);
112 int factor;
113
114 msg << MSG::VERBOSE <<
"called JetSignalStateCnv::compress() for :" <<
endmsg;
115 msg << MSG::VERBOSE <<
" raw momentum ( px | py | pz | m ) : ( "
116 << momRaw.
m_px <<
" | "
117 << momRaw.
m_py <<
" | "
118 << momRaw.
m_pz <<
" | "
120 msg << MSG::VERBOSE <<
" cal momentum ( px | py | pz | m ) : ( "
121 << momCal.
m_px <<
" | "
122 << momCal.
m_py <<
" | "
123 << momCal.
m_pz <<
" | "
125
126 bool forceNoCompression=false;
127
128
129 if ( momRaw.
m_m == 0 || momCal.
m_m == 0 )
130 forceNoCompression=true;
131 if ( momRaw.
m_px == 0 && momRaw.
m_py == 0 )
132 forceNoCompression=true;
133 if ( momCal.
m_px == 0 && momCal.
m_py == 0 )
134 forceNoCompression=true;
135
136 if ( forceNoCompression )
137 {
138 msg << MSG::DEBUG <<
"M or PT of calibrated or raw signal state of jet zero !"
139 <<
" Switching off compression for this jet !!!" <<
endmsg;
141 }
142
143
145 {
146 double angleC = atan2( momCal.
m_py, momCal.
m_px );
147 double angleR = atan2( momRaw.
m_py, momRaw.
m_px );
148 double p_traC = sqrt( momCal.
m_px * momCal.
m_px + momCal.
m_py * momCal.
m_py );
149 double p_traR = sqrt( momRaw.
m_px * momRaw.
m_px + momRaw.
m_py * momRaw.
m_py );
150 mantissa[0] = frexp( momCal.
m_m / momRaw.
m_m - 1, &exponent[0] );
151 mantissa[1] = frexp( angleC - angleR, &exponent[1] );
152 mantissa[2] = frexp( momCal.
eta() - momRaw.
eta(), &exponent[2] );
153 mantissa[3] = frexp( p_traC / p_traR - 1, &exponent[3] );
154
155 delta0 = momCal.
m_m / momRaw.
m_m - 1;
156 delta1 = angleC - angleR;
157 delta2 = momCal.
eta() - momRaw.
eta();
158 delta3 = p_traC / p_traR - 1;
159 }
160
161 unsigned long tmp0(0);
162 unsigned long tmp1(0);
163 unsigned long tmp2(0);
164 unsigned long tmp3(0);
165
166
167 unsigned short vec0(0);
168 unsigned short vec1(0);
169 unsigned short vec2(0);
170
171 switch(level)
172 {
174 factor = 0;
175 exponent[0] += 2;
176 if ( exponent[0] > 0x7 ) exponent[0] = 0x7;
177 if ( exponent[0] < 0x0 )
178 {
179 factor = -exponent[0];
180 exponent[0] = 0x0;
181 }
182 tmp0 =
int( fabs(mantissa[0]) * 0x10 ) >> factor;
183 tmp0 |= ( exponent[0] & 0x7 ) << 5;
184 if ( mantissa[0] < 0 ) tmp0 |= 0x10;
185
186 factor = 0;
187 exponent[1] += 5;
188 if ( exponent[1] > 0x7 ) exponent[1] = 0x7;
189 if ( exponent[1] < 0x0 )
190 {
191 factor = -exponent[1];
192 exponent[1] = 0x0;
193 }
194 tmp1 =
int( fabs(mantissa[1]) * 0x10 ) >> factor;
195 tmp1 |= ( exponent[1] & 0x7 ) << 5;
196 if ( mantissa[1] < 0 ) tmp1 |= 0x10;
197
198 factor = 0;
199 exponent[2] += 5;
200 if ( exponent[2] > 0x7 ) exponent[2] = 0x7;
201 if ( exponent[2] < 0x0 )
202 {
203 factor = -exponent[2];
204 exponent[2] = 0x0;
205 }
206 tmp2 =
int( fabs(mantissa[2]) * 0x10 ) >> factor;
207 tmp2 |= ( exponent[2] & 0x7 ) << 5;
208 if ( mantissa[2] < 0 )
tmp2 |= 0x10;
209
210 factor = 0;
211 exponent[3] += 5;
212 if ( exponent[3] > 0x7 ) exponent[3] = 0x7;
213 if ( exponent[3] < 0x0 )
214 {
215 factor = -exponent[3];
216 exponent[3] = 0x0;
217 }
218 tmp3 =
int( fabs(mantissa[3]) * 0x10 ) >> factor;
219 tmp3 |= ( exponent[3] & 0x7 ) << 5;
220 if ( mantissa[3] < 0 ) tmp3 |= 0x10;
221
222 vec0 = tmp0;
223 vec0 += tmp1 << 8;
225 vec1 += tmp3 << 8;
228 break;
229
231 factor = 0;
232 exponent[0] += 3;
233 if ( exponent[0] > 0xF ) exponent[0] = 0xF;
234 if ( exponent[0] < 0x0 )
235 {
236 factor = -exponent[0];
237 exponent[0] = 0;
238 }
239 tmp0 =
int( fabs(mantissa[0]) * 0x80 ) >> factor;
240 if ( mantissa[0] < 0 ) tmp0 |= 0x80;
241
242 factor = 0;
243 exponent[1] += 6;
244 if ( exponent[1] > 0xF ) exponent[1] = 0xF;
245 if ( exponent[1] < 0x0 )
246 {
247 factor = -exponent[1];
248 exponent[1] = 0;
249 }
250 tmp1 =
int( fabs(mantissa[1]) * 0x80 ) >> factor;
251 if ( mantissa[1] < 0 ) tmp1 |= 0x80;
252
253 factor = 0;
254 exponent[2] += 6;
255 if ( exponent[2] > 0xF ) exponent[2] = 0xF;
256 if ( exponent[2] < 0x0 )
257 {
258 factor = -exponent[2];
259 exponent[2] = 0;
260 }
261 tmp2 =
int( fabs(mantissa[2]) * 0x80 ) >> factor;
262 if ( mantissa[2] < 0 )
tmp2 |= 0x80;
263
264 factor = 0;
265 exponent[3] += 6;
266 if ( exponent[3] > 0xF ) exponent[3] = 0xF;
267 if ( exponent[3] < 0x0 )
268 {
269 factor = -exponent[3];
270 exponent[3] = 0;
271 }
272 tmp3 =
int( fabs(mantissa[3]) * 0x80 ) >> factor;
273 if ( mantissa[3] < 0 ) tmp3 |= 0x80;
274
275 vec0 = ( tmp0 & 0xFF );
276 vec0 += ( tmp1 & 0xFF ) << 8;
277 vec1 = (
tmp2 & 0xFF );
278 vec1 += ( tmp3 & 0xFF ) << 8;
280 vec2 |= exponent[1] << 4;
281 vec2 |= exponent[2] << 8;
282 vec2 |= exponent[3] << 12;
286 break;
287
289 factor = 0;
290 exponent[0] += 5;
291 if ( exponent[0] > 31 ) exponent[0] = 31;
292 if ( exponent[0] < 0 )
293 {
294 factor = -exponent[0];
295 exponent[0] = 0;
296 }
297 tmp0 =
int( fabs(mantissa[0]) * 0x400 ) >> factor;
298 tmp0 |= exponent[0] << 11;
299 if ( mantissa[0] < 0 ) tmp0 |= 0x400;
300
301 factor = 0;
302 exponent[1] += 7;
303 if ( exponent[1] > 31 ) exponent[1] = 31;
304 if ( exponent[1] < 0 )
305 {
306 factor = -exponent[1];
307 exponent[1] = 0;
308 }
309 tmp1 =
int( fabs(mantissa[1]) * 0x400 ) >> factor;
310 tmp1 |= exponent[1] << 11;
311 if ( mantissa[1] < 0 ) tmp1 |= 0x400;
312
313 factor = 0;
314 exponent[2] += 7;
315 if ( exponent[2] > 31 ) exponent[2] = 31;
316 if ( exponent[2] < 0 )
317 {
318 factor = -exponent[2];
319 exponent[2] = 0;
320 }
321 tmp2 =
int( fabs(mantissa[2]) * 0x400 ) >> factor;
322 tmp2 |= exponent[2] << 11;
323 if ( mantissa[2] < 0 )
tmp2 |= 0x400;
324
325 factor = 0;
326 exponent[3] += 7;
327 if ( exponent[3] > 31 ) exponent[3] = 31;
328 if ( exponent[3] < 0 )
329 {
330 factor = -exponent[3];
331 exponent[3] = 0;
332 }
333 tmp3 =
int( fabs(mantissa[3]) * 0x400 ) >> factor;
334 tmp3 |= exponent[3] << 11;
335 if ( mantissa[3] < 0 ) tmp3 |= 0x400;
336
341 break;
343 default:
344 union {
348
349 m.f = momRaw.
m_px;
ps.push_back(
m.s[0]);
ps.push_back(
m.s[1]);
350 m.f = momRaw.
m_py;
ps.push_back(
m.s[0]);
ps.push_back(
m.s[1]);
351 m.f = momRaw.
m_pz;
ps.push_back(
m.s[0]);
ps.push_back(
m.s[1]);
352 m.f = momRaw.
m_m;
ps.push_back(
m.s[0]);
ps.push_back(
m.s[1]);
353 msg << MSG::VERBOSE <<
" compress x : " <<
m.f <<
" = " <<
m.s[0] <<
" = " <<
m.s[1] <<
endmsg;
354 msg << MSG::VERBOSE <<
" compress y : " <<
m.f <<
" = " <<
m.s[0] <<
" = " <<
m.s[1] <<
endmsg;
355 msg << MSG::VERBOSE <<
" compress z : " <<
m.f <<
" = " <<
m.s[0] <<
" = " <<
m.s[1] <<
endmsg;
356 msg << MSG::VERBOSE <<
" compress m : " <<
m.f <<
" = " <<
m.s[0] <<
" = " <<
m.s[1] <<
endmsg;
357 break;
358 }
359 if (
msg.level() <= MSG::VERBOSE )
360 {
361 msg << MSG::VERBOSE <<
" compress # ps : " <<
ps.size() <<
" : ";
362 for ( JetConverterTypes::signalState_pers_t::const_iterator it=
ps.begin(); it !=
ps.end(); ++it )
363 msg << std::hex << *
it <<
" ";
365 msg << MSG::VERBOSE <<
" compress x : " << momRaw.
m_px <<
endmsg;
366 msg << MSG::VERBOSE <<
" compress y : " << momRaw.
m_py <<
endmsg;
367 msg << MSG::VERBOSE <<
" compress z : " << momRaw.
m_pz <<
endmsg;
368 msg << MSG::VERBOSE <<
" compress m : " << momRaw.
m_m <<
endmsg;
369
372
373 switch(level)
374 {
379 default: break;
380 };
381
382 msg << MSG::DEBUG <<
" compress M : " << delta0 <<
" = "
383 << mantissa[0] <<
" *2^ " << exponent[0]-
d0 <<
endmsg;
384 msg << MSG::DEBUG <<
" compress phi : " << delta1 <<
" = "
385 << mantissa[1] <<
" *2^ " << exponent[1]-
d1 <<
endmsg;
386 msg << MSG::DEBUG <<
" compress eta : " << delta2 <<
" = "
387 << mantissa[2] <<
" *2^ " << exponent[2]-
d1 <<
endmsg;
388 msg << MSG::DEBUG <<
" compress pT : " << delta3 <<
" = "
389 << mantissa[3] <<
" *2^ " << exponent[3]-
d1 <<
endmsg;
390 }
392 };
std::vector< D3PDTest::MyVec2 > vec2
std::vector< unsigned short > signalState_pers_t