CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/DataFormats/GeometryCommonDetAlgo/src/PerpendicularBoundPlaneBuilder.cc

Go to the documentation of this file.
00001 //#include "Utilities/Configuration/interface/Architecture.h"
00002 
00003 #include "DataFormats/GeometryCommonDetAlgo/interface/PerpendicularBoundPlaneBuilder.h"
00004 
00005 BoundPlane* 
00006 PerpendicularBoundPlaneBuilder::operator()( const Surface::GlobalPoint& origin,
00007                                             const Surface::GlobalVector& perp) const
00008 {
00009   // z axis coincides with perp
00010   GlobalVector zAxis = perp.unit();
00011 
00012   // x axis has no global Z component
00013   GlobalVector xAxis;
00014   if ( zAxis.x() != 0 || zAxis.y() != 0) {
00015     // precision is not an issue here, just protect against divizion by zero
00016     xAxis = GlobalVector( -zAxis.y(), zAxis.x(), 0).unit();
00017   }
00018   else { // perp coincides with global Z
00019     xAxis = GlobalVector( 1, 0, 0);
00020   }
00021 
00022   // y axis obtained by cross product
00023   GlobalVector yAxis( zAxis.cross( xAxis));
00024 
00025   Surface::RotationType rot( xAxis.x(), xAxis.y(), xAxis.z(),
00026                              yAxis.x(), yAxis.y(), yAxis.z(),
00027                              zAxis.x(), zAxis.y(), zAxis.z());
00028 
00029   return new BoundPlane( origin, rot);
00030 }