19 CSCSegment::CSCSegment(
const std::vector<const CSCRecHit2D*>& proto_segment,
LocalPoint origin,
23 theLocalDirection(direction), theCovMatrix(errors), theChi2(chi2), aME11a_duplicate(
false) {
25 for(
unsigned int i=0;
i<proto_segment.size(); ++
i)
26 theCSCRecHits.push_back(*proto_segment[
i]);
29 CSCSegment::~CSCSegment() {}
31 std::vector<const TrackingRecHit*> CSCSegment::recHits()
const{
32 std::vector<const TrackingRecHit*> pointersOfRecHits;
33 for (std::vector<CSCRecHit2D>::const_iterator irh = theCSCRecHits.begin(); irh!=theCSCRecHits.end(); ++irh) {
34 pointersOfRecHits.push_back(&(*irh));
36 return pointersOfRecHits;
39 std::vector<TrackingRecHit*> CSCSegment::recHits() {
41 std::vector<TrackingRecHit*> pointersOfRecHits;
42 for (std::vector<CSCRecHit2D>::iterator irh = theCSCRecHits.begin(); irh!=theCSCRecHits.end(); ++irh) {
43 pointersOfRecHits.push_back(&(*irh));
45 return pointersOfRecHits;
48 LocalError CSCSegment::localPositionError()
const {
49 return LocalError(theCovMatrix[2][2], theCovMatrix[2][3], theCovMatrix[3][3]);
52 LocalError CSCSegment::localDirectionError()
const {
53 return LocalError(theCovMatrix[0][0], theCovMatrix[0][1], theCovMatrix[1][1]);
63 result[0] = theLocalDirection.x()/theLocalDirection.z();
64 result[1] = theLocalDirection.y()/theLocalDirection.z();
74 static bool isInitialized =
false;
76 theProjectionMatrix[0][1] = 1;
77 theProjectionMatrix[1][2] = 1;
78 theProjectionMatrix[2][3] = 1;
79 theProjectionMatrix[3][4] = 1;
82 return theProjectionMatrix;
85 void CSCSegment::setDuplicateSegments(std::vector<CSCSegment*> & duplicates){
86 theDuplicateSegments.clear();
87 for(
unsigned int i=0;
i<duplicates.size(); ++
i){
88 theDuplicateSegments.push_back(*duplicates[
i]);
90 theDuplicateSegments.back().theDuplicateSegments.resize(0);
94 bool CSCSegment::testSharesAllInSpecificRecHits(
const std::vector<CSCRecHit2D>& specificRecHits_1,
95 const std::vector<CSCRecHit2D>& specificRecHits_2,
96 CSCRecHit2D::SharedInputType sharesInput)
const{
97 const std::vector<CSCRecHit2D> * rhContainer_1 = &specificRecHits_1;
98 const std::vector<CSCRecHit2D> * rhContainer_2 = &specificRecHits_2;
99 if(specificRecHits_1.size()>specificRecHits_2.size()){
100 rhContainer_2 = &specificRecHits_1;
101 rhContainer_1 = &specificRecHits_2;
104 bool shareConditionPassed =
true;
105 for ( std::vector<CSCRecHit2D>::const_iterator itRH = rhContainer_1->begin();
106 itRH != rhContainer_1->end(); ++itRH) {
108 bool sharedHit =
false;
109 for ( std::vector<CSCRecHit2D>::const_iterator itRH2 = rhContainer_2->begin();
110 itRH2 != rhContainer_2->end(); ++itRH2) {
111 if(itRH2->sharesInput(firstRecHit,sharesInput)){
117 shareConditionPassed =
false;
121 return shareConditionPassed;
132 bool CSCSegment::sharesRecHits(
const CSCSegment & anotherSegment, CSCRecHit2D::SharedInputType sharesInput)
const {
133 return testSharesAllInSpecificRecHits( theCSCRecHits , anotherSegment.specificRecHits(), sharesInput);
137 bool CSCSegment::sharesRecHits(
const CSCSegment & anotherSegment)
const {
138 if(testSharesAllInSpecificRecHits( theCSCRecHits , anotherSegment.specificRecHits(), CSCRecHit2D::someWires) &&
139 testSharesAllInSpecificRecHits( theCSCRecHits , anotherSegment.specificRecHits(), CSCRecHit2D::someStrips)){
150 std::vector<float> wireTimes;
151 for (std::vector<CSCRecHit2D>::const_iterator itRH = theCSCRecHits.begin();
152 itRH != theCSCRecHits.end(); ++itRH) {
154 averageTime+=recHit->tpeak();
155 averageTime+=recHit->wireTime();
156 wireTimes.push_back(recHit->wireTime());
158 averageTime=averageTime/(2*theCSCRecHits.size());
165 std::vector<float>::iterator maxHit;
166 for (std::vector<float>::iterator itWT=wireTimes.begin();
167 itWT!=wireTimes.end(); ++itWT) {
168 float diff=fabs(*itWT-averageTime);
175 int N=theCSCRecHits.size()+wireTimes.size();
176 averageTime=(averageTime*N-(*maxHit))/(N-1);
177 wireTimes.erase(maxHit);
190 os <<
"CSCSegment: local pos = " << seg.localPosition() <<
191 " posErr = (" <<
sqrt(seg.localPositionError().xx())<<
","<<
sqrt(seg.localPositionError().yy())<<
193 " dir = " << seg.localDirection() <<
194 " dirErr = (" <<
sqrt(seg.localDirectionError().xx())<<
","<<
sqrt(seg.localDirectionError().yy())<<
196 " chi2/ndf = " << seg.chi2()/double(seg.degreesOfFreedom()) <<
197 " #rechits = " << seg.specificRecHits().size()<<
198 " ME1/1a duplicates : "<<seg.duplicateSegments().size();
std::string print(const Track &, edm::Verbosity=edm::Concise)
Track print utility.
std::ostream & operator<<(std::ostream &out, const ALILine &li)
CLHEP::HepMatrix AlgebraicMatrix
CLHEP::HepVector AlgebraicVector
float maxDiff(float one, float two, float three, float four)
CLHEP::HepSymMatrix AlgebraicSymMatrix