Changes in external/TrackCovariance/VertexFit.cc [82db145:53f4746] in git
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
external/TrackCovariance/VertexFit.cc
r82db145 r53f4746 18 18 fxCst.ResizeTo(3); 19 19 fCovCst.ResizeTo(3, 3); 20 fCovCstInv.ResizeTo(3, 3); 20 21 fXv.ResizeTo(3); 21 22 fcovXv.ResizeTo(3, 3); … … 31 32 fxCst.ResizeTo(3); 32 33 fCovCst.ResizeTo(3, 3); 34 fCovCstInv.ResizeTo(3, 3); 33 35 fXv.ResizeTo(3); 34 36 fcovXv.ResizeTo(3, 3); … … 38 40 TVectorD pr = *trkPar[i]; 39 41 fPar.push_back(new TVectorD(pr)); 42 fParNew.push_back(new TVectorD(pr)); 40 43 TMatrixDSym cv = *trkCov[i]; 41 44 fCov.push_back(new TMatrixDSym(cv)); 45 fCovNew.push_back(new TMatrixDSym(cv)); 42 46 } 43 47 fChi2List.ResizeTo(fNtr); … … 54 58 fxCst.ResizeTo(3); 55 59 fCovCst.ResizeTo(3, 3); 60 fCovCstInv.ResizeTo(3, 3); 56 61 fXv.ResizeTo(3); 57 62 fcovXv.ResizeTo(3, 3); … … 61 66 { 62 67 fPar.push_back(new TVectorD(track[i]->GetObsPar())); 68 fParNew.push_back(new TVectorD(track[i]->GetObsPar())); 63 69 fCov.push_back(new TMatrixDSym(track[i]->GetCov())); 70 fCovNew.push_back(new TMatrixDSym(track[i]->GetCov())); 64 71 } 65 72 } … … 73 80 { 74 81 if (fx0i[i]) { fx0i[i]->Clear(); delete fx0i[i]; } 75 if (fai[i]) { fai[i]->Clear(); delete fai[i]; } 76 if (fDi[i]) { fDi[i]->Clear(); delete fDi[i]; } 77 if (fWi[i]) { fWi[i]->Clear(); delete fWi[i]; } 82 if (fai[i]) { fai[i]->Clear(); delete fai[i]; } 83 if (fdi[i]) { fdi[i]->Clear(); delete fdi[i]; } 84 if (fAti[i]) { fAti[i]->Clear(); delete fAti[i]; } 85 if (fDi[i]) { fDi[i]->Clear(); delete fDi[i]; } 86 if (fWi[i]) { fWi[i]->Clear(); delete fWi[i]; } 78 87 if (fWinvi[i]){ fWinvi[i]->Clear(); delete fWinvi[i]; } 79 88 } … … 81 90 fx0i.clear(); 82 91 fai.clear(); 92 fdi.clear(); 93 fAti.clear(); 83 94 fDi.clear(); 84 95 fWi.clear(); … … 88 99 { 89 100 fxCst.Clear(); 90 fCovCst.Clear(); 101 fCovCst.Clear(); 102 fCovCstInv.Clear(); 91 103 fXv.Clear(); 92 104 fcovXv.Clear(); … … 95 107 for (Int_t i = 0; i < fNtr; i++) 96 108 { 97 fPar[i]->Clear(); delete fPar[i]; 98 fCov[i]->Clear(); delete fCov[i]; 109 fPar[i]->Clear(); delete fPar[i]; 110 fParNew[i]->Clear(); delete fParNew[i]; 111 fCov[i]->Clear(); delete fCov[i]; 112 fCovNew[i]->Clear(); delete fCovNew[i]; 99 113 } 100 114 fPar.clear(); 101 fCov.clear(); 115 fParNew.clear(); 116 fCov.clear(); 117 fCovNew.clear(); 102 118 // 103 119 ResetWrkArrays(); … … 424 440 // 425 441 // Get track parameters and their covariance 426 TVectorD par = *fPar [i];442 TVectorD par = *fParNew[i]; 427 443 TMatrixDSym Cov = *fCov[i]; 428 444 // … … 433 449 // 434 450 TMatrixD A = Fill_A(par, fs); // A = dx/da = derivatives wrt track parameters 451 TMatrixD At(TMatrixD::kTransposed, A); // A transposed 452 fAti.push_back(new TMatrixD(At)); // Store A' 453 TVectorD di = A * (par - *fPar[i]); // x-shift 454 fdi.push_back(new TVectorD(di)); // Store x-shift 435 455 TMatrixDSym Winv = Cov.Similarity(A); // W^-1 = A*C*A' 436 fWinvi.push_back(new TMatrixDSym(Winv)); 456 fWinvi.push_back(new TMatrixDSym(Winv)); // Store W^-1 matrix 437 457 // 438 458 TMatrixDSym W = RegInv(Winv); // W = (A*C*A')^-1 … … 456 476 { 457 477 //std::cout << "VertexFitter: just in" << std::endl; 458 if (fNtr < 2) 459 { 478 if (fNtr < 2 && !fVtxCst){ 460 479 std::cout << "VertexFit::VertexFitter - Method called with less than 2 tracks - Aborting " << std::endl; 461 480 std::exit(1); … … 469 488 Double_t Chi2 = 0; 470 489 TVectorD x0 = fXv; // If previous fit done 471 if (fRold < 0.0)for (Int_t i = 0; i < 3; i++)x0(i) = 1000.; // Set to arbitrary large value if not 490 if (fRold < 0.0) { 491 // External constraint 492 if (fVtxCst) fRold = TMath::Sqrt(fxCst(0) * fxCst(0) + fxCst(1) * fxCst(1)); 493 // No constraint 494 else for (Int_t i = 0; i < 3; i++)x0(i) = 1000.; // Set to arbitrary large value 495 } 472 496 // 473 497 // Starting vertex radius approximation … … 475 499 Double_t R = fRold; // Use previous fit if available 476 500 if (R < 0.0) R = StartRadius(); // Rough vertex estimate 501 //std::cout << "Start radius: " << R << std::endl; 477 502 // 478 503 // Iteration properties … … 529 554 H += Ds; 530 555 // update constant term 531 TVectorD xs = *fx0i[i]; 556 TVectorD xs = *fx0i[i] - *fdi[i]; 557 TVectorD xx0 = *fx0i[i]; 558 /* 559 std::cout << "Iter. " << Ntry << ", trk " << i << ", x= " 560 << xx0(0) << ", " << xx0(1) << ", " << xx0(2)<< 561 ", ph0= "<<par(1)<< std::endl; 562 */ 532 563 cterm += Ds * xs; 533 564 } // End loop on tracks 565 // Some additions in case of external constraints 566 if (fVtxCst) { 567 H += fCovCstInv; 568 cterm += fCovCstInv * fxCst; 569 DW1D += fCovCstInv; 570 } 534 571 // 535 572 // update vertex position … … 544 581 for (Int_t i = 0; i < fNtr; i++) 545 582 { 546 TVectorD lambda = (*fDi[i]) * (*fx0i[i] - x );583 TVectorD lambda = (*fDi[i]) * (*fx0i[i] - x - *fdi[i]); 547 584 TMatrixDSym Wm1 = *fWinvi[i]; 548 585 fChi2List(i) = Wm1.Similarity(lambda); … … 551 588 TVectorD b = (*fWi[i]) * (x - (*fx0i[i])); 552 589 for (Int_t j = 0; j < 3; j++)ffi[i] += a(j) * b(j) / fa2i[i]; 590 TVectorD newPar = *fPar[i] - ((*fCov[i]) * (*fAti[i])) * lambda; 591 fParNew[i] = new TVectorD(newPar); 553 592 } 593 // Add external constraint to Chi2 594 if (fVtxCst) Chi2 += fCovCstInv.Similarity(x - fxCst); 554 595 // 555 596 TVectorD dx = x - x0; … … 562 603 // Store result 563 604 // 564 fXv = x; 605 fXv = x; // Vertex position 565 606 fcovXv = covX; // Vertex covariance 566 607 fChi2 = Chi2; // Vertex fit Chi2 608 //std::cout << "Found vertex " << fXv(0) << ", " << fXv(1) << ", " << fXv(2) << std::endl; 567 609 } // end of iteration loop 568 610 // … … 603 645 void VertexFit::AddVtxConstraint(TVectorD xv, TMatrixDSym cov) // Add gaussian vertex constraint 604 646 { 605 std::cout << "VertexFit::AddVtxConstraint: Not implemented yet" << std::endl; 647 //std::cout << "VertexFit::AddVtxConstraint: Not implemented yet" << std::endl; 648 fVtxCst = kTRUE; // Vertex constraint flag 649 fxCst = xv; // Constraint value 650 fCovCst = cov; // Constraint covariance 651 fCovCstInv = cov; 652 fCovCstInv.Invert(); // Its inverse 653 // 654 // Set starting vertex as external constraint 655 fXv = fxCst; 656 fcovXv = fCovCst; 606 657 } 607 658 // … … 613 664 fPar.push_back(par); // add new track 614 665 fCov.push_back(Cov); 666 fParNew.push_back(par); // add new track 667 fCovNew.push_back(Cov); 615 668 // 616 669 // Reset previous vertex temp arrays … … 628 681 fPar.erase(fPar.begin() + iTrk); // Remove track 629 682 fCov.erase(fCov.begin() + iTrk); 683 fParNew.erase(fParNew.begin() + iTrk); // Remove track 684 fCovNew.erase(fCovNew.begin() + iTrk); 630 685 // 631 686 // Reset previous vertex temp arrays
Note:
See TracChangeset
for help on using the changeset viewer.