All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GFWireHitPolicy.cxx
Go to the documentation of this file.
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 GFWireHitPolicy.h before using this class.
21 // ----------------------------------------------------------
22 
24 
25 #include <cassert>
26 #include <cmath>
27 #include <iostream>
28 
29 #include "TMath.h"
30 #include "TVector3.h"
31 
35 
36 const std::string genf::GFWireHitPolicy::fPolicyName = "GFWireHitPolicy";
37 
38 genf::GFWireHitPolicy::GFWireHitPolicy() :fMaxdistance(1.E50) {;}
39 
40 TMatrixT<Double_t>
42 {
43  TMatrixT<Double_t> returnMat(1,1);
44 
45  checkPlane(hit, plane);
46 
47  // raw x1, y1, z1, x2, y2, z2, rdrift
48  TMatrixT<Double_t> rC = hit->getRawHitCoord();
49 
50  returnMat[0][0] = rC[6][0];
51  return returnMat;
52 }
53 
54 TMatrixT<Double_t>
56 {
57  checkPlane(hit, plane);
58 
59  TMatrixT<Double_t> returnCov(1,1);
60  TMatrixT<Double_t> rawCov = hit->getRawHitCov();
61 
62  returnCov[0][0] = rawCov[6][6];
63 
64  return returnCov;
65 }
66 
67 
68 
70 {
71  // raw x1, y1, z1, x2, y2, z2, rdrift, zreco
72  TMatrixT<Double_t> rC = hit->getRawHitCoord();
73 
74  assert(rC.GetNrows()==7);
75 
76  TVector3 wire1(rC[0][0], rC[1][0], rC[2][0]);
77  TVector3 wire2(rC[3][0], rC[4][0], rC[5][0]);
78  TVector3 wiredirection = wire1 - wire2;
79 
80  TVector3 vaxis = plane.getV();
81  wiredirection.SetMag(1.);
82  vaxis.SetMag(1.);
83 
84  if(fabs(TMath::Abs(wiredirection.Dot(vaxis)) - 1) > 1e-3)
85  {
86 
87  std::cout << "GFWireHitPolicy: plane not valid!!" << std::endl;
88  }
89 }
90 
91 
92 const genf::GFDetPlane&
94 {
95 
96  TMatrixT<Double_t> x=hit->getRawHitCoord();
97  assert(x.GetNrows()==7);
98  TVector3 wire1(x[0][0],x[1][0],x[2][0]);
99  TVector3 wire2(x[3][0],x[4][0],x[5][0]);
100 
101  // distance of one (the first) of the wire extremities from the plane
102  Double_t d_from_refplane = fDetPlane.dist(wire1).Mag();
103  if(d_from_refplane < 1e-5) return fDetPlane;
104 
105 
106  // point of closest approach
107  TVector3 poca, poca_onwire, dirInPoca;
108 
109  rep->extrapolateToLine(wire1, wire2, poca, dirInPoca, poca_onwire);
110 
111 
112  Double_t distance;
113  distance = TMath::Sqrt(fabs(((wire1-poca).Mag2()*(wire2-wire1).Mag2()-pow((wire1-poca).Dot(wire2-wire1),2))/(wire2-wire1).Mag2()));
114 
115  // check poca inside tube
116  if(distance > fMaxdistance) {
117  GFException exc("distance poca-wire > maxdistance", __LINE__,__FILE__);
118  throw exc;
119  }
120 
121  // find plane
122  // unitary vector along distance
123  // poca (on track), poca_onwire (on wire)
124  TVector3 fromwiretoextr = poca - poca_onwire;
125  fromwiretoextr.SetMag(1.);
126  // unitary vector along the wire
127  TVector3 wiredirection = wire2 - wire1;
128  wiredirection.SetMag(1.);
129 
130  // check orthogonality
131  if(fabs(fromwiretoextr * wiredirection) > 1e-3) {
132  GFException exc("fromwiretoextr*wiredirection > 1e-3", __LINE__,__FILE__);
133  throw exc;
134  }
135 
136  TVector3 U;
137  U = fromwiretoextr;
138  TVector3 V;
139  V = wiredirection;
140  U.SetMag(1.);
141  V.SetMag(1.);
142 
143  TVector3 O = poca_onwire;
144 
145  fDetPlane = GFDetPlane(O, U, V);
146 
147  return fDetPlane;
148 }
149 
150 //ClassImp(GFWireHitPolicy)
virtual void extrapolateToLine(const TVector3 &point1, const TVector3 &point2, TVector3 &poca, TVector3 &normVec, TVector3 &poca_onwire)
This method extrapolates to the point of closest approach to a line.
process_name opflash particleana ie x
const GFDetPlane & detPlane(GFAbsRecoHit *, GFAbsTrackRep *)
Get detector plane Calls GFAbsTrackRep::extrapolateToLine for POCA.
TMatrixT< Double_t > getRawHitCoord() const
Get raw hit coordinates.
Definition: GFAbsRecoHit.h:183
process_name hit
Definition: cheaterreco.fcl:51
Base Class for genfit track representations. Defines interface for track parameterizations.
Definition: GFAbsTrackRep.h:83
void checkPlane(GFAbsRecoHit *, const GFDetPlane &)
Check if the detector plane is valid.
BEGIN_PROLOG V
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
TMatrixT< Double_t > hitCoord(GFAbsRecoHit *, const GFDetPlane &)
Hit coordinates in detector plane.
Exception class for error handling in GENFIT (provides storage for diagnostic information) ...
Definition: GFException.h:48
Var Sqrt(const Var &v)
Use to take sqrt of a var.
Definition: Var.cxx:172
do i e
TMatrixT< Double_t > hitCov(GFAbsRecoHit *, const GFDetPlane &)
Hit covariances in detector plane.
TVector3 getV() const
Definition: GFDetPlane.h:83
TMatrixT< Double_t > getRawHitCov() const
Get raw hit covariances.
Definition: GFAbsRecoHit.h:178
BEGIN_PROLOG could also be cout
static const std::string fPolicyName