CMS 3D CMS Logo

ForwardRingDiskBuilderFromDet.cc

Go to the documentation of this file.
00001 #include "TrackingTools/DetLayers/interface/ForwardRingDiskBuilderFromDet.h"
00002 #include "DataFormats/GeometrySurface/interface/SimpleDiskBounds.h"
00003 #include "DataFormats/GeometrySurface/interface/BoundingBox.h"
00004 
00005 using namespace std;
00006 
00007 // Warning, remember to assign this pointer to a ReferenceCountingPointer!
00008 BoundDisk* 
00009 ForwardRingDiskBuilderFromDet::operator()( const vector<const GeomDet*>& dets) const
00010 {
00011   pair<SimpleDiskBounds,float> bo = 
00012     computeBounds( dets );
00013 
00014 //   LogDebug("DetLayers") << "Creating disk at Z: " << bo.second << "\n"
00015 //        << "Bounds are (rmin/rmax/thick) " << bo.first.innerRadius()
00016 //        << " / " <<  bo.first.outerRadius()
00017 //        << " / " <<  bo.first.thickness()  ;
00018 
00019 //   typedef Det::PositionType::BasicVectorType Vector; 
00020 //   Vector posSum(0,0,0);
00021 //   for (vector<Det*>::const_iterator i=dets.begin(); i!=dets.end(); i++) {
00022 //     Vector pp = (**i).position().basicVector();
00023 //     //    LogDebug("DetLayers") << "  "<< (int) ( i-dets.begin()) << " at " << pp ;
00024 //     posSum += pp;
00025 //   }
00026 //   Det::PositionType meanPos( posSum/float(dets.size()));
00027 //   LogDebug("DetLayers") << "  meanPos "<< meanPos ;
00028 
00029   Surface::PositionType pos(0.,0.,bo.second);
00030   Surface::RotationType rot;
00031   return new BoundDisk( pos, rot, bo.first);
00032 }
00033 
00034 pair<SimpleDiskBounds, float>
00035 ForwardRingDiskBuilderFromDet::computeBounds( const vector<const GeomDet*>& dets) const
00036 {
00037   // go over all corners and compute maximum deviations from mean pos.
00038   float rmin((**(dets.begin())).surface().position().perp());
00039   float rmax(rmin); 
00040   float zmin((**(dets.begin())).surface().position().z());
00041   float zmax(zmin);
00042   for (vector<const GeomDet*>::const_iterator idet=dets.begin();
00043        idet != dets.end(); idet++) {
00044     
00045     /* ---- original implementation. Is it obsolete?
00046     vector<DetUnit*> detUnits = (**idet).detUnits();
00047     for (vector<DetUnit*>::const_iterator detu=detUnits.begin();
00048     detu!=detUnits.end(); detu++) {
00049     vector<GlobalPoint> corners = BoundingBox().corners(
00050     dynamic_cast<const BoundPlane&>((**detu).surface()));
00051     }
00052     ----- */
00053     vector<GlobalPoint> corners = BoundingBox().corners( (**idet).specificSurface() );
00054     for (vector<GlobalPoint>::const_iterator i=corners.begin();
00055          i!=corners.end(); i++) {
00056       float r = i->perp();
00057       float z = i->z();
00058       rmin = min( rmin, r);
00059       rmax = max( rmax, r);
00060       zmin = min( zmin, z);
00061       zmax = max( zmax, z);
00062     }
00063     // in addition to the corners we have to check the middle of the 
00064     // det +/- length/2, since the min (max) radius for typical fw
00065     // dets is reached there
00066 
00067     float rdet  = (**idet).position().perp();
00068     float len   = (**idet).surface().bounds().length();
00069     float width = (**idet).surface().bounds().width();
00070 
00071     GlobalVector xAxis = (**idet).toGlobal(LocalVector(1,0,0));
00072     GlobalVector yAxis = (**idet).toGlobal(LocalVector(0,1,0));
00073     GlobalVector perpDir = GlobalVector( (**idet).position() - GlobalPoint(0,0,(**idet).position().z()) );
00074 
00075     double xAxisCos = xAxis.unit().dot(perpDir.unit());
00076     double yAxisCos = yAxis.unit().dot(perpDir.unit());
00077 
00078     if( fabs(xAxisCos) > fabs(yAxisCos) ) {
00079       rmin = min( rmin, rdet-width/2.F);
00080       rmax = max( rmax, rdet+width/2.F);
00081     }else{
00082       rmin = min( rmin, rdet-len/2.F);
00083       rmax = max( rmax, rdet+len/2.F);
00084     }
00085   }
00086 
00087   
00088   float zPos = (zmax+zmin)/2.;
00089   return make_pair(SimpleDiskBounds(rmin,rmax,zmin-zPos,zmax-zPos), zPos);
00090 }

Generated on Tue Jun 9 17:48:16 2009 for CMSSW by  doxygen 1.5.4