CMS 3D CMS Logo

TrackerShapeToBounds.cc
Go to the documentation of this file.
5 #include <CLHEP/Units/SystemOfUnits.h>
6 #include <algorithm>
7 #include <iostream>
8 
9 using CLHEP::cm;
10 //#define DEBUG
11 
12 /* find out about the rotations of the detectors:
13 
14  (the code should also find out about other detector-types (pixes-fw, ...)
15  currently not implemented, of course)
16 
17  - for pixel-barrels:
18  detectors are modelled by boxes, ORCA convention for the local frame:
19  . the thickness is in global r-direction of global-CMS
20  . the longer side if in z-direction of global-CMS
21  . the shorter side is in phi-direction of global-CMS
22  ORCA convention of the local-frame:
23  . the local z-axis is defined to be in direction of the thickness of the box
24  . the local y-axis is defined to be in direction of the longer side of the box
25  . the local x-axis is thus in direction of the shorter side of the box
26 
27  1. So first look how the detector box is defined in DDD (which axis direction
28  is the thickness, which axis-direction is the shorter side,...)
29  2. Define a rotation which reorientates the box to Orca-conventions
30  in the local frame, if necessary
31  3. combine the global rotation from DDD with the rotation defined in 2.
32  */
33 
34 Bounds* TrackerShapeToBounds::buildBounds(const cms::DDSolidShape& shape, const std::vector<double>& par) const {
35  switch (shape) {
37  return buildBox(par);
38  break;
40  return buildTrap(par);
41  break;
45  return buildOpen();
46  break;
47  default:
48  std::cout << "Wrong DDshape to build...." << cms::dd::name(cms::DDSolidShapeMap, shape) << std::endl;
49  Bounds* bounds = nullptr;
50  return bounds;
51  }
52 }
53 
54 Bounds* TrackerShapeToBounds::buildBox(const std::vector<double>& paras) const {
55  int indexX = 0;
56  int indexY = 1;
57  int indexZ = 2;
58  Bounds* bounds = nullptr;
59 
60  if (paras[1] < paras[0] && paras[0] < paras[2]) {
61  indexX = 0;
62  indexY = 2;
63  indexZ = 1;
64  }
65 
66  bounds = new RectangularPlaneBounds(paras[indexX] / cm, // width - shorter side
67  paras[indexY] / cm, // length - longer side
68  paras[indexZ] / cm); // thickness
69  return bounds;
70 }
71 
72 Bounds* TrackerShapeToBounds::buildTrap(const std::vector<double>& paras) const {
73  Bounds* bounds = nullptr;
74  /*
75  TrapezoidalPlaneBounds (float be, float te, float a, float t)
76  constructed from:
77  half bottom edge (smaller side width)
78  half top edge (larger side width)
79  half apothem (distance from top to bottom sides, measured perpendicularly to them)
80  half thickness.
81 
82  if we have indexX=0, indexY=1 and indeZ=2
83  4 = be (ORCA x)
84  9 = te (ORCA x)
85  0 = a (ORCA y)
86  3 = t (ORCA z)
87 
88  if we have indexX=0, indexY=2 and indeZ=1
89  4 = be (ORCA x)
90  9 = te (ORCA x)
91  3 = a (ORCA y)
92  0 = t (ORCA z)
93 
94  so, so we have the indexes:
95  if indexX==0, indexY==1, indexZ==2, then everything is ok and
96  the following orcaCorrection-rotation will be a unit-matrix.
97  */
98 
99  if (paras[0] < 5) {
100  bounds = new TrapezoidalPlaneBounds(paras[4] / cm, paras[9] / cm, paras[3] / cm, paras[0] / cm);
101  } else if (paras[0] > paras[3]) {
102  bounds = new TrapezoidalPlaneBounds(paras[4] / cm, paras[9] / cm, paras[0] / cm, paras[3] / cm);
103  }
104  return bounds;
105 }
106 
108  OpenBounds* bounds = new OpenBounds();
109  return bounds;
110 }
std::string name(Mapping a, V value)
Definition: DDSolidShapes.h:31
Bounds * buildBounds(const cms::DDSolidShape &, const std::vector< double > &) const
const std::array< const cms::dd::NameValuePair< DDSolidShape >, 21 > DDSolidShapeMap
Definition: DDSolidShapes.h:99
Bounds * buildTrap(const std::vector< double > &) const
Unlimited (trivial) bounds.
Definition: OpenBounds.h:9
Definition: Bounds.h:18
Bounds * buildBox(const std::vector< double > &) const
DDSolidShape
Definition: DDSolidShapes.h:73