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 double vBx,vBy,vBz;
55 Trk::vkalMagFld::getMagFld(fittedVrt[0], fittedVrt[1], fittedVrt[2],vBx,vBy,vBz,(vk->vk_fitterControl).get());
56 double lPhi = atan2(ptot[1], ptot[0]);
57 double lTheta = acos(ptot[2] / sqrt(ptot[0]*ptot[0]+ptot[1]*ptot[1]+ptot[2]*ptot[2]));
58 double effectiveField = Trk::vkalMagFld::getEffField(vBx, vBy, vBz, lPhi, lTheta);
59 if ( UseTrkErr){
60 combinedTrack( Charge, ptot, vk->fitCovXYZMom, effectiveField, parV0, covParV0);
61 }else{
62 double DummyErr[21] = { 1.e-20,
63 0., 1.e-20,
64 0., 0., 1.e-20,
65 0., 0., 0., 1.e-18,
66 0., 0., 0., 0., 1.e-18,
67 0., 0., 0., 0., 0., 1.e-18};
68 combinedTrack( Charge, ptot, DummyErr, effectiveField, parV0, covParV0);
69 }
70//
71// Propagation to constraint vertex
72//
73 double nPar[5],nCov[15];
74 long int TrkID = -999; // Abstract track propagation
75 Trk::vkalPropagator::Propagate( TrkID, Charge, parV0, covParV0, fittedVrt, vk->FVC.vrt, nPar, nCov, (vk->vk_fitterControl).get());
76//
77//
78 double cnv[2][3];
79 cnv[0][0] = -sin(nPar[3]);
80 cnv[0][1] = cos(nPar[3]);
81 cnv[0][2] = 0.;
82 cnv[1][0] = sin(nPar[3])/tan(nPar[2]);
83 cnv[1][1] = cos(nPar[3])/tan(nPar[2]);
84 cnv[1][2] = -1.;
85//--
86 double covImp[3]={0.,0.,0.};
87 for( i=0; i<3; i++){
88 for( j=0; j<3; j++){
89 if(i>=j){ ij=i*(i+1)/2+j; }else{ ij=j*(j+1)/2+i;}
90 covImp[0] += cnv[0][i]*vk->FVC.covvrt[ij]*cnv[0][j];
91 covImp[1] += cnv[0][i]*vk->FVC.covvrt[ij]*cnv[1][j];
92 covImp[2] += cnv[1][i]*vk->FVC.covvrt[ij]*cnv[1][j];
93 }
94 }
95 if ( UseTrkErr){ covImp[0] += nCov[0]; covImp[1] += nCov[1]; covImp[2] += nCov[2];}
96
97 double dwgt[3];
98 int IERR=cfdinv(covImp, dwgt, -2); if(IERR){ IERR=cfdinv(covImp, dwgt, 2); if(IERR){dwgt[0]=dwgt[2]=1.e6; dwgt[1]=0.;}}
99 Signif = sqrt(dwgt[0] * nPar[0] * nPar[0] + 2. * dwgt[1] * nPar[0] * nPar[1] +
100 dwgt[2] * nPar[1] * nPar[1]);
101
102//std::cout<<" fittedcov="<<nCov[0]<<", "<<nCov[2]<<'\n';
103//std::cout<<" cfVrtDstSig="<<Signif<<", "<<nPar[0]<<", "<<nPar[1]<<'\n';
104 return Signif;
105}
106
107} /* End of namespace */
108
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 double getEffField(double bx, double by, double bz, double phi, double theta)
Definition VKalVrtBMag.h:60
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)
void combinedTrack(long int ICH, double *pv0, double *covi, double effectiveBMAG, double *par, double *covo)
Definition XYZtrp.cxx:113
std::array< double, 4 > getCnstParticleMom(const VKTrack *trk, const VKVertex *vk)
double cfVrtDstSig(VKVertex *vk, bool UseTrkErr)
Definition cfVrtDst.cxx:33
double covvrt[6]
Definition ForVrtClose.h:23