Belle II Software  release-08-01-10
HelixTrackModel.cc
1 /* Copyright 2008-2010, Technische Universitaet Muenchen,
2  Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch
3 
4  This file is part of GENFIT.
5 
6  GENFIT is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published
8  by the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  GENFIT is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with GENFIT. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #include "HelixTrackModel.h"
21 #include <FieldManager.h>
22 
23 #include <assert.h>
24 #include <math.h>
25 
26 namespace genfit {
27 
28 HelixTrackModel::HelixTrackModel(const TVector3& pos, const TVector3& mom, double charge) {
29 
30  mom_ = mom.Mag();
31 
33 
34  // B must point in Z direction
35  assert(B.X() == 0);
36  assert(B.Y() == 0);
37 
38  double Bz = B.Z();
39 
40  // calc helix parameters
41  TVector3 dir2D(mom);
42  dir2D.SetZ(0);
43  dir2D.SetMag(1.);
44  R_ = 100.*mom.Perp()/(0.0299792458*Bz) / fabs(charge);
45  sgn_ = 1;
46  if (charge<0) sgn_=-1.;
47  center_ = pos + sgn_ * R_ * dir2D.Orthogonal();
48  alpha0_ = (pos-center_).Phi();
49 
50  theta_ = mom.Theta();
51 
52  //std::cout<<"radius " << R_ << " center ";
53  //center_.Print();
54 
55 }
56 
57 
58 TVector3 HelixTrackModel::getPos(double tracklength) const {
59 
60  TVector3 pos;
61 
62  double angle = alpha0_ - sgn_ * tracklength / R_ * sin(theta_);
63 
64  TVector3 radius(R_,0,0);
65  radius.SetPhi(angle);
66  pos = center_ + radius;
67  pos.SetZ(center_.Z() - sgn_ * ((alpha0_-angle)*R_ * tan(theta_-M_PI/2.)) );
68 
69  return pos;
70 }
71 
72 void HelixTrackModel::getPosMom(double tracklength, TVector3& pos, TVector3& mom) const {
73 
74  double angle = alpha0_ - sgn_ * tracklength / R_ * sin(theta_);
75 
76  TVector3 radius(R_,0,0);
77  radius.SetPhi(angle);
78  pos = center_ + radius;
79  pos.SetZ(center_.Z() - sgn_ * ((alpha0_-angle)*R_ * tan(theta_-M_PI/2.)) );
80 
81  mom.SetXYZ(1,1,1);
82  mom.SetTheta(theta_);
83  mom.SetPhi(angle - sgn_*M_PI/2.);
84  mom.SetMag(mom_);
85 
86  /*std::cout<<"tracklength " << tracklength << "\n";
87  std::cout<<"angle " << angle << "\n";
88  std::cout<<"radius vector "; radius.Print();
89  std::cout<<"pos "; pos.Print();
90  std::cout<<"mom "; mom.Print();*/
91 
92 }
93 
94 
95 } /* End of namespace genfit */
TVector3 getFieldVal(const TVector3 &position)
This does NOT use the cache!
Definition: FieldManager.h:63
static FieldManager * getInstance()
Get singleton instance.
Definition: FieldManager.h:119
double tan(double a)
tan for double
Definition: beamHelpers.h:31
Defines for I/O streams used for error and debug printing.