GEAR  1.9.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Friends Pages
ZPlanarLayerLayout.cc
1 #include "gearimpl/ZPlanarLayerLayoutImpl.h"
2 #include <math.h>
3 
4 namespace gear{
5 
6  void ZPlanarLayerLayoutImpl::addLayer(int nLadders, double phi0,
7  // ladder
8  double ladderDistance, double ladderOffset, double ladderThickness,
9  double ladderLength, double ladderWidth, double ladderRadLength,
10  // sensitive
11  double sensitiveDistance, double sensitiveOffset, double sensitiveThickness,
12  double sensitiveLength, double sensitiveWidth, double sensitiveRadLength )
13  {
14 
15  Layer lL, sL ;
16 
17  // F. Gaede, 04.04.2008 : phi0 and offset have not been defined properly in the past
18  // what we want is: phi0: azimuthal angle of first ladder's normal and the offset
19  // going in the direction of increasing phi
20  // however what is used in the code is phi0 as the angle w/ the y-axis (and wrong orientation)
21  //
22  // -> we keep the internal representation of phi0 in the variable internalPhi0 and return
23  // M_PI/2. - internalPhi0
24 
25  lL.NLadders = nLadders ;
26  lL.internalPhi0 = M_PI/2. - phi0 ; // phi0 given wrt x-axis - internalPhi0 is wrt yaxis , negative orientation
27  lL.Distance = ladderDistance ;
28  lL.Offset = ladderOffset ; // offset given in direction of positive rotation (increasing phi)
29  lL.Thickness = ladderThickness ;
30  lL.Length = ladderLength ;
31  lL.Width = ladderWidth ;
32  lL.RadLength = ladderRadLength ;
33 
34  sL.NLadders = nLadders ;
35  sL.internalPhi0 = M_PI/2. - phi0 ; // phi0 given wrt x-axis - internalPhi0 is wrt yaxis , negative orientation
36  sL.Distance = sensitiveDistance ;
37  sL.Offset = sensitiveOffset ; // offset given in direction of positive rotation (increasing phi)
38  sL.Thickness = sensitiveThickness ;
39  sL.Length = sensitiveLength ;
40  sL.Width = sensitiveWidth ;
41  sL.RadLength = sensitiveRadLength ;
42 
43  _lVec.push_back( lL ) ;
44  _sVec.push_back( sL ) ;
45 
46  }
47 
48 
49  double ZPlanarLayerLayoutImpl::getMaxRadius( int layerIndex, bool sensitive ) const
50  {
51  Layer l ;
52  if (!sensitive) {
53  l = _lVec.at( layerIndex ) ;
54  }
55  else {
56  l = _sVec.at( layerIndex ) ;
57  }
58 
59  float d = l.Distance + l.Thickness ;
60  float w = l.Width / 2 + fabs( l.Offset ) ;
61 
62  double max = sqrt( d*d + w*w ) ;
63 
64  return max ;
65  }
66 
67  // returns starting phi for first ladder in layer (on side to IP)
68  double ZPlanarLayerLayoutImpl::getStartInnerPhi( int layerIndex , bool sensitive ) const
69  {
70  Layer l ;
71  if ( !sensitive ) {
72  l = _lVec.at( layerIndex ) ;
73  }
74  else {
75  l = _sVec.at( layerIndex ) ;
76  }
77  return ( l.internalPhi0 + atan( (-l.Width /2 - l.Offset) / l.Distance) ) ;
78  }
79 
80  // returns ending phi for first ladder in layer (on side to IP)
81  double ZPlanarLayerLayoutImpl::getEndInnerPhi( int layerIndex , bool sensitive ) const
82  {
83  Layer l ;
84  if ( !sensitive ) {
85  l = _lVec.at( layerIndex ) ;
86  }
87  else {
88  l = _sVec.at( layerIndex ) ;
89  }
90  return ( l.internalPhi0 + atan( (l.Width/2 - l.Offset) / l.Distance ) ) ;
91  }
92 
93 
94  // returns starting phi for first ladder in layer (on side away from IP)
95  double ZPlanarLayerLayoutImpl::getStartOuterPhi( int layerIndex , bool sensitive ) const
96  {
97  Layer l ;
98  if (sensitive) {
99  l = _lVec.at( layerIndex ) ;
100  }
101  else {
102  l = _sVec.at( layerIndex ) ;
103  }
104  return ( l.internalPhi0 - atan( (l.Width /2 + l.Offset) / (l.Distance + l.Thickness) ) ) ;
105  }
106 
107  // returns ending phi for first ladder in layer (on side away from IP)
108  double ZPlanarLayerLayoutImpl::getEndOuterPhi( int layerIndex , bool sensitive ) const
109  {
110  Layer l ;
111  if (sensitive) {
112  l = _lVec.at( layerIndex ) ;
113  }
114  else {
115  l = _sVec.at( layerIndex ) ;
116  }
117  return ( l.internalPhi0 + atan( (l.Width/2 - l.Offset) / (l.Distance + l.Thickness) ) ) ;
118  }
119 
120  // returns thickness under a certain angle
121  double ZPlanarLayerLayoutImpl::getThicknessForPhi( int layerIndex , double phi, bool sensitive ) const
122  {
123  Layer l ;
124  if (!sensitive) {
125  l = _lVec.at( layerIndex ) ;
126  }
127  else {
128  l = _sVec.at( layerIndex ) ;
129  }
130 
131  double angularThickness ;
132 
133  // first check if layer is completely out of ladder
134  if( phi < getStartInnerPhi( layerIndex , sensitive ) || phi > getEndInnerPhi( layerIndex, sensitive ) ) {
135  return -1 ;
136  }
137 
138  // check if angle is withhin outer boundaries - easy calculation then
139  if( phi >= getStartOuterPhi( layerIndex , sensitive ) && phi <= getEndOuterPhi( layerIndex , sensitive ) ) {
140  return ( l.Thickness / cos( phi ) ) ;
141  }
142 
143  // the angel is in corner area:
144 
145  // calculate distance from space point to intersection point with straight line from IP under phi
146  double distanceSpacePoint = l.Distance * tan( phi ) ;
147 
148  // calculate length of edge that is cut away on side facing IP
149  double cutAwayLength = l.Width/2 - l.Offset - distanceSpacePoint ;
150 
151  // now one can calculate the angular thickness
152  angularThickness = cutAwayLength / sin( phi ) ;
153 
154  return angularThickness ;
155  }
156 
157 
158 
159 
160 } //namespace
virtual double getMaxRadius(int layerIndex, bool sensitive=false) const
returns maximum radius for a given layer
virtual double getStartOuterPhi(int layerIndex, bool sensitive=false) const
returns starting phi for first ladder in layer layerIndex (on side away from IP)
virtual double getThicknessForPhi(int layerIndex, double phi, bool sensitive=false) const
returns thickness as viewed under the angle phi only for the first ladder in layer layerIndex...
virtual void addLayer(int nLadders, double phi0, double ladderDistance, double ladderOffset, double ladderThickness, double ladderLength, double ladderWidth, double ladderRadLength, double sensitiveDistance, double sensitiveOffset, double sensitiveThickness, double sensitiveLength, double sensitiveWidth, double sensitiveRadLength)
Add a new layer at the given positon.
virtual double getEndOuterPhi(int layerIndex, bool sensitive=false) const
returns ending phi for first ladder in layer layerIndex (on side away from IP)
virtual double getEndInnerPhi(int layerIndex, bool sensitive=false) const
returns ending phi for first ladder in layer layerIndex (on side facing IP)
Helper class for layer properties.
virtual double getStartInnerPhi(int layerIndex, bool sensitive=false) const
returns starting phi for first ladder in layer layerIndex (on side facing IP)