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
/** \file
 *
 *  \author G. Cerminara - INFN Torino
 */

#include "DataFormats/DTRecHit/interface/DTRecHit1D.h"

using namespace std;
using namespace DTEnums;

// Constructor from wireId and digi time only.
DTRecHit1D::DTRecHit1D(const DTWireId& wireId,
                       DTEnums::DTCellSide lr,
                       float digiTime)
    : RecHit1D(wireId.layerId()),  // the detId of the Det (a DTLayer).
      theWireId(wireId),
      theLRSide(lr),
      theDigiTime(digiTime),
      theLocalPosition(),
      theLocalError() {}

// Default constructor
DTRecHit1D::DTRecHit1D() : theWireId(), theLRSide(undefLR), theDigiTime(-1), theLocalPosition(), theLocalError() {}

// Constructor from a local position, wireId and digi time.
// The 3-dimensional local error is defined as
// resolution (the cell resolution) for the coordinate being measured
// and 0 for the two other coordinates
DTRecHit1D::DTRecHit1D(const DTWireId& wireId,
                       DTEnums::DTCellSide lr,
                       float digiTime,
                       const LocalPoint& pos)
    : RecHit1D(wireId.layerId()),  // the detId of the Det (a DTLayer).
      theWireId(wireId),
      theLRSide(lr),
      theDigiTime(digiTime),
      theLocalPosition(pos) {
  float cellResolution = 0.02;                                          //cm  cell resolution = 200 um = 0.02 cm
  theLocalError = LocalError(cellResolution * cellResolution, 0., 0.);  //FIXME: is it really needed?
}

// Constructor from a local position and error, wireId and digi time.
DTRecHit1D::DTRecHit1D(
    const DTWireId& wireId, DTEnums::DTCellSide lr, float digiTime, const LocalPoint& pos, const LocalError& err)
    : RecHit1D(wireId.layerId()),
      theWireId(wireId),
      theLRSide(lr),
      theDigiTime(digiTime),
      theLocalPosition(pos),
      theLocalError(err) {}

// Destructor
DTRecHit1D::~DTRecHit1D() {}

DTRecHit1D* DTRecHit1D::clone() const { return new DTRecHit1D(*this); }

// Access to component RecHits.
// No components rechits: it returns a null vector
vector<const TrackingRecHit*> DTRecHit1D::recHits() const {
  vector<const TrackingRecHit*> nullvector;
  return nullvector;
}

// Non-const access to component RecHits.
// No components rechits: it returns a null vector
vector<TrackingRecHit*> DTRecHit1D::recHits() {
  vector<TrackingRecHit*> nullvector;
  return nullvector;
}

// Comparison operator, based on the wireId and the digi time
bool DTRecHit1D::operator==(const DTRecHit1D& hit) const {
  return wireId() == hit.wireId() && fabs(digiTime() - hit.digiTime()) < 0.1;
}

// The ostream operator
ostream& operator<<(ostream& os, const DTRecHit1D& hit) {
  os << "pos: " << hit.localPosition().x();
  os << " +/- " << sqrt(hit.localPositionError().xx());
  return os;
}