BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
TrackPool.cxx
Go to the documentation of this file.
1#include "VertexFit/TrackPool.h"
2#include "VertexFit/GammaShape.h"
3#include "VertexFit/WTrackParameter.h"
4#include <string>
5
15 setBeamPosition( HepPoint3D( 0.0, 0.0, 0.0 ) );
16 setVBeamPosition( HepSymMatrix( 3, 0 ) );
17 m_numberone = 0;
18 m_numbertwo = 0;
19}
20
21void TrackPool::AddTrack( const int number, const double mass, const RecMdcTrack* trk ) {
22 HepVector helix( 5, 0 );
23 double error[15];
24 for ( int i = 0; i < 5; i++ ) helix[i] = trk->helix( i );
25 for ( int i = 0; i < 15; i++ ) error[i] = trk->err( i );
26 WTrackParameter wtrk( mass, helix, error );
27 setWTrackOrigin( wtrk );
28 setWTrackInfit( wtrk );
29 setWTrackList( number );
30 if ( number != numberWTrack() - 1 )
31 {
32 std::cout << "TrackPool: wrong track index"
33 << " " << number << " , " << numberWTrack() << std::endl;
34 }
35 setMapkinematic( 0 );
36 setMappositionA( m_numberone );
37 setMappositionB( m_numbertwo );
38 m_numberone = m_numberone + 4;
39}
40
41void TrackPool::AddTrack( const int number, const double mass, const RecEmcShower* trk ) {
42 //
43 // parameters: phi lambda mass energy
44 //
45 double ptrk = trk->energy();
46 double e = sqrt( ptrk * ptrk + mass * mass );
47 double the = trk->theta();
48 double phi = trk->phi();
49 HepLorentzVector p4( ptrk * sin( the ) * cos( phi ), ptrk * sin( the ) * sin( phi ),
50 ptrk * cos( the ), e );
51 double dphi = trk->dphi();
52 double dthe = trk->dtheta();
53 double de = trk->dE();
54 double x = trk->x();
55 double y = trk->y();
56 double z = trk->z();
57 HepPoint3D x3( x, y, z );
58 WTrackParameter wtrk( x3, p4, dphi, dthe, de );
59 HepSymMatrix Vpl = HepSymMatrix( 2, 0 );
60 //=== get Vclus===
61 HepSymMatrix Vclus = HepSymMatrix( 3, 0 );
62 Vclus = ( wtrk.Ew() ).sub( 5, 7 );
63 double xpr = x - m_BeamPosition[0];
64 double ypr = y - m_BeamPosition[1];
65 double zpr = z - m_BeamPosition[2];
66 double Rpr = sqrt( xpr * xpr + ypr * ypr );
67 // === get jacobi ===
68 HepMatrix J( 2, 3, 0 );
69 J[0][0] = -ypr / ( Rpr * Rpr );
70 J[0][1] = xpr / ( Rpr * Rpr );
71 J[1][0] = -xpr * zpr / ( Rpr * Rpr * Rpr );
72 J[1][1] = -ypr * zpr / ( Rpr * Rpr * Rpr );
73 J[1][2] = 1 / Rpr;
74 Vpl = Vclus.similarity( J ) + m_VBeamPosition.similarity( J );
75 Vpl[0][1] = 0;
76 // === get phipre, lambda===
77
78 double phipre = atan( ypr / xpr );
79
80 if ( xpr < 0 ) { phipre = atan( ypr / xpr ) + 3.1415926; }
81 double lambdapre = zpr / Rpr;
82
83 // === set p4 ===
84 double p0x = ptrk * cos( phipre ) / sqrt( 1 + lambdapre * lambdapre );
85 double p0y = ptrk * sin( phipre ) / sqrt( 1 + lambdapre * lambdapre );
86 double p0z = ptrk * lambdapre / sqrt( 1 + lambdapre * lambdapre );
87 double p0e = e;
88
89 double p0ver = sqrt( p0x * p0x + p0y * p0y );
90
91 HepMatrix B( 4, 3, 0 );
92 B[0][0] = -p0y;
93 B[0][1] = -p0z * p0x * p0ver / ( p0e * p0e );
94 B[0][2] = p0x / p0e;
95 B[1][0] = p0x;
96 B[1][1] = -p0z * p0y * p0ver / ( p0e * p0e );
97 B[1][2] = p0y / p0e;
98 B[2][1] = p0ver * p0ver * p0ver / ( p0e * p0e );
99 B[2][2] = p0z / p0e;
100 B[3][2] = 1;
101
102 HepSymMatrix Vple( 3, 0 );
103 Vple[0][0] = Vpl[0][0];
104 Vple[1][1] = Vpl[1][1];
105 Vple[2][2] = de * de;
106
107 HepSymMatrix Vpxyze( 4, 0 );
108 Vpxyze = Vple.similarity( B );
109
110 wtrk.setW( 0, p0x );
111 wtrk.setW( 1, p0y );
112 wtrk.setW( 2, p0z );
113 wtrk.setW( 3, p0e );
114
115 wtrk.setEw( Vpxyze );
116
117 HepSymMatrix Vplme( 4, 0 );
118 Vplme[0][0] = Vpl[0][0];
119 Vplme[1][1] = Vpl[1][1];
120 Vplme[3][3] = de * de;
121 wtrk.setVplm( Vplme );
122
123 HepVector plmp( 4, 0 );
124 plmp[0] = phipre;
125 plmp[1] = lambdapre;
126 plmp[2] = mass;
127 plmp[3] = e;
128 wtrk.setPlmp( plmp );
129
130 setWTrackOrigin( wtrk );
131 setWTrackInfit( wtrk );
132 setWTrackList( number );
133 if ( number != numberWTrack() - 1 )
134 {
135 std::cout << "TrackPool: wrong track index"
136 << " " << number << " , " << numberWTrack() << std::endl;
137 }
138 GammaShape gtrk( p4, dphi, dthe, de );
139 setGammaShape( gtrk );
140 setGammaShapeList( number );
141 setMapkinematic( 1 );
142 setMappositionA( m_numberone );
143 setMappositionB( m_numbertwo );
144 m_numberone = m_numberone + 4;
145}
146
147void TrackPool::AddMissTrack( const int number, const double mass, const RecEmcShower* trk ) {
148 //
149 // parameters: phi lambda mass ptrk
150 //
151 double ptrk = trk->energy();
152 double e = sqrt( ptrk * ptrk + mass * mass );
153 double the = trk->theta();
154 double phi = trk->phi();
155 HepLorentzVector p4( e * sin( the ) * cos( phi ), e * sin( the ) * sin( phi ),
156 e * cos( the ), e );
157 double dphi = trk->dphi();
158 double dthe = trk->dtheta();
159 double de = 1E+6;
160 double x = trk->x();
161 double y = trk->y();
162 double z = trk->z();
163
164 HepPoint3D x3( x, y, z );
165 WTrackParameter wtrk( x3, p4, dphi, dthe, de );
166 HepSymMatrix Vpe = HepSymMatrix( 2, 0 );
167 //=== get Vclus===
168 HepSymMatrix Vclus = HepSymMatrix( 3, 0 );
169 Vclus = ( wtrk.Ew() ).sub( 5, 7 );
170 double xpr = x - m_BeamPosition[0];
171 double ypr = y - m_BeamPosition[1];
172 double zpr = z - m_BeamPosition[2];
173 double Rpr = sqrt( xpr * xpr + ypr * ypr );
174 // === get jacobi ===
175 HepMatrix J( 2, 3, 0 );
176 J[0][0] = -ypr / ( Rpr * Rpr );
177 J[0][1] = xpr / ( Rpr * Rpr );
178 J[1][0] = -xpr * zpr / ( Rpr * Rpr * Rpr );
179 J[1][1] = -ypr * zpr / ( Rpr * Rpr * Rpr );
180 J[1][2] = 1 / Rpr;
181 Vpe = Vclus.similarity( J ) + m_VBeamPosition.similarity( J );
182 Vpe[0][1] = 0;
183
184 double phipre = atan( ypr / xpr );
185
186 if ( xpr < 0 ) { phipre = atan( ypr / xpr ) + 3.1415926; }
187 double lambdapre = zpr / Rpr;
188
189 HepVector plmp( 4, 0 );
190 plmp[0] = phipre;
191 plmp[1] = lambdapre;
192 plmp[2] = mass;
193 plmp[3] = ptrk;
194 wtrk.setPlmp( plmp );
195
196 HepSymMatrix Vplm( 3, 0 );
197 Vplm[0][0] = Vpe[0][0];
198 Vplm[1][1] = Vpe[1][1];
199 wtrk.setVplm( Vplm );
200
201 // === set p4 ===
202 double p0x = ptrk * cos( phipre ) / sqrt( 1 + lambdapre * lambdapre );
203 double p0y = ptrk * sin( phipre ) / sqrt( 1 + lambdapre * lambdapre );
204 double p0z = ptrk * lambdapre / sqrt( 1 + lambdapre * lambdapre );
205 double p0e = e;
206
207 wtrk.setW( 0, p0x );
208 wtrk.setW( 1, p0y );
209 wtrk.setW( 2, p0z );
210 wtrk.setW( 3, p0e );
211
212 wtrk.setType( 1 );
213 setWTrackOrigin( wtrk );
214 setWTrackInfit( wtrk );
215 setWTrackList( number );
216 GammaShape gtrk( p4, dphi, dthe, de );
217 setGammaShape( gtrk );
218 setGammaShapeList( number );
219 setMapkinematic( 5 );
220 setMappositionA( m_numberone );
221 setMappositionB( m_numbertwo );
222
223 m_numberone = m_numberone + 3;
224 m_numbertwo = m_numbertwo + 1;
225}
226
227void TrackPool::AddMissTrack( const int number, const RecEmcShower* trk ) {
228 //
229 // parameters: phi lambda mass E
230 //
231
232 double mass = 0;
233 double ptrk = trk->energy();
234 double e = sqrt( ptrk * ptrk + mass * mass );
235 double the = trk->theta();
236 double phi = trk->phi();
237 HepLorentzVector p4( e * sin( the ) * cos( phi ), e * sin( the ) * sin( phi ),
238 e * cos( the ), e );
239 double dphi = trk->dphi();
240 double dthe = trk->dtheta();
241 double de = 1E+6;
242 double x = trk->x();
243 double y = trk->y();
244 double z = trk->z();
245
246 HepPoint3D x3( x, y, z );
247 WTrackParameter wtrk( x3, p4, dphi, dthe, de );
248 HepSymMatrix Vpe = HepSymMatrix( 2, 0 );
249 //=== get Vclus===
250 HepSymMatrix Vclus = HepSymMatrix( 3, 0 );
251 Vclus = ( wtrk.Ew() ).sub( 5, 7 );
252 double xpr = x - m_BeamPosition[0];
253 double ypr = y - m_BeamPosition[1];
254 double zpr = z - m_BeamPosition[2];
255 double Rpr = sqrt( xpr * xpr + ypr * ypr );
256 // === get jacobi ===
257 HepMatrix J( 2, 3, 0 );
258 J[0][0] = -ypr / ( Rpr * Rpr );
259 J[0][1] = xpr / ( Rpr * Rpr );
260 J[1][0] = -xpr * zpr / ( Rpr * Rpr * Rpr );
261 J[1][1] = -ypr * zpr / ( Rpr * Rpr * Rpr );
262 J[1][2] = 1 / Rpr;
263 Vpe = Vclus.similarity( J ) + m_VBeamPosition.similarity( J );
264 Vpe[0][1] = 0;
265 double phipre = atan( ypr / xpr );
266
267 if ( xpr < 0 ) { phipre = atan( ypr / xpr ) + 3.1415926; }
268 double lambdapre = zpr / Rpr;
269
270 HepVector plmp( 4, 0 );
271 plmp[0] = phipre;
272 plmp[1] = lambdapre;
273 plmp[2] = mass;
274 plmp[3] = e;
275 wtrk.setPlmp( plmp );
276
277 HepSymMatrix Vplm( 2, 0 );
278 Vplm[0][0] = Vpe[0][0];
279 Vplm[1][1] = Vpe[1][1];
280 wtrk.setVplm( Vplm );
281
282 // === set p4 ===
283 double p0x = ptrk * cos( phipre ) / sqrt( 1 + lambdapre * lambdapre );
284 double p0y = ptrk * sin( phipre ) / sqrt( 1 + lambdapre * lambdapre );
285 double p0z = ptrk * lambdapre / sqrt( 1 + lambdapre * lambdapre );
286 double p0e = e;
287
288 wtrk.setW( 0, p0x );
289 wtrk.setW( 1, p0y );
290 wtrk.setW( 2, p0z );
291 wtrk.setW( 3, p0e );
292
293 wtrk.setType( 1 );
294 setWTrackOrigin( wtrk );
295 setWTrackInfit( wtrk );
296 setWTrackList( number );
297 GammaShape gtrk( p4, dphi, dthe, de );
298 setGammaShape( gtrk );
299 setGammaShapeList( number );
300 setMapkinematic( 4 );
301 setMappositionA( m_numberone );
302 setMappositionB( m_numbertwo );
303
304 m_numberone = m_numberone + 2;
305 m_numbertwo = m_numbertwo + 2;
306}
307
308void TrackPool::AddMissTrack( const int number, const double mass,
309 const HepLorentzVector p4 ) {
310 //
311 // parameters: mass px py pz
312 //
313
314 double dphi = 1E+6;
315 double dthe = 1E+6;
316 double dE = 1E+6;
317 WTrackParameter wtrk( p4, dphi, dthe, dE );
318 HepVector plmp( 4, 0 );
319 double phipre = atan( p4[1] / p4[0] );
320
321 if ( p4[0] < 0 ) { phipre = atan( p4[1] / p4[0] ) + 3.1415926; }
322 plmp[0] = phipre;
323 plmp[1] = wtrk.Lambda();
324 plmp[2] = mass;
325 plmp[3] = p4[3];
326 HepSymMatrix Vplm( 3, 0 );
327 wtrk.setPlmp( plmp );
328 wtrk.setVplm( Vplm );
329 wtrk.setType( 1 );
330 setWTrackOrigin( wtrk );
331 setWTrackInfit( wtrk );
332 setWTrackList( number );
333 setMapkinematic( 3 );
334 setMappositionA( m_numberone );
335 setMappositionB( m_numbertwo );
336 m_numberone = m_numberone + 1;
337 m_numbertwo = m_numbertwo + 3;
338}
339
340void TrackPool::AddMissTrack( const int number, const double mass ) {
341 //
342 // parameters: mass px py pz, but px,py,pz 's error matrix is set as 10e^6
343 //
344 WTrackParameter wtrk;
345 wtrk.setMass( mass );
346 HepVector w( 7, 0 );
347 HepSymMatrix Ew( 7, 0 );
348 w[0] = 0.2;
349 w[1] = 0.2;
350 w[2] = 0.2;
351 w[3] = sqrt( 0.2 * 0.2 * 3 + mass * mass );
352 Ew[0][0] = 1E+6;
353 Ew[1][1] = 1E+6;
354 Ew[2][2] = 1E+6;
355 wtrk.setW( w );
356 wtrk.setEw( Ew );
357 setWTrackOrigin( wtrk );
358 setWTrackInfit( wtrk );
359 setWTrackList( number );
360 setMapkinematic( 7 );
361 setMappositionA( m_numberone );
362 setMappositionB( m_numbertwo );
363 m_numberone = m_numberone + 4;
364}
365
366void TrackPool::AddMissTrack( const int number, HepLorentzVector p4 ) {
367 double dphi = 1E+3;
368 double dthe = 1E+3;
369 double dE = 1E+3;
370 WTrackParameter wtrk( p4, dphi, dthe, dE );
371 HepSymMatrix Ew = HepSymMatrix( 7, 0 );
372 for ( int i = 0; i < 7; i++ )
373 {
374 for ( int j = 0; j < 7; j++ )
375 {
376 if ( i == j ) Ew[i][j] = 1E+6;
377 }
378 }
379 wtrk.setType( 1 );
380 wtrk.setEw( Ew );
381 setWTrackOrigin( wtrk );
382 setWTrackInfit( wtrk );
383 setWTrackList( number );
384 setMapkinematic( 2 );
385 setMappositionA( m_numberone );
386 setMappositionB( m_numbertwo );
387 m_numbertwo = m_numbertwo + 4;
388}
389
390void TrackPool::AddTrack( const int number, WTrackParameter wtrk ) {
391 setWTrackOrigin( wtrk );
392 setWTrackInfit( wtrk );
393 setWTrackList( number );
394 if ( number != numberWTrack() - 1 )
395 {
396 std::cout << "TrackPool: wrong track index"
397 << " " << number << " , " << numberWTrack() << std::endl;
398 }
399 setMapkinematic( 0 );
400 setMappositionA( m_numberone );
401 setMappositionB( m_numbertwo );
402 m_numberone = m_numberone + 4;
403}
404
405void TrackPool::AddTrackVertex( const int number, const double mass,
406 const RecEmcShower* trk ) {
407 double ptrk = trk->energy();
408 double e = sqrt( ptrk * ptrk + mass * mass );
409 double the = trk->theta();
410 double phi = trk->phi();
411 HepLorentzVector p4( ptrk * sin( the ) * cos( phi ), ptrk * sin( the ) * sin( phi ),
412 ptrk * cos( the ), e );
413 double dphi = trk->dphi();
414 double dthe = trk->dtheta();
415 double de = trk->dE();
416 double x = trk->x();
417 double y = trk->y();
418 double z = trk->z();
419 HepPoint3D x3( x, y, z );
420 WTrackParameter wtrk( x3, p4, dphi, dthe, de );
421 setWTrackOrigin( wtrk );
422 setWTrackInfit( wtrk );
423 setWTrackList( number );
424 if ( number != numberWTrack() - 1 )
425 {
426 std::cout << "TrackPool: wrong track index"
427 << " " << number << " , " << numberWTrack() << std::endl;
428 }
429 GammaShape gtrk( p4, dphi, dthe, de );
430 setGammaShape( gtrk );
431 setGammaShapeList( number );
432 setMapkinematic( 6 );
433 m_numbertwo = 0;
434 setMappositionA( m_numberone );
435 setMappositionB( m_numbertwo );
436
437 m_numberone = m_numberone + 4;
438 m_numbertwo = m_numbertwo + 3;
439}
440
441std::vector<int> TrackPool::AddList( int n1 ) {
442 std::vector<int> lis;
443 lis.clear();
444 lis.push_back( n1 );
445 return lis;
446}
447
448std::vector<int> TrackPool::AddList( int n1, int n2 ) {
449 std::vector<int> lis;
450 lis.clear();
451 lis.push_back( n1 );
452 lis.push_back( n2 );
453 return lis;
454}
455
456std::vector<int> TrackPool::AddList( int n1, int n2, int n3 ) {
457 std::vector<int> lis;
458 lis.clear();
459 lis.push_back( n1 );
460 lis.push_back( n2 );
461 lis.push_back( n3 );
462 return lis;
463}
464
465std::vector<int> TrackPool::AddList( int n1, int n2, int n3, int n4 ) {
466 std::vector<int> lis;
467 lis.clear();
468 lis.push_back( n1 );
469 lis.push_back( n2 );
470 lis.push_back( n3 );
471 lis.push_back( n4 );
472 return lis;
473}
474
475std::vector<int> TrackPool::AddList( int n1, int n2, int n3, int n4, int n5 ) {
476 std::vector<int> lis;
477 lis.clear();
478 lis.push_back( n1 );
479 lis.push_back( n2 );
480 lis.push_back( n3 );
481 lis.push_back( n4 );
482 lis.push_back( n5 );
483 return lis;
484}
485
486std::vector<int> TrackPool::AddList( int n1, int n2, int n3, int n4, int n5, int n6 ) {
487 std::vector<int> lis;
488 lis.clear();
489 lis.push_back( n1 );
490 lis.push_back( n2 );
491 lis.push_back( n3 );
492 lis.push_back( n4 );
493 lis.push_back( n5 );
494 lis.push_back( n6 );
495 return lis;
496}
497
498std::vector<int> TrackPool::AddList( int n1, int n2, int n3, int n4, int n5, int n6, int n7 ) {
499 std::vector<int> lis;
500 lis.clear();
501 lis.push_back( n1 );
502 lis.push_back( n2 );
503 lis.push_back( n3 );
504 lis.push_back( n4 );
505 lis.push_back( n5 );
506 lis.push_back( n6 );
507 lis.push_back( n7 );
508 return lis;
509}
510
511std::vector<int> TrackPool::AddList( int n1, int n2, int n3, int n4, int n5, int n6, int n7,
512 int n8 ) {
513 std::vector<int> lis;
514 lis.clear();
515 lis.push_back( n1 );
516 lis.push_back( n2 );
517 lis.push_back( n3 );
518 lis.push_back( n4 );
519 lis.push_back( n5 );
520 lis.push_back( n6 );
521 lis.push_back( n7 );
522 lis.push_back( n8 );
523 return lis;
524}
525
526std::vector<int> TrackPool::AddList( int n1, int n2, int n3, int n4, int n5, int n6, int n7,
527 int n8, int n9 ) {
528 std::vector<int> lis;
529 lis.clear();
530 lis.push_back( n1 );
531 lis.push_back( n2 );
532 lis.push_back( n3 );
533 lis.push_back( n4 );
534 lis.push_back( n5 );
535 lis.push_back( n6 );
536 lis.push_back( n7 );
537 lis.push_back( n8 );
538 lis.push_back( n9 );
539 return lis;
540}
541
542std::vector<int> TrackPool::AddList( int n1, int n2, int n3, int n4, int n5, int n6, int n7,
543 int n8, int n9, int n10 ) {
544 std::vector<int> lis;
545 lis.clear();
546 lis.push_back( n1 );
547 lis.push_back( n2 );
548 lis.push_back( n3 );
549 lis.push_back( n4 );
550 lis.push_back( n5 );
551 lis.push_back( n6 );
552 lis.push_back( n7 );
553 lis.push_back( n8 );
554 lis.push_back( n9 );
555 lis.push_back( n10 );
556 return lis;
557}
558
559std::vector<int> TrackPool::AddList( int n1, int n2, int n3, int n4, int n5, int n6, int n7,
560 int n8, int n9, int n10, int n11 ) {
561 std::vector<int> lis;
562 lis.clear();
563 lis.push_back( n1 );
564 lis.push_back( n2 );
565 lis.push_back( n3 );
566 lis.push_back( n4 );
567 lis.push_back( n5 );
568 lis.push_back( n6 );
569 lis.push_back( n7 );
570 lis.push_back( n8 );
571 lis.push_back( n9 );
572 lis.push_back( n10 );
573 lis.push_back( n11 );
574 return lis;
575}
576
577std::vector<int> TrackPool::AddList( int n1, int n2, int n3, int n4, int n5, int n6, int n7,
578 int n8, int n9, int n10, int n11, int n12 ) {
579 std::vector<int> lis;
580 lis.clear();
581 lis.push_back( n1 );
582 lis.push_back( n2 );
583 lis.push_back( n3 );
584 lis.push_back( n4 );
585 lis.push_back( n5 );
586 lis.push_back( n6 );
587 lis.push_back( n7 );
588 lis.push_back( n8 );
589 lis.push_back( n9 );
590 lis.push_back( n10 );
591 lis.push_back( n11 );
592 lis.push_back( n12 );
593 return lis;
594}
double mass
HepGeom::Point3D< double > HepPoint3D
double w
int n2
Definition SD0Tag.cxx:59
int n1
Definition SD0Tag.cxx:58
const HepSymMatrix err() const
const HepVector helix() const
......
std::vector< int > AddList(int n1)
void setVBeamPosition(const HepSymMatrix VBeamPosition)
void AddTrack(const int number, const double mass, const RecMdcTrack *trk)
Definition TrackPool.cxx:21
void AddTrackVertex(const int number, const double mass, const RecEmcShower *trk)
void AddMissTrack(const int number, const double mass)
void setGammaShape(const int n, const GammaShape gammashape)
void setBeamPosition(const HepPoint3D BeamPosition)
void setWTrackOrigin(const int n, const WTrackParameter wtrk)
void setWTrackInfit(const int n, const WTrackParameter wtrk)