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