CMS 3D CMS Logo

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