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"
18 
19 //#define EDM_ML_DEBUG
20 using namespace geant_units::operators;
21 
23  std::string genMaterial; //General material
24  int nsectors; //Number of potenital straight edges
25  int nsectortot; //Number of straight edges (actual)
26  int nEndcap; //Number of endcaps
27  std::vector<int> eModule; //Modules to be present in part i (?)
28  std::string rotHalf; //Rotation matrix for half
29  std::string rotation; //Rotation matrix to place in mother
30  double zShift; //needed for TB setup (move HE)
31  double zFront; //Z of the front section
32  double zEnd; //Outer Z of the HE
33  double ziNose; //Starting Z of the nose
34  double ziL0Nose; //Starting Z of layer 0 at nose
35  double ziBody; //Starting Z of the body
36  double ziL0Body; //Starting Z of layer 0 at body
37  double ziKink; //Position of the kink point
38  double z0Beam; //Position of gap front along z-axis
39  double z1Beam; //Position of gap end along z-axis
40  double ziDip; //Starting Z of dipped part of body
41  double dzStep; //Width in Z of a layer
42  double dzShift; //Shift in Z for HE
43  double zShiftHac2; //needed for TB (remove part Hac2)
44  double rout; //Outer R of the HE
45  double riKink; //Inner radius at kink point
46  double riDip; //Inner radius at the dip point
47  double roDip; //Outer radius at the dip point
48  double heboxDepth; //Depth of the HE box
49  double drEnd; //Shift in R for the end absorber
50  double angTop; //Angle of top end of HE
51  double angBot; //Angle of the bottom end of HE
52  double angGap; //Gap angle (in degrees)
53  double slope; //Slope of the gap on HE side
54  std::string absMat; //Absorber material
55  int modules; //Number of modules
56  std::vector<std::string> modName; //Name
57  std::vector<std::string> modMat; //Material
58  std::vector<int> modType; //Type (0/1 for front/standard)
59  std::vector<int> sectionModule; //Number of sections in a module
60  std::vector<int> layerN; //Number of layers
61  std::vector<int> layerN0; //Layer numbers in section 0
62  std::vector<int> layerN1; //Layer numbers in section 1
63  std::vector<int> layerN2; //Layer numbers in section 2
64  std::vector<int> layerN3; //Layer numbers in section 3
65  std::vector<int> layerN4; //Layer numbers in section 4
66  std::vector<int> layerN5; //Layer numbers in section 5
67  std::vector<double> thick; //Thickness of absorber/air
68  std::vector<double> trimLeft; //Trimming of left layers in module
69  std::vector<double> trimRight; //Trimming of right layers in module
70  std::vector<double> zminBlock; //Minimum Z
71  std::vector<double> zmaxBlock; //Maximum Z
72  std::vector<double> rinBlock1; //Inner Radius
73  std::vector<double> routBlock1; //Outer Radius at zmin
74  std::vector<double> rinBlock2; //Inner Radius
75  std::vector<double> routBlock2; //Outer Radius at zmax
76  int phiSections; //Number of phi sections
77  std::vector<std::string> phiName; //Name of Phi sections
78  int layers; //Number of layers
79  std::vector<std::string> layerName; //Layer Names
80  std::vector<int> layerType; //Detector type in each layer
81  std::vector<double> layerT; //Layer thickness (plastic + scint.)
82  std::vector<double> scintT; //Scintillator thickness
83  std::string plastMat; //Plastic material
84  std::string scintMat; //Scintillator material
85  std::string rotmat; //Rotation matrix for positioning
86  std::string idName; //Name of the "parent" volume.
87  std::string idNameSpace; //Namespace of this and ALL sub-parts
88  int idOffset; // Geant4 ID's... = 4000;
89  double tolPos, tolAbs; //Tolerances
90 
91  HCalEndcapAlgo() = delete;
92 
94  cms::DDNamespace ns(ctxt, e, true);
95  cms::DDAlgoArguments args(ctxt, e);
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 " << convertCmToMm(zFront) << " zEnd " << convertCmToMm(zEnd)
127  << " ziNose " << convertCmToMm(ziNose) << " ziL0Nose " << convertCmToMm(ziL0Nose)
128  << " ziBody " << convertCmToMm(ziBody) << " ziL0Body " << convertCmToMm(ziL0Body)
129  << " z0Beam " << convertCmToMm(z0Beam) << " ziDip " << convertCmToMm(ziDip)
130  << " dzStep " << convertCmToMm(dzStep) << " Gap " << convertCmToMm(gap) << " z1 "
131  << convertCmToMm(z1) << "\n\tr1 " << convertCmToMm(r1) << " rout "
132  << convertCmToMm(rout) << " HeboxDepth " << convertCmToMm(heboxDepth) << " drEnd "
133  << convertCmToMm(drEnd) << "\tetamin " << etamin << " Bottom angle " << angBot
134  << " Gap angle " << angGap << " Z-Shift " << convertCmToMm(zShift) << " "
135  << convertCmToMm(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 " << convertCmToMm(dzShift) << "\n\tz1Beam " << convertCmToMm(z1Beam)
150  << "\tziKink" << convertCmToMm(ziKink) << "\triKink " << convertCmToMm(riKink)
151  << "\triDip " << convertCmToMm(riDip) << "\n\troDip " << convertCmToMm(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 " << convertCmToMm(thick[i])
183  << " trim " << convertCmToMm(trimLeft[i]) << ", " << convertCmToMm(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  << convertCmToMm(layerT[i]) << "\tScint.Thick " << convertCmToMm(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 " << convertCmToMm(zminBlock[i])
303  << ", " << convertCmToMm(zmaxBlock[i]) << "/ " << convertCmToMm(rinBlock1[i]) << ", "
304  << convertCmToMm(rinBlock2[i]) << "/ " << convertCmToMm(routBlock1[i]) << ", "
305  << convertCmToMm(routBlock2[i]);
306 #endif
307 
308  idName = args.value<std::string>("MotherName");
309  idNameSpace = static_cast<std::string>(ns.name());
310  idOffset = args.value<int>("IdOffset");
311 #ifdef EDM_ML_DEBUG
312  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: Parent " << args.parentName() << " idName " << idName
313  << " NameSpace " << idNameSpace << " Offset " << idOffset;
314 #endif
315 
316  tolPos = args.value<double>("TolPos");
317  tolAbs = args.value<double>("TolAbs");
318 #ifdef EDM_ML_DEBUG
319  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: Tolerances - Positioning " << convertCmToMm(tolPos)
320  << " Absorber " << convertCmToMm(tolAbs);
321  edm::LogVerbatim("HCalGeom") << "==>> Constructing DDHCalEndcapAlgo...";
322 #endif
323 
324  dd4hep::Volume parent = ns.volume(args.parentName());
325  constructGeneralVolume(ns, parent);
326 #ifdef EDM_ML_DEBUG
327  edm::LogVerbatim("HCalGeom") << "<<== End of DDHCalEndcapAlgo construction ...";
328 #endif
329  }
330 
332 #ifdef EDM_ML_DEBUG
333  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: General volume...";
334 #endif
335 
336  bool proto = true;
337  for (int i = 0; i < 3; i++)
338  if (eModule[i] > 0)
339  proto = false;
340 
341  dd4hep::Rotation3D rot = getRotation(rotation, ns);
342 #ifdef EDM_ML_DEBUG
343  edm::LogVerbatim("HCalGeom") << " Rotation matrix " << rotation << " Rotation " << rot;
344 #endif
345 
346  dd4hep::Position r0(0, 0, zShift);
347  double alpha = (1._pi) / nsectors;
348  double dphi = nsectortot * (2._pi) / nsectors;
349 
351  //vertical walls are allowed in SolidPolyhedra
352  double delz = 0;
353 
354  std::vector<double> pgonZ, pgonRmin, pgonRmax;
355  if (proto) {
356  double zf = ziBody + zShiftHac2;
357  pgonZ.emplace_back(zf - dzShift);
358  pgonRmin.emplace_back(zf * tan(angBot));
359  pgonRmax.emplace_back((zf - z1Beam) * slope);
360  } else {
361  pgonZ.emplace_back(zFront - dzShift);
362  pgonRmin.emplace_back(zFront * tan(angTop));
363  pgonRmax.emplace_back((zFront - z1Beam) * slope);
364  pgonZ.emplace_back(ziL0Body - dzShift);
365  pgonRmin.emplace_back(ziL0Body * tan(angTop));
366  pgonRmax.emplace_back((ziL0Body - z1Beam) * slope);
367  pgonZ.emplace_back(ziL0Body - dzShift);
368  pgonRmin.emplace_back(ziL0Body * tan(angBot));
369  pgonRmax.emplace_back((ziL0Body - z1Beam) * slope);
370  }
371  pgonZ.emplace_back(ziKink - dzShift);
372  pgonRmin.emplace_back(riKink);
373  pgonRmax.emplace_back(rout);
374  pgonZ.emplace_back(ziDip - dzShift);
375  pgonRmin.emplace_back(riDip);
376  pgonRmax.emplace_back(rout);
377  pgonZ.emplace_back(ziDip - dzShift + delz);
378  pgonRmin.emplace_back(riDip);
379  pgonRmax.emplace_back(roDip);
380  pgonZ.emplace_back(zEnd - dzShift);
381  pgonRmin.emplace_back(zEnd * tan(angBot));
382  pgonRmax.emplace_back(roDip);
383  pgonZ.emplace_back(zEnd);
384  pgonRmin.emplace_back(zEnd * tan(angBot));
385  pgonRmax.emplace_back(roDip);
386 
387  std::string name("Null");
388  dd4hep::Solid solid = dd4hep::Polyhedra(ns.prepend(idName), nsectortot, -alpha, dphi, pgonZ, pgonRmin, pgonRmax);
389 #ifdef EDM_ML_DEBUG
390  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << solid.name() << " Polyhedra made of " << genMaterial
391  << " with " << nsectortot << " sectors from " << convertRadToDeg(-alpha) << " to "
392  << convertRadToDeg(-alpha + dphi) << " and with " << pgonZ.size() << " sections";
393  for (unsigned int i = 0; i < pgonZ.size(); i++)
394  edm::LogVerbatim("HCalGeom") << "\t\tZ = " << convertCmToMm(pgonZ[i]) << "\tRmin = " << convertCmToMm(pgonRmin[i])
395  << "\tRmax = " << convertCmToMm(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, " << convertCmToMm(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, " << convertCmToMm(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 = " << convertCmToMm(pgonZMod[i])
432  << "\tRmin = " << convertCmToMm(pgonRminMod[i])
433  << "\tRmax = " << convertCmToMm(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," << -convertCmToMm(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 = " << convertCmToMm(pgonZMod[i])
453  << "\tRmin = " << convertCmToMm(pgonRminMod[i])
454  << "\tRmax = " << convertCmToMm(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 = " << convertCmToMm(pgonZBack[i])
494  << "\tRmin = " << convertCmToMm(pgonRminBack[i])
495  << "\tRmax = " << convertCmToMm(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 = " << convertCmToMm(pgonZ[k])
558  << "\tRmin = " << convertCmToMm(pgonRmin[k])
559  << "\tRmax = " << convertCmToMm(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 << " positioned in "
567  << 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 " << convertCmToMm(0.5 * layerT[layer]) << ", 0, 0, "
603  << convertCmToMm(yh) << ", " << convertCmToMm(bl) << ", " << convertCmToMm(tl)
604  << ", " << convertRadToDeg(alp) << ", " << convertCmToMm(yh) << ", "
605  << convertCmToMm(bl) << ", " << convertCmToMm(tl) << ", " << convertRadToDeg(alp);
606 #endif
607 
608  glog = dd4hep::Volume(solid.name(), solid, matplastic);
609 
610  dd4hep::Position r1(xpos, ypos, zpos);
611  module.placeVolume(glog, idOffset + layer + 1, dd4hep::Transform3D(rot, r1));
612 
613 #ifdef EDM_ML_DEBUG
614  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << glog.name() << " number " << (idOffset + layer + 1)
615  << " positioned in " << module.name() << " at (" << convertCmToMm(xpos) << ", "
616  << convertCmToMm(ypos) << ", " << convertCmToMm(zpos) << " with rotation: " << rot;
617 #endif
618 
619  //Now construct the layer of scintillator inside this
620  int copyNo = layer0 * 10 + layerType[layer];
621  name = modName[mod] + layerName[layer] + phiName[iphi];
622  constructScintLayer(ns, glog, scintT[layer], yh, bl, tl, alp, name, copyNo);
623  }
624 
625  //Now the absorber layer
626  double zi = zminBlock[mod] + layerT[layer];
627  double zo = zi + 0.5 * dzStep;
628  double rinF, routF, rinB, routB;
629  if (mod == 0) {
630  rinF = zi * tan(angTop);
631  routF = (zi - z1Beam) * slope;
632  rinB = zo * tan(angTop);
633  routB = (zo - z1Beam) * slope;
634  } else {
635  rinF = zi * tan(angBot);
636  routF = zi * tan(angTop);
637  rinB = zo * tan(angBot);
638  routB = zo * tan(angTop);
639  }
640 
641 #ifdef EDM_ML_DEBUG
642  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: Module " << mod << " Front " << convertCmToMm(zi) << ", "
643  << convertCmToMm(rinF) << ", " << convertCmToMm(routF) << " Back " << convertCmToMm(zo)
644  << ", " << convertCmToMm(rinB) << ", " << convertCmToMm(routB);
645 #endif
646 
647  double yh1, bl1, tl1, yh2, bl2, tl2, theta, phi, alp;
648  parameterLayer(
649  0, rinF, routF, rinB, routB, zi, zo, yh1, bl1, tl1, yh2, bl2, tl2, alp, theta, phi, xpos, ypos, zpos);
650  double fact = tolAbs;
651 
652 #ifdef EDM_ML_DEBUG
653  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: Trim " << convertCmToMm(fact) << " Param " << convertCmToMm(yh1)
654  << ", " << convertCmToMm(bl1) << ", " << convertCmToMm(tl1) << ", "
655  << convertCmToMm(yh2) << ", " << convertCmToMm(bl2) << ", " << convertCmToMm(tl2);
656 #endif
657 
658  bl1 -= fact;
659  tl1 -= fact;
660  bl2 -= fact;
661  tl2 -= fact;
662 
663  name = DDSplit(module.name()).first + "Absorber";
664  solid = dd4hep::Trap(ns.prepend(name), 0.5 * thick[mod], theta, phi, yh1, bl1, tl1, alp, yh2, bl2, tl2, alp);
665 #ifdef EDM_ML_DEBUG
666  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << solid.name() << " Trap made of " << absMat
667  << " of dimensions " << convertCmToMm(0.5 * thick[mod]) << ", "
668  << convertRadToDeg(theta) << ", " << convertRadToDeg(phi) << ", " << convertCmToMm(yh1)
669  << ", " << convertCmToMm(bl1) << ", " << convertCmToMm(tl1) << ", "
670  << convertRadToDeg(alp) << ", " << convertCmToMm(yh2) << ", " << convertCmToMm(bl2)
671  << ", " << convertCmToMm(tl2) << ", " << convertRadToDeg(alp);
672 #endif
673 
674  glog = dd4hep::Volume(solid.name(), solid, matabsorbr);
675 
676  dd4hep::Position r2(xpos, ypos, zpos);
677  module.placeVolume(glog, 1, dd4hep::Transform3D(rot, r2));
678 
679 #ifdef EDM_ML_DEBUG
680  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << glog.name() << " number 1 positioned in " << module.name()
681  << " at (" << convertCmToMm(xpos) << ", " << convertCmToMm(ypos) << ", "
682  << convertCmToMm(zpos) << ") with rotation: " << rot;
683 #endif
684  }
685 
687 #ifdef EDM_ML_DEBUG
688  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: \t\tInside module ..." << mod;
689 #endif
690 
692  //Pointers to the Rotation Matrices and to the Materials
693  dd4hep::Rotation3D rot = getRotation(rotmat, ns);
694  dd4hep::Material matter = ns.material(genMaterial);
695  dd4hep::Material matplastic = ns.material(plastMat);
696 
697  double alpha = (1._pi) / nsectors;
698  double zi = zminBlock[mod];
699 
700  for (int i = 0; i < layerN[mod]; i++) {
702  dd4hep::Solid solid;
703  dd4hep::Volume glog, plog;
704  int layer = getLayer(mod, i);
705  double zo = zi + 0.5 * dzStep;
706 
707  for (int iphi = 0; iphi < phiSections; iphi++) {
708  double ziAir = zo - thick[mod];
709  double rinF, rinB;
710  if (layer == 1) {
711  rinF = ziAir * tan(angTop);
712  rinB = zo * tan(angTop);
713  } else {
714  rinF = ziAir * tan(angBot);
715  rinB = zo * tan(angBot);
716  }
717  double routF = (ziAir - z1Beam) * slope;
718  double routB = (zo - z1Beam) * slope;
719  if (routF > routBlock2[mod])
720  routF = routBlock2[mod];
721  if (routB > routBlock2[mod])
722  routB = routBlock2[mod];
723 
724 #ifdef EDM_ML_DEBUG
725  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: Layer " << i << " Phi " << iphi << " Front "
726  << convertCmToMm(ziAir) << ", " << convertCmToMm(rinF) << ", "
727  << convertCmToMm(routF) << " Back " << convertCmToMm(zo) << ", "
728  << convertCmToMm(rinB) << ", " << convertCmToMm(routB);
729 #endif
730 
731  double yh1, bl1, tl1, yh2, bl2, tl2, theta, phi, alp;
732  double xpos, ypos, zpos;
733  parameterLayer(
734  iphi, rinF, routF, rinB, routB, ziAir, zo, yh1, bl1, tl1, yh2, bl2, tl2, alp, theta, phi, xpos, ypos, zpos);
735 
736  name = DDSplit(module.name()).first + layerName[layer] + phiName[iphi] + "Air";
737  solid = dd4hep::Trap(ns.prepend(name), 0.5 * thick[mod], theta, phi, yh1, bl1, tl1, alp, yh2, bl2, tl2, alp);
738 #ifdef EDM_ML_DEBUG
739  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << solid.name() << " Trap made of " << matter.name()
740  << " of dimensions " << convertCmToMm(0.5 * thick[mod]) << ", "
741  << convertRadToDeg(theta) << ", " << convertRadToDeg(phi) << ", "
742  << convertCmToMm(yh1) << ", " << convertCmToMm(bl1) << ", " << convertCmToMm(tl1)
743  << ", " << convertRadToDeg(alp) << ", " << convertCmToMm(yh2) << ", "
744  << convertCmToMm(bl2) << ", " << convertCmToMm(tl2) << ", "
745  << convertRadToDeg(alp);
746 #endif
747 
748  glog = dd4hep::Volume(solid.name(), solid, matter);
749  dd4hep::Position r1(xpos, ypos, zpos);
750  module.placeVolume(glog, layer + 1, dd4hep::Transform3D(rot, r1));
751 
752 #ifdef EDM_ML_DEBUG
753  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << glog.name() << " number " << (layer + 1)
754  << " positioned in " << module.name() << " at (" << convertCmToMm(xpos) << ", "
755  << convertCmToMm(ypos) << ", " << convertCmToMm(zpos)
756  << ") with rotation: " << rot;
757 #endif
758 
759  //Now the plastic with scintillators
760  double yh = 0.5 * (routF - rinB) - getTrim(mod, iphi);
761  double bl = 0.5 * rinB * tan(alpha) - getTrim(mod, iphi);
762  double tl = 0.5 * routF * tan(alpha) - getTrim(mod, iphi);
763  name = DDSplit(module.name()).first + layerName[layer] + phiName[iphi];
764  solid = dd4hep::Trap(ns.prepend(name), 0.5 * layerT[layer], 0, 0, yh, bl, tl, alp, yh, bl, tl, alp);
765 #ifdef EDM_ML_DEBUG
766  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << solid.name() << " Trap made of " << plastMat
767  << " of dimensions " << convertCmToMm(0.5 * layerT[layer]) << ", 0, 0, "
768  << convertCmToMm(yh) << ", " << convertCmToMm(bl) << ", " << convertCmToMm(tl)
769  << ", " << convertRadToDeg(alp) << ", " << convertCmToMm(yh) << ", "
770  << convertCmToMm(bl) << ", " << convertCmToMm(tl) << ", " << convertRadToDeg(alp);
771 #endif
772 
773  plog = dd4hep::Volume(solid.name(), solid, matplastic);
774  ypos = 0.5 * (routF + rinB) - xpos;
775  glog.placeVolume(plog, idOffset + layer + 1, dd4hep::Position(0., ypos, 0.));
776 
777 #ifdef EDM_ML_DEBUG
778  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << plog.name() << " number " << (idOffset + layer + 1)
779  << " positioned in " << glog.name() << " at (0, " << convertCmToMm(ypos)
780  << ", 0) with no rotation";
781 #endif
782 
783  //Constructing the scintillators inside
784  int copyNo = layer * 10 + layerType[layer];
785  name = modName[mod] + layerName[layer] + phiName[iphi];
786  constructScintLayer(ns, plog, scintT[layer], yh, bl, tl, alp, name, copyNo);
787  zo += 0.5 * dzStep;
788  } // End of loop over phi indices
789  zi = zo - 0.5 * dzStep;
790  } // End of loop on layers
791  }
792 
795  double dz,
796  double yh,
797  double bl,
798  double tl,
799  double alp,
800  const std::string& nm,
801  int id) {
802  dd4hep::Material matter = ns.material(scintMat);
803  std::string name = idName + "Scintillator" + nm;
804 
805  dd4hep::Solid solid = dd4hep::Trap(ns.prepend(name), 0.5 * dz, 0, 0, yh, bl, tl, alp, yh, bl, tl, alp);
806 #ifdef EDM_ML_DEBUG
807  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << solid.name() << " Trap made of " << scintMat
808  << " of dimensions " << convertCmToMm(0.5 * dz) << ", 0, 0, " << convertCmToMm(yh)
809  << ", " << convertCmToMm(bl) << ", " << convertCmToMm(tl) << ", "
810  << convertRadToDeg(alp) << ", " << convertCmToMm(yh) << ", " << convertCmToMm(bl)
811  << ", " << convertCmToMm(tl) << ", " << convertRadToDeg(alp);
812 #endif
813 
814  dd4hep::Volume glog(solid.name(), solid, matter);
815  detector.placeVolume(glog, id);
816 #ifdef EDM_ML_DEBUG
817  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << glog.name() << " number " << id << " positioned in "
818  << detector.name() << " at (0,0,0) with no rotation";
819 #endif
820  }
821 
822  int getLayer(unsigned int i, unsigned int j) const {
823  switch (i) {
824  case 0:
825  return layerN0[j];
826  break;
827  case 1:
828  return layerN1[j];
829  break;
830  case 2:
831  return layerN2[j];
832  break;
833  case 3:
834  return layerN3[j];
835  break;
836  case 4:
837  return layerN4[j];
838  break;
839  case 5:
840  return layerN5[j];
841  break;
842  default:
843  return 0;
844  }
845  }
846 
847  double getTrim(unsigned int i, unsigned int j) const {
848  if (j == 0)
849  return trimLeft[i];
850  else
851  return trimRight[j];
852  }
853 
855  int layer,
856  int iphi,
857  double& yh,
858  double& bl,
859  double& tl,
860  double& alp,
861  double& xpos,
862  double& ypos,
863  double& zpos) {
864  //Given module and layer number compute parameters of trapezoid
865  //and positioning parameters
866  double alpha = (1._pi) / nsectors;
867 #ifdef EDM_ML_DEBUG
868  edm::LogVerbatim("HCalGeom") << "Input " << iphi << " " << layer << " " << iphi << " Alpha "
869  << convertRadToDeg(alpha);
870 #endif
871 
872  double zi, zo;
873  if (iphi == 0) {
874  zi = zminBlock[mod];
875  zo = zi + layerT[layer];
876  } else {
877  zo = zmaxBlock[mod];
878  zi = zo - layerT[layer];
879  }
880  double rin, rout;
881  if (mod == 0) {
882  rin = zo * tan(angTop);
883  rout = (zi - z1Beam) * slope;
884  } else {
885  rin = zo * tan(angBot);
886  rout = zi * tan(angTop);
887  }
888  yh = 0.5 * (rout - rin);
889  bl = 0.5 * rin * tan(alpha);
890  tl = 0.5 * rout * tan(alpha);
891  xpos = 0.5 * (rin + rout);
892  ypos = 0.5 * (bl + tl);
893  zpos = 0.5 * (zi + zo);
894  yh -= getTrim(mod, iphi);
895  bl -= getTrim(mod, iphi);
896  tl -= getTrim(mod, iphi);
897  alp = atan(0.5 * tan(alpha));
898  if (iphi == 0) {
899  ypos = -ypos;
900  } else {
901  alp = -alp;
902  }
903 
904 #ifdef EDM_ML_DEBUG
905  edm::LogVerbatim("HCalGeom") << "Output Dimensions " << convertCmToMm(yh) << " " << convertCmToMm(bl) << " "
906  << convertCmToMm(tl) << " " << convertRadToDeg(alp) << " Position "
907  << convertCmToMm(xpos) << " " << convertCmToMm(ypos) << " " << convertCmToMm(zpos);
908 #endif
909  }
910 
912  double rinF,
913  double routF,
914  double rinB,
915  double routB,
916  double zi,
917  double zo,
918  double& yh1,
919  double& bl1,
920  double& tl1,
921  double& yh2,
922  double& bl2,
923  double& tl2,
924  double& alp,
925  double& theta,
926  double& phi,
927  double& xpos,
928  double& ypos,
929  double& zpos) {
930  //Given rin, rout compute parameters of the trapezoid and
931  //position of the trapezoid for a standrd layer
932  double alpha = (1._pi) / nsectors;
933 
934 #ifdef EDM_ML_DEBUG
935  edm::LogVerbatim("HCalGeom") << "Input " << iphi << " Front " << convertCmToMm(rinF) << " " << convertCmToMm(routF)
936  << " " << convertCmToMm(zi) << " Back " << convertCmToMm(rinB) << " "
937  << convertCmToMm(routB) << " " << convertCmToMm(zo) << " Alpha "
938  << convertRadToDeg(alpha);
939 #endif
940 
941  yh1 = 0.5 * (routF - rinB);
942  bl1 = 0.5 * rinB * tan(alpha);
943  tl1 = 0.5 * routF * tan(alpha);
944  yh2 = 0.5 * (routF - rinB);
945  bl2 = 0.5 * rinB * tan(alpha);
946  tl2 = 0.5 * routF * tan(alpha);
947  double dx = 0.25 * (bl2 + tl2 - bl1 - tl1);
948  double dy = 0.5 * (rinB + routF - rinB - routF);
949  xpos = 0.25 * (rinB + routF + rinB + routF);
950  ypos = 0.25 * (bl2 + tl2 + bl1 + tl1);
951  zpos = 0.5 * (zi + zo);
952  alp = atan(0.5 * tan(alpha));
953  // ypos-= tolPos;
954  if (iphi == 0) {
955  ypos = -ypos;
956  } else {
957  alp = -alp;
958  dx = -dx;
959  }
960  double r = sqrt(dx * dx + dy * dy);
961  theta = atan(r / (zo - zi));
962  phi = atan2(dy, dx);
963 
964 #ifdef EDM_ML_DEBUG
965  edm::LogVerbatim("HCalGeom") << "Output Dimensions " << convertCmToMm(yh1) << " " << convertCmToMm(bl1) << " "
966  << convertCmToMm(tl1) << " " << convertCmToMm(yh2) << " " << convertCmToMm(bl2) << " "
967  << convertCmToMm(tl2) << " " << convertRadToDeg(alp) << " " << convertRadToDeg(theta)
968  << " " << convertRadToDeg(phi) << " Position " << convertCmToMm(xpos) << " "
969  << convertCmToMm(ypos) << " " << convertCmToMm(zpos);
970 #endif
971  }
972 
973  dd4hep::Rotation3D getRotation(const std::string& rotation, cms::DDNamespace& ns) {
974  std::string rot = (strchr(rotation.c_str(), NAMESPACE_SEP) == nullptr) ? ("rotations:" + rotation) : rotation;
975 #ifdef EDM_ML_DEBUG
976  edm::LogVerbatim("HCalGeom") << "getRotation: " << rotation << ":" << rot << ":" << ns.rotation(rot);
977 #endif
978  return ns.rotation(rot);
979  }
980 };
981 
982 static long algorithm(dd4hep::Detector& /* description */,
983  cms::DDParsingContext& ctxt,
984  xml_h e,
985  dd4hep::SensitiveDetector& /* sens */) {
986  HCalEndcapAlgo hcalendcapalgo(ctxt, e);
987  return 1;
988 }
989 
990 // first argument is the type from the xml file
991 DECLARE_DDCMS_DETELEMENT(DDCMS_hcal_DDHCalEndcapAlgo, algorithm)
std::vector< double > scintT
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition: DDNamespace.cc:184
std::vector< double > rinBlock2
std::string idName
std::vector< int > layerN5
std::vector< double > layerT
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
dd4hep::Volume addVolumeNS(dd4hep::Volume vol) const
Definition: DDNamespace.cc:150
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T value(const std::string &name) const
Geom::Theta< T > theta() const
std::vector< int > eModule
std::vector< double > zminBlock
std::vector< double > zmaxBlock
double getTrim(unsigned int i, unsigned int j) const
static long algorithm(dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e, dd4hep::SensitiveDetector &)
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)
std::string_view name() const
Definition: DDNamespace.h:68
int getLayer(unsigned int i, unsigned int j) const
std::string scintMat
std::vector< int > layerN1
std::string plastMat
T sqrt(T t)
Definition: SSEVec.h:19
void constructGeneralVolume(cms::DDNamespace &ns, dd4hep::Volume &parent)
void constructInsideSector(cms::DDNamespace &ns, dd4hep::Volume &sector)
std::vector< double > routBlock1
std::vector< int > layerN4
std::string rotHalf
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
dd4hep::Material material(const std::string &name) const
Definition: DDNamespace.cc:121
std::string prepend(const std::string &) const
Definition: DDNamespace.cc:66
std::vector< int > layerType
constexpr NumType convertCmToMm(NumType centimeters)
Definition: GeantUnits.h:68
dd4hep::Volume Volume
ii
Definition: cuy.py:590
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
const dd4hep::Rotation3D & rotation(const std::string &name) const
Definition: DDNamespace.cc:130
std::vector< std::string > modName
std::vector< int > modType
std::vector< int > layerN2
std::vector< int > sectionModule
alpha
zGenParticlesMatch = cms.InputTag(""),
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
std::vector< double > thick
#define DECLARE_DDCMS_DETELEMENT(name, func)
Definition: DDPlugins.h:30
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
Definition: vlib.h:198
void constructScintLayer(cms::DDNamespace &ns, dd4hep::Volume &detector, double dz, double yh, double bl, double tl, double alp, const std::string &nm, int id)
std::string parentName() const
Access value of rParent child node.
std::string idNameSpace
HCalEndcapAlgo(cms::DDParsingContext &ctxt, xml_h e)
#define NAMESPACE_SEP
Definition: DDNamespace.h:79
dd4hep::Rotation3D getRotation(const std::string &rotation, cms::DDNamespace &ns)