ATLAS Offline Software
Propagator.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // Creates interface vkalPropagator object which contains pointers to real
6 // propagators ( external or internal)
7 //
8 // Single myPropagator object of vkalPropagator type is created in CFit.cxx
9 //------------------------------------------------------------------------
10 // Header include
12 
13 #include <cmath>
14 
17 #include "TrkVKalVrtCore/cfErPr.h"
18 #include "TrkVKalVrtCore/cfNewP.h"
19 #include "TrkVKalVrtCore/cfNewPm.h"
20 //-------------------------------------------------
21 
22 namespace {
23 // anonymous namespace for keeping internal
24 // implementation methods
25 // So as to have internal linkage
26 // no symbols exported
27 using namespace Trk;
28 
29 //-------------------------------------------------------------------------
30 // Simple propagator in constant field
31 // Due to a translation invariance propagation is done in relative coordinates
32 // assuming that starting point is (0,0,0)
33 //
34 void PropagateSTD(long int, long int Charge, double *ParOld, double *CovOld,
35  double *RefStart, double *RefEnd, double *ParNew,
36  double *CovNew, VKalVrtControlBase *CONTROL) {
37  double Way, closePoint[3], Goal[3];
38  Goal[0] = RefEnd[0] - RefStart[0];
39  Goal[1] = RefEnd[1] - RefStart[1];
40  Goal[2] = RefEnd[2] - RefStart[2];
41  cfnewp(Charge, ParOld, &Goal[0], &Way, ParNew, closePoint);
42  if (CovOld != nullptr)
43  cferpr(Charge, ParOld, &Goal[0], Way, CovOld, CovNew);
44  if (Charge ==
45  0) { // Correction for different magnetic field values in Ini and End
46  double vBx, vBy, vBz, vBzn;
47  Trk::vkalMagFld::getMagFld(RefStart[0], RefStart[1], RefStart[2], vBx, vBy,
48  vBz, CONTROL);
49  Trk::vkalMagFld::getMagFld(RefEnd[0], RefEnd[1], RefEnd[2], vBx, vBy, vBzn,
50  CONTROL);
51  double Corr = vBzn / vBz;
52  ParNew[4] *= Corr;
53  if (CovOld != nullptr) {
54  CovNew[10] *= Corr;
55  CovNew[11] *= Corr;
56  CovNew[12] *= Corr;
57  CovNew[13] *= Corr;
58  CovNew[14] *= Corr * Corr;
59  }
60  }
61 }
62 
63 //--------------------------------------------------------------------------------
64 // Runge-Kutta propagator in nonuniform field
65 //
66 void PropagateRKM(long int Charge, double *ParOld, double *CovOld,
67  double *RefStart, double *RefEnd, double *ParNew,
68  double *CovNew, VKalVrtControlBase *CONTROL) {
69  double Way;
70  double closePoint[3], Goal[3];
71  Goal[0] = RefEnd[0] - RefStart[0];
72  Goal[1] = RefEnd[1] - RefStart[1];
73  Goal[2] = RefEnd[2] - RefStart[2];
74  cfnewp(Charge, ParOld, &Goal[0], &Way, ParNew, closePoint);
75  if (CovOld != nullptr)
76  cferpr(Charge, ParOld, &Goal[0], Way, CovOld, CovNew);
77 
78  if (Charge != 0)
79  cfnewpm(ParOld, RefStart, RefEnd, Way, ParNew, closePoint, CONTROL);
80 
81  if (Charge ==
82  0) { // Correction for different magnetic field values in Ini and End
83  double vBx, vBy, vBz, vBzn;
84  Trk::vkalMagFld::getMagFld(RefStart[0], RefStart[1], RefStart[2], vBx, vBy,
85  vBz, CONTROL);
86  Trk::vkalMagFld::getMagFld(RefEnd[0], RefEnd[1], RefEnd[2], vBx, vBy, vBzn,
87  CONTROL);
88  double Corr = vBzn / vBz;
89  ParNew[4] *= Corr;
90  if (CovOld != nullptr) {
91  CovNew[10] *= Corr;
92  CovNew[11] *= Corr;
93  CovNew[12] *= Corr;
94  CovNew[13] *= Corr;
95  CovNew[14] *= Corr * Corr;
96  }
97  }
98 }
99 
100 } // namespace
101 
102 namespace Trk {
103 
107 
109  // if ( m_typePropagator == 3 ) return vk_objectProp->checkTarget(RefNew);
110  return true;
111 }
112 //------------------------------------------------------------------------
113 // Old propagator functions:
114 // CFNEWP - doesn't use magnetic field at all. Only track curvature.
115 // So it's symmetric for back and forward propagation
116 // CFNEWPM - use exact nonuniform magnetic field so is not symmetric.
117 // Used for forward propagation (0,0,0) -> REF.
118 // Returns perigee parameters with respect to REF
119 // (then in new reference system with center at REF!!!)
120 //
121 // Usually all package routines propagate from (0,0,0) to REF.
122 // Only XYZTRP propagates from REF to (0,0,0) and then uses BACKPROPAGATION
123 // Propagation now is done from RefStart point to RefEnd point
124 // A final position after propagation is PERIGEE assuming that a REF(target)
125 // is a CENTER OF NEW COORDINATE SYSTEM with axes parallel to initial ones
126 
127 void vkalPropagator::Propagate(long int TrkID, long int Charge, double *ParOld,
128  double *CovOld, double *RefOld, double *RefNew,
129  double *ParNew, double *CovNew,
130  VKalVrtControlBase *FitControl) {
131  if (RefOld[0] == RefNew[0] && RefOld[1] == RefNew[1] &&
132  RefOld[2] == RefNew[2]) {
133  std::copy(ParOld, ParOld + 5, ParNew);
134  if (CovOld != nullptr) {
135  std::copy(CovOld, CovOld + 15, CovNew);
136  }
137  return;
138  }
139  //
140  //-- Propagation itself
141  //
142  if (FitControl == nullptr ||
143  (FitControl->vk_objProp == nullptr &&
144  FitControl->vk_funcProp ==
145  nullptr)) { // No external propagators, use internal ones
146  // std::cout<<" Core: use INTERNAL propagator. Charge="<<Charge<<'\n';
147  if (vkalUseRKMPropagator) {
148  PropagateRKM(Charge, ParOld, CovOld, RefOld, RefNew, ParNew, CovNew,
149  FitControl);
150  } else {
151  PropagateSTD(TrkID, Charge, ParOld, CovOld, RefOld, RefNew, ParNew,
152  CovNew, FitControl);
153  }
154  return;
155  }
156 
157  if (FitControl->vk_objProp) {
158  // std::cout<<" Core: use EXTERNAL propagator. Charge="<<Charge<<'\n';
159  if (Charge == 0) {
160  PropagateSTD(TrkID, Charge, ParOld, CovOld, RefOld, RefNew, ParNew,
161  CovNew, FitControl);
162  } else {
163  FitControl->vk_objProp->Propagate(TrkID, Charge, ParOld, CovOld, RefOld,
164  RefNew, ParNew, CovNew,
165  *FitControl->vk_istate);
166  if (ParNew[0] == 0. && ParNew[1] == 0. && ParNew[2] == 0. &&
167  ParNew[3] == 0. && ParNew[4] == 0.) {
168  PropagateRKM(Charge, ParOld, CovOld, RefOld, RefNew, ParNew, CovNew,
169  FitControl);
170  }
171  }
172  return;
173  }
174  //-------------------
175  if (FitControl->vk_funcProp) {
176  FitControl->vk_funcProp(TrkID, Charge, ParOld, CovOld, RefOld, RefNew,
177  ParNew, CovNew);
178  return;
179  }
180  //-------------------
181 }
182 
183 void vkalPropagator::Propagate(VKTrack *trk, double *RefOld, double *RefNew,
184  double *ParNew, double *CovNew,
185  VKalVrtControlBase *FitControl) {
186  if (RefOld[0] == RefNew[0] && RefOld[1] == RefNew[1] &&
187  RefOld[2] == RefNew[2]) {
188  std::copy(trk->refPerig, trk->refPerig + 5, ParNew);
189  std::copy(trk->refCovar, trk->refCovar + 15, CovNew);
190  return;
191  }
192  long int TrkID = trk->Id;
193  long int Charge = trk->Charge;
194  //
195  //-- Propagation itself
196  //
197  if (FitControl == nullptr ||
198  (FitControl->vk_objProp == nullptr &&
199  FitControl->vk_funcProp ==
200  nullptr)) { // No external propagators, use internal ones
201  if (vkalUseRKMPropagator) {
202  PropagateRKM(Charge, trk->refPerig, trk->refCovar, RefOld, RefNew, ParNew,
203  CovNew, FitControl);
204  } else {
205  PropagateSTD(TrkID, Charge, trk->refPerig, trk->refCovar, RefOld, RefNew,
206  ParNew, CovNew, FitControl);
207  }
208  return;
209  }
210 
211  if (FitControl->vk_objProp) {
212  if (Charge == 0) {
213  PropagateSTD(TrkID, Charge, trk->refPerig, trk->refCovar, RefOld, RefNew,
214  ParNew, CovNew, FitControl);
215  } else {
216  FitControl->vk_objProp->Propagate(TrkID, Charge, trk->refPerig,
217  trk->refCovar, RefOld, RefNew, ParNew,
218  CovNew, *FitControl->vk_istate);
219  if (ParNew[0] == 0. && ParNew[1] == 0. && ParNew[2] == 0. &&
220  ParNew[3] == 0. && ParNew[4] == 0.) {
221  PropagateRKM(Charge, trk->refPerig, trk->refCovar, RefOld, RefNew,
222  ParNew, CovNew, FitControl);
223  }
224  }
225  return;
226  }
227  //-------------------
228  if (FitControl->vk_funcProp) {
229  FitControl->vk_funcProp(TrkID, Charge, trk->refPerig, trk->refCovar, RefOld,
230  RefNew, ParNew, CovNew);
231  return;
232  }
233 }
234 
235 } // namespace Trk
236 
Propagator.h
Trk::basePropagator::Propagate
virtual void Propagate(long int TrkID, long int Charge, double *ParOld, double *CovOld, double *RefStart, double *RefEnd, double *ParNew, double *CovNew, IVKalState &istate) const =0
vkalUseRKMPropagator
#define vkalUseRKMPropagator
Definition: Propagator.h:18
Trk::vkalPropagator::checkTarget
static bool checkTarget(double *RefEnd)
Definition: Propagator.cxx:108
Trk::vkalMagFld::getMagFld
static void getMagFld(const double, const double, const double, double &, double &, double &, VKalVrtControlBase *)
Definition: VKalVrtBMag.cxx:24
Trk::VKTrack::Id
long int Id
Definition: TrkVKalVrtCoreBase.h:72
Trk::VKTrack
Definition: TrkVKalVrtCoreBase.h:64
Trk::VKTrack::Charge
int Charge
Definition: TrkVKalVrtCoreBase.h:73
Trk::VKTrack::refPerig
double refPerig[5]
Definition: TrkVKalVrtCoreBase.h:96
Trk::basePropagator::basePropagator
basePropagator()
VKalVrtBMag.h
TrkVKalVrtCoreBase.h
Trk::cfnewp
void cfnewp(const long int ich, double *parold, double *ref, double *s, double *parnew, double *per)
Definition: cfNewP.cxx:10
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::VKalVrtControlBase::vk_funcProp
const addrPropagator vk_funcProp
Definition: TrkVKalVrtCore.h:39
Trk::cferpr
void cferpr(const long int ich, double *par, double *ref, const double s0, double *errold, double *errnew)
Definition: cfErPr.cxx:12
Trk::VKalVrtControlBase::vk_objProp
const basePropagator * vk_objProp
Definition: TrkVKalVrtCore.h:38
Trk::basePropagator::~basePropagator
virtual ~basePropagator()
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Trk::VKalVrtControlBase::vk_istate
IVKalState * vk_istate
Definition: TrkVKalVrtCore.h:40
Trk::cfnewpm
void cfnewpm(double *par, const double *xyzStart, double *xyzEnd, const double ustep, double *parn, double *closePoint, VKalVrtControlBase *CONTROL)
Definition: cfNewPm.cxx:16
cfNewPm.h
Trk::VKTrack::refCovar
double refCovar[15]
Definition: TrkVKalVrtCoreBase.h:97
cfNewP.h
calibdata.copy
bool copy
Definition: calibdata.py:27
Trk::VKalVrtControlBase
Definition: TrkVKalVrtCore.h:26
cfErPr.h
Trk::vkalPropagator::vkalPropagator
vkalPropagator()