CMS 3D CMS Logo

DDHGCalHEAlgo.cc
Go to the documentation of this file.
1 // File: DDHGCalHEAlgo.cc
3 // Description: Geometry factory class for HGCal (Mix)
5 
21 
22 #include <cmath>
23 #include <memory>
24 #include <string>
25 #include <unordered_set>
26 #include <vector>
27 
28 //#define EDM_ML_DEBUG
29 using namespace cms_units::operators;
30 
31 class DDHGCalHEAlgo : public DDAlgorithm {
32 public:
33  // Constructor and Destructor
34  DDHGCalHEAlgo(); // const std::string & name);
35  ~DDHGCalHEAlgo() override;
36 
37  void initialize(const DDNumericArguments& nArgs,
38  const DDVectorArguments& vArgs,
39  const DDMapArguments& mArgs,
40  const DDStringArguments& sArgs,
41  const DDStringVectorArguments& vsArgs) override;
42  void execute(DDCompactView& cpv) override;
43 
44 protected:
45  void constructLayers(const DDLogicalPart&, DDCompactView& cpv);
46  void positionMix(const DDLogicalPart& glog,
47  const std::string& name,
48  int copy,
49  double thick,
50  const DDMaterial& matter,
51  double rin,
52  double rmid,
53  double routF,
54  double zz,
55  DDCompactView& cpv);
56  void positionSensitive(const DDLogicalPart& glog,
57  double rin,
58  double rout,
59  double zpos,
60  int layertype,
61  int layercenter,
62  DDCompactView& cpv);
63 
64 private:
66  std::unique_ptr<HGCalWaferType> waferType_;
67 
68  std::vector<std::string> wafers_; // Wafers
69  std::vector<std::string> materials_; // Materials
70  std::vector<std::string> names_; // Names
71  std::vector<double> thick_; // Thickness of the material
72  std::vector<int> copyNumber_; // Initial copy numbers
73  std::vector<int> layers_; // Number of layers in a section
74  std::vector<double> layerThick_; // Thickness of each section
75  std::vector<double> rMixLayer_; // Partition between Si/Sci part
76  std::vector<int> layerType_; // Type of the layer
77  std::vector<int> layerSense_; // Content of a layer (sensitive?)
78  int firstLayer_; // Copy # of the first sensitive layer
79  int absorbMode_; // Absorber mode
80  std::vector<std::string> materialsTop_; // Materials of top layers
81  std::vector<std::string> namesTop_; // Names of top layers
82  std::vector<double> layerThickTop_; // Thickness of the top sections
83  std::vector<int> layerTypeTop_; // Type of the Top layer
84  std::vector<int> copyNumberTop_; // Initial copy numbers (top section)
85  std::vector<std::string> materialsBot_; // Materials of bottom layers
86  std::vector<std::string> namesBot_; // Names of bottom layers
87  std::vector<double> layerThickBot_; // Thickness of the bottom sections
88  std::vector<int> layerTypeBot_; // Type of the bottom layers
89  std::vector<int> copyNumberBot_; // Initial copy numbers (bot section)
90  std::vector<int> layerSenseBot_; // Content of bottom layer (sensitive?)
91  std::vector<int> layerCenter_; // Centering of the wafers
92 
93  double zMinBlock_; // Starting z-value of the block
94  std::vector<double> rad100to200_; // Parameters for 120-200mum trans.
95  std::vector<double> rad200to300_; // Parameters for 200-300mum trans.
96  double zMinRadPar_; // Minimum z for radius parametriz.
97  int choiceType_; // Type of parametrization to be used
98  int nCutRadPar_; // Cut off threshold for corners
99  double fracAreaMin_; // Minimum fractional conatined area
100  double waferSize_; // Width of the wafer
101  double waferSepar_; // Sensor separation
102  int sectors_; // Sectors
103  std::vector<double> slopeB_; // Slope at the lower R
104  std::vector<double> zFrontB_; // Starting Z values for the slopes
105  std::vector<double> rMinFront_; // Corresponding rMin's
106  std::vector<double> slopeT_; // Slopes at the larger R
107  std::vector<double> zFrontT_; // Starting Z values for the slopes
108  std::vector<double> rMaxFront_; // Corresponding rMax's
109  std::string nameSpace_; // Namespace of this and ALL sub-parts
110  std::unordered_set<int> copies_; // List of copy #'s
111  double alpha_, cosAlpha_;
112 };
113 
115 #ifdef EDM_ML_DEBUG
116  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: Creating an instance";
117 #endif
118 }
119 
121 
123  const DDVectorArguments& vArgs,
124  const DDMapArguments&,
125  const DDStringArguments& sArgs,
126  const DDStringVectorArguments& vsArgs) {
127  wafers_ = vsArgs["WaferNames"];
128 #ifdef EDM_ML_DEBUG
129  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << wafers_.size() << " wafers";
130  for (unsigned int i = 0; i < wafers_.size(); ++i)
131  edm::LogVerbatim("HGCalGeom") << "Wafer[" << i << "] " << wafers_[i];
132 #endif
133  materials_ = vsArgs["MaterialNames"];
134  names_ = vsArgs["VolumeNames"];
135  thick_ = vArgs["Thickness"];
136  for (unsigned int i = 0; i < materials_.size(); ++i) {
137  copyNumber_.emplace_back(1);
138  }
139 #ifdef EDM_ML_DEBUG
140  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << materials_.size() << " types of volumes";
141  for (unsigned int i = 0; i < names_.size(); ++i)
142  edm::LogVerbatim("HGCalGeom") << "Volume [" << i << "] " << names_[i] << " of thickness " << thick_[i]
143  << " filled with " << materials_[i] << " first copy number " << copyNumber_[i];
144 #endif
145  layers_ = dbl_to_int(vArgs["Layers"]);
146  layerThick_ = vArgs["LayerThick"];
147  rMixLayer_ = vArgs["LayerRmix"];
148 #ifdef EDM_ML_DEBUG
149  edm::LogVerbatim("HGCalGeom") << "There are " << layers_.size() << " blocks";
150  for (unsigned int i = 0; i < layers_.size(); ++i)
151  edm::LogVerbatim("HGCalGeom") << "Block [" << i << "] of thickness " << layerThick_[i] << " Rmid " << rMixLayer_[i]
152  << " with " << layers_[i] << " layers";
153 #endif
154  layerType_ = dbl_to_int(vArgs["LayerType"]);
155  layerSense_ = dbl_to_int(vArgs["LayerSense"]);
156  firstLayer_ = (int)(nArgs["FirstLayer"]);
157  absorbMode_ = (int)(nArgs["AbsorberMode"]);
158 #ifdef EDM_ML_DEBUG
159  edm::LogVerbatim("HGCalGeom") << "First Layer " << firstLayer_ << " and "
160  << "Absober mode " << absorbMode_;
161 #endif
162  layerCenter_ = dbl_to_int(vArgs["LayerCenter"]);
163 #ifdef EDM_ML_DEBUG
164  for (unsigned int i = 0; i < layerCenter_.size(); ++i)
165  edm::LogVerbatim("HGCalGeom") << "LayerCenter [" << i << "] " << layerCenter_[i];
166 #endif
167  if (firstLayer_ > 0) {
168  for (unsigned int i = 0; i < layerType_.size(); ++i) {
169  if (layerSense_[i] > 0) {
170  int ii = layerType_[i];
171  copyNumber_[ii] = firstLayer_;
172 #ifdef EDM_ML_DEBUG
173  edm::LogVerbatim("HGCalGeom") << "First copy number for layer type " << i << ":" << ii << " with "
174  << materials_[ii] << " changed to " << copyNumber_[ii];
175 #endif
176  break;
177  }
178  }
179  }
180 #ifdef EDM_ML_DEBUG
181  edm::LogVerbatim("HGCalGeom") << "There are " << layerType_.size() << " layers";
182  for (unsigned int i = 0; i < layerType_.size(); ++i)
183  edm::LogVerbatim("HGCalGeom") << "Layer [" << i << "] with material type " << layerType_[i] << " sensitive class "
184  << layerSense_[i];
185 #endif
186  materialsTop_ = vsArgs["TopMaterialNames"];
187  namesTop_ = vsArgs["TopVolumeNames"];
188  layerThickTop_ = vArgs["TopLayerThickness"];
189  layerTypeTop_ = dbl_to_int(vArgs["TopLayerType"]);
190  for (unsigned int i = 0; i < materialsTop_.size(); ++i) {
191  copyNumberTop_.emplace_back(1);
192  }
193 #ifdef EDM_ML_DEBUG
194  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << materialsTop_.size() << " types of volumes in the top part";
195  for (unsigned int i = 0; i < materialsTop_.size(); ++i)
196  edm::LogVerbatim("HGCalGeom") << "Volume [" << i << "] " << namesTop_[i] << " of thickness " << layerThickTop_[i]
197  << " filled with " << materialsTop_[i] << " first copy number " << copyNumberTop_[i];
198  edm::LogVerbatim("HGCalGeom") << "There are " << layerTypeTop_.size() << " layers in the top part";
199  for (unsigned int i = 0; i < layerTypeTop_.size(); ++i)
200  edm::LogVerbatim("HGCalGeom") << "Layer [" << i << "] with material type " << layerTypeTop_[i];
201 #endif
202  materialsBot_ = vsArgs["BottomMaterialNames"];
203  namesBot_ = vsArgs["BottomVolumeNames"];
204  layerTypeBot_ = dbl_to_int(vArgs["BottomLayerType"]);
205  layerSenseBot_ = dbl_to_int(vArgs["BottomLayerSense"]);
206  layerThickBot_ = vArgs["BottomLayerThickness"];
207  for (unsigned int i = 0; i < materialsBot_.size(); ++i) {
208  copyNumberBot_.emplace_back(1);
209  }
210 #ifdef EDM_ML_DEBUG
211  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << materialsBot_.size() << " types of volumes in the bottom part";
212  for (unsigned int i = 0; i < materialsBot_.size(); ++i)
213  edm::LogVerbatim("HGCalGeom") << "Volume [" << i << "] " << namesBot_[i] << " of thickness " << layerThickBot_[i]
214  << " filled with " << materialsBot_[i] << " first copy number " << copyNumberBot_[i];
215  edm::LogVerbatim("HGCalGeom") << "There are " << layerTypeBot_.size() << " layers in the bottom part";
216  for (unsigned int i = 0; i < layerTypeBot_.size(); ++i)
217  edm::LogVerbatim("HGCalGeom") << "Layer [" << i << "] with material type " << layerTypeBot_[i]
218  << " sensitive class " << layerSenseBot_[i];
219 #endif
220  zMinBlock_ = nArgs["zMinBlock"];
221  rad100to200_ = vArgs["rad100to200"];
222  rad200to300_ = vArgs["rad200to300"];
223  zMinRadPar_ = nArgs["zMinForRadPar"];
224  choiceType_ = (int)(nArgs["choiceType"]);
225  nCutRadPar_ = (int)(nArgs["nCornerCut"]);
226  fracAreaMin_ = nArgs["fracAreaMin"];
227  waferSize_ = nArgs["waferSize"];
228  waferSepar_ = nArgs["SensorSeparation"];
229  sectors_ = (int)(nArgs["Sectors"]);
230  alpha_ = (1._pi) / sectors_;
231  cosAlpha_ = cos(alpha_);
232 #ifdef EDM_ML_DEBUG
233  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: zStart " << zMinBlock_ << " radius for wafer type separation uses "
234  << rad100to200_.size() << " parameters; zmin " << zMinRadPar_ << " cutoff "
235  << choiceType_ << ":" << nCutRadPar_ << ":" << fracAreaMin_ << " wafer width "
236  << waferSize_ << " separations " << waferSepar_ << " sectors " << sectors_ << ":"
237  << convertRadToDeg(alpha_) << ":" << cosAlpha_;
238  for (unsigned int k = 0; k < rad100to200_.size(); ++k)
239  edm::LogVerbatim("HGCalGeom") << "[" << k << "] 100-200 " << rad100to200_[k] << " 200-300 " << rad200to300_[k];
240 #endif
241  slopeB_ = vArgs["SlopeBottom"];
242  zFrontB_ = vArgs["ZFrontBottom"];
243  rMinFront_ = vArgs["RMinFront"];
244  slopeT_ = vArgs["SlopeTop"];
245  zFrontT_ = vArgs["ZFrontTop"];
246  rMaxFront_ = vArgs["RMaxFront"];
247 #ifdef EDM_ML_DEBUG
248  for (unsigned int i = 0; i < slopeB_.size(); ++i)
249  edm::LogVerbatim("HGCalGeom") << "Block [" << i << "] Zmin " << zFrontB_[i] << " Rmin " << rMinFront_[i]
250  << " Slope " << slopeB_[i];
251  for (unsigned int i = 0; i < slopeT_.size(); ++i)
252  edm::LogVerbatim("HGCalGeom") << "Block [" << i << "] Zmin " << zFrontT_[i] << " Rmax " << rMaxFront_[i]
253  << " Slope " << slopeT_[i];
254 #endif
255  nameSpace_ = DDCurrentNamespace::ns();
256 #ifdef EDM_ML_DEBUG
257  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: NameSpace " << nameSpace_;
258 #endif
259 
260  waferType_ = std::make_unique<HGCalWaferType>(
261  rad100to200_, rad200to300_, (waferSize_ + waferSepar_), zMinRadPar_, choiceType_, nCutRadPar_, fracAreaMin_);
262 }
263 
265 // DDHGCalHEAlgo methods...
267 
269 #ifdef EDM_ML_DEBUG
270  edm::LogVerbatim("HGCalGeom") << "==>> Constructing DDHGCalHEAlgo...";
271  copies_.clear();
272 #endif
273  constructLayers(parent(), cpv);
274 #ifdef EDM_ML_DEBUG
275  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << copies_.size() << " different wafer copy numbers";
276  int k(0);
277  for (std::unordered_set<int>::const_iterator itr = copies_.begin(); itr != copies_.end(); ++itr, ++k) {
278  edm::LogVerbatim("HGCalGeom") << "Copy [" << k << "] : " << (*itr);
279  }
280  copies_.clear();
281  edm::LogVerbatim("HGCalGeom") << "<<== End of DDHGCalHEAlgo construction...";
282 #endif
283 }
284 
286 #ifdef EDM_ML_DEBUG
287  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: \t\tInside Layers";
288 #endif
289  double zi(zMinBlock_);
290  int laymin(0);
291  const double tol(0.01);
292  for (unsigned int i = 0; i < layers_.size(); i++) {
293  double zo = zi + layerThick_[i];
294  double routF = HGCalGeomTools::radius(zi, zFrontT_, rMaxFront_, slopeT_);
295  int laymax = laymin + layers_[i];
296  double zz = zi;
297  double thickTot(0);
298  for (int ly = laymin; ly < laymax; ++ly) {
299  int ii = layerType_[ly];
300  int copy = copyNumber_[ii];
301  double hthick = 0.5 * thick_[ii];
302  double rinB = HGCalGeomTools::radius(zo, zFrontB_, rMinFront_, slopeB_);
303  zz += hthick;
304  thickTot += thick_[ii];
305 
306  std::string name = names_[ii] + std::to_string(copy);
307 #ifdef EDM_ML_DEBUG
308  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: Layer " << ly << ":" << ii << " Front " << zi << ", " << routF
309  << " Back " << zo << ", " << rinB << " superlayer thickness " << layerThick_[i];
310 #endif
311  DDName matName(DDSplit(materials_[ii]).first, DDSplit(materials_[ii]).second);
312  DDMaterial matter(matName);
313  DDLogicalPart glog;
314  if (layerSense_[ly] < 1) {
315  std::vector<double> pgonZ, pgonRin, pgonRout;
316  if (layerSense_[ly] == 0 || absorbMode_ == 0) {
317  double rmax =
318  (std::min(routF, HGCalGeomTools::radius(zz + hthick, zFrontT_, rMaxFront_, slopeT_)) * cosAlpha_) - tol;
319  pgonZ.emplace_back(-hthick);
320  pgonZ.emplace_back(hthick);
321  pgonRin.emplace_back(rinB);
322  pgonRin.emplace_back(rinB);
323  pgonRout.emplace_back(rmax);
324  pgonRout.emplace_back(rmax);
325  } else {
326  HGCalGeomTools::radius(zz - hthick,
327  zz + hthick,
328  zFrontB_,
329  rMinFront_,
330  slopeB_,
331  zFrontT_,
332  rMaxFront_,
333  slopeT_,
334  -layerSense_[ly],
335  pgonZ,
336  pgonRin,
337  pgonRout);
338  for (unsigned int isec = 0; isec < pgonZ.size(); ++isec) {
339  pgonZ[isec] -= zz;
340  pgonRout[isec] = pgonRout[isec] * cosAlpha_ - tol;
341  }
342  }
343  DDSolid solid =
344  DDSolidFactory::polyhedra(DDName(name, nameSpace_), sectors_, -alpha_, 2._pi, pgonZ, pgonRin, pgonRout);
345  glog = DDLogicalPart(solid.ddname(), matter, solid);
346 #ifdef EDM_ML_DEBUG
347  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << solid.name() << " polyhedra of " << sectors_
348  << " sectors covering " << convertRadToDeg(-alpha_) << ":"
349  << convertRadToDeg(-alpha_ + 2._pi) << " with " << pgonZ.size() << " sections";
350  for (unsigned int k = 0; k < pgonZ.size(); ++k)
351  edm::LogVerbatim("HGCalGeom") << "[" << k << "] z " << pgonZ[k] << " R " << pgonRin[k] << ":" << pgonRout[k];
352 #endif
353  } else {
354  DDSolid solid = DDSolidFactory::tubs(DDName(name, nameSpace_), hthick, rinB, routF, 0.0, 2._pi);
355  glog = DDLogicalPart(solid.ddname(), matter, solid);
356 #ifdef EDM_ML_DEBUG
357  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << solid.name() << " Tubs made of " << matName
358  << " of dimensions " << rinB << ", " << routF << ", " << hthick
359  << ", 0.0, 360.0 and positioned in: " << glog.name() << " number " << copy;
360 #endif
361  positionMix(glog, name, copy, thick_[ii], matter, rinB, rMixLayer_[i], routF, zz, cpv);
362  }
363  DDTranslation r1(0, 0, zz);
364  DDRotation rot;
365  cpv.position(glog, module, copy, r1, rot);
366  ++copyNumber_[ii];
367 #ifdef EDM_ML_DEBUG
368  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << glog.name() << " number " << copy << " positioned in "
369  << module.name() << " at " << r1 << " with " << rot;
370 #endif
371  zz += hthick;
372  } // End of loop over layers in a block
373  zi = zo;
374  laymin = laymax;
375  if (std::abs(thickTot - layerThick_[i]) < 0.00001) {
376  } else if (thickTot > layerThick_[i]) {
377  edm::LogError("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " is smaller than " << thickTot
378  << ": thickness of all its "
379  << "components **** ERROR ****";
380  } else if (thickTot < layerThick_[i]) {
381  edm::LogWarning("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " does not match with "
382  << thickTot << " of the components";
383  }
384  } // End of loop over blocks
385 }
386 
388  const std::string& nameM,
389  int copyM,
390  double thick,
391  const DDMaterial& matter,
392  double rin,
393  double rmid,
394  double rout,
395  double zz,
396  DDCompactView& cpv) {
397  DDLogicalPart glog1;
398  DDTranslation tran;
399  DDRotation rot;
400  for (unsigned int ly = 0; ly < layerTypeTop_.size(); ++ly) {
401  int ii = layerTypeTop_[ly];
402  copyNumberTop_[ii] = copyM;
403  }
404  for (unsigned int ly = 0; ly < layerTypeBot_.size(); ++ly) {
405  int ii = layerTypeBot_[ly];
406  copyNumberBot_[ii] = copyM;
407  }
408  double hthick = 0.5 * thick;
409  // Make the top part first
410  std::string name = nameM + "Top";
411  DDSolid solid = DDSolidFactory::tubs(DDName(name, nameSpace_), hthick, rmid, rout, 0.0, 2._pi);
412  glog1 = DDLogicalPart(solid.ddname(), matter, solid);
413 #ifdef EDM_ML_DEBUG
414  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << solid.name() << " Tubs made of " << matter.name()
415  << " of dimensions " << rmid << ", " << rout << ", " << hthick << ", 0.0, 360.0";
416 #endif
417  cpv.position(glog1, glog, 1, tran, rot);
418 #ifdef EDM_ML_DEBUG
419  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << glog1.name() << " number 1 positioned in " << glog.name()
420  << " at " << tran << " with " << rot;
421 #endif
422  double thickTot(0), zpos(-hthick);
423  for (unsigned int ly = 0; ly < layerTypeTop_.size(); ++ly) {
424  int ii = layerTypeTop_[ly];
425  int copy = copyNumberTop_[ii];
426  double hthickl = 0.5 * layerThickTop_[ii];
427  thickTot += layerThickTop_[ii];
428  name = namesTop_[ii] + std::to_string(copy);
429 #ifdef EDM_ML_DEBUG
430  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: Layer " << ly << ":" << ii << " R " << rmid << ":" << rout
431  << " Thick " << layerThickTop_[ii];
432 #endif
433  DDName matName(DDSplit(materialsTop_[ii]).first, DDSplit(materialsTop_[ii]).second);
434  DDMaterial matter1(matName);
435  solid = DDSolidFactory::tubs(DDName(name, nameSpace_), hthickl, rmid, rout, 0.0, 2._pi);
436  DDLogicalPart glog2 = DDLogicalPart(solid.ddname(), matter1, solid);
437 #ifdef EDM_ML_DEBUG
438  double eta1 = -log(tan(0.5 * atan(rmid / zz)));
439  double eta2 = -log(tan(0.5 * atan(rout / zz)));
440  edm::LogVerbatim("HGCalGeom") << name << " z|rin|rout " << zz << ":" << rmid << ":" << rout << " eta " << eta1
441  << ":" << eta2;
442  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << solid.name() << " Tubs made of " << matName
443  << " of dimensions " << rmid << ", " << rout << ", " << hthickl << ", 0.0, 360.0";
444 #endif
445  zpos += hthickl;
446  DDTranslation r1(0, 0, zpos);
447  cpv.position(glog2, glog1, copy, r1, rot);
448 #ifdef EDM_ML_DEBUG
449  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: Position " << glog2.name() << " number " << copy << " in "
450  << glog1.name() << " at " << r1 << " with " << rot;
451 #endif
452  ++copyNumberTop_[ii];
453  zpos += hthickl;
454  }
455  if (std::abs(thickTot - thick) < 0.00001) {
456  } else if (thickTot > thick) {
457  edm::LogError("HGCalGeom") << "Thickness of the partition " << thick << " is smaller than " << thickTot
458  << ": thickness of all its components in "
459  << "the top part **** ERROR ****";
460  } else if (thickTot < thick) {
461  edm::LogWarning("HGCalGeom") << "Thickness of the partition " << thick << " does not match with " << thickTot
462  << " of the components in top part";
463  }
464 
465  // Make the bottom part next
466  name = nameM + "Bottom";
467  solid = DDSolidFactory::tubs(DDName(name, nameSpace_), hthick, rin, rmid, 0.0, 2._pi);
468  glog1 = DDLogicalPart(solid.ddname(), matter, solid);
469 #ifdef EDM_ML_DEBUG
470  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << solid.name() << " Tubs made of " << matter.name()
471  << " of dimensions " << rin << ", " << rmid << ", " << hthick << ", 0.0, 360.0";
472 #endif
473  cpv.position(glog1, glog, 1, tran, rot);
474 #ifdef EDM_ML_DEBUG
475  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << glog1.name() << " number 1 positioned in " << glog.name()
476  << " at " << tran << " with " << rot;
477 #endif
478  thickTot = 0;
479  zpos = -hthick;
480  for (unsigned int ly = 0; ly < layerTypeBot_.size(); ++ly) {
481  int ii = layerTypeBot_[ly];
482  int copy = copyNumberBot_[ii];
483  double hthickl = 0.5 * layerThickBot_[ii];
484  thickTot += layerThickBot_[ii];
485  name = namesBot_[ii] + std::to_string(copy);
486 #ifdef EDM_ML_DEBUG
487  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: Layer " << ly << ":" << ii << " R " << rin << ":" << rmid
488  << " Thick " << layerThickBot_[ii];
489 #endif
490  DDName matName(DDSplit(materialsBot_[ii]).first, DDSplit(materialsBot_[ii]).second);
491  DDMaterial matter1(matName);
492  solid = DDSolidFactory::tubs(DDName(name, nameSpace_), hthickl, rin, rmid, 0.0, 2._pi);
493  DDLogicalPart glog2 = DDLogicalPart(solid.ddname(), matter1, solid);
494 #ifdef EDM_ML_DEBUG
495  double eta1 = -log(tan(0.5 * atan(rin / zz)));
496  double eta2 = -log(tan(0.5 * atan(rmid / zz)));
497  edm::LogVerbatim("HGCalGeom") << name << " z|rin|rout " << zz << ":" << rin << ":" << rmid << " eta " << eta1 << ":"
498  << eta2;
499  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << solid.name() << " Tubs made of " << matName
500  << " of dimensions " << rin << ", " << rmid << ", " << hthickl << ", 0.0, 360.0";
501 #endif
502  zpos += hthickl;
503  DDTranslation r1(0, 0, zpos);
504  cpv.position(glog2, glog1, copy, r1, rot);
505 #ifdef EDM_ML_DEBUG
506  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: Position " << glog2.name() << " number " << copy << " in "
507  << glog1.name() << " at " << r1 << " with " << rot;
508 #endif
509  if (layerSenseBot_[ly] != 0) {
510 #ifdef EDM_ML_DEBUG
511  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: z " << (zz + zpos) << " Center " << copy << ":"
512  << (copy - firstLayer_) << ":" << layerCenter_[copy - firstLayer_];
513 #endif
514  positionSensitive(glog2, rin, rmid, zz + zpos, layerSenseBot_[ly], layerCenter_[copy - firstLayer_], cpv);
515  }
516  zpos += hthickl;
517  ++copyNumberBot_[ii];
518  }
519  if (std::abs(thickTot - thick) < 0.00001) {
520  } else if (thickTot > thick) {
521  edm::LogError("HGCalGeom") << "Thickness of the partition " << thick << " is smaller than " << thickTot
522  << ": thickness of all its components in "
523  << "the top part **** ERROR ****";
524  } else if (thickTot < thick) {
525  edm::LogWarning("HGCalGeom") << "Thickness of the partition " << thick << " does not match with " << thickTot
526  << " of the components in top part";
527  }
528 }
529 
531  double rin,
532  double rout,
533  double zpos,
534  int layertype,
535  int layercenter,
536  DDCompactView& cpv) {
537  static const double sqrt3 = std::sqrt(3.0);
538  double r = 0.5 * (waferSize_ + waferSepar_);
539  double R = 2.0 * r / sqrt3;
540  double dy = 0.75 * R;
541  int N = (int)(0.5 * rout / r) + 2;
542  std::pair<double, double> xyoff = geomTools_.shiftXY(layercenter, (waferSize_ + waferSepar_));
543 #ifdef EDM_ML_DEBUG
544  int ium(0), ivm(0), iumAll(0), ivmAll(0), kount(0), ntot(0), nin(0);
545  std::vector<int> ntype(6, 0);
546  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << glog.ddname() << " rin:rout " << rin << ":" << rout << " zpos "
547  << zpos << " N " << N << " for maximum u, v Offset; Shift " << xyoff.first << ":"
548  << xyoff.second << " WaferSize " << (waferSize_ + waferSepar_);
549 #endif
550  for (int u = -N; u <= N; ++u) {
551  int iu = std::abs(u);
552  for (int v = -N; v <= N; ++v) {
553  int iv = std::abs(v);
554  int nr = 2 * v;
555  int nc = -2 * u + v;
556  double xpos = xyoff.first + nc * r;
557  double ypos = xyoff.second + nr * dy;
558  std::pair<int, int> corner = HGCalGeomTools::waferCorner(xpos, ypos, r, R, rin, rout, false);
559 #ifdef EDM_ML_DEBUG
560  ++ntot;
561 #endif
562  if (corner.first > 0) {
563  int type = waferType_->getType(xpos, ypos, zpos);
564  int copy = type * 1000000 + iv * 100 + iu;
565  if (u < 0)
566  copy += 10000;
567  if (v < 0)
568  copy += 100000;
569 #ifdef EDM_ML_DEBUG
570  if (iu > ium)
571  ium = iu;
572  if (iv > ivm)
573  ivm = iv;
574  kount++;
575  if (copies_.count(copy) == 0)
576  copies_.insert(copy);
577 #endif
578  if (corner.first == (int)(HGCalParameters::k_CornerSize)) {
579 #ifdef EDM_ML_DEBUG
580  if (iu > iumAll)
581  iumAll = iu;
582  if (iv > ivmAll)
583  ivmAll = iv;
584  ++nin;
585 #endif
586  DDTranslation tran(xpos, ypos, 0.0);
588  if (layertype > 1)
589  type += 3;
590  DDName name = DDName(DDSplit(wafers_[type]).first, DDSplit(wafers_[type]).second);
591  cpv.position(name, glog.ddname(), copy, tran, rotation);
592 #ifdef EDM_ML_DEBUG
593  ++ntype[type];
594  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << name << " number " << copy << " positioned in "
595  << glog.ddname() << " at " << tran << " with " << rotation;
596 #endif
597  }
598  }
599  }
600  }
601 #ifdef EDM_ML_DEBUG
602  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: Maximum # of u " << ium << ":" << iumAll << " # of v " << ivm << ":"
603  << ivmAll << " and " << nin << ":" << kount << ":" << ntot << " wafers (" << ntype[0]
604  << ":" << ntype[1] << ":" << ntype[2] << ":" << ntype[3] << ":" << ntype[4] << ":"
605  << ntype[5] << ") for " << glog.ddname() << " R " << rin << ":" << rout;
606 #endif
607 }
608 
609 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDHGCalHEAlgo, "hgcal:DDHGCalHEAlgo");
DDHGCalHEAlgo::layerThick_
std::vector< double > layerThick_
Definition: DDHGCalHEAlgo.cc:74
DDHGCalHEAlgo::layerCenter_
std::vector< int > layerCenter_
Definition: DDHGCalHEAlgo.cc:91
PluginFactory.h
HGCalGeomTools::waferCorner
static std::pair< int32_t, int32_t > waferCorner(double xpos, double ypos, double r, double R, double rMin, double rMax, bool oldBug=false)
Definition: HGCalGeomTools.cc:219
DDHGCalHEAlgo::copies_
std::unordered_set< int > copies_
Definition: DDHGCalHEAlgo.cc:110
DDHGCalHEAlgo::waferSize_
double waferSize_
Definition: DDHGCalHEAlgo.cc:100
DDCurrentNamespace.h
DDHGCalHEAlgo::waferSepar_
double waferSepar_
Definition: DDHGCalHEAlgo.cc:101
mps_fire.i
i
Definition: mps_fire.py:355
cms_units::operators
Definition: CMSUnits.h:13
geometryCSVtoXML.zz
zz
Definition: geometryCSVtoXML.py:19
MessageLogger.h
DDHGCalHEAlgo::rMinFront_
std::vector< double > rMinFront_
Definition: DDHGCalHEAlgo.cc:105
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
DDHGCalHEAlgo::materials_
std::vector< std::string > materials_
Definition: DDHGCalHEAlgo.cc:69
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
DDHGCalHEAlgo::waferType_
std::unique_ptr< HGCalWaferType > waferType_
Definition: DDHGCalHEAlgo.cc:66
DDHGCalHEAlgo::initialize
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDHGCalHEAlgo.cc:122
min
T min(T a, T b)
Definition: MathUtil.h:58
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
DDHGCalHEAlgo::zFrontB_
std::vector< double > zFrontB_
Definition: DDHGCalHEAlgo.cc:104
DDSplit.h
DDHGCalHEAlgo::nCutRadPar_
int nCutRadPar_
Definition: DDHGCalHEAlgo.cc:98
HLT_2018_cff.eta1
eta1
Definition: HLT_2018_cff.py:8220
DDHGCalHEAlgo
Definition: DDHGCalHEAlgo.cc:31
HGCalParameters::k_CornerSize
static constexpr uint32_t k_CornerSize
Definition: HGCalParameters.h:38
DDHGCalHEAlgo::positionSensitive
void positionSensitive(const DDLogicalPart &glog, double rin, double rout, double zpos, int layertype, int layercenter, DDCompactView &cpv)
Definition: DDHGCalHEAlgo.cc:530
DDHGCalHEAlgo::~DDHGCalHEAlgo
~DDHGCalHEAlgo() override
Definition: DDHGCalHEAlgo.cc:120
DDHGCalHEAlgo::namesBot_
std::vector< std::string > namesBot_
Definition: DDHGCalHEAlgo.cc:86
distTCMET_cfi.corner
corner
Definition: distTCMET_cfi.py:38
nin
int nin
Definition: CascadeWrapper.h:114
DDHGCalHEAlgo::constructLayers
void constructLayers(const DDLogicalPart &, DDCompactView &cpv)
Definition: DDHGCalHEAlgo.cc:285
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:215
DDHGCalHEAlgo::copyNumber_
std::vector< int > copyNumber_
Definition: DDHGCalHEAlgo.cc:72
DDHGCalHEAlgo::thick_
std::vector< double > thick_
Definition: DDHGCalHEAlgo.cc:71
findQualityFiles.v
v
Definition: findQualityFiles.py:179
dbl_to_int
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
dqmdumpme.first
first
Definition: dqmdumpme.py:55
DDHGCalHEAlgo::layerTypeTop_
std::vector< int > layerTypeTop_
Definition: DDHGCalHEAlgo.cc:83
DDHGCalHEAlgo::copyNumberTop_
std::vector< int > copyNumberTop_
Definition: DDHGCalHEAlgo.cc:84
DDHGCalHEAlgo::layerSense_
std::vector< int > layerSense_
Definition: DDHGCalHEAlgo.cc:77
DDHGCalHEAlgo::layerThickBot_
std::vector< double > layerThickBot_
Definition: DDHGCalHEAlgo.cc:87
DDHGCalHEAlgo::absorbMode_
int absorbMode_
Definition: DDHGCalHEAlgo.cc:79
DDHGCalHEAlgo::nameSpace_
std::string nameSpace_
Definition: DDHGCalHEAlgo.cc:109
DDHGCalHEAlgo::sectors_
int sectors_
Definition: DDHGCalHEAlgo.cc:102
DDHGCalHEAlgo::geomTools_
HGCalGeomTools geomTools_
Definition: DDHGCalHEAlgo.cc:65
DDMaterial
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
DDHGCalHEAlgo::zFrontT_
std::vector< double > zFrontT_
Definition: DDHGCalHEAlgo.cc:107
DDHGCalHEAlgo::names_
std::vector< std::string > names_
Definition: DDHGCalHEAlgo.cc:70
DDSolidFactory::polyhedra
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:551
DDHGCalHEAlgo::layerThickTop_
std::vector< double > layerThickTop_
Definition: DDHGCalHEAlgo.cc:82
DDTranslation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
DDBase::name
const N & name() const
Definition: DDBase.h:59
HGCalWaferType.h
DDHGCalHEAlgo::rad100to200_
std::vector< double > rad100to200_
Definition: DDHGCalHEAlgo.cc:94
N
#define N
Definition: blowfish.cc:9
DDSolidFactory::tubs
static DDSolid tubs(const DDName &name, double zhalf, double rIn, double rOut, double startPhi, double deltaPhi)
Definition: DDSolid.cc:653
DDSolid.h
DDHGCalHEAlgo::zMinBlock_
double zMinBlock_
Definition: DDHGCalHEAlgo.cc:93
dqmdumpme.k
k
Definition: dqmdumpme.py:60
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
HLT_2018_cff.eta2
eta2
Definition: HLT_2018_cff.py:8221
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DDHGCalHEAlgo::rad200to300_
std::vector< double > rad200to300_
Definition: DDHGCalHEAlgo.cc:95
edm::LogWarning
Definition: MessageLogger.h:141
DDHGCalHEAlgo::namesTop_
std::vector< std::string > namesTop_
Definition: DDHGCalHEAlgo.cc:81
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
DDHGCalHEAlgo::rMaxFront_
std::vector< double > rMaxFront_
Definition: DDHGCalHEAlgo.cc:108
edm::LogError
Definition: MessageLogger.h:183
EgHLTOffHistBins_cfi.nr
nr
Definition: EgHLTOffHistBins_cfi.py:4
DDHGCalHEAlgo::wafers_
std::vector< std::string > wafers_
Definition: DDHGCalHEAlgo.cc:68
DDHGCalHEAlgo::firstLayer_
int firstLayer_
Definition: DDHGCalHEAlgo.cc:78
DDBase::ddname
const N & ddname() const
Definition: DDBase.h:61
edmplugin::PluginFactory
Definition: PluginFactory.h:34
DDHGCalHEAlgo::layers_
std::vector< int > layers_
Definition: DDHGCalHEAlgo.cc:73
DDLogicalPart
A DDLogicalPart aggregates information concerning material, solid and sensitveness ....
Definition: DDLogicalPart.h:93
DDTypes.h
DDMaterial.h
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
createfilelist.int
int
Definition: createfilelist.py:10
DDutils.h
edm::LogVerbatim
Definition: MessageLogger.h:297
HGCalGeomTools
Definition: HGCalGeomTools.h:8
DDHGCalHEAlgo::cosAlpha_
double cosAlpha_
Definition: DDHGCalHEAlgo.cc:111
PVValHelper::dy
Definition: PVValidationHelpers.h:49
DDLogicalPart.h
itr
std::vector< std::pair< float, float > >::iterator itr
Definition: HGCDigitizer.cc:28
module
Definition: vlib.h:198
DDHGCalHEAlgo::fracAreaMin_
double fracAreaMin_
Definition: DDHGCalHEAlgo.cc:99
DDHGCalHEAlgo::execute
void execute(DDCompactView &cpv) override
Definition: DDHGCalHEAlgo.cc:268
DDHGCalHEAlgo::slopeB_
std::vector< double > slopeB_
Definition: DDHGCalHEAlgo.cc:103
alignCSCRings.r
r
Definition: alignCSCRings.py:93
DDHGCalHEAlgo::DDHGCalHEAlgo
DDHGCalHEAlgo()
Definition: DDHGCalHEAlgo.cc:114
DDHGCalHEAlgo::materialsBot_
std::vector< std::string > materialsBot_
Definition: DDHGCalHEAlgo.cc:85
ReadMapType< double >
HGCalGeomTools.h
HGCalGeomTools::radius
static void radius(double zf, double zb, std::vector< double > const &zFront1, std::vector< double > const &rFront1, std::vector< double > const &slope1, std::vector< double > const &zFront2, std::vector< double > const &rFront2, std::vector< double > const &slope2, int flag, std::vector< double > &zz, std::vector< double > &rin, std::vector< double > &rout)
Definition: HGCalGeomTools.cc:11
DDAlgorithm.h
type
type
Definition: HCALResponse.h:21
DDHGCalGeom::constructLayers
void constructLayers(const cms::DDNamespace &ns, const std::vector< std::string > &wafers, const std::vector< std::string > &covers, const std::vector< int > &layerType, const std::vector< int > &layerSense, const std::vector< int > &maxModule, const std::vector< std::string > &names, const std::vector< std::string > &materials, std::vector< int > &copyNumber, const std::vector< double > &layerThick, const double &absorbW, const double &absorbH, const double &waferTot, const double &rMax, const double &rMaxFine, std::unordered_set< int > &copies, int firstLayer, int lastLayer, double zFront, double totalWidth, bool ignoreCenter, dd4hep::Volume &module)
Definition: DDHGCalTBModuleX.cc:21
diffTwoXMLs.r1
r1
Definition: diffTwoXMLs.py:53
DDHGCalHEAlgo::copyNumberBot_
std::vector< int > copyNumberBot_
Definition: DDHGCalHEAlgo.cc:89
DDHGCalHEAlgo::zMinRadPar_
double zMinRadPar_
Definition: DDHGCalHEAlgo.cc:96
DDCurrentNamespace::ns
static std::string & ns()
Definition: DDCurrentNamespace.cc:3
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
DDSolid
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
DDHGCalHEAlgo::layerTypeBot_
std::vector< int > layerTypeBot_
Definition: DDHGCalHEAlgo.cc:88
DDRotation
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
CMSUnits.h
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
DDHGCalHEAlgo::rMixLayer_
std::vector< double > rMixLayer_
Definition: DDHGCalHEAlgo.cc:75
initialize
static AlgebraicMatrix initialize()
Definition: BeamSpotTransientTrackingRecHit.cc:24
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
DDHGCalHEAlgo::choiceType_
int choiceType_
Definition: DDHGCalHEAlgo.cc:97
DDHGCalHEAlgo::materialsTop_
std::vector< std::string > materialsTop_
Definition: DDHGCalHEAlgo.cc:80
DDAlgorithmFactory.h
dttmaxenums::R
Definition: DTTMax.h:29
HGCalParameters.h
class-composition.parent
parent
Definition: class-composition.py:88
cuy.ii
ii
Definition: cuy.py:590
DDHGCalHEAlgo::positionMix
void positionMix(const DDLogicalPart &glog, const std::string &name, int copy, double thick, const DDMaterial &matter, double rin, double rmid, double routF, double zz, DDCompactView &cpv)
Definition: DDHGCalHEAlgo.cc:387
DDHGCalHEAlgo::slopeT_
std::vector< double > slopeT_
Definition: DDHGCalHEAlgo.cc:106
DDHGCalHEAlgo::layerSenseBot_
std::vector< int > layerSenseBot_
Definition: DDHGCalHEAlgo.cc:90
DDSplit
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = ':'
Definition: DDSplit.cc:3
DDHGCalHEAlgo::layerType_
std::vector< int > layerType_
Definition: DDHGCalHEAlgo.cc:76
DDCompactView::position
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
Definition: DDCompactView.cc:66