CMS 3D CMS Logo

DDTIBLayerAlgo.cc
Go to the documentation of this file.
1 #include "DD4hep/DetFactoryHelper.h"
2 #include <DD4hep/DD4hepUnits.h>
6 
7 using namespace std;
8 using namespace dd4hep;
9 using namespace cms;
10 using namespace angle_units::operators;
11 
12 static long algorithm(Detector& /* description */, cms::DDParsingContext& context, xml_h element) {
13  using VecDouble = vector<double>;
14 
15  cms::DDNamespace ns(context, element, true);
16  DDAlgoArguments args(context, element);
17 
18  string mother = args.parentName();
19  string genMat = args.str("GeneralMaterial"); //General material name
20  double detectorTilt = args.dble("DetectorTilt"); //Detector Tilt
21  double layerL = args.dble("LayerL"); //Length of the layer
22 
23  double radiusLo = args.dble("RadiusLo"); //Radius for detector at lower level
24  int stringsLo = args.integer("StringsLo"); //Number of strings ......
25  string detectorLo = args.str("StringDetLoName"); //Detector string name ......
26 
27  double radiusUp = args.dble("RadiusUp"); //Radius for detector at upper level
28  int stringsUp = args.integer("StringsUp"); //Number of strings ......
29  string detectorUp = args.str("StringDetUpName"); //Detector string name ......
30 
31  double cylinderT = args.dble("CylinderThickness"); //Cylinder thickness
32  double cylinderInR = args.dble("CylinderInnerRadius"); //Cylinder inner radius
33  string cylinderMat = args.str("CylinderMaterial"); //Cylinder material
34  double MFRingInR = args.dble("MFRingInnerRadius"); //Inner Manifold Ring Inner Radius
35  double MFRingOutR = args.dble("MFRingOuterRadius"); //Outer Manifold Ring Outer Radius
36  double MFRingT = args.dble("MFRingThickness"); //Manifold Ring Thickness
37  double MFRingDz = args.dble("MFRingDeltaz"); //Manifold Ring Half Lenght
38  string MFIntRingMat = args.str("MFIntRingMaterial"); //Manifold Ring Material
39  string MFExtRingMat = args.str("MFExtRingMaterial"); //Manifold Ring Material
40 
41  double supportT = args.dble("SupportThickness"); //Cylinder barrel CF skin thickness
42 
43  string centMat = args.str("CentRingMaterial"); //Central rings material
44  VecDouble centRing1par = args.vecDble("CentRing1"); //Central rings parameters
45  VecDouble centRing2par = args.vecDble("CentRing2"); //Central rings parameters
46 
47  string fillerMat = args.str("FillerMaterial"); //Filler material
48  double fillerDz = args.dble("FillerDeltaz"); //Filler Half Length
49 
50  string ribMat = args.str("RibMaterial"); //Rib material
51  VecDouble ribW = args.vecDble("RibWidth"); //Rib width
52  VecDouble ribPhi = args.vecDble("RibPhi"); //Rib Phi position
53 
54  VecDouble dohmListFW = args.vecDble("DOHMListFW"); //DOHM/AUX positions in #strings FW
55  VecDouble dohmListBW = args.vecDble("DOHMListBW"); //DOHM/AUX positions in #strings BW
56 
57  double dohmtoMF = args.dble("DOHMtoMFDist"); //DOHM Distance to MF
58  double dohmCarrierPhiOff = args.dble("DOHMCarrierPhiOffset"); //DOHM Carrier Phi offset wrt horizontal
59  string dohmPrimName = args.str("StringDOHMPrimName"); //DOHM Primary Logical Volume name
60  string dohmAuxName = args.str("StringDOHMAuxName"); //DOHM Auxiliary Logical Volume name
61 
62  string dohmCarrierMaterial = args.str("DOHMCarrierMaterial"); //DOHM Carrier Material
63  string dohmCableMaterial = args.str("DOHMCableMaterial"); //DOHM Cable Material
64  double dohmPrimL = args.dble("DOHMPRIMLength"); //DOHM PRIMary Length
65  string dohmPrimMaterial = args.str("DOHMPRIMMaterial"); //DOHM PRIMary Material
66  double dohmAuxL = args.dble("DOHMAUXLength"); //DOHM AUXiliary Length
67  string dohmAuxMaterial = args.str("DOHMAUXMaterial"); //DOHM AUXiliary Material
68 
69  string pillarMaterial = args.str("PillarMaterial"); //Pillar Material
70 
71  double fwIntPillarDz = args.dble("FWIntPillarDz"); //Internal pillar parameters
72  double fwIntPillarDPhi = args.dble("FWIntPillarDPhi");
73  VecDouble fwIntPillarZ = args.vecDble("FWIntPillarZ");
74  VecDouble fwIntPillarPhi = args.vecDble("FWIntPillarPhi");
75  double bwIntPillarDz = args.dble("BWIntPillarDz");
76  double bwIntPillarDPhi = args.dble("BWIntPillarDPhi");
77  VecDouble bwIntPillarZ = args.vecDble("BWIntPillarZ");
78  VecDouble bwIntPillarPhi = args.vecDble("BWIntPillarPhi");
79 
80  double fwExtPillarDz = args.dble("FWExtPillarDz"); //External pillar parameters
81  double fwExtPillarDPhi = args.dble("FWExtPillarDPhi");
82  VecDouble fwExtPillarZ = args.vecDble("FWExtPillarZ");
83  VecDouble fwExtPillarPhi = args.vecDble("FWExtPillarPhi");
84  double bwExtPillarDz = args.dble("BWExtPillarDz");
85  double bwExtPillarDPhi = args.dble("BWExtPillarDPhi");
86  VecDouble bwExtPillarZ = args.vecDble("BWExtPillarZ");
87  VecDouble bwExtPillarPhi = args.vecDble("BWExtPillarPhi");
88 
90 
91  auto LogPosition = [](dd4hep::PlacedVolume pvl) {
92  edm::LogVerbatim("TIBGeom") << "DDTIBLayerAlgo: " << pvl.volume()->GetName()
93  << " positioned: " << pvl.motherVol()->GetName() << " " << pvl.position();
94  };
95 
96  edm::LogVerbatim("TIBGeom") << "Parent " << mother << " NameSpace " << ns.name() << " General Material " << genMat;
97  edm::LogVerbatim("TIBGeom") << "Lower layer Radius " << radiusLo << " Number " << stringsLo << " String "
98  << detectorLo;
99  edm::LogVerbatim("TIBGeom") << "Upper layer Radius " << radiusUp << " Number " << stringsUp << " String "
100  << detectorUp;
101  edm::LogVerbatim("TIBGeom") << "Cylinder Material/thickness " << cylinderMat << " " << cylinderT << " Rib Material "
102  << ribMat << " at " << ribW.size() << " positions with width/phi";
103  for (unsigned int i = 0; i < ribW.size(); i++) {
104  edm::LogVerbatim("TIBGeom") << "\tribW[" << i << "] = " << ribW[i] << "\tribPhi[" << i
105  << "] = " << convertRadToDeg(ribPhi[i]);
106  }
107  edm::LogVerbatim("TIBGeom") << "DOHM Primary "
108  << " Material " << dohmPrimMaterial << " Length " << dohmPrimL;
109  edm::LogVerbatim("TIBGeom") << "DOHM Aux "
110  << " Material " << dohmAuxMaterial << " Length " << dohmAuxL;
111  for (double i : dohmListFW) {
112  if (i > 0.)
113  edm::LogVerbatim("TIBGeom") << "DOHM Primary at FW Position " << i;
114  if (i < 0.)
115  edm::LogVerbatim("TIBGeom") << "DOHM Aux at FW Position " << -i;
116  }
117  for (double i : dohmListBW) {
118  if (i > 0.)
119  edm::LogVerbatim("TIBGeom") << "DOHM Primary at BW Position " << i;
120  if (i < 0.)
121  edm::LogVerbatim("TIBGeom") << "DOHM Aux at BW Position " << -i;
122  }
123  edm::LogVerbatim("TIBGeom") << "FW Internal Pillar [Dz, DPhi] " << fwIntPillarDz << ", " << fwIntPillarDPhi;
124  for (unsigned int i = 0; i < fwIntPillarZ.size(); i++) {
125  if (fwIntPillarPhi[i] > 0.) {
126  edm::LogVerbatim("TIBGeom") << " at positions [z, phi] " << fwIntPillarZ[i] << " " << fwIntPillarPhi[i];
127  }
128  }
129  edm::LogVerbatim("TIBGeom") << "BW Internal Pillar [Dz, DPhi] " << bwIntPillarDz << ", " << bwIntPillarDPhi;
130  for (unsigned int i = 0; i < bwIntPillarZ.size(); i++) {
131  if (bwIntPillarPhi[i] > 0.) {
132  edm::LogVerbatim("TIBGeom") << " at positions [z, phi] " << bwIntPillarZ[i] << " " << bwIntPillarPhi[i];
133  }
134  }
135  edm::LogVerbatim("TIBGeom") << "FW External Pillar [Dz, DPhi] " << fwExtPillarDz << ", " << fwExtPillarDPhi;
136  for (unsigned int i = 0; i < fwExtPillarZ.size(); i++) {
137  if (fwExtPillarPhi[i] > 0.) {
138  edm::LogVerbatim("TIBGeom") << " at positions [z, phi] " << fwExtPillarZ[i] << " " << fwExtPillarPhi[i];
139  }
140  }
141  edm::LogVerbatim("TIBGeom") << "BW External Pillar [Dz, DPhi] " << bwExtPillarDz << ", " << bwExtPillarDPhi;
142  for (unsigned int i = 0; i < bwExtPillarZ.size(); i++) {
143  if (bwExtPillarPhi[i] > 0.) {
144  edm::LogVerbatim("TIBGeom") << " at positions [z, phi] " << bwExtPillarZ[i] << " " << bwExtPillarPhi[i];
145  }
146  }
147 
148  const string& idName = mother;
149  double rmin = MFRingInR;
150  double rmax = MFRingOutR;
151  Solid solid = ns.addSolidNS(ns.prepend(idName), Tube(rmin, rmax, 0.5 * layerL));
152  edm::LogVerbatim("TIBGeom") << solid.name() << " Tubs made of " << genMat << " from 0 to " << convertRadToDeg(2_pi)
153  << " with Rin " << rmin << " Rout " << rmax << " ZHalf " << 0.5 * layerL;
154  Volume layer = ns.addVolumeNS(Volume(ns.prepend(idName), solid, ns.material(genMat)));
155 
156  //Internal layer first
157  double rin = rmin + MFRingT;
158  // double rout = 0.5*(radiusLo+radiusUp-cylinderT);
159  double rout = cylinderInR;
160  string name = idName + "Down";
161  solid = ns.addSolidNS(ns.prepend(name), Tube(rin, rout, 0.5 * layerL));
162  edm::LogVerbatim("TIBGeom") << solid.name() << " Tubs made of " << genMat << " from 0 to " << convertRadToDeg(2_pi)
163  << " with Rin " << rin << " Rout " << rout << " ZHalf " << 0.5 * layerL;
164  Volume layerIn = ns.addVolumeNS(Volume(ns.prepend(name), solid, ns.material(genMat)));
165  pv = layer.placeVolume(layerIn, 1);
166  LogPosition(pv);
167 
168  double rposdet = radiusLo;
169  double dphi = 2_pi / stringsLo;
170  Volume detIn = ns.volume(detectorLo);
171  for (int n = 0; n < stringsLo; n++) {
172  double phi = (n + 0.5) * dphi;
173  double phix = phi - detectorTilt + 90_deg;
174  double theta = 90_deg;
175  double phiy = phix + 90._deg;
176  Rotation3D rotation = makeRotation3D(theta, phix, theta, phiy, 0., 0.);
177  Position trdet(rposdet * cos(phi), rposdet * sin(phi), 0);
178  pv = layerIn.placeVolume(detIn, n + 1, Transform3D(rotation, trdet));
179  LogPosition(pv);
180  }
181  //Now the external layer
182  rin = cylinderInR + cylinderT;
183  rout = rmax - MFRingT;
184  name = idName + "Up";
185  solid = ns.addSolidNS(ns.prepend(name), Tube(rin, rout, 0.5 * layerL));
186  edm::LogVerbatim("TIBGeom") << solid.name() << " Tubs made of " << genMat << " from 0 to " << convertRadToDeg(2_pi)
187  << " with Rin " << rin << " Rout " << rout << " ZHalf " << 0.5 * layerL;
188  Volume layerOut = ns.addVolumeNS(Volume(ns.prepend(name), solid, ns.material(genMat)));
189  pv = layer.placeVolume(layerOut, 1);
190  LogPosition(pv);
191 
192  rposdet = radiusUp;
193  dphi = 2_pi / stringsUp;
194  Volume detOut = ns.volume(detectorUp);
195  for (int n = 0; n < stringsUp; n++) {
196  double phi = (n + 0.5) * dphi;
197  double phix = phi - detectorTilt - 90_deg;
198  double theta = 90_deg;
199  double phiy = phix + 90._deg;
200  Rotation3D rotation = makeRotation3D(theta, phix, theta, phiy, 0., 0.);
201  Position trdet(rposdet * cos(phi), rposdet * sin(phi), 0);
202  pv = layerOut.placeVolume(detOut, n + 1, Transform3D(rotation, trdet));
203  LogPosition(pv);
204  }
205 
206  //
207  // Inner cylinder, support wall and ribs
208  //
209  // External skins
210  rin = cylinderInR;
211  rout = cylinderInR + cylinderT;
212  name = idName + "Cylinder";
213  solid = ns.addSolidNS(ns.prepend(name), Tube(rin, rout, 0.5 * layerL));
214  edm::LogVerbatim("TIBGeom") << solid.name() << " Tubs made of " << cylinderMat << " from 0 to "
215  << convertRadToDeg(2_pi) << " with Rin " << rin << " Rout " << rout << " ZHalf "
216  << 0.5 * layerL;
217  Volume cylinder = ns.addVolumeNS(Volume(ns.prepend(name), solid, ns.material(cylinderMat)));
218  pv = layer.placeVolume(cylinder, 1);
219  LogPosition(pv);
220 
221  //
222  // inner part of the cylinder
223  //
224  rin += supportT;
225  rout -= supportT;
226  name = idName + "CylinderIn";
227  solid = ns.addSolidNS(ns.prepend(name), Tube(rin, rout, 0.5 * layerL));
228  edm::LogVerbatim("TIBGeom") << solid.name() << " Tubs made of " << genMat << " from 0 to " << convertRadToDeg(2_pi)
229  << " with Rin " << rin << " Rout " << rout << " ZHalf " << 0.5 * layerL;
230  Volume cylinderIn = ns.addVolumeNS(Volume(ns.prepend(name), solid, ns.material(genMat)));
231  pv = cylinder.placeVolume(cylinderIn, 1);
232  LogPosition(pv);
233 
234  //
235  // Filler Rings
236  //
237  name = idName + "Filler";
238  solid = ns.addSolidNS(ns.prepend(name), Tube(rin, rout, fillerDz));
239  edm::LogVerbatim("TIBGeom") << solid.name() << " Tubs made of " << fillerMat << " from " << 0. << " to "
240  << convertRadToDeg(2_pi) << " with Rin " << rin << " Rout " << rout << " ZHalf "
241  << fillerDz;
242  Volume cylinderFiller = ns.addVolumeNS(Volume(ns.prepend(name), solid, ns.material(fillerMat)));
243  pv = cylinderIn.placeVolume(cylinderFiller, 1, Position(0.0, 0.0, 0.5 * layerL - fillerDz));
244  LogPosition(pv);
245 
246  pv = cylinderIn.placeVolume(cylinderFiller, 2, Position(0.0, 0.0, -0.5 * layerL + fillerDz));
247  LogPosition(pv);
248 
249  //
250  // Ribs
251  //
252  Material matrib = ns.material(ribMat);
253  for (size_t i = 0; i < ribW.size(); i++) {
254  name = idName + "Rib" + std::to_string(i);
255  double width = 2. * ribW[i] / (rin + rout);
256  double dz = 0.5 * layerL - 2. * fillerDz;
257  double _rmi = std::min(rin + 0.5 * dd4hep::mm, rout - 0.5 * dd4hep::mm);
258  double _rma = std::max(rin + 0.5 * dd4hep::mm, rout - 0.5 * dd4hep::mm);
259  solid = ns.addSolidNS(ns.prepend(name), Tube(_rmi, _rma, dz, -0.5 * width, 0.5 * width));
260  edm::LogVerbatim("TIBGeom") << solid.name() << " Tubs made of " << ribMat << " from "
261  << -0.5 * convertRadToDeg(width) << " to " << 0.5 * convertRadToDeg(width)
262  << " with Rin " << rin + 0.5 * dd4hep::mm << " Rout " << rout - 0.5 * dd4hep::mm
263  << " ZHalf " << dz;
264  Volume cylinderRib = ns.addVolumeNS(Volume(ns.prepend(name), solid, matrib));
265  double phix = ribPhi[i];
266  double theta = 90_deg;
267  double phiy = phix + 90._deg;
268  Rotation3D rotation = makeRotation3D(theta, phix, theta, phiy, 0., 0.);
269  Position tran(0, 0, 0);
270  pv = cylinderIn.placeVolume(cylinderRib, 1, Transform3D(rotation, tran));
271  LogPosition(pv);
272  }
273 
274  //
275  //Manifold rings
276  //
277  // Inner ones first
278  rin = MFRingInR;
279  rout = rin + MFRingT;
280  name = idName + "InnerMFRing";
281  solid = ns.addSolidNS(ns.prepend(name), Tube(rin, rout, MFRingDz));
282  edm::LogVerbatim("TIBGeom") << solid.name() << " Tubs made of " << MFIntRingMat << " from 0 to "
283  << convertRadToDeg(2_pi) << " with Rin " << rin << " Rout " << rout << " ZHalf "
284  << MFRingDz;
285 
286  Volume inmfr = ns.addVolumeNS(Volume(ns.prepend(name), solid, ns.material(MFIntRingMat)));
287 
288  pv = layer.placeVolume(inmfr, 1, Position(0.0, 0.0, -0.5 * layerL + MFRingDz));
289  LogPosition(pv);
290 
291  pv = layer.placeVolume(inmfr, 2, Position(0.0, 0.0, +0.5 * layerL - MFRingDz));
292  LogPosition(pv);
293 
294  // Outer ones
295  rout = MFRingOutR;
296  rin = rout - MFRingT;
297  name = idName + "OuterMFRing";
298  solid = ns.addSolidNS(ns.prepend(name), Tube(rin, rout, MFRingDz));
299  edm::LogVerbatim("TIBGeom") << solid.name() << " Tubs made of " << MFExtRingMat << " from 0 to "
300  << convertRadToDeg(2_pi) << " with Rin " << rin << " Rout " << rout << " ZHalf "
301  << MFRingDz;
302 
303  Volume outmfr = ns.addVolumeNS(Volume(ns.prepend(name), solid, ns.material(MFExtRingMat)));
304  pv = layer.placeVolume(outmfr, 1, Position(0.0, 0.0, -0.5 * layerL + MFRingDz));
305  LogPosition(pv);
306  pv = layer.placeVolume(outmfr, 2, Position(0.0, 0.0, +0.5 * layerL - MFRingDz));
307  LogPosition(pv);
308 
309  //
310  //Central Support rings
311  //
312  // Ring 1
313  double centZ = centRing1par[0];
314  double centDz = 0.5 * centRing1par[1];
315  rin = centRing1par[2];
316  rout = centRing1par[3];
317  name = idName + "CentRing1";
318  solid = ns.addSolidNS(ns.prepend(name), Tube(rin, rout, centDz));
319 
320  edm::LogVerbatim("TIBGeom") << solid.name() << " Tubs made of " << centMat << " from 0 to " << convertRadToDeg(2_pi)
321  << " with Rin " << rin << " Rout " << rout << " ZHalf " << centDz;
322 
323  Volume cent1 = ns.addVolumeNS(Volume(ns.prepend(name), solid, ns.material(centMat)));
324  pv = layer.placeVolume(cent1, 1, Position(0.0, 0.0, centZ));
325  LogPosition(pv);
326  // Ring 2
327  centZ = centRing2par[0];
328  centDz = 0.5 * centRing2par[1];
329  rin = centRing2par[2];
330  rout = centRing2par[3];
331  name = idName + "CentRing2";
332  solid = ns.addSolidNS(ns.prepend(name), Tube(rin, rout, centDz));
333  edm::LogVerbatim("TIBGeom") << solid.name() << " Tubs made of " << centMat << " from 0 to " << convertRadToDeg(2_pi)
334  << " with Rin " << rin << " Rout " << rout << " ZHalf " << centDz;
335 
336  Volume cent2 = ns.addVolumeNS(Volume(ns.prepend(name), solid, ns.material(centMat)));
337  pv = layer.placeVolume(cent2, 1, Position(0e0, 0e0, centZ));
338  LogPosition(pv);
339 
340  //
342  //
343  // Preparing DOHM Carrier solid
344  //
345  name = idName + "DOHMCarrier";
346  double dohmCarrierRin = MFRingOutR - MFRingT;
347  double dohmCarrierRout = MFRingOutR;
348  double dohmCarrierDz = 0.5 * (dohmPrimL + dohmtoMF);
349  double dohmCarrierZ = 0.5 * layerL - 2. * MFRingDz - dohmCarrierDz;
350 
351  solid = ns.addSolidNS(
352  ns.prepend(name),
353  Tube(dohmCarrierRin, dohmCarrierRout, dohmCarrierDz, dohmCarrierPhiOff, 180._deg - dohmCarrierPhiOff));
354  edm::LogVerbatim("TIBGeom") << solid.name() << " Tubs made of " << dohmCarrierMaterial << " from "
355  << dohmCarrierPhiOff << " to " << 180._deg - dohmCarrierPhiOff << " with Rin "
356  << dohmCarrierRin << " Rout " << MFRingOutR << " ZHalf " << dohmCarrierDz;
357 
358  // Define FW and BW carrier logical volume and
359  // place DOHM Primary and auxiliary modules inside it
360  dphi = 2_pi / stringsUp;
361 
362  Rotation3D dohmRotation;
363  double dohmR = 0.5 * (dohmCarrierRin + dohmCarrierRout);
364 
365  for (int j = 0; j < 4; j++) {
366  vector<double> dohmList;
367  Position tran;
368  string rotstr;
369  Rotation3D rotation;
370  int dohmCarrierReplica = 0;
371  int placeDohm = 0;
372 
373  Volume dohmCarrier;
374 
375  switch (j) {
376  case 0:
377  name = idName + "DOHMCarrierFW";
378  dohmCarrier = ns.addVolumeNS(Volume(ns.prepend(name), solid, ns.material(dohmCarrierMaterial)));
379  dohmList = dohmListFW;
380  tran = Position(0., 0., dohmCarrierZ);
381  rotstr = idName + "FwUp";
382  rotation = Rotation3D();
383  dohmCarrierReplica = 1;
384  placeDohm = 1;
385  break;
386  case 1:
387  name = idName + "DOHMCarrierFW";
388  dohmCarrier = ns.volume(name); // Re-use internally stored DOHMCarrierFW Volume
389  dohmList = dohmListFW;
390  tran = Position(0., 0., dohmCarrierZ);
391  rotstr = idName + "FwDown";
392  rotation = makeRotation3D(90._deg, 180._deg, 90._deg, 270._deg, 0., 0.);
393  dohmCarrierReplica = 2;
394  placeDohm = 0;
395  break;
396  case 2:
397  name = idName + "DOHMCarrierBW";
398  dohmCarrier = ns.addVolumeNS(Volume(ns.prepend(name), solid, ns.material(dohmCarrierMaterial)));
399  dohmList = dohmListBW;
400  tran = Position(0., 0., -dohmCarrierZ);
401  rotstr = idName + "BwUp";
402  rotation = makeRotation3D(90._deg, 180._deg, 90._deg, 90._deg, 180._deg, 0.);
403  dohmCarrierReplica = 1;
404  placeDohm = 1;
405  break;
406  case 3:
407  name = idName + "DOHMCarrierBW";
408  dohmCarrier = ns.volume(name); // Re-use internally stored DOHMCarrierBW Volume
409  dohmList = dohmListBW;
410  tran = Position(0., 0., -dohmCarrierZ);
411  rotstr = idName + "BwDown";
412  rotation = makeRotation3D(90._deg, 0., 90._deg, 270._deg, 180._deg, 0.);
413  dohmCarrierReplica = 2;
414  placeDohm = 0;
415  break;
416  }
417 
418  int primReplica = 0;
419  int auxReplica = 0;
420 
421  for (size_t i = 0; i < placeDohm * dohmList.size(); i++) {
422  double phi = (std::abs(dohmList[i]) + 0.5 - 1.) * dphi;
423  double phix = phi + 90_deg;
424  double phideg = convertRadToDeg(phix);
425  if (phideg != 0) {
426  double theta = 90_deg;
427  double phiy = phix + 90._deg;
428  dohmRotation = makeRotation3D(theta, phix, theta, phiy, 0., 0.);
429  }
430  int dohmReplica = 0;
431  double dohmZ = 0.;
432  Volume dohm;
433 
434  if (dohmList[i] < 0.) {
435  // Place a Auxiliary DOHM
436  dohm = ns.volume(dohmAuxName);
437  dohmZ = dohmCarrierDz - 0.5 * dohmAuxL - dohmtoMF;
438  primReplica++;
439  dohmReplica = primReplica;
440  } else {
441  // Place a Primary DOHM
442  dohm = ns.volume(dohmPrimName);
443  dohmZ = dohmCarrierDz - 0.5 * dohmPrimL - dohmtoMF;
444  auxReplica++;
445  dohmReplica = auxReplica;
446  }
447  Position dohmTrasl(dohmR * cos(phi), dohmR * sin(phi), dohmZ);
448  pv = dohmCarrier.placeVolume(dohm, dohmReplica, Transform3D(dohmRotation, dohmTrasl));
449  LogPosition(pv);
450  }
451 
452  pv = layer.placeVolume(dohmCarrier, dohmCarrierReplica, Transform3D(rotation, tran));
453  LogPosition(pv);
454  }
455  //
457  for (int j = 0; j < 4; j++) {
458  vector<double> pillarZ;
459  vector<double> pillarPhi;
460  double pillarDz = 0, pillarDPhi = 0, pillarRin = 0, pillarRout = 0;
461 
462  switch (j) {
463  case 0:
464  name = idName + "FWIntPillar";
465  pillarZ = fwIntPillarZ;
466  pillarPhi = fwIntPillarPhi;
467  pillarRin = MFRingInR;
468  pillarRout = MFRingInR + MFRingT;
469  pillarDz = fwIntPillarDz;
470  pillarDPhi = fwIntPillarDPhi;
471  break;
472  case 1:
473  name = idName + "BWIntPillar";
474  pillarZ = bwIntPillarZ;
475  pillarPhi = bwIntPillarPhi;
476  pillarRin = MFRingInR;
477  pillarRout = MFRingInR + MFRingT;
478  pillarDz = bwIntPillarDz;
479  pillarDPhi = bwIntPillarDPhi;
480  break;
481  case 2:
482  name = idName + "FWExtPillar";
483  pillarZ = fwExtPillarZ;
484  pillarPhi = fwExtPillarPhi;
485  pillarRin = MFRingOutR - MFRingT;
486  pillarRout = MFRingOutR;
487  pillarDz = fwExtPillarDz;
488  pillarDPhi = fwExtPillarDPhi;
489  break;
490  case 3:
491  name = idName + "BWExtPillar";
492  pillarZ = bwExtPillarZ;
493  pillarPhi = bwExtPillarPhi;
494  pillarRin = MFRingOutR - MFRingT;
495  pillarRout = MFRingOutR;
496  pillarDz = bwExtPillarDz;
497  pillarDPhi = bwExtPillarDPhi;
498  break;
499  }
500 
501  solid = ns.addSolidNS(ns.prepend(name), Tube(pillarRin, pillarRout, pillarDz, -pillarDPhi, pillarDPhi));
502  Volume Pillar = ns.addVolumeNS(Volume(ns.prepend(name), solid, ns.material(pillarMaterial)));
503  edm::LogVerbatim("TIBGeom") << solid.name() << " Tubs made of " << pillarMaterial << " from " << -pillarDPhi
504  << " to " << pillarDPhi << " with Rin " << pillarRin << " Rout " << pillarRout
505  << " ZHalf " << pillarDz;
506  Position pillarTran;
507  Rotation3D pillarRota;
508  for (unsigned int i = 0; i < pillarZ.size(); i++) {
509  if (pillarPhi[i] > 0.) {
510  pillarTran = Position(0., 0., pillarZ[i]);
511  pillarRota = makeRotation3D(90._deg, pillarPhi[i], 90._deg, 90._deg + pillarPhi[i], 0., 0.);
512  pv = layer.placeVolume(Pillar, i, Transform3D(pillarRota, pillarTran));
513  LogPosition(pv);
514  }
515  }
516  }
517  return 1;
518 }
519 
520 // first argument is the type from the xml file
521 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTIBLayerAlgo, algorithm)
static long algorithm(Detector &, cms::DDParsingContext &context, xml_h element)
Log< level::Info, true > LogVerbatim
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
dd4hep::Material material(const std::string &name) const
Definition: DDNamespace.cc:166
DDRotationMatrix makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
static std::string to_string(const XMLCh *ch)
#define DECLARE_DDCMS_DETELEMENT(name, func)
Definition: DDPlugins.h:25
dd4hep::PlacedVolume PlacedVolume
std::string_view name() const
Definition: DDNamespace.h:79
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
def pv(vc)
Definition: MetAnalyzer.py:7
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
dd4hep::Volume Volume
Namespace of DDCMS conversion namespace.
dd4hep::Volume addVolumeNS(dd4hep::Volume vol) const
Definition: DDNamespace.cc:202
vector< double > VecDouble
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition: DDNamespace.cc:276
dd4hep::Solid addSolidNS(const std::string &name, dd4hep::Solid solid) const
Definition: DDNamespace.cc:292
std::string prepend(const std::string &) const
Definition: DDNamespace.cc:99