ATLAS Offline Software
Loading...
Searching...
No Matches
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
14GeoXPEngine::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
83const Genfun::AbsFunction & GeoXPEngine::x() const {
84 return *m_x;
85}
86const Genfun::AbsFunction & GeoXPEngine::y() const {
87 return *m_y;
88}
89const Genfun::AbsFunction & GeoXPEngine::z() const {
90 return *m_z;
91}
92const Genfun::AbsFunction & GeoXPEngine::px() const {
93 return *m_px;
94}
95const Genfun::AbsFunction & GeoXPEngine::py() const {
96 return *m_py;
97}
98const Genfun::AbsFunction & GeoXPEngine::pz() const {
99 return *m_pz;
100}
#define I(x, y, z)
Definition MD5.cxx:116
const Genfun::AbsFunction * m_pz
Definition GeoXPEngine.h:60
const Genfun::AbsFunction * m_z
Definition GeoXPEngine.h:57
const Genfun::AbsFunction * m_y
Definition GeoXPEngine.h:56
GeoXPEngine(const Genfun::AbsFunction &Bx, const Genfun::AbsFunction &By, const Genfun::AbsFunction &Bz, const HepGeom::Point3D< double > &x0, const CLHEP::HepLorentzVector &p0, double q)
const Genfun::AbsFunction & px() const
const Genfun::AbsFunction & py() const
const Genfun::AbsFunction * m_py
Definition GeoXPEngine.h:59
const Genfun::AbsFunction & pz() const
const Genfun::AbsFunction & y() const
const Genfun::AbsFunction * m_x
Definition GeoXPEngine.h:55
const Genfun::AbsFunction & z() const
const Genfun::AbsFunction * m_px
Definition GeoXPEngine.h:58
const Genfun::AbsFunction & x() const