ATLAS Offline Software
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 
16 namespace 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 //--------------------------------------------------------------------------------------------------
33 double 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 
Propagator.h
CommonPars.h
Trk::cfVrtDstSig
double cfVrtDstSig(VKVertex *vk, bool UseTrkErr)
Definition: cfVrtDst.cxx:33
cfVrtDst.h
Trk::vkalMagFld::getMagFld
static void getMagFld(const double, const double, const double, double &, double &, double &, VKalVrtControlBase *)
Definition: VKalVrtBMag.cxx:24
skel.it
it
Definition: skel.GENtoEVGEN.py:396
Trk::VKVertex::FVC
ForVrtClose FVC
Definition: TrkVKalVrtCoreBase.h:160
Trk::VKVertex::refIterV
double refIterV[3]
Definition: TrkVKalVrtCoreBase.h:146
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
Trk::getCnstParticleMom
std::array< double, 4 > getCnstParticleMom(const VKTrack *trk, const VKVertex *vk)
Definition: cfMomentum.cxx:92
Trk::combinedTrack
void combinedTrack(long int ICH, double *pv0, double *covi, double BMAG, double *par, double *covo)
Definition: XYZtrp.cxx:113
Trk::cfdinv
int cfdinv(double *cov, double *wgt, long int NI)
Definition: Tracking/TrkVertexFitter/TrkVKalVrtCore/src/Matrix.cxx:497
TrkVKalVrtCoreBase.h
Trk::VKVertex::TrackList
std::vector< std::unique_ptr< VKTrack > > TrackList
Definition: TrkVKalVrtCoreBase.h:167
Trk::vkalPropagator::Propagate
static void Propagate(long int TrkID, long int Charge, double *ParOld, double *CovOld, double *RefStart, double *RefEnd, double *ParNew, double *CovNew, VKalVrtControlBase *FitControl=0)
Definition: Propagator.cxx:127
Trk::ForVrtClose::vrt
double vrt[3]
Definition: ForVrtClose.h:23
lumiFormat.i
int i
Definition: lumiFormat.py:85
Matrix.h
drawFromPickle.tan
tan
Definition: drawFromPickle.py:36
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Trk::VKVertex::vk_fitterControl
std::unique_ptr< VKalVrtControl > vk_fitterControl
Definition: TrkVKalVrtCoreBase.h:194
Trk::VKVertex::cnstV
double cnstV[3]
Definition: TrkVKalVrtCoreBase.h:143
Trk::VKVertex::fitCovXYZMom
double fitCovXYZMom[21]
Definition: TrkVKalVrtCoreBase.h:159
XYZtrp.h
Trk::VKVertex
Definition: TrkVKalVrtCoreBase.h:128
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
Trk::ForVrtClose::covvrt
double covvrt[6]
Definition: ForVrtClose.h:23
cfMomentum.h