Go to the documentation of this file.00001 #include "TrackingTools/DetLayers/interface/CylinderBuilderFromDet.h"
00002 #include "DataFormats/GeometrySurface/interface/SimpleCylinderBounds.h"
00003 #include "DataFormats/GeometrySurface/interface/BoundingBox.h"
00004 #include <algorithm>
00005
00006 using namespace std;
00007
00008 BoundCylinder*
00009 CylinderBuilderFromDet::operator()( vector<const Det*>::const_iterator first,
00010 vector<const Det*>::const_iterator last) const
00011 {
00012
00013 typedef PositionType::BasicVectorType Vector;
00014 Vector posSum(0,0,0);
00015 float rSum = 0;
00016 for (vector<const Det*>::const_iterator i=first; i!=last; i++) {
00017 posSum += (**i).surface().position().basicVector();
00018 rSum += (**i).surface().position().perp();
00019 }
00020 float div(1/float(last-first));
00021 PositionType meanPos( div*posSum);
00022 float meanR( div*rSum);
00023
00024
00025 float rmin = meanR;
00026 float rmax = meanR;
00027 float zmin = meanPos.z();
00028 float zmax = meanPos.z();
00029 for (vector<const Det*>::const_iterator i=first; i!=last; i++) {
00030 vector<GlobalPoint> corners =
00031 BoundingBox::corners( dynamic_cast<const BoundPlane&>((**i).surface()));
00032 for (vector<GlobalPoint>::const_iterator ic = corners.begin();
00033 ic != corners.end(); ic++) {
00034 float r = ic->perp();
00035 float z = ic->z();
00036 rmin = min( rmin, r);
00037 rmax = max( rmax, r);
00038 zmin = min( zmin, z);
00039 zmax = max( zmax, z);
00040 }
00041
00042
00043
00044 float rdet = (**i).surface().position().perp();
00045 float halfThick = (**i).surface().bounds().thickness() / 2.F;
00046 rmin = min( rmin, rdet-halfThick);
00047 rmax = max( rmax, rdet+halfThick);
00048 }
00049
00050
00051
00052
00053
00054
00055
00056 PositionType pos( 0, 0, 0.5*(zmin+zmax));
00057 RotationType rot;
00058
00059 return new BoundCylinder( pos, rot,
00060 SimpleCylinderBounds( rmin, rmax,
00061 zmin-pos.z(), zmax-pos.z()));
00062 }
00063
00064 void CylinderBuilderFromDet::operator()(const Det& det) {
00065 BoundingBox bb( dynamic_cast<const BoundPlane&>(det.surface()));
00066 for (int nc=0; nc<8; ++nc) {
00067 float r = bb[nc].perp();
00068 float z = bb[nc].z();
00069 rmin = std::min( rmin, r);
00070 rmax = std::max( rmax, r);
00071 zmin = std::min( zmin, z);
00072 zmax = std::max( zmax, z);
00073 }
00074
00075
00076
00077 float rdet = det.surface().position().perp();
00078 float halfThick = det.surface().bounds().thickness() / 2.F;
00079 rmin = std::min( rmin, rdet-halfThick);
00080 rmax = std::max( rmax, rdet+halfThick);
00081 }
00082
00083 BoundCylinder* CylinderBuilderFromDet::build() const {
00084
00085 PositionType pos( 0, 0, 0.5*(zmin+zmax));
00086 RotationType rot;
00087
00088 return new BoundCylinder( pos, rot,
00089 SimpleCylinderBounds( rmin, rmax,
00090 zmin-pos.z(), zmax-pos.z()));
00091 }