StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StExtGeometry.cxx
1 /***************************************************************************
2  *
3  * $Id: StExtGeometry.cxx,v 2.2 2017/05/04 00:56:43 perev Exp $
4  *
5  * Author: Victor Perevoztchikov, November 2016
6  ***************************************************************************
7  *
8  * Description:
9  *
10  ***************************************************************************
11  *
12  * $Log: StExtGeometry.cxx,v $
13  * Revision 2.2 2017/05/04 00:56:43 perev
14  * Increase name to add 0
15  *
16  * Revision 2.1 2016/11/28 20:58:30 ullrich
17  * Initial Revision.
18  *
19  *
20  **************************************************************************/
21 #include <stdlib.h>
22 #include <string.h>
23 #include <assert.h>
24 #include "StExtGeometry.h"
25 #include "TCernLib.h"
26 
27 ClassImp(StExtGeometry)
28 
29 static const char rcsid[] = "$Id: StExtGeometry.cxx,v 2.2 2017/05/04 00:56:43 perev Exp $";
30 
31 //_____________________________________________________________________________
32 StExtGeometry::StExtGeometry(const char *name)
33 {
34  memset(mName,0,mEnd-mName+1);
35  setName(name);
36 }
37 
38 //_____________________________________________________________________________
39 StExtGeometry::~StExtGeometry() {/* noop */}
40 //_____________________________________________________________________________
41 StThreeVectorF StExtGeometry::origin() const
42 {
43  float x = mRxy*cos(mPhi);
44  float y = mRxy*sin(mPhi);
45  return StThreeVectorF(x,y,mZ);
46 }
47 
48 //_____________________________________________________________________________
49 StThreeVectorF StExtGeometry::momentum() const
50 {
51  float ptt = pt();
52  float x = ptt*cos(mPsi);
53  float y = ptt*sin(mPsi);
54  float z = ptt*mTan;
55  return StThreeVectorF(x,y,z);
56 }
57 //_____________________________________________________________________________
58 void StExtGeometry::setName(const char *name)
59 {
60  int n = strlen(name); if (n>7) n=7;
61  strncpy(mName,name,n);mName[n]=0;
62 }
63 
64 //_____________________________________________________________________________
65 void StExtGeometry::set(double rXY,const double pars[7],const double errs[15])
66 {
67  mRxy = rXY;
68  if (pars) {TCL::ucopy(pars, &mPhi, 6);}
69  if (errs) {TCL::ucopy(errs, mG, 15);} else {TCL::vzero(mG,15);}
70 }
71 
72 //_____________________________________________________________________________
73 StPhysicalHelixD StExtGeometry::helix() const
74 {
75  // double curvature = fabs(mCurv);
76  int h = (mCurv>=0) ? 1:-1;
77 
78  double phase = mPsi-h*M_PI/2;
79 
80  return StPhysicalHelixD(fabs(mCurv), // 1/cm
81  atan(mTan), // radian
82  phase, // radian
83  origin(), // cm
84  h);
85 }
86 
87 //_____________________________________________________________________________
88 THelixTrack StExtGeometry::thelix() const
89 {
90  enum {kImp,kZ,kPsi,kPti,kTan};
91 
92  StThreeVectorD pos = origin();
93  StThreeVectorD dir = momentum().unit();
94  THelixTrack myHelx(&(pos.x()),&(dir.x()),mCurv);
95  return myHelx;
96 }
97 //_____________________________________________________________________________
98 void StExtGeometry::add(StExtGeometry **top)
99 {
100  StExtGeometry **kadd = top;
101  StExtGeometry *lExt=0;
102  for(;(lExt=*kadd);kadd = &(lExt->mNext)) {if (mRxy<lExt->rxy()) break;}
103  *kadd = this; this->mNext = lExt;
104 }