Go to the documentation of this file.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), aME11a_duplicate(false) {
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 void CSCSegment::setDuplicateSegments(std::vector<CSCSegment*> & duplicates){
00086 theDuplicateSegments.clear();
00087 for(unsigned int i=0; i<duplicates.size(); ++i){
00088 theDuplicateSegments.push_back(*duplicates[i]);
00089
00090 theDuplicateSegments.back().theDuplicateSegments.resize(0);
00091 }
00092 }
00093
00094 bool CSCSegment::testSharesAllInSpecificRecHits( const std::vector<CSCRecHit2D>& specificRecHits_1,
00095 const std::vector<CSCRecHit2D>& specificRecHits_2,
00096 CSCRecHit2D::SharedInputType sharesInput) const{
00097 const std::vector<CSCRecHit2D> * rhContainer_1 = &specificRecHits_1;
00098 const std::vector<CSCRecHit2D> * rhContainer_2 = &specificRecHits_2;
00099 if(specificRecHits_1.size()>specificRecHits_2.size()){
00100 rhContainer_2 = &specificRecHits_1;
00101 rhContainer_1 = &specificRecHits_2;
00102 }
00103
00104 bool shareConditionPassed = true;
00105 for ( std::vector<CSCRecHit2D>::const_iterator itRH = rhContainer_1->begin();
00106 itRH != rhContainer_1->end(); ++itRH) {
00107 const CSCRecHit2D *firstRecHit = &(*itRH);
00108 bool sharedHit = false;
00109 for ( std::vector<CSCRecHit2D>::const_iterator itRH2 = rhContainer_2->begin();
00110 itRH2 != rhContainer_2->end(); ++itRH2) {
00111 if(itRH2->sharesInput(firstRecHit,sharesInput)){
00112 sharedHit = true;
00113 break;
00114 }
00115 }
00116 if(!sharedHit){
00117 shareConditionPassed = false;
00118 break;
00119 }
00120 }
00121 return shareConditionPassed;
00122 }
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132 bool CSCSegment::sharesRecHits(const CSCSegment & anotherSegment, CSCRecHit2D::SharedInputType sharesInput) const {
00133 return testSharesAllInSpecificRecHits( theCSCRecHits , anotherSegment.specificRecHits(), sharesInput);
00134 }
00135
00136
00137 bool CSCSegment::sharesRecHits(const CSCSegment & anotherSegment) const {
00138 if(testSharesAllInSpecificRecHits( theCSCRecHits , anotherSegment.specificRecHits(), CSCRecHit2D::someWires) &&
00139 testSharesAllInSpecificRecHits( theCSCRecHits , anotherSegment.specificRecHits(), CSCRecHit2D::someStrips)){
00140 return true;
00141 }
00142 else{
00143 return false;
00144 }
00145 }
00146
00147
00148 void CSCSegment::print() const {
00149 std::cout << *this << std::endl;
00150 }
00151
00152 std::ostream& operator<<(std::ostream& os, const CSCSegment& seg) {
00153 os << "CSCSegment: local pos = " << seg.localPosition() <<
00154 " posErr = (" << sqrt(seg.localPositionError().xx())<<","<<sqrt(seg.localPositionError().yy())<<
00155 "0,)\n"<<
00156 " dir = " << seg.localDirection() <<
00157 " dirErr = (" << sqrt(seg.localDirectionError().xx())<<","<<sqrt(seg.localDirectionError().yy())<<
00158 "0,)\n"<<
00159 " chi2/ndf = " << seg.chi2()/double(seg.degreesOfFreedom()) <<
00160 " #rechits = " << seg.specificRecHits().size()<<
00161 " ME1/1a duplicates : "<<seg.duplicateSegments().size();
00162 return os;
00163 }
00164
00165
00166
00167