Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
/** \file
 *
 * \author Stefano Lacaprara - INFN Legnaro <stefano.lacaprara@pd.infn.it>
 * \author Riccardo Bellan - INFN TO <riccardo.bellan@cern.ch>
 */

/* This Class Header */
#include "DataFormats/DTRecHit/interface/DTRecSegment2D.h"

/* Collaborating Class Header */

/* C++ Headers */
#include <iostream>
using namespace std;
/* ====================================================================== */

/* static member definition */

//This function is only used to initialize theProjectionMatrix at load time
static AlgebraicMatrix initTheProjectionMatrix() {
  AlgebraicMatrix theProjectionMatrix(2, 5, 0);
  theProjectionMatrix[0][1] = 1;
  theProjectionMatrix[1][3] = 1;
  return theProjectionMatrix;
}
const AlgebraicMatrix DTRecSegment2D::theProjectionMatrix{initTheProjectionMatrix()};

/* Operations */
AlgebraicSymMatrix DTRecSegment2D::parametersError() const {
  AlgebraicSymMatrix m(2);
  /// mat[0][0]=sigma (dx/dz)
  /// mat[1][1]=sigma (x)
  /// mat[0][1]=cov(dx/dz,x)
  // if ( det().alignmentPositionError()) {
  //   LocalError lape =
  //     ErrorFrameTransformer().transform( det().alignmentPositionError()->globalError(),
  //                                        det().surface());
  //   m[0][0] = lv.xx();
  //   m[0][1] = 0.;
  //   m[1][1] = lp.xx()+lape.xx();
  // } else {
  m[0][0] = theCovMatrix[0][0];
  m[0][1] = theCovMatrix[0][1];
  m[1][1] = theCovMatrix[1][1];
  //};

  //cout << "theCovMatrix elements " << theCovMatrix[0][0] << " , " << theCovMatrix[0][1] <<
  //        " , " << theCovMatrix[1][0] << " , " << theCovMatrix[1][1] << endl;

  return m;
}

DTRecSegment2D::~DTRecSegment2D() {}

DTRecSegment2D::DTRecSegment2D(DetId id, const vector<DTRecHit1D>& hits)
    : RecSegment(id), theChi2(0.0), theT0(0.), theVdrift(0.), theHits(hits) {}

DTRecSegment2D::DTRecSegment2D(DetId id,
                               LocalPoint& position,
                               LocalVector& direction,
                               AlgebraicSymMatrix& covMatrix,
                               double chi2,
                               std::vector<DTRecHit1D>& hits1D)
    : RecSegment(id),
      thePosition(position),
      theDirection(direction),
      theCovMatrix(covMatrix),
      theChi2(chi2),
      theT0(0.),
      theVdrift(0.),
      theHits(hits1D) {}

/* Operations */
LocalError DTRecSegment2D::localPositionError() const { return LocalError(theCovMatrix[1][1], 0., 0.); }

LocalError DTRecSegment2D::localDirectionError() const { return LocalError(theCovMatrix[0][0], 0., 0.); }

int DTRecSegment2D::degreesOfFreedom() const { return theHits.size() - dimension(); }

ostream& operator<<(ostream& os, const DTRecSegment2D& seg) {
  os << "Pos " << seg.localPosition() << " Dir: " << seg.localDirection() << " chi2/ndof: " << seg.chi2() << "/"
     << seg.degreesOfFreedom();
  return os;
}

std::vector<const TrackingRecHit*> DTRecSegment2D::recHits() const {
  std::vector<const TrackingRecHit*> pointersOfRecHits;

  for (std::vector<DTRecHit1D>::const_iterator rechit = theHits.begin(); rechit != theHits.end(); rechit++)
    pointersOfRecHits.push_back(&(*rechit));

  return pointersOfRecHits;
}

std::vector<TrackingRecHit*> DTRecSegment2D::recHits() {
  std::vector<TrackingRecHit*> pointersOfRecHits;

  for (std::vector<DTRecHit1D>::iterator rechit = theHits.begin(); rechit != theHits.end(); rechit++)
    pointersOfRecHits.push_back(&(*rechit));

  return pointersOfRecHits;
}

std::vector<DTRecHit1D> DTRecSegment2D::specificRecHits() const { return theHits; }

void DTRecSegment2D::update(std::vector<DTRecHit1D>& updatedRecHits) { theHits = updatedRecHits; }

void DTRecSegment2D::setPosition(const LocalPoint& pos) { thePosition = pos; }

void DTRecSegment2D::setDirection(const LocalVector& dir) { theDirection = dir; }

void DTRecSegment2D::setCovMatrix(const AlgebraicSymMatrix& cov) { theCovMatrix = cov; }

void DTRecSegment2D::setChi2(const double& chi2) { theChi2 = chi2; }

void DTRecSegment2D::setT0(const double& t0) { theT0 = t0; }

void DTRecSegment2D::setVdrift(const double& vdrift) { theVdrift = vdrift; }