StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StTrackChair.cxx
1 #include "StTrackChair.h"
2 #include "StHelixD.hh"
3 const Char_t *StTrackChair::trackTableList[] = {"tpt_track_st","dst_track_st"};
4 
5 ClassImp(StTrackChair)
6 //_____________________________________________________________________________
7 static Int_t CheckName(const Char_t *key, const Char_t **values, Int_t length)
8 {
9  int i;
10  for (i=0;i<length && strcmp(key,values[i]);i++);
11  if (i == length) i=-1;
12  return i;
13 }
14 //_____________________________________________________________________________
15 StTrackChair::StTrackChair(TTable *table) : TChair(table) {
16  if (!table) return;
17  mR0 = table->GetOffset("r0"); // radius at start (cm)
18  mPhi0 = table->GetOffset("phi0"); // azimuthal angle at start (deg)
19  mZ0 = table->GetOffset("z0"); // z-coord. at start (cm)
20  mPsi = table->GetOffset("psi"); // azimuthal angle of pT vector (deg)
21  mTanl = table->GetOffset("tanl"); // tan(dip) =pz/pt at start
22  mCurvature = table->GetOffset("curvature");// Track curvature (1/cm)
23  mLength = table->GetOffset("length"); // from first to last point (cm)
24  if (strcmp(table->GetType(),"tpt_track_st")) {
25  mInvpt = table->GetOffset("invpt") ; // 1/pt at start (GeV/c)^(-1)
26  mCharge = table->GetOffset("icharge"); // Particle charge in units of |e|
27  } else {
28  mInvpt = table->GetOffset("invp"); // 1/pt at start (GeV/c)^(-1)
29  mCharge = table->GetOffset("q"); // Particle charge in units of |e|
30  }
31 }
32 
33 //_____________________________________________________________________________
34 StHelixD *StTrackChair::MakeHelix(Int_t i, float bField) const
35 {
36  //see: StEvent/StHelixModel
37  const float pi2 = 3.1415926/2.;
38  const float rad = pi2/90.;
39  const void *point = At(i);
40  Float_t angle = (*(Float_t*)GetOffset(point,mPhi0)) * rad;
41  int h = (*(Int_t *)GetOffset(point,mCharge))*bField > 0 ? -1 : 1;
42  Float_t ro = *(Float_t *)GetOffset(point,mR0);
43 
44  StThreeVectorD vector(ro*cos(angle),ro*sin(angle),*(Float_t *)GetOffset(point,mZ0));
45 
46  Float_t curv = *(Float_t *)GetOffset(point,mCurvature);
47  Float_t tanl = *(Float_t *)GetOffset(point,mTanl);
48  Float_t psi = *(Float_t *)GetOffset(point,mPsi);
49 
50  StHelixD *helix = new StHelixD(curv, atan(tanl), psi*rad-h*pi2, vector, h);
51  return helix;
52 }
53 
54 //_____________________________________________________________________________
55 Int_t StTrackChair::IsTrack(TTable *table){
56  assert(table);
57  return CheckName(table->GetType(),trackTableList,sizeof(trackTableList)/sizeof(Char_t *));
58 }
59 //_____________________________________________________________________________
61  assert(table);
62  StTrackChair *chair = 0;
63  if (CheckName(table->GetType(),trackTableList,sizeof(trackTableList)/sizeof(Char_t *))>=0)
64  chair = new StTrackChair(table);
65  return chair;
66 }
TDataSet * Instance() const
Definition: StTrackChair.h:24
Definition: TChair.h:27
virtual const Char_t * GetType() const
Returns the type of the wrapped C-structure kept as the TNamed title.
Definition: TTable.cxx:1444
Definition: TTable.h:48