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