ATLAS Offline Software
SCT_SkiAux.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //
6 // 1st Feb 2005 D.Naito modified.
7 // 28th Mar 2005 S.Mima modified.
8 //
10 
13 
14 #include "SCT_GeoModel/SCT_Ski.h"
19 
20 #include "GeoModelKernel/GeoTubs.h"
21 #include "GeoModelKernel/GeoLogVol.h"
22 #include "GeoModelKernel/GeoPhysVol.h"
23 #include "GeoModelKernel/GeoNameTag.h"
24 #include "GeoModelKernel/GeoTransform.h"
25 #include "GeoModelKernel/GeoMaterial.h"
26 #include "GeoModelKernel/GeoDefinitions.h"
27 #include "GeoModelKernel/Units.h"
28 
29 #include <cmath>
30 
31 inline double sqr(double x) {return x*x;}
32 
33 // Small utility function to determine min and max angle of components.
34 void
35 calcMinMaxRatioS(double xCenter, double yCenter,
36  double xWidth, double yWidth,
37  double & minRatio, double & maxRatio);
38 
39 SCT_SkiAux::SCT_SkiAux(const std::string & name,
40  SCT_Ski * ski,
41  SCT_Bracket * bracket,
42  SCT_Harness * harness,
43  SCT_SkiPowerTape * skiPowerTape,
44  double innerRadius,
45  double bracketPhiOffset,
46  double powerTapePhiOffset,
47  double divisionAngle,
48  InDetDD::SCT_DetectorManager* detectorManager,
49  SCT_GeometryManager* geometryManager,
50  SCT_MaterialManager* materials) :
51  SCT_SharedComponentFactory(name, detectorManager, geometryManager, materials),
52  m_innerRadius(innerRadius),
53  m_bracketPhiOffset(bracketPhiOffset),
54  m_powerTapePhiOffset(powerTapePhiOffset),
55  m_sectorAngle(divisionAngle),
56  m_ski(ski), m_bracket(bracket), m_harness(harness), m_skiPowerTape(skiPowerTape)
57 {
58  getParameters();
60 }
61 
62 void
64 {
65 }
66 
67 GeoVPhysVol *
69 {
70  // SkiAux is a composition with all the elements that go along with
71  // ski but are not tilted with the ski. Currently the brackets, harness
72  // and powertapes. Harness is not present in older geometries.
73  // The reference point is the beam axis.
74  // The envelope is a tube sector.
75 
76  //
77  // Calculate Position of Brackets. Z position is calculated when it is positioned
78  //
79  // phi offset is calculated in SCT_Layer. For AGE compatible version it is positioned
80  // such that the lower edge of the bracket is lined up with the upper
81  // edge of the next module below it.
82 
83  // Define small distance for avoiding overlaps.
84  double radiusBracket = m_innerRadius + 0.5*m_bracket->thickness() + epsilon();
85  double xBracketPos = radiusBracket * cos(m_bracketPhiOffset);
86  double yBracketPos = radiusBracket * sin(m_bracketPhiOffset);
87 
88  // Calculate position of harness, if present. Phi offset is
89  // same as power tapes, and we leave a gap equal to one tape
90  // width
91  double xHarnessPos = 0;
92  double yHarnessPos = 0;
93  if(m_harness != nullptr) {
94  double radiusHarness = m_innerRadius +
95  0.5 * m_harness->thickness() +
97  xHarnessPos = radiusHarness * cos(m_powerTapePhiOffset);
98  yHarnessPos = radiusHarness * sin(m_powerTapePhiOffset);
99  }
100 
101  //
102  // Calculate Position of PowerTapes
103  //
104  // Calculate x position of stack of tapes.
105  // If no harness is present, this is on the outer surface of the support
106  // cylinder with a gap equal to a tape width. In AGE there is a bug at the
107  // moment so this is not identical to AGE.
108  // If the harness is present, the power tapes are moved beyond the harness
109 
110  double radiusTape = m_innerRadius +
111  0.5 * m_skiPowerTape->thickness() +
113  if(m_harness != nullptr) {radiusTape += m_harness->thickness();}
114  double xTapePos = radiusTape * cos(m_powerTapePhiOffset);
115  double yTapePos = radiusTape * sin(m_powerTapePhiOffset);
116 
117  //
118  // Calculate envelope.
119  //
120  // Calculate the max radius that the components extend to.
121  // N.B. harness is inside power tape, so don't need to check it
122  double rMaxExtentOfPowerTape =
123  sqrt( sqr(radiusTape + 0.5 * m_skiPowerTape->thickness()) +
124  sqr(0.5 * m_skiPowerTape->width()) );
125 
126  double rMaxExtentOfBracket =
127  sqrt( sqr(radiusBracket + 0.5 * m_bracket->thickness()) +
128  sqr(0.5 * m_bracket->width()) );
129 
130  m_outerRadius = std::max(rMaxExtentOfBracket,rMaxExtentOfPowerTape) + epsilon();
131 
132 
133  // calculate min and max tan(alpha) = y/x in order to work out
134  // maximum and minimum angle for the sector.
135  // Assumes angles are between -pi/2 and pi/2 and don't straddle pi/2 boarder.
136  double minAngle=0.;
137  double maxAngle=0.;
138 
139  double halfAngleBracket = atan(0.5 * m_bracket->width()/m_innerRadius);
140  double halfAnglePowerTape = atan(0.5 * m_skiPowerTape->width()/m_innerRadius);
141  // Harness and power tape are at same phi
142  if(m_harness != nullptr) {
143  double halfAngleHarness = atan(0.5 * m_harness->width()/m_innerRadius);
144  halfAnglePowerTape = std::max(halfAnglePowerTape, halfAngleHarness);
145  }
146 
148  minAngle = m_bracketPhiOffset - halfAngleBracket;
149  maxAngle = m_powerTapePhiOffset + halfAnglePowerTape;
150  } else {
151  minAngle = m_powerTapePhiOffset - halfAnglePowerTape;
152  maxAngle = m_bracketPhiOffset + halfAngleBracket;
153  }
154 
155 
156  // Calculate extent so that min and max angle are equal distant to sector edge
157  double midAngle = 0.5 * (minAngle+maxAngle);
159 
160  // Length is same as power tape length
162 
163  const GeoTubs * skiAuxShape = new GeoTubs(m_innerRadius, m_outerRadius, 0.5*m_length,
165  const GeoLogVol *skiAuxLog =
166  new GeoLogVol(getName(), skiAuxShape, m_materials->gasMaterial());
167  GeoPhysVol * skiAux = new GeoPhysVol(skiAuxLog);
168 
169  //
170  // Position brackets
171  //
172 
173  // Loop over modules in ski as we need their z positions.
174  for (int iModule = 0; iModule < m_ski->modulesPerSki(); iModule++) {
175 
176  // Z Position is position of the center of the baseBoard:
177  double coolingCenterPosZ = m_ski->zPos(iModule) + m_ski->coolingBlockOffsetZ();
178  GeoTrf::Translation3D posBracket(xBracketPos, yBracketPos, coolingCenterPosZ);
179  GeoTrf::RotateZ3D rotBracket(m_bracketPhiOffset);
180  skiAux->add(new GeoTransform(GeoTrf::Transform3D(posBracket*rotBracket)));
181  skiAux->add(m_bracket->getVolume());
182  }
183 
184  // Position the harness
185  if(m_harness != nullptr) {
186  GeoTrf::Translation3D posHarness(xHarnessPos, yHarnessPos, 0);
187  GeoTrf::RotateZ3D rotHarness(m_powerTapePhiOffset);
188  skiAux->add(new GeoTransform(GeoTrf::Transform3D(posHarness*rotHarness)));
189  skiAux->add(m_harness->getVolume());
190  }
191 
192  //
193  // Position the power tapes
194  //
195  GeoTrf::Translation3D posTape(xTapePos, yTapePos, 0);
196  GeoTrf::RotateZ3D rotTape(m_powerTapePhiOffset);
197 
198  skiAux->add(new GeoTransform(GeoTrf::Transform3D(posTape*rotTape)));
199  skiAux->add(m_skiPowerTape->getVolume());
200 
201 
202  // return the volume pointer of the top volume
203  return skiAux;
204 
205 }
206 
207 void
208 calcMinMaxRatioS(double xCenter, double yCenter,
209  double xWidth, double yWidth,
210  double & minRatio, double & maxRatio)
211 {
212  // Returns minRatio and maxRatio
213 
214  // This function assumes x is always positive.
215  double x = 0.5 * xWidth;
216  double y = 0.5 * yWidth;
217 
218  double r00,r01,r10,r11;
219 
220  r11 = (yCenter + y) / (xCenter + x);
221  r00 = (yCenter - y) / (xCenter - x);
222  r10 = (yCenter + y) / (xCenter - x);
223  r01 = (yCenter - y) / (xCenter + x);
224 
225  minRatio = std::min(r11 , std::min(r00, std::min(r10, r01)));
226  maxRatio = std::max(r11 , std::max(r00, std::max(r10, r01)));
227 
228 }
SCT_SkiAux::m_ski
SCT_Ski * m_ski
Definition: SCT_SkiAux.h:71
SCT_Bracket::width
double width() const
Definition: SCT_Bracket.h:29
SCT_MaterialManager
Definition: SCT_MaterialManager.h:21
SCT_SkiAux::build
virtual GeoVPhysVol * build()
Definition: SCT_SkiAux.cxx:68
SCT_SkiAux::SCT_SkiAux
SCT_SkiAux(const std::string &name, SCT_Ski *ski, SCT_Bracket *bracket, SCT_Harness *harness, SCT_SkiPowerTape *skiPowerTape, double innerRadius, double bracketPhiOffset, double powerTapePhiOffset, double divisionAngle, InDetDD::SCT_DetectorManager *detectorManager, SCT_GeometryManager *geometryManager, SCT_MaterialManager *materials)
Definition: SCT_SkiAux.cxx:39
InDetDD::SCT_DetectorManager
Definition: SCT_DetectorManager.h:49
SCT_SkiAux::m_bracketPhiOffset
double m_bracketPhiOffset
Definition: SCT_SkiAux.h:65
SCT_Ski::coolingBlockOffsetZ
double coolingBlockOffsetZ() const
Definition: SCT_Ski.h:75
SCT_Bracket
Definition: SCT_Bracket.h:18
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
SCT_MaterialManager.h
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
SCT_Harness.h
x
#define x
SCT_ComponentFactory::epsilon
double epsilon() const
Definition: SCT_ComponentFactory.cxx:38
SCT_SkiPowerTape.h
SCT_SkiAux::m_sectorAngle
double m_sectorAngle
Definition: SCT_SkiAux.h:68
SCT_SkiPowerTape::width
double width() const
Definition: SCT_SkiPowerTape.h:30
drawFromPickle.atan
atan
Definition: drawFromPickle.py:36
SCT_SkiAux::getParameters
void getParameters()
Definition: SCT_SkiAux.cxx:63
SCT_SharedComponentFactory::getVolume
GeoVPhysVol * getVolume()
Definition: SCT_ComponentFactory.h:67
SCT_SkiAux::m_harness
SCT_Harness * m_harness
Definition: SCT_SkiAux.h:73
MuonParameters::midAngle
@ midAngle
Definition: MuonParamDefs.h:149
SCT_MaterialManager::gasMaterial
const GeoMaterial * gasMaterial() const
Definition: SCT_MaterialManager.cxx:69
SCT_Bracket::thickness
double thickness() const
Definition: SCT_Bracket.h:28
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
SCT_SkiPowerTape
Definition: SCT_SkiPowerTape.h:15
SCT_Harness
Definition: SCT_Harness.h:15
SCT_SkiPowerTape::powerTapeThickness
double powerTapeThickness() const
Definition: SCT_SkiPowerTape.h:32
SCT_SkiPowerTape::length
double length() const
Definition: SCT_SkiPowerTape.h:31
SCT_Ski.h
SCT_Ski
Definition: SCT_Ski.h:30
SCT_SkiAux::m_length
double m_length
Definition: SCT_SkiAux.h:64
SCT_ComponentFactory::m_materials
SCT_MaterialManager * m_materials
Definition: SCT_ComponentFactory.h:43
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
SCT_SharedComponentFactory::m_physVolume
GeoVPhysVol * m_physVolume
Definition: SCT_ComponentFactory.h:70
SCT_Module.h
calcMinMaxRatioS
void calcMinMaxRatioS(double xCenter, double yCenter, double xWidth, double yWidth, double &minRatio, double &maxRatio)
Definition: SCT_SkiAux.cxx:208
SCT_SkiAux::m_innerRadius
double m_innerRadius
Definition: SCT_SkiAux.h:62
sqr
double sqr(double x)
Definition: SCT_SkiAux.cxx:31
SCT_Harness::width
double width() const
Definition: SCT_Harness.h:26
SCT_Harness::thickness
double thickness() const
Definition: SCT_Harness.h:25
SCT_SkiAux::m_outerRadius
double m_outerRadius
Definition: SCT_SkiAux.h:63
y
#define y
SCT_Ski::zPos
double zPos(int i) const
Definition: SCT_Ski.h:52
SCT_Bracket.h
Amg::Translation3D
Eigen::Translation< double, 3 > Translation3D
Definition: GeoPrimitives.h:44
SCT_SkiAux::m_powerTapePhiOffset
double m_powerTapePhiOffset
Definition: SCT_SkiAux.h:66
SCT_SharedComponentFactory
Definition: SCT_ComponentFactory.h:56
SCT_SkiAux::m_bracket
SCT_Bracket * m_bracket
Definition: SCT_SkiAux.h:72
SCT_SkiAux::m_skiPowerTape
SCT_SkiPowerTape * m_skiPowerTape
Definition: SCT_SkiAux.h:74
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
SCT_SkiPowerTape::thickness
double thickness() const
Definition: SCT_SkiPowerTape.h:29
SCT_SkiAux.h
SCT_ComponentFactory::getName
const std::string & getName() const
Definition: SCT_ComponentFactory.h:35
SCT_GeometryManager.h
SCT_GeometryManager
Definition: SCT_GeometryManager.h:25
SCT_Ski::modulesPerSki
int modulesPerSki() const
Definition: SCT_Ski.h:56
SCT_SkiAux::m_sectorStartAngle
double m_sectorStartAngle
Definition: SCT_SkiAux.h:67