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