00001 #include "StTrackChair.h"
00002 #include "StHelixD.hh"
00003 const Char_t *StTrackChair::trackTableList[] = {"tpt_track_st","dst_track_st"};
00004
00005 ClassImp(StTrackChair)
00006
00007 static Int_t CheckName(const Char_t *key, const Char_t **values, Int_t length)
00008 {
00009 int i;
00010 for (i=0;i<length && strcmp(key,values[i]);i++);
00011 if (i == length) i=-1;
00012 return i;
00013 }
00014
00015 StTrackChair::StTrackChair(TTable *table) : TChair(table) {
00016 if (!table) return;
00017 mR0 = table->GetOffset("r0");
00018 mPhi0 = table->GetOffset("phi0");
00019 mZ0 = table->GetOffset("z0");
00020 mPsi = table->GetOffset("psi");
00021 mTanl = table->GetOffset("tanl");
00022 mCurvature = table->GetOffset("curvature");
00023 mLength = table->GetOffset("length");
00024 if (strcmp(table->GetType(),"tpt_track_st")) {
00025 mInvpt = table->GetOffset("invpt") ;
00026 mCharge = table->GetOffset("icharge");
00027 } else {
00028 mInvpt = table->GetOffset("invp");
00029 mCharge = table->GetOffset("q");
00030 }
00031 }
00032
00033
00034 StHelixD *StTrackChair::MakeHelix(Int_t i, float bField) const
00035 {
00036
00037 const float pi2 = 3.1415926/2.;
00038 const float rad = pi2/90.;
00039 const void *point = At(i);
00040 Float_t angle = (*(Float_t*)GetOffset(point,mPhi0)) * rad;
00041 int h = (*(Int_t *)GetOffset(point,mCharge))*bField > 0 ? -1 : 1;
00042 Float_t ro = *(Float_t *)GetOffset(point,mR0);
00043
00044 StThreeVectorD vector(ro*cos(angle),ro*sin(angle),*(Float_t *)GetOffset(point,mZ0));
00045
00046 Float_t curv = *(Float_t *)GetOffset(point,mCurvature);
00047 Float_t tanl = *(Float_t *)GetOffset(point,mTanl);
00048 Float_t psi = *(Float_t *)GetOffset(point,mPsi);
00049
00050 StHelixD *helix = new StHelixD(curv, atan(tanl), psi*rad-h*pi2, vector, h);
00051 return helix;
00052 }
00053
00054
00055 Int_t StTrackChair::IsTrack(TTable *table){
00056 assert(table);
00057 return CheckName(table->GetType(),trackTableList,sizeof(trackTableList)/sizeof(Char_t *));
00058 }
00059
00060 StTrackChair *StTrackChair::Instance(TTable *table){
00061 assert(table);
00062 StTrackChair *chair = 0;
00063 if (CheckName(table->GetType(),trackTableList,sizeof(trackTableList)/sizeof(Char_t *))>=0)
00064 chair = new StTrackChair(table);
00065 return chair;
00066 }