Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:02

0001 /** \file
0002  *
0003  * \author Stefano Lacaprara - INFN Legnaro <stefano.lacaprara@pd.infn.it>
0004  * \author Riccardo Bellan - INFN TO <riccardo.bellan@cern.ch>
0005  */
0006 
0007 /* This Class Header */
0008 #include "DataFormats/DTRecHit/interface/DTRecSegment2D.h"
0009 
0010 /* Collaborating Class Header */
0011 
0012 /* C++ Headers */
0013 #include <iostream>
0014 using namespace std;
0015 /* ====================================================================== */
0016 
0017 /* static member definition */
0018 
0019 //This function is only used to initialize theProjectionMatrix at load time
0020 static AlgebraicMatrix initTheProjectionMatrix() {
0021   AlgebraicMatrix theProjectionMatrix(2, 5, 0);
0022   theProjectionMatrix[0][1] = 1;
0023   theProjectionMatrix[1][3] = 1;
0024   return theProjectionMatrix;
0025 }
0026 const AlgebraicMatrix DTRecSegment2D::theProjectionMatrix{initTheProjectionMatrix()};
0027 
0028 /* Operations */
0029 AlgebraicSymMatrix DTRecSegment2D::parametersError() const {
0030   AlgebraicSymMatrix m(2);
0031   /// mat[0][0]=sigma (dx/dz)
0032   /// mat[1][1]=sigma (x)
0033   /// mat[0][1]=cov(dx/dz,x)
0034   // if ( det().alignmentPositionError()) {
0035   //   LocalError lape =
0036   //     ErrorFrameTransformer().transform( det().alignmentPositionError()->globalError(),
0037   //                                        det().surface());
0038   //   m[0][0] = lv.xx();
0039   //   m[0][1] = 0.;
0040   //   m[1][1] = lp.xx()+lape.xx();
0041   // } else {
0042   m[0][0] = theCovMatrix[0][0];
0043   m[0][1] = theCovMatrix[0][1];
0044   m[1][1] = theCovMatrix[1][1];
0045   //};
0046 
0047   //cout << "theCovMatrix elements " << theCovMatrix[0][0] << " , " << theCovMatrix[0][1] <<
0048   //        " , " << theCovMatrix[1][0] << " , " << theCovMatrix[1][1] << endl;
0049 
0050   return m;
0051 }
0052 
0053 DTRecSegment2D::~DTRecSegment2D() {}
0054 
0055 DTRecSegment2D::DTRecSegment2D(DetId id, const vector<DTRecHit1D>& hits)
0056     : RecSegment(id), theChi2(0.0), theT0(0.), theVdrift(0.), theHits(hits) {}
0057 
0058 DTRecSegment2D::DTRecSegment2D(DetId id,
0059                                LocalPoint& position,
0060                                LocalVector& direction,
0061                                AlgebraicSymMatrix& covMatrix,
0062                                double chi2,
0063                                std::vector<DTRecHit1D>& hits1D)
0064     : RecSegment(id),
0065       thePosition(position),
0066       theDirection(direction),
0067       theCovMatrix(covMatrix),
0068       theChi2(chi2),
0069       theT0(0.),
0070       theVdrift(0.),
0071       theHits(hits1D) {}
0072 
0073 /* Operations */
0074 LocalError DTRecSegment2D::localPositionError() const { return LocalError(theCovMatrix[1][1], 0., 0.); }
0075 
0076 LocalError DTRecSegment2D::localDirectionError() const { return LocalError(theCovMatrix[0][0], 0., 0.); }
0077 
0078 int DTRecSegment2D::degreesOfFreedom() const { return theHits.size() - dimension(); }
0079 
0080 ostream& operator<<(ostream& os, const DTRecSegment2D& seg) {
0081   os << "Pos " << seg.localPosition() << " Dir: " << seg.localDirection() << " chi2/ndof: " << seg.chi2() << "/"
0082      << seg.degreesOfFreedom();
0083   return os;
0084 }
0085 
0086 std::vector<const TrackingRecHit*> DTRecSegment2D::recHits() const {
0087   std::vector<const TrackingRecHit*> pointersOfRecHits;
0088 
0089   for (std::vector<DTRecHit1D>::const_iterator rechit = theHits.begin(); rechit != theHits.end(); rechit++)
0090     pointersOfRecHits.push_back(&(*rechit));
0091 
0092   return pointersOfRecHits;
0093 }
0094 
0095 std::vector<TrackingRecHit*> DTRecSegment2D::recHits() {
0096   std::vector<TrackingRecHit*> pointersOfRecHits;
0097 
0098   for (std::vector<DTRecHit1D>::iterator rechit = theHits.begin(); rechit != theHits.end(); rechit++)
0099     pointersOfRecHits.push_back(&(*rechit));
0100 
0101   return pointersOfRecHits;
0102 }
0103 
0104 std::vector<DTRecHit1D> DTRecSegment2D::specificRecHits() const { return theHits; }
0105 
0106 void DTRecSegment2D::update(std::vector<DTRecHit1D>& updatedRecHits) { theHits = updatedRecHits; }
0107 
0108 void DTRecSegment2D::setPosition(const LocalPoint& pos) { thePosition = pos; }
0109 
0110 void DTRecSegment2D::setDirection(const LocalVector& dir) { theDirection = dir; }
0111 
0112 void DTRecSegment2D::setCovMatrix(const AlgebraicSymMatrix& cov) { theCovMatrix = cov; }
0113 
0114 void DTRecSegment2D::setChi2(const double& chi2) { theChi2 = chi2; }
0115 
0116 void DTRecSegment2D::setT0(const double& t0) { theT0 = t0; }
0117 
0118 void DTRecSegment2D::setVdrift(const double& vdrift) { theVdrift = vdrift; }