Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include <cmath>
00017
00018 #include "RecoTracker/RoadSearchSeedFinder/interface/RoadSearchCircleSeed.h"
00019 #include "RecoTracker/TkSeedGenerator/interface/FastCircle.h"
00020
00021 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00022
00023 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
00024
00025 RoadSearchCircleSeed::RoadSearchCircleSeed(const TrackingRecHit *hit1,
00026 const TrackingRecHit *hit2,
00027 const TrackingRecHit *hit3,
00028 GlobalPoint &point1,
00029 GlobalPoint &point2,
00030 GlobalPoint &point3) {
00031
00032 hits_.reserve(3);
00033 hits_.push_back(hit1);
00034 hits_.push_back(hit2);
00035 hits_.push_back(hit3);
00036
00037 points_.reserve(3);
00038 points_.push_back(point1);
00039 points_.push_back(point2);
00040 points_.push_back(point3);
00041
00042 FastCircle kreis(point1,
00043 point2,
00044 point3);
00045
00046 if ( !kreis.isValid() ) {
00047
00048 type_ = straightLine;
00049 inBarrel_ = true;
00050 center_ = GlobalPoint(0,0,0);
00051 radius_ = 0;
00052 impactParameter_ = 0;
00053 } else {
00054 type_ = circle;
00055 inBarrel_ = calculateInBarrel();
00056 radius_ = kreis.rho();
00057 center_ = GlobalPoint(kreis.x0(),kreis.y0(),0);
00058 impactParameter_ = calculateImpactParameter(center_,radius_);
00059 }
00060
00061 }
00062
00063 RoadSearchCircleSeed::RoadSearchCircleSeed(const TrackingRecHit *hit1,
00064 const TrackingRecHit *hit2,
00065 GlobalPoint &point1,
00066 GlobalPoint &point2) {
00067
00068
00069
00070
00071 hits_.reserve(2);
00072 hits_.push_back(hit1);
00073 hits_.push_back(hit2);
00074
00075 points_.reserve(2);
00076 points_.push_back(point1);
00077 points_.push_back(point2);
00078
00079 type_ = straightLine;
00080 inBarrel_ = true;
00081 center_ = GlobalPoint(0,0,0);
00082 radius_ = 0;
00083 impactParameter_ = 0;
00084
00085 }
00086
00087 RoadSearchCircleSeed::~RoadSearchCircleSeed() {
00088 }
00089
00090 bool RoadSearchCircleSeed::calculateInBarrel() {
00091
00092
00093
00094
00095
00096 for (std::vector<const TrackingRecHit*>::const_iterator hit = hits_.begin();
00097 hit != hits_.end(); ++hit) {
00098 if ((*hit)->geographicalId().subdetId() == StripSubdetector::TEC) {
00099 return false;
00100 }
00101 }
00102
00103 return true;
00104 }
00105
00106 double RoadSearchCircleSeed::calculateImpactParameter(GlobalPoint ¢er,
00107 double radius) {
00108
00109
00110
00111
00112 double d = std::sqrt( center.x() * center.x() +
00113 center.y() * center.y() );
00114
00115 return std::abs(d-radius);
00116 }
00117
00118 double RoadSearchCircleSeed::calculateEta(double theta) const {
00119
00120
00121
00122
00123 return -1.*std::log(std::tan(theta/2.));
00124 }
00125
00126 double RoadSearchCircleSeed::Theta() const {
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140 std::vector<LineRZ> lines;
00141 for (std::vector<GlobalPoint>::const_iterator point1 = points_.begin();
00142 point1 != points_.end(); ++point1) {
00143 for (std::vector<GlobalPoint>::const_iterator point2 = point1+1;
00144 point2 != points_.end(); ++point2) {
00145 lines.push_back(LineRZ(*point1, *point2));
00146 }
00147 }
00148
00149 double netTheta = 0.;
00150 for (std::vector<LineRZ>::const_iterator line = lines.begin();
00151 line != lines.end(); ++line){
00152 netTheta += line->Theta();
00153 }
00154 return netTheta/(double)lines.size();
00155 }
00156
00157 double RoadSearchCircleSeed::Phi0() const {
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172 if (type_ == straightLine) {
00173 std::vector<LineXY> lines;
00174 for (std::vector<GlobalPoint>::const_iterator point1 = points_.begin();
00175 point1 != points_.end(); ++point1) {
00176 for (std::vector<GlobalPoint>::const_iterator point2 = point1+1;
00177 point2 != points_.end(); ++point2) {
00178 lines.push_back(LineXY(*point1,*point2));
00179 }
00180 }
00181 double netPhi = 0.;
00182 for (std::vector<LineXY>::const_iterator line = lines.begin();
00183 line != lines.end(); ++line) {
00184 netPhi += line->Phi();
00185 }
00186 return netPhi/(double)lines.size();
00187 }
00188
00189
00190
00191 else if (2.*Radius()+ImpactParameter()<110) {
00192 return 100000.;
00193 }
00194
00195
00196 else {
00197 double phi = 100000.;
00198 double centerPhi = center_.barePhi();
00199
00200
00201
00202
00203
00204
00205 GlobalPoint firstPoint = points_[0];
00206 for (unsigned int i=1; i<points_.size(); ++i) {
00207 if (firstPoint.perp() > points_[i].perp()) {
00208 firstPoint = points_[i];
00209 }
00210 }
00211
00212
00213
00214
00215
00216 if (firstPoint.barePhi() == centerPhi) {
00217 GlobalPoint nextHit = points_[0];
00218 for (unsigned int i=1; i<points_.size(); ++i) {
00219 if (nextHit.perp() == firstPoint.perp() ||
00220 (firstPoint.perp()!= points_[i].perp() &&
00221 nextHit.perp() > points_[i].perp())) {
00222 nextHit = points_[i];
00223 }
00224 }
00225 firstPoint = nextHit;
00226 }
00227
00228
00229 if (firstPoint.barePhi() > centerPhi) {
00230
00231
00232 phi = centerPhi + Geom::pi()/2.;
00233 if (phi>Geom::pi()) {
00234 phi -= 2.*Geom::pi();
00235 }
00236 }
00237
00238 else if (firstPoint.barePhi() < centerPhi) {
00239
00240
00241 phi = centerPhi - Geom::pi()/2.;
00242 if (phi<-1.*Geom::pi()) {
00243 phi += 2.*Geom::pi();
00244 }
00245 }
00246 return phi;
00247 }
00248 }
00249
00250 std::string RoadSearchCircleSeed::print() const {
00251
00252
00253
00254
00255 std::ostringstream ost;
00256
00257 if ( type_ == RoadSearchCircleSeed::straightLine ) {
00258 ost << "Straight Line: number of points: " << points_.size() << "\n";
00259 unsigned int counter = 0;
00260 for ( std::vector<GlobalPoint>::const_iterator point = points_.begin();
00261 point != points_.end();
00262 ++point ) {
00263 ++counter;
00264 ost << " Point " << counter << ": " << point->x() << "," << point->y() << "\n";
00265 }
00266 } else {
00267 ost << "Circle: number of points: " << points_.size() << "\n";
00268 ost << " Radius : " << radius_ << "\n";
00269 ost << " In the barrel : " << inBarrel_ << "\n";
00270 ost << " ImpactParameter: " << impactParameter_ << "\n";
00271 ost << " Center : " << center_.x() << "," << center_.y() << "\n";
00272 unsigned int counter = 0;
00273 for ( std::vector<GlobalPoint>::const_iterator point = points_.begin();
00274 point != points_.end();
00275 ++point ) {
00276 ++counter;
00277 ost << " Point " << counter << " : " << point->x() << "," << point->y() << "\n";
00278 }
00279 }
00280
00281 return ost.str();
00282 }
00283
00284 std::ostream& operator<<(std::ostream& ost, const RoadSearchCircleSeed & seed) {
00285
00286
00287
00288
00289 if ( seed.Type() == RoadSearchCircleSeed::straightLine ) {
00290 ost << "Straight Line: number of points: " << seed.Points().size() << "\n";
00291 unsigned int counter = 0;
00292 for ( std::vector<GlobalPoint>::const_iterator point = seed.Points().begin();
00293 point != seed.Points().end();
00294 ++point ) {
00295 ++counter;
00296 ost << " Point " << counter << ": " << point->x() << "," << point->y() << "\n";
00297 }
00298 } else {
00299 ost << "Circle: number of points: " << seed.Points().size() << "\n";
00300 ost << " Radius : " << seed.Radius() << "\n";
00301 ost << " In the barrel : " << seed.InBarrel() << "\n";
00302 ost << " ImpactParameter: " << seed.ImpactParameter() << "\n";
00303 ost << " Center : " << seed.Center().x() << "," << seed.Center().y() << "\n";
00304 unsigned int counter = 0;
00305 for ( std::vector<GlobalPoint>::const_iterator point = seed.Points().begin();
00306 point != seed.Points().end();
00307 ++point ) {
00308 ++counter;
00309 ost << " Point " << counter << " : " << point->x() << "," << point->y() << "\n";
00310 }
00311 }
00312
00313 return ost;
00314 }
00315
00316 bool RoadSearchCircleSeed::Compare(const RoadSearchCircleSeed *circle,
00317 double centerCut,
00318 double radiusCut,
00319 unsigned int differentHitsCut) const {
00320
00321
00322
00323
00324
00325
00326
00327
00328 bool result = false;
00329
00330 result = CompareRadius(circle,radiusCut);
00331 if ( result ) {
00332 result = CompareCenter(circle,centerCut);
00333 if ( result ) {
00334 result = CompareDifferentHits(circle,differentHitsCut);
00335 }
00336 }
00337
00338 return result;
00339
00340 }
00341
00342 bool RoadSearchCircleSeed::CompareCenter(const RoadSearchCircleSeed *circle,
00343 double centerCut) const {
00344
00345
00346
00347
00348
00349
00350 bool result = false;
00351
00352 double averageCenter = std::sqrt(((center_.x()+circle->Center().x())/2) *
00353 ((center_.x()+circle->Center().x())/2) +
00354 ((center_.y()+circle->Center().y())/2) *
00355 ((center_.y()+circle->Center().y())/2));
00356 double differenceCenter = std::sqrt((center_.x()-circle->Center().x()) *
00357 (center_.x()-circle->Center().x()) +
00358 (center_.y()-circle->Center().y()) *
00359 (center_.y()-circle->Center().y()));
00360
00361 if ( differenceCenter/averageCenter <= centerCut ) {
00362 result = true;
00363 }
00364
00365
00366
00367
00368
00369
00370
00371 return result;
00372
00373 }
00374
00375 bool RoadSearchCircleSeed::CompareRadius(const RoadSearchCircleSeed *circle,
00376 double radiusCut) const {
00377
00378
00379
00380
00381
00382
00383 bool result = false;
00384
00385 double averageRadius = (radius_ + circle->Radius() ) /2;
00386 double differenceRadius = std::abs(radius_ - circle->Radius());
00387
00388 if ( differenceRadius/averageRadius <= radiusCut ) {
00389 result = true;
00390 }
00391
00392
00393
00394
00395
00396
00397
00398 return result;
00399
00400 }
00401
00402 bool RoadSearchCircleSeed::CompareDifferentHits(const RoadSearchCircleSeed *circle,
00403 unsigned int differentHitsCut) const {
00404
00405
00406
00407
00408
00409
00410 bool result = false;
00411
00412
00413 unsigned int counter = 0;
00414 for ( std::vector<const TrackingRecHit*>::const_iterator hit1 = hits_.begin(),
00415 hit1End = hits_.end();
00416 hit1 != hit1End;
00417 ++hit1 ) {
00418 bool included = false;
00419 for ( std::vector<const TrackingRecHit*>::const_iterator hit2 = circle->begin_hits(),
00420 hit2End = circle->end_hits();
00421 hit2 != hit2End;
00422 ++hit2 ) {
00423 if ( *hit1 == *hit2 ) {
00424 included = true;
00425 }
00426 }
00427 if ( !included ) {
00428 ++counter;
00429 }
00430 }
00431
00432 if ( counter <= differentHitsCut ) {
00433 result = true;
00434 }
00435
00436
00437
00438
00439
00440 return result;
00441
00442 }
00443
00444
00445
00446
00447 LineRZ::LineRZ(GlobalPoint point1, GlobalPoint point2)
00448 {
00449 theR_ = std::fabs(point1.perp()-point2.perp());
00450 theZ_ = std::fabs(point1.z()-point2.z());
00451
00452 if ((point1.perp() >= point2.perp() &&
00453 point1.z() < point2.z()) ||
00454 (point2.perp() >= point1.perp() &&
00455 point2.z() < point1.z()))
00456 {
00457 theZ_ = -1.*theZ_;
00458 }
00459 }
00460
00461
00462
00463
00464 LineRZ::~LineRZ()
00465 { }
00466
00467
00468
00469
00470 LineXY::LineXY(GlobalPoint point1, GlobalPoint point2)
00471 {
00472 theX_ = std::fabs(point1.x()-point2.x());
00473 theY_ = std::fabs(point1.y()-point2.y());
00474
00475 if ((point1.perp() >= point2.perp() &&
00476 point1.x() < point2.x()) ||
00477 (point2.perp() >= point1.perp() &&
00478 point2.x() < point1.x()))
00479 {
00480 theX_ = -1.*theX_;
00481 }
00482
00483 if ((point1.perp() >= point2.perp() &&
00484 point1.y() < point2.y()) ||
00485 (point2.perp() >= point1.perp() &&
00486 point2.y() < point1.y()))
00487 {
00488 theY_ = -1.*theY_;
00489 }
00490 }
00491
00492
00493
00494
00495 LineXY::~LineXY()
00496 { }