SND@LHC Software
Loading...
Searching...
No Matches
WireMeasurement.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*/
23#include "WireMeasurement.h"
24
25#include <cmath>
26#include <algorithm>
27
28#include <Exception.h>
29#include <RKTrackRep.h>
30#include <HMatrixU.h>
31
32#include <cassert>
33
34
35namespace genfit {
36
37
39 : AbsMeasurement(nDim), maxDistance_(2), leftRight_(0)
40{
41 assert(nDim >= 7);
42}
43
44WireMeasurement::WireMeasurement(const TVectorD& rawHitCoords, const TMatrixDSym& rawHitCov, int detId, int hitId, TrackPoint* trackPoint)
45 : AbsMeasurement(rawHitCoords, rawHitCov, detId, hitId, trackPoint), maxDistance_(2), leftRight_(0)
46{
47 assert(rawHitCoords_.GetNrows() >= 7);
48}
49
51
52 // copy state. Neglect covariance.
53 StateOnPlane st(state);
54
55 TVector3 wire1(rawHitCoords_(0), rawHitCoords_(1), rawHitCoords_(2));
56 TVector3 wire2(rawHitCoords_(3), rawHitCoords_(4), rawHitCoords_(5));
57
58 //std::cout << " wire1(" << rawHitCoords_(0) << ", " << rawHitCoords_(1) << ", " << rawHitCoords_(2) << ")" << std::endl;
59 //std::cout << " wire2(" << rawHitCoords_(3) << ", " << rawHitCoords_(4) << ", " << rawHitCoords_(5) << ")" << std::endl;
60
61 // unit vector along the wire (V)
62 TVector3 wireDirection = wire2 - wire1;
63 wireDirection.SetMag(1.);
64
65 //std::cout << " wireDirection(" << wireDirection.X() << ", " << wireDirection.Y() << ", " << wireDirection.Z() << ")" << std::endl;
66
67 // point of closest approach
68 const AbsTrackRep* rep = state.getRep();
69 rep->extrapolateToLine(st, wire1, wireDirection);
70 const TVector3& poca = rep->getPos(st);
71 TVector3 dirInPoca = rep->getMom(st);
72 dirInPoca.SetMag(1.);
73 const TVector3& pocaOnWire = wire1 + wireDirection.Dot(poca - wire1)*wireDirection;
74
75 // check if direction is parallel to wire
76 if (fabs(wireDirection.Angle(dirInPoca)) < 0.01){
77 Exception exc("WireMeasurement::detPlane(): Cannot construct detector plane, direction is parallel to wire", __LINE__,__FILE__);
78 throw exc;
79 }
80
81 // construct orthogonal vector
82 TVector3 U = dirInPoca.Cross(wireDirection);
83 // U.SetMag(1.); automatically assured
84
85 return SharedPlanePtr(new DetPlane(pocaOnWire, U, wireDirection));
86}
87
88
89std::vector<MeasurementOnPlane*> WireMeasurement::constructMeasurementsOnPlane(const StateOnPlane& state) const
90{
91 double mR = rawHitCoords_(6);
92 double mL = -mR;
93 double V = rawHitCov_(6,6);
94
95 MeasurementOnPlane* mopL = new MeasurementOnPlane(TVectorD(1, &mL),
96 TMatrixDSym(1, &V),
97 state.getPlane(), state.getRep(), constructHMatrix(state.getRep()));
98
99 MeasurementOnPlane* mopR = new MeasurementOnPlane(TVectorD(1, &mR),
100 TMatrixDSym(1, &V),
101 state.getPlane(), state.getRep(), constructHMatrix(state.getRep()));
102
103 // set left/right weights
104 if (leftRight_ < 0) {
105 mopL->setWeight(1);
106 mopR->setWeight(0);
107 }
108 else if (leftRight_ > 0) {
109 mopL->setWeight(0);
110 mopR->setWeight(1);
111 }
112 else {
113 double val = 0.5 * pow(std::max(0., 1 - mR/maxDistance_), 2.);
114 mopL->setWeight(val);
115 mopR->setWeight(val);
116 }
117
118 std::vector<MeasurementOnPlane*> retVal;
119 retVal.push_back(mopL);
120 retVal.push_back(mopR);
121 return retVal;
122}
123
125 if (dynamic_cast<const RKTrackRep*>(rep) == NULL) {
126 Exception exc("WireMeasurement default implementation can only handle state vectors of type RKTrackRep!", __LINE__,__FILE__);
127 throw exc;
128 }
129
130 return new HMatrixU();
131}
132
134 if (lr==0) leftRight_ = 0;
135 else if (lr<0) leftRight_ = -1;
136 else leftRight_ = 1;
137}
138
139
140} /* End of namespace genfit */
HMatrix for projecting from AbsTrackRep parameters to measured parameters in a DetPlane.
Definition AbsHMatrix.h:37
Contains the measurement and covariance in raw detector coordinates.
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.
virtual TVector3 getPos(const StateOnPlane &state) const =0
Get the cartesian position 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 one-dimensional MeasurementOnPlane and RKTrackRep parameterization.
Definition HMatrixU.h:37
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 AbsTrackRep * getRep() const
const SharedPlanePtr & getPlane() const
Object containing AbsMeasurement and AbsFitterInfo objects.
Definition TrackPoint.h:50
virtual std::vector< MeasurementOnPlane * > constructMeasurementsOnPlane(const StateOnPlane &state) const
void setLeftRightResolution(int lr)
virtual SharedPlanePtr constructPlane(const StateOnPlane &state) const
virtual const AbsHMatrix * constructHMatrix(const AbsTrackRep *) const
Matrix inversion tools.
Definition AbsBField.h:29
boost::shared_ptr< genfit::DetPlane > SharedPlanePtr
Shared Pointer to a DetPlane.