ATLAS Offline Software
Loading...
Searching...
No Matches
cfVrtDst.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
12#include <cmath>
13#include <array>
14#include <iostream>
15
16namespace Trk {
17
18// Function calculates distance between summary track after fit and vertex for constraint
19// Flag UseTrkErr tells if SummaryTrack errors+VertexErrors are used or only VertexErrors
20// Algorithm:
21// V0 is first propagated to (0,0,0) point and then is propagated back to reference
22// point. Error matrix is slightly different from one obtained with direct propagation
23// as in cfVrtDstSig
24//---------------------------------------------------------------------------------------
25//
26// Function calculates a significance of summary track - constraint vertex 3D distance
27// As V0 origin vk->cnstV[] is used!!!
28//
29// V0 covariance matrix is not calculated and taken from vk->fitCovXYZMom saved on previous fit
30// Algorithm:
31// V0 track is obtained at fitted point and propagated to reference point
32//--------------------------------------------------------------------------------------------------
33double cfVrtDstSig( VKVertex * vk, bool UseTrkErr)
34{
35 int i,j,ij,it;
36 double parV0[5], covParV0[15];
37 double Signif;
38 /* ------------------------------------------------------------------- */
39
40 double ptot[3]= {0.,0.,0.};
41 int NTRK = vk->TrackList.size();
42 for ( it=0; it<NTRK; it++) {
43 std::array<double, 4> pp=getCnstParticleMom( vk->TrackList[it].get(), vk );
44 ptot[0] += pp[0];
45 ptot[1] += pp[1];
46 ptot[2] += pp[2];
47 }
48 double fittedVrt[3]={vk->refIterV[0] + vk->cnstV[0],
49 vk->refIterV[1] + vk->cnstV[1],
50 vk->refIterV[2] + vk->cnstV[2]};
51 long int Charge = 0; for ( it=0; it<NTRK; it++) Charge += vk->TrackList[it]->Charge;
52//std::cout<<" cfVrtDst ntrk="<<NTRK<<" chg="<<Charge<<'\n';
53 double localField=Trk::vkalMagFld::getMagFld(fittedVrt,(vk->vk_fitterControl).get());
54 if ( UseTrkErr){
55 combinedTrack( Charge, ptot, vk->fitCovXYZMom, localField, parV0, covParV0);
56 }else{
57 double DummyErr[21] = { 1.e-20,
58 0., 1.e-20,
59 0., 0., 1.e-20,
60 0., 0., 0., 1.e-18,
61 0., 0., 0., 0., 1.e-18,
62 0., 0., 0., 0., 0., 1.e-18};
63 combinedTrack( Charge, ptot, DummyErr, localField, parV0, covParV0);
64 }
65//
66// Propagation to constraint vertex
67//
68 double nPar[5],nCov[15];
69 long int TrkID = -999; // Abstract track propagation
70 Trk::vkalPropagator::Propagate( TrkID, Charge, parV0, covParV0, fittedVrt, vk->FVC.vrt, nPar, nCov, (vk->vk_fitterControl).get());
71//
72//
73 double cnv[2][3];
74 cnv[0][0] = -sin(nPar[3]);
75 cnv[0][1] = cos(nPar[3]);
76 cnv[0][2] = 0.;
77 cnv[1][0] = sin(nPar[3])/tan(nPar[2]);
78 cnv[1][1] = cos(nPar[3])/tan(nPar[2]);
79 cnv[1][2] = -1.;
80//--
81 double covImp[3]={0.,0.,0.};
82 for( i=0; i<3; i++){
83 for( j=0; j<3; j++){
84 if(i>=j){ ij=i*(i+1)/2+j; }else{ ij=j*(j+1)/2+i;}
85 covImp[0] += cnv[0][i]*vk->FVC.covvrt[ij]*cnv[0][j];
86 covImp[1] += cnv[0][i]*vk->FVC.covvrt[ij]*cnv[1][j];
87 covImp[2] += cnv[1][i]*vk->FVC.covvrt[ij]*cnv[1][j];
88 }
89 }
90 if ( UseTrkErr){ covImp[0] += nCov[0]; covImp[1] += nCov[1]; covImp[2] += nCov[2];}
91
92 double dwgt[3];
93 int IERR=cfdinv(covImp, dwgt, -2); if(IERR){ IERR=cfdinv(covImp, dwgt, 2); if(IERR){dwgt[0]=dwgt[2]=1.e6; dwgt[1]=0.;}}
94 Signif = sqrt(dwgt[0] * nPar[0] * nPar[0] + 2. * dwgt[1] * nPar[0] * nPar[1] +
95 dwgt[2] * nPar[1] * nPar[1]);
96
97//std::cout<<" fittedcov="<<nCov[0]<<", "<<nCov[2]<<'\n';
98//std::cout<<" cfVrtDstSig="<<Signif<<", "<<nPar[0]<<", "<<nPar[1]<<'\n';
99 return Signif;
100}
101
102} /* End of namespace */
103
std::vector< std::unique_ptr< VKTrack > > TrackList
double fitCovXYZMom[21]
std::unique_ptr< VKalVrtControl > vk_fitterControl
static void getMagFld(const double, const double, const double, double &, double &, double &, const VKalVrtControlBase *)
static void Propagate(long int TrkID, long int Charge, double *ParOld, double *CovOld, double *RefStart, double *RefEnd, double *ParNew, double *CovNew, VKalVrtControlBase *FitControl=0)
Ensure that the ATLAS eigen extensions are properly loaded.
int cfdinv(double *cov, double *wgt, long int NI)
std::array< double, 4 > getCnstParticleMom(const VKTrack *trk, const VKVertex *vk)
double cfVrtDstSig(VKVertex *vk, bool UseTrkErr)
Definition cfVrtDst.cxx:33
void combinedTrack(long int ICH, double *pv0, double *covi, double BMAG, double *par, double *covo)
Definition XYZtrp.cxx:113
double covvrt[6]
Definition ForVrtClose.h:23