ATLAS Offline Software
PrCFit.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 #include <cmath>
8 #include <iostream>
9 
10 namespace Trk {
11 
12 
13 /*------------------------------------------------------------------------------*/
14 /* Package for vertex fit with constraints */
15 /* Minimal calling sequence: */
16 /* .......................... */
17 /* call PRCFIT(ntrk,wm,bmag,vrt,vrte,irob): setting values for cnsts */
18 /* call SetMassCnst(bmag,vrt,vrte,irob): setting values for cnsts */
19 /* call CFPEST(ntrk,xyz0,ich,apar,par0) : primary estimation of Theta, */
20 /* : phi,1/r if they are not known*/
21 /* call CFIT(iflag,ifcovv0,ntrk,ich,xyz0,par0,apar,awgt, : fit itself */
22 /* @ xyzfit,parfs,ptot,covf,chi2,chi2tr,ierr) */
23 /* if(ierr.ne.0) goto 9999 */
24 /* ........................... */
25 /* call FITERM(ntrk,errmtx) : full error matrix in symmetric */
26 /* : form ( if needed) */
27 /* ........................... */
28 /* WARNING 1: For using tracks with charge=0 they should have */
29 /* par(5) = MAG*0.002998/pt and correct definition */
30 /* of weight matrix ( or at least weight(15)=1./err**2) */
31 /* WARNING 2: Magnetic field in ATLAS for use in fit is 2.084 ( centre ) */
32 /* WARNING 3: Perigee parameters inside package DOESN'T coinside with */
33 /* those in XKALMAN. See conversion code in GetTrkPar and */
34 /* CnvErrMtx subroutines. (Will be changed in future...) */
35 /* Other useful subroutines (see comments inside code): */
36 /* XYZTRP : track conversion (X,Y,Z,PX,PY,PZ) --> (eps,z,theta,phi,1/r) */
37 /* CFIMP : track impact parameters calculation */
38 /* CFNEWP : propagate track to new vertex */
39 /* CFERPR : propagate track error matrix to new vertex */
40 /* STPCNV : track momentum from track (theta,phi,1/r) at vertex */
41 /*------------------------------------------------------------------------------*/
42 
43 void ForCFT::prcfit( long int ntrk, double *wm, const double *wmfit, double bmag, const double *vrt, const double *vrte) noexcept
44 {
45  long int i__1;
46  double summ;
47 
48 
49 /*------------------------------------------------------------------------------*/
50 /* SETTING OF INITIAL PARAMETERS FOR C-FIT */
51 /* (DEPENDING ON TYPE OF FIT) */
52 /* INPUT: */
53 /* NTRK : number of tracks */
54 /* WM(JTK) : track masses ( if negative - track doesn't */
55 /* : participate in mass constraint ) */
56 /* WMFIT : masses for mass constraints */
57 /* VRT(3) : point for directional constraint */
58 /* (usually primary vertex) */
59 /* VRTE(6) : error matrix for VRT ( for IFLAG=6) */
60 /* BMAG : magnetic field (in Tesla) */
61 /* Magnetic field is obligatory , other parameters MUST be set */
62 /* when used in constraints */
63 /* General mass constraint for all tracks is set in PRCFIT through WMFIT */
64 /* if WMFIT > Sum_of_track_masses */
65 /* Any number of additional mass constraints can be set up with */
66 /* SetMassCnst(NCnstTrk,IndexTrk,WMCNST) where */
67 /* INPUT: */
68 /* NCnstTrk :track number of track subset for cnst.*/
69 /* IndexTrk(NCnstTrk) :index of each track from subset in */
70 /* :general track set for vertex fit. */
71 /* WmCnst :Mass for given constraint */
72 /* Author: V.Kostioukhine (1995 ,2004,2005) */
73 /* */
74 /* All functions here must be called AFTER(!!!) prcfit. */
75 /* */
76 /*------------------------------------------------------------------------------*/
77 
78  this->localbmag = bmag;
79  this->nmcnst = 0;
80  for (int i=0; i<8; ++i) this->wmfit[i] = -10000.;
81  summ = 0.;
82  i__1 = ntrk<vkalNTrkM ? ntrk: vkalNTrkM;
83  for (int i=0; i<i__1; ++i) {
84  this->wm[i] = std::abs(wm[i]);
85  summ += wm[i];
86  }
87  if ((*wmfit) > summ) {
88 /* Set general mass constraint based on ALL tracks */
89  this->nmcnst = 1;
90  for (int i = 0; i < vkalNTrkM; ++i) {
91  indtrkmc[0][i] = 0;
92  if (i < ntrk) {indtrkmc[0][i] = 1;}
93  }
94  this->wmfit[0] = (*wmfit);
95  }
96 
97  this->vrt[0] = vrt[0];
98  this->vrt[1] = vrt[1];
99  this->vrt[2] = vrt[2];
100  this->covvrt[0] = vrte[0];
101  this->covvrt[1] = vrte[1];
102  this->covvrt[2] = vrte[2];
103  this->covvrt[3] = vrte[3];
104  this->covvrt[4] = vrte[4];
105  this->covvrt[5] = vrte[5];
106  this->irob = 0;
107  this->IterationNumber = 50;
108  this->IterationPrecision = 1.e-3;
109  for (int i = 0; i < vkalNTrkM; ++i) this->robres[i]=1.; //Safety
110 //
111 // Reset all constraints
112 //
113 this->useMassCnst = 0;
114 this->usePhiCnst = 0;
115 this->useThetaCnst = 0;
116 this->useAprioriVrt = 0;
117 this->usePointingCnst = 0;
118 this->usePassNear = 0;
119 //forcft_1.usePlaneCnst = 0; //Used only on demand=> must NOT be reset here!!!
120 }
121 
122 ForCFT::ForCFT() noexcept{
123  nmcnst=0;
126  Ap=Bp=Dp=Cp=0.;
127  IterationNumber = 50;
128  IterationPrecision=1.e-3;
129  RobustScale = 1.; irob=0;
130  for (int ic=0; ic<vkalMaxNMassCnst; ++ic) wmfit[ic] = -10000.;
131  for (int it=0; it<vkalNTrkM; ++it) {
132  wm[it] = 139.57018;
133  robres[it] = 1.;
134  for(int ic=0; ic<vkalMaxNMassCnst; ic++) indtrkmc[ic][it]=0;
135  }
136  localbmag=1.997; // Safety: standard magnetic field in ID
137 }
138 
139 
140 void ForCFT::vksetIterationNum(long int Iter) noexcept
141 {
142  if (Iter<3) Iter=3;
143  if (Iter>100) Iter=100;
144  IterationNumber = Iter;
145 }
146 
147 void ForCFT::vksetIterationPrec(double Prec) noexcept
148 {
149  if (Prec<1.e-5) Prec=1.e-5;
150  if (Prec>1.e-1) Prec=1.e-1;
151  IterationPrecision = Prec;
152 }
153 
154 void ForCFT::vksetRobustScale(double Scale) noexcept
155 {
156  if (Scale<0.01) Scale=0.01;
157  if (Scale>100.) Scale=100.;
158  RobustScale = Scale;
159 }
160 
161 void ForCFT::vksetRobustness(long int Rob) noexcept
162 {
163  if (Rob<0) Rob=0;
164  if (Rob>7) Rob=7;
165  irob = Rob;
166 }
167 
168 void ForCFT::vksetUseMassCnst() noexcept { useMassCnst = 1;}
169 void ForCFT::vksetUsePhiCnst() noexcept { usePhiCnst = 1;}
170 void ForCFT::vksetUsePlaneCnst(double a, double b, double c, double d) noexcept {
171  if(a+b+c+d == 0.){ usePlaneCnst = 0;
172  }else{ usePlaneCnst = 1; }
173  Ap = a; Bp = b; Cp = c; Dp = d;
174 }
175 
176 
177 
178 void ForCFT::setmasscnst_(long int ncnsttrk, long int *indextrk, double wmcnst) noexcept
179 {
180  if (indextrk==nullptr) return; //Protection! Track indices start from 1 (not 0)!
181  --indextrk;
182 
183  ++nmcnst;
184  if (nmcnst > 8) return ;
185  for (int i = 0; i < vkalNTrkM; ++i) {
186  indtrkmc[nmcnst-1][i] = 0;
187  }
188  for (int i = 0; i < ncnsttrk; ++i) {
189  if (indextrk[i] > 0 && indextrk[i] < vkalNTrkM) {
190  indtrkmc[nmcnst-1][indextrk[i]] = 1;
191  }
192  }
193  wmfit[nmcnst - 1] = wmcnst;
194  }
195 
196 } /* End of namespace */
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
CommonPars.h
Trk::ForCFT::useThetaCnst
int useThetaCnst
Definition: ForCFT.h:17
Trk::ForCFT::vksetRobustScale
void vksetRobustScale(double Scale) noexcept
Definition: PrCFit.cxx:154
Trk::ForCFT::vksetRobustness
void vksetRobustness(long int Rob) noexcept
Definition: PrCFit.cxx:161
hist_file_dump.d
d
Definition: hist_file_dump.py:137
Trk::ForCFT::ForCFT
ForCFT() noexcept
Definition: PrCFit.cxx:122
skel.it
it
Definition: skel.GENtoEVGEN.py:396
Trk::ForCFT::vksetUseMassCnst
void vksetUseMassCnst() noexcept
Definition: PrCFit.cxx:168
Trk::ForCFT::Cp
double Cp
Definition: ForCFT.h:30
Trk::ForCFT::vksetIterationPrec
void vksetIterationPrec(double Prec) noexcept
Definition: PrCFit.cxx:147
Trk::ForCFT::setmasscnst_
void setmasscnst_(long int ncnsttrk, long int *indextrk, double wmcnst) noexcept
Definition: PrCFit.cxx:178
Trk::ForCFT::usePassNear
int usePassNear
Definition: ForCFT.h:20
Trk::ForCFT::indtrkmc
int indtrkmc[vkalMaxNMassCnst][vkalNTrkM]
Definition: ForCFT.h:46
lumiFormat.i
int i
Definition: lumiFormat.py:85
Trk::ForCFT::RobustScale
double RobustScale
Definition: ForCFT.h:44
Trk::ForCFT::vksetUsePhiCnst
void vksetUsePhiCnst() noexcept
Definition: PrCFit.cxx:169
Trk::ForCFT::useAprioriVrt
int useAprioriVrt
Definition: ForCFT.h:19
Trk::ForCFT::IterationPrecision
double IterationPrecision
Definition: ForCFT.h:48
Scale
void Scale(TH1 *h, double d=1)
Definition: comparitor.cxx:77
Trk::ForCFT::usePhiCnst
int usePhiCnst
Definition: ForCFT.h:16
Trk::ForCFT::usePlaneCnst
int usePlaneCnst
Definition: ForCFT.h:21
grepfile.ic
int ic
Definition: grepfile.py:33
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Trk::ForCFT::wm
double wm[vkalNTrkM]
Definition: ForCFT.h:26
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
Trk::ForCFT::Dp
double Dp
Definition: ForCFT.h:30
Trk::ForCFT::Ap
double Ap
Definition: ForCFT.h:30
vkalNTrkM
#define vkalNTrkM
Definition: CommonPars.h:22
Trk::ForCFT::prcfit
void prcfit(long int ntrk, double *wm, const double *wmfit, double bmag, const double *vrt, const double *vrte) noexcept
Definition: PrCFit.cxx:43
Trk::ForCFT::wmfit
double wmfit[vkalMaxNMassCnst]
Definition: ForCFT.h:27
Trk::ForCFT::localbmag
double localbmag
Definition: ForCFT.h:28
a
TList * a
Definition: liststreamerinfos.cxx:10
Trk::ForCFT::vksetIterationNum
void vksetIterationNum(long int Iter) noexcept
Definition: PrCFit.cxx:140
Trk::ForCFT::irob
int irob
Definition: ForCFT.h:43
vkalMaxNMassCnst
#define vkalMaxNMassCnst
Definition: CommonPars.h:27
Trk::ForCFT::IterationNumber
int IterationNumber
Definition: ForCFT.h:47
Trk::ForCFT::nmcnst
int nmcnst
Definition: ForCFT.h:25
Trk::ForCFT::Bp
double Bp
Definition: ForCFT.h:30
python.compressB64.c
def c
Definition: compressB64.py:93
ForCFT.h
Trk::ForCFT::vksetUsePlaneCnst
void vksetUsePlaneCnst(double a, double b, double c, double d) noexcept
Definition: PrCFit.cxx:170
Trk::ForCFT::robres
double robres[vkalNTrkM]
Definition: ForCFT.h:45
Trk::ForCFT::useMassCnst
int useMassCnst
Definition: ForCFT.h:15
Trk::ForCFT::usePointingCnst
int usePointingCnst
Definition: ForCFT.h:18