CMS 3D CMS Logo

DDTIDAxialCableAlgo.cc
Go to the documentation of this file.
1 // File: DDTIDAxialCableAlgo.cc
3 // Description: Create and position TID axial cables at prescribed phi values
5 
6 #include <algorithm>
7 #include <cmath>
8 
9 #include "DD4hep/DetFactoryHelper.h"
13 
14 using namespace edm;
15 using namespace dd4hep;
16 using namespace cms;
17 using namespace geant_units::operators;
18 
19 namespace {
21  xml_h e, SensitiveDetector & /* sens */) {
22  cms::DDNamespace ns(ctxt, e, true);
23  cms::DDAlgoArguments args(ctxt, e);
24 
25  LogVerbatim("TIDGeom") << "DDTIDAxialCableAlgo info: Creating an instance...";
26 
27  double zBend = args.value<double>("ZBend"); // Start z (at bending)........
28  double zEnd = args.value<double>("ZEnd"); // End z ........
29  double rMin = args.value<double>("RMin"); // Minimum radius ........
30  double rMax = args.value<double>("RMax"); // Maximum radius ........
31  double rTop = args.value<double>("RTop"); // Maximum radius (top)........
32  double width = args.value<double>("Width"); // Angular width
33  double thick = args.value<double>("Thick"); // Thickness
34  std::vector<double> angles =
35  args.value<std::vector<double>>("Angles"); // Phi Angles
36  std::vector<double> zposWheel =
37  args.value<std::vector<double>>("ZPosWheel"); // Z position of wheels
38  std::vector<double> zposRing = args.value<std::vector<double>>(
39  "ZPosRing"); // Z position of rings inside wheels
40 
41  std::string childName = args.value<std::string>("ChildName"); // Child name
42  std::string matIn =
43  args.value<std::string>("MaterialIn"); // Material name (for inner parts)
44  std::string matOut =
45  args.value<std::string>("MaterialOut"); // Material name (for outer part)
46 
47  LogVerbatim("TIDGeom")
48  << "DDTIDAxialCableAlgo debug: Parameters for creating "
49  << (zposWheel.size() + 2) << " axial cables and positioning"
50  << angles.size() << "copies in Service volume"
51  << "\nzBend " << zBend << "\nzEnd " << zEnd << "\nrMin " << rMin
52  << "\nrMax " << rMax << "\nCable width " << convertRadToDeg(width)
53  << "\nthickness " << thick << " with Angles";
54 
55  for (int i = 0; i < (int)(angles.size()); i++)
56  LogVerbatim("TIDGeom") << "\n\tangles[" << i
57  << "] = " << convertRadToDeg(angles[i]);
58 
59  LogVerbatim("TIDGeom") << "\nWheels " << zposWheel.size() << " at Z";
60 
61  for (int i = 0; i < (int)(zposWheel.size()); i++)
62  LogVerbatim("TIDGeom") << "\n\tzposWheel[" << i << "] = " << zposWheel[i];
63 
64  LogVerbatim("TIDGeom") << "\neach with " << zposRing.size() << " Rings at Z";
65 
66  for (int i = 0; i < (int)(zposRing.size()); i++)
67  LogVerbatim("TIDGeom") << "\tzposRing[" << i << "] = " << zposRing[i];
68 
69  Volume mother = ns.volume(args.parentName());
70 
71  LogVerbatim("TIDGeom") << "DDTIDAxialCableAlgo debug: Parent "
72  << mother.name() << "\tChild " << childName
73  << " NameSpace " << ns.name() << "\tMaterial " << matIn
74  << " and " << matOut;
75 
76  std::vector<Volume> logs;
77  const double thk = thick / zposRing.size();
78  double r = rMin;
79  double thktot = 0;
80  double z;
81 
82  // Cables between the wheels
83  for (int k = 0; k < (int)(zposWheel.size()); k++) {
84  std::vector<double> pconZ, pconRmin, pconRmax;
85 
86  for (int i = 0; i < (int)(zposRing.size()); i++) {
87  thktot += thk;
88  z = zposWheel[k] + zposRing[i] - 0.5 * thk;
89 
90  if (i != 0) {
91  pconZ.emplace_back(z);
92  pconRmin.emplace_back(r);
93  pconRmax.emplace_back(rMax);
94  }
95 
96  r = rMin;
97  pconZ.emplace_back(z);
98  pconRmin.emplace_back(r);
99  pconRmax.emplace_back(rMax);
100 
101  z += thk;
102  pconZ.emplace_back(z);
103  pconRmin.emplace_back(r);
104  pconRmax.emplace_back(rMax);
105 
106  r = rMax - thktot;
107  pconZ.emplace_back(z);
108  pconRmin.emplace_back(r);
109  pconRmax.emplace_back(rMax);
110  }
111 
112  if (k >= ((int)(zposWheel.size()) - 1))
113  z = zBend;
114  else
115  z = zposWheel[k + 1] + zposRing[0] - 0.5 * thk;
116 
117  pconZ.emplace_back(z);
118  pconRmin.emplace_back(r);
119  pconRmax.emplace_back(rMax);
120 
121  std::string name = childName + std::to_string(k);
122 
123  Solid solid = ns.addSolid(
124  name, Polycone(-0.5 * width, width, pconRmin, pconRmax, pconZ));
125 
126  LogVerbatim("TIDGeom") << "DDTIDAxialCableAlgo test: " << solid.name()
127  << " Polycone made of " << matIn << " from "
128  << convertRadToDeg(-0.5 * width) << " to "
129  << convertRadToDeg(0.5 * width) << " and with "
130  << pconZ.size() << " sections ";
131 
132  for (int i = 0; i < (int)(pconZ.size()); i++)
133  LogVerbatim("TIDGeom")
134  << "\t[" << i << "]\tZ = " << pconZ[i] << "\tRmin = " << pconRmin[i]
135  << "\tRmax = " << pconRmax[i];
136 
137  logs.emplace_back(
138  Volume(solid.name(), solid, ns.material("materials:Air")));
139  }
140 
141  // Cable in the vertical part
142  std::vector<double> pconZ, pconRmin, pconRmax;
143  r = thktot * rMax / rTop;
144  z = zBend - thktot;
145  LogVerbatim("TIDGeom") << "DDTIDAxialCableAlgo test: Thk " << thk << " Total "
146  << thktot << " rMax " << rMax << " rTop " << rTop
147  << " dR " << r << " z " << z;
148 
149  pconZ.emplace_back(z);
150  pconRmin.emplace_back(rMax);
151  pconRmax.emplace_back(rMax);
152 
153  z = zBend - r;
154  pconZ.emplace_back(z);
155  pconRmin.emplace_back(rMax);
156  pconRmax.emplace_back(rTop);
157 
158  pconZ.emplace_back(zBend);
159  pconRmin.emplace_back(rMax);
160  pconRmax.emplace_back(rTop);
161 
162  std::string name = childName + std::to_string(zposWheel.size());
163 
164  Solid solid = ns.addSolid(
165  name, Polycone(-0.5 * width, width, pconRmin, pconRmax, pconZ));
166 
167  LogVerbatim("TIDGeom") << "DDTIDAxialCableAlgo test: " << solid.name()
168  << " Polycone made of " << matIn << " from "
169  << convertRadToDeg(-0.5 * width) << " to "
170  << convertRadToDeg(0.5 * width) << " and with "
171  << pconZ.size() << " sections ";
172 
173  for (int i = 0; i < (int)(pconZ.size()); i++)
174  LogVerbatim("TIDGeom") << "\t[" << i << "]\tZ = " << pconZ[i]
175  << "\tRmin = " << pconRmin[i]
176  << "\tRmax = " << pconRmax[i];
177 
178  logs.emplace_back(Volume(solid.name(), solid, ns.material(matIn)));
179 
180  // Cable in the outer part
181  name = childName + std::to_string(zposWheel.size() + 1);
182  r = rTop - r;
183  solid = ns.addSolid(name,
184  Tube(r, rTop, 0.5 * (zEnd - zBend), -0.5 * width, width));
185 
186  LogVerbatim("TIDGeom") << "DDTIDAxialCableAlgo test: " << solid.name()
187  << " Tubs made of " << matOut << " from "
188  << convertRadToDeg(-0.5 * width) << " to "
189  << convertRadToDeg(0.5 * width) << " with Rin " << r
190  << " Rout " << rTop << " ZHalf "
191  << 0.5 * (zEnd - zBend);
192 
193  logs.emplace_back(Volume(solid.name(), solid, ns.material(matOut)));
194 
195  // Position the cables
196  constexpr double theta = 90_deg;
197 
198  for (int i = 0; i < (int)(angles.size()); i++) {
199  double phix = angles[i];
200  double phiy = phix + 90_deg;
201 
202  Rotation3D rotation = cms::makeRotation3D(theta, phix, theta, phiy, 0., 0.);
203  LogVerbatim("TIDGeom") << "DDTIDAxialCableAlgo test: Creating a new "
204  << "rotation: " << convertRadToDeg(theta) << ", "
205  << convertRadToDeg(phix) << ", "
206  << convertRadToDeg(theta) << ", "
207  << convertRadToDeg(phiy) << ", 0, 0";
208 
209  for (int k = 0; k < (int)(logs.size()); k++) {
210  Position tran = Position(0., 0., 0.);
211 
212  if (k == ((int)(logs.size()) - 1))
213  tran = Position(0., 0., 0.5 * (zEnd + zBend));
214 
215  mother.placeVolume(logs[k], i + 1, Transform3D(rotation, tran));
216 
217  LogVerbatim("TIDGeom")
218  << "DDTIDAxialCableAlgo test " << logs[k].name() << " number "
219  << i + 1 << " positioned in " << mother.name() << " at " << tran
220  << " with " << rotation;
221  }
222  }
223  return s_executed;
224 }
225 } // namespace
226 
227 // first argument is the type from the xml file
228 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTIDAxialCableAlgo, algorithm)
Geom::Theta< T > theta() const
constexpr NumType convertRadToDeg(NumType radians)
Definition: GeantUnits.h:98
float float float z
dd4hep::Rotation3D makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
static constexpr long s_executed
dd4hep::Volume Volume
int k[5][pyjets_maxn]
Namespace of DDCMS conversion namespace.
#define DECLARE_DDCMS_DETELEMENT(name, func)
Definition: DDPlugins.h:31
HLT enums.
#define constexpr