EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GFWirepointHitPolicy.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file GFWirepointHitPolicy.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 */
19 // ----------------------------------------------------------
20 // Please see GFWirepointHitPolicy.h before using this class.
21 // ----------------------------------------------------------
22 
23 #include "GFWirepointHitPolicy.h"
24 
25 #include "assert.h"
26 #include <cmath>
27 
28 #include "TMath.h"
29 #include "TVector3.h"
30 
31 #include "GFAbsRecoHit.h"
32 #include "GFException.h"
33 
34 const std::string GFWirepointHitPolicy::fPolicyName = "GFWirepointHitPolicy";
35 
36 GFWirepointHitPolicy::GFWirepointHitPolicy() : fMaxdistance(1.E50) {;}
37 
38 TMatrixT<double>
40 {
41  TMatrixT<double> returnMat(2,1);
42 
43  checkPlane(hit, plane);
44 
45  // raw x1, y1, z1, x2, y2, z2, rdrift, zreco
46  TMatrixT<double> rC = hit->getRawHitCoord();
47 
48  returnMat[0][0] = rC[6][0];
49  returnMat[1][0] = rC[7][0];
50  return returnMat;
51 }
52 
53 TMatrixT<double>
55 {
56  checkPlane(hit, plane);
57 
58  TMatrixT<double> returnCov(2,2);
59  TMatrixT<double> rawCov = hit->getRawHitCov();
60 
61  returnCov[0][0] = rawCov[6][6];
62  returnCov[1][0] = rawCov[7][6];
63  returnCov[0][1] = rawCov[6][7];
64  returnCov[1][1] = rawCov[7][7];
65 
66  return returnCov;
67 }
68 
69 
70 
72 {
73  // raw x1, y1, z1, x2, y2, z2, rdrift, zreco
74  TMatrixT<double> rC = hit->getRawHitCoord();
75 
76  assert(rC.GetNrows()==8);
77 
78  TVector3 wire1(rC[0][0], rC[1][0], rC[2][0]);
79  TVector3 wire2(rC[3][0], rC[4][0], rC[5][0]);
80  TVector3 wiredirection = wire1 - wire2;
81 
82  TVector3 vaxis = plane.getV();
83  wiredirection.SetMag(1.);
84  vaxis.SetMag(1.);
85 
86  if(fabs(TMath::Abs(wiredirection.Dot(vaxis)) - 1) > 1e-3)
87  {
88 
89  std::cout << "GFWirepointHitPolicy: plane not valid!!" << std::endl;
90  }
91 }
92 
93 
94 const GFDetPlane&
96 {
97 
98  TMatrixT<double> x=hit->getRawHitCoord();
99  assert(x.GetNrows()==8);
100  TVector3 wire1(x[0][0],x[1][0],x[2][0]);
101  TVector3 wire2(x[3][0],x[4][0],x[5][0]);
102 
103  // distance of one (the first) of the wire extremities from the plane
104  Double_t d_from_refplane = fDetPlane.dist(wire1).Mag();
105  if(d_from_refplane < 1e-5) return fDetPlane;
106 
107 
108  // point of closest approach
109  TVector3 poca, poca_onwire, dirInPoca;
110 
111  rep->extrapolateToLine(wire1, wire2, poca, dirInPoca, poca_onwire);
112 
113 
114  Double_t distance;
115  distance = TMath::Sqrt(fabs(((wire1-poca).Mag2()*(wire2-wire1).Mag2()-pow((wire1-poca).Dot(wire2-wire1),2))/(wire2-wire1).Mag2()));
116 
117  // check poca inside tube
118  if(distance > fMaxdistance) {
119  GFException exc("distance poca-wire > maxdistance", __LINE__,__FILE__);
120  throw exc;
121  }
122 
123  // find plane
124  // unitary vector along distance
125  // poca (on track), poca_onwire (on wire)
126  TVector3 fromwiretoextr = poca - poca_onwire;
127  fromwiretoextr.SetMag(1.);
128  // unitary vector along the wire
129  TVector3 wiredirection = wire2 - wire1;
130  wiredirection.SetMag(1.);
131 
132  // check orthogonality
133  if(fabs(fromwiretoextr * wiredirection) > 1e-3) {
134  GFException exc("fromwiretoextr*wiredirection > 1e-3", __LINE__,__FILE__);
135  throw exc;
136  }
137 
138  TVector3 U;
139  U = fromwiretoextr;
140  TVector3 V;
141  V = wiredirection;
142  U.SetMag(1.);
143  V.SetMag(1.);
144 
145  TVector3 O = (wire1 + wire2) * 0.5;
146 
147 
148  fDetPlane = GFDetPlane(O, U, V);
149 
150  return fDetPlane;
151 }
152