StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFgtHit.cxx
1 /***************************************************************************
2  *
3  * $Id: StFgtHit.cxx,v 2.1 2012/04/16 20:20:49 ullrich Exp $
4  * Author: S. Gliske, Oct 2011
5  *
6  ***************************************************************************
7  *
8  * Description: see header file.
9  *
10  ***************************************************************************
11  *
12  * $Log: StFgtHit.cxx,v $
13  * Revision 2.1 2012/04/16 20:20:49 ullrich
14  * Initial Revision
15  *
16  *
17  **************************************************************************/
18 
19 #include "StFgtHit.h"
20 #include <cmath>
21 
22 // constructor
23 StFgtHit::StFgtHit( int key, int centralStripGeoId, float charge,
24  short disc, short quad, char layer,
25  float rPos, float rErr, float phiPos, float phiErr, float zPos, float zErr )
26 {
27  StHit::setHardwarePosition(disc*8+quad*2+(layer=='R'));
28  StHit::setCharge(charge);
29  mKey = key;
30  mR = rPos;
31  mErrR = rErr;
32  mPhi = phiPos;
33  mErrPhi =phiErr ;
34  mCentralStripGeoId = centralStripGeoId;
35  mChargeUncert = 1000;
36 
37  // Assert is being commented out. If an invalid quad is specified, then
38  // the hardwardware ID in the parent StHit will be incorrect.
39  // assert( quad >= 0 && quad < 4 );
40 
41  mPosition.setX( rPos*cos(phiPos) );
42  mPosition.setY( rPos*sin(phiPos) );
43  mPosition.setZ( zPos );
44 
45  update2error();
46  mPositionError.setZ( zErr );
47 }
48 
49 // deconstructor
50 StFgtHit::~StFgtHit() {
51  // nothing to do
52 }
53 
54 // propagate the uncertainty on phi and r to uncertainty on x and y
55 void StFgtHit::update2error(){
56  float cosPhiSq = cos( mPhi );
57  cosPhiSq *= cosPhiSq;
58  float sinPhiSq = 1 - cosPhiSq;
59 
60  float mErrRSq = mErrR*mErrR;
61  float mErrPhiSq = mErrPhi*mErrPhi;
62 
63  float xErrSq = mErrRSq*cosPhiSq + mErrPhiSq*sinPhiSq;
64  float yErrSq = mErrRSq*sinPhiSq + mErrPhiSq*cosPhiSq;
65 
66  mPositionError.setX( sqrt( xErrSq ) );
67  mPositionError.setY( sqrt( yErrSq ) );
68 }
69 
70 ClassImp(StFgtHit);