CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/DataFormats/GeometrySurface/src/GeneralTrapezoidalPlaneBounds.cc

Go to the documentation of this file.
00001 
00002 #include "DataFormats/GeometrySurface/interface/GeneralTrapezoidalPlaneBounds.h"
00003 #include "DataFormats/GeometrySurface/interface/LocalError.h"
00004 #include <cmath>
00005 
00006 GeneralTrapezoidalPlaneBounds::GeneralTrapezoidalPlaneBounds( float be, float te, float ang, 
00007                                                               float a, float t) : 
00008   hbotedge(be), htopedge(te), tilt_angle(ang), hapothem(a), hthickness(t) {
00009 
00010   // pre-compute offsets of triangles and tg of (half) opening
00011   // angles of the trapezoid for faster inside() implementation
00012     
00013   tg_tilt = tan(ang*M_PI/180.);
00014   xoff = a * tg_tilt;
00015   offsetp = a * (te+be) / (te-be+2.*xoff);  // for x > 0 
00016   tan_ap = (te+xoff) / (offsetp + a);
00017   offsetn = a * (te+be) / (te-be-2.*xoff);  // for x < 0 
00018   tan_an = (xoff-te) / (offsetn + a);
00019 }
00020 
00021 bool GeneralTrapezoidalPlaneBounds::inside( const Local2DPoint& p) const {
00022   return std::abs(p.y()) <= hapothem && 
00023     ( (p.x() >=0. && p.x()/(p.y()+offsetp) <= tan_ap) ||
00024       (p.x() < 0. && p.x()/(p.y()+offsetn) >= tan_an) );
00025 }
00026 
00027 bool GeneralTrapezoidalPlaneBounds::inside( const Local3DPoint& p) const {
00028   return std::abs(p.y()) <= hapothem &&
00029     ( (p.x() >=0. && p.x()/(p.y()+offsetp) <= tan_ap) ||
00030       (p.x() < 0. && p.x()/(p.y()+offsetn) >= tan_an) ) &&
00031     std::abs(p.z()) <= hthickness;
00032 }
00033 
00034 bool GeneralTrapezoidalPlaneBounds::inside( const Local3DPoint& p, 
00035                                             const LocalError& err, float scale) const {
00036 
00037   GeneralTrapezoidalPlaneBounds tmp( hbotedge + sqrt(err.xx())*scale,
00038                                      htopedge + sqrt(err.xx())*scale,
00039                                      tilt_angle,
00040                                      hapothem + sqrt(err.yy())*scale,
00041                                      hthickness);
00042   return tmp.inside(p);
00043 }
00044 
00045 const std::vector<float> GeneralTrapezoidalPlaneBounds::parameters() const { 
00046   std::vector<float> vec(7);
00047   // Same order as geant3 for constructor compatibility
00048   vec[0] = hthickness;
00049   vec[1] = 0;
00050   vec[2] = 0;
00051   vec[3] = hapothem;
00052   vec[4] = hbotedge;
00053   vec[5] = htopedge;
00054   vec[6] = tilt_angle;
00055   return vec;
00056 }