QwAnalysis
QwRayTracer.h
Go to the documentation of this file.
1 /*! \file QwRayTracer.h
2  *
3  * \author Jie Pan <jpan@jlab.org>
4  * \author Wouter Deconinck <wdconinc@mit.edu>
5  *
6  * \date Thu Nov 26 11:44:51 CST 2009
7  * \brief Definition of the ray-tracing bridging method for R2/R3 partial tracks
8  *
9  * \ingroup QwTracking
10  *
11  * Integrating the equations of motion for electrons in the QTOR.
12  * The 4'th order Runge-Kutta method is used.
13  *
14  * The Newton-Raphson method is used to solve for `the momentum of the track.
15  *
16  */
17 
18 
19 #ifndef __QWRAYTRACER_H__
20 #define __QWRAYTRACER_H__
21 
22 // System headers
23 #include <iostream>
24 #include <vector>
25 
26 // ROOT headers
27 #include <TSystem.h>
28 #include <TFile.h>
29 #include <TTree.h>
30 #include <TVector3.h>
31 #include <TVectorD.h>
32 #include <TMatrixD.h>
33 #include <TRandom3.h>
34 #include <TStopwatch.h>
35 
36 // Qweak headers
37 #include "QwOptions.h"
38 #include "VQwBridgingMethod.h"
39 #include "QwPartialTrack.h"
40 #include "QwMagneticField.h"
41 
42 
44 
45  public:
46 
47  /// Default constructor
48  QwRayTracer(QwOptions& options);
49  /// Destructor
50  virtual ~QwRayTracer();
51 
52  /// \brief Define command line and config file options
53  static void DefineOptions(QwOptions& options);
54  /// \brief Process command line and config file options
55  void ProcessOptions(QwOptions& options);
56 
57  /// \brief Load the magnetic field based on config file options
58  bool LoadMagneticFieldMap(QwOptions& options);
59 
60  /// Get magnetic field current
61  double GetMagneticFieldCurrent() const {
62  if (fBfield) return fBfield->GetActualCurrent();
63  else return 0.0;
64  }
65  /// Set magnetic field current
66  void SetMagneticFieldCurrent(const double current) {
67  if (fBfield) fBfield->SetActualCurrent(current);
68  }
69 
70  /// \brief Bridge from the front to back partial track
71  const QwTrack* Bridge(const QwPartialTrack* front, const QwPartialTrack* back);
72 
73  /// \brief Runge-Kutta numerical integration by Butcher tableau
74  int IntegrateRK(
75  const TMatrixD& A,
76  const TMatrixD& b,
77  TVector3& r,
78  TVector3& v,
79  const double p,
80  const double z,
81  const double h,
82  const double epsilon);
83 
84  /// \brief Runge-Kutta numerical integration
85  int IntegrateRK(
86  TVector3& r,
87  TVector3& v,
88  const double p,
89  const double z,
90  const int order,
91  const double h);
92 
93  private:
94 
95  /// Magnetic field (static)
97 
98  /// Runge-Kutta method order
100  /// Runge-Kutta fixed step size for order 4 or less
102  /// Runge-Kutta minimum and maximum step size for adaptive step
103  double fIntegrationMinimumStep; ///< Minimum step size
104  double fIntegrationMaximumStep; ///< Maximum step size
105  double fIntegrationTolerance; ///< Allowable truncation error in adaptive step
106 
107  /// Newton's method optimization variable
109  /// Optimization variable from position and direction
110  double GetOptimizationVariable(const TVector3 &position, const TVector3 &direction) const {
111  switch (fOptimizationVariable) {
112  case 0: return position.Perp(); // perpendicular position at matching plane
113  case 1: return direction.Theta(); // polar angle of direction at matching plane
114  // since direction is normalized, sin(direction.Theta()) == direction.Perp()
115  default: return position.Perp(); // case 0 is default
116  }
117  }
118 
119  /// Newton's method optimization resolution: continue optimization until the difference
120  /// between optimization variable after swimming and optimization variable of target
121  /// partial track in back chamber is below this value
123 
124  /// Newton's method step size in momentum
126 
127  /// Newton's method initial momentum
129 
130  /// Starting position for magnetic field swimming
132  /// Ending position for magnetic field swimming
133  double fEndPosition;
134 
135  Double_t fBdl; ///< scalar field integrals
136  Double_t fBdlx; ///< x component of the field integral
137  Double_t fBdly; ///< y component of the field integral
138  Double_t fBdlz; ///< z component of the field integral
139 
140 }; // class QwRayTracer
141 
142 #endif // __QWRAYTRACER_H__
bool LoadMagneticFieldMap(QwOptions &options)
Load the magnetic field based on config file options.
Definition: QwRayTracer.cc:77
static QwMagneticField * fBfield
Magnetic field (static)
Definition: QwRayTracer.h:96
static void DefineOptions(QwOptions &options)
Define command line and config file options.
Definition: QwRayTracer.cc:93
Magnetic field map object.
double fOptimizationResolution
Definition: QwRayTracer.h:122
Double_t fBdly
y component of the field integral
Definition: QwRayTracer.h:137
An options class.
Definition: QwOptions.h:133
double fStartPosition
Starting position for magnetic field swimming.
Definition: QwRayTracer.h:131
double fIntegrationStep
Runge-Kutta fixed step size for order 4 or less.
Definition: QwRayTracer.h:101
int fOptimizationVariable
Newton&#39;s method optimization variable.
Definition: QwRayTracer.h:108
Definition of the partial track class.
Double_t fBdl
scalar field integrals
Definition: QwRayTracer.h:135
void SetActualCurrent(const double current)
Set the actual current.
double GetMagneticFieldCurrent() const
Get magnetic field current.
Definition: QwRayTracer.h:61
QwRayTracer(QwOptions &options)
Default constructor.
Definition: QwRayTracer.cc:48
double fIntegrationMaximumStep
Maximum step size.
Definition: QwRayTracer.h:104
Interface to the various bridging methods.
Contains the complete track as a concatenation of partial tracks.
Definition: QwTrack.h:30
void ProcessOptions(QwOptions &options)
Process command line and config file options.
Definition: QwRayTracer.cc:150
double fInitialMomentum
Newton&#39;s method initial momentum.
Definition: QwRayTracer.h:128
const QwTrack * Bridge(const QwPartialTrack *front, const QwPartialTrack *back)
Bridge from the front to back partial track.
Definition: QwRayTracer.cc:178
Double_t fBdlx
x component of the field integral
Definition: QwRayTracer.h:136
int fIntegrationOrder
Runge-Kutta method order.
Definition: QwRayTracer.h:99
An options class which parses command line, config file and environment.
double fEndPosition
Ending position for magnetic field swimming.
Definition: QwRayTracer.h:133
Definition of the bridging method interface.
double fIntegrationMinimumStep
Runge-Kutta minimum and maximum step size for adaptive step.
Definition: QwRayTracer.h:103
double GetOptimizationVariable(const TVector3 &position, const TVector3 &direction) const
Optimization variable from position and direction.
Definition: QwRayTracer.h:110
double fIntegrationTolerance
Allowable truncation error in adaptive step.
Definition: QwRayTracer.h:105
double fMomentumStep
Newton&#39;s method step size in momentum.
Definition: QwRayTracer.h:125
Contains the straight part of a track in one region only.
int IntegrateRK(const TMatrixD &A, const TMatrixD &b, TVector3 &r, TVector3 &v, const double p, const double z, const double h, const double epsilon)
Runge-Kutta numerical integration by Butcher tableau.
Definition: QwRayTracer.cc:510
double GetActualCurrent() const
Get the actual current.
void SetMagneticFieldCurrent(const double current)
Set magnetic field current.
Definition: QwRayTracer.h:66
Double_t fBdlz
z component of the field integral
Definition: QwRayTracer.h:138
virtual ~QwRayTracer()
Destructor.
Definition: QwRayTracer.cc:66