CMS 3D CMS Logo

DDHCalEndcapModuleAlgo.cc
Go to the documentation of this file.
1 // File: DDHCalEndcapModuleAlgo.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 DDHCalEndcapModuleAlgo : public DDAlgorithm {
30 public:
31  //Constructor and Destructor
32  DDHCalEndcapModuleAlgo(); //const std::string & name);
33  ~DDHCalEndcapModuleAlgo() override;
34 
35  struct HcalEndcapPar {
36  double yh1, bl1, tl1, yh2, bl2, tl2, alp, theta, phi, xpos, ypos, zpos;
37  HcalEndcapPar(double yh1v = 0,
38  double bl1v = 0,
39  double tl1v = 0,
40  double yh2v = 0,
41  double bl2v = 0,
42  double tl2v = 0,
43  double alpv = 0,
44  double thv = 0,
45  double fiv = 0,
46  double x = 0,
47  double y = 0,
48  double z = 0)
49  : yh1(yh1v),
50  bl1(bl1v),
51  tl1(tl1v),
52  yh2(yh2v),
53  bl2(bl2v),
54  tl2(tl2v),
55  alp(alpv),
56  theta(thv),
57  phi(fiv),
58  xpos(x),
59  ypos(y),
60  zpos(z) {}
61  };
62  void initialize(const DDNumericArguments& nArgs,
63  const DDVectorArguments& vArgs,
64  const DDMapArguments& mArgs,
65  const DDStringArguments& sArgs,
66  const DDStringVectorArguments& vsArgs) override;
67  void execute(DDCompactView& cpv) override;
68 
69 private:
70  void constructInsideModule0(const DDLogicalPart& module, DDCompactView& cpv);
71  void constructInsideModule(const DDLogicalPart& module, DDCompactView& cpv);
72  HcalEndcapPar parameterLayer0(unsigned int iphi);
73  HcalEndcapPar parameterLayer(
74  unsigned int iphi, double rinF, double routF, double rinB, double routB, double zi, double zo);
75  void constructScintLayer(const DDLogicalPart& detector,
76  double dz,
78  const std::string& nm,
79  int id,
80  DDCompactView& cpv);
81  double getTrim(unsigned int j) const;
82  double getRout(double z) const;
83 
84  std::string genMaterial; //General material
85  std::string absorberMat; //Absorber material
86  std::string plasticMat; //Plastic material cover
87  std::string scintMat; //Scintillator material
88  std::string rotstr; //Rotation matrix to place in mother
89  int sectors; //Number of potenital straight edges
90  double zMinBlock; //Minimum z extent of the block
91  double zMaxBlock; //Maximum
92  double z1Beam; //Position of gap end along z-axis
93  double ziDip; //Starting Z of dipped part of body
94  double dzStep; //Width in Z of a layer
95  double moduleThick; //Thickness of a layer (air/absorber)
96  double layerThick; //Thickness of a layer (plastic)
97  double scintThick; //Thickness of scinitllator
98  double rMaxBack; //Maximum R after the dip
99  double rMaxFront; //Maximum R before the dip
100  double slopeBot; //Slope of the bottom edge
101  double slopeTop; //Slope of the top edge
102  double slopeTopF; //Slope of the top front edge
103  double trimLeft; //Trim of the left edge
104  double trimRight; //Trim of the right edge
105  double tolAbs; //Tolerance for absorber
106  int modType; //Type of module
107  int modNumber; //Module number
108  int layerType; //Layer type
109  std::vector<int> layerNumber; //layer numbers
110  std::vector<std::string> phiName; //Name of Phi sections
111  std::vector<std::string> layerName; //Layer Names
112 
113  std::string idName; //Name of the "parent" volume.
114  std::string idNameSpace; //Namespace of this and ALL sub-parts
115  std::string modName; //Module Name
116  int idOffset; // Geant4 ID's... = 4000;
117 };
118 
120 #ifdef EDM_ML_DEBUG
121  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapModuleAlgo: Creating an instance";
122 #endif
123 }
124 
126 
128  const DDVectorArguments& vArgs,
129  const DDMapArguments&,
130  const DDStringArguments& sArgs,
131  const DDStringVectorArguments& vsArgs) {
132  genMaterial = sArgs["MaterialName"];
133  absorberMat = sArgs["AbsorberMat"];
134  plasticMat = sArgs["PlasticMat"];
135  scintMat = sArgs["ScintMat"];
136  rotstr = sArgs["Rotation"];
137  sectors = int(nArgs["Sectors"]);
138 #ifdef EDM_ML_DEBUG
139  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapModuleAlgo: General material " << genMaterial << "\tAbsorber "
140  << absorberMat << "\tPlastic " << plasticMat << "\tScintillator " << scintMat
141  << "\tRotation " << rotstr << "\tSectors " << sectors;
142 #endif
143  zMinBlock = nArgs["ZMinBlock"];
144  zMaxBlock = nArgs["ZMaxBlock"];
145  z1Beam = nArgs["Z1Beam"];
146  ziDip = nArgs["ZiDip"];
147  dzStep = nArgs["DzStep"];
148  moduleThick = nArgs["ModuleThick"];
149  layerThick = nArgs["LayerThick"];
150  scintThick = nArgs["ScintThick"];
151 #ifdef EDM_ML_DEBUG
152  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapModuleAlgo: Zmin " << zMinBlock << "\tZmax " << zMaxBlock << "\tZ1Beam "
153  << z1Beam << "\tZiDip " << ziDip << "\tDzStep " << dzStep << "\tModuleThick "
154  << moduleThick << "\tLayerThick " << layerThick << "\tScintThick " << scintThick;
155 #endif
156  rMaxFront = nArgs["RMaxFront"];
157  rMaxBack = nArgs["RMaxBack"];
158  trimLeft = nArgs["TrimLeft"];
159  trimRight = nArgs["TrimRight"];
160  tolAbs = nArgs["TolAbs"];
161 #ifdef EDM_ML_DEBUG
162  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapModuleAlgo: RMaxFront " << rMaxFront << "\tRmaxBack " << rMaxBack
163  << "\tTrims " << trimLeft << ":" << trimRight << "\tTolAbs " << tolAbs;
164 #endif
165  slopeBot = nArgs["SlopeBottom"];
166  slopeTop = nArgs["SlopeTop"];
167  slopeTopF = nArgs["SlopeTopFront"];
168  modType = (int)(nArgs["ModType"]);
169  modNumber = (int)(nArgs["ModNumber"]);
170  layerType = (int)(nArgs["LayerType"]);
171 #ifdef EDM_ML_DEBUG
172  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapModuleAlgo: slopeBot " << slopeBot << "\tslopeTop " << slopeTop
173  << "\tslopeTopF " << slopeTopF << "\tmodType " << modType << "\tmodNumber " << modNumber
174  << "\tlayerType " << layerType;
175 #endif
176  layerNumber = dbl_to_int(vArgs["LayerNumber"]);
177 #ifdef EDM_ML_DEBUG
178  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapModuleAlgo: " << layerNumber.size() << " layer Numbers";
179  for (unsigned int i = 0; i < layerNumber.size(); ++i)
180  edm::LogVerbatim("HCalGeom") << "LayerNumber[" << i << "] = " << layerNumber[i];
181 #endif
182  phiName = vsArgs["PhiName"];
183 #ifdef EDM_ML_DEBUG
184  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapModuleAlgo: " << phiName.size() << " phi sectors";
185  for (unsigned int i = 0; i < phiName.size(); ++i)
186  edm::LogVerbatim("HCalGeom") << "PhiName[" << i << "] = " << phiName[i];
187 #endif
188  layerName = vsArgs["LayerName"];
189 #ifdef EDM_ML_DEBUG
190  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapModuleAlgo: " << layerName.size() << " layers";
191  for (unsigned int i = 0; i < layerName.size(); ++i)
192  edm::LogVerbatim("HCalGeom") << "LayerName[" << i << "] = " << layerName[i];
193 #endif
194  idName = sArgs["MotherName"];
195  idNameSpace = DDCurrentNamespace::ns();
196  idOffset = int(nArgs["IdOffset"]);
197  modName = sArgs["ModName"];
198 #ifdef EDM_ML_DEBUG
199  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapModuleAlgo: Parent " << parent().name() << " " << modName << " idName "
200  << idName << " NameSpace " << idNameSpace << " Offset " << idOffset;
201 #endif
202 }
203 
205 // DDHCalEndcapModuleAlgo methods...
207 
209 #ifdef EDM_ML_DEBUG
210  edm::LogVerbatim("HCalGeom") << "==>> Constructing DDHCalEndcapModuleAlgo...";
211 #endif
212  if (modType == 0)
213  constructInsideModule0(parent(), cpv);
214  else
215  constructInsideModule(parent(), cpv);
216 #ifdef EDM_ML_DEBUG
217  edm::LogVerbatim("HCalGeom") << "<<== End of DDHCalEndcapModuleAlgo construction ...";
218 #endif
219 }
220 
222 #ifdef EDM_ML_DEBUG
223  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapModuleAlgo: \t\tInside module0";
224 #endif
225  //Pointers to the Rotation Matrices and to the Materials
227  DDRotation rot(DDName(DDSplit(rotstr).first, DDSplit(rotstr).second));
228  DDName matName(DDSplit(absorberMat).first, DDSplit(absorberMat).second);
229  DDMaterial matabsorbr(matName);
230  DDName plasName(DDSplit(plasticMat).first, DDSplit(plasticMat).second);
231  DDMaterial matplastic(plasName);
232 
233  int layer = layerNumber[0];
234  int layer0 = layerNumber[1];
236  DDSolid solid;
237  DDLogicalPart glog, plog;
238  for (unsigned int iphi = 0; iphi < phiName.size(); iphi++) {
239  DDHCalEndcapModuleAlgo::HcalEndcapPar parm = parameterLayer0(iphi);
240  name = idName + modName + layerName[0] + phiName[iphi];
241  solid = DDSolidFactory::trap(DDName(name, idNameSpace),
242  0.5 * layerThick,
243  0,
244  0,
245  parm.yh1,
246  parm.bl1,
247  parm.tl1,
248  parm.alp,
249  parm.yh2,
250  parm.bl1,
251  parm.tl2,
252  parm.alp);
253 #ifdef EDM_ML_DEBUG
254  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapModuleAlgo: " << solid.name() << " Trap made of " << plasName
255  << " of dimensions " << 0.5 * layerThick << ", 0, 0, " << parm.yh1 << ", " << parm.bl1
256  << ", " << parm.tl1 << ", " << convertRadToDeg(parm.alp) << ", " << parm.yh2 << ", "
257  << parm.bl2 << ", " << parm.tl2 << ", " << convertRadToDeg(parm.alp);
258 #endif
259  glog = DDLogicalPart(solid.ddname(), matplastic, solid);
260 
261  DDTranslation r1(parm.xpos, parm.ypos, parm.zpos);
262  cpv.position(glog, module, idOffset + layer + 1, r1, rot);
263 #ifdef EDM_ML_DEBUG
264  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapModuleAlgo: " << glog.name() << " number " << idOffset + layer + 1
265  << " positioned in " << module.name() << " at " << r1 << " with " << rot;
266 #endif
267  //Now construct the layer of scintillator inside this
268  int copyNo = layer0 * 10 + layerType;
269  name = modName + layerName[0] + phiName[iphi];
270  constructScintLayer(glog, scintThick, parm, name, copyNo, cpv);
271  }
272 
273  //Now the absorber layer
274  double zi = zMinBlock + layerThick;
275  double zo = zi + 0.5 * dzStep;
276  double rinF, routF, rinB, routB;
277  if (modNumber == 0) {
278  rinF = zi * slopeTopF;
279  routF = (zi - z1Beam) * slopeTop;
280  rinB = zo * slopeTopF;
281  routB = (zo - z1Beam) * slopeTop;
282  } else if (modNumber > 0) {
283  rinF = zi * slopeBot;
284  routF = zi * slopeTopF;
285  rinB = zo * slopeBot;
286  routB = zo * slopeTopF;
287  } else {
288  rinF = zi * slopeBot;
289  routF = (zi - z1Beam) * slopeTop;
290  rinB = zo * slopeBot;
291  routB = (zo - z1Beam) * slopeTop;
292  }
293 #ifdef EDM_ML_DEBUG
294  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapModuleAlgo: Front " << zi << ", " << rinF << ", " << routF << " Back "
295  << zo << ", " << rinB << ", " << routB;
296 #endif
297  DDHCalEndcapModuleAlgo::HcalEndcapPar parm = parameterLayer(0, rinF, routF, rinB, routB, zi, zo);
298 #ifdef EDM_ML_DEBUG
299  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapModuleAlgo: Trim " << tolAbs << " Param " << parm.yh1 << ", " << parm.bl1
300  << ", " << parm.tl1 << ", " << parm.yh2 << ", " << parm.bl2 << ", " << parm.tl2;
301 #endif
302  parm.bl1 -= tolAbs;
303  parm.tl1 -= tolAbs;
304  parm.bl2 -= tolAbs;
305  parm.tl2 -= tolAbs;
306 
307  name = idName + modName + layerName[0] + "Absorber";
308  solid = DDSolidFactory::trap(DDName(name, idNameSpace),
309  0.5 * moduleThick,
310  parm.theta,
311  parm.phi,
312  parm.yh1,
313  parm.bl1,
314  parm.tl1,
315  parm.alp,
316  parm.yh2,
317  parm.bl2,
318  parm.tl2,
319  parm.alp);
320 #ifdef EDM_ML_DEBUG
321  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapModuleAlgo: " << solid.name() << " Trap made of " << matName
322  << " of dimensions " << 0.5 * moduleThick << ", " << convertRadToDeg(parm.theta) << ", "
323  << convertRadToDeg(parm.phi) << ", " << parm.yh1 << ", " << parm.bl1 << ", " << parm.tl1
324  << ", " << convertRadToDeg(parm.alp) << ", " << parm.yh2 << ", " << parm.bl2 << ", "
325  << parm.tl2 << ", " << convertRadToDeg(parm.alp);
326 #endif
327  glog = DDLogicalPart(solid.ddname(), matabsorbr, solid);
328 
329  DDTranslation r2(parm.xpos, parm.ypos, parm.zpos);
330  cpv.position(glog, module, 1, r2, rot);
331 #ifdef EDM_ML_DEBUG
332  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapModuleAlgo: " << glog.name() << " number 1 positioned in "
333  << module.name() << " at " << r2 << " with " << rot;
334 #endif
335 }
336 
338 #ifdef EDM_ML_DEBUG
339  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapModuleAlgo: \t\tInside module";
340 #endif
341  //Pointers to the Rotation Matrices and to the Materials
343  DDRotation rot(DDName(DDSplit(rotstr).first, DDSplit(rotstr).second));
344  DDName matName(DDSplit(genMaterial).first, DDSplit(genMaterial).second);
345  DDMaterial matter(matName);
346  DDName plasName(DDSplit(plasticMat).first, DDSplit(plasticMat).second);
347  DDMaterial matplastic(plasName);
348 
349  double alpha = (1._pi) / sectors;
350  double zi = zMinBlock;
351 
352  for (unsigned int i = 0; i < layerName.size(); i++) {
354  DDSolid solid;
355  DDLogicalPart glog, plog;
356  int layer = layerNumber[i];
357  double zo = zi + 0.5 * dzStep;
358 
359  for (unsigned int iphi = 0; iphi < phiName.size(); iphi++) {
360  double ziAir = zo - moduleThick;
361  double rinF, rinB;
362  if (modNumber == 0) {
363  rinF = ziAir * slopeTopF;
364  rinB = zo * slopeTopF;
365  } else {
366  rinF = ziAir * slopeBot;
367  rinB = zo * slopeBot;
368  }
369  double routF = getRout(ziAir);
370  double routB = getRout(zo);
371 #ifdef EDM_ML_DEBUG
372  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapModuleAlgo: Layer " << i << " Phi " << iphi << " Front " << ziAir
373  << ", " << rinF << ", " << routF << " Back " << zo << ", " << rinB << ", " << routB;
374 #endif
375  DDHCalEndcapModuleAlgo::HcalEndcapPar parm = parameterLayer(iphi, rinF, routF, rinB, routB, ziAir, zo);
376 
377  name = idName + modName + layerName[i] + phiName[iphi] + "Air";
378  solid = DDSolidFactory::trap(DDName(name, idNameSpace),
379  0.5 * moduleThick,
380  parm.theta,
381  parm.phi,
382  parm.yh1,
383  parm.bl1,
384  parm.tl1,
385  parm.alp,
386  parm.yh2,
387  parm.bl2,
388  parm.tl2,
389  parm.alp);
390 #ifdef EDM_ML_DEBUG
391  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapModuleAlgo: " << solid.name() << " Trap made of " << matName
392  << " of dimensions " << 0.5 * moduleThick << ", " << convertRadToDeg(parm.theta)
393  << ", " << convertRadToDeg(parm.phi) << ", " << parm.yh1 << ", " << parm.bl1 << ", "
394  << parm.tl1 << ", " << convertRadToDeg(parm.alp) << ", " << parm.yh2 << ", "
395  << parm.bl2 << ", " << parm.tl2 << ", " << convertRadToDeg(parm.alp);
396 #endif
397  glog = DDLogicalPart(solid.ddname(), matter, solid);
398 
399  DDTranslation r1(parm.xpos, parm.ypos, parm.zpos);
400  cpv.position(glog, module, layer + 1, r1, rot);
401 #ifdef EDM_ML_DEBUG
402  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapModuleAlgo: " << glog.name() << " number " << layer + 1
403  << " positioned in " << module.name() << " at " << r1 << " with " << rot;
404 #endif
405  //Now the plastic with scintillators
406  parm.yh1 = 0.5 * (routF - rinB) - getTrim(iphi);
407  parm.bl1 = 0.5 * rinB * tan(alpha) - getTrim(iphi);
408  parm.tl1 = 0.5 * routF * tan(alpha) - getTrim(iphi);
409  name = idName + modName + layerName[i] + phiName[iphi];
410  solid = DDSolidFactory::trap(DDName(name, idNameSpace),
411  0.5 * layerThick,
412  0,
413  0,
414  parm.yh1,
415  parm.bl1,
416  parm.tl1,
417  parm.alp,
418  parm.yh1,
419  parm.bl1,
420  parm.tl1,
421  parm.alp);
422 #ifdef EDM_ML_DEBUG
423  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapModuleAlgo: " << solid.name() << " Trap made of " << plasName
424  << " of dimensions " << 0.5 * layerThick << ", 0, 0, " << parm.yh1 << ", "
425  << parm.bl1 << ", " << parm.tl1 << ", " << convertRadToDeg(parm.alp) << ", "
426  << parm.yh1 << ", " << parm.bl1 << ", " << parm.tl1 << ", "
427  << convertRadToDeg(parm.alp);
428 #endif
429  plog = DDLogicalPart(solid.ddname(), matplastic, solid);
430 
431  double ypos = 0.5 * (routF + rinB) - parm.xpos;
432  DDTranslation r2(0., ypos, 0.);
433  cpv.position(plog, glog, idOffset + layer + 1, r2, DDRotation());
434 #ifdef EDM_ML_DEBUG
435  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapModuleAlgo: " << plog.name() << " number " << idOffset + layer + 1
436  << " positioned in " << glog.name() << " at " << r2 << " with no rotation";
437 #endif
438  //Constructin the scintillators inside
439  int copyNo = layer * 10 + layerType;
440  name = modName + layerName[i] + phiName[iphi];
441  constructScintLayer(plog, scintThick, parm, name, copyNo, cpv);
442  zo += 0.5 * dzStep;
443  } // End of loop over phi indices
444  zi = zo - 0.5 * dzStep;
445  } // End of loop on layers
446 }
447 
450  //Given module and layer number compute parameters of trapezoid
451  //and positioning parameters
452  double alpha = (1._pi) / sectors;
453 #ifdef EDM_ML_DEBUG
454  edm::LogVerbatim("HCalGeom") << "Input " << iphi << " Alpha " << convertRadToDeg(alpha);
455 #endif
456  double zi, zo;
457  if (iphi == 0) {
458  zi = zMinBlock;
459  zo = zi + layerThick;
460  } else {
461  zo = zMaxBlock;
462  zi = zo - layerThick;
463  }
464  double rin, rout;
465  if (modNumber == 0) {
466  rin = zo * slopeTopF;
467  rout = (zi - z1Beam) * slopeTop;
468  } else if (modNumber > 0) {
469  rin = zo * slopeBot;
470  rout = zi * slopeTopF;
471  } else {
472  rin = zo * slopeBot;
473  rout = (zi - z1Beam) * slopeTop;
474  }
475 #ifdef EDM_ML_DEBUG
476  edm::LogVerbatim("HCalGeom") << "ModNumber " << modNumber << " " << zi << " " << zo << " " << slopeTopF << " "
477  << slopeTop << " " << slopeBot << " " << rin << " " << rout << " " << getTrim(iphi);
478 #endif
479  double yh = 0.5 * (rout - rin);
480  double bl = 0.5 * rin * tan(alpha);
481  double tl = 0.5 * rout * tan(alpha);
482  parm.xpos = 0.5 * (rin + rout);
483  parm.ypos = 0.5 * (bl + tl);
484  parm.zpos = 0.5 * (zi + zo);
485  parm.yh1 = parm.yh2 = yh - getTrim(iphi);
486  parm.bl1 = parm.bl2 = bl - getTrim(iphi);
487  parm.tl1 = parm.tl2 = tl - getTrim(iphi);
488  parm.alp = atan(0.5 * tan(alpha));
489  if (iphi == 0) {
490  parm.ypos = -parm.ypos;
491  } else {
492  parm.alp = -parm.alp;
493  }
494 #ifdef EDM_ML_DEBUG
495  edm::LogVerbatim("HCalGeom") << "Output Dimensions " << parm.yh1 << " " << parm.bl1 << " " << parm.tl1 << " "
496  << convertRadToDeg(parm.alp) << " Position " << parm.xpos << " " << parm.ypos << " "
497  << parm.zpos;
498 #endif
499  return parm;
500 }
501 
503  unsigned int iphi, double rinF, double routF, double rinB, double routB, double zi, double zo) {
505  //Given rin, rout compute parameters of the trapezoid and
506  //position of the trapezoid for a standrd layer
507  double alpha = (1._pi) / sectors;
508 #ifdef EDM_ML_DEBUG
509  edm::LogVerbatim("HCalGeom") << "Input " << iphi << " Front " << rinF << " " << routF << " " << zi << " Back " << rinB
510  << " " << routB << " " << zo << " Alpha " << convertRadToDeg(alpha);
511 #endif
512  parm.yh1 = 0.5 * (routF - rinB);
513  parm.bl1 = 0.5 * rinB * tan(alpha);
514  parm.tl1 = 0.5 * routF * tan(alpha);
515  parm.yh2 = 0.5 * (routF - rinB);
516  parm.bl2 = 0.5 * rinB * tan(alpha);
517  parm.tl2 = 0.5 * routF * tan(alpha);
518  double dx = 0.25 * (parm.bl2 + parm.tl2 - parm.bl1 - parm.tl1);
519  double dy = 0.5 * (rinB + routF - rinB - routF);
520  parm.xpos = 0.25 * (rinB + routF + rinB + routF);
521  parm.ypos = 0.25 * (parm.bl2 + parm.tl2 + parm.bl1 + parm.tl1);
522  parm.zpos = 0.5 * (zi + zo);
523  parm.alp = atan(0.5 * tan(alpha));
524  if (iphi == 0) {
525  parm.ypos = -parm.ypos;
526  } else {
527  parm.alp = -parm.alp;
528  dx = -dx;
529  }
530  double r = sqrt(dx * dx + dy * dy);
531 #ifdef EDM_ML_DEBUG
532  edm::LogVerbatim("HCalGeom") << "dx|dy|r " << dx << ":" << dy << ":" << r;
533 #endif
534  if (r > 1.0e-8) {
535  parm.theta = atan(r / (zo - zi));
536  parm.phi = atan2(dy, dx);
537  } else {
538  parm.theta = parm.phi = 0;
539  }
540 #ifdef EDM_ML_DEBUG
541  edm::LogVerbatim("HCalGeom") << "Output Dimensions " << parm.yh1 << " " << parm.bl1 << " " << parm.tl1 << " "
542  << parm.yh2 << " " << parm.bl2 << " " << parm.tl2 << " " << convertRadToDeg(parm.alp)
543  << " " << convertRadToDeg(parm.theta) << " " << convertRadToDeg(parm.phi) << " Position "
544  << parm.xpos << " " << parm.ypos << " " << parm.zpos;
545 #endif
546  return parm;
547 }
548 
550  double dz,
552  const std::string& nm,
553  int id,
554  DDCompactView& cpv) {
555  DDName matname(DDSplit(scintMat).first, DDSplit(scintMat).second);
556  DDMaterial matter(matname);
557  std::string name = idName + "Scintillator" + nm;
558 
559  DDSolid solid = DDSolidFactory::trap(DDName(name, idNameSpace),
560  0.5 * dz,
561  0,
562  0,
563  parm.yh1,
564  parm.bl1,
565  parm.tl1,
566  parm.alp,
567  parm.yh1,
568  parm.bl1,
569  parm.tl1,
570  parm.alp);
571 #ifdef EDM_ML_DEBUG
572  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapModuleAlgo: " << solid.name() << " Trap made of " << scintMat
573  << " of dimensions " << 0.5 * dz << ", 0, 0, " << parm.yh1 << ", " << parm.bl1 << ", "
574  << parm.tl1 << ", " << convertRadToDeg(parm.alp) << ", " << parm.yh1 << ", " << parm.bl1
575  << ", " << parm.tl1 << ", " << convertRadToDeg(parm.alp);
576 #endif
577  DDLogicalPart glog(solid.ddname(), matter, solid);
578 
579  cpv.position(glog, detector, id, DDTranslation(0, 0, 0), DDRotation());
580 #ifdef EDM_ML_DEBUG
581  edm::LogVerbatim("HCalGeom") << "DDHCalEndcapModuleAlgo: " << glog.name() << " number " << id << " positioned in "
582  << detector.name() << " at (0,0,0) with no rotation";
583 #endif
584 }
585 
586 double DDHCalEndcapModuleAlgo::getTrim(unsigned int j) const {
587  if (j == 0)
588  return trimLeft;
589  else
590  return trimRight;
591 }
592 
593 double DDHCalEndcapModuleAlgo::getRout(double z) const {
594  double r = (modNumber >= 0) ? ((z - z1Beam) * slopeTop) : z * slopeTopF;
595  if (z > ziDip) {
596  if (r > rMaxBack)
597  r = rMaxBack;
598  } else {
599  if (r > rMaxFront)
600  r = rMaxFront;
601  }
602  return r;
603 }
604 
605 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDHCalEndcapModuleAlgo, "hcal:DDHCalEndcapModuleAlgo");
Log< level::Info, true > LogVerbatim
static AlgebraicMatrix initialize()
HcalEndcapPar parameterLayer(unsigned int iphi, double rinF, double routF, double rinB, double routB, double zi, double zo)
void constructInsideModule0(const DDLogicalPart &module, DDCompactView &cpv)
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
static std::string & ns()
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
HcalEndcapPar parameterLayer0(unsigned int iphi)
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
U second(std::pair< T, U > const &p)
std::vector< std::string > phiName
void constructInsideModule(const DDLogicalPart &module, DDCompactView &cpv)
T sqrt(T t)
Definition: SSEVec.h:19
void constructScintLayer(const DDLogicalPart &detector, double dz, DDHCalEndcapModuleAlgo::HcalEndcapPar parm, const std::string &nm, int id, DDCompactView &cpv)
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
HcalEndcapPar(double yh1v=0, double bl1v=0, double tl1v=0, double yh2v=0, double bl2v=0, double tl2v=0, double alpv=0, double thv=0, double fiv=0, double x=0, double y=0, double z=0)
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< std::string > layerName
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
const N & name() const
Definition: DDBase.h:59
double getTrim(unsigned int j) const
const N & ddname() const
Definition: DDBase.h:61
double getRout(double z) const
void execute(DDCompactView &cpv) override
float x
#define DEFINE_EDM_PLUGIN(factory, type, name)
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
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7