Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DMagneticFieldStepper.h
Go to the documentation of this file.
1 
2 
3 
4 #ifndef __DMAGNETICFIELDSTEPPER_H__
5 #define __DMAGNETICFIELDSTEPPER_H__
6 
7 #include <math.h>
8 
9 #include <DVector3.h>
10 #include "JANA/jerror.h"
11 
13 
14 
15 /// DMagneticFieldStepper class
16 ///
17 /// This class will step a particle track through a magnetic
18 /// field. It has methods to find the point on the track which
19 /// comes closest to a specified point in space.
20 
21 
23 {
24  public:
25 
26  DMagneticFieldStepper(const DMagneticFieldMap *map, double q=1.0);
27  DMagneticFieldStepper(const DMagneticFieldMap *map, double q, const DVector3 *x, const DVector3 *p);
29 
30  jerror_t SetStartingParams(double q, const DVector3 *x, const DVector3 *p);
31  jerror_t SetMagneticFieldMap(const DMagneticFieldMap *map);
32  jerror_t SetStepSize(double step);
33  void SetCharge(double q){this->q = q;}
34  double Step(DVector3 *newpos=NULL, DVector3 *B=NULL,double stepsize=0.0);
35  double FastStep(double stepsize=0.0);
36 
38  void GetBField(DVector3 &B){B = this->B;}
39  void GetMomentum(DVector3 &mom){mom = this->mom;}
40  void GetPosition(DVector3 &pos){pos = this->pos;}
41  double GetCharge(void){return q;}
42  void GetPosMom(DVector3 &pos, DVector3 &mom){pos=this->pos; mom=this->mom;}
43  bool SwimToPlane(DVector3 &pos, DVector3 &mom, const DVector3 &origin, const DVector3 &norm, double *pathlen=NULL);
44  bool DistToPlane(DVector3 &pos, const DVector3 &origin, const DVector3 &norm);
45  bool SwimToRadius(DVector3 &pos, DVector3 &mom, double R, double *pathlen=NULL);
46  bool DistToRadius(DVector3 &pos, double R);
47 
48  inline double GetRo(void){return fabs(Ro);}
49  inline double Getdz_dphi(void){return Ro*mom.Dot(zdir)/mom.Dot(ydir);}
50  inline double GetStepSize(void) const{return stepsize;}
51 
52  bool SwimToPOCAtoBeamLine(double q,DVector3 &pos, DVector3 &mom);
53 
54  private:
55  const DMagneticFieldMap *bfield; ///< pointer to magnetic field map
56  double stepsize; ///< maximum distance(cm) to move particle when Step() is called
57  double last_stepsize;///< stepsize (cm) used for last step
58  double q; ///< electric charge in units of e
59  DVector3 pos; ///< current position of particle
60  DVector3 mom; ///< current location of particle
61  DVector3 start_pos; ///< starting position of track
62  DVector3 start_mom; ///< starting momentum of track
64  double Ro, Rp;
66 
68 
69  void CalcDirs(double *Bvals=NULL);
70 };
71 
72 #endif // __DMAGNETICFIELDSTEPPER_H__
void GetBField(DVector3 &B)
bool SwimToPlane(DVector3 &pos, DVector3 &mom, const DVector3 &origin, const DVector3 &norm, double *pathlen=NULL)
TVector3 DVector3
Definition: DVector3.h:14
bool DistToRadius(DVector3 &pos, double R)
Double_t x[NCHANNELS]
Definition: st_tw_resols.C:39
double q
electric charge in units of e
DVector3 mom
current location of particle
bool SwimToRadius(DVector3 &pos, DVector3 &mom, double R, double *pathlen=NULL)
void GetPosMom(DVector3 &pos, DVector3 &mom)
DMagneticFieldStepper class.
const DMagneticFieldMap * bfield
pointer to magnetic field map
jerror_t SetStartingParams(double q, const DVector3 *x, const DVector3 *p)
DVector3 start_pos
starting position of track
double last_stepsize
stepsize (cm) used for last step
void CalcDirs(double *Bvals=NULL)
double GetStepSize(void) const
void GetMomentum(DVector3 &mom)
DMagneticFieldStepper(const DMagneticFieldMap *map, double q=1.0)
bool SwimToPOCAtoBeamLine(double q, DVector3 &pos, DVector3 &mom)
double FastStep(double stepsize=0.0)
DVector3 pos
current position of particle
void GetPosition(DVector3 &pos)
double stepsize
maximum distance(cm) to move particle when Step() is called
bool DistToPlane(DVector3 &pos, const DVector3 &origin, const DVector3 &norm)
DVector3 start_mom
starting momentum of track
double Step(DVector3 *newpos=NULL, DVector3 *B=NULL, double stepsize=0.0)
jerror_t SetMagneticFieldMap(const DMagneticFieldMap *map)
jerror_t SetStepSize(double step)
void GetDirs(DVector3 &xdir, DVector3 &ydir, DVector3 &zdir)