00001 #include "VertexFit/TrackPool.h"
00002 #include "VertexFit/WTrackParameter.h"
00003 #include "VertexFit/GammaShape.h"
00004 #include <string>
00005
00006 TrackPool::TrackPool() {
00007 clearWTrackOrigin();
00008 clearWTrackInfit();
00009 clearWTrackList();
00010 clearGammaShape();
00011 clearGammaShapeList();
00012 clearMapkinematic();
00013 clearMappositionA();
00014 clearMappositionB();
00015 setBeamPosition(HepPoint3D(0.0,0.0,0.0));
00016 setVBeamPosition(HepSymMatrix(3,0));
00017 m_numberone = 0;
00018 m_numbertwo = 0;
00019 }
00020
00021
00022 void TrackPool::AddTrack(const int number, const double mass,
00023 const RecMdcTrack *trk) {
00024 HepVector helix(5,0);
00025 double error[15];
00026 for(int i = 0; i < 5; i++)
00027 helix[i] = trk->helix(i);
00028 for(int i = 0; i < 15; i++)
00029 error[i] = trk->err(i);
00030 WTrackParameter wtrk(mass, helix, error);
00031 setWTrackOrigin(wtrk);
00032 setWTrackInfit(wtrk);
00033 setWTrackList(number);
00034 if(number != numberWTrack()-1) {
00035 std::cout << "TrackPool: wrong track index" <<" "
00036 <<number<<" , " <<numberWTrack()<< std::endl;
00037 }
00038 setMapkinematic(0);
00039 setMappositionA(m_numberone);
00040 setMappositionB(m_numbertwo);
00041 m_numberone = m_numberone + 4;
00042 }
00043
00044 void TrackPool::AddTrack(const int number, const double mass,
00045 const RecEmcShower *trk) {
00046
00047
00048
00049 double ptrk = trk->energy();
00050 double e = sqrt(ptrk*ptrk + mass * mass);
00051 double the = trk->theta();
00052 double phi = trk->phi();
00053 HepLorentzVector p4(ptrk * sin(the) * cos(phi),
00054 ptrk * sin(the) * sin(phi),
00055 ptrk * cos(the),
00056 e);
00057 double dphi = trk->dphi();
00058 double dthe = trk->dtheta();
00059 double de = trk->dE();
00060 double x = trk->x();
00061 double y = trk->y();
00062 double z = trk->z();
00063 HepPoint3D x3 (x, y ,z);
00064 WTrackParameter wtrk(x3, p4 ,dphi ,dthe, de);
00065 HepSymMatrix Vpl = HepSymMatrix(2,0);
00066
00067 HepSymMatrix Vclus = HepSymMatrix (3,0);
00068 Vclus = (wtrk.Ew()).sub(5,7);
00069 double xpr = x - m_BeamPosition[0];
00070 double ypr = y - m_BeamPosition[1];
00071 double zpr = z - m_BeamPosition[2];
00072 double Rpr = sqrt(xpr*xpr + ypr*ypr);
00073
00074 HepMatrix J(2,3,0);
00075 J[0][0] = -ypr/(Rpr*Rpr);
00076 J[0][1] = xpr/(Rpr*Rpr);
00077 J[1][0] = -xpr * zpr/(Rpr*Rpr*Rpr);
00078 J[1][1] = -ypr * zpr/(Rpr*Rpr*Rpr);
00079 J[1][2] = 1/Rpr;
00080 Vpl = Vclus.similarity(J) + m_VBeamPosition.similarity(J);
00081 Vpl[0][1]=0;
00082
00083
00084 double phipre = atan(ypr/xpr);
00085
00086 if(xpr<0){
00087 phipre = atan(ypr/xpr) + 3.1415926;
00088 }
00089 double lambdapre = zpr/Rpr;
00090
00091
00092
00093 double p0x = ptrk*cos(phipre)/sqrt(1 + lambdapre*lambdapre);
00094 double p0y = ptrk*sin(phipre)/sqrt(1 + lambdapre*lambdapre);
00095 double p0z = ptrk*lambdapre/sqrt(1 + lambdapre*lambdapre);
00096 double p0e = e;
00097
00098
00099 double p0ver = sqrt(p0x*p0x + p0y*p0y);
00100
00101
00102 HepMatrix B(4,3,0);
00103 B[0][0] = -p0y;
00104 B[0][1] = -p0z * p0x * p0ver/(p0e * p0e);
00105 B[0][2] = p0x/p0e;
00106 B[1][0] = p0x;
00107 B[1][1] = -p0z * p0y * p0ver/(p0e * p0e);
00108 B[1][2] = p0y/p0e;
00109 B[2][1] = p0ver * p0ver * p0ver/(p0e * p0e);
00110 B[2][2] = p0z/p0e;
00111 B[3][2] = 1;
00112
00113 HepSymMatrix Vple(3,0);
00114 Vple[0][0] = Vpl[0][0];
00115 Vple[1][1] = Vpl[1][1];
00116 Vple[2][2] = de * de;
00117
00118 HepSymMatrix Vpxyze(4,0);
00119 Vpxyze = Vple.similarity(B);
00120
00121 wtrk.setW(0,p0x);
00122 wtrk.setW(1,p0y);
00123 wtrk.setW(2,p0z);
00124 wtrk.setW(3,p0e);
00125
00126 wtrk.setEw(Vpxyze);
00127
00128 HepSymMatrix Vplme(4,0);
00129 Vplme[0][0] = Vpl[0][0];
00130 Vplme[1][1] = Vpl[1][1];
00131 Vplme[3][3] = de * de;
00132 wtrk.setVplm(Vplme);
00133
00134 HepVector plmp(4 , 0);
00135 plmp[0] = phipre;
00136 plmp[1] = lambdapre;
00137 plmp[2] = mass;
00138 plmp[3] = e;
00139 wtrk.setPlmp(plmp);
00140
00141
00142 setWTrackOrigin(wtrk);
00143 setWTrackInfit(wtrk);
00144 setWTrackList(number);
00145 if(number != numberWTrack()-1) {
00146 std::cout << "TrackPool: wrong track index" <<" "
00147 <<number<<" , " <<numberWTrack()<< std::endl;
00148 }
00149 GammaShape gtrk(p4,dphi,dthe,de);
00150 setGammaShape(gtrk);
00151 setGammaShapeList(number);
00152 setMapkinematic(1);
00153 setMappositionA(m_numberone);
00154 setMappositionB(m_numbertwo);
00155 m_numberone = m_numberone + 4;
00156 }
00157
00158
00159 void TrackPool::AddMissTrack(const int number, const double mass,
00160 const RecEmcShower *trk) {
00161
00162
00163
00164 double ptrk = trk->energy();
00165 double e = sqrt(ptrk*ptrk + mass * mass);
00166 double the = trk->theta();
00167 double phi = trk->phi();
00168 HepLorentzVector p4( e* sin(the) * cos(phi),
00169 e * sin(the) * sin(phi),
00170 e * cos(the),
00171 e);
00172 double dphi = trk->dphi();
00173 double dthe = trk->dtheta();
00174 double de = 1E+6;
00175 double x = trk->x();
00176 double y = trk->y();
00177 double z = trk->z();
00178
00179 HepPoint3D x3 (x, y ,z);
00180 WTrackParameter wtrk(x3, p4 ,dphi ,dthe, de);
00181 HepSymMatrix Vpe = HepSymMatrix(2,0);
00182
00183 HepSymMatrix Vclus = HepSymMatrix (3,0);
00184 Vclus = (wtrk.Ew()).sub(5,7);
00185 double xpr = x - m_BeamPosition[0];
00186 double ypr = y - m_BeamPosition[1];
00187 double zpr = z - m_BeamPosition[2];
00188 double Rpr = sqrt(xpr*xpr + ypr*ypr);
00189
00190 HepMatrix J(2,3,0);
00191 J[0][0] = -ypr/(Rpr*Rpr);
00192 J[0][1] = xpr/(Rpr*Rpr);
00193 J[1][0] = -xpr * zpr/(Rpr*Rpr*Rpr);
00194 J[1][1] = -ypr * zpr/(Rpr*Rpr*Rpr);
00195 J[1][2] = 1/Rpr;
00196 Vpe = Vclus.similarity(J) + m_VBeamPosition.similarity(J);
00197 Vpe[0][1]=0;
00198
00199 double phipre = atan(ypr/xpr);
00200
00201 if(xpr<0){
00202 phipre = atan(ypr/xpr) + 3.1415926;
00203 }
00204 double lambdapre = zpr/Rpr;
00205
00206
00207 HepVector plmp(4 , 0);
00208 plmp[0] = phipre;
00209 plmp[1] = lambdapre;
00210 plmp[2] = mass;
00211 plmp[3] = ptrk;
00212 wtrk.setPlmp(plmp);
00213
00214 HepSymMatrix Vplm(3,0);
00215 Vplm[0][0] = Vpe[0][0];
00216 Vplm[1][1] = Vpe[1][1];
00217 wtrk.setVplm(Vplm);
00218
00219
00220
00221
00222 double p0x = ptrk*cos(phipre)/sqrt(1 + lambdapre*lambdapre);
00223 double p0y = ptrk*sin(phipre)/sqrt(1 + lambdapre*lambdapre);
00224 double p0z = ptrk*lambdapre/sqrt(1 + lambdapre*lambdapre);
00225 double p0e = e;
00226
00227 wtrk.setW(0,p0x);
00228 wtrk.setW(1,p0y);
00229 wtrk.setW(2,p0z);
00230 wtrk.setW(3,p0e);
00231
00232 wtrk.setType(1);
00233 setWTrackOrigin(wtrk);
00234 setWTrackInfit(wtrk);
00235 setWTrackList(number);
00236 GammaShape gtrk(p4,dphi,dthe,de);
00237 setGammaShape(gtrk);
00238 setGammaShapeList(number);
00239 setMapkinematic(5);
00240 setMappositionA(m_numberone);
00241 setMappositionB(m_numbertwo);
00242
00243 m_numberone = m_numberone + 3;
00244 m_numbertwo = m_numbertwo + 1;
00245 }
00246
00247
00248
00249
00250 void TrackPool::AddMissTrack(const int number, const RecEmcShower *trk) {
00251
00252
00253
00254
00255 double mass = 0;
00256 double ptrk = trk->energy();
00257 double e = sqrt(ptrk*ptrk + mass * mass);
00258 double the = trk->theta();
00259 double phi = trk->phi();
00260 HepLorentzVector p4( e* sin(the) * cos(phi),
00261 e * sin(the) * sin(phi),
00262 e * cos(the),
00263 e);
00264 double dphi = trk->dphi();
00265 double dthe = trk->dtheta();
00266 double de = 1E+6;
00267 double x = trk->x();
00268 double y = trk->y();
00269 double z = trk->z();
00270
00271 HepPoint3D x3 (x, y ,z);
00272 WTrackParameter wtrk(x3, p4 ,dphi ,dthe, de);
00273 HepSymMatrix Vpe = HepSymMatrix(2,0);
00274
00275 HepSymMatrix Vclus = HepSymMatrix (3,0);
00276 Vclus = (wtrk.Ew()).sub(5,7);
00277 double xpr = x - m_BeamPosition[0];
00278 double ypr = y - m_BeamPosition[1];
00279 double zpr = z - m_BeamPosition[2];
00280 double Rpr = sqrt(xpr*xpr + ypr*ypr);
00281
00282 HepMatrix J(2,3,0);
00283 J[0][0] = -ypr/(Rpr*Rpr);
00284 J[0][1] = xpr/(Rpr*Rpr);
00285 J[1][0] = -xpr * zpr/(Rpr*Rpr*Rpr);
00286 J[1][1] = -ypr * zpr/(Rpr*Rpr*Rpr);
00287 J[1][2] = 1/Rpr;
00288 Vpe = Vclus.similarity(J) + m_VBeamPosition.similarity(J);
00289 Vpe[0][1]=0;
00290 double phipre = atan(ypr/xpr);
00291
00292 if(xpr<0){
00293 phipre = atan(ypr/xpr) + 3.1415926;
00294 }
00295 double lambdapre = zpr/Rpr;
00296
00297
00298 HepVector plmp(4 , 0);
00299 plmp[0] = phipre;
00300 plmp[1] = lambdapre;
00301 plmp[2] = mass;
00302 plmp[3] = e;
00303 wtrk.setPlmp(plmp);
00304
00305 HepSymMatrix Vplm(2,0);
00306 Vplm[0][0] = Vpe[0][0];
00307 Vplm[1][1] = Vpe[1][1];
00308 wtrk.setVplm(Vplm);
00309
00310
00311
00312
00313 double p0x = ptrk*cos(phipre)/sqrt(1 + lambdapre*lambdapre);
00314 double p0y = ptrk*sin(phipre)/sqrt(1 + lambdapre*lambdapre);
00315 double p0z = ptrk*lambdapre/sqrt(1 + lambdapre*lambdapre);
00316 double p0e = e;
00317
00318 wtrk.setW(0,p0x);
00319 wtrk.setW(1,p0y);
00320 wtrk.setW(2,p0z);
00321 wtrk.setW(3,p0e);
00322
00323 wtrk.setType(1);
00324 setWTrackOrigin(wtrk);
00325 setWTrackInfit(wtrk);
00326 setWTrackList(number);
00327 GammaShape gtrk(p4,dphi,dthe,de);
00328 setGammaShape(gtrk);
00329 setGammaShapeList(number);
00330 setMapkinematic(4);
00331 setMappositionA(m_numberone);
00332 setMappositionB(m_numbertwo);
00333
00334 m_numberone = m_numberone + 2;
00335 m_numbertwo = m_numbertwo + 2;
00336 }
00337
00338
00339
00340
00341 void TrackPool::AddMissTrack(const int number, const double mass, const HepLorentzVector p4) {
00342
00343
00344
00345
00346 double dphi = 1E+6;
00347 double dthe = 1E+6;
00348 double dE = 1E+6;
00349 WTrackParameter wtrk(p4, dphi, dthe, dE);
00350 HepVector plmp(4, 0);
00351 double phipre = atan(p4[1]/p4[0]);
00352
00353 if(p4[0]<0){
00354 phipre = atan(p4[1]/p4[0]) + 3.1415926;
00355 }
00356 plmp[0] = phipre;
00357 plmp[1] = wtrk.Lambda();
00358 plmp[2] = mass;
00359 plmp[3] = p4[3];
00360 HepSymMatrix Vplm(3, 0);
00361 wtrk.setPlmp(plmp);
00362 wtrk.setVplm(Vplm);
00363 wtrk.setType(1);
00364 setWTrackOrigin(wtrk);
00365 setWTrackInfit(wtrk);
00366 setWTrackList(number);
00367 setMapkinematic(3);
00368 setMappositionA(m_numberone);
00369 setMappositionB(m_numbertwo);
00370 m_numberone = m_numberone + 1;
00371 m_numbertwo = m_numbertwo + 3;
00372 }
00373
00374
00375 void TrackPool::AddMissTrack(const int number, const double mass) {
00376
00377
00378
00379 WTrackParameter wtrk;
00380 wtrk.setMass(mass);
00381 HepVector w(7,0);
00382 HepSymMatrix Ew(7,0);
00383 w[0] = 0.2;
00384 w[1] = 0.2;
00385 w[2] = 0.2;
00386 w[3] = sqrt(0.2*0.2*3 + mass*mass);
00387 Ew[0][0] = 1E+6;
00388 Ew[1][1] = 1E+6;
00389 Ew[2][2] = 1E+6;
00390 wtrk.setW(w);
00391 wtrk.setEw(Ew);
00392 setWTrackOrigin(wtrk);
00393 setWTrackInfit(wtrk);
00394 setWTrackList(number);
00395 setMapkinematic(7);
00396 setMappositionA(m_numberone);
00397 setMappositionB(m_numbertwo);
00398 m_numberone = m_numberone + 4;
00399
00400 }
00401
00402
00403 void TrackPool::AddMissTrack(const int number, HepLorentzVector p4) {
00404 double dphi = 1E+3;
00405 double dthe = 1E+3;
00406 double dE = 1E+3;
00407 WTrackParameter wtrk(p4, dphi, dthe, dE);
00408 HepSymMatrix Ew = HepSymMatrix(7,0);
00409 for (int i = 0; i < 7; i++) {
00410 for (int j = 0; j < 7; j++) {
00411 if(i==j) Ew[i][j] = 1E+6;
00412 }
00413 }
00414 wtrk.setType(1);
00415 wtrk.setEw(Ew);
00416 setWTrackOrigin(wtrk);
00417 setWTrackInfit(wtrk);
00418 setWTrackList(number);
00419 setMapkinematic(2);
00420 setMappositionA(m_numberone);
00421 setMappositionB(m_numbertwo);
00422 m_numbertwo = m_numbertwo + 4;
00423 }
00424
00425
00426
00427
00428
00429 void TrackPool::AddTrack(const int number, WTrackParameter wtrk) {
00430 setWTrackOrigin(wtrk);
00431 setWTrackInfit(wtrk);
00432 setWTrackList(number);
00433 if(number != numberWTrack()-1) {
00434 std::cout << "TrackPool: wrong track index" <<" "
00435 <<number<<" , " <<numberWTrack()<< std::endl;
00436 }
00437 setMapkinematic(0);
00438 setMappositionA(m_numberone);
00439 setMappositionB(m_numbertwo);
00440 m_numberone = m_numberone + 4;
00441 }
00442
00443
00444 void TrackPool::AddTrackVertex(const int number, const double mass, const RecEmcShower *trk) {
00445 double ptrk = trk->energy();
00446 double e = sqrt(ptrk*ptrk + mass * mass);
00447 double the = trk->theta();
00448 double phi = trk->phi();
00449 HepLorentzVector p4(ptrk * sin(the) * cos(phi),
00450 ptrk * sin(the) * sin(phi),
00451 ptrk * cos(the),
00452 e);
00453 double dphi = trk->dphi();
00454 double dthe = trk->dtheta();
00455 double de = trk->dE();
00456 double x = trk->x();
00457 double y = trk->y();
00458 double z = trk->z();
00459 HepPoint3D x3 (x, y ,z);
00460 WTrackParameter wtrk(x3, p4 ,dphi ,dthe, de);
00461 setWTrackOrigin(wtrk);
00462 setWTrackInfit(wtrk);
00463 setWTrackList(number);
00464 if(number != numberWTrack()-1) {
00465 std::cout << "TrackPool: wrong track index" <<" "
00466 <<number<<" , " <<numberWTrack()<< std::endl;
00467 }
00468 GammaShape gtrk(p4,dphi,dthe,de);
00469 setGammaShape(gtrk);
00470 setGammaShapeList(number);
00471 setMapkinematic(6);
00472 m_numbertwo = 0;
00473 setMappositionA(m_numberone);
00474 setMappositionB(m_numbertwo);
00475
00476 m_numberone = m_numberone + 4;
00477 m_numbertwo = m_numbertwo + 3;
00478 }
00479
00480
00481
00482
00483 std::vector<int> TrackPool::AddList(int n1) {
00484 std::vector<int> lis;
00485 lis.clear();
00486 lis.push_back(n1);
00487 return lis;
00488 }
00489
00490 std::vector<int> TrackPool::AddList(int n1, int n2) {
00491 std::vector<int> lis;
00492 lis.clear();
00493 lis.push_back(n1);
00494 lis.push_back(n2);
00495 return lis;
00496 }
00497
00498 std::vector<int> TrackPool::AddList(int n1, int n2, int n3) {
00499 std::vector<int> lis;
00500 lis.clear();
00501 lis.push_back(n1);
00502 lis.push_back(n2);
00503 lis.push_back(n3);
00504 return lis;
00505 }
00506
00507 std::vector<int> TrackPool::AddList(int n1, int n2, int n3, int n4) {
00508 std::vector<int> lis;
00509 lis.clear();
00510 lis.push_back(n1);
00511 lis.push_back(n2);
00512 lis.push_back(n3);
00513 lis.push_back(n4);
00514 return lis;
00515 }
00516
00517 std::vector<int> TrackPool::AddList(int n1, int n2, int n3, int n4, int n5) {
00518 std::vector<int> lis;
00519 lis.clear();
00520 lis.push_back(n1);
00521 lis.push_back(n2);
00522 lis.push_back(n3);
00523 lis.push_back(n4);
00524 lis.push_back(n5);
00525 return lis;
00526 }
00527
00528 std::vector<int> TrackPool::AddList(int n1, int n2, int n3, int n4, int n5, int n6) {
00529 std::vector<int> lis;
00530 lis.clear();
00531 lis.push_back(n1);
00532 lis.push_back(n2);
00533 lis.push_back(n3);
00534 lis.push_back(n4);
00535 lis.push_back(n5);
00536 lis.push_back(n6);
00537 return lis;
00538 }
00539
00540 std::vector<int> TrackPool::AddList(int n1, int n2, int n3, int n4, int n5, int n6, int n7) {
00541 std::vector<int> lis;
00542 lis.clear();
00543 lis.push_back(n1);
00544 lis.push_back(n2);
00545 lis.push_back(n3);
00546 lis.push_back(n4);
00547 lis.push_back(n5);
00548 lis.push_back(n6);
00549 lis.push_back(n7);
00550 return lis;
00551 }
00552
00553 std::vector<int> TrackPool::AddList(int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8) {
00554 std::vector<int> lis;
00555 lis.clear();
00556 lis.push_back(n1);
00557 lis.push_back(n2);
00558 lis.push_back(n3);
00559 lis.push_back(n4);
00560 lis.push_back(n5);
00561 lis.push_back(n6);
00562 lis.push_back(n7);
00563 lis.push_back(n8);
00564 return lis;
00565 }
00566
00567 std::vector<int> TrackPool::AddList(int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8,
00568 int n9) {
00569 std::vector<int> lis;
00570 lis.clear();
00571 lis.push_back(n1);
00572 lis.push_back(n2);
00573 lis.push_back(n3);
00574 lis.push_back(n4);
00575 lis.push_back(n5);
00576 lis.push_back(n6);
00577 lis.push_back(n7);
00578 lis.push_back(n8);
00579 lis.push_back(n9);
00580 return lis;
00581 }
00582
00583 std::vector<int> TrackPool::AddList(int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8,
00584 int n9, int n10) {
00585 std::vector<int> lis;
00586 lis.clear();
00587 lis.push_back(n1);
00588 lis.push_back(n2);
00589 lis.push_back(n3);
00590 lis.push_back(n4);
00591 lis.push_back(n5);
00592 lis.push_back(n6);
00593 lis.push_back(n7);
00594 lis.push_back(n8);
00595 lis.push_back(n9);
00596 lis.push_back(n10);
00597 return lis;
00598 }
00599
00600 std::vector<int> TrackPool::AddList(int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8,
00601 int n9, int n10, int n11) {
00602 std::vector<int> lis;
00603 lis.clear();
00604 lis.push_back(n1);
00605 lis.push_back(n2);
00606 lis.push_back(n3);
00607 lis.push_back(n4);
00608 lis.push_back(n5);
00609 lis.push_back(n6);
00610 lis.push_back(n7);
00611 lis.push_back(n8);
00612 lis.push_back(n9);
00613 lis.push_back(n10);
00614 lis.push_back(n11);
00615 return lis;
00616 }
00617
00618 std::vector<int> TrackPool::AddList(int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8,
00619 int n9, int n10, int n11, int n12) {
00620 std::vector<int> lis;
00621 lis.clear();
00622 lis.push_back(n1);
00623 lis.push_back(n2);
00624 lis.push_back(n3);
00625 lis.push_back(n4);
00626 lis.push_back(n5);
00627 lis.push_back(n6);
00628 lis.push_back(n7);
00629 lis.push_back(n8);
00630 lis.push_back(n9);
00631 lis.push_back(n10);
00632 lis.push_back(n11);
00633 lis.push_back(n12);
00634 return lis;
00635 }
00636
00637