SND@LHC Software
Loading...
Searching...
No Matches
WirePointMeasurement.cc
Go to the documentation of this file.
1/* Copyright 2008-2010, Technische Universitaet Muenchen,
2 Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch
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
21
22#include <Exception.h>
23#include <RKTrackRep.h>
24#include <HMatrixUV.h>
25
26#include <cassert>
27#include <algorithm>
28
29
30namespace genfit {
31
33 : WireMeasurement(nDim)
34{
35 assert(nDim >= 8);
36}
37
38WirePointMeasurement::WirePointMeasurement(const TVectorD& rawHitCoords, const TMatrixDSym& rawHitCov, int detId, int hitId, TrackPoint* trackPoint)
39 : WireMeasurement(rawHitCoords, rawHitCov, detId, hitId, trackPoint)
40{
41 assert(rawHitCoords_.GetNrows() >= 8);
42}
43
44
46
47 // copy state. Neglect covariance.
48 StateOnPlane st(state);
49
50 TVector3 wire1(rawHitCoords_(0), rawHitCoords_(1), rawHitCoords_(2));
51 TVector3 wire2(rawHitCoords_(3), rawHitCoords_(4), rawHitCoords_(5));
52
53 //std::cout << " wire1(" << rawHitCoords_(0) << ", " << rawHitCoords_(1) << ", " << rawHitCoords_(2) << ")" << std::endl;
54 //std::cout << " wire2(" << rawHitCoords_(3) << ", " << rawHitCoords_(4) << ", " << rawHitCoords_(5) << ")" << std::endl;
55
56 // unit vector along the wire (V)
57 TVector3 wireDirection = wire2 - wire1;
58 wireDirection.SetMag(1.);
59
60 //std::cout << " wireDirection(" << wireDirection.X() << ", " << wireDirection.Y() << ", " << wireDirection.Z() << ")" << std::endl;
61
62 // point of closest approach
63 const AbsTrackRep* rep = state.getRep();
64 rep->extrapolateToLine(st, wire1, wireDirection);
65 //const TVector3& poca = rep->getPos(st);
66 TVector3 dirInPoca = rep->getMom(st);
67 dirInPoca.SetMag(1.);
68 //const TVector3& pocaOnWire = wire1 + wireDirection.Dot(poca - wire1)*wireDirection;
69
70 // check if direction is parallel to wire
71 if (fabs(wireDirection.Angle(dirInPoca)) < 0.01){
72 Exception exc("WireMeasurement::detPlane(): Cannot construct detector plane, direction is parallel to wire", __LINE__,__FILE__);
73 throw exc;
74 }
75
76 // construct orthogonal vector
77 TVector3 U = dirInPoca.Cross(wireDirection);
78 // U.SetMag(1.); automatically assured
79
80 return SharedPlanePtr(new DetPlane(wire1, U, wireDirection));
81}
82
83
84std::vector<MeasurementOnPlane*> WirePointMeasurement::constructMeasurementsOnPlane(const StateOnPlane& state) const
85{
86 MeasurementOnPlane* mopR = new MeasurementOnPlane(TVectorD(2),
87 TMatrixDSym(2),
88 state.getPlane(), state.getRep(), constructHMatrix(state.getRep()));
89
90 mopR->getState()(0) = rawHitCoords_(6);
91 mopR->getState()(1) = rawHitCoords_(7);
92
93 mopR->getCov()(0,0) = rawHitCov_(6,6);
94 mopR->getCov()(1,0) = rawHitCov_(7,6);
95 mopR->getCov()(0,1) = rawHitCov_(6,7);
96 mopR->getCov()(1,1) = rawHitCov_(7,7);
97
98
99 MeasurementOnPlane* mopL = new MeasurementOnPlane(*mopR);
100 mopL->getState()(0) *= -1;
101
102 // set left/right weights
103 if (leftRight_ < 0) {
104 mopL->setWeight(1);
105 mopR->setWeight(0);
106 }
107 else if (leftRight_ > 0) {
108 mopL->setWeight(0);
109 mopR->setWeight(1);
110 }
111 else {
112 double val = 0.5 * pow(std::max(0., 1 - rawHitCoords_(6)/maxDistance_), 2.);
113 mopL->setWeight(val);
114 mopR->setWeight(val);
115 }
116
117 std::vector<MeasurementOnPlane*> retVal;
118 retVal.push_back(mopL);
119 retVal.push_back(mopR);
120 return retVal;
121}
122
124 if (dynamic_cast<const RKTrackRep*>(rep) == NULL) {
125 Exception exc("WirePointMeasurement default implementation can only handle state vectors of type RKTrackRep!", __LINE__,__FILE__);
126 throw exc;
127 }
128
129 return new HMatrixUV();
130}
131
132} /* End of namespace genfit */
HMatrix for projecting from AbsTrackRep parameters to measured parameters in a DetPlane.
Definition AbsHMatrix.h:37
Abstract base class for a track representation.
Definition AbsTrackRep.h:66
virtual double extrapolateToLine(StateOnPlane &state, const TVector3 &linePoint, const TVector3 &lineDirection, bool stopAtBoundary=false, bool calcJacobianNoise=false) const =0
Extrapolates the state to the POCA to a line, and returns the extrapolation length and,...
virtual TVector3 getMom(const StateOnPlane &state) const =0
Get the cartesian momentum vector of a state.
Detector plane.
Definition DetPlane.h:61
Exception class for error handling in GENFIT (provides storage for diagnostic information)
Definition Exception.h:48
AbsHMatrix implementation for two-dimensional MeasurementOnPlane and RKTrackRep parameterization.
Definition HMatrixUV.h:39
const TMatrixDSym & getCov() const
Measured coordinates on a plane.
void setWeight(double weight)
AbsTrackRep with 5D track parameterization in plane coordinates: (q/p, u', v', u, v)
Definition RKTrackRep.h:70
A state with arbitrary dimension defined in a DetPlane.
const TVectorD & getState() const
const AbsTrackRep * getRep() const
const SharedPlanePtr & getPlane() const
Object containing AbsMeasurement and AbsFitterInfo objects.
Definition TrackPoint.h:50
Class for measurements in wire detectors (Straw tubes and drift chambers) which do not measure the co...
virtual SharedPlanePtr constructPlane(const StateOnPlane &state) const
virtual const AbsHMatrix * constructHMatrix(const AbsTrackRep *) const
virtual std::vector< MeasurementOnPlane * > constructMeasurementsOnPlane(const StateOnPlane &state) const
Matrix inversion tools.
Definition AbsBField.h:29
boost::shared_ptr< genfit::DetPlane > SharedPlanePtr
Shared Pointer to a DetPlane.