CMS 3D CMS Logo

OuterDetCompatibility.cc

Go to the documentation of this file.
00001 #include "RecoTracker/TkTrackingRegions/interface/OuterDetCompatibility.h"
00002 #include "RecoTracker/TkTrackingRegions/interface/GlobalDetRangeZPhi.h"
00003 #include "RecoTracker/TkTrackingRegions/interface/GlobalDetRangeRPhi.h"
00004 #include "TrackingTools/DetLayers/interface/PhiLess.h"
00005 #include "TrackingTools/DetLayers/interface/rangesIntersect.h"
00006 
00007 using namespace std;
00008 
00009 bool OuterDetCompatibility::operator() (const BoundPlane& plane) const
00010 {
00011   if (barrel) {
00012     GlobalDetRangeZPhi detRange(plane);
00013     if (!checkPhi(detRange.phiRange())) return 0;
00014     if (!checkZ(detRange.zRange())) return 0;
00015   } else {
00016     GlobalDetRangeRPhi detRange(plane);
00017     if (!checkPhi(detRange.phiRange())) return 0;
00018     if (!checkR(detRange.rRange())) return 0;
00019   }
00020   return 1;
00021 }
00022 
00023 
00024 bool OuterDetCompatibility::checkPhi(
00025     const OuterHitPhiPrediction::Range & detPhiRange) const
00026 { return rangesIntersect(detPhiRange, hitDetPhiRange, PhiLess()); }
00027 
00028 bool OuterDetCompatibility::checkR(
00029     const HitRZConstraint::Range & detRRange) const
00030 { return rangesIntersect(detRRange, hitDetRRange); }
00031 
00032 bool OuterDetCompatibility::checkZ(
00033     const HitRZConstraint::Range & detZRange) const
00034 { return rangesIntersect(detZRange, hitDetZRange); }
00035 
00036 
00037 GlobalPoint OuterDetCompatibility::center() const
00038 {
00039   float phi = hitDetPhiRange.mean();
00040   float r   = hitDetRRange.mean();
00041   return GlobalPoint( r*cos(phi), r*sin(phi), hitDetZRange.mean() );
00042 }
00043 
00044 MeasurementEstimator::Local2DVector
00045     OuterDetCompatibility::maximalLocalDisplacement(
00046        const GlobalPoint & ts, const BoundPlane& plane) const
00047 {
00048   float x_loc = 0.;
00049   float y_loc = 0.;
00050   if(barrel) {
00051     double  radius = ts.perp();
00052     GlobalVector planeNorm = plane.normalVector();
00053     GlobalVector tsDir = GlobalVector( ts.x(), ts.y(),0. ).unit();
00054     double ts_phi = tsDir.phi();
00055     if (! hitDetPhiRange.inside(ts_phi) ) {
00056      while (ts_phi >= hitDetPhiRange.max() ) ts_phi -= 2*M_PI;
00057      while (ts_phi < hitDetPhiRange.min() ) ts_phi += 2*M_PI;
00058      if (!hitDetPhiRange.inside(ts_phi)) return MeasurementEstimator::Local2DVector(0.,0.);
00059     }
00060     double cosGamma = tsDir.dot(planeNorm);
00061 
00062     double dx1 = loc_dist( radius, ts_phi, hitDetPhiRange.min(), cosGamma);
00063     double dx2 = loc_dist( radius, ts_phi, hitDetPhiRange.max(), cosGamma);
00064 
00065     double ts_z = ts.z();
00066     double dy1 = ts_z - hitDetZRange.min();
00067     double dy2 = hitDetZRange.max() - ts_z;
00068 
00069     x_loc = max(dx1,dx2);
00070     y_loc = max(dy1,dy2);
00071 
00072     // debug only
00073 /*
00074     double r1 = dx1 * fabs(cosGamma) / sin(ts_phi-hitDetPhiRange.min());
00075     double r2 = dx2 * fabs(cosGamma) / sin(hitDetPhiRange.max()-ts_phi);
00076     GlobalPoint p1( r1* cos(hitDetPhiRange.min()), r1 * sin(hitDetPhiRange.min()), hitDetZRange.min());
00077     GlobalPoint p2( r2* cos(hitDetPhiRange.max()), r2 * sin(hitDetPhiRange.max()), hitDetZRange.min());
00078     GlobalPoint p3( r1* cos(hitDetPhiRange.min()), r1 * sin(hitDetPhiRange.min()), hitDetZRange.max());
00079     GlobalPoint p4( r2* cos(hitDetPhiRange.max()), r2 * sin(hitDetPhiRange.max()), hitDetZRange.max());
00080     cout << " Local1: " << plane.toLocal(ts-p1) << endl;
00081     cout << " Local2: " << plane.toLocal(ts-p2) << endl;
00082     cout << " Local3: " << plane.toLocal(ts-p3) << endl;
00083     cout << " Local4: " << plane.toLocal(ts-p4) << endl;
00084 */
00085   }
00086   else {
00087     LocalPoint ts_loc = plane.toLocal(ts);
00088     GlobalVector planeNorm = plane.normalVector();
00089 
00090     double x_glob[4], y_glob[4], z_glob[4];
00091     x_glob[0] = hitDetRRange.min()*cos(hitDetPhiRange.min());
00092     y_glob[0] = hitDetRRange.min()*sin(hitDetPhiRange.min());
00093     x_glob[1] = hitDetRRange.max()*cos(hitDetPhiRange.min());
00094     y_glob[1] = hitDetRRange.max()*sin(hitDetPhiRange.min());
00095     x_glob[2] = hitDetRRange.min()*cos(hitDetPhiRange.max());
00096     y_glob[2] = hitDetRRange.min()*sin(hitDetPhiRange.max());
00097     x_glob[3] = hitDetRRange.max()*cos(hitDetPhiRange.max());
00098     y_glob[3] = hitDetRRange.max()*sin(hitDetPhiRange.max());
00099 
00100     for (int idx = 0; idx < 4; idx++) {
00101       double dx_glob = x_glob[idx] - ts.x();
00102       double dy_glob = y_glob[idx] - ts.y();
00103       double dz_glob = -(dx_glob * planeNorm.x() + dy_glob*planeNorm.y()) / planeNorm.z();
00104       z_glob[idx] = dz_glob + ts.z();
00105     }
00106 
00107     for (int idx=0; idx <4; idx++) {
00108       LocalPoint lp = plane.toLocal( GlobalPoint( x_glob[idx], y_glob[idx], z_glob[idx]));
00109       x_loc = max(x_loc, fabs(lp.x()-ts_loc.x()));
00110       y_loc = max(y_loc, fabs(lp.y()-ts_loc.y())); 
00111     }
00112   }
00113   MeasurementEstimator::Local2DVector distance(x_loc,y_loc);
00114   return distance;
00115 }
00116 
00117 double OuterDetCompatibility::loc_dist(
00118       double radius, double ts_phi, double range_phi, double cosGamma) const
00119 {
00120     double sinDphi = sin(ts_phi - range_phi);
00121     double cosDphi = sqrt(1-sinDphi*sinDphi);
00122     double sinGamma = sqrt(1-cosGamma*cosGamma);
00123     double sinBeta = fabs(cosDphi*cosGamma -  sinDphi* sinGamma); 
00124     return radius * fabs(sinDphi) / sinBeta; 
00125 }

Generated on Tue Jun 9 17:45:59 2009 for CMSSW by  doxygen 1.5.4