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