CMS 3D CMS Logo

DDTIBLayerAlgo.cc
Go to the documentation of this file.
1 // File: DDTIBLayerAlgo.cc
3 // Description: Makes a TIB layer and position the strings with a tilt angle
5 
15 #include "CLHEP/Units/GlobalPhysicalConstants.h"
16 #include "CLHEP/Units/GlobalSystemOfUnits.h"
17 
18 #include <cmath>
19 #include <algorithm>
20 #include <map>
21 #include <string>
22 #include <vector>
23 
24 using namespace std;
25 
26 class DDTIBLayerAlgo : public DDAlgorithm {
27 public:
28  //Constructor and Destructor
30  ~DDTIBLayerAlgo() override;
31 
32  void initialize(const DDNumericArguments& nArgs,
33  const DDVectorArguments& vArgs,
34  const DDMapArguments& mArgs,
35  const DDStringArguments& sArgs,
36  const DDStringVectorArguments& vsArgs) override;
37 
38  void execute(DDCompactView& cpv) override;
39 
40 private:
41  string idNameSpace; //Namespace of this and ALL parts
42  string genMat; //General material name
43  double detectorTilt; //Detector Tilt
44  double layerL; //Length of the layer
45 
46  double radiusLo; //Radius for detector at lower level
47  double phioffLo; //Phi offset ......
48  int stringsLo; //Number of strings ......
49  string detectorLo; //Detector string name ......
50 
51  double radiusUp; //Radius for detector at upper level
52  double phioffUp; //Phi offset ......
53  int stringsUp; //Number of strings ......
54  string detectorUp; //Detector string name ......
55 
56  double cylinderT; //Cylinder thickness
57  double cylinderInR; //Cylinder inner radius
58  string cylinderMat; //Cylinder material
59  double MFRingInR; //Inner Manifold Ring Inner Radius
60  double MFRingOutR; //Outer Manifold Ring Outer Radius
61  double MFRingT; //Manifold Ring Thickness
62  double MFRingDz; //Manifold Ring Half Lenght
63  string MFIntRingMat; //Manifold Ring Material
64  string MFExtRingMat; //Manifold Ring Material
65 
66  double supportT; //Cylinder barrel CF skin thickness
67 
68  string centMat; //Central rings material
69  vector<double> centRing1par; //Central rings parameters
70  vector<double> centRing2par; //Central rings parameters
71 
72  string fillerMat; //Filler material
73  double fillerDz; //Filler Half Length
74 
75  string ribMat; //Rib material
76  vector<double> ribW; //Rib width
77  vector<double> ribPhi; //Rib Phi position
78 
79  vector<double> dohmListFW; //DOHM/AUX positions in #strings FW
80  vector<double> dohmListBW; //DOHM/AUX positions in #strings BW
81 
82  double dohmtoMF; //DOHM Distance to MF
83  double dohmCarrierPhiOff; //DOHM Carrier Phi offset wrt horizontal
84  string dohmPrimName; //DOHM Primary Logical Volume name
85  string dohmAuxName; //DOHM Auxiliary Logical Volume name
86 
87  string dohmCarrierMaterial; //DOHM Carrier Material
88  string dohmCableMaterial; //DOHM Cable Material
89  double dohmPrimL; //DOHM PRIMary Length
90  string dohmPrimMaterial; //DOHM PRIMary Material
91  double dohmAuxL; //DOHM AUXiliary Length
92  string dohmAuxMaterial; //DOHM AUXiliary Material
93 
94  string pillarMaterial; //Pillar Material
95 
96  double fwIntPillarDz; //Internal pillar parameters
98  vector<double> fwIntPillarZ;
99  vector<double> fwIntPillarPhi;
102  vector<double> bwIntPillarZ;
103  vector<double> bwIntPillarPhi;
104 
105  double fwExtPillarDz; //External pillar parameters
107  vector<double> fwExtPillarZ;
108  vector<double> fwExtPillarPhi;
111  vector<double> bwExtPillarZ;
112  vector<double> bwExtPillarPhi;
113 };
114 
115 DDTIBLayerAlgo::DDTIBLayerAlgo() : ribW(0), ribPhi(0) {
116  LogDebug("TIBGeom") << "DDTIBLayerAlgo info: Creating an instance";
117 }
118 
120 
122  const DDVectorArguments& vArgs,
123  const DDMapArguments&,
124  const DDStringArguments& sArgs,
125  const DDStringVectorArguments&) {
127  genMat = sArgs["GeneralMaterial"];
128  DDName parentName = parent().name();
129  LogDebug("TIBGeom") << "DDTIBLayerAlgo debug: Parent " << parentName << " NameSpace " << idNameSpace
130  << " General Material " << genMat;
131 
132  detectorTilt = nArgs["DetectorTilt"];
133  layerL = nArgs["LayerL"];
134 
135  radiusLo = nArgs["RadiusLo"];
136  stringsLo = int(nArgs["StringsLo"]);
137  detectorLo = sArgs["StringDetLoName"];
138  LogDebug("TIBGeom") << "DDTIBLayerAlgo debug: Lower layer Radius " << radiusLo << " Number " << stringsLo
139  << " String " << detectorLo;
140 
141  radiusUp = nArgs["RadiusUp"];
142  stringsUp = int(nArgs["StringsUp"]);
143  detectorUp = sArgs["StringDetUpName"];
144  LogDebug("TIBGeom") << "DDTIBLayerAlgo debug: Upper layer Radius " << radiusUp << " Number " << stringsUp
145  << " String " << detectorUp;
146 
147  cylinderT = nArgs["CylinderThickness"];
148  cylinderInR = nArgs["CylinderInnerRadius"];
149  cylinderMat = sArgs["CylinderMaterial"];
150  MFRingInR = nArgs["MFRingInnerRadius"];
151  MFRingOutR = nArgs["MFRingOuterRadius"];
152  MFRingT = nArgs["MFRingThickness"];
153  MFRingDz = nArgs["MFRingDeltaz"];
154  MFIntRingMat = sArgs["MFIntRingMaterial"];
155  MFExtRingMat = sArgs["MFExtRingMaterial"];
156 
157  supportT = nArgs["SupportThickness"];
158 
159  centMat = sArgs["CentRingMaterial"];
160  centRing1par = vArgs["CentRing1"];
161  centRing2par = vArgs["CentRing2"];
162 
163  fillerMat = sArgs["FillerMaterial"];
164  fillerDz = nArgs["FillerDeltaz"];
165 
166  ribMat = sArgs["RibMaterial"];
167  ribW = vArgs["RibWidth"];
168  ribPhi = vArgs["RibPhi"];
169  LogDebug("TIBGeom") << "DDTIBLayerAlgo debug: Cylinder Material/"
170  << "thickness " << cylinderMat << " " << cylinderT << " Rib Material " << ribMat << " at "
171  << ribW.size() << " positions with width/phi";
172 
173  for (unsigned int i = 0; i < ribW.size(); i++)
174  LogDebug("TIBGeom") << "\tribW[" << i << "] = " << ribW[i] << "\tribPhi[" << i << "] = " << ribPhi[i] / CLHEP::deg;
175 
176  dohmCarrierPhiOff = nArgs["DOHMCarrierPhiOffset"];
177 
178  dohmtoMF = nArgs["DOHMtoMFDist"];
179 
180  dohmPrimName = sArgs["StringDOHMPrimName"];
181  dohmAuxName = sArgs["StringDOHMAuxName"];
182 
183  dohmCarrierMaterial = sArgs["DOHMCarrierMaterial"];
184  dohmCableMaterial = sArgs["DOHMCableMaterial"];
185  dohmPrimL = nArgs["DOHMPRIMLength"];
186  dohmPrimMaterial = sArgs["DOHMPRIMMaterial"];
187  dohmAuxL = nArgs["DOHMAUXLength"];
188  dohmAuxMaterial = sArgs["DOHMAUXMaterial"];
189  dohmListFW = vArgs["DOHMListFW"];
190  dohmListBW = vArgs["DOHMListBW"];
191  LogDebug("TIBGeom") << "DDTIBLayerAlgo debug: DOHM Primary "
192  << " Material " << dohmPrimMaterial << " Length " << dohmPrimL;
193  LogDebug("TIBGeom") << "DDTIBLayerAlgo debug: DOHM Aux "
194  << " Material " << dohmAuxMaterial << " Length " << dohmAuxL;
195  for (double i : dohmListFW) {
196  if (i > 0.)
197  LogDebug("TIBGeom") << "DOHM Primary at FW Position " << i;
198  if (i < 0.)
199  LogDebug("TIBGeom") << "DOHM Aux at FW Position " << -i;
200  }
201  for (double i : dohmListBW) {
202  if (i > 0.)
203  LogDebug("TIBGeom") << "DOHM Primary at BW Position " << i;
204  if (i < 0.)
205  LogDebug("TIBGeom") << "DOHM Aux at BW Position " << -i;
206  }
207 
208  //Pillar Material
209  pillarMaterial = sArgs["PillarMaterial"];
210 
211  // Internal Pillar Parameters
212  fwIntPillarDz = nArgs["FWIntPillarDz"];
213  fwIntPillarDPhi = nArgs["FWIntPillarDPhi"];
214  fwIntPillarZ = vArgs["FWIntPillarZ"];
215  fwIntPillarPhi = vArgs["FWIntPillarPhi"];
216  bwIntPillarDz = nArgs["BWIntPillarDz"];
217  bwIntPillarDPhi = nArgs["BWIntPillarDPhi"];
218  bwIntPillarZ = vArgs["BWIntPillarZ"];
219  bwIntPillarPhi = vArgs["BWIntPillarPhi"];
220  LogDebug("TIBGeom") << "FW Internal Pillar [Dz, DPhi] " << fwIntPillarDz << ", " << fwIntPillarDPhi;
221  for (unsigned int i = 0; i < fwIntPillarZ.size(); i++) {
222  if (fwIntPillarPhi[i] > 0.) {
223  LogDebug("TIBGeom") << " at positions [z, phi] " << fwIntPillarZ[i] << " " << fwIntPillarPhi[i];
224  }
225  }
226  LogDebug("TIBGeom") << "BW Internal Pillar [Dz, DPhi] " << bwIntPillarDz << ", " << bwIntPillarDPhi;
227  for (unsigned int i = 0; i < bwIntPillarZ.size(); i++) {
228  if (bwIntPillarPhi[i] > 0.) {
229  LogDebug("TIBGeom") << " at positions [z, phi] " << bwIntPillarZ[i] << " " << bwIntPillarPhi[i];
230  }
231  }
232 
233  // External Pillar Parameters
234  fwExtPillarDz = nArgs["FWExtPillarDz"];
235  fwExtPillarDPhi = nArgs["FWExtPillarDPhi"];
236  fwExtPillarZ = vArgs["FWExtPillarZ"];
237  fwExtPillarPhi = vArgs["FWExtPillarPhi"];
238  bwExtPillarDz = nArgs["BWExtPillarDz"];
239  bwExtPillarDPhi = nArgs["BWExtPillarDPhi"];
240  bwExtPillarZ = vArgs["BWExtPillarZ"];
241  bwExtPillarPhi = vArgs["BWExtPillarPhi"];
242  LogDebug("TIBGeom") << "FW External Pillar [Dz, DPhi] " << fwExtPillarDz << ", " << fwExtPillarDPhi;
243  for (unsigned int i = 0; i < fwExtPillarZ.size(); i++) {
244  if (fwExtPillarPhi[i] > 0.) {
245  LogDebug("TIBGeom") << " at positions [z, phi] " << fwExtPillarZ[i] << " " << fwExtPillarPhi[i];
246  }
247  }
248  LogDebug("TIBGeom") << "BW External Pillar [Dz, DPhi] " << bwExtPillarDz << ", " << bwExtPillarDPhi;
249  for (unsigned int i = 0; i < bwExtPillarZ.size(); i++) {
250  if (bwExtPillarPhi[i] > 0.) {
251  LogDebug("TIBGeom") << " at positions [z, phi] " << bwExtPillarZ[i] << " " << bwExtPillarPhi[i];
252  }
253  }
254 }
255 
257  LogDebug("TIBGeom") << "==>> Constructing DDTIBLayerAlgo...";
258 
259  DDName parentName = parent().name();
260  const string& idName = parentName.name();
261 
262  double rmin = MFRingInR;
263  double rmax = MFRingOutR;
264 
265  DDSolid solid = DDSolidFactory::tubs(DDName(idName, idNameSpace), 0.5 * layerL, rmin, rmax, 0, CLHEP::twopi);
266 
267  LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << DDName(idName, idNameSpace) << " Tubs made of " << genMat
268  << " from 0 to " << CLHEP::twopi / CLHEP::deg << " with Rin " << rmin << " Rout " << rmax
269  << " ZHalf " << 0.5 * layerL;
270 
272  DDMaterial matter(matname);
273  DDLogicalPart layer(solid.ddname(), matter, solid);
274 
275  //Internal layer first
276  double rin = rmin + MFRingT;
277  // double rout = 0.5*(radiusLo+radiusUp-cylinderT);
278  double rout = cylinderInR;
279  string name = idName + "Down";
280  solid = DDSolidFactory::tubs(DDName(name, idNameSpace), 0.5 * layerL, rin, rout, 0, CLHEP::twopi);
281  LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << DDName(name, idNameSpace) << " Tubs made of " << genMat
282  << " from 0 to " << CLHEP::twopi / CLHEP::deg << " with Rin " << rin << " Rout " << rout
283  << " ZHalf " << 0.5 * layerL;
284  DDLogicalPart layerIn(solid.ddname(), matter, solid);
285  cpv.position(layerIn, layer, 1, DDTranslation(0.0, 0.0, 0.0), DDRotation());
286  LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << layerIn.name() << " number 1 positioned in " << layer.name()
287  << " at (0,0,0) with no rotation";
288 
289  double rposdet = radiusLo;
290  double dphi = CLHEP::twopi / stringsLo;
292  for (int n = 0; n < stringsLo; n++) {
293  double phi = (n + 0.5) * dphi;
294  double phix = phi - detectorTilt + 90 * CLHEP::deg;
295  double phideg = phix / CLHEP::deg;
297  if (phideg != 0) {
298  double theta = 90 * CLHEP::deg;
299  double phiy = phix + 90. * CLHEP::deg;
300  string rotstr = idName + to_string(phideg * 10.);
302  if (!rotation) {
303  LogDebug("TIBGeom") << "DDTIBLayerAlgo test: Creating a new "
304  << "rotation: " << rotstr << "\t90., " << phix / CLHEP::deg << ", 90.," << phiy / CLHEP::deg
305  << ", 0, 0";
306  rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta, phiy, 0., 0.);
307  }
308  }
309  DDTranslation trdet(rposdet * cos(phi), rposdet * sin(phi), 0);
310  cpv.position(detIn, layerIn, n + 1, trdet, rotation);
311  LogDebug("TIBGeom") << "DDTIBLayerAlgo test " << detIn.name() << " number " << n + 1 << " positioned in "
312  << layerIn.name() << " at " << trdet << " with " << rotation;
313  }
314 
315  //Now the external layer
316  rin = cylinderInR + cylinderT;
317  rout = rmax - MFRingT;
318  name = idName + "Up";
319  solid = DDSolidFactory::tubs(DDName(name, idNameSpace), 0.5 * layerL, rin, rout, 0, CLHEP::twopi);
320  LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << DDName(name, idNameSpace) << " Tubs made of " << genMat
321  << " from 0 to " << CLHEP::twopi / CLHEP::deg << " with Rin " << rin << " Rout " << rout
322  << " ZHalf " << 0.5 * layerL;
323  DDLogicalPart layerOut(solid.ddname(), matter, solid);
324  cpv.position(layerOut, layer, 1, DDTranslation(0.0, 0.0, 0.0), DDRotation());
325  LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << layerOut.name() << " number 1 positioned in " << layer.name()
326  << " at (0,0,0) with no rotation";
327 
328  rposdet = radiusUp;
329  dphi = CLHEP::twopi / stringsUp;
331  for (int n = 0; n < stringsUp; n++) {
332  double phi = (n + 0.5) * dphi;
333  double phix = phi - detectorTilt - 90 * CLHEP::deg;
334  double phideg = phix / CLHEP::deg;
336  if (phideg != 0) {
337  double theta = 90 * CLHEP::deg;
338  double phiy = phix + 90. * CLHEP::deg;
339  string rotstr = idName + to_string(phideg * 10.);
341  if (!rotation) {
342  LogDebug("TIBGeom") << "DDTIBLayerAlgo test: Creating a new "
343  << "rotation: " << rotstr << "\t90., " << phix / CLHEP::deg << ", 90.," << phiy / CLHEP::deg
344  << ", 0, 0";
345  rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta, phiy, 0., 0.);
346  }
347  }
348  DDTranslation trdet(rposdet * cos(phi), rposdet * sin(phi), 0);
349  cpv.position(detOut, layerOut, n + 1, trdet, rotation);
350  LogDebug("TIBGeom") << "DDTIBLayerAlgo test " << detOut.name() << " number " << n + 1 << " positioned in "
351  << layerOut.name() << " at " << trdet << " with " << rotation;
352  }
353 
354  //
355  // Inner cylinder, support wall and ribs
356  //
357  // External skins
358  rin = cylinderInR;
359  rout = cylinderInR + cylinderT;
360  name = idName + "Cylinder";
361  solid = DDSolidFactory::tubs(DDName(name, idNameSpace), 0.5 * layerL, rin, rout, 0, CLHEP::twopi);
362  LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << DDName(name, idNameSpace) << " Tubs made of " << cylinderMat
363  << " from 0 to " << CLHEP::twopi / CLHEP::deg << " with Rin " << rin << " Rout " << rout
364  << " ZHalf " << 0.5 * layerL;
366  DDMaterial matcyl(matname);
367  DDLogicalPart cylinder(solid.ddname(), matcyl, solid);
368  cpv.position(cylinder, layer, 1, DDTranslation(0.0, 0.0, 0.0), DDRotation());
369  LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << cylinder.name() << " number 1 positioned in " << layer.name()
370  << " at (0,0,0) with no rotation";
371  //
372  // inner part of the cylinder
373  //
374  rin += supportT;
375  rout -= supportT;
376  name = idName + "CylinderIn";
377  solid = DDSolidFactory::tubs(DDName(name, idNameSpace), 0.5 * layerL, rin, rout, 0, CLHEP::twopi);
378  LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << DDName(name, idNameSpace) << " Tubs made of " << genMat
379  << " from 0 to " << CLHEP::twopi / CLHEP::deg << " with Rin " << rin << " Rout " << rout
380  << " ZHalf " << 0.5 * layerL;
381  DDLogicalPart cylinderIn(solid.ddname(), matter, solid);
382  cpv.position(cylinderIn, cylinder, 1, DDTranslation(0.0, 0.0, 0.0), DDRotation());
383  LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << cylinderIn.name() << " number 1 positioned in " << cylinder.name()
384  << " at (0,0,0) with no rotation";
385  //
386  // Filler Rings
387  //
389  DDMaterial matfiller(matname);
390  name = idName + "Filler";
391  solid = DDSolidFactory::tubs(DDName(name, idNameSpace), fillerDz, rin, rout, 0., CLHEP::twopi);
392  LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << DDName(name, idNameSpace) << " Tubs made of " << fillerMat
393  << " from " << 0. << " to " << CLHEP::twopi / CLHEP::deg << " with Rin " << rin << " Rout "
394  << rout << " ZHalf " << fillerDz;
395  DDLogicalPart cylinderFiller(solid.ddname(), matfiller, solid);
396  cpv.position(cylinderFiller, cylinderIn, 1, DDTranslation(0.0, 0.0, 0.5 * layerL - fillerDz), DDRotation());
397  cpv.position(cylinderFiller, cylinderIn, 2, DDTranslation(0.0, 0.0, -0.5 * layerL + fillerDz), DDRotation());
398  LogDebug("TIBGeom") << "DDTIBLayerAlgo test " << cylinderFiller.name() << " number 1"
399  << " positioned in " << cylinderIn.name() << " at "
400  << DDTranslation(0.0, 0.0, 0.5 * layerL - fillerDz) << " number 2"
401  << " positioned in " << cylinderIn.name() << " at "
402  << DDTranslation(0.0, 0.0, -0.5 * layerL + fillerDz);
403 
404  //
405  // Ribs
406  //
408  DDMaterial matrib(matname);
409  for (int i = 0; i < (int)(ribW.size()); i++) {
410  name = idName + "Rib" + to_string(i);
411  double width = 2. * ribW[i] / (rin + rout);
412  double dz = 0.5 * layerL - 2. * fillerDz;
413  solid = DDSolidFactory::tubs(
414  DDName(name, idNameSpace), dz, rin + 0.5 * CLHEP::mm, rout - 0.5 * CLHEP::mm, -0.5 * width, width);
415  LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << DDName(name, idNameSpace) << " Tubs made of " << ribMat
416  << " from " << -0.5 * width / CLHEP::deg << " to " << 0.5 * width / CLHEP::deg << " with Rin "
417  << rin + 0.5 * CLHEP::mm << " Rout " << rout - 0.5 * CLHEP::mm << " ZHalf " << dz;
418  DDLogicalPart cylinderRib(solid.ddname(), matrib, solid);
419  double phix = ribPhi[i];
420  double phideg = phix / CLHEP::deg;
422  if (phideg != 0) {
423  double theta = 90 * CLHEP::deg;
424  double phiy = phix + 90. * CLHEP::deg;
425  string rotstr = idName + to_string(phideg * 10.);
427  if (!rotation) {
428  LogDebug("TIBGeom") << "DDTIBLayerAlgo test: Creating a new "
429  << "rotation: " << rotstr << "\t90., " << phix / CLHEP::deg << ", 90.," << phiy / CLHEP::deg
430  << ", 0, 0";
431  rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta, phiy, 0., 0.);
432  }
433  }
434  DDTranslation tran(0, 0, 0);
435  cpv.position(cylinderRib, cylinderIn, 1, tran, rotation);
436  LogDebug("TIBGeom") << "DDTIBLayerAlgo test " << cylinderRib.name() << " number 1"
437  << " positioned in " << cylinderIn.name() << " at " << tran << " with " << rotation;
438  }
439 
440  //Manifold rings
441  //
442  // Inner ones first
444  DDMaterial matintmfr(matname);
445  rin = MFRingInR;
446  rout = rin + MFRingT;
447  name = idName + "InnerMFRing";
448  solid = DDSolidFactory::tubs(DDName(name, idNameSpace), MFRingDz, rin, rout, 0, CLHEP::twopi);
449 
450  LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << DDName(name, idNameSpace) << " Tubs made of " << MFIntRingMat
451  << " from 0 to " << CLHEP::twopi / CLHEP::deg << " with Rin " << rin << " Rout " << rout
452  << " ZHalf " << MFRingDz;
453 
454  DDLogicalPart inmfr(solid.ddname(), matintmfr, solid);
455  cpv.position(inmfr, layer, 1, DDTranslation(0.0, 0.0, -0.5 * layerL + MFRingDz), DDRotation());
456  cpv.position(inmfr, layer, 2, DDTranslation(0.0, 0.0, +0.5 * layerL - MFRingDz), DDRotation());
457  LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << inmfr.name() << " number 1 and 2 positioned in " << layer.name()
458  << " at (0,0,+-" << 0.5 * layerL - MFRingDz << ") with no rotation";
459  // Outer ones
461  DDMaterial matextmfr(matname);
462  rout = MFRingOutR;
463  rin = rout - MFRingT;
464  name = idName + "OuterMFRing";
465  solid = DDSolidFactory::tubs(DDName(name, idNameSpace), MFRingDz, rin, rout, 0, CLHEP::twopi);
466 
467  LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << DDName(name, idNameSpace) << " Tubs made of " << MFExtRingMat
468  << " from 0 to " << CLHEP::twopi / CLHEP::deg << " with Rin " << rin << " Rout " << rout
469  << " ZHalf " << MFRingDz;
470 
471  DDLogicalPart outmfr(solid.ddname(), matextmfr, solid);
472  cpv.position(outmfr, layer, 1, DDTranslation(0.0, 0.0, -0.5 * layerL + MFRingDz), DDRotation());
473  cpv.position(outmfr, layer, 2, DDTranslation(0.0, 0.0, +0.5 * layerL - MFRingDz), DDRotation());
474  LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << outmfr.name() << " number 1 and 2 positioned in " << layer.name()
475  << " at (0,0,+-" << 0.5 * layerL - MFRingDz << ") with no rotation";
476 
477  //Central Support rings
478  //
480  DDMaterial matcent(matname);
481  // Ring 1
482  double centZ = centRing1par[0];
483  double centDz = 0.5 * centRing1par[1];
484  rin = centRing1par[2];
485  rout = centRing1par[3];
486  name = idName + "CentRing1";
487  solid = DDSolidFactory::tubs(DDName(name, idNameSpace), centDz, rin, rout, 0, CLHEP::twopi);
488 
489  LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << DDName(name, idNameSpace) << " Tubs made of " << centMat
490  << " from 0 to " << CLHEP::twopi / CLHEP::deg << " with Rin " << rin << " Rout " << rout
491  << " ZHalf " << centDz;
492 
493  DDLogicalPart cent1(solid.ddname(), matcent, solid);
494  cpv.position(cent1, layer, 1, DDTranslation(0.0, 0.0, centZ), DDRotation());
495  LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << cent1.name() << " positioned in " << layer.name() << " at (0,0,"
496  << centZ << ") with no rotation";
497  // Ring 2
498  centZ = centRing2par[0];
499  centDz = 0.5 * centRing2par[1];
500  rin = centRing2par[2];
501  rout = centRing2par[3];
502  name = idName + "CentRing2";
503  solid = DDSolidFactory::tubs(DDName(name, idNameSpace), centDz, rin, rout, 0, CLHEP::twopi);
504 
505  LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << DDName(name, idNameSpace) << " Tubs made of " << centMat
506  << " from 0 to " << CLHEP::twopi / CLHEP::deg << " with Rin " << rin << " Rout " << rout
507  << " ZHalf " << centDz;
508 
509  DDLogicalPart cent2(solid.ddname(), matcent, solid);
510  cpv.position(cent2, layer, 1, DDTranslation(0.0, 0.0, centZ), DDRotation());
511  LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << cent2.name() << " positioned in " << layer.name() << " at (0,0,"
512  << centZ << ") with no rotation";
513 
515  //
516  // Preparing DOHM Carrier solid
517 
518  name = idName + "DOHMCarrier";
519 
520  double dohmCarrierRin = MFRingOutR - MFRingT;
521  double dohmCarrierRout = MFRingOutR;
522  double dohmCarrierDz = 0.5 * (dohmPrimL + dohmtoMF);
523  double dohmCarrierZ = 0.5 * layerL - 2. * MFRingDz - dohmCarrierDz;
524 
526  dohmCarrierDz,
527  dohmCarrierRin,
528  dohmCarrierRout,
530  180. * CLHEP::deg - 2. * dohmCarrierPhiOff);
531  LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << DDName(name, idNameSpace) << " Tubs made of " << dohmCarrierMaterial
532  << " from " << dohmCarrierPhiOff << " to " << 180. * CLHEP::deg - dohmCarrierPhiOff
533  << " with Rin " << dohmCarrierRin << " Rout " << MFRingOutR << " ZHalf " << dohmCarrierDz;
534 
535  // Define FW and BW carrier logical volume and
536  // place DOHM Primary and auxiliary modules inside it
537 
538  dphi = CLHEP::twopi / stringsUp;
539 
540  DDRotation dohmRotation;
541 
542  double dohmR = 0.5 * (dohmCarrierRin + dohmCarrierRout);
543 
544  for (int j = 0; j < 4; j++) {
545  vector<double> dohmList;
546  DDTranslation tran;
547  string rotstr;
549  int dohmCarrierReplica = 0;
550  int placeDohm = 0;
551 
552  switch (j) {
553  case 0:
554  name = idName + "DOHMCarrierFW";
555  dohmList = dohmListFW;
556  tran = DDTranslation(0., 0., dohmCarrierZ);
557  rotstr = idName + "FwUp";
558  rotation = DDRotation();
559  dohmCarrierReplica = 1;
560  placeDohm = 1;
561  break;
562  case 1:
563  name = idName + "DOHMCarrierFW";
564  dohmList = dohmListFW;
565  tran = DDTranslation(0., 0., dohmCarrierZ);
566  rotstr = idName + "FwDown";
567  rotation = DDrot(DDName(rotstr, idNameSpace),
568  90. * CLHEP::deg,
569  180. * CLHEP::deg,
570  90. * CLHEP::deg,
571  270. * CLHEP::deg,
572  0.,
573  0.);
574  dohmCarrierReplica = 2;
575  placeDohm = 0;
576  break;
577  case 2:
578  name = idName + "DOHMCarrierBW";
579  dohmList = dohmListBW;
580  tran = DDTranslation(0., 0., -dohmCarrierZ);
581  rotstr = idName + "BwUp";
582  rotation = DDrot(DDName(rotstr, idNameSpace),
583  90. * CLHEP::deg,
584  180. * CLHEP::deg,
585  90. * CLHEP::deg,
586  90. * CLHEP::deg,
587  180. * CLHEP::deg,
588  0.);
589  dohmCarrierReplica = 1;
590  placeDohm = 1;
591  break;
592  case 3:
593  name = idName + "DOHMCarrierBW";
594  dohmList = dohmListBW;
595  tran = DDTranslation(0., 0., -dohmCarrierZ);
596  rotstr = idName + "BwDown";
597  rotation = DDrot(DDName(rotstr, idNameSpace),
598  90. * CLHEP::deg,
599  0.,
600  90. * CLHEP::deg,
601  270. * CLHEP::deg,
602  180. * CLHEP::deg,
603  0.);
604  dohmCarrierReplica = 2;
605  placeDohm = 0;
606  break;
607  }
608 
609  DDLogicalPart dohmCarrier(name, DDMaterial(dohmCarrierMaterial), solid);
610 
611  int primReplica = 0;
612  int auxReplica = 0;
613 
614  for (int i = 0; i < placeDohm * ((int)(dohmList.size())); i++) {
615  double phi = (abs(dohmList[i]) + 0.5 - 1.) * dphi;
616  double phix = phi + 90 * CLHEP::deg;
617  double phideg = phix / CLHEP::deg;
618  if (phideg != 0) {
619  double theta = 90 * CLHEP::deg;
620  double phiy = phix + 90. * CLHEP::deg;
621  string rotstr = idName + to_string(abs(dohmList[i]) - 1.);
622  dohmRotation = DDRotation(DDName(rotstr, idNameSpace));
623  if (!dohmRotation) {
624  LogDebug("TIBGeom") << "DDTIBLayerAlgo test: Creating a new "
625  << "rotation: " << rotstr << "\t" << theta << ", " << phix / CLHEP::deg << ", " << theta
626  << ", " << phiy / CLHEP::deg << ", 0, 0";
627  dohmRotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta, phiy, 0., 0.);
628  }
629  }
630 
631  string dohmName;
632  int dohmReplica = 0;
633  double dohmZ = 0.;
634 
635  if (dohmList[i] < 0.) {
636  // Place a Auxiliary DOHM
637  dohmName = dohmAuxName;
638  dohmZ = dohmCarrierDz - 0.5 * dohmAuxL - dohmtoMF;
639  primReplica++;
640  dohmReplica = primReplica;
641 
642  } else {
643  // Place a Primary DOHM
644  dohmName = dohmPrimName;
645  dohmZ = dohmCarrierDz - 0.5 * dohmPrimL - dohmtoMF;
646  auxReplica++;
647  dohmReplica = auxReplica;
648  }
649 
650  DDName dohm(DDSplit(dohmName).first, DDSplit(dohmName).second);
651  DDTranslation dohmTrasl(dohmR * cos(phi), dohmR * sin(phi), dohmZ);
652  cpv.position(dohm, dohmCarrier, dohmReplica, dohmTrasl, dohmRotation);
653  LogDebug("TIBGeom") << "DDTIBLayerAlgo test " << dohm.name() << " replica " << dohmReplica << " positioned in "
654  << dohmCarrier.name() << " at " << dohmTrasl << " with " << dohmRotation;
655  }
656 
657  cpv.position(dohmCarrier, parent(), dohmCarrierReplica, tran, rotation);
658  LogDebug("TIBGeom") << "DDTIBLayerAlgo test " << dohmCarrier.name() << " positioned in " << parent().name()
659  << " at " << tran << " with " << rotation;
660  }
661 
663 
664  for (int j = 0; j < 4; j++) {
666  DDMaterial pillarMat(matname);
667  vector<double> pillarZ;
668  vector<double> pillarPhi;
669  double pillarDz = 0, pillarDPhi = 0, pillarRin = 0, pillarRout = 0;
670 
671  switch (j) {
672  case 0:
673  name = idName + "FWIntPillar";
674  pillarZ = fwIntPillarZ;
675  pillarPhi = fwIntPillarPhi;
676  pillarRin = MFRingInR;
677  pillarRout = MFRingInR + MFRingT;
678  pillarDz = fwIntPillarDz;
679  pillarDPhi = fwIntPillarDPhi;
680  break;
681  case 1:
682  name = idName + "BWIntPillar";
683  pillarZ = bwIntPillarZ;
684  pillarPhi = bwIntPillarPhi;
685  pillarRin = MFRingInR;
686  pillarRout = MFRingInR + MFRingT;
687  pillarDz = bwIntPillarDz;
688  pillarDPhi = bwIntPillarDPhi;
689  break;
690  case 2:
691  name = idName + "FWExtPillar";
692  pillarZ = fwExtPillarZ;
693  pillarPhi = fwExtPillarPhi;
694  pillarRin = MFRingOutR - MFRingT;
695  pillarRout = MFRingOutR;
696  pillarDz = fwExtPillarDz;
697  pillarDPhi = fwExtPillarDPhi;
698  break;
699  case 3:
700  name = idName + "BWExtPillar";
701  pillarZ = bwExtPillarZ;
702  pillarPhi = bwExtPillarPhi;
703  pillarRin = MFRingOutR - MFRingT;
704  pillarRout = MFRingOutR;
705  pillarDz = bwExtPillarDz;
706  pillarDPhi = bwExtPillarDPhi;
707  break;
708  }
709 
710  solid =
711  DDSolidFactory::tubs(DDName(name, idNameSpace), pillarDz, pillarRin, pillarRout, -pillarDPhi, 2. * pillarDPhi);
712 
713  DDLogicalPart Pillar(name, DDMaterial(pillarMat), solid);
714 
715  LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << DDName(name, idNameSpace) << " Tubs made of " << pillarMat
716  << " from " << -pillarDPhi << " to " << pillarDPhi << " with Rin " << pillarRin << " Rout "
717  << pillarRout << " ZHalf " << pillarDz;
718 
719  DDTranslation pillarTran;
720  DDRotation pillarRota;
721  int pillarReplica = 0;
722  for (unsigned int i = 0; i < pillarZ.size(); i++) {
723  if (pillarPhi[i] > 0.) {
724  pillarTran = DDTranslation(0., 0., pillarZ[i]);
725  pillarRota = DDanonymousRot(unique_ptr<DDRotationMatrix>(DDcreateRotationMatrix(
726  90. * CLHEP::deg, pillarPhi[i], 90. * CLHEP::deg, 90. * CLHEP::deg + pillarPhi[i], 0., 0.)));
727 
728  cpv.position(Pillar, parent(), i, pillarTran, pillarRota);
729  LogDebug("TIBGeom") << "DDTIBLayerAlgo test " << Pillar.name() << " positioned in " << parent().name() << " at "
730  << pillarTran << " with " << pillarRota << " copy number " << pillarReplica;
731 
732  pillarReplica++;
733  }
734  }
735  }
736 }
737 
738 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDTIBLayerAlgo, "track:DDTIBLayerAlgo");
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
static AlgebraicMatrix initialize()
DDRotation DDanonymousRot(std::unique_ptr< DDRotationMatrix > rot)
Defines a anonymous rotation or rotation-reflection matrix.
Definition: DDRotation.cc:143
vector< double > bwIntPillarPhi
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
vector< double > bwExtPillarZ
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
std::string to_string(const V &value)
Definition: OMSAccess.h:71
static std::string & ns()
vector< double > ribW
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
~DDTIBLayerAlgo() override
vector< double > dohmListFW
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
vector< double > bwIntPillarZ
constexpr std::array< uint8_t, layerIndexSize > layer
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
vector< double > fwExtPillarPhi
U second(std::pair< T, U > const &p)
string dohmCarrierMaterial
vector< double > bwExtPillarPhi
vector< double > fwIntPillarPhi
vector< double > dohmListBW
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
double dohmCarrierPhiOff
string dohmAuxMaterial
void execute(DDCompactView &cpv) override
vector< double > fwIntPillarZ
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
DDRotation DDrot(const DDName &name, std::unique_ptr< DDRotationMatrix > rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:67
std::unique_ptr< DDRotationMatrix > DDcreateRotationMatrix(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
create a new DDRotationMatrix in the GEANT3 style.
Definition: DDRotation.cc:120
static DDSolid tubs(const DDName &name, double zhalf, double rIn, double rOut, double startPhi, double deltaPhi)
Definition: DDSolid.cc:667
vector< double > centRing2par
const N & name() const
Definition: DDBase.h:59
const N & ddname() const
Definition: DDBase.h:61
string dohmPrimMaterial
vector< double > ribPhi
#define DEFINE_EDM_PLUGIN(factory, type, name)
string dohmCableMaterial
vector< double > fwExtPillarZ
vector< double > centRing1par
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:3
Geom::Theta< T > theta() const
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
double fwIntPillarDPhi
#define LogDebug(id)