Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:49:13

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/GlobalSystemOfUnits.h"
0006 #include <algorithm>
0007 #include <iostream>
0008 //#define DEBUG
0009 
0010 /* find out about the rotations of the detectors:
0011        
0012   (the code should also find out about other detector-types (pixes-fw, ...)     
0013   currently not implemented, of course)
0014 
0015   - for pixel-barrels:
0016   detectors are modelled by boxes, ORCA convention for the local frame:
0017   . the thickness is in global r-direction of global-CMS
0018   . the longer side if in z-direction of global-CMS
0019   . the shorter side is in phi-direction of global-CMS
0020   ORCA convention of the local-frame:
0021   . the local z-axis is defined to be in direction of the thickness of the box
0022   . the local y-axis is defined to be in direction of the longer side of the box
0023   . the local x-axis is thus in direction of the shorter side of the box
0024     
0025   1. So first look how the detector box is defined in DDD (which axis direction
0026   is the thickness, which axis-direction is the shorter side,...)
0027   2. Define a rotation which reorientates the box to Orca-conventions
0028   in the local frame, if necessary
0029   3. combine the global rotation from DDD with the rotation defined in 2.   
0030   */
0031 
0032 Bounds* TrackerShapeToBounds::buildBounds(const cms::DDSolidShape& shape, const std::vector<double>& par) const {
0033   switch (shape) {
0034     case cms::DDSolidShape::ddbox:
0035       return buildBox(par);
0036       break;
0037     case cms::DDSolidShape::ddtrap:
0038       return buildTrap(par);
0039       break;
0040     case cms::DDSolidShape::ddtubs:
0041     case cms::DDSolidShape::ddpolycone:
0042     case cms::DDSolidShape::ddsubtraction:
0043       return buildOpen();
0044       break;
0045     default:
0046       std::cout << "Wrong DDshape to build...." << cms::dd::name(cms::DDSolidShapeMap, shape) << std::endl;
0047       Bounds* bounds = nullptr;
0048       return bounds;
0049   }
0050 }
0051 
0052 Bounds* TrackerShapeToBounds::buildBox(const std::vector<double>& paras) const {
0053   int indexX = 0;
0054   int indexY = 1;
0055   int indexZ = 2;
0056   Bounds* bounds = nullptr;
0057 
0058   if (paras[1] < paras[0] && paras[0] < paras[2]) {
0059     indexX = 0;
0060     indexY = 2;
0061     indexZ = 1;
0062   }
0063 
0064   bounds = new RectangularPlaneBounds(paras[indexX] / cm,   // width - shorter side
0065                                       paras[indexY] / cm,   // length - longer side
0066                                       paras[indexZ] / cm);  // thickness
0067   return bounds;
0068 }
0069 
0070 Bounds* TrackerShapeToBounds::buildTrap(const std::vector<double>& paras) const {
0071   Bounds* bounds = nullptr;
0072   /*
0073     TrapezoidalPlaneBounds (float be, float te, float a, float t)
0074     constructed from:
0075     half bottom edge (smaller side width)
0076     half top edge (larger side width)
0077     half apothem (distance from top to bottom sides, measured perpendicularly to them)
0078     half thickness.
0079     
0080     if  we have indexX=0, indexY=1 and indeZ=2
0081     4 = be (ORCA x)
0082     9 = te (ORCA x)
0083     0 = a (ORCA y)
0084     3 = t (ORCA z)
0085 
0086     if  we have indexX=0, indexY=2 and indeZ=1
0087     4 = be (ORCA x)
0088     9 = te (ORCA x)
0089     3 = a (ORCA y)
0090     0 = t (ORCA z)
0091 
0092     so, so we have the indexes:
0093     if indexX==0, indexY==1, indexZ==2, then everything is ok and
0094     the following orcaCorrection-rotation will be a unit-matrix.
0095   */
0096 
0097   if (paras[0] < 5) {
0098     bounds = new TrapezoidalPlaneBounds(paras[4] / cm, paras[9] / cm, paras[3] / cm, paras[0] / cm);
0099   } else if (paras[0] > paras[3]) {
0100     bounds = new TrapezoidalPlaneBounds(paras[4] / cm, paras[9] / cm, paras[0] / cm, paras[3] / cm);
0101   }
0102   return bounds;
0103 }
0104 
0105 Bounds* TrackerShapeToBounds::buildOpen() const {
0106   OpenBounds* bounds = new OpenBounds();
0107   return bounds;
0108 }