Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:27

0001 #include "TrackingTools/DetLayers/interface/ForwardRingDiskBuilderFromDet.h"
0002 #include "DataFormats/GeometrySurface/interface/SimpleDiskBounds.h"
0003 #include "DataFormats/GeometrySurface/interface/BoundingBox.h"
0004 
0005 using namespace std;
0006 
0007 // Warning, remember to assign this pointer to a ReferenceCountingPointer!
0008 BoundDisk* ForwardRingDiskBuilderFromDet::operator()(const vector<const GeomDet*>& dets) const {
0009   auto bo = computeBounds(dets);
0010 
0011   //   LogDebug("DetLayers") << "Creating disk at Z: " << bo.second << "\n"
0012   //        << "Bounds are (rmin/rmax/thick) " << bo.first.innerRadius()
0013   //        << " / " <<  bo.first.outerRadius()
0014   //        << " / " <<  bo.first.thickness()  ;
0015 
0016   //   typedef Det::PositionType::BasicVectorType Vector;
0017   //   Vector posSum(0,0,0);
0018   //   for (vector<Det*>::const_iterator i=dets.begin(); i!=dets.end(); i++) {
0019   //     Vector pp = (**i).position().basicVector();
0020   //     //    LogDebug("DetLayers") << "  "<< (int) ( i-dets.begin()) << " at " << pp ;
0021   //     posSum += pp;
0022   //   }
0023   //   Det::PositionType meanPos( posSum/float(dets.size()));
0024   //   LogDebug("DetLayers") << "  meanPos "<< meanPos ;
0025 
0026   Surface::PositionType pos(0., 0., bo.second);
0027   Surface::RotationType rot;
0028   return new BoundDisk(pos, rot, bo.first);
0029 }
0030 
0031 pair<SimpleDiskBounds*, float> ForwardRingDiskBuilderFromDet::computeBounds(const vector<const GeomDet*>& dets) const {
0032   // go over all corners and compute maximum deviations from mean pos.
0033   float rmin((**(dets.begin())).surface().position().perp());
0034   float rmax(rmin);
0035   float zmin((**(dets.begin())).surface().position().z());
0036   float zmax(zmin);
0037   for (vector<const GeomDet*>::const_iterator idet = dets.begin(); idet != dets.end(); idet++) {
0038     /* ---- original implementation. Is it obsolete?
0039     vector<DetUnit*> detUnits = (**idet).detUnits();
0040     for (vector<DetUnit*>::const_iterator detu=detUnits.begin();
0041     detu!=detUnits.end(); detu++) {
0042     vector<GlobalPoint> corners = BoundingBox().corners(
0043     dynamic_cast<const Plane&>((**detu).surface()));
0044     }
0045     ----- */
0046     vector<GlobalPoint> corners = BoundingBox().corners((**idet).specificSurface());
0047     for (vector<GlobalPoint>::const_iterator i = corners.begin(); i != corners.end(); i++) {
0048       float r = i->perp();
0049       float z = i->z();
0050       rmin = min(rmin, r);
0051       rmax = max(rmax, r);
0052       zmin = min(zmin, z);
0053       zmax = max(zmax, z);
0054     }
0055     // in addition to the corners we have to check the middle of the
0056     // det +/- length/2, since the min (max) radius for typical fw
0057     // dets is reached there
0058 
0059     float rdet = (**idet).position().perp();
0060     float len = (**idet).surface().bounds().length();
0061     float width = (**idet).surface().bounds().width();
0062 
0063     GlobalVector xAxis = (**idet).toGlobal(LocalVector(1, 0, 0));
0064     GlobalVector yAxis = (**idet).toGlobal(LocalVector(0, 1, 0));
0065     GlobalVector perpDir = GlobalVector((**idet).position() - GlobalPoint(0, 0, (**idet).position().z()));
0066 
0067     double xAxisCos = xAxis.unit().dot(perpDir.unit());
0068     double yAxisCos = yAxis.unit().dot(perpDir.unit());
0069 
0070     if (fabs(xAxisCos) > fabs(yAxisCos)) {
0071       rmin = min(rmin, rdet - width / 2.F);
0072       rmax = max(rmax, rdet + width / 2.F);
0073     } else {
0074       rmin = min(rmin, rdet - len / 2.F);
0075       rmax = max(rmax, rdet + len / 2.F);
0076     }
0077   }
0078 
0079   float zPos = (zmax + zmin) / 2.;
0080   return make_pair(new SimpleDiskBounds(rmin, rmax, zmin - zPos, zmax - zPos), zPos);
0081 }