StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StHelixModel.cxx
1 /***************************************************************************
2  *
3  * $Id: StHelixModel.cxx,v 2.12 2009/11/23 16:34:06 fisyak Exp $
4  *
5  * Author: Thomas Ullrich, Sep 1999
6  ***************************************************************************
7  *
8  * Description:
9  *
10  ***************************************************************************
11  *
12  * $Log: StHelixModel.cxx,v $
13  * Revision 2.12 2009/11/23 16:34:06 fisyak
14  * Cleanup, remove dependence on dst tables, clean up software monitors
15  *
16  * Revision 2.11 2004/07/15 16:36:24 ullrich
17  * Removed all clone() declerations and definitions. Use StObject::clone() only.
18  *
19  * Revision 2.10 2003/12/04 03:51:11 perev
20  * Set small but non zero curvature
21  *
22  * Revision 2.9 2003/04/09 17:59:39 genevb
23  * Add setMomentum function
24  *
25  * Revision 2.8 2001/07/21 18:04:02 ullrich
26  * Added code to helix() in order to stay backwards compatible.
27  *
28  * Revision 2.7 2001/07/19 16:18:46 ullrich
29  * Added missing method helicity().
30  *
31  * Revision 2.6 2001/07/17 22:23:30 ullrich
32  * Added helicity to track geometry.
33  *
34  * Revision 2.5 2001/04/05 04:00:50 ullrich
35  * Replaced all (U)Long_t by (U)Int_t and all redundant ROOT typedefs.
36  *
37  * Revision 2.4 2001/03/24 03:34:49 perev
38  * clone() -> clone() const
39  *
40  * Revision 2.3 2000/03/17 14:52:23 ullrich
41  * Method helix() now checks for q=0 and sets
42  * curvature = 0 (which it should be anyhow).
43  *
44  * Revision 2.2 1999/10/28 22:25:42 ullrich
45  * Adapted new StArray version. First version to compile on Linux and Sun.
46  *
47  * Revision 2.1 1999/10/13 19:44:49 ullrich
48  * Initial Revision
49  *
50  **************************************************************************/
51 #include "StHelixModel.h"
52 #include "StThreeVectorF.hh"
53 #include "SystemOfUnits.h"
54 #include "PhysicalConstants.h"
55 
56 ClassImp(StHelixModel)
57 
58 static const char rcsid[] = "$Id: StHelixModel.cxx,v 2.12 2009/11/23 16:34:06 fisyak Exp $";
59 
60 StHelixModel::StHelixModel() : mModel(helixModel)
61 {
62  mPsi = 0;
63  mCurvature = 1.e-6;
64  mDipAngle = 0;
65  mCharge = 0;
66  mHelicity = 0;
67 }
68 
69 StHelixModel::StHelixModel(short q, float psi, float c, float dip,
70  const StThreeVectorF& o, const StThreeVectorF& p, short h)
71  : mModel(helixModel),
72  mCharge(q),
73  mPsi(psi),
74  mCurvature(c+1.e-10),
75  mDipAngle(dip),
76  mOrigin(o),
77  mMomentum(p),
78  mHelicity(h)
79 {/* noop */}
80 
81 StHelixModel::~StHelixModel() { /* noop */ }
82 
84 StHelixModel::copy() const { return new StHelixModel(*this); }
85 
86 StTrackModel
87 StHelixModel::model() const {return mModel;}
88 
89 short
90 StHelixModel::charge() const {return mCharge;}
91 
92 short
93 StHelixModel::helicity() const {return mHelicity;}
94 
95 double
96 StHelixModel::curvature() const {return mCurvature;}
97 
98 double
99 StHelixModel::psi() const {return mPsi;}
100 
101 double
102 StHelixModel::dipAngle() const {return mDipAngle;}
103 
104 const StThreeVectorF&
105 StHelixModel::origin() const {return mOrigin;}
106 
107 const StThreeVectorF&
108 StHelixModel::momentum() const {return mMomentum;}
109 
111 StHelixModel::helix() const
112 {
113  //
114  // No charge no curvature.
115  // Agreement is to use q=0 as equivalent
116  // to saying curvature = 0. It should be
117  // 0 but we better make sure.
118  //
119  double curvature = mCurvature;
120  if (mCharge == 0) curvature = 0;
121 
122  //
123  // h = -sign(q*B)
124  // mHelicity is needed at this point. It is NOT
125  // filled from the constructor using the table
126  // but has to be provided separately.
127  //
128  // For B=0, h is ill defined and we can use
129  // +1 or -1. Both work as long as the phase
130  // is calculated correctly. Here we use the
131  // +1 convention.
132  //
133  int h = mHelicity;
134 
135  //
136  // Need to stay backwards compatible. All we can do here
137  // is to assume B > 0. This is OK since the inverse field
138  // and the introduction of mHelicity happened at the same time.
139  //
140  if (h == 0) {
141  if (mCharge == 0)
142  h = 1;
143  else if (mCharge > 0)
144  h = -1;
145  else
146  h = 1;
147  }
148  // end backwards compatibility fix
149 
150 
151  if (mCharge == 0) h = 1;
152 
153  double phase = mPsi-h*pi/2;
154 
155  return StPhysicalHelixD(curvature, // 1/cm
156  mDipAngle, // radian
157  phase, // radian
158  mOrigin, // cm
159  h);
160 }
161 
162 void
163 StHelixModel::setCharge(short val) { mCharge = val; }
164 
165 void
166 StHelixModel::setHelicity(short val) { mHelicity = val; }
167 
168 void
169 StHelixModel::setCurvature(double val) { mCurvature = val; }
170 
171 void
172 StHelixModel::setPsi(double val) { mPsi = val; }
173 
174 void
175 StHelixModel::setDipAngle(double val) { mDipAngle = val; }
176 
177 void
178 StHelixModel::setOrigin(const StThreeVectorF& val) { mOrigin = val; }
179 
180 void
181 StHelixModel::setMomentum(const StThreeVectorF& val) { mMomentum = val; }