GENFIT  Rev:NoNumberAvailable
SpacepointMeasurement.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 
20 #include "SpacepointMeasurement.h"
21 
22 #include "Exception.h"
23 #include "RKTrackRep.h"
24 #include "Tools.h"
25 #include "HMatrixUV.h"
26 #include "MeasurementOnPlane.h"
27 
28 #include <cassert>
29 #include <TBuffer.h>
30 
31 namespace genfit {
32 
34  : AbsMeasurement(nDim), weightedPlaneContruction_(true), G_(3), cutCov_(true)
35 {
36  assert(nDim >= 3);
37 
38  //this->initG();
39 }
40 
41 SpacepointMeasurement::SpacepointMeasurement(const TVectorD& rawHitCoords, const TMatrixDSym& rawHitCov, int detId, int hitId, TrackPoint* trackPoint,
42  bool weightedPlaneContruction, bool cutCov)
43  : AbsMeasurement(rawHitCoords, rawHitCov, detId, hitId, trackPoint),
44  weightedPlaneContruction_(weightedPlaneContruction), cutCov_(cutCov)
45 {
46  assert(rawHitCoords_.GetNrows() >= 3);
47 
49  this->initG();
50 }
51 
52 
54 
55  // copy state. Neglect covariance.
56  StateOnPlane st(state);
57 
58  const TVector3 point(rawHitCoords_(0), rawHitCoords_(1), rawHitCoords_(2));
59 
61  st.extrapolateToPoint(point, G_);
62  else
63  st.extrapolateToPoint(point);
64 
65  return st.getPlane();
66 }
67 
68 
69 std::vector<MeasurementOnPlane*> SpacepointMeasurement::constructMeasurementsOnPlane(const StateOnPlane& state) const
70 {
71  MeasurementOnPlane* mop = new MeasurementOnPlane(TVectorD(2),
72  TMatrixDSym(3), // will be resized to 2x2 by Similarity later
73  state.getPlane(), state.getRep(), constructHMatrix(state.getRep()));
74 
75  TVectorD& m = mop->getState();
76  TMatrixDSym& V = mop->getCov();
77 
78  const TVector3& o(state.getPlane()->getO());
79  const TVector3& u(state.getPlane()->getU());
80  const TVector3& v(state.getPlane()->getV());
81 
82  // m
83  m(0) = (rawHitCoords_(0)-o.X()) * u.X() +
84  (rawHitCoords_(1)-o.Y()) * u.Y() +
85  (rawHitCoords_(2)-o.Z()) * u.Z();
86 
87  m(1) = (rawHitCoords_(0)-o.X()) * v.X() +
88  (rawHitCoords_(1)-o.Y()) * v.Y() +
89  (rawHitCoords_(2)-o.Z()) * v.Z();
90 
91  //
92  // V
93  //
94  V = rawHitCov_;
95 
96  // jac = dF_i/dx_j = s_unitvec * t_untivec, with s=u,v and t=x,y,z
97  TMatrixD jac(3,2);
98  jac(0,0) = u.X();
99  jac(1,0) = u.Y();
100  jac(2,0) = u.Z();
101  jac(0,1) = v.X();
102  jac(1,1) = v.Y();
103  jac(2,1) = v.Z();
104 
105  if (cutCov_) { // cut (default)
107  V.SimilarityT(jac);
109  }
110  else { // projection
111  V.SimilarityT(jac);
112  }
113 
114  std::vector<MeasurementOnPlane*> retVal;
115  retVal.push_back(mop);
116  return retVal;
117 }
118 
119 
121  if (dynamic_cast<const RKTrackRep*>(rep) == NULL) {
122  Exception exc("SpacepointMeasurement default implementation can only handle state vectors of type RKTrackRep!", __LINE__,__FILE__);
123  throw exc;
124  }
125 
126  return new HMatrixUV();
127 }
128 
129 
131  rawHitCov_.GetSub(0, 2, G_);
133 }
134 
135 
136 // Modified from auto-generated Streamer to account for non-persistent G_
137 void SpacepointMeasurement::Streamer(TBuffer &R__b)
138 {
139  // Stream an object of class genfit::SpacepointMeasurement.
140 
141  if (R__b.IsReading()) {
142  R__b.ReadClassBuffer(genfit::SpacepointMeasurement::Class(),this);
143 
145  this->initG();
146  } else {
147  R__b.WriteClassBuffer(genfit::SpacepointMeasurement::Class(),this);
148  }
149 }
150 
151 
152 } /* End of namespace genfit */
genfit::SharedPlanePtr
boost::shared_ptr< genfit::DetPlane > SharedPlanePtr
Shared Pointer to a DetPlane.
Definition: SharedPlanePtr.h:43
genfit::SpacepointMeasurement::initG
void initG()
Definition: SpacepointMeasurement.cc:130
genfit::tools::invertMatrix
void invertMatrix(const TMatrixDSym &mat, TMatrixDSym &inv, double *determinant=NULL)
Invert a matrix, throwing an Exception when inversion fails. Optional calculation of determinant.
Definition: Tools.cc:40
genfit::MeasuredStateOnPlane::getCov
const TMatrixDSym & getCov() const
Definition: MeasuredStateOnPlane.h:55
SpacepointMeasurement.h
genfit::AbsHMatrix
HMatrix for projecting from AbsTrackRep parameters to measured parameters in a DetPlane.
Definition: AbsHMatrix.h:37
genfit::Exception
Exception class for error handling in GENFIT (provides storage for diagnostic information)
Definition: Exception.h:48
genfit
Defines for I/O streams used for error and debug printing.
Definition: AbsFinitePlane.cc:22
genfit::SpacepointMeasurement::constructHMatrix
virtual const AbsHMatrix * constructHMatrix(const AbsTrackRep *) const
Definition: SpacepointMeasurement.cc:120
genfit::SpacepointMeasurement::weightedPlaneContruction_
bool weightedPlaneContruction_
Definition: SpacepointMeasurement.h:78
genfit::AbsMeasurement::rawHitCov_
TMatrixDSym rawHitCov_
Definition: AbsMeasurement.h:114
genfit::SpacepointMeasurement::G_
TMatrixDSym G_
Definition: SpacepointMeasurement.h:79
genfit::AbsTrackRep
Abstract base class for a track representation.
Definition: AbsTrackRep.h:66
genfit::SpacepointMeasurement::SpacepointMeasurement
SpacepointMeasurement(int nDim=3)
Definition: SpacepointMeasurement.cc:33
genfit::SpacepointMeasurement::constructPlane
virtual SharedPlanePtr constructPlane(const StateOnPlane &state) const
Contruct the virtual detector plane.
Definition: SpacepointMeasurement.cc:53
genfit::AbsMeasurement
Contains the measurement and covariance in raw detector coordinates.
Definition: AbsMeasurement.h:42
genfit::AbsMeasurement::rawHitCoords_
TVectorD rawHitCoords_
Definition: AbsMeasurement.h:113
genfit::TrackPoint
Object containing AbsMeasurement and AbsFitterInfo objects.
Definition: TrackPoint.h:50
genfit::HMatrixUV
AbsHMatrix implementation for two-dimensional MeasurementOnPlane and RKTrackRep parameterization.
Definition: HMatrixUV.h:39
genfit::StateOnPlane
A state with arbitrary dimension defined in a DetPlane.
Definition: StateOnPlane.h:45
HMatrixUV.h
genfit::SpacepointMeasurement::constructMeasurementsOnPlane
virtual std::vector< MeasurementOnPlane * > constructMeasurementsOnPlane(const StateOnPlane &state) const
Definition: SpacepointMeasurement.cc:69
MeasurementOnPlane.h
genfit::MeasurementOnPlane
Measured coordinates on a plane.
Definition: MeasurementOnPlane.h:45
Tools.h
genfit::StateOnPlane::getPlane
const SharedPlanePtr & getPlane() const
Definition: StateOnPlane.h:65
RKTrackRep.h
genfit::StateOnPlane::getState
const TVectorD & getState() const
Definition: StateOnPlane.h:61
genfit::SpacepointMeasurement::cutCov_
bool cutCov_
inverse of 3x3 cov
Definition: SpacepointMeasurement.h:80
Exception.h
genfit::StateOnPlane::extrapolateToPoint
double extrapolateToPoint(const TVector3 &point, bool stopAtBoundary=false, bool calcJacobianNoise=false)
Definition: StateOnPlane.h:82
genfit::StateOnPlane::getRep
const AbsTrackRep * getRep() const
Definition: StateOnPlane.h:66