CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/DataFormats/GeometrySurface/src/TrapezoidalPlaneBounds.cc

Go to the documentation of this file.
00001 
00002 
00003 #include "DataFormats/GeometrySurface/interface/TrapezoidalPlaneBounds.h"
00004 #include "DataFormats/GeometrySurface/interface/LocalError.h"
00005 #include <cmath>
00006 
00007 TrapezoidalPlaneBounds::TrapezoidalPlaneBounds( float be, float te, 
00008                                                 float a, float t) : 
00009   hbotedge(be), htopedge(te), hapothem(a), hthickness(t) {
00010 
00011   // pre-compute offset of triangle vertex and tg of (half) opening
00012   // angle of the trapezoid for faster inside() implementation.
00013 
00014   offset = a * (te+be) / (te-be);  // check sign if te < be !!! 
00015   tan_a = te / fabs(offset + a);
00016 }
00017 
00018 
00019 int TrapezoidalPlaneBounds::yAxisOrientation() const {
00020   int yAx = 1;
00021   if(hbotedge>htopedge) yAx = -1;
00022   return yAx;
00023 }
00024 
00025 bool TrapezoidalPlaneBounds::inside( const Local2DPoint& p) const {
00026   return fabs(p.y()) < hapothem && 
00027     fabs(p.x())/fabs(p.y()+offset) < tan_a;
00028 }
00029 
00030 bool TrapezoidalPlaneBounds::inside( const Local3DPoint& p) const {
00031   return fabs(p.y()) < hapothem &&
00032     fabs(p.x())/fabs(p.y()+offset) < tan_a &&
00033     fabs(p.z()) < hthickness;
00034 }
00035 
00036 bool TrapezoidalPlaneBounds::inside( const Local3DPoint& p,
00037                                      const LocalError& err, float scale) const {
00038   TrapezoidalPlaneBounds tmp( hbotedge + sqrt(err.xx())*scale,
00039                               htopedge + sqrt(err.xx())*scale,
00040                               hapothem + sqrt(err.yy())*scale,
00041                               hthickness);
00042   return tmp.inside(p);
00043 }
00044   
00045 bool TrapezoidalPlaneBounds::inside( const Local2DPoint& p, const LocalError& err, float scale) const {
00046   return Bounds::inside(p,err,scale);
00047 }
00048 
00049 Bounds* TrapezoidalPlaneBounds::clone() const { 
00050   return new TrapezoidalPlaneBounds(*this);
00051 }
00052 
00053 
00054 
00055 const std::vector<float> TrapezoidalPlaneBounds::parameters() const { 
00056   std::vector<float> vec(4);
00057   // Same order as geant3 for constructor compatibility
00058   vec[0] = hbotedge;
00059   vec[1] = htopedge;
00060   vec[3] = hapothem;
00061   vec[2] = hthickness;
00062   return vec;
00063 }