File indexing completed on 2024-05-10 02:20:55
0001 #include "Geometry/TrackerNumberingBuilder/interface/TrackerShapeToBounds.h"
0002 #include "DataFormats/GeometrySurface/interface/OpenBounds.h"
0003 #include "DataFormats/GeometrySurface/interface/RectangularPlaneBounds.h"
0004 #include "DataFormats/GeometrySurface/interface/TrapezoidalPlaneBounds.h"
0005 #include <CLHEP/Units/SystemOfUnits.h>
0006 #include <algorithm>
0007 #include <iostream>
0008
0009 using CLHEP::cm;
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 Bounds* TrackerShapeToBounds::buildBounds(const cms::DDSolidShape& shape, const std::vector<double>& par) const {
0035 switch (shape) {
0036 case cms::DDSolidShape::ddbox:
0037 return buildBox(par);
0038 break;
0039 case cms::DDSolidShape::ddtrap:
0040 return buildTrap(par);
0041 break;
0042 case cms::DDSolidShape::ddtubs:
0043 case cms::DDSolidShape::ddpolycone:
0044 case cms::DDSolidShape::ddsubtraction:
0045 return buildOpen();
0046 break;
0047 default:
0048 std::cout << "Wrong DDshape to build...." << cms::dd::name(cms::DDSolidShapeMap, shape) << std::endl;
0049 Bounds* bounds = nullptr;
0050 return bounds;
0051 }
0052 }
0053
0054 Bounds* TrackerShapeToBounds::buildBox(const std::vector<double>& paras) const {
0055 int indexX = 0;
0056 int indexY = 1;
0057 int indexZ = 2;
0058 Bounds* bounds = nullptr;
0059
0060 if (paras[1] < paras[0] && paras[0] < paras[2]) {
0061 indexX = 0;
0062 indexY = 2;
0063 indexZ = 1;
0064 }
0065
0066 bounds = new RectangularPlaneBounds(paras[indexX] / cm,
0067 paras[indexY] / cm,
0068 paras[indexZ] / cm);
0069 return bounds;
0070 }
0071
0072 Bounds* TrackerShapeToBounds::buildTrap(const std::vector<double>& paras) const {
0073 Bounds* bounds = nullptr;
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099 if (paras[0] < 5) {
0100 bounds = new TrapezoidalPlaneBounds(paras[4] / cm, paras[9] / cm, paras[3] / cm, paras[0] / cm);
0101 } else if (paras[0] > paras[3]) {
0102 bounds = new TrapezoidalPlaneBounds(paras[4] / cm, paras[9] / cm, paras[0] / cm, paras[3] / cm);
0103 }
0104 return bounds;
0105 }
0106
0107 Bounds* TrackerShapeToBounds::buildOpen() const {
0108 OpenBounds* bounds = new OpenBounds();
0109 return bounds;
0110 }