Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DReferenceTrajectory.h
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: DReferenceTrajectory.h
4 // Created: Wed Jul 19 13:42:58 EDT 2006
5 // Creator: davidl (on Darwin swire-b241.jlab.org 8.7.0 powerpc)
6 //
7 
8 #ifndef _DReferenceTrajectory_
9 #define _DReferenceTrajectory_
10 
11 #include <vector>
12 using std::vector;
13 
14 #include <TMatrixFSym.h>
15 #include <TMatrix.h>
16 
17 #include <HDGEOMETRY/DGeometry.h>
18 #include <DVector3.h>
19 #include <DVector2.h>
20 #include <JANA/jerror.h>
21 #include <DMatrixDSym.h>
22 #include <DMatrix.h>
23 #include <PID/DKinematicData.h>
24 #include "DResourcePool.h"
25 
26 #include <DCoordinateSystem.h>
27 
28 class DMagneticFieldMap;
29 class DTrackCandidate;
30 class DRootGeom;
31 
33 
34  /// This class is a utility class used by the TRACKING package. It
35  /// is used to swim a particle through the (inhomogeneous) magnetic
36  /// field, accounting for energy loss in the geometry, and recording
37  /// each step so that derivatives and distances can be calculated.
38  /// Because this uses the coordinates defined in the reference
39  /// trajectory method (B. Mecking Nucl. Instr. and Methods.
40  /// 203 (1982) 299-305), the angles needed to rotate into the
41  /// lab frame are saved as well. This used the DMagneticFieldStepper
42  /// class for swimming through the field.
43 
44  public:
45 
49  };
50  enum state_t{
51  kPx,
52  kPy,
53  kPz,
54  kX,
55  kY,
56  kZ,
58  };
59 
61  public:
63  double Ro;
64  DVector3 B; // components of magnetic field
65  double s; // distance along RT
66  double t; // flight time
67  double cov_t_t; //flight time variance
68  double cov_px_t,cov_py_t,cov_pz_t; // correlations
69 
70  // The following are used to calculate the covariance matrix for MULS
71  double itheta02; // running sum of MULS angle theta_0 squared
72  double itheta02s; // ditto but times s
73  double itheta02s2; // ditto but times s^2
74  double invX0;
75  };
76 
78  , double q=1.0
79  , swim_step_t *swim_steps=NULL
80  , int max_swim_steps=0
81  , double step_size=-1.0);
84  virtual ~DReferenceTrajectory();
85  virtual const char* className(void){return static_className();}
86  static const char* static_className(void){return "DReferenceTrajectory";}
87 
88  void CopyWithShift(const DReferenceTrajectory *rt, DVector3 shift);
89  void Reset(void);
90 
91  double DistToRT(double x, double y, double z) const {return DistToRT(DVector3(x,y,z));}
92  double DistToRT(DVector3 hit, double *s=NULL,DetectorSystem_t detector=SYS_NULL) const;
93  double DistToRTwithTime(DVector3 hit, double *s=NULL,
94  double *t=NULL,double *var_t=NULL,
95  DetectorSystem_t detector=SYS_NULL) const;
96  double DistToRT(const DCoordinateSystem *wire, double *s=NULL) const;
97  double DistToRTBruteForce(const DCoordinateSystem *wire, double *s=NULL) const;
98  double DistToRT(const DCoordinateSystem *wire, const swim_step_t *step, double *s=NULL) const;
99  double DistToRTBruteForce(const DCoordinateSystem *wire, const swim_step_t *step, double *s=NULL) const;
100  double Straw_dx(const DCoordinateSystem *wire, double radius) const;
101  swim_step_t* FindClosestSwimStep(const DCoordinateSystem *wire, int *istep_ptr=NULL) const;
102  swim_step_t* FindClosestSwimStep(const DVector3 &origin, DVector3 norm, int *istep_ptr=NULL) const;
103  swim_step_t* FindPlaneCrossing(const DVector3 &origin, DVector3 norm,int first_i=0, DetectorSystem_t detector=SYS_NULL) const;
104  void Swim(const DVector3 &pos, const DVector3 &mom, double q=-1000.0,const TMatrixFSym *cov=NULL, double smax=2000.0, const DCoordinateSystem *wire=NULL);
105  void FastSwim(const DVector3 &pos, const DVector3 &mom, double q,double smax=2000.0, double zmin=-100.,double zmax=1000.0);
106  void FastSwimForHitSelection(const DVector3 &pos, const DVector3 &mom, double q);
107 
108  void FastSwim(const DVector3 &pos, const DVector3 &mom,
109  DVector3 &last_pos, DVector3 &last_mom,
110  double q,double smax=2000.0,
111  const DCoordinateSystem *wire=NULL);
112  void FastSwim(const DVector3 &pos, const DVector3 &mom,
113  DVector3 &last_pos, DVector3 &last_mom,double q,
114  const DVector3 &origin,const DVector3 &dir,
115  double smax=2000.0
116  );
117 
118  int InsertSteps(const swim_step_t *start_step, double delta_s, double step_size=0.02);
119  jerror_t GetIntersectionWithPlane(const DVector3 &origin, const DVector3 &norm, DVector3 &pos, double *s=NULL,double *t=NULL,double *var_t=NULL,DetectorSystem_t detector=SYS_NULL) const;
120  jerror_t GetIntersectionWithPlane(const DVector3 &origin, const DVector3 &norm, DVector3 &pos, DVector3 &p_at_intersection,double *s=NULL,double *t=NULL,double *var_t=NULL,DetectorSystem_t detector=SYS_NULL) const;
121  jerror_t GetIntersectionWithRadius(double R,DVector3 &mypos,
122  double *s=NULL,
123  double *t=NULL,
124  DVector3 *dir=NULL) const;
125  DVector3 GetLastDOCAPoint(void) const;
126  void GetLastDOCAPoint(DVector3 &pos, DVector3 &mom) const;
127  jerror_t FindPOCAtoPoint(const DVector3 &point,
128  const DMatrixDSym *covpoint,
129  DKinematicData *track_kd,
130  double &doca, double &var_doca) const;
131  jerror_t FindPOCAtoLine(const DVector3 &origin,
132  const DVector3 &dir,
133  const DMatrixDSym *covpoint,
134  DKinematicData *track_kd,
135  DVector3 &commonpos, double &doca, double &var_doca) const;
136 
137  double GetLastDistAlongWire(void) const {return last_dist_along_wire;}
138  void SetStepSize(double step_size){this->step_size=step_size;}
139  void SetDRootGeom(const DRootGeom *RootGeom){this->RootGeom = RootGeom;}
140  void SetDGeometry(const DGeometry *geom){this->geom = geom;}
141  const DRootGeom* GetDRootGeom(void) const {return RootGeom;}
142  const DGeometry* GetDGeometry(void) const {return geom;}
143  const DMagneticFieldMap* GetBfield(void) const {return bfield;}
144  double GetMass(void) const {return mass;}
145  double GetStepSize(void) const {return step_size;}
146  void SetMass(double mass){this->mass = mass;this->mass_sq=mass*mass;}
147  void SetPLossDirection(direction_t direction){ploss_direction=direction;}
151  double GetBoundaryStepFraction(void) const {return BOUNDARY_STEP_FRACTION;}
152  double GetMinStepSize(void) const {return MIN_STEP_SIZE;}
153  double GetMaxStepSize(void) const {return MAX_STEP_SIZE;}
154  inline double dPdx_from_A_Z_rho(double ptot, double A, double Z, double density) const;
155  inline double dPdx(double ptot, double KrhoZ_overA, double rhoZ_overA,double LogI) const;
156  bool GetHitCDCEndplate(void) const {return hit_cdc_endplate;}
161 
162  int GetDebugLevel(void){return debug_level;}
163  void SetDebugLevel(int new_level){debug_level=new_level;}
164 
165  void Dump(double zmin=-1000.0, double zmax=1000.0);
166 
167  const swim_step_t *GetLastSwimStep(void) const {return last_swim_step;}
168 
169 
170  jerror_t IntersectTracks(const DReferenceTrajectory *rt2,
171  DKinematicData *track1_kd,
172  DKinematicData *track2_kd,
173  DVector3 &pos, double &doca,
174  double &var_doca, double &vertex_chi2,
175  bool DoFitVertex=false) const;
176  jerror_t PropagateCovariance(double ds,double q,
177  double mass_sq,const DVector3 &mom,
178  const DVector3 &pos,const DVector3 &B,
179  TMatrixFSym &C) const;
180 
181  jerror_t BrentsAlgorithm(DVector3 &pos1,DVector3 &mom1,
182  DVector3 &pos2,DVector3 &mom2,
183  double ds,double q2,
184  double &doca) const;
185 
186  void FitVertex(const DVector3 &pos1,const DVector3 &mom1,
187  const DVector3 &pos2,const DVector3 &mom2,
188  const TMatrixFSym &cov1,
189  const TMatrixFSym &cov2,
190  DVector3 &pos,double &vertex_chi2,
191  double q1=1., double q2=1.) const;
192 
193 
196  float q;
198  double Rsqmax_interior; // Maximum squared radius (in cm^2) corresponding to inside of BCAL
199  double Rsqmax_exterior; // Maximum squared radius (in cm^2) corresponding to outside of BCAL
200 
201  protected:
202 
204 
208  double step_size;
211  const DGeometry *geom;
214  double zmin_track_boundary; // boundary at which to stop swimming
215  double zmax_track_boundary; // boundary at which to stop swimming
216 
217  mutable double last_phi; ///< last phi found in DistToRT
218  mutable const swim_step_t* last_swim_step; ///< last swim step used in DistToRT
219  mutable double last_dist_along_wire;
220  mutable double last_dz_dphi;
221 
222  double mass,mass_sq;
224 
228 
229  static thread_local shared_ptr<DResourcePool<TMatrixFSym>> dResourcePool_TMatrixFSym;
230 
231  private:
232  DReferenceTrajectory(){} // force use of constructor with arguments.
233 
234 };
235 
236 #endif // _DReferenceTrajectory_
237 
int InsertSteps(const swim_step_t *start_step, double delta_s, double step_size=0.02)
jerror_t BrentsAlgorithm(DVector3 &pos1, DVector3 &mom1, DVector3 &pos2, DVector3 &mom2, double ds, double q2, double &doca) const
double Straw_dx(const DCoordinateSystem *wire, double radius) const
bool GetCheckMaterialBoundaries(void) const
double GetBoundaryStepFraction(void) const
void FastSwim(const DVector3 &pos, const DVector3 &mom, double q, double smax=2000.0, double zmin=-100., double zmax=1000.0)
void CopyWithShift(const DReferenceTrajectory *rt, DVector3 shift)
const swim_step_t * GetLastSwimStep(void) const
virtual const char * className(void)
TVector3 DVector3
Definition: DVector3.h:14
Definition: GlueX.h:16
void SetDebugLevel(int new_level)
const DMagneticFieldMap * bfield
Double_t x[NCHANNELS]
Definition: st_tw_resols.C:39
#define y
DVector3 GetLastDOCAPoint(void) const
void SetMass(double mass)
swim_step_t * FindPlaneCrossing(const DVector3 &origin, DVector3 norm, int first_i=0, DetectorSystem_t detector=SYS_NULL) const
void Swim(const DVector3 &pos, const DVector3 &mom, double q=-1000.0, const TMatrixFSym *cov=NULL, double smax=2000.0, const DCoordinateSystem *wire=NULL)
double dPdx(double ptot, double KrhoZ_overA, double rhoZ_overA, double LogI) const
double zmax
void SetZminTrackingBoundary(double zmin)
DetectorSystem_t
Definition: GlueX.h:15
bool GetHitCDCEndplate(void) const
double GetLastDistAlongWire(void) const
TMatrixDSym DMatrixDSym
Definition: DMatrixDSym.h:13
double GetZmaxTrackingBoundary(void)
jerror_t IntersectTracks(const DReferenceTrajectory *rt2, DKinematicData *track1_kd, DKinematicData *track2_kd, DVector3 &pos, double &doca, double &var_doca, double &vertex_chi2, bool DoFitVertex=false) const
void SetDGeometry(const DGeometry *geom)
const DGeometry * GetDGeometry(void) const
swim_step_t * FindClosestSwimStep(const DCoordinateSystem *wire, int *istep_ptr=NULL) const
double GetStepSize(void) const
static thread_local shared_ptr< DResourcePool< TMatrixFSym > > dResourcePool_TMatrixFSym
double GetMaxStepSize(void) const
void FastSwimForHitSelection(const DVector3 &pos, const DVector3 &mom, double q)
double DistToRT(double x, double y, double z) const
void SetCheckMaterialBoundaries(bool check_material_boundaries)
double DistToRTBruteForce(const DCoordinateSystem *wire, double *s=NULL) const
double DistToRTwithTime(DVector3 hit, double *s=NULL, double *t=NULL, double *var_t=NULL, DetectorSystem_t detector=SYS_NULL) const
jerror_t FindPOCAtoPoint(const DVector3 &point, const DMatrixDSym *covpoint, DKinematicData *track_kd, double &doca, double &var_doca) const
direction_t GetPLossDirection(void) const
void Dump(double zmin=-1000.0, double zmax=1000.0)
double GetMass(void) const
void SetDRootGeom(const DRootGeom *RootGeom)
const DMagneticFieldMap * GetBfield(void) const
double dPdx_from_A_Z_rho(double ptot, double A, double Z, double density) const
void SetZmaxTrackingBoundary(double zmax)
&lt;A href=&quot;index.html#legend&quot;&gt; &lt;IMG src=&quot;CORE.png&quot; width=&quot;100&quot;&gt; &lt;/A&gt;
void FitVertex(const DVector3 &pos1, const DVector3 &mom1, const DVector3 &pos2, const DVector3 &mom2, const TMatrixFSym &cov1, const TMatrixFSym &cov2, DVector3 &pos, double &vertex_chi2, double q1=1., double q2=1.) const
jerror_t GetIntersectionWithRadius(double R, DVector3 &mypos, double *s=NULL, double *t=NULL, DVector3 *dir=NULL) const
DReferenceTrajectory & operator=(const DReferenceTrajectory &rt)
const swim_step_t * last_swim_step
last swim step used in DistToRT
double last_phi
last phi found in DistToRT
static const char * static_className(void)
direction_t
This class is a utility class used by the TRACKING package. It is used to swim a particle through the...
const DRootGeom * GetDRootGeom(void) const
double GetMinStepSize(void) const
jerror_t FindPOCAtoLine(const DVector3 &origin, const DVector3 &dir, const DMatrixDSym *covpoint, DKinematicData *track_kd, DVector3 &commonpos, double &doca, double &var_doca) const
void SetPLossDirection(direction_t direction)
TDirectory * dir
Definition: bcal_hist_eff.C:31
double zmin
const DRootGeom * RootGeom
double GetZminTrackingBoundary(void)
void SetStepSize(double step_size)
jerror_t GetIntersectionWithPlane(const DVector3 &origin, const DVector3 &norm, DVector3 &pos, double *s=NULL, double *t=NULL, double *var_t=NULL, DetectorSystem_t detector=SYS_NULL) const
jerror_t PropagateCovariance(double ds, double q, double mass_sq, const DVector3 &mom, const DVector3 &pos, const DVector3 &B, TMatrixFSym &C) const