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 <map>
10 #include <string>
11 #include <vector>
12 
25 
26 //#define EDM_ML_DEBUG
27 using namespace angle_units::operators;
28 
29 class DDHCalEndcapAlgo : public DDAlgorithm {
30 public:
31  //Constructor and Destructor
33  ~DDHCalEndcapAlgo() override;
34 
35  //Get Methods
36  const std::string& getGenMat() const { return genMaterial; }
37  const std::string& getRotation() const { return rotation; }
38  int getNsectors() const { return nsectors; }
39  int getNsectortot() const { return nsectortot; }
40  int getEndcaps() const { return nEndcap; }
41  int equipModule(unsigned int i) const { return eModule[i]; }
42  double getZShift() const { return zShift; }
43 
44  double getZFront() const { return zFront; }
45  double getZEnd() const { return zEnd; }
46  double getZiNose() const { return ziNose; }
47  double getZiL0Nose() const { return ziL0Nose; }
48  double getZiBody() const { return ziBody; }
49  double getZiL0Body() const { return ziL0Body; }
50  double getZiKink() const { return ziKink; }
51  double getZ0Beam() const { return z0Beam; }
52  double getZ1Beam() const { return z1Beam; }
53  double getZiDip() const { return ziDip; }
54  double getDzStep() const { return dzStep; }
55  double getDzShift() const { return dzShift; }
56  double getZShiftHac2() const { return zShiftHac2; }
57 
58  double getRout() const { return rout; }
59  double getRinKink() const { return riKink; }
60  double getRinDip() const { return riDip; }
61  double getRoutDip() const { return roDip; }
62  double getHeboxDepth() const { return heboxDepth; }
63  double getDrEnd() const { return drEnd; }
64  double getAngTop() const { return angTop; }
65  double getAngBot() const { return angBot; }
66  double getAngGap() const { return angGap; }
67  double getSlope() const { return slope; }
68 
69  const std::string& getAbsMat() const { return absMat; }
70  int getModules() const { return modules; }
71  const std::string& getModName(unsigned int i) const { return modName[i]; }
72  const std::string& getModMat(unsigned int i) const { return modMat[i]; }
73  int getModType(unsigned int i) const { return modType[i]; }
74  int getSectionModule(unsigned i) const { return sectionModule[i]; }
75  int getLayerN(unsigned int i) const { return layerN[i]; }
76  int getLayer(unsigned int i, unsigned int j) const;
77  double getThick(unsigned int i) const { return thick[i]; }
78  double getTrim(unsigned int i, unsigned int j) const;
79  double getZminBlock(unsigned i) const { return zminBlock[i]; }
80  double getZmaxBlock(unsigned i) const { return zmaxBlock[i]; }
81  double getRinBlock1(unsigned i) const { return rinBlock1[i]; }
82  double getRinBlock2(unsigned i) const { return rinBlock2[i]; }
83  double getRoutBlock1(unsigned i) const { return routBlock1[i]; }
84  double getRoutBlock2(unsigned i) const { return routBlock2[i]; }
85 
86  int getPhi() const { return phiSections; }
87  const std::string& getPhiName(unsigned int i) const { return phiName[i]; }
88  int getLayers() const { return layers; }
89  const std::string& getLayerName(unsigned int i) const { return layerName[i]; }
90  int getLayerType(unsigned int i) const { return layerType[i]; }
91  double getLayerT(unsigned int i) const { return layerT[i]; }
92  double getScintT(unsigned int i) const { return scintT[i]; }
93  const std::string& getPlastMat() const { return plastMat; }
94  const std::string& getScintMat() const { return scintMat; }
95  const std::string& getRotMat() const { return rotmat; }
96  double getTolPos() const { return tolPos; }
97  double getTolAbs() const { return tolAbs; }
98 
99  void initialize(const DDNumericArguments& nArgs,
100  const DDVectorArguments& vArgs,
101  const DDMapArguments& mArgs,
102  const DDStringArguments& sArgs,
103  const DDStringVectorArguments& vsArgs) override;
104 
105  void execute(DDCompactView& cpv) override;
106 
107 protected:
108  void constructGeneralVolume(DDCompactView& cpv);
109  void constructInsideSector(const DDLogicalPart& sector, DDCompactView& cpv);
110  void parameterLayer(int iphi,
111  double rinF,
112  double routF,
113  double rinB,
114  double routB,
115  double zi,
116  double zo,
117  double& yh1,
118  double& bl1,
119  double& tl1,
120  double& yh2,
121  double& bl2,
122  double& tl2,
123  double& alp,
124  double& theta,
125  double& phi,
126  double& xpos,
127  double& ypos,
128  double& zcpv);
129  void parameterLayer0(int mod,
130  int layer,
131  int iphi,
132  double& yh,
133  double& bl,
134  double& tl,
135  double& alp,
136  double& xpos,
137  double& ypos,
138  double& zcpv);
139  void constructInsideModule0(const DDLogicalPart& module, int mod, DDCompactView& cpv);
140  void constructInsideModule(const DDLogicalPart& module, int mod, DDCompactView& cpv);
141  void constructScintLayer(const DDLogicalPart& glog,
142  double pDz,
143  double yh,
144  double bl,
145  double tl,
146  double alp,
147  const std::string& name,
148  int id,
149  DDCompactView& cpv);
150 
151 private:
152  std::string genMaterial; //General material
153  int nsectors; //Number of potenital straight edges
154  int nsectortot; //Number of straight edges (actual)
155  int nEndcap; //Number of endcaps
156  std::vector<int> eModule; //Modules to be present in part i (?)
157  std::string rotHalf; //Rotation matrix for half
158  std::string rotns; //Name space for rotation
159  std::string rotation; //Rotation matrix to place in mother
160  double zShift; //needed for TB setup (move HE)
161 
162  double zFront; //Z of the front section
163  double zEnd; //Outer Z of the HE
164  double ziNose; //Starting Z of the nose
165  double ziL0Nose; //Starting Z of layer 0 at nose
166  double ziBody; //Starting Z of the body
167  double ziL0Body; //Starting Z of layer 0 at body
168  double ziKink; //Position of the kink point
169  double z0Beam; //Position of gap front along z-axis
170  double z1Beam; //Position of gap end along z-axis
171  double ziDip; //Starting Z of dipped part of body
172  double dzStep; //Width in Z of a layer
173  double dzShift; //Shift in Z for HE
174  double zShiftHac2; //needed for TB (remove part Hac2)
175 
176  double rout; //Outer R of the HE
177  double riKink; //Inner radius at kink point
178  double riDip; //Inner radius at the dip point
179  double roDip; //Outer radius at the dip point
180  double heboxDepth; //Depth of the HE box
181  double drEnd; //Shift in R for the end absorber
182 
183  double angTop; //Angle of top end of HE
184  double angBot; //Angle of the bottom end of HE
185  double angGap; //Gap angle (in degrees)
186  double slope; //Slope of the gap on HE side
187 
188  std::string absMat; //Absorber material
189  int modules; //Number of modules
190  std::vector<std::string> modName; //Name
191  std::vector<std::string> modMat; //Material
192  std::vector<int> modType; //Type (0/1 for front/standard)
193  std::vector<int> sectionModule; //Number of sections in a module
194  std::vector<int> layerN; //Number of layers
195  std::vector<int> layerN0; //Layer numbers in section 0
196  std::vector<int> layerN1; //Layer numbers in section 1
197  std::vector<int> layerN2; //Layer numbers in section 2
198  std::vector<int> layerN3; //Layer numbers in section 3
199  std::vector<int> layerN4; //Layer numbers in section 4
200  std::vector<int> layerN5; //Layer numbers in section 5
201  std::vector<double> thick; //Thickness of absorber/air
202  std::vector<double> trimLeft; //Trimming of left layers in module
203  std::vector<double> trimRight; //Trimming of right layers in module
204  std::vector<double> zminBlock; //Minimum Z
205  std::vector<double> zmaxBlock; //Maximum Z
206  std::vector<double> rinBlock1; //Inner Radius
207  std::vector<double> routBlock1; //Outer Radius at zmin
208  std::vector<double> rinBlock2; //Inner Radius
209  std::vector<double> routBlock2; //Outer Radius at zmax
210 
211  int phiSections; //Number of phi sections
212  std::vector<std::string> phiName; //Name of Phi sections
213  int layers; //Number of layers
214  std::vector<std::string> layerName; //Layer Names
215  std::vector<int> layerType; //Detector type in each layer
216  std::vector<double> layerT; //Layer thickness (plastic + scint.)
217  std::vector<double> scintT; //Scintillator thickness
218  std::string plastMat; //Plastic material
219  std::string scintMat; //Scintillator material
220  std::string rotmat; //Rotation matrix for positioning
221 
222  std::string idName; //Name of the "parent" volume.
223  std::string idNameSpace; //Namespace of this and ALL sub-parts
224  int idOffset; // Geant4 ID's... = 4000;
225 
226  double tolPos, tolAbs; //Tolerances
227 };
228 
230  : modMat(0),
231  modType(0),
232  sectionModule(0),
233  layerN(0),
234  layerN0(0),
235  layerN1(0),
236  layerN2(0),
237  layerN3(0),
238  layerN4(0),
239  layerN5(0),
240  thick(0),
241  trimLeft(0),
242  trimRight(0),
243  zminBlock(0),
244  zmaxBlock(0),
245  rinBlock1(0),
246  routBlock1(0),
247  rinBlock2(0),
248  routBlock2(0),
249  layerType(0),
250  layerT(0),
251  scintT(0) {
252 #ifdef EDM_ML_DEBUG
253  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: Creating an instance";
254 #endif
255 }
256 
258 
259 int DDHCalEndcapAlgo::getLayer(unsigned int i, unsigned int j) const {
260  switch (i) {
261  case 0:
262  return layerN0[j];
263  break;
264 
265  case 1:
266  return layerN1[j];
267  break;
268 
269  case 2:
270  return layerN2[j];
271  break;
272 
273  case 3:
274  return layerN3[j];
275  break;
276 
277  case 4:
278  return layerN4[j];
279  break;
280 
281  case 5:
282  return layerN5[j];
283  break;
284 
285  default:
286  return 0;
287  }
288 }
289 
290 double DDHCalEndcapAlgo::getTrim(unsigned int i, unsigned int j) const {
291  if (j == 0)
292  return trimLeft[i];
293  else
294  return trimRight[j];
295 }
296 
298  const DDVectorArguments& vArgs,
299  const DDMapArguments&,
300  const DDStringArguments& sArgs,
301  const DDStringVectorArguments& vsArgs) {
302  genMaterial = sArgs["MaterialName"];
303  rotation = sArgs["Rotation"];
304  nsectors = int(nArgs["Sector"]);
305  nsectortot = int(nArgs["SectorTot"]);
306  nEndcap = int(nArgs["Endcap"]);
307  rotHalf = sArgs["RotHalf"];
308  rotns = sArgs["RotNameSpace"];
309  zShift = nArgs["ZShift"];
310 
311  zFront = nArgs["ZFront"];
312  zEnd = nArgs["ZEnd"];
313  ziNose = nArgs["ZiNose"];
314  ziL0Nose = nArgs["ZiL0Nose"];
315  ziBody = nArgs["ZiBody"];
316  ziL0Body = nArgs["ZiL0Body"];
317  z0Beam = nArgs["Z0Beam"];
318  ziDip = nArgs["ZiDip"];
319  dzStep = nArgs["DzStep"];
320  zShiftHac2 = nArgs["ZShiftHac2"];
321  double gap = nArgs["Gap"];
322  double z1 = nArgs["Z1"];
323  double r1 = nArgs["R1"];
324  rout = nArgs["Rout"];
325  heboxDepth = nArgs["HEboxDepth"];
326  drEnd = nArgs["DrEnd"];
327  double etamin = nArgs["Etamin"];
328  angBot = nArgs["AngBot"];
329  angGap = nArgs["AngGap"];
330 
331 #ifdef EDM_ML_DEBUG
332  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: General material " << genMaterial << "\tSectors " << nsectors
333  << ", " << nsectortot << "\tEndcaps " << nEndcap << "\tRotation matrix for half "
334  << rotns << ":" << rotHalf << "\n\tzFront " << zFront << " zEnd " << zEnd << " ziNose "
335  << ziNose << " ziL0Nose " << ziL0Nose << " ziBody " << ziBody << " ziL0Body " << ziL0Body
336  << " z0Beam " << z0Beam << " ziDip " << ziDip << " dzStep " << dzStep << " Gap " << gap
337  << " z1 " << z1 << "\n\tr1 " << r1 << " rout " << rout << " HeboxDepth " << heboxDepth
338  << " drEnd " << drEnd << "\tetamin " << etamin << " Bottom angle " << angBot
339  << " Gap angle " << angGap << " Z-Shift " << zShift << " " << zShiftHac2;
340 #endif
341 
342  //Derived quantities
343  angTop = 2.0 * atan(exp(-etamin));
344  slope = tan(angGap);
345  z1Beam = z1 - r1 / slope;
346  ziKink = z1Beam + rout / slope;
347  riKink = ziKink * tan(angBot);
348  riDip = ziDip * tan(angBot);
349  roDip = rout - heboxDepth;
350  dzShift = (z1Beam - z0Beam) - gap / sin(angGap);
351 
352 #ifdef EDM_ML_DEBUG
353  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: angTop " << convertRadToDeg(angTop) << "\tSlope " << slope
354  << "\tDzShift " << dzShift << "\n\tz1Beam " << z1Beam << "\tziKink" << ziKink
355  << "\triKink " << riKink << "\triDip " << riDip << "\n\troDip " << roDip << "\tRotation "
356  << rotation;
357 #endif
358 
360  //Modules
361  absMat = sArgs["AbsMat"];
362  modules = int(nArgs["Modules"]);
363 
364 #ifdef EDM_ML_DEBUG
365  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: Number of modules " << modules << " and absorber material "
366  << absMat;
367 #endif
368 
369  modName = vsArgs["ModuleName"];
370  modMat = vsArgs["ModuleMat"];
371  modType = dbl_to_int(vArgs["ModuleType"]);
372  sectionModule = dbl_to_int(vArgs["SectionModule"]);
373  thick = vArgs["ModuleThick"];
374  trimLeft = vArgs["TrimLeft"];
375  trimRight = vArgs["TrimRight"];
376  eModule = dbl_to_int(vArgs["EquipModule"]);
377  layerN = dbl_to_int(vArgs["LayerN"]);
378  layerN0 = dbl_to_int(vArgs["LayerN0"]);
379  layerN1 = dbl_to_int(vArgs["LayerN1"]);
380  layerN2 = dbl_to_int(vArgs["LayerN2"]);
381  layerN3 = dbl_to_int(vArgs["LayerN3"]);
382  layerN4 = dbl_to_int(vArgs["LayerN4"]);
383  layerN5 = dbl_to_int(vArgs["LayerN5"]);
384 
385 #ifdef EDM_ML_DEBUG
386  for (int i = 0; i < modules; i++) {
387  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << modName[i] << " type " << modType[i] << " Sections "
388  << sectionModule[i] << " thickness of absorber/air " << thick[i] << " trim "
389  << trimLeft[i] << ", " << trimRight[i] << " equip module " << eModule[i] << " with "
390  << layerN[i] << " layers";
391  if (i == 0) {
392  for (int j = 0; j < layerN[i]; j++) {
393  edm::LogVerbatim("HCalGeom") << "\t " << layerN0[j] << "/" << layerN0[j + 1];
394  }
395  } else if (i == 1) {
396  for (int j = 0; j < layerN[i]; j++) {
397  edm::LogVerbatim("HCalGeom") << "\t " << layerN1[j] << "/" << layerN1[j + 1];
398  }
399  } else if (i == 2) {
400  for (int j = 0; j < layerN[i]; j++) {
401  edm::LogVerbatim("HCalGeom") << "\t " << layerN2[j];
402  }
403  } else if (i == 3) {
404  for (int j = 0; j < layerN[i]; j++) {
405  edm::LogVerbatim("HCalGeom") << "\t " << layerN3[j];
406  }
407  } else if (i == 4) {
408  for (int j = 0; j < layerN[i]; j++) {
409  edm::LogVerbatim("HCalGeom") << "\t " << layerN4[j];
410  }
411  } else if (i == 5) {
412  for (int j = 0; j < layerN[i]; j++) {
413  edm::LogVerbatim("HCalGeom") << "\t " << layerN5[j];
414  }
415  }
416  }
417 #endif
418 
420  //Layers
421  phiSections = int(nArgs["PhiSections"]);
422  phiName = vsArgs["PhiName"];
423  layers = int(nArgs["Layers"]);
424  layerName = vsArgs["LayerName"];
425  layerType = dbl_to_int(vArgs["LayerType"]);
426  layerT = vArgs["LayerT"];
427  scintT = vArgs["ScintT"];
428  scintMat = sArgs["ScintMat"];
429  plastMat = sArgs["PlastMat"];
430  rotmat = sArgs["RotMat"];
431 
432 #ifdef EDM_ML_DEBUG
433  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: Phi Sections " << phiSections;
434  for (int i = 0; i < phiSections; i++)
435  edm::LogVerbatim("HCalGeom") << "\tName[" << i << "] : " << phiName[i];
436  edm::LogVerbatim("HCalGeom") << "\tPlastic: " << plastMat << "\tScintillator: " << scintMat << "\tRotation matrix "
437  << rotns << ":" << rotmat << "\n\tNumber of layers " << layers;
438  for (int i = 0; i < layers; i++) {
439  edm::LogVerbatim("HCalGeom") << "\t" << layerName[i] << "\tType " << layerType[i] << "\tThickness " << layerT[i]
440  << "\tScint.Thick " << scintT[i];
441  }
442 #endif
443 
445  // Derive bounding of the modules
446  int module = 0;
447  // Layer 0 (Nose)
448  if (modules > 0) {
449  zminBlock.emplace_back(ziL0Nose);
450  zmaxBlock.emplace_back(zminBlock[module] + layerT[0] + 0.5 * dzStep);
451  rinBlock1.emplace_back(zminBlock[module] * tan(angTop));
452  rinBlock2.emplace_back(zmaxBlock[module] * tan(angTop));
453  routBlock1.emplace_back((zminBlock[module] - z1Beam) * slope);
454  routBlock2.emplace_back((zmaxBlock[module] - z1Beam) * slope);
455  module++;
456  }
457 
458  // Layer 0 (Body)
459  if (modules > 1) {
460  zminBlock.emplace_back(ziL0Body);
461  zmaxBlock.emplace_back(zminBlock[module] + layerT[0] + 0.5 * dzStep);
462  rinBlock1.emplace_back(zminBlock[module] * tan(angBot));
463  rinBlock2.emplace_back(zmaxBlock[module] * tan(angBot));
464  routBlock1.emplace_back(zminBlock[module] * tan(angTop));
465  routBlock2.emplace_back(zmaxBlock[module] * tan(angTop));
466  module++;
467  }
468 
469  // Hac1
470  if (modules > 2) {
471  zminBlock.emplace_back(ziNose);
472  zmaxBlock.emplace_back(ziBody);
473  rinBlock1.emplace_back(zminBlock[module] * tan(angTop));
474  rinBlock2.emplace_back(zmaxBlock[module] * tan(angTop));
475  routBlock1.emplace_back((zminBlock[module] - z1Beam) * slope);
476  routBlock2.emplace_back((zmaxBlock[module] - z1Beam) * slope);
477  module++;
478  }
479 
480  // Hac2
481  if (modules > 3) {
482  zminBlock.emplace_back(ziBody);
483  zmaxBlock.emplace_back(zminBlock[module] + layerN[3] * dzStep);
484  rinBlock1.emplace_back(zminBlock[module] * tan(angBot));
485  rinBlock2.emplace_back(zmaxBlock[module] * tan(angBot));
486  routBlock1.emplace_back((zmaxBlock[module - 1] - z1Beam) * slope);
487  routBlock2.emplace_back(rout);
488  module++;
489  }
490 
491  // Hac3
492  if (modules > 4) {
493  zminBlock.emplace_back(zmaxBlock[module - 1]);
494  zmaxBlock.emplace_back(zminBlock[module] + layerN[4] * dzStep);
495  rinBlock1.emplace_back(zminBlock[module] * tan(angBot));
496  rinBlock2.emplace_back(zmaxBlock[module] * tan(angBot));
497  routBlock1.emplace_back(rout);
498  routBlock2.emplace_back(rout);
499  module++;
500  }
501 
502  // Hac4
503  if (modules > 5) {
504  zminBlock.emplace_back(zmaxBlock[module - 1]);
505  zmaxBlock.emplace_back(zminBlock[module] + layerN[5] * dzStep);
506  rinBlock1.emplace_back(zminBlock[module] * tan(angBot));
507  rinBlock2.emplace_back(zmaxBlock[module] * tan(angBot));
508  routBlock1.emplace_back(rout);
509  routBlock2.emplace_back(roDip);
510  module++;
511  }
512 
513 #ifdef EDM_ML_DEBUG
514  for (int i = 0; i < module; i++)
515  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: Module " << i << "\tZ/Rin/Rout " << zminBlock[i] << ", "
516  << zmaxBlock[i] << "/ " << rinBlock1[i] << ", " << rinBlock2[i] << "/ "
517  << routBlock1[i] << ", " << routBlock2[i];
518 #endif
519 
520  idName = sArgs["MotherName"];
522  idOffset = int(nArgs["IdOffset"]);
523 
524 #ifdef EDM_ML_DEBUG
525  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: Parent " << parent().name() << " idName " << idName
526  << " NameSpace " << idNameSpace << " Offset " << idOffset;
527 #endif
528 
529  tolPos = nArgs["TolPos"];
530  tolAbs = nArgs["TolAbs"];
531 
532 #ifdef EDM_ML_DEBUG
533  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: Tolerances - Positioning " << tolPos << " Absorber " << tolAbs;
534 #endif
535 }
536 
538 // DDHCalEndcapAlgo methods...
540 
542 #ifdef EDM_ML_DEBUG
543  edm::LogVerbatim("HCalGeom") << "==>> Constructing DDHCalEndcapAlgo...";
544 #endif
545 
547 
548 #ifdef EDM_ML_DEBUG
549  edm::LogVerbatim("HCalGeom") << "<<== End of DDHCalEndcapAlgo construction ...";
550 #endif
551 }
552 
553 //----------------------start here for DDD work!!! ---------------
554 
556 #ifdef EDM_ML_DEBUG
557  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: General volume...";
558 #endif
559 
560  bool proto = true;
561  for (int i = 0; i < 3; i++)
562  if (equipModule(i) > 0)
563  proto = false;
564 
565  DDRotation rot;
566  if (DDSplit(getRotation()).first == "NULL")
567  rot = DDRotation();
568  else
570 
571 #ifdef EDM_ML_DEBUG
572  edm::LogVerbatim("HCalGeom") << " First " << DDSplit(getRotation()).first << " Second "
573  << DDSplit(getRotation()).second << " Rotation " << rot;
574 #endif
575 
576  DDTranslation r0(0, 0, getZShift());
577  double alpha = (1._pi) / getNsectors();
578  double dphi = getNsectortot() * (2._pi) / getNsectors();
579 
581  //vertical walls are allowed in SolidPolyhedra
582  double delz = 0;
583 
584  std::vector<double> pgonZ, pgonRmin, pgonRmax;
585  if (proto) {
586  double zf = getZiBody() + getZShiftHac2();
587  pgonZ.emplace_back(zf - getDzShift());
588  pgonRmin.emplace_back(zf * tan(getAngBot()));
589  pgonRmax.emplace_back((zf - getZ1Beam()) * getSlope());
590  } else {
591  pgonZ.emplace_back(getZFront() - getDzShift());
592  pgonRmin.emplace_back(getZFront() * tan(getAngTop()));
593  pgonRmax.emplace_back((getZFront() - getZ1Beam()) * getSlope());
594  pgonZ.emplace_back(getZiL0Body() - getDzShift());
595  pgonRmin.emplace_back(getZiL0Body() * tan(getAngTop()));
596  pgonRmax.emplace_back((getZiL0Body() - getZ1Beam()) * getSlope());
597  pgonZ.emplace_back(getZiL0Body() - getDzShift());
598  pgonRmin.emplace_back(getZiL0Body() * tan(getAngBot()));
599  pgonRmax.emplace_back((getZiL0Body() - getZ1Beam()) * getSlope());
600  }
601  pgonZ.emplace_back(getZiKink() - getDzShift());
602  pgonRmin.emplace_back(getRinKink());
603  pgonRmax.emplace_back(getRout());
604  pgonZ.emplace_back(getZiDip() - getDzShift());
605  pgonRmin.emplace_back(getRinDip());
606  pgonRmax.emplace_back(getRout());
607  pgonZ.emplace_back(getZiDip() - getDzShift() + delz);
608  pgonRmin.emplace_back(getRinDip());
609  pgonRmax.emplace_back(getRoutDip());
610  pgonZ.emplace_back(getZEnd() - getDzShift());
611  pgonRmin.emplace_back(getZEnd() * tan(getAngBot()));
612  pgonRmax.emplace_back(getRoutDip());
613  pgonZ.emplace_back(getZEnd());
614  pgonRmin.emplace_back(getZEnd() * tan(getAngBot()));
615  pgonRmax.emplace_back(getRoutDip());
616 
617  std::string name("Null");
618  DDSolid solid;
619  solid =
620  DDSolidFactory::polyhedra(DDName(idName, idNameSpace), getNsectortot(), -alpha, dphi, pgonZ, pgonRmin, pgonRmax);
621 #ifdef EDM_ML_DEBUG
622  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << DDName(idName, idNameSpace) << " Polyhedra made of "
623  << getGenMat() << " with " << getNsectortot() << " sectors from "
624  << convertRadToDeg(-alpha) << " to " << convertRadToDeg(-alpha + dphi) << " and with "
625  << pgonZ.size() << " sections";
626  for (unsigned int i = 0; i < pgonZ.size(); i++)
627  edm::LogVerbatim("HCalGeom") << "\t\tZ = " << pgonZ[i] << "\tRmin = " << pgonRmin[i] << "\tRmax = " << pgonRmax[i];
628 #endif
629 
631  DDMaterial matter(matname);
632  DDLogicalPart genlogic(DDName(idName, idNameSpace), matter, solid);
633 
634  DDName parentName = parent().name();
635  cpv.position(DDName(idName, idNameSpace), parentName, 1, r0, rot);
636 
637 #ifdef EDM_ML_DEBUG
638  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << DDName(idName, idNameSpace) << " number 1 positioned in "
639  << parentName << " at " << r0 << " with " << rot;
640 #endif
641 
642  if (getEndcaps() != 1) {
644  cpv.position(DDName(idName, idNameSpace), parentName, 2, r0, rot);
645 
646 #ifdef EDM_ML_DEBUG
647  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << DDName(idName, idNameSpace) << " number 2 "
648  << "positioned in " << parentName << " at " << r0 << " with " << rot;
649 #endif
650  }
651 
652  //Forward half
653  name = idName + "Front";
654  std::vector<double> pgonZMod, pgonRminMod, pgonRmaxMod;
655  for (unsigned int i = 0; i < (pgonZ.size() - 1); i++) {
656  pgonZMod.emplace_back(pgonZ[i] + getDzShift());
657  pgonRminMod.emplace_back(pgonRmin[i]);
658  pgonRmaxMod.emplace_back(pgonRmax[i]);
659  }
661  DDName(name, idNameSpace), getNsectortot(), -alpha, dphi, pgonZMod, pgonRminMod, pgonRmaxMod);
662 
663 #ifdef EDM_ML_DEBUG
664  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << DDName(name, idNameSpace) << " Polyhedra made of "
665  << getGenMat() << " with " << getNsectortot() << " sectors from "
666  << convertRadToDeg(-alpha) << " to " << convertRadToDeg(-alpha + dphi) << " and with "
667  << pgonZMod.size() << " sections ";
668  for (unsigned int i = 0; i < pgonZMod.size(); i++)
669  edm::LogVerbatim("HCalGeom") << "\t\tZ = " << pgonZMod[i] << "\tRmin = " << pgonRminMod[i]
670  << "\tRmax = " << pgonRmaxMod[i];
671 #endif
672 
673  DDLogicalPart genlogich(DDName(name, idNameSpace), matter, solid);
674 
675  cpv.position(genlogich, genlogic, 1, DDTranslation(0.0, 0.0, -getDzShift()), DDRotation());
676 
677 #ifdef EDM_ML_DEBUG
678  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << genlogich.name() << " number 1 positioned in "
679  << genlogic.name() << " at (0,0," << -getDzShift() << ") with no rotation";
680 #endif
681 
682  //Construct sector (from -alpha to +alpha)
683  name = idName + "Module";
684  solid =
685  DDSolidFactory::polyhedra(DDName(name, idNameSpace), 1, -alpha, 2 * alpha, pgonZMod, pgonRminMod, pgonRmaxMod);
686 #ifdef EDM_ML_DEBUG
687  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << DDName(name, idNameSpace) << " Polyhedra made of "
688  << getGenMat() << " with 1 sector from " << convertRadToDeg(-alpha) << " to "
689  << convertRadToDeg(alpha) << " and with " << pgonZMod.size() << " sections";
690  for (unsigned int i = 0; i < pgonZMod.size(); i++)
691  edm::LogVerbatim("HCalGeom") << "\t\tZ = " << pgonZMod[i] << "\tRmin = " << pgonRminMod[i]
692  << "\tRmax = " << pgonRmaxMod[i];
693 #endif
694 
695  DDLogicalPart seclogic(DDName(name, idNameSpace), matter, solid);
696 
697  for (int ii = 0; ii < getNsectortot(); ii++) {
698  double phi = ii * 2 * alpha;
700  std::string rotstr("NULL");
701  if (phi != 0) {
702  rotstr = "R" + formatAsDegreesInInteger(phi);
703  rotation = DDRotation(DDName(rotstr, rotns));
704  if (!rotation) {
705 #ifdef EDM_ML_DEBUG
706  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: Creating a new rotation " << rotstr << "\t 90,"
707  << convertRadToDeg(phi) << ", 90," << convertRadToDeg(phi + 90._deg) << ", 0, 0";
708 #endif
709  rotation = DDrot(DDName(rotstr, rotns), 90._deg, phi, 90._deg, (90._deg + phi), 0, 0);
710  } //if !rotation
711  } //if phi!=0
712 
713  cpv.position(seclogic, genlogich, ii + 1, DDTranslation(0.0, 0.0, 0.0), rotation);
714 
715 #ifdef EDM_ML_DEBUG
716  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << seclogic.name() << " number " << ii + 1 << " positioned in "
717  << genlogich.name() << " at (0,0,0) with " << rotation;
718 #endif
719  }
720 
721  //Construct the things inside the sector
722  constructInsideSector(seclogic, cpv);
723 
724  //Backward half
725  name = idName + "Back";
726  std::vector<double> pgonZBack, pgonRminBack, pgonRmaxBack;
727  pgonZBack.emplace_back(getZEnd() - getDzShift());
728  pgonRminBack.emplace_back(pgonZBack[0] * tan(getAngBot()) + getDrEnd());
729  pgonRmaxBack.emplace_back(getRoutDip());
730  pgonZBack.emplace_back(getZEnd());
731  pgonRminBack.emplace_back(pgonZBack[1] * tan(getAngBot()) + getDrEnd());
732  pgonRmaxBack.emplace_back(getRoutDip());
734  DDName(name, idNameSpace), getNsectortot(), -alpha, dphi, pgonZBack, pgonRminBack, pgonRmaxBack);
735 
736 #ifdef EDM_ML_DEBUG
737  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << DDName(name, idNameSpace) << " Polyhedra made of "
738  << getAbsMat() << " with " << getNsectortot() << " sectors from "
739  << convertRadToDeg(-alpha) << " to " << convertRadToDeg(-alpha + dphi) << " and with "
740  << pgonZBack.size() << " sections";
741  for (unsigned int i = 0; i < pgonZBack.size(); i++)
742  edm::LogVerbatim("HCalGeom") << "\t\tZ = " << pgonZBack[i] << "\tRmin = " << pgonRminBack[i]
743  << "\tRmax = " << pgonRmaxBack[i];
744 #endif
745 
746  DDName absMatname(DDSplit(getAbsMat()).first, DDSplit(getAbsMat()).second);
747  DDMaterial absMatter(absMatname);
748  DDLogicalPart glog(DDName(name, idNameSpace), absMatter, solid);
749 
750  cpv.position(glog, genlogic, 1, DDTranslation(0.0, 0.0, 0.0), DDRotation());
751 
752 #ifdef EDM_ML_DEBUG
753  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << glog.name() << " number 1 positioned in " << genlogic.name()
754  << " at (0,0,0) with no rotation";
755 #endif
756 }
757 
759 #ifdef EDM_ML_DEBUG
760  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: Modules (" << getModules() << ") ...";
761 #endif
762 
763  double alpha = (1._pi) / getNsectors();
764 
765  for (int i = 0; i < getModules(); i++) {
768  DDMaterial matter(matname);
769 
770  if (equipModule(i) > 0) {
771  int nsec = getSectionModule(i);
772 
774  //vertical walls are allowed in SolidPolyhedra
775  double deltaz = 0;
776 
777  std::vector<double> pgonZ, pgonRmin, pgonRmax;
778  if (nsec == 3) {
779  double zf = getZminBlock(i) + getZShiftHac2();
780  pgonZ.emplace_back(zf);
781  pgonRmin.emplace_back(zf * tan(getAngBot()));
782  pgonRmax.emplace_back((zf - getZ1Beam()) * getSlope());
783  pgonZ.emplace_back(getZiKink());
784  pgonRmin.emplace_back(getRinKink());
785  pgonRmax.emplace_back(getRout());
786  } else {
787  pgonZ.emplace_back(getZminBlock(i));
788  pgonRmin.emplace_back(getRinBlock1(i));
789  pgonRmax.emplace_back(getRoutBlock1(i));
790  }
791  if (nsec == 4) {
792  pgonZ.emplace_back(getZiDip());
793  pgonRmin.emplace_back(getRinDip());
794  pgonRmax.emplace_back(getRout());
795  pgonZ.emplace_back(pgonZ[1] + deltaz);
796  pgonRmin.emplace_back(pgonRmin[1]);
797  pgonRmax.emplace_back(getRoutDip());
798  }
799  pgonZ.emplace_back(getZmaxBlock(i));
800  pgonRmin.emplace_back(getRinBlock2(i));
801  pgonRmax.emplace_back(getRoutBlock2(i));
802 
803  //Solid & volume
804  DDSolid solid;
805  solid = DDSolidFactory::polyhedra(DDName(name, idNameSpace), 1, -alpha, 2 * alpha, pgonZ, pgonRmin, pgonRmax);
806 
807 #ifdef EDM_ML_DEBUG
808  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << DDName(name, idNameSpace) << " Polyhedra made of "
809  << getModMat(i) << " with 1 sector from " << convertRadToDeg(-alpha) << " to "
810  << convertRadToDeg(alpha) << " and with " << nsec << " sections";
811  for (unsigned int k = 0; k < pgonZ.size(); k++)
812  edm::LogVerbatim("HCalGeom") << "\t\tZ = " << pgonZ[k] << "\tRmin = " << pgonRmin[k]
813  << "\tRmax = " << pgonRmax[k];
814 #endif
815 
816  DDLogicalPart glog(DDName(name, idNameSpace), matter, solid);
817 
818  cpv.position(glog, sector, i + 1, DDTranslation(0.0, 0.0, 0.0), DDRotation());
819 
820 #ifdef EDM_ML_DEBUG
821  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << glog.name() << " number " << i + 1 << " positioned in "
822  << sector.name() << " at (0,0,0) with no rotation";
823 #endif
824 
825  if (getModType(i) == 0)
826  constructInsideModule0(glog, i, cpv);
827  else
828  constructInsideModule(glog, i, cpv);
829  }
830  }
831 }
832 
834  int layer,
835  int iphi,
836  double& yh,
837  double& bl,
838  double& tl,
839  double& alp,
840  double& xpos,
841  double& ypos,
842  double& zpos) {
843  //Given module and layer number compute parameters of trapezoid
844  //and positioning parameters
845  double alpha = (1._pi) / getNsectors();
846 
847 #ifdef EDM_ML_DEBUG
848  edm::LogVerbatim("HCalGeom") << "Input " << iphi << " " << layer << " " << iphi << " Alpha "
850 #endif
851 
852  double zi, zo;
853  if (iphi == 0) {
854  zi = getZminBlock(mod);
855  zo = zi + getLayerT(layer);
856  } else {
857  zo = getZmaxBlock(mod);
858  zi = zo - getLayerT(layer);
859  }
860  double rin, rout;
861  if (mod == 0) {
862  rin = zo * tan(getAngTop());
863  rout = (zi - getZ1Beam()) * getSlope();
864  } else {
865  rin = zo * tan(getAngBot());
866  rout = zi * tan(getAngTop());
867  }
868  yh = 0.5 * (rout - rin);
869  bl = 0.5 * rin * tan(alpha);
870  tl = 0.5 * rout * tan(alpha);
871  xpos = 0.5 * (rin + rout);
872  ypos = 0.5 * (bl + tl);
873  zpos = 0.5 * (zi + zo);
874  yh -= getTrim(mod, iphi);
875  bl -= getTrim(mod, iphi);
876  tl -= getTrim(mod, iphi);
877  alp = atan(0.5 * tan(alpha));
878  if (iphi == 0) {
879  ypos = -ypos;
880  } else {
881  alp = -alp;
882  }
883 
884 #ifdef EDM_ML_DEBUG
885  edm::LogVerbatim("HCalGeom") << "Output Dimensions " << yh << " " << bl << " " << tl << " " << convertRadToDeg(alp)
886  << " Position " << xpos << " " << ypos << " " << zpos;
887 #endif
888 }
889 
891  double rinF,
892  double routF,
893  double rinB,
894  double routB,
895  double zi,
896  double zo,
897  double& yh1,
898  double& bl1,
899  double& tl1,
900  double& yh2,
901  double& bl2,
902  double& tl2,
903  double& alp,
904  double& theta,
905  double& phi,
906  double& xpos,
907  double& ypos,
908  double& zpos) {
909  //Given rin, rout compute parameters of the trapezoid and
910  //position of the trapezoid for a standrd layer
911  double alpha = (1._pi) / getNsectors();
912 
913 #ifdef EDM_ML_DEBUG
914  edm::LogVerbatim("HCalGeom") << "Input " << iphi << " Front " << rinF << " " << routF << " " << zi << " Back " << rinB
915  << " " << routB << " " << zo << " Alpha " << convertRadToDeg(alpha);
916 #endif
917 
918  yh1 = 0.5 * (routF - rinB);
919  bl1 = 0.5 * rinB * tan(alpha);
920  tl1 = 0.5 * routF * tan(alpha);
921  yh2 = 0.5 * (routF - rinB);
922  bl2 = 0.5 * rinB * tan(alpha);
923  tl2 = 0.5 * routF * tan(alpha);
924  double dx = 0.25 * (bl2 + tl2 - bl1 - tl1);
925  double dy = 0.5 * (rinB + routF - rinB - routF);
926  xpos = 0.25 * (rinB + routF + rinB + routF);
927  ypos = 0.25 * (bl2 + tl2 + bl1 + tl1);
928  zpos = 0.5 * (zi + zo);
929  alp = atan(0.5 * tan(alpha));
930  // ypos-= getTolPos();
931  if (iphi == 0) {
932  ypos = -ypos;
933  } else {
934  alp = -alp;
935  dx = -dx;
936  }
937  double r = sqrt(dx * dx + dy * dy);
938  theta = atan(r / (zo - zi));
939  phi = atan2(dy, dx);
940 
941 #ifdef EDM_ML_DEBUG
942  edm::LogVerbatim("HCalGeom") << "Output Dimensions " << yh1 << " " << bl1 << " " << tl1 << " " << yh2 << " " << bl2
943  << " " << tl2 << " " << convertRadToDeg(alp) << " " << convertRadToDeg(theta) << " "
944  << convertRadToDeg(phi) << " Position " << xpos << " " << ypos << " " << zpos;
945 #endif
946 }
947 
949 #ifdef EDM_ML_DEBUG
950  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: \t\tInside module0 ..." << mod;
951 #endif
952 
954  //Pointers to the Rotation Matrices and to the Materials
955  std::string rotstr = getRotMat();
956  DDRotation rot(DDName(rotstr, rotns));
958  DDMaterial matabsorbr(matName);
960  DDMaterial matplastic(plasName);
961 
962  int layer = getLayer(mod, 0);
963  int layer0 = getLayer(mod, 1);
965  double xpos, ypos, zpos;
966  DDSolid solid;
967  DDLogicalPart glog, plog;
968  for (int iphi = 0; iphi < getPhi(); iphi++) {
969  double yh, bl, tl, alp;
970  parameterLayer0(mod, layer, iphi, yh, bl, tl, alp, xpos, ypos, zpos);
971  name = module.name().name() + getLayerName(layer) + getPhiName(iphi);
972  solid =
973  DDSolidFactory::trap(DDName(name, idNameSpace), 0.5 * getLayerT(layer), 0, 0, yh, bl, tl, alp, yh, bl, tl, alp);
974 
975 #ifdef EDM_ML_DEBUG
976  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << solid.name() << " Trap made of " << getPlastMat()
977  << " of dimensions " << 0.5 * getLayerT(layer) << ", 0, 0, " << yh << ", " << bl
978  << ", " << tl << ", " << convertRadToDeg(alp) << ", " << yh << ", " << bl << ", " << tl
979  << ", " << convertRadToDeg(alp);
980 #endif
981 
982  glog = DDLogicalPart(solid.ddname(), matplastic, solid);
983 
984  DDTranslation r1(xpos, ypos, zpos);
985  cpv.position(glog, module, idOffset + layer + 1, r1, rot);
986 
987 #ifdef EDM_ML_DEBUG
988  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << glog.name() << " number " << idOffset + layer + 1
989  << " positioned in " << module.name() << " at " << r1 << " with " << rot;
990 #endif
991 
992  //Now construct the layer of scintillator inside this
993  int copyNo = layer0 * 10 + getLayerType(layer);
995  constructScintLayer(glog, getScintT(layer), yh, bl, tl, alp, name, copyNo, cpv);
996  }
997 
998  //Now the absorber layer
999  double zi = getZminBlock(mod) + getLayerT(layer);
1000  double zo = zi + 0.5 * getDzStep();
1001  double rinF, routF, rinB, routB;
1002  if (mod == 0) {
1003  rinF = zi * tan(getAngTop());
1004  routF = (zi - getZ1Beam()) * getSlope();
1005  rinB = zo * tan(getAngTop());
1006  routB = (zo - getZ1Beam()) * getSlope();
1007  } else {
1008  rinF = zi * tan(getAngBot());
1009  routF = zi * tan(getAngTop());
1010  rinB = zo * tan(getAngBot());
1011  routB = zo * tan(getAngTop());
1012  }
1013 
1014 #ifdef EDM_ML_DEBUG
1015  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: Module " << mod << " Front " << zi << ", " << rinF << ", " << routF
1016  << " Back " << zo << ", " << rinB << ", " << routB;
1017 #endif
1018 
1019  double yh1, bl1, tl1, yh2, bl2, tl2, theta, phi, alp;
1020  parameterLayer(0, rinF, routF, rinB, routB, zi, zo, yh1, bl1, tl1, yh2, bl2, tl2, alp, theta, phi, xpos, ypos, zpos);
1021  double fact = getTolAbs();
1022 
1023 #ifdef EDM_ML_DEBUG
1024  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: Trim " << fact << " Param " << yh1 << ", " << bl1 << ", " << tl1
1025  << ", " << yh2 << ", " << bl2 << ", " << tl2;
1026 #endif
1027 
1028  bl1 -= fact;
1029  tl1 -= fact;
1030  bl2 -= fact;
1031  tl2 -= fact;
1032 
1033  name = module.name().name() + "Absorber";
1034  solid = DDSolidFactory::trap(
1035  DDName(name, idNameSpace), 0.5 * getThick(mod), theta, phi, yh1, bl1, tl1, alp, yh2, bl2, tl2, alp);
1036 #ifdef EDM_ML_DEBUG
1037  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << solid.name() << " Trap made of " << getAbsMat()
1038  << " of dimensions " << 0.5 * getThick(mod) << ", " << convertRadToDeg(theta) << ", "
1039  << convertRadToDeg(phi) << ", " << yh1 << ", " << bl1 << ", " << tl1 << ", "
1040  << convertRadToDeg(alp) << ", " << yh2 << ", " << bl2 << ", " << tl2 << ", "
1041  << convertRadToDeg(alp);
1042 #endif
1043 
1044  glog = DDLogicalPart(solid.ddname(), matabsorbr, solid);
1045 
1046  DDTranslation r2(xpos, ypos, zpos);
1047  cpv.position(glog, module, 1, r2, rot);
1048 
1049 #ifdef EDM_ML_DEBUG
1050  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << glog.name() << " number 1 positioned in " << module.name()
1051  << " at " << r2 << " with " << rot;
1052 #endif
1053 }
1054 
1056 #ifdef EDM_ML_DEBUG
1057  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: \t\tInside module ..." << mod;
1058 #endif
1059 
1061  //Pointers to the Rotation Matrices and to the Materials
1062  std::string rotstr = getRotMat();
1063  DDRotation rot(DDName(rotstr, rotns));
1065  DDMaterial matter(matName);
1067  DDMaterial matplastic(plasName);
1068 
1069  double alpha = (1._pi) / getNsectors();
1070  double zi = getZminBlock(mod);
1071 
1072  for (int i = 0; i < getLayerN(mod); i++) {
1073  std::string name;
1074  DDSolid solid;
1075  DDLogicalPart glog, plog;
1076  int layer = getLayer(mod, i);
1077  double zo = zi + 0.5 * getDzStep();
1078 
1079  for (int iphi = 0; iphi < getPhi(); iphi++) {
1080  double ziAir = zo - getThick(mod);
1081  double rinF, rinB;
1082  if (layer == 1) {
1083  rinF = ziAir * tan(getAngTop());
1084  rinB = zo * tan(getAngTop());
1085  } else {
1086  rinF = ziAir * tan(getAngBot());
1087  rinB = zo * tan(getAngBot());
1088  }
1089  double routF = (ziAir - getZ1Beam()) * getSlope();
1090  double routB = (zo - getZ1Beam()) * getSlope();
1091  if (routF > getRoutBlock2(mod))
1092  routF = getRoutBlock2(mod);
1093  if (routB > getRoutBlock2(mod))
1094  routB = getRoutBlock2(mod);
1095 
1096 #ifdef EDM_ML_DEBUG
1097  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: Layer " << i << " Phi " << iphi << " Front " << ziAir << ", "
1098  << rinF << ", " << routF << " Back " << zo << ", " << rinB << ", " << routB;
1099 #endif
1100 
1101  double yh1, bl1, tl1, yh2, bl2, tl2, theta, phi, alp;
1102  double xpos, ypos, zpos;
1104  iphi, rinF, routF, rinB, routB, ziAir, zo, yh1, bl1, tl1, yh2, bl2, tl2, alp, theta, phi, xpos, ypos, zpos);
1105 
1106  name = module.name().name() + getLayerName(layer) + getPhiName(iphi) + "Air";
1107  solid = DDSolidFactory::trap(
1108  DDName(name, idNameSpace), 0.5 * getThick(mod), theta, phi, yh1, bl1, tl1, alp, yh2, bl2, tl2, alp);
1109 
1110 #ifdef EDM_ML_DEBUG
1111  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << solid.name() << " Trap made of " << getGenMat()
1112  << " of dimensions " << 0.5 * getThick(mod) << ", " << convertRadToDeg(theta) << ", "
1113  << convertRadToDeg(phi) << ", " << yh1 << ", " << bl1 << ", " << tl1 << ", "
1114  << convertRadToDeg(alp) << ", " << yh2 << ", " << bl2 << ", " << tl2 << ", "
1115  << convertRadToDeg(alp);
1116 #endif
1117 
1118  glog = DDLogicalPart(solid.ddname(), matter, solid);
1119 
1120  DDTranslation r1(xpos, ypos, zpos);
1121  cpv.position(glog, module, layer + 1, r1, rot);
1122 
1123 #ifdef EDM_ML_DEBUG
1124  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << glog.name() << " number " << layer + 1
1125  << " positioned in " << module.name() << " at " << r1 << " with " << rot;
1126 #endif
1127 
1128  //Now the plastic with scintillators
1129  double yh = 0.5 * (routF - rinB) - getTrim(mod, iphi);
1130  double bl = 0.5 * rinB * tan(alpha) - getTrim(mod, iphi);
1131  double tl = 0.5 * routF * tan(alpha) - getTrim(mod, iphi);
1132  name = module.name().name() + getLayerName(layer) + getPhiName(iphi);
1133  solid = DDSolidFactory::trap(
1134  DDName(name, idNameSpace), 0.5 * getLayerT(layer), 0, 0, yh, bl, tl, alp, yh, bl, tl, alp);
1135 
1136 #ifdef EDM_ML_DEBUG
1137  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << solid.name() << " Trap made of " << getPlastMat()
1138  << " of dimensions " << 0.5 * getLayerT(layer) << ", 0, 0, " << yh << ", " << bl
1139  << ", " << tl << ", " << convertRadToDeg(alp) << ", " << yh << ", " << bl << ", "
1140  << tl << ", " << convertRadToDeg(alp);
1141 #endif
1142 
1143  plog = DDLogicalPart(solid.ddname(), matplastic, solid);
1144 
1145  ypos = 0.5 * (routF + rinB) - xpos;
1146  DDTranslation r2(0., ypos, 0.);
1147  cpv.position(plog, glog, idOffset + layer + 1, r2, DDRotation());
1148 
1149 #ifdef EDM_ML_DEBUG
1150  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << plog.name() << " number " << idOffset + layer + 1
1151  << " positioned in " << glog.name() << " at " << r2 << " with no rotation";
1152 #endif
1153 
1154  //Constructin the scintillators inside
1155  int copyNo = layer * 10 + getLayerType(layer);
1157  constructScintLayer(plog, getScintT(layer), yh, bl, tl, alp, name, copyNo, cpv);
1158  zo += 0.5 * getDzStep();
1159  } // End of loop over phi indices
1160  zi = zo - 0.5 * getDzStep();
1161  } // End of loop on layers
1162 }
1163 
1165  double dz,
1166  double yh,
1167  double bl,
1168  double tl,
1169  double alp,
1170  const std::string& nm,
1171  int id,
1172  DDCompactView& cpv) {
1174  DDMaterial matter(matname);
1175  std::string name = idName + "Scintillator" + nm;
1176 
1177  DDSolid solid = DDSolidFactory::trap(DDName(name, idNameSpace), 0.5 * dz, 0, 0, yh, bl, tl, alp, yh, bl, tl, alp);
1178 
1179 #ifdef EDM_ML_DEBUG
1180  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << DDName(name, idNameSpace) << " Trap made of " << getScintMat()
1181  << " of dimensions " << 0.5 * dz << ", 0, 0, " << yh << ", " << bl << ", " << tl << ", "
1182  << convertRadToDeg(alp) << ", " << yh << ", " << bl << ", " << tl << ", "
1183  << convertRadToDeg(alp);
1184 #endif
1185 
1186  DDLogicalPart glog(solid.ddname(), matter, solid);
1187 
1188  cpv.position(glog, detector, id, DDTranslation(0, 0, 0), DDRotation());
1189 
1190 #ifdef EDM_ML_DEBUG
1191  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapAlgo: " << glog.name() << " number " << id << " positioned in "
1192  << detector.name() << " at (0,0,0) with no rotation";
1193 #endif
1194 }
1195 
1196 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDHCalEndcapAlgo, "hcal:DDHCalEndcapAlgo");
Log< level::Info, true > LogVerbatim
static AlgebraicMatrix initialize()
void execute(DDCompactView &cpv) override
double getThick(unsigned int i) const
std::vector< int > layerN2
std::vector< int > modType
std::string idNameSpace
std::vector< double > zminBlock
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
std::vector< int > layerN0
std::vector< std::string > modMat
int getSectionModule(unsigned i) const
int getLayerType(unsigned int i) const
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
int getLayers() const
const std::string & getGenMat() const
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
static const double slope[3]
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
double getAngGap() const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
double getDzShift() const
void constructInsideSector(const DDLogicalPart &sector, DDCompactView &cpv)
double getZiL0Nose() const
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
std::vector< double > routBlock1
double getDrEnd() const
void constructInsideModule(const DDLogicalPart &module, int mod, DDCompactView &cpv)
static std::string & ns()
std::vector< double > zmaxBlock
double getZEnd() const
double getRinKink() const
int getLayer(unsigned int i, unsigned int j) const
const std::string & getModMat(unsigned int i) const
double getAngTop() const
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
double getHeboxDepth() const
double getRout() const
std::string formatAsDegreesInInteger(double radianVal)
Definition: DDTypes.cc:79
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
int getEndcaps() const
std::vector< double > routBlock2
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
double getRinDip() const
U second(std::pair< T, U > const &p)
double getZShift() const
double getTolPos() const
std::vector< std::string > layerName
int equipModule(unsigned int i) const
constexpr uint8_t getLayer(uint32_t detId)
void parameterLayer0(int mod, int layer, int iphi, double &yh, double &bl, double &tl, double &alp, double &xpos, double &ypos, double &zcpv)
std::vector< int > layerN1
double getZminBlock(unsigned i) const
void constructScintLayer(const DDLogicalPart &glog, double pDz, double yh, double bl, double tl, double alp, const std::string &name, int id, DDCompactView &cpv)
double getZiBody() const
int getLayerN(unsigned int i) const
std::vector< int > layerN4
T sqrt(T t)
Definition: SSEVec.h:19
double getZ0Beam() const
const std::string & getPhiName(unsigned int i) const
double getZmaxBlock(unsigned i) const
double getRoutDip() const
std::vector< int > sectionModule
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
double getZiL0Body() const
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
DDRotation DDrot(const DDName &name, std::unique_ptr< DDRotationMatrix > rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:67
std::vector< double > rinBlock1
double getRinBlock2(unsigned i) const
std::vector< std::string > modName
std::vector< int > layerN5
~DDHCalEndcapAlgo() override
static DDSolid trap(const DDName &name, double pDz, double pTheta, double pPhi, double pDy1, double pDx1, double pDx2, double pAlp1, double pDy2, double pDx3, double pDx4, double pAlp2)
Definition: DDSolid.cc:609
std::vector< int > eModule
ii
Definition: cuy.py:589
std::vector< int > dbl_to_int(const std::vector< double > &vecdbl)
Converts a std::vector of doubles to a std::vector of int.
Definition: DDutils.h:7
std::vector< int > layerType
std::vector< int > layerN
const N & name() const
Definition: DDBase.h:59
double getSlope() const
int getNsectortot() const
double getRoutBlock1(unsigned i) const
const double fact
double getTrim(unsigned int i, unsigned int j) const
const N & ddname() const
Definition: DDBase.h:61
void constructGeneralVolume(DDCompactView &cpv)
double getRinBlock1(unsigned i) const
void constructInsideModule0(const DDLogicalPart &module, int mod, DDCompactView &cpv)
const std::string & getRotMat() const
double getZiDip() const
double getZiKink() const
double getTolAbs() const
double getLayerT(unsigned int i) const
std::vector< double > rinBlock2
std::vector< double > trimRight
double getZShiftHac2() const
double getScintT(unsigned int i) const
const std::string & getScintMat() const
double getAngBot() const
double getZiNose() const
const std::string & getRotation() const
const std::string & getModName(unsigned int i) const
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::vector< int > layerN3
double getDzStep() const
std::vector< std::string > phiName
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 &zcpv)
std::string genMaterial
std::vector< double > thick
int getNsectors() const
const std::string & getAbsMat() const
int getModules() const
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
int getModType(unsigned int i) const
double getRoutBlock2(unsigned i) const
std::vector< double > scintT
std::vector< double > layerT
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:3
Geom::Theta< T > theta() const
double getZFront() const
const std::string & getLayerName(unsigned int i) const
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
double getZ1Beam() const
static DDSolid polyhedra(const DDName &name, int sides, double startPhi, double deltaPhi, const std::vector< double > &z, const std::vector< double > &rmin, const std::vector< double > &rmax)
Creates a polyhedra (refere to Geant3 or Geant4 documentation)
Definition: DDSolid.cc:565
const std::string & getPlastMat() const
std::vector< double > trimLeft