CMS 3D CMS Logo

DTRecSegment4D.cc
Go to the documentation of this file.
1 
7 /* This Class Header */
9 
10 /* Collaborating Class Header */
13 /* C++ Headers */
14 
16  const DTSLRecSegment2D& zedSeg,
17  const LocalPoint& posZInCh,
18  const LocalVector& dirZInCh)
19  : RecSegment(phiSeg.chamberId()), theProjection(full), thePhiSeg(phiSeg), theZedSeg(zedSeg), theDimension(4) {
20  // Check consistency of 2 sub-segments
21  if (DTChamberId(phiSeg.geographicalId().rawId()) != DTChamberId(zedSeg.geographicalId().rawId()))
22  throw cms::Exception("DTRecSegment4D")
23  << "the z Segment and the phi segment have different chamber id" << std::endl;
24 
25  // The position of 2D segments are defined in the SL frame: I must first
26  // extrapolate that position at the Chamber reference plane
27  LocalPoint posZAt0 = posZInCh + dirZInCh * (-posZInCh.z()) / cos(dirZInCh.theta());
28 
29  thePosition = LocalPoint(phiSeg.localPosition().x(), posZAt0.y(), 0.);
30  LocalVector dirPhiInCh = phiSeg.localDirection();
31 
32  // given the actual definition of chamber refFrame, (with z poiniting to IP),
33  // the zed component of direction is negative.
34  theDirection = LocalVector(dirPhiInCh.x() / fabs(dirPhiInCh.z()), dirZInCh.y() / fabs(dirZInCh.z()), -1.);
36 
37  // set cov matrix
39  theCovMatrix[0][0] = phiSeg.covMatrix()[0][0]; //sigma (dx/dz)
40  theCovMatrix[0][2] = phiSeg.covMatrix()[0][1]; //cov(dx/dz,x)
41  theCovMatrix[2][2] = phiSeg.covMatrix()[1][1]; //sigma (x)
42  setCovMatrixForZed(posZInCh);
43 }
44 
46  : RecSegment(phiSeg.chamberId()),
47  theProjection(phi),
48  thePhiSeg(phiSeg),
49  theZedSeg(DTSLRecSegment2D()),
50  theDimension(2) {
52 
54 
55  // set cov matrix
57  theCovMatrix[0][0] = phiSeg.covMatrix()[0][0]; //sigma (dx/dz)
58  theCovMatrix[0][2] = phiSeg.covMatrix()[0][1]; //cov(dx/dz,x)
59  theCovMatrix[2][2] = phiSeg.covMatrix()[1][1]; //sigma (x)
60 }
61 
62 DTRecSegment4D::DTRecSegment4D(const DTSLRecSegment2D& zedSeg, const LocalPoint& posZInCh, const LocalVector& dirZInCh)
63  : RecSegment(zedSeg.superLayerId().chamberId()),
64  theProjection(Z),
65  thePhiSeg(DTChamberRecSegment2D()),
66  theZedSeg(zedSeg),
67  theDimension(2) {
68  LocalPoint posZAt0 = posZInCh + dirZInCh * (-posZInCh.z() / cos(dirZInCh.theta()));
69 
70  thePosition = posZAt0;
71  theDirection = dirZInCh;
72 
73  // set cov matrix
75  setCovMatrixForZed(posZInCh);
76 }
77 
79 
81  if (dimension() == 4) {
82  // (dx/dz,dy/dz,x,y)
84  result[2] = thePosition.x();
85  result[3] = thePosition.y();
86  result[0] = theDirection.x() / theDirection.z();
87  result[1] = theDirection.y() / theDirection.z();
88  return result;
89  }
90 
92  if (theProjection == phi) {
93  // (dx/dz,x)
94  result[1] = thePosition.x();
95  result[0] = theDirection.x() / theDirection.z();
96  } else if (theProjection == Z) {
97  // (dy/dz,y) (note we are in the chamber r.f.)
98  result[1] = thePosition.y();
99  result[0] = theDirection.y() / theDirection.z();
100  }
101  return result;
102 }
103 
105  if (dimension() == 4) {
106  return theCovMatrix;
107  }
108 
110  if (theProjection == phi) {
111  result[0][0] = theCovMatrix[0][0]; //S(dx/dz)
112  result[0][1] = theCovMatrix[0][2]; //Cov(dx/dz,x)
113  result[1][1] = theCovMatrix[2][2]; //S(x)
114  } else if (theProjection == Z) {
115  result[0][0] = theCovMatrix[1][1]; //S(dy/dz)
116  result[0][1] = theCovMatrix[1][3]; //Cov(dy/dz,y)
117  result[1][1] = theCovMatrix[3][3]; //S(y)
118  }
119  return result;
120 }
121 
122 //These methods are only used to initialize the const static values
123 // used by projectionMatrix().
126  the4DProjectionMatrix[0][1] = 1;
127  the4DProjectionMatrix[1][2] = 1;
128  the4DProjectionMatrix[2][3] = 1;
129  the4DProjectionMatrix[3][4] = 1;
130  return the4DProjectionMatrix;
131 }
133 
136  the2DPhiProjMatrix[0][1] = 1;
137  the2DPhiProjMatrix[1][3] = 1;
138  return the2DPhiProjMatrix;
139 }
141 
144  the2DZProjMatrix[0][2] = 1;
145  the2DZProjMatrix[1][4] = 1;
146  return the2DZProjMatrix;
147 }
149 
151  if (dimension() == 4) {
152  return the4DProjectionMatrix;
153  } else if (theProjection == phi) {
154  return the2DPhiProjMatrix;
155  } else if (theProjection == Z) {
156  return the2DZProjMatrix;
157  } else {
158  return AlgebraicMatrix();
159  }
160 }
161 
163  return LocalError(theCovMatrix[2][2], theCovMatrix[2][3], theCovMatrix[3][3]);
164 }
165 
167  return LocalError(theCovMatrix[0][0], theCovMatrix[0][1], theCovMatrix[1][1]);
168 }
169 
170 double DTRecSegment4D::chi2() const {
171  double result = 0;
172  if (hasPhi())
173  result += thePhiSeg.chi2();
174  if (hasZed())
175  result += theZedSeg.chi2();
176  return result;
177 }
178 
180  int result = 0;
181  if (hasPhi())
183  if (hasZed())
185  return result;
186 }
187 
189  // Warning!!! the covariance matrix for Theta SL segment is defined in the SL
190  // reference frame, here that in the Chamber ref frame must be used.
191  // For direction, no problem, but the position is extrapolated, so we must
192  // propagate the error properly.
193 
194  // many thanks to Paolo Ronchese for the help in deriving the formulas!
195 
196  // y=m*z+q in SL frame
197  // y=m'*z+q' in CH frame
198 
199  // var(m') = var(m)
200  theCovMatrix[1][1] = theZedSeg.parametersError()[0][0]; //sigma (dy/dz)
201 
202  // cov(m',q') = DeltaZ*Var(m) + Cov(m,q)
203  theCovMatrix[1][3] =
204  posZInCh.z() * theZedSeg.parametersError()[0][0] + theZedSeg.parametersError()[0][1]; //cov(dy/dz,y)
205 
206  // Var(q') = DeltaZ^2*Var(m) + Var(q) + 2*DeltaZ*Cov(m,q)
207  // cout << "Var(q') = DeltaZ^2*Var(m) + Var(q) + 2*DeltaZ*Cov(m,q)" << endl;
208  // cout << "Var(q')= " << posZInCh.z()*posZInCh.z() << "*" <<
209  // theZedSeg.parametersError()[0][0] << " + " <<
210  // theZedSeg.parametersError()[1][1] << " + " <<
211  // 2*posZInCh.z() << "*" << theZedSeg.parametersError()[0][1] ;
212  theCovMatrix[3][3] = 2. * (posZInCh.z() * posZInCh.z()) * theZedSeg.parametersError()[0][0] +
213  theZedSeg.parametersError()[1][1] + 2. * posZInCh.z() * theZedSeg.parametersError()[0][1];
214  // cout << " = " << theCovMatrix[3][3] << endl;
215 }
216 
217 std::ostream& operator<<(std::ostream& os, const DTRecSegment4D& seg) {
218  os << "Pos " << seg.localPosition() << " Dir: " << seg.localDirection() << " dim: " << seg.dimension()
219  << " chi2/ndof: " << seg.chi2() << "/" << seg.degreesOfFreedom() << " :";
220  if (seg.hasPhi())
221  os << seg.phiSegment()->recHits().size();
222  else
223  os << 0;
224  os << ":";
225  if (seg.hasZed())
226  os << seg.zSegment()->recHits().size();
227  else
228  os << 0;
229  return os;
230 }
231 
233 std::vector<const TrackingRecHit*> DTRecSegment4D::recHits() const {
234  std::vector<const TrackingRecHit*> pointersOfRecHits;
235 
236  if (hasPhi())
237  pointersOfRecHits.push_back(phiSegment());
238  if (hasZed())
239  pointersOfRecHits.push_back(zSegment());
240 
241  return pointersOfRecHits;
242 }
243 
245 std::vector<TrackingRecHit*> DTRecSegment4D::recHits() {
246  std::vector<TrackingRecHit*> pointersOfRecHits;
247 
248  if (hasPhi())
249  pointersOfRecHits.push_back(phiSegment());
250  if (hasZed())
251  pointersOfRecHits.push_back(zSegment());
252 
253  return pointersOfRecHits;
254 }
255 
Vector3DBase< float, LocalTag >
initThe2DZProjMatrix
static AlgebraicMatrix initThe2DZProjMatrix()
Definition: DTRecSegment4D.cc:142
DTSLRecSegment2D
Definition: DTSLRecSegment2D.h:15
DTRecSegment4D::DTRecSegment4D
DTRecSegment4D()
Empty constructor.
Definition: DTRecSegment4D.h:27
DTRecSegment4D
Definition: DTRecSegment4D.h:23
DTRecSegment4D::dimension
int dimension() const override
Dimension (in parameter space)
Definition: DTRecSegment4D.h:79
DTRecSegment4D::localDirection
LocalVector localDirection() const override
Local direction in Chamber frame.
Definition: DTRecSegment4D.h:67
DTRecSegment4D::localDirectionError
LocalError localDirectionError() const override
Local direction error in the Chamber frame.
Definition: DTRecSegment4D.cc:166
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
PV3DBase::theta
Geom::Theta< T > theta() const
Definition: PV3DBase.h:72
RecSegment
Definition: RecSegment.h:27
the2DZProjMatrix
static const AlgebraicMatrix the2DZProjMatrix
Definition: DTRecSegment4D.cc:148
DTRecSegment4D::chamberId
virtual DTChamberId chamberId() const
The (specific) DetId of the chamber on which the segment resides.
Definition: DTRecSegment4D.cc:256
DTRecSegment4D::setCovMatrixForZed
void setCovMatrixForZed(const LocalPoint &posZInCh)
Definition: DTRecSegment4D.cc:188
DTRecSegment4D::thePhiSeg
DTChamberRecSegment2D thePhiSeg
Definition: DTRecSegment4D.h:138
full
Definition: GenABIO.cc:168
align::LocalPoint
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
DTRecSegment4D::localPosition
LocalPoint localPosition() const override
Local position in Chamber frame.
Definition: DTRecSegment4D.h:61
DTRecSegment4D::zSegment
const DTSLRecSegment2D * zSegment() const
The Z segment: 0 if not zed projection available.
Definition: DTRecSegment4D.h:99
DTRecSegment4D::thePosition
LocalPoint thePosition
Definition: DTRecSegment4D.h:124
TrackingRecHit::geographicalId
DetId geographicalId() const
Definition: TrackingRecHit.h:120
DTRecSegment4D::recHits
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
Definition: DTRecSegment4D.cc:233
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
DTRecSegment2D::recHits
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
Definition: DTRecSegment2D.cc:86
operator<<
std::ostream & operator<<(std::ostream &os, const DTRecSegment4D &seg)
Definition: DTRecSegment4D.cc:217
Vector3DBase::unit
Vector3DBase unit() const
Definition: Vector3DBase.h:54
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
AlgebraicVector
CLHEP::HepVector AlgebraicVector
Definition: AlgebraicObjects.h:13
the2DPhiProjMatrix
static const AlgebraicMatrix the2DPhiProjMatrix
Definition: DTRecSegment4D.cc:140
DTRecSegment4D::Z
Definition: DTRecSegment4D.h:115
DTRecSegment4D::theProjection
Projection theProjection
Definition: DTRecSegment4D.h:116
DTRecSegment4D::theDirection
LocalVector theDirection
Definition: DTRecSegment4D.h:125
Point3DBase< float, LocalTag >
DTChamberId.h
DTRecSegment4D::degreesOfFreedom
int degreesOfFreedom() const override
Degrees of freedom of the segment fit.
Definition: DTRecSegment4D.cc:179
initThe2DPhiProjMatrix
static AlgebraicMatrix initThe2DPhiProjMatrix()
Definition: DTRecSegment4D.cc:134
DTRecSegment4D::parametersError
AlgebraicSymMatrix parametersError() const override
Covariance matrix fo parameters()
Definition: DTRecSegment4D.cc:104
DTRecSegment2D::chi2
double chi2() const override
the chi2 of the fit
Definition: DTRecSegment2D.h:96
PVValHelper::phi
Definition: PVValidationHelpers.h:68
LocalError
Definition: LocalError.h:12
DTRecSegment4D::projectionMatrix
AlgebraicMatrix projectionMatrix() const override
The projection matrix relates the trajectory state parameters to the segment parameters().
Definition: DTRecSegment4D.cc:150
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
LocalVector
Local3DVector LocalVector
Definition: LocalVector.h:12
initThe4DProjectionMatrix
static AlgebraicMatrix initThe4DProjectionMatrix()
Definition: DTRecSegment4D.cc:124
DTRecSegment2D::localPosition
LocalPoint localPosition() const override
local position in SL frame
Definition: DTRecSegment2D.h:84
DTChamberRecSegment2D
Definition: DTChamberRecSegment2D.h:31
DOFs::Z
Definition: AlignPCLThresholdsWriter.cc:37
DTRecSegment4D::parameters
AlgebraicVector parameters() const override
Definition: DTRecSegment4D.cc:80
AlgebraicSymMatrix
CLHEP::HepSymMatrix AlgebraicSymMatrix
Definition: AlgebraicObjects.h:15
DTRecSegment4D.h
DTRecSegment2D::covMatrix
AlgebraicSymMatrix covMatrix() const
the Covariance Matrix
Definition: DTRecSegment2D.h:111
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
AlgebraicMatrix
CLHEP::HepMatrix AlgebraicMatrix
Definition: AlgebraicObjects.h:14
DTRecSegment4D::hasZed
bool hasZed() const
Does it have the Z projection?
Definition: DTRecSegment4D.h:93
DTRecSegment4D::theZedSeg
DTSLRecSegment2D theZedSeg
Definition: DTRecSegment4D.h:139
Exception
Definition: hltDiff.cc:246
DTRecSegment2D::parametersError
AlgebraicSymMatrix parametersError() const override
Definition: DTRecSegment2D.cc:29
DTRecSegment4D::localPositionError
LocalError localPositionError() const override
Local position error in Chamber frame.
Definition: DTRecSegment4D.cc:162
DTRecSegment4D::chi2
double chi2() const override
Chi2 of the segment fit.
Definition: DTRecSegment4D.cc:170
Exception.h
DTRecSegment4D::hasPhi
bool hasPhi() const
Does it have the Phi projection?
Definition: DTRecSegment4D.h:90
DTRecSegment4D::~DTRecSegment4D
~DTRecSegment4D() override
Destructor.
Definition: DTRecSegment4D.cc:78
DTRecSegment2D::degreesOfFreedom
int degreesOfFreedom() const override
return the DOF of the segment
Definition: DTRecSegment2D.cc:78
mps_fire.result
result
Definition: mps_fire.py:303
DTRecSegment2D::localDirection
LocalVector localDirection() const override
the local direction in SL frame
Definition: DTRecSegment2D.h:90
DTChamberId
Definition: DTChamberId.h:14
DTRecSegment4D::theCovMatrix
AlgebraicSymMatrix theCovMatrix
Definition: DTRecSegment4D.h:136
DTRecSegment4D::phiSegment
const DTChamberRecSegment2D * phiSegment() const
The superPhi segment: 0 if no phi projection available.
Definition: DTRecSegment4D.h:96
the4DProjectionMatrix
static const AlgebraicMatrix the4DProjectionMatrix
Definition: DTRecSegment4D.cc:132
DTRecSegment4D::phi
Definition: DTRecSegment4D.h:115