CMS 3D CMS Logo

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