Belle II Software  release-08-01-10
ProlateSpacepointMeasurement.cc
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 "ProlateSpacepointMeasurement.h"
21 
22 #include <cmath>
23 
24 #include "Exception.h"
25 #include "RKTrackRep.h"
26 
27 
28 namespace genfit {
29 
30 ProlateSpacepointMeasurement::ProlateSpacepointMeasurement(int nDim)
31  : SpacepointMeasurement(nDim), largestErrorDirection_(0,0,1)
32 {
33  ;
34 }
35 
36 ProlateSpacepointMeasurement::ProlateSpacepointMeasurement(const TVectorD& rawHitCoords, const TMatrixDSym& rawHitCov, int detId, int hitId, TrackPoint* trackPoint)
37  : SpacepointMeasurement(rawHitCoords, rawHitCov, detId, hitId, trackPoint), largestErrorDirection_(0,0,1)
38 {
39  ;
40 }
41 
42 
43 SharedPlanePtr ProlateSpacepointMeasurement::constructPlane(const StateOnPlane& state) const {
44 
45  // copy state. Neglect covariance.
46  StateOnPlane st(state);
47 
48 
49  const TVector3 wire1(rawHitCoords_(0), rawHitCoords_(1), rawHitCoords_(2));
50 
51  const AbsTrackRep* rep = state.getRep();
52  rep->extrapolateToLine(st, wire1, largestErrorDirection_);
53 
54  TVector3 dirInPoca = rep->getMom(st);
55  dirInPoca.SetMag(1.);
56 
57  // check if direction is parallel to wire
58  if (fabs(largestErrorDirection_.Angle(dirInPoca)) < 0.01){
59  Exception exc("ProlateSpacepointMeasurement::constructPlane(): Cannot construct detector plane, track direction is parallel to largest error direction", __LINE__,__FILE__);
60  throw exc;
61  }
62 
63  // construct orthogonal vector
64  TVector3 U = largestErrorDirection_.Cross(dirInPoca);
65 
66  return SharedPlanePtr(new DetPlane(wire1, U, largestErrorDirection_));
67 }
68 
69 
70 } /* End of namespace genfit */
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:59
Exception class for error handling in GENFIT (provides storage for diagnostic information)
Definition: Exception.h:48
A state with arbitrary dimension defined in a DetPlane.
Definition: StateOnPlane.h:47
Defines for I/O streams used for error and debug printing.
std::shared_ptr< genfit::DetPlane > SharedPlanePtr
Shared Pointer to a DetPlane.