StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StDcaGeometry.cxx
1 /***************************************************************************
2  *
3  * $Id: StDcaGeometry.cxx,v 2.12 2017/06/01 23:48:44 smirnovd Exp $
4  *
5  * Author: Victor Perevoztchikov, Thomas Ullrich, May 2006
6  ***************************************************************************
7  *
8  * Description:
9  *
10  ***************************************************************************
11  *
12  * $Log: StDcaGeometry.cxx,v $
13  * Revision 2.12 2017/06/01 23:48:44 smirnovd
14  * [Cosmetic] StDcaGeometry: Whitespace adjustments
15  *
16  * Revision 2.11 2013/11/13 21:35:48 fisyak
17  * Suppress Warning
18  *
19  * Revision 2.9 2013/07/16 14:29:03 fisyak
20  * Restore mass fit tracks
21  *
22  * Revision 2.8 2013/01/15 23:21:05 fisyak
23  * improve printouts
24  *
25  * Revision 2.7 2012/06/01 14:19:06 fisyak
26  * Fix print out
27  *
28  * Revision 2.6 2010/08/31 20:14:50 fisyak
29  * Fix format
30  *
31  * Revision 2.5 2010/08/31 19:49:16 fisyak
32  * adjust parameters print out
33  *
34  * Revision 2.4 2010/01/26 20:34:39 fisyak
35  * Add print out and conversion from DCA to x,y,z,px,py,pz
36  *
37  * Revision 2.3 2009/10/27 22:50:25 fisyak
38  * Add set from double
39  *
40  * Revision 2.2 2008/03/04 01:03:36 perev
41  * remove redundant mHz
42  *
43  * Revision 2.1 2006/05/24 17:27:43 ullrich
44  * Initial Revision.
45  *
46  **************************************************************************/
47 #include "StDcaGeometry.h"
48 #if ROOT_VERSION_CODE < 331013
49 #include "TCL.h"
50 #else
51 #include "TCernLib.h"
52 #endif
53 #include "TRMatrix.h"
54 #include "TRSymMatrix.h"
55 #include "TMath.h"
56 ClassImp(StDcaGeometry)
57 
58 static const char rcsid[] = "$Id: StDcaGeometry.cxx,v 2.12 2017/06/01 23:48:44 smirnovd Exp $";
59 
61 {
62  memset(mBeg,0,mEnd-mBeg+1);
63 }
64 
65 StDcaGeometry::~StDcaGeometry() {/* noop */}
66 
67 StThreeVectorF StDcaGeometry::origin() const
68 {
69  float x = -mImp*sin(mPsi);
70  float y = mImp*cos(mPsi);
71  return StThreeVectorF(x,y,mZ);
72 }
73 
74 StThreeVectorF StDcaGeometry::momentum() const
75 {
76  float ptt = pt();
77  float x = ptt*cos(mPsi);
78  float y = ptt*sin(mPsi);
79  float z = ptt*mTan;
80  return StThreeVectorF(x,y,z);
81 }
82 
83 void StDcaGeometry::set(const float pars[7],const float errs[15])
84 {
85  if (pars) memcpy(&mImp ,pars,sizeof(float)*6 );
86  if (errs) memcpy(&mImpImp,errs,sizeof(float)*15);
87 }
88 void StDcaGeometry::set(const double pars[7],const double errs[15])
89 {
90  if (pars) TCL::ucopy(pars, &mImp, 6);
91  if (errs) TCL::ucopy(errs, &mImpImp, 15);
92 }
93 
94 StPhysicalHelixD StDcaGeometry::helix() const
95 {
96  // double curvature = fabs(mCurv);
97  int h = (mCurv>=0) ? 1:-1;
98 
99  double phase = mPsi-h*M_PI/2;
100 
101  return StPhysicalHelixD(fabs(mCurv), // 1/cm
102  atan(mTan), // radian
103  phase, // radian
104  origin(), // cm
105  h);
106 }
107 
108 THelixTrack StDcaGeometry::thelix() const
109 {
110  enum {kImp,kZ,kPsi,kPti,kTan};
111 
112  StThreeVectorD pos = origin();
113  StThreeVectorD dir = momentum().unit();
114  THelixTrack myHelx(&(pos.x()),&(dir.x()),mCurv);
115  double errXY[6],errSZ[6];
116  const float *myErr = &mImpImp;
117  int jjx=0,jjz=0;
118 
119  for (int i=0,li=0;i<5; li+=++i) {
120  for (int j=0;j<=i;j++) {
121  do {// select XY part
122  if(i==kZ || i==kTan) break;
123  if(j==kZ || j==kTan) break;
124  errXY[jjx++]=myErr[li+j];
125  }
126  while(0);
127  do {// select SZ part
128  if(i!=kZ && i!=kTan) break;
129  if(j!=kZ && j!=kTan) break;
130  errSZ[jjz++]=myErr[li+j];
131  }
132  while(0);
133  }
134  }
135  errXY[3]*=hz();
136  errXY[4]*=hz();
137  errXY[5]*=hz()*hz();
138  myHelx.SetEmx(errXY,errSZ);
139  return myHelx;
140 }
141 //________________________________________________________________________________
142 ostream& operator<<(ostream& os, const StDcaGeometry& dca) {
143  const Float_t *errMx = dca.errMatrix();
144  return os << Form("Dca: imp %7.2f +/-%7.2f, Z:%7.2f +/-%7.2f, psi:%7.2f +/-%7.2f, pT/q:%7.2f +/-%6.1f%%, TanL:%8.3f +/-%8.3f",
145  dca.impact(), (errMx[0] >= 0) ? TMath::Sqrt(errMx[0]) : -13,
146  dca.z(), (errMx[2] >= 0) ? TMath::Sqrt(errMx[2]) : -13,
147  dca.psi(), (errMx[5] >= 0) ? TMath::Sqrt(errMx[5]) : -13,
148  dca.charge()*dca.pt(), (errMx[9] >= 0 && dca.pt() > 0) ? 100*TMath::Sqrt(errMx[9])*dca.pt() : -13,
149  dca.tanDip(), (errMx[14] >= 0) ? TMath::Sqrt(errMx[14]): -13);
150 }
151 //________________________________________________________________________________
152 void StDcaGeometry::Print(Option_t *option) const {cout << *this << endl;}
153 //________________________________________________________________________________
154 void StDcaGeometry::GetXYZ(Double_t xyzp[6], Double_t CovXyzp[21]) const {
155  static const Float_t one = 1;
156  Double_t sinP = TMath::Sin(mPsi);
157  Double_t cosP = TMath::Cos(mPsi);
158  Double_t pT = pt();
159  xyzp[0] = - mImp*sinP; // x
160  xyzp[1] = mImp*cosP; // y
161  xyzp[2] = mZ; // z
162  xyzp[3] = pT*cosP; // px
163  xyzp[4] = pT*sinP; // py
164  xyzp[5] = pT*mTan; // pz
165  Double_t dpTdPti = -pT*pT*TMath::Sign(one,mPti);
166  Double_t f[30] = {
167  //mImp,mZ, mPsi, mPti, mTan
168  -sinP, 0, -mImp*cosP, 0, 0
169  ,cosP, 0, -mImp*sinP, 0, 0
170  , 0, 1, 0, 0, 0
171  , 0, 0, -pT*sinP, dpTdPti*cosP, 0
172  , 0, 0, pT*cosP, dpTdPti*sinP, 0
173  , 0, 0, 0, dpTdPti*mTan, pT
174  };
175  TRMatrix F(6,5,f);
176  TRSymMatrix C(5,errMatrix());
177  TRSymMatrix Cov(F,TRArray::kAxSxAT,C);
178  TCL::ucopy(Cov.GetArray(),CovXyzp,21);
179 }