00001
00007 #include <DataFormats/CSCRecHit/interface/CSCSegment.h>
00008 #include <iostream>
00009
00010 namespace {
00011
00012 inline
00013 DetId buildDetId(CSCDetId id) {
00014 return CSCDetId(id.endcap(),id.station(),id.ring(),id.chamber(), 0);
00015 }
00016
00017 }
00018
00019 CSCSegment::CSCSegment(std::vector<const CSCRecHit2D*> proto_segment, LocalPoint origin,
00020 LocalVector direction, AlgebraicSymMatrix errors, double chi2) :
00021 RecSegment(buildDetId(proto_segment.front()->cscDetId())),
00022 theOrigin(origin),
00023 theLocalDirection(direction), theCovMatrix(errors), theChi2(chi2) {
00024
00025 for(unsigned int i=0; i<proto_segment.size(); i++)
00026 theCSCRecHits.push_back(*proto_segment[i]);
00027 }
00028
00029 CSCSegment::~CSCSegment() {}
00030
00031 std::vector<const TrackingRecHit*> CSCSegment::recHits() const{
00032 std::vector<const TrackingRecHit*> pointersOfRecHits;
00033 for (std::vector<CSCRecHit2D>::const_iterator irh = theCSCRecHits.begin(); irh!=theCSCRecHits.end(); ++irh) {
00034 pointersOfRecHits.push_back(&(*irh));
00035 }
00036 return pointersOfRecHits;
00037 }
00038
00039 std::vector<TrackingRecHit*> CSCSegment::recHits() {
00040
00041 std::vector<TrackingRecHit*> pointersOfRecHits;
00042 for (std::vector<CSCRecHit2D>::iterator irh = theCSCRecHits.begin(); irh!=theCSCRecHits.end(); ++irh) {
00043 pointersOfRecHits.push_back(&(*irh));
00044 }
00045 return pointersOfRecHits;
00046 }
00047
00048 LocalError CSCSegment::localPositionError() const {
00049 return LocalError(theCovMatrix[2][2], theCovMatrix[2][3], theCovMatrix[3][3]);
00050 }
00051
00052 LocalError CSCSegment::localDirectionError() const {
00053 return LocalError(theCovMatrix[0][0], theCovMatrix[0][1], theCovMatrix[1][1]);
00054 }
00055
00056
00057 AlgebraicVector CSCSegment::parameters() const {
00058
00059
00060
00061 AlgebraicVector result(4);
00062
00063 result[0] = theLocalDirection.x()/theLocalDirection.z();
00064 result[1] = theLocalDirection.y()/theLocalDirection.z();
00065 result[2] = theOrigin.x();
00066 result[3] = theOrigin.y();
00067
00068 return result;
00069 }
00070
00071
00072 AlgebraicMatrix CSCSegment::projectionMatrix() const {
00073 static AlgebraicMatrix theProjectionMatrix( 4, 5, 0);
00074 static bool isInitialized = false;
00075 if (!isInitialized) {
00076 theProjectionMatrix[0][1] = 1;
00077 theProjectionMatrix[1][2] = 1;
00078 theProjectionMatrix[2][3] = 1;
00079 theProjectionMatrix[3][4] = 1;
00080 isInitialized=true;
00081 }
00082 return theProjectionMatrix;
00083 }
00084
00085
00086 void CSCSegment::print() const {
00087 std::cout << *this << std::endl;
00088 }
00089
00090 std::ostream& operator<<(std::ostream& os, const CSCSegment& seg) {
00091 os << "CSCSegment: local pos = " << seg.localPosition() <<
00092 " dir = " << seg.localDirection() <<
00093 " chi2 = " << seg.chi2() << " #rechits = " << seg.specificRecHits().size();
00094 return os;
00095 }
00096
00097
00098
00099