EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EicTrackingRecoHit.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EicTrackingRecoHit.cxx
1 //
2 // AYK (ayk@bnl.gov), 2013/06/12
3 //
4 // Tracking reco hit and GenFit interface classes;
5 //
6 
7 #include <assert.h>
8 
9 #include <GeaneTrackRep.h>
10 
11 #include "EicTrackingRecoHit.h"
12 
13 // Move to a better place later;
14 #define _SQR_(arg) ((arg)*(arg))
15 
16 // -----------------------------------------------------------------------------------------------
17 
18 TMatrixT<double> EicTrackingRecoHit::getHMatrix(const GFAbsTrackRep* stateVector)
19 {
20  // Deal with Geane representation for now;
21  if (dynamic_cast<const GeaneTrackRep*>(stateVector) != NULL) {
22  // Do it better later once implement 1D X- and Y-silicon detectors;
23  assert(GetMdim() == 2);
24 
25  TMatrixT<double> HMatrix(GetMdim(), 5);
26 
27  // Reset all elements;
28  for(unsigned ip=0; ip<GetMdim(); ip++)
29  for(unsigned iq=0; iq<5; iq++)
30  HMatrix[ip][iq] = 0.0;
31 
32  // Set only slope coefficients (?);
33  for(unsigned ip=0; ip<GetMdim(); ip++)
34  HMatrix[ip][ip+3] = 1.0;
35 
36  return HMatrix;
37  }
38  else {
39  std::cerr << "For now can only handle state"
40  << " vectors of type GeaneTrackRep only -> abort"
41  << std::endl;
42  throw;
43  } //if
44 } // EicTrackingRecoHit::getHMatrix()
45 
46 // -----------------------------------------------------------------------------------------------
47 
48 //
49 // FIXME: may want to optimize some of the actions here (check basis
50 // vector lookup availability, etc);
51 //
52 
54 {
55  EicGeoParData *gPtr = (EicGeoParData *)ptr;
57 
58  return gPtr->GetLookupTableNode(id);
59 } // EicTrackingRecoHit::GetLookupTableNode()
60 
61 // -----------------------------------------------------------------------------------------------
62 
64  GFRecoHitIfc<GFPlanarHitPolicy>(hit->GetMdim()), mDim(hit->GetMdim())
65 {
66  const LogicalVolumeLookupTableEntry *node = GetLookupTableNode(hit, ptr);
67 
68  // Reset hit coordinates to 0.0 and assign local (diagonal) covariance matrix;
69  // see virtual plane definition below (global[] enters there!);
70  TVector3 local = hit->GetLocalCoordinates();
71 
72  // fHitCoord[][] & fHitCov[][] are not inherited from EicTrackingRecoHit, so perhaps
73  // do not want to try to unify this code between EicPlanarRecoHit & EicSpaceRecoHit;
74  for(int iq=0; iq<hit->GetMdim(); iq++) {
75  fHitCoord[iq][0 ] = 0.0;
76 
77  //fHitCov [iq][iq] = _SQR_(hit->GetSigma(iq));
78  fHitCov [iq][iq] = hit->GetCovariance(iq,iq);
79  } //for iq
80 
81  if (hit->mXYmode) {
82  TVector3 uu(1,0,0), vv(0,1,0);
84  LocalToMasterVect(node->mGeoMtx, uu),
85  LocalToMasterVect(node->mGeoMtx, vv)));
86  } else {
87  //assert(0);
88  // NB: should be in sync with EicKfNodeTemplateCartesian2D::SmearLocalCoord();
89  TVector3 uu = TVector3(local.Y(),-local.X(),0).Unit(), vv(0,0,1);
91  LocalToMasterVect(node->mGeoMtx, uu),
92  LocalToMasterVect(node->mGeoMtx, vv)));
93  } //if
94 } // EicPlanarRecoHit::EicPlanarRecoHit()
95 
96 // -----------------------------------------------------------------------------------------------
97 
98 //
99 // FIXME: move cov.matrix to MARS; for now assume that TPC is aligned along Z axis
100 // -> no rotation needed here; -> CHECK!!!
101 //
102 
105 {
106  const LogicalVolumeLookupTableEntry *node = GetLookupTableNode(hit, ptr);
107 
108  // Reset hit coordinates to 0.0 and assign local (diagonal) covariance matrix;
109  // see virtual plane definition below (global[] enters there!);
110  TVector3 local = hit->GetLocalCoordinates();
111  TVector3 global = LocalToMaster(node->mGeoMtx, local);
112 
113  double buffer[3][3];
114  for(int ip=0; ip<hit->GetMdim(); ip++)
115  for(int iq=0; iq<hit->GetMdim(); iq++)
116  buffer[ip][iq] = hit->GetCovariance(ip,iq);
117  TGeoRotation grr;
118  grr.SetMatrix((double*)buffer);
119 
120  TGeoRotation www = *node->mGeoMtx * grr * node->mGeoMtx->Inverse();
121  //TGeoRotation www = node->mGeoMtx->Inverse() * grr * *node->mGeoMtx;
122 
123  for(int ip=0; ip<hit->GetMdim(); ip++) {
124  fHitCoord[ip][0 ] = global[ip];
125 
126  for(int iq=0; iq<hit->GetMdim(); iq++)
127  //@@@ earlier version (buggy: no conversion to MARS) fHitCov[ip][iq] = hit->GetCovariance(ip,iq);
128  fHitCov[ip][iq] = www.GetRotationMatrix()[ip*3+iq];
129  } //for ip
130 } // EicSpaceRecoHit::EicSpaceRecoHit()
131 
132 // -----------------------------------------------------------------------------------------------
133