ATLAS Offline Software
GeoXPEngine.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "GeoXPEngine.h"
6 #include "CLHEP/GenericFunctions/Variable.hh"
7 #include "CLHEP/GenericFunctions/FixedConstant.hh"
8 #include "CLHEP/GenericFunctions/RKIntegrator.hh"
9 #include "CLHEP/Geometry/Point3D.h"
10 #include "CLHEP/Vector/LorentzVector.h"
11 #include "CLHEP/Units/PhysicalConstants.h"
12 
13 
14 GeoXPEngine::GeoXPEngine (const Genfun::AbsFunction & Bx,
15  const Genfun::AbsFunction & By,
16  const Genfun::AbsFunction & Bz,
17  const HepGeom::Point3D<double> & x0,
18  const CLHEP::HepLorentzVector & p0,
19  double q )
20 {
21 
22 
23  // Peform a Runge-Kutte Integration of the trajectory of the charged
24  // particle in a magnetic field. Physics input is the Lorentz force
25  // law; note, relativistic expression applies.
26 
27  double m = p0.m();
28  double E = p0.e();
29  Genfun::Variable t;
30 
31 
32  if (m<100*CLHEP::keV) {
33  m_x= (Genfun::FixedConstant(x0.x()) + (CLHEP::c_light*p0.x()/p0.vect().mag())*t).clone();
34  m_y= (Genfun::FixedConstant(x0.y()) + (CLHEP::c_light*p0.y()/p0.vect().mag())*t).clone();
35  m_z= (Genfun::FixedConstant(x0.z()) + (CLHEP::c_light*p0.z()/p0.vect().mag())*t).clone();
36  m_px = Genfun::FixedConstant(p0.x()).clone();
37  m_py = Genfun::FixedConstant(p0.y()).clone();
38  m_pz = Genfun::FixedConstant(p0.z()).clone();
39 
40 
41  }
42  else {
43 
44  Genfun::RKIntegrator rkIntegrator;
45  Genfun::Variable Px(0,6),Py(1,6), Pz(2,6), X(3,6), Y(4,6), Z(5,6);
46  Genfun::FixedConstant I(1.0);
47 
48  const double inv_E = 1. / E;
49  Genfun::GENFUNCTION DPxDt = (q*inv_E)*(Py*(I%I%I%Bz) -Pz*(I%I%I%By))*CLHEP::c_light;
50  Genfun::GENFUNCTION DPyDt = (q*inv_E)*(Pz*(I%I%I%Bx) -Px*(I%I%I%Bz))*CLHEP::c_light;
51  Genfun::GENFUNCTION DPzDt = (q*inv_E)*(Px*(I%I%I%By) -Py*(I%I%I%Bx))*CLHEP::c_light;
52  Genfun::GENFUNCTION DxDt = Px*inv_E;
53  Genfun::GENFUNCTION DyDt = Py*inv_E;
54  Genfun::GENFUNCTION DzDt = Pz*inv_E;
55 
56  rkIntegrator.addDiffEquation(&DPxDt, "Px",p0.x(), p0.x(), p0.x());
57  rkIntegrator.addDiffEquation(&DPyDt, "Py",p0.y(), p0.y(), p0.y());
58  rkIntegrator.addDiffEquation(&DPzDt, "Pz",p0.z(), p0.z(), p0.z());
59  rkIntegrator.addDiffEquation(&DxDt, "x", x0.x(), x0.x(), x0.x());
60  rkIntegrator.addDiffEquation(&DyDt, "y", x0.y(), x0.y(), x0.y());
61  rkIntegrator.addDiffEquation(&DzDt, "z", x0.z(), x0.z(), x0.z());
62 
63 
64 
65  m_px = (*rkIntegrator.getFunction(0))(CLHEP::c_light*t).clone();
66  m_py = (*rkIntegrator.getFunction(1))(CLHEP::c_light*t).clone();
67  m_pz = (*rkIntegrator.getFunction(2))(CLHEP::c_light*t).clone();
68  m_x = (*rkIntegrator.getFunction(3))(CLHEP::c_light*t).clone();
69  m_y = (*rkIntegrator.getFunction(4))(CLHEP::c_light*t).clone();
70  m_z = (*rkIntegrator.getFunction(5))(CLHEP::c_light*t).clone();
71  }
72 }
73 
75  delete m_x;
76  delete m_y;
77  delete m_z;
78  delete m_px;
79  delete m_py;
80  delete m_pz;
81 }
82 
83 const Genfun::AbsFunction & GeoXPEngine::x() const {
84  return *m_x;
85 }
86 const Genfun::AbsFunction & GeoXPEngine::y() const {
87  return *m_y;
88 }
89 const Genfun::AbsFunction & GeoXPEngine::z() const {
90  return *m_z;
91 }
92 const Genfun::AbsFunction & GeoXPEngine::px() const {
93  return *m_px;
94 }
95 const Genfun::AbsFunction & GeoXPEngine::py() const {
96  return *m_py;
97 }
98 const Genfun::AbsFunction & GeoXPEngine::pz() const {
99  return *m_pz;
100 }
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
GeoXPEngine::~GeoXPEngine
~GeoXPEngine()
Definition: GeoXPEngine.cxx:74
GeoXPEngine::m_pz
const Genfun::AbsFunction * m_pz
Definition: GeoXPEngine.h:60
GeoXPEngine::m_y
const Genfun::AbsFunction * m_y
Definition: GeoXPEngine.h:56
Monitored::Z
@ Z
Definition: HistogramFillerUtils.h:24
GeoXPEngine::py
const Genfun::AbsFunction & py() const
Definition: GeoXPEngine.cxx:95
GeoXPEngine::pz
const Genfun::AbsFunction & pz() const
Definition: GeoXPEngine.cxx:98
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
GeoXPEngine::z
const Genfun::AbsFunction & z() const
Definition: GeoXPEngine.cxx:89
Monitored::X
@ X
Definition: HistogramFillerUtils.h:24
python.SystemOfUnits.keV
int keV
Definition: SystemOfUnits.py:156
GeoXPEngine::GeoXPEngine
GeoXPEngine(const Genfun::AbsFunction &Bx, const Genfun::AbsFunction &By, const Genfun::AbsFunction &Bz, const HepGeom::Point3D< double > &x0, const CLHEP::HepLorentzVector &p0, double q)
Definition: GeoXPEngine.cxx:14
GeoXPEngine.h
Monitored::Y
@ Y
Definition: HistogramFillerUtils.h:24
VP1PartSpect::E
@ E
Definition: VP1PartSpectFlags.h:21
GeoXPEngine::y
const Genfun::AbsFunction & y() const
Definition: GeoXPEngine.cxx:86
python.PhysicalConstants.c_light
float c_light
Definition: PhysicalConstants.py:63
GeoXPEngine::px
const Genfun::AbsFunction & px() const
Definition: GeoXPEngine.cxx:92
GeoXPEngine::x
const Genfun::AbsFunction & x() const
Definition: GeoXPEngine.cxx:83
GeoXPEngine::m_px
const Genfun::AbsFunction * m_px
Definition: GeoXPEngine.h:58
GeoXPEngine::m_x
const Genfun::AbsFunction * m_x
Definition: GeoXPEngine.h:55
GeoXPEngine::m_py
const Genfun::AbsFunction * m_py
Definition: GeoXPEngine.h:59
extractSporadic.q
list q
Definition: extractSporadic.py:98
GeoXPEngine::m_z
const Genfun::AbsFunction * m_z
Definition: GeoXPEngine.h:57
I
#define I(x, y, z)
Definition: MD5.cxx:116
TRTCalib_cfilter.p0
p0
Definition: TRTCalib_cfilter.py:129