Back to home page

Project CMSSW displayed by LXR

 
 

    


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 //#define DEBUG
0011 
0012 /* find out about the rotations of the detectors:
0013        
0014   (the code should also find out about other detector-types (pixes-fw, ...)     
0015   currently not implemented, of course)
0016 
0017   - for pixel-barrels:
0018   detectors are modelled by boxes, ORCA convention for the local frame:
0019   . the thickness is in global r-direction of global-CMS
0020   . the longer side if in z-direction of global-CMS
0021   . the shorter side is in phi-direction of global-CMS
0022   ORCA convention of the local-frame:
0023   . the local z-axis is defined to be in direction of the thickness of the box
0024   . the local y-axis is defined to be in direction of the longer side of the box
0025   . the local x-axis is thus in direction of the shorter side of the box
0026     
0027   1. So first look how the detector box is defined in DDD (which axis direction
0028   is the thickness, which axis-direction is the shorter side,...)
0029   2. Define a rotation which reorientates the box to Orca-conventions
0030   in the local frame, if necessary
0031   3. combine the global rotation from DDD with the rotation defined in 2.   
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,   // width - shorter side
0067                                       paras[indexY] / cm,   // length - longer side
0068                                       paras[indexZ] / cm);  // thickness
0069   return bounds;
0070 }
0071 
0072 Bounds* TrackerShapeToBounds::buildTrap(const std::vector<double>& paras) const {
0073   Bounds* bounds = nullptr;
0074   /*
0075     TrapezoidalPlaneBounds (float be, float te, float a, float t)
0076     constructed from:
0077     half bottom edge (smaller side width)
0078     half top edge (larger side width)
0079     half apothem (distance from top to bottom sides, measured perpendicularly to them)
0080     half thickness.
0081     
0082     if  we have indexX=0, indexY=1 and indeZ=2
0083     4 = be (ORCA x)
0084     9 = te (ORCA x)
0085     0 = a (ORCA y)
0086     3 = t (ORCA z)
0087 
0088     if  we have indexX=0, indexY=2 and indeZ=1
0089     4 = be (ORCA x)
0090     9 = te (ORCA x)
0091     3 = a (ORCA y)
0092     0 = t (ORCA z)
0093 
0094     so, so we have the indexes:
0095     if indexX==0, indexY==1, indexZ==2, then everything is ok and
0096     the following orcaCorrection-rotation will be a unit-matrix.
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 }