CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/RecoTracker/TkDetLayers/src/GlobalDetRodRangeZPhi.cc

Go to the documentation of this file.
00001 #include "GlobalDetRodRangeZPhi.h"
00002 #include "DataFormats/GeometrySurface/interface/BoundPlane.h"
00003 #include "DataFormats/GeometrySurface/interface/Bounds.h"
00004 #include "TrackingTools/DetLayers/interface/PhiLess.h"
00005 
00006 #include <vector>
00007 
00008 using namespace std;
00009 
00010 GlobalDetRodRangeZPhi::GlobalDetRodRangeZPhi( const BoundPlane& plane) {
00011 
00012   float dx = plane.bounds().width()/2.;
00013   float dy = plane.bounds().length()/2.;
00014   float dz = plane.bounds().thickness()/2.;
00015 
00016   // rods may be inverted (actually are in every other layer), so have to find out the 
00017   // orientation of the local frame
00018   float deltaZ = (plane.toGlobal( LocalPoint( 0, 0, -dz)).perp() < 
00019                   plane.toGlobal( LocalPoint( 0, 0, dz)).perp() ) ? -dz : dz ;
00020   
00021 
00022   vector<Surface::GlobalPoint> corners(4);
00023   corners[0] = plane.toGlobal( LocalPoint( -dx, -dy, deltaZ));
00024   corners[1] = plane.toGlobal( LocalPoint( -dx,  dy, deltaZ));
00025   corners[2] = plane.toGlobal( LocalPoint(  dx, -dy, deltaZ));
00026   corners[3] = plane.toGlobal( LocalPoint(  dx,  dy, deltaZ));
00027 
00028   float phimin = corners[0].phi();  float phimax = phimin;
00029   float zmin   = corners[0].z();    float zmax   = zmin;
00030   for ( int i=1; i<4; i++) {
00031     float phi = corners[i].phi();
00032     if ( PhiLess()( phi, phimin)) phimin = phi;
00033     if ( PhiLess()( phimax, phi)) phimax = phi;
00034 
00035     float z = corners[i].z();
00036     if ( z < zmin) zmin = z;
00037     if ( z > zmax) zmax = z;
00038   }
00039 
00040   theZRange.first    = zmin;
00041   theZRange.second   = zmax;
00042   thePhiRange.first  = phimin;
00043   thePhiRange.second = phimax;
00044 
00045 }