CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/RecoTracker/TkTrackingRegions/src/GlobalDetRangeZPhi.cc

Go to the documentation of this file.
00001 #include "RecoTracker/TkTrackingRegions/interface/GlobalDetRangeZPhi.h"
00002 #include "DataFormats/GeometrySurface/interface/BoundPlane.h"
00003 #include "DataFormats/GeometrySurface/interface/Bounds.h"
00004 #include "TrackingTools/DetLayers/interface/PhiLess.h"
00005 #include <functional>
00006 #include <cmath>
00007 #include <vector>
00008 
00009 using namespace std;
00010 
00011 GlobalDetRangeZPhi::GlobalDetRangeZPhi( const BoundPlane& plane) {
00012 
00013   float dx = plane.bounds().width()/2.;
00014   float dy = plane.bounds().length()/2.;
00015 
00016   vector<Surface::GlobalPoint> corners(4);
00017   corners[0] = plane.toGlobal( LocalPoint( -dx, -dy, 0));
00018   corners[1] = plane.toGlobal( LocalPoint( -dx,  dy, 0));
00019   corners[2] = plane.toGlobal( LocalPoint(  dx, -dy, 0));
00020   corners[3] = plane.toGlobal( LocalPoint(  dx,  dy, 0));
00021 
00022   float phimin = corners[0].phi();  float phimax = phimin;
00023   float zmin   = corners[0].z();    float zmax   = zmin;
00024   for ( int i=1; i<4; i++) {
00025     float phi = corners[i].phi();
00026     if ( PhiLess()( phi, phimin)) phimin = phi;
00027     if ( PhiLess()( phimax, phi)) phimax = phi;
00028 
00029     float z = corners[i].z();
00030     if ( z < zmin) zmin = z;
00031     if ( z > zmax) zmax = z;
00032   }
00033 
00034   theZRange.first    = zmin;
00035   theZRange.second   = zmax;
00036   thePhiRange.first  = phimin;
00037   thePhiRange.second = phimax;
00038 
00039 }