Go to the documentation of this file.00001 #include "DataFormats/GeometrySurface/interface/BoundSpan.h"
00002 #include "DataFormats/GeometrySurface/interface/Surface.h"
00003 #include "DataFormats/GeometrySurface/interface/TrapezoidalPlaneBounds.h"
00004 #include "DataFormats/GeometrySurface/interface/RectangularPlaneBounds.h"
00005
00006 #include "DataFormats/GeometryVector/interface/VectorUtil.h"
00007
00008 void BoundSpan::compute(Surface const & plane) {
00009 const TrapezoidalPlaneBounds* trapezoidalBounds( dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
00010 const RectangularPlaneBounds* rectangularBounds( dynamic_cast<const RectangularPlaneBounds*>(&(plane.bounds())));
00011
00012 Surface::GlobalPoint corners[8];
00013
00014 if (trapezoidalBounds) {
00015 std::array<const float, 4> const & parameters = (*trapezoidalBounds).parameters();
00016
00017 float hbotedge = parameters[0];
00018 float htopedge = parameters[1];
00019 float hapothem = parameters[3];
00020 float thickness = (*trapezoidalBounds).thickness();
00021
00022 corners[0] = plane.toGlobal( LocalPoint( -htopedge, hapothem, thickness/2));
00023 corners[1] = plane.toGlobal( LocalPoint( htopedge, hapothem, thickness/2));
00024 corners[2] = plane.toGlobal( LocalPoint( hbotedge, -hapothem, thickness/2));
00025 corners[3] = plane.toGlobal( LocalPoint( -hbotedge, -hapothem, thickness/2));
00026 corners[4] = plane.toGlobal( LocalPoint( -htopedge, hapothem, -thickness/2));
00027 corners[5] = plane.toGlobal( LocalPoint( htopedge, hapothem, -thickness/2));
00028 corners[6] = plane.toGlobal( LocalPoint( hbotedge, -hapothem, -thickness/2));
00029 corners[7] = plane.toGlobal( LocalPoint( -hbotedge, -hapothem, -thickness/2));
00030
00031 }else if(rectangularBounds) {
00032 float length = rectangularBounds->length();
00033 float width = rectangularBounds->width();
00034 float thickness = (*rectangularBounds).thickness();
00035
00036 corners[0] = plane.toGlobal( LocalPoint( -width/2, -length/2, thickness/2));
00037 corners[1] = plane.toGlobal( LocalPoint( -width/2, +length/2, thickness/2));
00038 corners[2] = plane.toGlobal( LocalPoint( +width/2, -length/2, thickness/2));
00039 corners[3] = plane.toGlobal( LocalPoint( +width/2, +length/2, thickness/2));
00040 corners[4] = plane.toGlobal( LocalPoint( -width/2, -length/2, -thickness/2));
00041 corners[5] = plane.toGlobal( LocalPoint( -width/2, +length/2, -thickness/2));
00042 corners[6] = plane.toGlobal( LocalPoint( +width/2, -length/2, -thickness/2));
00043 corners[7] = plane.toGlobal( LocalPoint( +width/2, +length/2, -thickness/2));
00044 }else{
00045
00046 }
00047
00048 float phimin = corners[0].barePhi(); float phimax = phimin;
00049 float zmin = corners[0].z(); float zmax = zmin;
00050 for ( int i = 1; i < 8; i++ ) {
00051 float cPhi = corners[i].barePhi();
00052 if ( Geom::phiLess( cPhi, phimin)) { phimin = cPhi; }
00053 if ( Geom::phiLess( phimax, cPhi)) { phimax = cPhi; }
00054 float z = corners[i].z();
00055 if ( z < zmin) zmin = z;
00056 if ( z > zmax) zmax = z;
00057 }
00058 m_zSpan.first = zmin;
00059 m_zSpan.second = zmax;
00060 m_phiSpan.first = phimin;
00061 m_phiSpan.second = phimax;
00062 }