EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GFPseudoSpacepointWireHitPolicy.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file GFPseudoSpacepointWireHitPolicy.cxx
1 /* Copyright 2008-2010, Technische Universitaet Muenchen,
2  Authors: Christian Hoeppner & Sebastian Neubert
3 
4  This file is part of GENFIT.
5 
6  GENFIT is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published
8  by the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  GENFIT is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with GENFIT. If not, see <http://www.gnu.org/licenses/>.
18 */
20 
21 #include "assert.h"
22 
23 #include "TMath.h"
24 
25 #include "GFAbsRecoHit.h"
26 #include "GFException.h"
27 
28 const std::string GFPseudoSpacepointWireHitPolicy::fPolicyName = "GFPseudoSpacepointWireHitPolicy";
29 
30 
32  fMaxdistance(1.E50),
33  fWireDirection(0, 0, 1)
34 {
35  ;
36 }
37 
38 
39 TMatrixT<double>
41 {
42  TMatrixT<double> returnMat(2,1);
43 
44  TMatrixT<double> _D(3,1);
45  TVector3 _U;
46  TVector3 _V;
47 
48  _D[0][0] = (plane.getO())[0];
49  _D[1][0] = (plane.getO())[1];
50  _D[2][0] = (plane.getO())[2];
51 
52  _D *= -1.;
53  _D += hit->getRawHitCoord();
54  //now the vector _D points from the origin of the plane to the hit point
55 
56 
57  _U = plane.getU();
58  _V = plane.getV();
59 
60 
61  returnMat[0][0] = _D[0][0] * _U[0] + _D[1][0] * _U[1] + _D[2][0] * _U[2];
62  returnMat[1][0] = _D[0][0] * _V[0] + _D[1][0] * _V[1] + _D[2][0] * _V[2];
63  //std::cout << "hitCoord="<<std::endl;
64  //returnMat.Print();
65  return returnMat;
66 }
67 
68 TMatrixT<double>
70 {
71  TVector3 _U;
72  TVector3 _V;
73 
74  _U = plane.getU();
75  _V = plane.getV();
76 
77  TMatrixT<double> rawCov = hit->getRawHitCov();
78 
79  TMatrixT<double> jac(3,2);
80 
81  // jac = dF_i/dx_j = s_unitvec * t_untivec, with s=u,v and t=x,y,z
82  jac[0][0] = _U[0];
83  jac[1][0] = _U[1];
84  jac[2][0] = _U[2];
85  jac[0][1] = _V[0];
86  jac[1][1] = _V[1];
87  jac[2][1] = _V[2];
88 
89  TMatrixT<double> jac_orig = jac;
90  TMatrixT<double> jac_t = jac.T();
91 
92  TMatrixT<double> result=jac_t * (rawCov * jac_orig);
93  //std::cout << "hitCov="<<std::endl;
94  //result.Print();
95  return result;
96 }
97 
98 const GFDetPlane&
100 {
101 
102  TMatrixT<double> rawcoord = hit->getRawHitCoord();
103  TVector3 point(rawcoord[0][0],rawcoord[1][0],rawcoord[2][0]);
104 
105  TVector3 wire1(point);
106  TVector3 wire2(point);
107  wire2 += fWireDirection;
108 
109  // distance of one (the first) of the wire extremities from the plane
110  Double_t d_from_refplane = fDetPlane.dist(wire1).Mag();
111  if(d_from_refplane < 1e-5) return fDetPlane;
112 
113 
114  // point of closest approach
115  TVector3 poca, poca_onwire, dirInPoca;
116 
117  rep->extrapolateToLine(wire1, wire2, poca, dirInPoca, poca_onwire);
118 
119 
120  Double_t distance;
121  distance = TMath::Sqrt(fabs(((wire1-poca).Mag2()*(wire2-wire1).Mag2()-pow((wire1-poca).Dot(wire2-wire1),2))/(wire2-wire1).Mag2()));
122 
123  // check poca inside tube
124  if(distance > fMaxdistance) {
125  GFException exc("distance poca-wire > maxdistance", __LINE__,__FILE__);
126  throw exc;
127  }
128 
129  // find plane
130  // unitary vector along distance
131  // poca (on track), poca_onwire (on wire)
132  TVector3 fromwiretoextr = poca - poca_onwire;
133  fromwiretoextr.SetMag(1.);
134  // unitary vector along the wire
135  TVector3 wiredirection = wire2 - wire1;
136  wiredirection.SetMag(1.);
137 
138  // check orthogonality
139  if(fabs(fromwiretoextr * wiredirection) > 1e-3) {
140  GFException exc("fromwiretoextr*wiredirection > 1e-3", __LINE__,__FILE__);
141  throw exc;
142  }
143 
144  TVector3 U;
145  U = fromwiretoextr;
146  TVector3 V;
147  V = wiredirection;
148  U.SetMag(1.);
149  V.SetMag(1.);
150 
151  TVector3 O = poca_onwire;
152 
153  fDetPlane = GFDetPlane(O, U, V);
154 
155  return fDetPlane;
156 }
157