CMS 3D CMS Logo

DDHCalBarrelAlgo.cc
Go to the documentation of this file.
1 // File: DDHCalBarrelAlgo.cc
3 // adapted from CCal(G4)HcalBarrel.cc
4 // Description: Geometry factory class for Hcal Barrel
6 
7 #include <cmath>
8 #include <algorithm>
9 #include <map>
10 #include <string>
11 #include <vector>
12 
18 #include "DD4hep/DetFactoryHelper.h"
19 
20 //#define EDM_ML_DEBUG
21 using namespace angle_units::operators;
22 
24  //General Volume
25  // <----- Zmax ------>
26  //Router************************-------
27  // * *Rstep2| Theta angle w.r.t. vertical
28  // * *---------------
29  // * * |
30  // * *Theta[i] Rmax[i]
31  // * *--------------- |
32  // *Theta[0] Rmax[0]| |
33  //Rinner*****************----------------------
34 
35  std::string genMaterial; //General material
36  int nsectors; //Number of potenital straight edges
37  int nsectortot; //Number of straight edges (actual)
38  int nhalf; //Number of half modules
39  double rinner, router; //See picture
40  int rzones; // ....
41  std::vector<double> theta; // .... (in degrees)
42  std::vector<double> rmax; // ....
43  std::vector<double> zoff; // ....
44  std::vector<double> ttheta; //tan(theta)
45  std::string rotHalf; //Rotation matrix of the second half
46  std::string rotns; //Name space for Rotation matrices
47 
48  //Upper layers inside general volume
49  // <---- Zout ---->
50  // | **************** |
51  // | * * Wstep
52  // W * ***** |
53  // | * *
54  // | ********************
55  // <------ Zin ------->
56  // Middle layers inside general volume
57  // <------ Zout ------> Zout = Full sector Z at position
58  // | ******************** Zin = Full sector Z at position
59  // | * *
60  // W * * Angle = Theta sector
61  // | * * )
62  // | ****************--------
63  // <------ Zin ------->
64 
65  // Lower layers
66  // <------ Zout ------> Zin(i)=Zout(i-1)
67  // | ******************** Zout(i)=Zin(i)+W(i)/tan(Theta(i))
68  // | * *
69  // W * * Theta
70  // | * *
71  // | ****************--------
72  // <--- Zin ------>
73 
74  int nLayers; //Number of layers
75  std::vector<int> layerId; //Number identification
76  std::vector<std::string> layerLabel; //String identification
77  std::vector<std::string> layerMat; //Material
78  std::vector<double> layerWidth; //W in picture
79  std::vector<double> layerD1; //d1 in front picture
80  std::vector<double> layerD2; //d2 in front picture
81  std::vector<double> layerAlpha; //Angular width of the middle tiles
82  std::vector<double> layerT1; //t in front picture (side)
83  std::vector<double> layerT2; //t in front picture (front)
84  std::vector<int> layerAbsorb; //Absorber flag
85  std::vector<double> layerGap; //Gap at the edge
86 
87  int nAbsorber; //Number of absorber layers in middle
88  std::vector<std::string> absorbName; //Absorber name
89  std::vector<std::string> absorbMat; //Absorber material
90  std::vector<double> absorbD; //Distance from the bottom surface
91  std::vector<double> absorbT; //Thickness
92  std::string middleMat; //Material of the detector layer
93  double middleD; //Distance from the bottom surface
94  double middleW; //Half width
95  int nMidAbs; //Number of absorbers in front part
96  std::vector<std::string> midName; //Absorber names in the front part
97  std::vector<std::string> midMat; //Absorber material
98  std::vector<double> midW; //Half width
99  std::vector<double> midT; //Thickness
100 
101  std::vector<std::string> sideMat; //Material for special side layers
102  std::vector<double> sideD; //Depth from bottom surface
103  std::vector<double> sideT; //Thickness
104  int nSideAbs; //Number of absorbers in special side
105  std::vector<std::string> sideAbsName; //Absorber name
106  std::vector<std::string> sideAbsMat; //Absorber material
107  std::vector<double> sideAbsW; //Half width
108 
109  // Detectors. Each volume inside the layer has the shape:
110  //
111  // ******************************* |
112  // *\\\\\\\Plastic\\\\\\\\\\\\\\\* T2
113  // ******************************* |
114  // *////Scintillator/////////////* Tsc
115  // ******************************* |
116  // *\\\\\\\Plastic\\\\\\\\\\\\\\\* T1
117  // ******************************* | |
118  // * Air * dP1
119  // ******************************* |
120  //
121  std::string detMat; //fill material
122  std::string detRot; //Rotation matrix for the 2nd
123  std::string detMatPl; //Plastic material
124  std::string detMatSc; //Scintillator material
125  std::vector<int> detType;
126  std::vector<double> detdP1; //Air gap (side)
127  std::vector<double> detdP2; //Air gap (centre)
128  std::vector<double> detT11; //Back plastic thickness (side)
129  std::vector<double> detT12; //Back plastic thickness (centre)
130  std::vector<double> detTsc; //Scintillator
131  std::vector<double> detT21; //Front plastic thickness (side)
132  std::vector<double> detT22; //Front plastic thickness (centre)
133  std::vector<double> detWidth1; //Width of phi(1,4) megatiles
134  std::vector<double> detWidth2; //Width of phi(2,3) megatiles
135  std::vector<int> detPosY; //Positioning of phi(1,4) tiles - 0 centre
136 
137  std::string idName; //Name of the "parent" volume.
138  std::string idNameSpace; //Namespace of this and ALL sub-parts
139  int idOffset; // Geant4 ID's... = 3000;
140 
141  HcalBarrelAlgo() = delete;
142 
144  cms::DDNamespace ns(ctxt, e, true);
145  cms::DDAlgoArguments args(ctxt, e);
146 #ifdef EDM_ML_DEBUG
147  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: Creating an instance";
148 #endif
149 
150  genMaterial = args.value<std::string>("MaterialName");
151  nsectors = args.value<int>("NSector");
152  nsectortot = args.value<int>("NSectorTot");
153  nhalf = args.value<int>("NHalf");
154  rinner = args.value<double>("RIn");
155  router = args.value<double>("ROut");
156  rzones = args.value<int>("RZones");
157  rotHalf = args.value<std::string>("RotHalf");
158  rotns = args.value<std::string>("RotNameSpace");
159 
160  theta = args.value<std::vector<double> >("Theta");
161  rmax = args.value<std::vector<double> >("RMax");
162  zoff = args.value<std::vector<double> >("ZOff");
163  for (int i = 0; i < rzones; i++) {
164  ttheta.emplace_back(tan(theta[i])); //*deg already done in XML
165  }
166  if (rzones > 3)
167  rmax[2] = (zoff[3] - zoff[2]) / ttheta[2];
168 
169 #ifdef EDM_ML_DEBUG
170  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: General material " << genMaterial << "\tSectors " << nsectors
171  << ", " << nsectortot << "\tHalves " << nhalf << "\tRotation matrix " << rotns << ":"
172  << rotHalf << "\n\t\t" << cms::convert2mm(rinner) << "\t" << cms::convert2mm(router)
173  << "\t" << rzones;
174  for (int i = 0; i < rzones; i++)
175  edm::LogVerbatim("HCalGeom") << "\tTheta[" << i << "] = " << theta[i] << "\trmax[" << i
176  << "] = " << cms::convert2mm(rmax[i]) << "\tzoff[" << i
177  << "] = " << cms::convert2mm(zoff[i]);
178 #endif
179  //Layers
181  nLayers = args.value<int>("NLayers");
182 #ifdef EDM_ML_DEBUG
183  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: Layer\t" << nLayers;
184 #endif
185  layerId = args.value<std::vector<int> >("Id");
186  layerLabel = args.value<std::vector<std::string> >("LayerLabel");
187  layerMat = args.value<std::vector<std::string> >("LayerMat");
188  layerWidth = args.value<std::vector<double> >("LayerWidth");
189  layerD1 = args.value<std::vector<double> >("D1");
190  layerD2 = args.value<std::vector<double> >("D2");
191  layerAlpha = args.value<std::vector<double> >("Alpha2");
192  layerT1 = args.value<std::vector<double> >("T1");
193  layerT2 = args.value<std::vector<double> >("T2");
194  layerAbsorb = args.value<std::vector<int> >("AbsL");
195  layerGap = args.value<std::vector<double> >("Gap");
196 #ifdef EDM_ML_DEBUG
197  for (int i = 0; i < nLayers; i++)
198  edm::LogVerbatim("HCalGeom") << layerLabel[i] << "\t" << layerId[i] << "\t" << layerMat[i] << "\t"
199  << cms::convert2mm(layerWidth[i]) << "\t" << cms::convert2mm(layerD1[i]) << "\t"
200  << cms::convert2mm(layerD2[i]) << "\t" << layerAlpha[i] << "\t"
201  << cms::convert2mm(layerT1[i]) << "\t" << cms::convert2mm(layerT2[i]) << "\t"
202  << layerAbsorb[i] << "\t" << cms::convert2mm(layerGap[i]);
203 #endif
204 
206  //Absorber Layers and middle part
207  absorbName = args.value<std::vector<std::string> >("AbsorbName");
208  absorbMat = args.value<std::vector<std::string> >("AbsorbMat");
209  absorbD = args.value<std::vector<double> >("AbsorbD");
210  absorbT = args.value<std::vector<double> >("AbsorbT");
211  nAbsorber = absorbName.size();
212 #ifdef EDM_ML_DEBUG
213  for (int i = 0; i < nAbsorber; i++)
214  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << absorbName[i] << " Material " << absorbMat[i] << " d "
215  << cms::convert2mm(absorbD[i]) << " t " << cms::convert2mm(absorbT[i]);
216 #endif
217  middleMat = args.value<std::string>("MiddleMat");
218  middleD = args.value<double>("MiddleD");
219  middleW = args.value<double>("MiddleW");
220 #ifdef EDM_ML_DEBUG
221  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: Middle material " << middleMat << " d "
222  << cms::convert2mm(middleD) << " w " << cms::convert2mm(middleW);
223 #endif
224  midName = args.value<std::vector<std::string> >("MidAbsName");
225  midMat = args.value<std::vector<std::string> >("MidAbsMat");
226  midW = args.value<std::vector<double> >("MidAbsW");
227  midT = args.value<std::vector<double> >("MidAbsT");
228  nMidAbs = midName.size();
229 #ifdef EDM_ML_DEBUG
230  for (int i = 0; i < nMidAbs; i++)
231  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << midName[i] << " Material " << midMat[i] << " W "
232  << cms::convert2mm(midW[i]) << " T " << cms::convert2mm(midT[i]);
233 #endif
234 
235  //Absorber layers in the side part
236  sideMat = args.value<std::vector<std::string> >("SideMat");
237  sideD = args.value<std::vector<double> >("SideD");
238  sideT = args.value<std::vector<double> >("SideT");
239 #ifdef EDM_ML_DEBUG
240  for (unsigned int i = 0; i < sideMat.size(); i++)
241  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: Side material " << sideMat[i] << " d "
242  << cms::convert2mm(sideD[i]) << " t " << cms::convert2mm(sideT[i]);
243 #endif
244  sideAbsName = args.value<std::vector<std::string> >("SideAbsName");
245  sideAbsMat = args.value<std::vector<std::string> >("SideAbsMat");
246  sideAbsW = args.value<std::vector<double> >("SideAbsW");
247  nSideAbs = sideAbsName.size();
248 #ifdef EDM_ML_DEBUG
249  for (int i = 0; i < nSideAbs; i++)
250  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << sideAbsName[i] << " Material " << sideAbsMat[i] << " W "
251  << cms::convert2mm(sideAbsW[i]);
252 #endif
253 
255  // Detectors
256 
257  detMat = args.value<std::string>("DetMat");
258  detRot = args.value<std::string>("DetRot");
259  detMatPl = args.value<std::string>("DetMatPl");
260  detMatSc = args.value<std::string>("DetMatSc");
261 #ifdef EDM_ML_DEBUG
262  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: Detector (" << nLayers << ") Rotation matrix " << rotns << ":"
263  << detRot << "\n\t\t" << detMat << "\t" << detMatPl << "\t" << detMatSc;
264 #endif
265  detType = args.value<std::vector<int> >("DetType");
266  detdP1 = args.value<std::vector<double> >("DetdP1");
267  detdP2 = args.value<std::vector<double> >("DetdP2");
268  detT11 = args.value<std::vector<double> >("DetT11");
269  detT12 = args.value<std::vector<double> >("DetT12");
270  detTsc = args.value<std::vector<double> >("DetTsc");
271  detT21 = args.value<std::vector<double> >("DetT21");
272  detT22 = args.value<std::vector<double> >("DetT22");
273  detWidth1 = args.value<std::vector<double> >("DetWidth1");
274  detWidth2 = args.value<std::vector<double> >("DetWidth2");
275  detPosY = args.value<std::vector<int> >("DetPosY");
276 #ifdef EDM_ML_DEBUG
277  for (int i = 0; i < nLayers; i++)
278  edm::LogVerbatim("HCalGeom") << i + 1 << "\t" << detType[i] << "\t" << cms::convert2mm(detdP1[i]) << ", "
279  << cms::convert2mm(detdP2[i]) << "\t" << cms::convert2mm(detT11[i]) << ", "
280  << cms::convert2mm(detT12[i]) << "\t" << cms::convert2mm(detTsc[i]) << "\t"
281  << cms::convert2mm(detT21[i]) << ", " << cms::convert2mm(detT22[i]) << "\t"
282  << cms::convert2mm(detWidth1[i]) << "\t" << cms::convert2mm(detWidth2[i]) << "\t"
283  << detPosY[i];
284 #endif
285 
286  // idName = parentName.name();
287  idName = args.value<std::string>("MotherName");
288  idNameSpace = ns.name();
289  idOffset = args.value<int>("IdOffset");
290 #ifdef EDM_ML_DEBUG
291  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: Parent " << args.parentName() << " idName " << idName
292  << " NameSpace " << idNameSpace << " Offset " << idOffset;
293  edm::LogVerbatim("HCalGeom") << "==>> Constructing DDHCalBarrelAlgo...\n"
294  << "DDHCalBarrelAlgo: General volume...";
295 #endif
296 
297  double alpha = (1._pi) / nsectors;
298  double dphi = nsectortot * (2._pi) / nsectors;
299  int nsec, ntot(15);
300  if (nhalf == 1)
301  nsec = 8;
302  else
303  nsec = 15;
304  int nf = ntot - nsec;
305 
306  //Calculate zmin... see HCalBarrel.hh picture. For polyhedra
307  //Rmin and Rmax are distances to vertex
308  double zmax = zoff[3];
309  double zstep5 = zoff[4];
310  double zstep4 = (zoff[1] + rmax[1] * ttheta[1]);
311  if ((zoff[2] + rmax[1] * ttheta[2]) > zstep4)
312  zstep4 = (zoff[2] + rmax[1] * ttheta[2]);
313  double zstep3 = (zoff[1] + rmax[0] * ttheta[1]);
314  double zstep2 = (zoff[0] + rmax[0] * ttheta[0]);
315  double zstep1 = (zoff[0] + rinner * ttheta[0]);
316  double rout = router;
317  double rout1 = rmax[3];
318  double rin = rinner;
319  double rmid1 = rmax[0];
320  double rmid2 = rmax[1];
321  double rmid3 = (zoff[4] - zoff[2]) / ttheta[2];
322  double rmid4 = rmax[2];
323 
324  std::vector<double> pgonZ = {-zmax,
325  -zstep5,
326  -zstep5,
327  -zstep4,
328  -zstep3,
329  -zstep2,
330  -zstep1,
331  0,
332  zstep1,
333  zstep2,
334  zstep3,
335  zstep4,
336  zstep5,
337  zstep5,
338  zmax};
339 
340  std::vector<double> pgonRmin = {
341  rmid4, rmid3, rmid3, rmid2, rmid1, rmid1, rin, rin, rin, rmid1, rmid1, rmid2, rmid3, rmid3, rmid4};
342 
343  std::vector<double> pgonRmax = {
344  rout1, rout1, rout, rout, rout, rout, rout, rout, rout, rout, rout, rout, rout, rout1, rout1};
345 
346  std::vector<double> pgonZHalf = {0, zstep1, zstep2, zstep3, zstep4, zstep5, zstep5, zmax};
347 
348  std::vector<double> pgonRminHalf = {rin, rin, rmid1, rmid1, rmid2, rmid3, rmid3, rmid4};
349 
350  std::vector<double> pgonRmaxHalf = {rout, rout, rout, rout, rout, rout, rout1, rout1};
351 
352  std::string name("Null");
353  dd4hep::Solid solid;
354  if (nf == 0) {
355  solid = dd4hep::Polyhedra(ns.prepend(idName), nsectortot, -alpha, dphi, pgonZ, pgonRmin, pgonRmax);
356 #ifdef EDM_ML_DEBUG
357  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << solid.name() << " Polyhedra made of " << genMaterial
358  << " with " << nsectortot << " sectors from " << convertRadToDeg(-alpha) << " to "
359  << convertRadToDeg(-alpha + dphi) << " and with " << nsec << " sections ";
360  for (unsigned int i = 0; i < pgonZ.size(); i++)
361  edm::LogVerbatim("HCalGeom") << "\t"
362  << "\tZ = " << cms::convert2mm(pgonZ[i])
363  << "\tRmin = " << cms::convert2mm(pgonRmin[i])
364  << "\tRmax = " << cms::convert2mm(pgonRmax[i]);
365 #endif
366  } else {
367  solid = dd4hep::Polyhedra(ns.prepend(idName), nsectortot, -alpha, dphi, pgonZHalf, pgonRminHalf, pgonRmaxHalf);
368 #ifdef EDM_ML_DEBUG
369  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << solid.name() << " Polyhedra made of " << genMaterial
370  << " with " << nsectortot << " sectors from " << convertRadToDeg(-alpha) << " to "
371  << convertRadToDeg(-alpha + dphi) << " and with " << nsec << " sections ";
372  for (unsigned int i = 0; i < pgonZHalf.size(); i++)
373  edm::LogVerbatim("HCalGeom") << "\t\tZ = " << cms::convert2mm(pgonZHalf[i])
374  << "\tRmin = " << cms::convert2mm(pgonRminHalf[i])
375  << "\tRmax = " << cms::convert2mm(pgonRmaxHalf[i]);
376 #endif
377  }
378 
379  dd4hep::Material matter = ns.material(genMaterial);
380  dd4hep::Volume genlogic(solid.name(), solid, matter);
381  dd4hep::Volume parentName = ns.volume(args.parentName());
382  parentName.placeVolume(genlogic, 1);
383 #ifdef EDM_ML_DEBUG
384  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << genlogic.name() << " number 1 positioned in "
385  << parentName.name() << " at (0, 0, 0) with no rotation";
386 #endif
387  //Forward and backwards halfs
388  name = idName + "Half";
389  nf = (ntot + 1) / 2;
390  solid = dd4hep::Polyhedra(ns.prepend(name), nsectortot, -alpha, dphi, pgonZHalf, pgonRminHalf, pgonRmaxHalf);
391 #ifdef EDM_ML_DEBUG
392  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << solid.name() << " Polyhedra made of " << genMaterial
393  << " with " << nsectortot << " sectors from " << convertRadToDeg(-alpha) << " to "
394  << convertRadToDeg(-alpha + dphi) << " and with " << nf << " sections ";
395  for (unsigned int i = 0; i < pgonZHalf.size(); i++)
396  edm::LogVerbatim("HCalGeom") << "\t\tZ = " << cms::convert2mm(pgonZHalf[i])
397  << "\tRmin = " << cms::convert2mm(pgonRminHalf[i])
398  << "\tRmax = " << cms::convert2mm(pgonRmaxHalf[i]);
399 #endif
400  dd4hep::Volume genlogich(solid.name(), solid, matter);
401  genlogic.placeVolume(genlogich, 1);
402 #ifdef EDM_ML_DEBUG
403  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << genlogich.name() << " number 1 positioned in "
404  << genlogic.name() << " at (0, 0, 0) with no rotation";
405 #endif
406  if (nhalf != 1) {
407  dd4hep::Rotation3D rot = getRotation(rotHalf, rotns, ns);
408  genlogic.placeVolume(genlogich, 2, rot);
409 #ifdef EDM_ML_DEBUG
410  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << genlogich.name() << " number 2 positioned in "
411  << genlogic.name() << " at (0, 0, 0) with " << rot;
412 #endif
413  } //end if (getNhalf...
414 
415  //Construct sector (from -alpha to +alpha)
416  name = idName + "Module";
417  solid = dd4hep::Polyhedra(ns.prepend(name), 1, -alpha, 2 * alpha, pgonZHalf, pgonRminHalf, pgonRmaxHalf);
418  dd4hep::Volume seclogic(solid.name(), solid, matter);
419 #ifdef EDM_ML_DEBUG
420  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << solid.name() << " Polyhedra made of " << matter.name()
421  << " with 1 sector from " << convertRadToDeg(-alpha) << " to "
422  << convertRadToDeg(alpha) << " and with " << nf << " sections";
423  for (unsigned int i = 0; i < pgonZHalf.size(); i++)
424  edm::LogVerbatim("HCalGeom") << "\t\tZ = " << cms::convert2mm(pgonZHalf[i])
425  << "\tRmin = " << cms::convert2mm(pgonRminHalf[i])
426  << "\tRmax = " << cms::convert2mm(pgonRmaxHalf[i]);
427 #endif
428 
429  for (int ii = 0; ii < nsectortot; ii++) {
430  double phi = ii * 2 * alpha;
431  dd4hep::Rotation3D rotation;
432  if (phi != 0) {
433  rotation = dd4hep::RotationZ(phi);
434 #ifdef EDM_ML_DEBUG
435  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: Creating a new "
436  << "rotation around Z " << convertRadToDeg(phi);
437 #endif
438  } //if phideg!=0
439  genlogich.placeVolume(seclogic, ii + 1, rotation);
440 #ifdef EDM_ML_DEBUG
441  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << seclogic.name() << " number " << ii + 1
442  << " positioned in " << genlogich.name() << " at (0, 0, 0) with " << rotation;
443 #endif
444  }
445 
446  //Construct the things inside the sector
447 #ifdef EDM_ML_DEBUG
448  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: Layers (" << nLayers << ") ...";
449 #endif
450  rin = rinner;
451  for (int i = 0; i < nLayers; i++) {
452  std::string name = idName + layerLabel[i];
453  dd4hep::Material matter = ns.material(layerMat[i]);
454  double width = layerWidth[i];
455  double rout = rin + width;
456 
457  int in = 0, out = 0;
458  for (int j = 0; j < rzones - 1; j++) {
459  if (rin >= rmax[j])
460  in = j + 1;
461  if (rout > rmax[j])
462  out = j + 1;
463  }
464  double zout = zoff[in] + rin * ttheta[in];
465 
467  //vertical walls are allowed in SolidPolyhedra
468 #ifdef EDM_ML_DEBUG
469  int nsec = 2;
470 #endif
471  std::vector<double> pgonZ, pgonRmin, pgonRmax;
472  // index 0
473  pgonZ.emplace_back(0);
474  pgonRmin.emplace_back(rin);
475  pgonRmax.emplace_back(rout);
476  // index 1
477  pgonZ.emplace_back(zout);
478  pgonRmin.emplace_back(rin);
479  pgonRmax.emplace_back(rout);
480  if (in == out) {
481  if (in <= 3) {
482  //index 2
483  pgonZ.emplace_back(zoff[in] + rout * ttheta[in]);
484  pgonRmin.emplace_back(pgonRmax[1]);
485  pgonRmax.emplace_back(pgonRmax[1]);
486 #ifdef EDM_ML_DEBUG
487  nsec++;
488 #endif
489  }
490  } else {
491  if (in == 3) {
492  //redo index 1, add index 2
493  pgonZ[1] = (zoff[out] + rmax[out] * ttheta[out]);
494  pgonZ.emplace_back(pgonZ[1]);
495  pgonRmin.emplace_back(pgonRmin[1]);
496  pgonRmax.emplace_back(rmax[in]);
497  //index 3
498  pgonZ.emplace_back(zoff[in] + rmax[in] * ttheta[in]);
499  pgonRmin.emplace_back(pgonRmin[2]);
500  pgonRmax.emplace_back(pgonRmax[2]);
501 #ifdef EDM_ML_DEBUG
502  nsec += 2;
503 #endif
504  } else {
505  //index 2
506  pgonZ.emplace_back(zoff[in] + rmax[in] * ttheta[in]);
507  pgonRmin.emplace_back(rmax[in]);
508  pgonRmax.emplace_back(pgonRmax[1]);
509 #ifdef EDM_ML_DEBUG
510  nsec++;
511 #endif
512  if (in == 0) {
513  pgonZ.emplace_back(zoff[out] + rmax[in] * ttheta[out]);
514  pgonRmin.emplace_back(pgonRmin[2]);
515  pgonRmax.emplace_back(pgonRmax[2]);
516 #ifdef EDM_ML_DEBUG
517  nsec++;
518 #endif
519  }
520  if (in <= 1) {
521  pgonZ.emplace_back(zoff[out] + rout * ttheta[out]);
522  pgonRmin.emplace_back(rout);
523  pgonRmax.emplace_back(rout);
524 #ifdef EDM_ML_DEBUG
525  nsec++;
526 #endif
527  }
528  }
529  }
530  //Solid & volume
531  dd4hep::Solid solid;
532  double alpha1 = alpha;
533  if (layerGap[i] > 1.e-6) {
534  double rmid = 0.5 * (rin + rout);
535  double width = rmid * tan(alpha) - layerGap[i];
536  alpha1 = atan(width / rmid);
537 #ifdef EDM_ML_DEBUG
538  edm::LogVerbatim("HCalGeom") << "\tAlpha_1 modified from " << convertRadToDeg(alpha) << " to "
539  << convertRadToDeg(alpha1) << " Rmid " << cms::convert2mm(rmid)
540  << " Reduced width " << cms::convert2mm(width);
541 #endif
542  }
543  solid = dd4hep::Polyhedra(ns.prepend(name), 1, -alpha1, 2 * alpha1, pgonZ, pgonRmin, pgonRmax);
544  dd4hep::Volume glog(solid.name(), solid, matter);
545 #ifdef EDM_ML_DEBUG
546  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << solid.name() << " (Layer " << i << ") Polyhedra made of "
547  << matter.name() << " with 1 sector from " << convertRadToDeg(-alpha1) << " to "
548  << convertRadToDeg(alpha1) << " and with " << nsec << " sections";
549  for (unsigned int k = 0; k < pgonZ.size(); k++)
550  edm::LogVerbatim("HCalGeom") << "\t\t" << cms::convert2mm(pgonZ[k]) << "\t" << cms::convert2mm(pgonRmin[k])
551  << "\t" << cms::convert2mm(pgonRmax[k]);
552 #endif
553 
554  seclogic.placeVolume(glog, layerId[i]);
555 #ifdef EDM_ML_DEBUG
556  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << glog.name() << " number " << layerId[i]
557  << " positioned in " << seclogic.name() << " at (0,0,0) with no rotation";
558 #endif
559  constructInsideLayers(glog,
560  layerLabel[i],
561  layerId[i],
562  layerAbsorb[i],
563  rin,
564  layerD1[i],
565  alpha1,
566  layerD2[i],
567  layerAlpha[i],
568  layerT1[i],
569  layerT2[i],
570  ns);
571  rin = rout;
572  }
573  }
574 
576  const std::string& nm,
577  int id,
578  int nAbs,
579  double rin,
580  double d1,
581  double alpha1,
582  double d2,
583  double alpha2,
584  double t1,
585  double t2,
586  cms::DDNamespace& ns) {
587 #ifdef EDM_ML_DEBUG
588  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: \t\tInside layer " << id << "...";
589 #endif
590 
592  //Pointers to the Rotation Matrices and to the Materials
593  dd4hep::Rotation3D rot = getRotation(detRot, rotns, ns);
594 
595  std::string nam0 = nm + "In";
596  std::string name = idName + nam0;
597  dd4hep::Material matter = ns.material(detMat);
598 
599  dd4hep::Solid solid;
600  dd4hep::Volume glog, mother;
601  double rsi, dx, dy, dz, x, y;
602  int i, in;
603  //Two lower volumes
604  if (alpha1 > 0) {
605  rsi = rin + d1;
606  in = 0;
607  for (i = 0; i < rzones - 1; i++) {
608  if (rsi >= rmax[i])
609  in = i + 1;
610  }
611  dx = 0.5 * t1;
612  dy = 0.5 * rsi * (tan(alpha1) - tan(alpha2));
613  dz = 0.5 * (zoff[in] + rsi * ttheta[in]);
614  x = rsi + dx;
615  y = 0.5 * rsi * (tan(alpha1) + tan(alpha2));
616  dd4hep::Position r11(x, y, dz);
617  dd4hep::Position r12(x, -y, dz);
618 
619  solid = dd4hep::Box(ns.prepend(name + "1"), dx, dy, dz);
620 #ifdef EDM_ML_DEBUG
621  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << solid.name() << " Box made of " << matter.name()
622  << " of dimensions " << cms::convert2mm(dx) << ", " << cms::convert2mm(dy) << ", "
623  << cms::convert2mm(dz);
624 #endif
625  glog = dd4hep::Volume(solid.name(), solid, matter);
626 
627  if (nAbs != 0) {
628  mother = constructSideLayer(laylog, name, nAbs, rin, alpha1, ns);
629  } else {
630  mother = laylog;
631  }
632  mother.placeVolume(glog, idOffset + 1, r11);
633  mother.placeVolume(glog, idOffset + 2, dd4hep::Transform3D(rot, r12));
634 #ifdef EDM_ML_DEBUG
635  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << glog.name() << " Number " << (idOffset + 1)
636  << " positioned in " << mother.name() << " at (" << cms::convert2mm(x) << ","
637  << cms::convert2mm(y) << "," << cms::convert2mm(dz) << ") with no rotation\n"
638  << "DDHCalBarrelAlgo: " << glog.name() << " Number " << (idOffset + 2)
639  << " positioned in " << mother.name() << " at (" << cms::convert2mm(x) << ","
640  << -cms::convert2mm(y) << "," << cms::convert2mm(dz) << ") with " << rot;
641 #endif
642  //Constructin the plastics and scintillators inside
643  constructInsideDetectors(glog, nam0 + "1", id, dx, dy, dz, 1, ns);
644  }
645 
646  //Upper volume
647  rsi = rin + d2;
648  in = 0;
649  for (i = 0; i < rzones - 1; i++) {
650  if (rsi >= rmax[i])
651  in = i + 1;
652  }
653  dx = 0.5 * t2;
654  dy = 0.5 * rsi * tan(alpha2);
655  dz = 0.5 * (zoff[in] + rsi * ttheta[in]);
656  x = rsi + dx;
657  dd4hep::Position r21(x, dy, dz);
658  dd4hep::Position r22(x, -dy, dz);
659 
660  solid = dd4hep::Box(ns.prepend(name + "2"), dx, dy, dz);
661 #ifdef EDM_ML_DEBUG
662  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << solid.name() << " Box made of " << matter.name()
663  << " of dimensions " << cms::convert2mm(dx) << ", " << cms::convert2mm(dy) << ", "
664  << cms::convert2mm(dz);
665 #endif
666  glog = dd4hep::Volume(solid.name(), solid, matter);
667 
668  if (nAbs < 0) {
669  mother = constructMidLayer(laylog, name, rin, alpha1, ns);
670  } else {
671  mother = laylog;
672  }
673  mother.placeVolume(glog, idOffset + 3, r21);
674  mother.placeVolume(glog, idOffset + 4, dd4hep::Transform3D(rot, r22));
675 #ifdef EDM_ML_DEBUG
676  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << glog.name() << " Number " << (idOffset + 3)
677  << " positioned in " << mother.name() << " at (" << cms::convert2mm(x) << ","
678  << cms::convert2mm(dy) << "," << cms::convert2mm(dz)
679  << ") with no rotation\nDDHCalBarrelAlgo: " << glog.name() << " Number "
680  << (idOffset + 4) << " positioned in " << mother.name() << " at ("
681  << cms::convert2mm(x) << "," << -cms::convert2mm(dy) << "," << cms::convert2mm(dz)
682  << ") with " << rot;
683 #endif
684  //Constructin the plastics and scintillators inside
685  constructInsideDetectors(glog, nam0 + "2", id, dx, dy, dz, 2, ns);
686  }
687 
689  dd4hep::Volume& laylog, const std::string& nm, int nAbs, double rin, double alpha, cms::DDNamespace& ns) {
690  //Extra absorber layer
691  int k = abs(nAbs) - 1;
692  std::string namek = nm + "Side";
693  double rsi = rin + sideD[k];
694  int in = 0;
695  for (int i = 0; i < rzones - 1; i++) {
696  if (rsi >= rmax[i])
697  in = i + 1;
698  }
699  std::vector<double> pgonZ, pgonRmin, pgonRmax;
700  // index 0
701  pgonZ.emplace_back(0.0);
702  pgonRmin.emplace_back(rsi);
703  pgonRmax.emplace_back(rsi + sideT[k]);
704  // index 1
705  pgonZ.emplace_back(zoff[in] + rsi * ttheta[in]);
706  pgonRmin.emplace_back(rsi);
707  pgonRmax.emplace_back(pgonRmax[0]);
708  // index 2
709  pgonZ.emplace_back(zoff[in] + pgonRmax[0] * ttheta[in]);
710  pgonRmin.emplace_back(pgonRmax[1]);
711  pgonRmax.emplace_back(pgonRmax[1]);
712  dd4hep::Solid solid = dd4hep::Polyhedra(ns.prepend(namek), 1, -alpha, 2 * alpha, pgonZ, pgonRmin, pgonRmax);
713  dd4hep::Material matter = ns.material(sideMat[k]);
714  dd4hep::Volume glog(solid.name(), solid, matter);
715 #ifdef EDM_ML_DEBUG
716  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << solid.name() << " Polyhedra made of " << sideMat[k]
717  << " with 1 sector from " << convertRadToDeg(-alpha) << " to "
718  << convertRadToDeg(alpha) << " and with " << pgonZ.size() << " sections";
719  for (unsigned int ii = 0; ii < pgonZ.size(); ii++)
720  edm::LogVerbatim("HCalGeom") << "\t\tZ = " << cms::convert2mm(pgonZ[ii])
721  << "\tRmin = " << cms::convert2mm(pgonRmin[ii])
722  << "\tRmax = " << cms::convert2mm(pgonRmax[ii]);
723 #endif
724 
725  laylog.placeVolume(glog, 1);
726 #ifdef EDM_ML_DEBUG
727  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << glog.name() << " Number 1 positioned in " << laylog.name()
728  << " at (0,0,0) with no rotation";
729 #endif
730  if (nAbs < 0) {
731  dd4hep::Volume mother = glog;
732  double rmid = pgonRmax[0];
733  for (int i = 0; i < nSideAbs; i++) {
734  double alpha1 = atan(sideAbsW[i] / rmid);
735  if (alpha1 > 0) {
736  std::string name = namek + sideAbsName[i];
737  solid = dd4hep::Polyhedra(ns.prepend(name), 1, -alpha1, 2 * alpha1, pgonZ, pgonRmin, pgonRmax);
738  dd4hep::Material matter = ns.material(sideAbsMat[i]);
739  dd4hep::Volume log(solid.name(), solid, matter);
740 #ifdef EDM_ML_DEBUG
741  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << solid.name() << " Polyhedra made of " << sideAbsMat[i]
742  << " with 1 sector from " << convertRadToDeg(-alpha1) << " to "
743  << convertRadToDeg(alpha1) << " and with " << pgonZ.size() << " sections";
744  for (unsigned int ii = 0; ii < pgonZ.size(); ii++)
745  edm::LogVerbatim("HCalGeom") << "\t\tZ = " << cms::convert2mm(pgonZ[ii])
746  << "\tRmin = " << cms::convert2mm(pgonRmin[ii])
747  << "\tRmax = " << cms::convert2mm(pgonRmax[ii]);
748 #endif
749 
750  mother.placeVolume(log, 1);
751 #ifdef EDM_ML_DEBUG
752  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << log.name() << " Number 1 positioned in "
753  << mother.name() << " at (0,0,0) with no rotation";
754 #endif
755  mother = log;
756  }
757  }
758  }
759  return glog;
760  }
761 
763  dd4hep::Volume laylog, const std::string& nm, double rin, double alpha, cms::DDNamespace& ns) {
764  dd4hep::Solid solid;
765  dd4hep::Volume log, glog;
766  std::string name = nm + "Mid";
767  for (int k = 0; k < nAbsorber; k++) {
768  std::string namek = name + absorbName[k];
769  double rsi = rin + absorbD[k];
770  int in = 0;
771  for (int i = 0; i < rzones - 1; i++) {
772  if (rsi >= rmax[i])
773  in = i + 1;
774  }
775  std::vector<double> pgonZ, pgonRmin, pgonRmax;
776  // index 0
777  pgonZ.emplace_back(0.0);
778  pgonRmin.emplace_back(rsi);
779  pgonRmax.emplace_back(rsi + absorbT[k]);
780  // index 1
781  pgonZ.emplace_back(zoff[in] + rsi * ttheta[in]);
782  pgonRmin.emplace_back(rsi);
783  pgonRmax.emplace_back(pgonRmax[0]);
784  // index 2
785  pgonZ.emplace_back(zoff[in] + pgonRmax[0] * ttheta[in]);
786  pgonRmin.emplace_back(pgonRmax[1]);
787  pgonRmax.emplace_back(pgonRmax[1]);
788  solid = dd4hep::Polyhedra(ns.prepend(namek), 1, -alpha, 2 * alpha, pgonZ, pgonRmin, pgonRmax);
789  dd4hep::Material matter = ns.material(absorbMat[k]);
790  log = dd4hep::Volume(solid.name(), solid, matter);
791 #ifdef EDM_ML_DEBUG
792  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << solid.name() << " Polyhedra made of " << matter.name()
793  << " with 1 sector from " << convertRadToDeg(-alpha) << " to "
794  << convertRadToDeg(alpha) << " and with " << pgonZ.size() << " sections";
795  for (unsigned int ii = 0; ii < pgonZ.size(); ii++)
796  edm::LogVerbatim("HCalGeom") << "\t\tZ = " << cms::convert2mm(pgonZ[ii])
797  << "\tRmin = " << cms::convert2mm(pgonRmin[ii])
798  << "\tRmax = " << cms::convert2mm(pgonRmax[ii]);
799 #endif
800 
801  laylog.placeVolume(log, 1);
802 #ifdef EDM_ML_DEBUG
803  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << log.name() << " Number 1 positioned in " << laylog.name()
804  << " at (0,0,0) with no rotation";
805 #endif
806  if (k == 0) {
807  double rmin = pgonRmin[0];
808  double rmax = pgonRmax[0];
809  dd4hep::Volume mother = log;
810  for (int i = 0; i < 1; i++) {
811  double alpha1 = atan(midW[i] / rmin);
812  std::string namek = name + midName[i];
813  solid = dd4hep::Polyhedra(ns.prepend(namek), 1, -alpha1, 2 * alpha1, pgonZ, pgonRmin, pgonRmax);
814  dd4hep::Material matter1 = ns.material(midMat[i]);
815  log = dd4hep::Volume(solid.name(), solid, matter1);
816 #ifdef EDM_ML_DEBUG
817  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << solid.name() << " Polyhedra made of "
818  << matter1.name() << " with 1 sector from " << convertRadToDeg(-alpha1) << " to "
819  << convertRadToDeg(alpha1) << " and with " << pgonZ.size() << " sections";
820  for (unsigned int ii = 0; ii < pgonZ.size(); ii++)
821  edm::LogVerbatim("HCalGeom") << "\t\tZ = " << cms::convert2mm(pgonZ[ii])
822  << "\tRmin = " << cms::convert2mm(pgonRmin[ii])
823  << "\tRmax = " << cms::convert2mm(pgonRmax[ii]);
824 #endif
825 
826  mother.placeVolume(log, 1);
827 #ifdef EDM_ML_DEBUG
828  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << log.name() << " Number 1 positioned in "
829  << mother.name() << " at (0,0,0) with no rotation";
830 #endif
831  mother = log;
832  }
833 
834  // Now the layer with detectors
835  double rmid = rmin + middleD;
836  pgonRmin[0] = rmid;
837  pgonRmax[0] = rmax;
838  pgonRmin[1] = rmid;
839  pgonRmax[1] = rmax;
840  pgonZ[1] = zoff[in] + rmid * ttheta[in];
841  pgonRmin[2] = rmax;
842  pgonRmax[2] = rmax;
843  pgonZ[2] = zoff[in] + rmax * ttheta[in];
844  double alpha1 = atan(middleW / rmin);
845  solid = dd4hep::Polyhedra(ns.prepend(name), 1, -alpha1, 2 * alpha1, pgonZ, pgonRmin, pgonRmax);
846  dd4hep::Material matter1 = ns.material(middleMat);
847  glog = dd4hep::Volume(solid.name(), solid, matter1);
848 #ifdef EDM_ML_DEBUG
849  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << solid.name() << " Polyhedra made of " << matter1.name()
850  << " with 1 sector from " << convertRadToDeg(-alpha1) << " to "
851  << convertRadToDeg(alpha1) << " and with " << pgonZ.size() << " sections";
852  for (unsigned int ii = 0; ii < pgonZ.size(); ii++)
853  edm::LogVerbatim("HCalGeom") << "\t\tZ = " << cms::convert2mm(pgonZ[ii])
854  << "\tRmin = " << cms::convert2mm(pgonRmin[ii])
855  << "\tRmax = " << cms::convert2mm(pgonRmax[ii]);
856 #endif
857 
858  mother.placeVolume(glog, 1);
859 #ifdef EDM_ML_DEBUG
860  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << glog.name() << " Number 1 positioned in "
861  << mother.name() << " at (0,0,0) with no rotation";
862 #endif
863  // Now the remaining absorber layers
864  for (int i = 1; i < nMidAbs; i++) {
865  namek = name + midName[i];
866  rmid = rmin + midT[i];
867  pgonRmin[0] = rmin;
868  pgonRmax[0] = rmid;
869  pgonRmin[1] = rmin;
870  pgonRmax[1] = rmid;
871  pgonZ[1] = zoff[in] + rmin * ttheta[in];
872  pgonRmin[2] = rmid;
873  pgonRmax[2] = rmid;
874  pgonZ[2] = zoff[in] + rmid * ttheta[in];
875  alpha1 = atan(midW[i] / rmin);
876  solid = dd4hep::Polyhedra(ns.prepend(namek), 1, -alpha1, 2 * alpha1, pgonZ, pgonRmin, pgonRmax);
877  dd4hep::Material matter2 = ns.material(midMat[i]);
878  log = dd4hep::Volume(solid.name(), solid, matter2);
879 #ifdef EDM_ML_DEBUG
880  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << solid.name() << " Polyhedra made of "
881  << matter2.name() << " with 1 sector from " << convertRadToDeg(-alpha1) << " to "
882  << convertRadToDeg(alpha1) << " and with " << pgonZ.size() << " sections";
883  for (unsigned int ii = 0; ii < pgonZ.size(); ii++)
884  edm::LogVerbatim("HCalGeom") << "\t\tZ = " << cms::convert2mm(pgonZ[ii])
885  << "\tRmin = " << cms::convert2mm(pgonRmin[ii])
886  << "\tRmax = " << cms::convert2mm(pgonRmax[ii]);
887 #endif
888 
889  mother.placeVolume(log, i);
890 #ifdef EDM_ML_DEBUG
891  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << log.name() << " Number " << i << " positioned in "
892  << mother.name() << " at (0,0,0) with no rotation";
893 #endif
894  mother = log;
895  }
896  }
897  }
898  return glog;
899  }
900 
902  const std::string& name,
903  int id,
904  double dx,
905  double dy,
906  double dz,
907  int type,
908  cms::DDNamespace& ns) {
909 #ifdef EDM_ML_DEBUG
910  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: \t\tInside detector " << id << "...";
911 #endif
912 
913  dd4hep::Material plmatter = ns.material(detMatPl);
914  dd4hep::Material scmatter = ns.material(detMatSc);
915  std::string plname = DDSplit(detector.name()).first + "Plastic_";
916  std::string scname = idName + "Scintillator" + name;
917 
918  id--;
919  dd4hep::Solid solid;
920  dd4hep::Volume glog;
921  double wid, y = 0;
922  double dx1, dx2, shiftX;
923 
924  if (type == 1) {
925  wid = 0.5 * detWidth1[id];
926  dx1 = 0.5 * detT11[id];
927  dx2 = 0.5 * detT21[id];
928  shiftX = detdP1[id];
929  if (detPosY[id] > 0)
930  y = -dy + wid;
931  } else {
932  wid = 0.5 * detWidth2[id];
933  dx1 = 0.5 * detT12[id];
934  dx2 = 0.5 * detT22[id];
935  shiftX = detdP2[id];
936  }
937 
938  solid = dd4hep::Box(ns.prepend(plname + "1"), dx1, wid, dz);
939  glog = dd4hep::Volume(solid.name(), solid, plmatter);
940 #ifdef EDM_ML_DEBUG
941  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << solid.name() << " Box made of " << plmatter.name()
942  << " of dimensions " << cms::convert2mm(dx1) << ", " << cms::convert2mm(wid) << ", "
943  << cms::convert2mm(dz);
944 #endif
945 
946  double x = shiftX + dx1 - dx;
947  detector.placeVolume(glog, 1, dd4hep::Position(x, y, 0));
948 #ifdef EDM_ML_DEBUG
949  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << glog.name() << " Number 1 positioned in " << detector.name()
950  << " at (" << cms::convert2mm(x) << "," << cms::convert2mm(y)
951  << ",0) with no rotation";
952 #endif
953  solid = dd4hep::Box(ns.prepend(scname), 0.5 * detTsc[id], wid, dz);
954  glog = dd4hep::Volume(solid.name(), solid, scmatter);
955 #ifdef EDM_ML_DEBUG
956  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << solid.name() << " Box made of " << scmatter.name()
957  << " of dimensions " << cms::convert2mm(0.5 * detTsc[id]) << ", "
958  << cms::convert2mm(wid) << ", " << cms::convert2mm(dz);
959 #endif
960 
961  x += dx1 + 0.5 * detTsc[id];
962  int copyNo = id * 10 + detType[id];
963  detector.placeVolume(glog, copyNo, dd4hep::Position(x, y, 0));
964 #ifdef EDM_ML_DEBUG
965  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << glog.name() << " Number " << copyNo << " positioned in "
966  << detector.name() << " at (" << cms::convert2mm(x) << "," << cms::convert2mm(y)
967  << ",0) with no rotation";
968 #endif
969  solid = dd4hep::Box(ns.prepend(plname + "2"), dx2, wid, dz);
970  glog = dd4hep::Volume(solid.name(), solid, plmatter);
971 #ifdef EDM_ML_DEBUG
972  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << solid.name() << " Box made of " << plmatter.name()
973  << " of dimensions " << cms::convert2mm(dx2) << ", " << cms::convert2mm(wid) << ", "
974  << cms::convert2mm(dz);
975 #endif
976 
977  x += 0.5 * detTsc[id] + dx2;
978  detector.placeVolume(glog, 1, dd4hep::Position(x, y, 0));
979 #ifdef EDM_ML_DEBUG
980  edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << glog.name() << " Number 1 positioned in " << detector.name()
981  << " at (" << cms::convert2mm(x) << "," << cms::convert2mm(y)
982  << ",0) with no rotation";
983 #endif
984  }
985 
986  dd4hep::Rotation3D getRotation(std::string& rotation, std::string& rotns, cms::DDNamespace& ns) {
987  std::string rot = (strchr(rotation.c_str(), NAMESPACE_SEP) == nullptr) ? (rotns + ":" + rotation) : rotation;
988 #ifdef EDM_ML_DEBUG
989  edm::LogVerbatim("HCalGeom") << "getRotation: " << rotation << ":" << rot << ":" << ns.rotation(rot);
990 #endif
991  return ns.rotation(rot);
992  }
993 };
994 
995 static long algorithm(dd4hep::Detector& /* description */, cms::DDParsingContext& ctxt, xml_h e) {
996  HcalBarrelAlgo hcalbarrelalgo(ctxt, e);
997 #ifdef EDM_ML_DEBUG
998  edm::LogVerbatim("HCalGeom") << "<<== End of DDHCalBarrelAlgo construction";
999 #endif
1000  return cms::s_executed;
1001 }
1002 
1003 // first argument is the type from the xml file
1004 DECLARE_DDCMS_DETELEMENT(DDCMS_hcal_DDHCalBarrelAlgo, algorithm)
std::vector< double > rmax
dd4hep::Volume constructMidLayer(dd4hep::Volume laylog, const std::string &nm, double rin, double alpha, cms::DDNamespace &ns)
Log< level::Info, true > LogVerbatim
std::string rotHalf
std::vector< double > sideAbsW
dd4hep::Rotation3D getRotation(std::string &rotation, std::string &rotns, cms::DDNamespace &ns)
const dd4hep::Rotation3D & rotation(const std::string &name) const
Definition: DDNamespace.cc:182
std::vector< int > detPosY
void constructInsideDetectors(dd4hep::Volume &detector, const std::string &name, int id, double dx, double dy, double dz, int type, cms::DDNamespace &ns)
std::vector< double > detWidth1
std::string detRot
std::string detMatPl
std::string rotns
std::vector< double > detdP2
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
constexpr NumType convert2mm(NumType length)
Definition: DDutils.h:7
std::string detMat
std::string genMaterial
std::string middleMat
HcalBarrelAlgo(cms::DDParsingContext &ctxt, xml_h &e)
std::vector< double > absorbD
dd4hep::Material material(const std::string &name) const
Definition: DDNamespace.cc:166
std::vector< std::string > sideAbsMat
std::vector< double > detT11
void constructInsideLayers(dd4hep::Volume &laylog, const std::string &nm, int id, int nAbs, double rin, double d1, double alpha1, double d2, double alpha2, double t1, double t2, cms::DDNamespace &ns)
std::vector< double > layerT1
#define DECLARE_DDCMS_DETELEMENT(name, func)
Definition: DDPlugins.h:25
std::vector< std::string > absorbMat
std::vector< std::string > midMat
std::vector< double > detT12
static constexpr long s_executed
std::vector< std::string > midName
std::vector< double > layerAlpha
std::vector< std::string > sideAbsName
std::string_view name() const
Definition: DDNamespace.h:79
std::vector< double > sideD
std::string detMatSc
std::vector< double > absorbT
static long algorithm(dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e)
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< double > detWidth2
std::vector< double > zoff
std::vector< int > detType
dd4hep::Volume constructSideLayer(dd4hep::Volume &laylog, const std::string &nm, int nAbs, double rin, double alpha, cms::DDNamespace &ns)
std::vector< double > detT22
std::string idNameSpace
std::string idName
dd4hep::Volume Volume
ii
Definition: cuy.py:589
std::vector< double > theta
std::vector< double > detT21
std::vector< int > layerAbsorb
std::vector< double > layerD1
std::vector< std::string > absorbName
std::vector< double > layerT2
std::vector< double > sideT
std::vector< double > detdP1
std::vector< std::string > layerMat
std::vector< double > layerGap
float x
std::vector< double > midT
std::vector< double > layerWidth
std::vector< double > midW
static constexpr float d1
std::vector< std::string > layerLabel
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
__shared__ uint32_t ntot
std::vector< double > detTsc
std::vector< double > layerD2
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition: DDNamespace.cc:276
std::vector< std::string > sideMat
std::vector< double > ttheta
std::string prepend(const std::string &) const
Definition: DDNamespace.cc:99
#define NAMESPACE_SEP
Definition: DDNamespace.h:92
std::vector< int > layerId