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
0008 BoundDisk* ForwardRingDiskBuilderFromDet::operator()(const vector<const GeomDet*>& dets) const {
0009 auto bo = computeBounds(dets);
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
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
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
0039
0040
0041
0042
0043
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
0056
0057
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 }