CMS 3D CMS Logo

DDHCalEndcapAlgo.cc
Go to the documentation of this file.
1 // File: DDHCalEndcapAlgo.cc
3 // adapted from CCal(G4)HcalEndcap.cc
4 // Description: Geometry factory class for Hcal Endcap
6 
7 #include <cmath>
8 #include <algorithm>
9 #include <string>
10 #include <vector>
11 
14 #include "DD4hep/DetFactoryHelper.h"
19 
20 //#define EDM_ML_DEBUG
21 using namespace angle_units::operators;
22 
24  std::string genMaterial; //General material
25  int nsectors; //Number of potenital straight edges
26  int nsectortot; //Number of straight edges (actual)
27  int nEndcap; //Number of endcaps
28  std::vector<int> eModule; //Modules to be present in part i (?)
29  std::string rotHalf; //Rotation matrix for half
30  std::string rotation; //Rotation matrix to place in mother
31  double zShift; //needed for TB setup (move HE)
32  double zFront; //Z of the front section
33  double zEnd; //Outer Z of the HE
34  double ziNose; //Starting Z of the nose
35  double ziL0Nose; //Starting Z of layer 0 at nose
36  double ziBody; //Starting Z of the body
37  double ziL0Body; //Starting Z of layer 0 at body
38  double ziKink; //Position of the kink point
39  double z0Beam; //Position of gap front along z-axis
40  double z1Beam; //Position of gap end along z-axis
41  double ziDip; //Starting Z of dipped part of body
42  double dzStep; //Width in Z of a layer
43  double dzShift; //Shift in Z for HE
44  double zShiftHac2; //needed for TB (remove part Hac2)
45  double rout; //Outer R of the HE
46  double riKink; //Inner radius at kink point
47  double riDip; //Inner radius at the dip point
48  double roDip; //Outer radius at the dip point
49  double heboxDepth; //Depth of the HE box
50  double drEnd; //Shift in R for the end absorber
51  double angTop; //Angle of top end of HE
52  double angBot; //Angle of the bottom end of HE
53  double angGap; //Gap angle (in degrees)
54  double slope; //Slope of the gap on HE side
55  std::string absMat; //Absorber material
56  int modules; //Number of modules
57  std::vector<std::string> modName; //Name
58  std::vector<std::string> modMat; //Material
59  std::vector<int> modType; //Type (0/1 for front/standard)
60  std::vector<int> sectionModule; //Number of sections in a module
61  std::vector<int> layerN; //Number of layers
62  std::vector<int> layerN0; //Layer numbers in section 0
63  std::vector<int> layerN1; //Layer numbers in section 1
64  std::vector<int> layerN2; //Layer numbers in section 2
65  std::vector<int> layerN3; //Layer numbers in section 3
66  std::vector<int> layerN4; //Layer numbers in section 4
67  std::vector<int> layerN5; //Layer numbers in section 5
68  std::vector<double> thick; //Thickness of absorber/air
69  std::vector<double> trimLeft; //Trimming of left layers in module
70  std::vector<double> trimRight; //Trimming of right layers in module
71  std::vector<double> zminBlock; //Minimum Z
72  std::vector<double> zmaxBlock; //Maximum Z
73  std::vector<double> rinBlock1; //Inner Radius
74  std::vector<double> routBlock1; //Outer Radius at zmin
75  std::vector<double> rinBlock2; //Inner Radius
76  std::vector<double> routBlock2; //Outer Radius at zmax
77  int phiSections; //Number of phi sections
78  std::vector<std::string> phiName; //Name of Phi sections
79  int layers; //Number of layers
80  std::vector<std::string> layerName; //Layer Names
81  std::vector<int> layerType; //Detector type in each layer
82  std::vector<double> layerT; //Layer thickness (plastic + scint.)
83  std::vector<double> scintT; //Scintillator thickness
84  std::string plastMat; //Plastic material
85  std::string scintMat; //Scintillator material
86  std::string rotmat; //Rotation matrix for positioning
87  std::string idName; //Name of the "parent" volume.
88  int idOffset; // Geant4 ID's... = 4000;
89  double tolPos, tolAbs; //Tolerances
90 
91  HCalEndcapAlgo() = delete;
92 
94  cms::DDNamespace ns(ctxt, e, true);
96 
97  genMaterial = args.value<std::string>("MaterialName");
98  rotation = args.value<std::string>("Rotation");
99  nsectors = args.value<int>("Sector");
100  nsectortot = args.value<int>("SectorTot");
101  nEndcap = args.value<int>("Endcap");
102  rotHalf = args.value<std::string>("RotHalf");
103  zShift = args.value<double>("ZShift");
104  zFront = args.value<double>("ZFront");
105  zEnd = args.value<double>("ZEnd");
106  ziNose = args.value<double>("ZiNose");
107  ziL0Nose = args.value<double>("ZiL0Nose");
108  ziBody = args.value<double>("ZiBody");
109  ziL0Body = args.value<double>("ZiL0Body");
110  z0Beam = args.value<double>("Z0Beam");
111  ziDip = args.value<double>("ZiDip");
112  dzStep = args.value<double>("DzStep");
113  zShiftHac2 = args.value<double>("ZShiftHac2");
114  double gap = args.value<double>("Gap");
115  double z1 = args.value<double>("Z1");
116  double r1 = args.value<double>("R1");
117  rout = args.value<double>("Rout");
118  heboxDepth = args.value<double>("HEboxDepth");
119  drEnd = args.value<double>("DrEnd");
120  double etamin = args.value<double>("Etamin");
121  angBot = args.value<double>("AngBot");
122  angGap = args.value<double>("AngGap");
123 #ifdef EDM_ML_DEBUG
124  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: General material " << genMaterial << "\tSectors " << nsectors
125  << ", " << nsectortot << "\tEndcaps " << nEndcap << "\tRotation matrix for half "
126  << rotHalf << "\n\tzFront " << cms::convert2mm(zFront) << " zEnd "
127  << cms::convert2mm(zEnd) << " ziNose " << cms::convert2mm(ziNose) << " ziL0Nose "
128  << cms::convert2mm(ziL0Nose) << " ziBody " << cms::convert2mm(ziBody) << " ziL0Body "
129  << cms::convert2mm(ziL0Body) << " z0Beam " << cms::convert2mm(z0Beam) << " ziDip "
130  << cms::convert2mm(ziDip) << " dzStep " << cms::convert2mm(dzStep) << " Gap "
131  << cms::convert2mm(gap) << " z1 " << cms::convert2mm(z1) << "\n\tr1 "
132  << cms::convert2mm(r1) << " rout " << cms::convert2mm(rout) << " HeboxDepth "
133  << cms::convert2mm(heboxDepth) << " drEnd " << cms::convert2mm(drEnd) << "\tetamin "
134  << etamin << " Bottom angle " << angBot << " Gap angle " << angGap << " Z-Shift "
135  << cms::convert2mm(zShift) << " " << cms::convert2mm(zShiftHac2);
136 #endif
137 
138  //Derived quantities
139  angTop = 2.0 * atan(exp(-etamin));
140  slope = tan(angGap);
141  z1Beam = z1 - r1 / slope;
142  ziKink = z1Beam + rout / slope;
143  riKink = ziKink * tan(angBot);
144  riDip = ziDip * tan(angBot);
145  roDip = rout - heboxDepth;
146  dzShift = (z1Beam - z0Beam) - gap / sin(angGap);
147 #ifdef EDM_ML_DEBUG
148  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: angTop " << convertRadToDeg(angTop) << "\tSlope " << slope
149  << "\tDzShift " << cms::convert2mm(dzShift) << "\n\tz1Beam " << cms::convert2mm(z1Beam)
150  << "\tziKink" << cms::convert2mm(ziKink) << "\triKink " << cms::convert2mm(riKink)
151  << "\triDip " << cms::convert2mm(riDip) << "\n\troDip " << cms::convert2mm(roDip)
152  << "\tRotation " << rotation;
153 #endif
154 
156  //Modules
157  absMat = args.value<std::string>("AbsMat");
158  modules = args.value<int>("Modules");
159 #ifdef EDM_ML_DEBUG
160  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: Number of modules " << modules << " and absorber material "
161  << absMat;
162 #endif
163 
164  modName = args.value<std::vector<std::string> >("ModuleName");
165  modMat = args.value<std::vector<std::string> >("ModuleMat");
166  modType = args.value<std::vector<int> >("ModuleType");
167  sectionModule = args.value<std::vector<int> >("SectionModule");
168  thick = args.value<std::vector<double> >("ModuleThick");
169  trimLeft = args.value<std::vector<double> >("TrimLeft");
170  trimRight = args.value<std::vector<double> >("TrimRight");
171  eModule = args.value<std::vector<int> >("EquipModule");
172  layerN = args.value<std::vector<int> >("LayerN");
173  layerN0 = args.value<std::vector<int> >("LayerN0");
174  layerN1 = args.value<std::vector<int> >("LayerN1");
175  layerN2 = args.value<std::vector<int> >("LayerN2");
176  layerN3 = args.value<std::vector<int> >("LayerN3");
177  layerN4 = args.value<std::vector<int> >("LayerN4");
178  layerN5 = args.value<std::vector<int> >("LayerN5");
179 #ifdef EDM_ML_DEBUG
180  for (int i = 0; i < modules; i++) {
181  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << modName[i] << " type " << modType[i] << " Sections "
182  << sectionModule[i] << " thickness of absorber/air " << cms::convert2mm(thick[i])
183  << " trim " << cms::convert2mm(trimLeft[i]) << ", " << cms::convert2mm(trimRight[i])
184  << " equip module " << eModule[i] << " with " << layerN[i] << " layers";
185  if (i == 0) {
186  for (int j = 0; j < layerN[i]; j++) {
187  edm::LogVerbatim("HCalGeom") << "\t " << layerN0[j] << "/" << layerN0[j + 1];
188  }
189  } else if (i == 1) {
190  for (int j = 0; j < layerN[i]; j++) {
191  edm::LogVerbatim("HCalGeom") << "\t " << layerN1[j] << "/" << layerN1[j + 1];
192  }
193  } else if (i == 2) {
194  for (int j = 0; j < layerN[i]; j++) {
195  edm::LogVerbatim("HCalGeom") << "\t " << layerN2[j];
196  }
197  } else if (i == 3) {
198  for (int j = 0; j < layerN[i]; j++) {
199  edm::LogVerbatim("HCalGeom") << "\t " << layerN3[j];
200  }
201  } else if (i == 4) {
202  for (int j = 0; j < layerN[i]; j++) {
203  edm::LogVerbatim("HCalGeom") << "\t " << layerN4[j];
204  }
205  } else if (i == 5) {
206  for (int j = 0; j < layerN[i]; j++) {
207  edm::LogVerbatim("HCalGeom") << "\t " << layerN5[j];
208  }
209  }
210  }
211 #endif
212 
214  //Layers
215  phiSections = args.value<int>("PhiSections");
216  phiName = args.value<std::vector<std::string> >("PhiName");
217  layers = args.value<int>("Layers");
218  layerName = args.value<std::vector<std::string> >("LayerName");
219  layerType = args.value<std::vector<int> >("LayerType");
220  layerT = args.value<std::vector<double> >("LayerT");
221  scintT = args.value<std::vector<double> >("ScintT");
222  scintMat = args.value<std::string>("ScintMat");
223  plastMat = args.value<std::string>("PlastMat");
224  rotmat = args.value<std::string>("RotMat");
225 #ifdef EDM_ML_DEBUG
226  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: Phi Sections " << phiSections;
227  for (int i = 0; i < phiSections; i++)
228  edm::LogVerbatim("HCalGeom") << "\tName[" << i << "] : " << phiName[i];
229  edm::LogVerbatim("HCalGeom") << "\tPlastic: " << plastMat << "\tScintillator: " << scintMat << "\tRotation matrix "
230  << rotmat << "\n\tNumber of layers " << layers;
231  for (int i = 0; i < layers; i++) {
232  edm::LogVerbatim("HCalGeom") << "\t" << layerName[i] << "\tType " << layerType[i] << "\tThickness "
233  << cms::convert2mm(layerT[i]) << "\tScint.Thick " << cms::convert2mm(scintT[i]);
234  }
235 #endif
236 
238  // Derive bounding of the modules
239  int module = 0;
240  // Layer 0 (Nose)
241  if (modules > 0) {
242  zminBlock.emplace_back(ziL0Nose);
243  zmaxBlock.emplace_back(zminBlock[module] + layerT[0] + 0.5 * dzStep);
244  rinBlock1.emplace_back(zminBlock[module] * tan(angTop));
245  rinBlock2.emplace_back(zmaxBlock[module] * tan(angTop));
246  routBlock1.emplace_back((zminBlock[module] - z1Beam) * slope);
247  routBlock2.emplace_back((zmaxBlock[module] - z1Beam) * slope);
248  module++;
249  }
250  // Layer 0 (Body)
251  if (modules > 1) {
252  zminBlock.emplace_back(ziL0Body);
253  zmaxBlock.emplace_back(zminBlock[module] + layerT[0] + 0.5 * dzStep);
254  rinBlock1.emplace_back(zminBlock[module] * tan(angBot));
255  rinBlock2.emplace_back(zmaxBlock[module] * tan(angBot));
256  routBlock1.emplace_back(zminBlock[module] * tan(angTop));
257  routBlock2.emplace_back(zmaxBlock[module] * tan(angTop));
258  module++;
259  }
260  // Hac1
261  if (modules > 2) {
262  zminBlock.emplace_back(ziNose);
263  zmaxBlock.emplace_back(ziBody);
264  rinBlock1.emplace_back(zminBlock[module] * tan(angTop));
265  rinBlock2.emplace_back(zmaxBlock[module] * tan(angTop));
266  routBlock1.emplace_back((zminBlock[module] - z1Beam) * slope);
267  routBlock2.emplace_back((zmaxBlock[module] - z1Beam) * slope);
268  module++;
269  }
270  // Hac2
271  if (modules > 3) {
272  zminBlock.emplace_back(ziBody);
273  zmaxBlock.emplace_back(zminBlock[module] + layerN[3] * dzStep);
274  rinBlock1.emplace_back(zminBlock[module] * tan(angBot));
275  rinBlock2.emplace_back(zmaxBlock[module] * tan(angBot));
276  routBlock1.emplace_back((zmaxBlock[module - 1] - z1Beam) * slope);
277  routBlock2.emplace_back(rout);
278  module++;
279  }
280  // Hac3
281  if (modules > 4) {
282  zminBlock.emplace_back(zmaxBlock[module - 1]);
283  zmaxBlock.emplace_back(zminBlock[module] + layerN[4] * dzStep);
284  rinBlock1.emplace_back(zminBlock[module] * tan(angBot));
285  rinBlock2.emplace_back(zmaxBlock[module] * tan(angBot));
286  routBlock1.emplace_back(rout);
287  routBlock2.emplace_back(rout);
288  module++;
289  }
290  // Hac4
291  if (modules > 5) {
292  zminBlock.emplace_back(zmaxBlock[module - 1]);
293  zmaxBlock.emplace_back(zminBlock[module] + layerN[5] * dzStep);
294  rinBlock1.emplace_back(zminBlock[module] * tan(angBot));
295  rinBlock2.emplace_back(zmaxBlock[module] * tan(angBot));
296  routBlock1.emplace_back(rout);
297  routBlock2.emplace_back(roDip);
298  module++;
299  }
300 #ifdef EDM_ML_DEBUG
301  for (int i = 0; i < module; i++)
302  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: Module " << i << "\tZ/Rin/Rout "
303  << cms::convert2mm(zminBlock[i]) << ", " << cms::convert2mm(zmaxBlock[i]) << "/ "
304  << cms::convert2mm(rinBlock1[i]) << ", " << cms::convert2mm(rinBlock2[i]) << "/ "
305  << cms::convert2mm(routBlock1[i]) << ", " << cms::convert2mm(routBlock2[i]);
306 #endif
307 
308  idName = args.value<std::string>("MotherName");
309  idOffset = args.value<int>("IdOffset");
310 #ifdef EDM_ML_DEBUG
311  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: Parent " << args.parentName() << " idName " << idName
312  << " NameSpace " << ns.name() << " Offset " << idOffset;
313 #endif
314 
315  tolPos = args.value<double>("TolPos");
316  tolAbs = args.value<double>("TolAbs");
317 #ifdef EDM_ML_DEBUG
318  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: Tolerances - Positioning " << cms::convert2mm(tolPos)
319  << " Absorber " << cms::convert2mm(tolAbs);
320  edm::LogVerbatim("HCalGeom") << "==>> Constructing DDHCalEndcapAlgo...";
321 #endif
322 
323  dd4hep::Volume parent = ns.volume(args.parentName());
324  constructGeneralVolume(ns, parent);
325 #ifdef EDM_ML_DEBUG
326  edm::LogVerbatim("HCalGeom") << "<<== End of DDHCalEndcapAlgo construction ...";
327 #endif
328  }
329 
331 #ifdef EDM_ML_DEBUG
332  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: General volume...";
333 #endif
334 
335  bool proto = true;
336  for (int i = 0; i < 3; i++)
337  if (eModule[i] > 0)
338  proto = false;
339 
340  dd4hep::Rotation3D rot = getRotation(rotation, ns);
341 #ifdef EDM_ML_DEBUG
342  edm::LogVerbatim("HCalGeom") << " Rotation matrix " << rotation << " Rotation " << rot;
343 #endif
344 
345  dd4hep::Position r0(0, 0, zShift);
346  double alpha = (1._pi) / nsectors;
347  double dphi = nsectortot * (2._pi) / nsectors;
348 
350  //vertical walls are allowed in SolidPolyhedra
351  double delz = 0;
352 
353  std::vector<double> pgonZ, pgonRmin, pgonRmax;
354  if (proto) {
355  double zf = ziBody + zShiftHac2;
356  pgonZ.emplace_back(zf - dzShift);
357  pgonRmin.emplace_back(zf * tan(angBot));
358  pgonRmax.emplace_back((zf - z1Beam) * slope);
359  } else {
360  pgonZ.emplace_back(zFront - dzShift);
361  pgonRmin.emplace_back(zFront * tan(angTop));
362  pgonRmax.emplace_back((zFront - z1Beam) * slope);
363  pgonZ.emplace_back(ziL0Body - dzShift);
364  pgonRmin.emplace_back(ziL0Body * tan(angTop));
365  pgonRmax.emplace_back((ziL0Body - z1Beam) * slope);
366  pgonZ.emplace_back(ziL0Body - dzShift);
367  pgonRmin.emplace_back(ziL0Body * tan(angBot));
368  pgonRmax.emplace_back((ziL0Body - z1Beam) * slope);
369  }
370  pgonZ.emplace_back(ziKink - dzShift);
371  pgonRmin.emplace_back(riKink);
372  pgonRmax.emplace_back(rout);
373  pgonZ.emplace_back(ziDip - dzShift);
374  pgonRmin.emplace_back(riDip);
375  pgonRmax.emplace_back(rout);
376  pgonZ.emplace_back(ziDip - dzShift + delz);
377  pgonRmin.emplace_back(riDip);
378  pgonRmax.emplace_back(roDip);
379  pgonZ.emplace_back(zEnd - dzShift);
380  pgonRmin.emplace_back(zEnd * tan(angBot));
381  pgonRmax.emplace_back(roDip);
382  pgonZ.emplace_back(zEnd);
383  pgonRmin.emplace_back(zEnd * tan(angBot));
384  pgonRmax.emplace_back(roDip);
385 
386  std::string name("Null");
387  dd4hep::Solid solid = dd4hep::Polyhedra(ns.prepend(idName), nsectortot, -alpha, dphi, pgonZ, pgonRmin, pgonRmax);
388 #ifdef EDM_ML_DEBUG
389  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << solid.name() << " Polyhedra made of " << genMaterial
390  << " with " << nsectortot << " sectors from " << convertRadToDeg(-alpha) << " to "
391  << convertRadToDeg(-alpha + dphi) << " and with " << pgonZ.size() << " sections";
392  for (unsigned int i = 0; i < pgonZ.size(); i++)
393  edm::LogVerbatim("HCalGeom") << "\t\tZ = " << cms::convert2mm(pgonZ[i])
394  << "\tRmin = " << cms::convert2mm(pgonRmin[i])
395  << "\tRmax = " << cms::convert2mm(pgonRmax[i]);
396 #endif
397  dd4hep::Material matter = ns.material(genMaterial);
398  dd4hep::Volume genlogic(solid.name(), solid, matter);
399 
400  parent.placeVolume(genlogic, 1, dd4hep::Transform3D(rot, r0));
401 #ifdef EDM_ML_DEBUG
402  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << genlogic.name() << " number 1 positioned in "
403  << parent.name() << " at (0, 0, " << cms::convert2mm(zShift)
404  << ") with rotation: " << rot;
405 #endif
406 
407  if (nEndcap != 1) {
408  rot = getRotation(rotHalf, ns);
409  parent.placeVolume(genlogic, 2, dd4hep::Transform3D(rot, r0));
410 #ifdef EDM_ML_DEBUG
411  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << genlogic.name() << " number 2 "
412  << "positioned in " << parent.name() << " at (0, 0, " << cms::convert2mm(zShift)
413  << ") with rotation: " << rot;
414 #endif
415  }
416 
417  //Forward half
418  name = idName + "Front";
419  std::vector<double> pgonZMod, pgonRminMod, pgonRmaxMod;
420  for (unsigned int i = 0; i < (pgonZ.size() - 1); i++) {
421  pgonZMod.emplace_back(pgonZ[i] + dzShift);
422  pgonRminMod.emplace_back(pgonRmin[i]);
423  pgonRmaxMod.emplace_back(pgonRmax[i]);
424  }
425  solid = dd4hep::Polyhedra(ns.prepend(name), nsectortot, -alpha, dphi, pgonZMod, pgonRminMod, pgonRmaxMod);
426 #ifdef EDM_ML_DEBUG
427  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << solid.name() << " Polyhedra made of " << genMaterial
428  << " with " << nsectortot << " sectors from " << convertRadToDeg(-alpha) << " to "
429  << convertRadToDeg(-alpha + dphi) << " and with " << pgonZMod.size() << " sections ";
430  for (unsigned int i = 0; i < pgonZMod.size(); i++)
431  edm::LogVerbatim("HCalGeom") << "\t\tZ = " << cms::convert2mm(pgonZMod[i])
432  << "\tRmin = " << cms::convert2mm(pgonRminMod[i])
433  << "\tRmax = " << cms::convert2mm(pgonRmaxMod[i]);
434 #endif
435 
436  dd4hep::Volume genlogich(solid.name(), solid, matter);
437  ns.addVolumeNS(genlogich);
438  genlogic.placeVolume(genlogich, 1, dd4hep::Position(0, 0, -dzShift));
439 #ifdef EDM_ML_DEBUG
440  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << genlogich.name() << " number 1 positioned in "
441  << genlogic.name() << " at (0,0," << -cms::convert2mm(dzShift) << ") with no rotation";
442 #endif
443 
444  //Construct sector (from -alpha to +alpha)
445  name = idName + "Module";
446  solid = dd4hep::Polyhedra(ns.prepend(name), 1, -alpha, 2 * alpha, pgonZMod, pgonRminMod, pgonRmaxMod);
447 #ifdef EDM_ML_DEBUG
448  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << solid.name() << " Polyhedra made of " << genMaterial
449  << " with 1 sector from " << convertRadToDeg(-alpha) << " to "
450  << convertRadToDeg(alpha) << " and with " << pgonZMod.size() << " sections";
451  for (unsigned int i = 0; i < pgonZMod.size(); i++)
452  edm::LogVerbatim("HCalGeom") << "\t\tZ = " << cms::convert2mm(pgonZMod[i])
453  << "\tRmin = " << cms::convert2mm(pgonRminMod[i])
454  << "\tRmax = " << cms::convert2mm(pgonRmaxMod[i]);
455 #endif
456 
457  dd4hep::Volume seclogic(solid.name(), solid, matter);
458  for (int ii = 0; ii < nsectortot; ii++) {
459  double phi = ii * 2 * alpha;
460  dd4hep::Rotation3D rot0;
461  if (phi != 0) {
462  rot0 = dd4hep::RotationZ(phi);
463 #ifdef EDM_ML_DEBUG
464  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: Creating a new rotation \t 90," << convertRadToDeg(phi)
465  << ", 90," << convertRadToDeg(phi + 90._deg) << ", 0, 0";
466 #endif
467  }
468  genlogich.placeVolume(seclogic, ii + 1, rot0);
469 #ifdef EDM_ML_DEBUG
470  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << seclogic.name() << " number " << (ii + 1)
471  << " positioned in " << genlogich.name() << " at (0, 0, 0) with rotation: " << rot0;
472 #endif
473  }
474 
475  //Construct the things inside the sector
476  constructInsideSector(ns, seclogic);
477 
478  //Backward half
479  name = idName + "Back";
480  std::vector<double> pgonZBack, pgonRminBack, pgonRmaxBack;
481  pgonZBack.emplace_back(zEnd - dzShift);
482  pgonRminBack.emplace_back(pgonZBack[0] * tan(angBot) + drEnd);
483  pgonRmaxBack.emplace_back(roDip);
484  pgonZBack.emplace_back(zEnd);
485  pgonRminBack.emplace_back(pgonZBack[1] * tan(angBot) + drEnd);
486  pgonRmaxBack.emplace_back(roDip);
487  solid = dd4hep::Polyhedra(ns.prepend(name), nsectortot, -alpha, dphi, pgonZBack, pgonRminBack, pgonRmaxBack);
488 #ifdef EDM_ML_DEBUG
489  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << solid.name() << " Polyhedra made of " << absMat << " with "
490  << nsectortot << " sectors from " << convertRadToDeg(-alpha) << " to "
491  << convertRadToDeg(-alpha + dphi) << " and with " << pgonZBack.size() << " sections";
492  for (unsigned int i = 0; i < pgonZBack.size(); i++)
493  edm::LogVerbatim("HCalGeom") << "\t\tZ = " << cms::convert2mm(pgonZBack[i])
494  << "\tRmin = " << cms::convert2mm(pgonRminBack[i])
495  << "\tRmax = " << cms::convert2mm(pgonRmaxBack[i]);
496 #endif
497 
498  dd4hep::Material absMatter = ns.material(absMat);
499  dd4hep::Volume glog(solid.name(), solid, absMatter);
500  genlogic.placeVolume(glog, 1);
501 #ifdef EDM_ML_DEBUG
502  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << glog.name() << " number 1 positioned in " << genlogic.name()
503  << " at (0,0,0) with no rotation";
504 #endif
505  }
506 
508 #ifdef EDM_ML_DEBUG
509  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: Modules (" << modules << ") ...";
510 #endif
511 
512  double alpha = (1._pi) / nsectors;
513  for (int i = 0; i < modules; i++) {
514  std::string name = idName + modName[i];
515  dd4hep::Material matter = ns.material(modMat[i]);
516 
517  if (eModule[i] > 0) {
518  int nsec = sectionModule[i];
519 
521  //vertical walls are allowed in SolidPolyhedra
522  double deltaz = 0;
523 
524  std::vector<double> pgonZ, pgonRmin, pgonRmax;
525  if (nsec == 3) {
526  double zf = zminBlock[i] + zShiftHac2;
527  pgonZ.emplace_back(zf);
528  pgonRmin.emplace_back(zf * tan(angBot));
529  pgonRmax.emplace_back((zf - z1Beam) * slope);
530  pgonZ.emplace_back(ziKink);
531  pgonRmin.emplace_back(riKink);
532  pgonRmax.emplace_back(rout);
533  } else {
534  pgonZ.emplace_back(zminBlock[i]);
535  pgonRmin.emplace_back(rinBlock1[i]);
536  pgonRmax.emplace_back(routBlock1[i]);
537  }
538  if (nsec == 4) {
539  pgonZ.emplace_back(ziDip);
540  pgonRmin.emplace_back(riDip);
541  pgonRmax.emplace_back(rout);
542  pgonZ.emplace_back(pgonZ[1] + deltaz);
543  pgonRmin.emplace_back(pgonRmin[1]);
544  pgonRmax.emplace_back(roDip);
545  }
546  pgonZ.emplace_back(zmaxBlock[i]);
547  pgonRmin.emplace_back(rinBlock2[i]);
548  pgonRmax.emplace_back(routBlock2[i]);
549 
550  //Solid & volume
551  dd4hep::Solid solid = dd4hep::Polyhedra(ns.prepend(name), 1, -alpha, 2 * alpha, pgonZ, pgonRmin, pgonRmax);
552 #ifdef EDM_ML_DEBUG
553  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << solid.name() << " Polyhedra made of " << modMat[i]
554  << " with 1 sector from " << convertRadToDeg(-alpha) << " to "
555  << convertRadToDeg(alpha) << " and with " << nsec << " sections";
556  for (unsigned int k = 0; k < pgonZ.size(); k++)
557  edm::LogVerbatim("HCalGeom") << "\t\tZ = " << cms::convert2mm(pgonZ[k])
558  << "\tRmin = " << cms::convert2mm(pgonRmin[k])
559  << "\tRmax = " << cms::convert2mm(pgonRmax[k]);
560 #endif
561 
562  dd4hep::Volume glog(solid.name(), solid, matter);
563 
564  sector.placeVolume(glog, i + 1);
565 #ifdef EDM_ML_DEBUG
566  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << glog.name() << " number " << (i + 1)
567  << " positioned in " << sector.name() << " at (0,0,0) with no rotation";
568 #endif
569 
570  if (modType[i] == 0)
571  constructInsideModule0(ns, glog, i);
572  else
573  constructInsideModule(ns, glog, i);
574  }
575  }
576  }
577 
579 #ifdef EDM_ML_DEBUG
580  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: \t\tInside module0 ..." << mod;
581 #endif
582 
584  //Pointers to the Rotation Matrices and to the Materials
585  dd4hep::Rotation3D rot = getRotation(rotmat, ns);
586  dd4hep::Material matabsorbr = ns.material(absMat);
587  dd4hep::Material matplastic = ns.material(plastMat);
588 
589  int layer = getLayer(mod, 0);
590  int layer0 = getLayer(mod, 1);
592  double xpos, ypos, zpos;
593  dd4hep::Solid solid;
594  dd4hep::Volume glog;
595  for (int iphi = 0; iphi < phiSections; iphi++) {
596  double yh, bl, tl, alp;
597  parameterLayer0(mod, layer, iphi, yh, bl, tl, alp, xpos, ypos, zpos);
598  name = DDSplit(module.name()).first + layerName[layer] + phiName[iphi];
599  solid = dd4hep::Trap(ns.prepend(name), 0.5 * layerT[layer], 0, 0, yh, bl, tl, alp, yh, bl, tl, alp);
600 #ifdef EDM_ML_DEBUG
601  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << solid.name() << " Trap made of " << plastMat
602  << " of dimensions " << cms::convert2mm(0.5 * layerT[layer]) << ", 0, 0, "
603  << cms::convert2mm(yh) << ", " << cms::convert2mm(bl) << ", " << cms::convert2mm(tl)
604  << ", " << convertRadToDeg(alp) << ", " << cms::convert2mm(yh) << ", "
605  << cms::convert2mm(bl) << ", " << cms::convert2mm(tl) << ", "
606  << convertRadToDeg(alp);
607 #endif
608 
609  glog = dd4hep::Volume(solid.name(), solid, matplastic);
610 
611  dd4hep::Position r1(xpos, ypos, zpos);
612  module.placeVolume(glog, idOffset + layer + 1, dd4hep::Transform3D(rot, r1));
613 
614 #ifdef EDM_ML_DEBUG
615  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << glog.name() << " number " << (idOffset + layer + 1)
616  << " positioned in " << module.name() << " at (" << cms::convert2mm(xpos) << ", "
617  << cms::convert2mm(ypos) << ", " << cms::convert2mm(zpos)
618  << " with rotation: " << rot;
619 #endif
620 
621  //Now construct the layer of scintillator inside this
622  int copyNo = layer0 * 10 + layerType[layer];
623  name = modName[mod] + layerName[layer] + phiName[iphi];
624  constructScintLayer(ns, glog, scintT[layer], yh, bl, tl, alp, name, copyNo);
625  }
626 
627  //Now the absorber layer
628  double zi = zminBlock[mod] + layerT[layer];
629  double zo = zi + 0.5 * dzStep;
630  double rinF, routF, rinB, routB;
631  if (mod == 0) {
632  rinF = zi * tan(angTop);
633  routF = (zi - z1Beam) * slope;
634  rinB = zo * tan(angTop);
635  routB = (zo - z1Beam) * slope;
636  } else {
637  rinF = zi * tan(angBot);
638  routF = zi * tan(angTop);
639  rinB = zo * tan(angBot);
640  routB = zo * tan(angTop);
641  }
642 
643 #ifdef EDM_ML_DEBUG
644  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: Module " << mod << " Front " << cms::convert2mm(zi) << ", "
645  << cms::convert2mm(rinF) << ", " << cms::convert2mm(routF) << " Back "
646  << cms::convert2mm(zo) << ", " << cms::convert2mm(rinB) << ", "
647  << cms::convert2mm(routB);
648 #endif
649 
650  double yh1, bl1, tl1, yh2, bl2, tl2, theta, phi, alp;
651  parameterLayer(
652  0, rinF, routF, rinB, routB, zi, zo, yh1, bl1, tl1, yh2, bl2, tl2, alp, theta, phi, xpos, ypos, zpos);
653  double fact = tolAbs;
654 
655 #ifdef EDM_ML_DEBUG
656  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: Trim " << cms::convert2mm(fact) << " Param "
657  << cms::convert2mm(yh1) << ", " << cms::convert2mm(bl1) << ", " << cms::convert2mm(tl1)
658  << ", " << cms::convert2mm(yh2) << ", " << cms::convert2mm(bl2) << ", "
659  << cms::convert2mm(tl2);
660 #endif
661 
662  bl1 -= fact;
663  tl1 -= fact;
664  bl2 -= fact;
665  tl2 -= fact;
666 
667  name = DDSplit(module.name()).first + "Absorber";
668  solid = dd4hep::Trap(ns.prepend(name), 0.5 * thick[mod], theta, phi, yh1, bl1, tl1, alp, yh2, bl2, tl2, alp);
669 #ifdef EDM_ML_DEBUG
670  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << solid.name() << " Trap made of " << absMat
671  << " of dimensions " << cms::convert2mm(0.5 * thick[mod]) << ", "
672  << convertRadToDeg(theta) << ", " << convertRadToDeg(phi) << ", "
673  << cms::convert2mm(yh1) << ", " << cms::convert2mm(bl1) << ", " << cms::convert2mm(tl1)
674  << ", " << convertRadToDeg(alp) << ", " << cms::convert2mm(yh2) << ", "
675  << cms::convert2mm(bl2) << ", " << cms::convert2mm(tl2) << ", "
676  << convertRadToDeg(alp);
677 #endif
678 
679  glog = dd4hep::Volume(solid.name(), solid, matabsorbr);
680 
681  dd4hep::Position r2(xpos, ypos, zpos);
682  module.placeVolume(glog, 1, dd4hep::Transform3D(rot, r2));
683 
684 #ifdef EDM_ML_DEBUG
685  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << glog.name() << " number 1 positioned in " << module.name()
686  << " at (" << cms::convert2mm(xpos) << ", " << cms::convert2mm(ypos) << ", "
687  << cms::convert2mm(zpos) << ") with rotation: " << rot;
688 #endif
689  }
690 
692 #ifdef EDM_ML_DEBUG
693  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: \t\tInside module ..." << mod;
694 #endif
695 
697  //Pointers to the Rotation Matrices and to the Materials
698  dd4hep::Rotation3D rot = getRotation(rotmat, ns);
699  dd4hep::Material matter = ns.material(genMaterial);
700  dd4hep::Material matplastic = ns.material(plastMat);
701 
702  double alpha = (1._pi) / nsectors;
703  double zi = zminBlock[mod];
704 
705  for (int i = 0; i < layerN[mod]; i++) {
707  dd4hep::Solid solid;
708  dd4hep::Volume glog, plog;
709  int layer = getLayer(mod, i);
710  double zo = zi + 0.5 * dzStep;
711 
712  for (int iphi = 0; iphi < phiSections; iphi++) {
713  double ziAir = zo - thick[mod];
714  double rinF, rinB;
715  if (layer == 1) {
716  rinF = ziAir * tan(angTop);
717  rinB = zo * tan(angTop);
718  } else {
719  rinF = ziAir * tan(angBot);
720  rinB = zo * tan(angBot);
721  }
722  double routF = (ziAir - z1Beam) * slope;
723  double routB = (zo - z1Beam) * slope;
724  if (routF > routBlock2[mod])
725  routF = routBlock2[mod];
726  if (routB > routBlock2[mod])
727  routB = routBlock2[mod];
728 
729 #ifdef EDM_ML_DEBUG
730  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: Layer " << i << " Phi " << iphi << " Front "
731  << cms::convert2mm(ziAir) << ", " << cms::convert2mm(rinF) << ", "
732  << cms::convert2mm(routF) << " Back " << cms::convert2mm(zo) << ", "
733  << cms::convert2mm(rinB) << ", " << cms::convert2mm(routB);
734 #endif
735 
736  double yh1, bl1, tl1, yh2, bl2, tl2, theta, phi, alp;
737  double xpos, ypos, zpos;
738  parameterLayer(
739  iphi, rinF, routF, rinB, routB, ziAir, zo, yh1, bl1, tl1, yh2, bl2, tl2, alp, theta, phi, xpos, ypos, zpos);
740 
741  name = DDSplit(module.name()).first + layerName[layer] + phiName[iphi] + "Air";
742  solid = dd4hep::Trap(ns.prepend(name), 0.5 * thick[mod], theta, phi, yh1, bl1, tl1, alp, yh2, bl2, tl2, alp);
743 #ifdef EDM_ML_DEBUG
744  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << solid.name() << " Trap made of " << matter.name()
745  << " of dimensions " << cms::convert2mm(0.5 * thick[mod]) << ", "
746  << convertRadToDeg(theta) << ", " << convertRadToDeg(phi) << ", "
747  << cms::convert2mm(yh1) << ", " << cms::convert2mm(bl1) << ", "
748  << cms::convert2mm(tl1) << ", " << convertRadToDeg(alp) << ", "
749  << cms::convert2mm(yh2) << ", " << cms::convert2mm(bl2) << ", "
750  << cms::convert2mm(tl2) << ", " << convertRadToDeg(alp);
751 #endif
752 
753  glog = dd4hep::Volume(solid.name(), solid, matter);
754  dd4hep::Position r1(xpos, ypos, zpos);
755  module.placeVolume(glog, layer + 1, dd4hep::Transform3D(rot, r1));
756 
757 #ifdef EDM_ML_DEBUG
758  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << glog.name() << " number " << (layer + 1)
759  << " positioned in " << module.name() << " at (" << cms::convert2mm(xpos) << ", "
760  << cms::convert2mm(ypos) << ", " << cms::convert2mm(zpos)
761  << ") with rotation: " << rot;
762 #endif
763 
764  //Now the plastic with scintillators
765  double yh = 0.5 * (routF - rinB) - getTrim(mod, iphi);
766  double bl = 0.5 * rinB * tan(alpha) - getTrim(mod, iphi);
767  double tl = 0.5 * routF * tan(alpha) - getTrim(mod, iphi);
768  name = DDSplit(module.name()).first + layerName[layer] + phiName[iphi];
769  solid = dd4hep::Trap(ns.prepend(name), 0.5 * layerT[layer], 0, 0, yh, bl, tl, alp, yh, bl, tl, alp);
770 #ifdef EDM_ML_DEBUG
771  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << solid.name() << " Trap made of " << plastMat
772  << " of dimensions " << cms::convert2mm(0.5 * layerT[layer]) << ", 0, 0, "
773  << cms::convert2mm(yh) << ", " << cms::convert2mm(bl) << ", "
774  << cms::convert2mm(tl) << ", " << convertRadToDeg(alp) << ", "
775  << cms::convert2mm(yh) << ", " << cms::convert2mm(bl) << ", "
776  << cms::convert2mm(tl) << ", " << convertRadToDeg(alp);
777 #endif
778 
779  plog = dd4hep::Volume(solid.name(), solid, matplastic);
780  ypos = 0.5 * (routF + rinB) - xpos;
781  glog.placeVolume(plog, idOffset + layer + 1, dd4hep::Position(0., ypos, 0.));
782 
783 #ifdef EDM_ML_DEBUG
784  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << plog.name() << " number " << (idOffset + layer + 1)
785  << " positioned in " << glog.name() << " at (0, " << cms::convert2mm(ypos)
786  << ", 0) with no rotation";
787 #endif
788 
789  //Constructing the scintillators inside
790  int copyNo = layer * 10 + layerType[layer];
791  name = modName[mod] + layerName[layer] + phiName[iphi];
792  constructScintLayer(ns, plog, scintT[layer], yh, bl, tl, alp, name, copyNo);
793  zo += 0.5 * dzStep;
794  } // End of loop over phi indices
795  zi = zo - 0.5 * dzStep;
796  } // End of loop on layers
797  }
798 
801  double dz,
802  double yh,
803  double bl,
804  double tl,
805  double alp,
806  const std::string& nm,
807  int id) {
808  dd4hep::Material matter = ns.material(scintMat);
809  std::string name = idName + "Scintillator" + nm;
810 
811  dd4hep::Solid solid = dd4hep::Trap(ns.prepend(name), 0.5 * dz, 0, 0, yh, bl, tl, alp, yh, bl, tl, alp);
812 #ifdef EDM_ML_DEBUG
813  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << solid.name() << " Trap made of " << scintMat
814  << " of dimensions " << cms::convert2mm(0.5 * dz) << ", 0, 0, " << cms::convert2mm(yh)
815  << ", " << cms::convert2mm(bl) << ", " << cms::convert2mm(tl) << ", "
816  << convertRadToDeg(alp) << ", " << cms::convert2mm(yh) << ", " << cms::convert2mm(bl)
817  << ", " << cms::convert2mm(tl) << ", " << convertRadToDeg(alp);
818 #endif
819 
820  dd4hep::Volume glog(solid.name(), solid, matter);
821  detector.placeVolume(glog, id);
822 #ifdef EDM_ML_DEBUG
823  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << glog.name() << " number " << id << " positioned in "
824  << detector.name() << " at (0,0,0) with no rotation";
825 #endif
826  }
827 
828  int getLayer(unsigned int i, unsigned int j) const {
829  switch (i) {
830  case 0:
831  return layerN0[j];
832  break;
833  case 1:
834  return layerN1[j];
835  break;
836  case 2:
837  return layerN2[j];
838  break;
839  case 3:
840  return layerN3[j];
841  break;
842  case 4:
843  return layerN4[j];
844  break;
845  case 5:
846  return layerN5[j];
847  break;
848  default:
849  return 0;
850  }
851  }
852 
853  double getTrim(unsigned int i, unsigned int j) const {
854  if (j == 0)
855  return trimLeft[i];
856  else
857  return trimRight[j];
858  }
859 
861  int layer,
862  int iphi,
863  double& yh,
864  double& bl,
865  double& tl,
866  double& alp,
867  double& xpos,
868  double& ypos,
869  double& zpos) {
870  //Given module and layer number compute parameters of trapezoid
871  //and positioning parameters
872  double alpha = (1._pi) / nsectors;
873 #ifdef EDM_ML_DEBUG
874  edm::LogVerbatim("HCalGeom") << "Input " << iphi << " " << layer << " " << iphi << " Alpha "
876 #endif
877 
878  double zi, zo;
879  if (iphi == 0) {
880  zi = zminBlock[mod];
881  zo = zi + layerT[layer];
882  } else {
883  zo = zmaxBlock[mod];
884  zi = zo - layerT[layer];
885  }
886  double rin, rout;
887  if (mod == 0) {
888  rin = zo * tan(angTop);
889  rout = (zi - z1Beam) * slope;
890  } else {
891  rin = zo * tan(angBot);
892  rout = zi * tan(angTop);
893  }
894  yh = 0.5 * (rout - rin);
895  bl = 0.5 * rin * tan(alpha);
896  tl = 0.5 * rout * tan(alpha);
897  xpos = 0.5 * (rin + rout);
898  ypos = 0.5 * (bl + tl);
899  zpos = 0.5 * (zi + zo);
900  yh -= getTrim(mod, iphi);
901  bl -= getTrim(mod, iphi);
902  tl -= getTrim(mod, iphi);
903  alp = atan(0.5 * tan(alpha));
904  if (iphi == 0) {
905  ypos = -ypos;
906  } else {
907  alp = -alp;
908  }
909 
910 #ifdef EDM_ML_DEBUG
911  edm::LogVerbatim("HCalGeom") << "Output Dimensions " << cms::convert2mm(yh) << " " << cms::convert2mm(bl) << " "
912  << cms::convert2mm(tl) << " " << convertRadToDeg(alp) << " Position "
913  << cms::convert2mm(xpos) << " " << cms::convert2mm(ypos) << " "
914  << cms::convert2mm(zpos);
915 #endif
916  }
917 
919  double rinF,
920  double routF,
921  double rinB,
922  double routB,
923  double zi,
924  double zo,
925  double& yh1,
926  double& bl1,
927  double& tl1,
928  double& yh2,
929  double& bl2,
930  double& tl2,
931  double& alp,
932  double& theta,
933  double& phi,
934  double& xpos,
935  double& ypos,
936  double& zpos) {
937  //Given rin, rout compute parameters of the trapezoid and
938  //position of the trapezoid for a standrd layer
939  double alpha = (1._pi) / nsectors;
940 
941 #ifdef EDM_ML_DEBUG
942  edm::LogVerbatim("HCalGeom") << "Input " << iphi << " Front " << cms::convert2mm(rinF) << " "
943  << cms::convert2mm(routF) << " " << cms::convert2mm(zi) << " Back "
944  << cms::convert2mm(rinB) << " " << cms::convert2mm(routB) << " " << cms::convert2mm(zo)
945  << " Alpha " << convertRadToDeg(alpha);
946 #endif
947 
948  yh1 = 0.5 * (routF - rinB);
949  bl1 = 0.5 * rinB * tan(alpha);
950  tl1 = 0.5 * routF * tan(alpha);
951  yh2 = 0.5 * (routF - rinB);
952  bl2 = 0.5 * rinB * tan(alpha);
953  tl2 = 0.5 * routF * tan(alpha);
954  double dx = 0.25 * (bl2 + tl2 - bl1 - tl1);
955  double dy = 0.5 * (rinB + routF - rinB - routF);
956  xpos = 0.25 * (rinB + routF + rinB + routF);
957  ypos = 0.25 * (bl2 + tl2 + bl1 + tl1);
958  zpos = 0.5 * (zi + zo);
959  alp = atan(0.5 * tan(alpha));
960  // ypos-= tolPos;
961  if (iphi == 0) {
962  ypos = -ypos;
963  } else {
964  alp = -alp;
965  dx = -dx;
966  }
967  double r = sqrt(dx * dx + dy * dy);
968  theta = atan(r / (zo - zi));
969  phi = atan2(dy, dx);
970 
971 #ifdef EDM_ML_DEBUG
972  edm::LogVerbatim("HCalGeom") << "Output Dimensions " << cms::convert2mm(yh1) << " " << cms::convert2mm(bl1) << " "
973  << cms::convert2mm(tl1) << " " << cms::convert2mm(yh2) << " " << cms::convert2mm(bl2)
974  << " " << cms::convert2mm(tl2) << " " << convertRadToDeg(alp) << " "
975  << convertRadToDeg(theta) << " " << convertRadToDeg(phi) << " Position "
976  << cms::convert2mm(xpos) << " " << cms::convert2mm(ypos) << " "
977  << cms::convert2mm(zpos);
978 #endif
979  }
980 
981  dd4hep::Rotation3D getRotation(const std::string& rotation, cms::DDNamespace& ns) {
982  std::string rot = (strchr(rotation.c_str(), NAMESPACE_SEP) == nullptr) ? ("rotations:" + rotation) : rotation;
983 #ifdef EDM_ML_DEBUG
984  edm::LogVerbatim("HCalGeom") << "getRotation: " << rotation << ":" << rot << ":" << ns.rotation(rot);
985 #endif
986  return ns.rotation(rot);
987  }
988 };
989 
990 static long algorithm(dd4hep::Detector& /* description */, cms::DDParsingContext& ctxt, xml_h e) {
991  HCalEndcapAlgo hcalendcapalgo(ctxt, e);
992  return cms::s_executed;
993 }
994 
995 // first argument is the type from the xml file
996 DECLARE_DDCMS_DETELEMENT(DDCMS_hcal_DDHCalEndcapAlgo, algorithm)
Log< level::Info, true > LogVerbatim
std::vector< double > scintT
std::vector< double > rinBlock2
std::string idName
std::vector< int > layerN5
std::vector< double > layerT
const dd4hep::Rotation3D & rotation(const std::string &name) const
Definition: DDNamespace.cc:182
void constructInsideModule0(cms::DDNamespace &ns, dd4hep::Volume &module, int mod)
std::string rotmat
std::string absMat
static const double slope[3]
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
constexpr NumType convert2mm(NumType length)
Definition: DDutils.h:7
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::vector< int > eModule
std::vector< double > zminBlock
std::vector< double > zmaxBlock
dd4hep::Material material(const std::string &name) const
Definition: DDNamespace.cc:166
std::vector< int > layerN0
std::vector< double > trimRight
std::vector< double > trimLeft
std::vector< int > layerN3
std::vector< std::string > modMat
void constructInsideModule(cms::DDNamespace &ns, dd4hep::Volume &module, int mod)
#define DECLARE_DDCMS_DETELEMENT(name, func)
Definition: DDPlugins.h:25
constexpr uint8_t getLayer(uint32_t detId)
int getLayer(unsigned int i, unsigned int j) const
std::string scintMat
static constexpr long s_executed
std::vector< int > layerN1
std::string plastMat
T sqrt(T t)
Definition: SSEVec.h:23
void constructGeneralVolume(cms::DDNamespace &ns, dd4hep::Volume &parent)
void constructInsideSector(cms::DDNamespace &ns, dd4hep::Volume &sector)
std::string_view name() const
Definition: DDNamespace.h:79
static long algorithm(dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e)
std::vector< double > routBlock1
std::vector< int > layerN4
std::string rotHalf
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
double getTrim(unsigned int i, unsigned int j) const
std::vector< int > layerType
dd4hep::Volume Volume
ii
Definition: cuy.py:589
std::vector< int > layerN
std::string genMaterial
std::vector< std::string > phiName
void parameterLayer0(int mod, int layer, int iphi, double &yh, double &bl, double &tl, double &alp, double &xpos, double &ypos, double &zpos)
const double fact
std::string rotation
std::vector< double > routBlock2
std::vector< std::string > modName
std::vector< int > modType
std::vector< int > layerN2
std::vector< int > sectionModule
std::vector< std::string > layerName
void parameterLayer(int iphi, double rinF, double routF, double rinB, double routB, double zi, double zo, double &yh1, double &bl1, double &tl1, double &yh2, double &bl2, double &tl2, double &alp, double &theta, double &phi, double &xpos, double &ypos, double &zpos)
std::vector< double > rinBlock1
dd4hep::Volume addVolumeNS(dd4hep::Volume vol) const
Definition: DDNamespace.cc:202
std::vector< double > thick
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:3
void constructScintLayer(cms::DDNamespace &ns, dd4hep::Volume &detector, double dz, double yh, double bl, double tl, double alp, const std::string &nm, int id)
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition: DDNamespace.cc:276
HCalEndcapAlgo(cms::DDParsingContext &ctxt, xml_h e)
std::string prepend(const std::string &) const
Definition: DDNamespace.cc:99
#define NAMESPACE_SEP
Definition: DDNamespace.h:92
MPlex< T, D1, D2, N > atan2(const MPlex< T, D1, D2, N > &y, const MPlex< T, D1, D2, N > &x)
Definition: Matriplex.h:648
dd4hep::Rotation3D getRotation(const std::string &rotation, cms::DDNamespace &ns)