CMS 3D CMS Logo

DDHGCalMixLayer.cc
Go to the documentation of this file.
1 // File: DDHGCalMixLayer.cc
3 // Description: Geometry factory class for HGCal (Mix)
5 
25 
26 #include <cmath>
27 #include <memory>
28 #include <string>
29 #include <unordered_set>
30 #include <vector>
31 
32 //#define EDM_ML_DEBUG
33 using namespace angle_units::operators;
34 
35 class DDHGCalMixLayer : public DDAlgorithm {
36 public:
38 
39  void initialize(const DDNumericArguments& nArgs,
40  const DDVectorArguments& vArgs,
41  const DDMapArguments& mArgs,
42  const DDStringArguments& sArgs,
43  const DDStringVectorArguments& vsArgs) override;
44  void execute(DDCompactView& cpv) override;
45 
46 protected:
47  void constructLayers(const DDLogicalPart&, DDCompactView& cpv);
48  void positionMix(const DDLogicalPart& glog,
49  const std::string& nameM,
50  int copyM,
51  double thick,
52  const DDMaterial& matter,
53  DDCompactView& cpv);
54 
55 private:
57 
58  static constexpr double tol1_ = 0.01;
59  static constexpr double tol2_ = 0.00001;
60 
61  int waferTypes_; // Number of wafer types
62  int facingTypes_; // Types of facings of modules toward IP
63  int partialTypes_; // Number of partial wafer types
64  int orientationTypes_; // Number of partial wafer orienations
65  int phiBinsScint_; // Maximum number of cells along phi
66  int firstLayer_; // Copy # of the first sensitive layer
67  int absorbMode_; // Absorber mode
68  int sensitiveMode_; // Sensitive mode
69  double zMinBlock_; // Starting z-value of the block
70  double waferSize_; // Width of the wafer
71  double waferSepar_; // Sensor separation
72  int sectors_; // Sectors
73  std::vector<double> slopeB_; // Slope at the lower R
74  std::vector<double> zFrontB_; // Starting Z values for the slopes
75  std::vector<double> rMinFront_; // Corresponding rMin's
76  std::vector<double> slopeT_; // Slopes at the larger R
77  std::vector<double> zFrontT_; // Starting Z values for the slopes
78  std::vector<double> rMaxFront_; // Corresponding rMax's
79  std::vector<std::string> waferFull_; // Names of full wafer modules
80  std::vector<std::string> waferPart_; // Names of partial wafer modules
81  std::vector<std::string> materials_; // Materials
82  std::vector<std::string> names_; // Names
83  std::vector<double> thick_; // Thickness of the material
84  std::vector<int> copyNumber_; // Initial copy numbers
85  std::vector<int> layers_; // Number of layers in a section
86  std::vector<double> layerThick_; // Thickness of each section
87  std::vector<int> layerType_; // Type of the layer
88  std::vector<int> layerSense_; // Content of a layer (sensitive?)
89  std::vector<std::string> materialTop_; // Materials of top layers
90  std::vector<std::string> namesTop_; // Names of top layers
91  std::vector<double> layerThickTop_; // Thickness of the top sections
92  std::vector<int> layerTypeTop_; // Type of the Top layer
93  std::vector<int> copyNumberTop_; // Initial copy numbers (top section)
94  std::vector<int> layerOrient_; // Layer orientation of silicon layers
95  std::vector<int> waferIndex_; // Wafer index for the types
96  std::vector<int> waferProperty_; // Wafer property
97  std::vector<int> waferLayerStart_; // Start index of wafers in each layer
98  std::vector<double> tileRMin_; // Minimum radius of each ring
99  std::vector<double> tileRMax_; // Maximum radius of each ring
100  std::vector<int> tileIndex_; // Index of tile (layer/start|end ring)
101  std::vector<int> tilePhis_; // Tile phi range for each index
102  std::vector<int> tileLayerStart_; // Start index of tiles in each layer
103  std::string nameSpace_; // Namespace of this and ALL sub-parts
104  std::unordered_set<int> copies_; // List of copy #'s
105  double alpha_, cosAlpha_;
106 };
107 
109 #ifdef EDM_ML_DEBUG
110  edm::LogVerbatim("HGCalGeom") << "DDHGCalMixLayer: Creating an instance";
111 #endif
112 }
113 
115  const DDVectorArguments& vArgs,
116  const DDMapArguments&,
117  const DDStringArguments& sArgs,
118  const DDStringVectorArguments& vsArgs) {
119  waferTypes_ = static_cast<int>(nArgs["WaferTypes"]);
120  facingTypes_ = static_cast<int>(nArgs["FacingTypes"]);
121  partialTypes_ = static_cast<int>(nArgs["PartialTypes"]);
122  orientationTypes_ = static_cast<int>(nArgs["OrientationTypes"]);
123  phiBinsScint_ = static_cast<int>(nArgs["NPhiBinScint"]);
124 #ifdef EDM_ML_DEBUG
125  edm::LogVerbatim("HGCalGeom") << "DDHGCalMixLayer::Number of types of wafers: " << waferTypes_
126  << " facings: " << facingTypes_ << " partials: " << partialTypes_
127  << " Orientations: " << orientationTypes_ << "; number of cells along phi "
128  << phiBinsScint_;
129 #endif
130  firstLayer_ = (int)(nArgs["FirstLayer"]);
131  absorbMode_ = (int)(nArgs["AbsorberMode"]);
132  sensitiveMode_ = (int)(nArgs["SensitiveMode"]);
133 #ifdef EDM_ML_DEBUG
134  edm::LogVerbatim("HGCalGeom") << "DDHGCalMixLayer::First Layer " << firstLayer_ << " and "
135  << "Absober:Sensitive mode " << absorbMode_ << ":" << sensitiveMode_;
136 #endif
137  zMinBlock_ = nArgs["zMinBlock"];
138  waferSize_ = nArgs["waferSize"];
139  waferSepar_ = nArgs["SensorSeparation"];
140  sectors_ = (int)(nArgs["Sectors"]);
141  alpha_ = (1._pi) / sectors_;
142  cosAlpha_ = cos(alpha_);
143 #ifdef EDM_ML_DEBUG
144  edm::LogVerbatim("HGCalGeom") << "DDHGCalMixLayer: zStart " << zMinBlock_ << " wafer width " << waferSize_
145  << " separations " << waferSepar_ << " sectors " << sectors_ << ":"
146  << convertRadToDeg(alpha_) << ":" << cosAlpha_;
147 #endif
148  slopeB_ = vArgs["SlopeBottom"];
149  zFrontB_ = vArgs["ZFrontBottom"];
150  rMinFront_ = vArgs["RMinFront"];
151  slopeT_ = vArgs["SlopeTop"];
152  zFrontT_ = vArgs["ZFrontTop"];
153  rMaxFront_ = vArgs["RMaxFront"];
154 #ifdef EDM_ML_DEBUG
155  for (unsigned int i = 0; i < slopeB_.size(); ++i)
156  edm::LogVerbatim("HGCalGeom") << "Bottom Block [" << i << "] Zmin " << zFrontB_[i] << " Rmin " << rMinFront_[i]
157  << " Slope " << slopeB_[i];
158  for (unsigned int i = 0; i < slopeT_.size(); ++i)
159  edm::LogVerbatim("HGCalGeom") << "Top Block [" << i << "] Zmin " << zFrontT_[i] << " Rmax " << rMaxFront_[i]
160  << " Slope " << slopeT_[i];
161 #endif
162  waferFull_ = vsArgs["WaferNamesFull"];
163  waferPart_ = vsArgs["WaferNamesPartial"];
164 #ifdef EDM_ML_DEBUG
165  edm::LogVerbatim("HGCalGeom") << "DDHGCalMixLayer: " << waferFull_.size() << " full and " << waferPart_.size()
166  << " partial modules\nDDHGCalMixLayer:Full Modules:";
167  unsigned int i1max = static_cast<unsigned int>(waferFull_.size());
168  for (unsigned int i1 = 0; i1 < i1max; i1 += 2) {
169  std::ostringstream st1;
170  unsigned int i2 = std::min((i1 + 2), i1max);
171  for (unsigned int i = i1; i < i2; ++i)
172  st1 << " [" << i << "] " << waferFull_[i];
173  edm::LogVerbatim("HGCalGeom") << st1.str() << std::endl;
174  }
175  edm::LogVerbatim("HGCalGeom") << "DDHGCalMixLayer: Partial Modules:";
176  i1max = static_cast<unsigned int>(waferPart_.size());
177  for (unsigned int i1 = 0; i1 < i1max; i1 += 2) {
178  std::ostringstream st1;
179  unsigned int i2 = std::min((i1 + 2), i1max);
180  for (unsigned int i = i1; i < i2; ++i)
181  st1 << " [" << i << "] " << waferPart_[i];
182  edm::LogVerbatim("HGCalGeom") << st1.str() << std::endl;
183  }
184 #endif
185  materials_ = vsArgs["MaterialNames"];
186  names_ = vsArgs["VolumeNames"];
187  thick_ = vArgs["Thickness"];
188  copyNumber_.resize(materials_.size(), 1);
189 #ifdef EDM_ML_DEBUG
190  edm::LogVerbatim("HGCalGeom") << "DDHGCalMixLayer: " << materials_.size() << " types of volumes";
191  for (unsigned int i = 0; i < names_.size(); ++i)
192  edm::LogVerbatim("HGCalGeom") << "Volume [" << i << "] " << names_[i] << " of thickness " << thick_[i]
193  << " filled with " << materials_[i] << " first copy number " << copyNumber_[i];
194 #endif
195  layers_ = dbl_to_int(vArgs["Layers"]);
196  layerThick_ = vArgs["LayerThick"];
197 #ifdef EDM_ML_DEBUG
198  edm::LogVerbatim("HGCalGeom") << "There are " << layers_.size() << " blocks";
199  for (unsigned int i = 0; i < layers_.size(); ++i)
200  edm::LogVerbatim("HGCalGeom") << "Block [" << i << "] of thickness " << layerThick_[i] << " with " << layers_[i]
201  << " layers";
202 #endif
203  layerType_ = dbl_to_int(vArgs["LayerType"]);
204  layerSense_ = dbl_to_int(vArgs["LayerSense"]);
205  layerOrient_ = dbl_to_int(vArgs["LayerTypes"]);
206  for (unsigned int k = 0; k < layerOrient_.size(); ++k)
207  layerOrient_[k] = HGCalTypes::layerType(layerOrient_[k]);
208 #ifdef EDM_ML_DEBUG
209  for (unsigned int i = 0; i < layerOrient_.size(); ++i)
210  edm::LogVerbatim("HGCalGeom") << "LayerTypes [" << i << "] " << layerOrient_[i];
211 #endif
212  if (firstLayer_ > 0) {
213  for (unsigned int i = 0; i < layerType_.size(); ++i) {
214  if (layerSense_[i] > 0) {
215  int ii = layerType_[i];
216  copyNumber_[ii] = firstLayer_;
217 #ifdef EDM_ML_DEBUG
218  edm::LogVerbatim("HGCalGeom") << "First copy number for layer type " << i << ":" << ii << " with "
219  << materials_[ii] << " changed to " << copyNumber_[ii];
220 #endif
221  break;
222  }
223  }
224  } else {
225  firstLayer_ = 1;
226  }
227 #ifdef EDM_ML_DEBUG
228  edm::LogVerbatim("HGCalGeom") << "There are " << layerType_.size() << " layers";
229  for (unsigned int i = 0; i < layerType_.size(); ++i)
230  edm::LogVerbatim("HGCalGeom") << "Layer [" << i << "] with material type " << layerType_[i] << " sensitive class "
231  << layerSense_[i];
232 #endif
233  materialTop_ = vsArgs["TopMaterialNames"];
234  namesTop_ = vsArgs["TopVolumeNames"];
235  layerThickTop_ = vArgs["TopLayerThickness"];
236  layerTypeTop_ = dbl_to_int(vArgs["TopLayerType"]);
237  copyNumberTop_.resize(materialTop_.size(), firstLayer_);
238 #ifdef EDM_ML_DEBUG
239  edm::LogVerbatim("HGCalGeom") << "DDHGCalMixLayer: " << materialTop_.size() << " types of volumes in the top part";
240  for (unsigned int i = 0; i < materialTop_.size(); ++i)
241  edm::LogVerbatim("HGCalGeom") << "Volume [" << i << "] " << namesTop_[i] << " of thickness " << layerThickTop_[i]
242  << " filled with " << materialTop_[i] << " first copy number " << copyNumberTop_[i];
243  edm::LogVerbatim("HGCalGeom") << "There are " << layerTypeTop_.size() << " layers in the top part";
244  for (unsigned int i = 0; i < layerTypeTop_.size(); ++i)
245  edm::LogVerbatim("HGCalGeom") << "Layer [" << i << "] with material type " << layerTypeTop_[i];
246 #endif
247  waferIndex_ = dbl_to_int(vArgs["WaferIndex"]);
248  waferProperty_ = dbl_to_int(vArgs["WaferProperties"]);
249  waferLayerStart_ = dbl_to_int(vArgs["WaferLayerStart"]);
250 #ifdef EDM_ML_DEBUG
251  edm::LogVerbatim("HGCalGeom") << "waferProperties with " << waferIndex_.size() << " entries in "
252  << waferLayerStart_.size() << " layers";
253  for (unsigned int k = 0; k < waferLayerStart_.size(); ++k)
254  edm::LogVerbatim("HGCalGeom") << "LayerStart[" << k << "] " << waferLayerStart_[k];
255  for (unsigned int k = 0; k < waferIndex_.size(); ++k)
256  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << waferIndex_[k] << " ("
257  << HGCalWaferIndex::waferLayer(waferIndex_[k]) << ", "
258  << HGCalWaferIndex::waferU(waferIndex_[k]) << ", "
259  << HGCalWaferIndex::waferV(waferIndex_[k]) << ") : ("
260  << HGCalProperty::waferThick(waferProperty_[k]) << ":"
261  << HGCalProperty::waferPartial(waferProperty_[k]) << ":"
262  << HGCalProperty::waferOrient(waferProperty_[k]) << ")";
263 #endif
264  tileRMin_ = vArgs["TileRMin"];
265  tileRMax_ = vArgs["TileRMax"];
266  tileIndex_ = dbl_to_int(vArgs["TileLayerRings"]);
267  tilePhis_ = dbl_to_int(vArgs["TilePhiRange"]);
268  tileLayerStart_ = dbl_to_int(vArgs["TileLayerStart"]);
269 #ifdef EDM_ML_DEBUG
270  edm::LogVerbatim("HGCalGeom") << "DDHGCalMixLayer:: with " << tileRMin_.size() << " rings";
271  for (unsigned int k = 0; k < tileRMin_.size(); ++k)
272  edm::LogVerbatim("HGCalGeom") << "Ring[" << k << "] " << tileRMin_[k] << " : " << tileRMax_[k];
273  edm::LogVerbatim("HGCalGeom") << "TileProperties with " << tileIndex_.size() << " entries in "
274  << tileLayerStart_.size() << " layers";
275  for (unsigned int k = 0; k < tileLayerStart_.size(); ++k)
276  edm::LogVerbatim("HGCalGeom") << "LayerStart[" << k << "] " << tileLayerStart_[k];
277  for (unsigned int k = 0; k < tileIndex_.size(); ++k)
278  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << tileIndex_[k] << " ("
279  << "Layer " << std::get<0>(HGCalTileIndex::tileUnpack(tileIndex_[k])) << " Ring "
280  << std::get<1>(HGCalTileIndex::tileUnpack(tileIndex_[k])) << ":"
281  << std::get<2>(HGCalTileIndex::tileUnpack(tileIndex_[k])) << ") Phi "
282  << std::get<1>(HGCalTileIndex::tileUnpack(tilePhis_[k])) << ":"
283  << std::get<2>(HGCalTileIndex::tileUnpack(tilePhis_[k]));
284 #endif
285  nameSpace_ = DDCurrentNamespace::ns();
286 #ifdef EDM_ML_DEBUG
287  edm::LogVerbatim("HGCalGeom") << "DDHGCalMixLayer: NameSpace " << nameSpace_ << ":";
288 #endif
289 }
290 
292 // DDHGCalMixLayer methods...
294 
296 #ifdef EDM_ML_DEBUG
297  edm::LogVerbatim("HGCalGeom") << "==>> Constructing DDHGCalMixLayer...";
298  copies_.clear();
299 #endif
300  constructLayers(parent(), cpv);
301 #ifdef EDM_ML_DEBUG
302  edm::LogVerbatim("HGCalGeom") << "DDHGCalMixLayer: " << copies_.size() << " different wafer copy numbers";
303  int k(0);
304  for (std::unordered_set<int>::const_iterator itr = copies_.begin(); itr != copies_.end(); ++itr, ++k) {
305  edm::LogVerbatim("HGCalGeom") << "Copy [" << k << "] : " << (*itr);
306  }
307  copies_.clear();
308  edm::LogVerbatim("HGCalGeom") << "<<== End of DDHGCalMixLayer construction...";
309 #endif
310 }
311 
313  double zi(zMinBlock_);
314  int laymin(0);
315  for (unsigned int i = 0; i < layers_.size(); i++) {
316  double zo = zi + layerThick_[i];
317  double routF = HGCalGeomTools::radius(zi, zFrontT_, rMaxFront_, slopeT_);
318  int laymax = laymin + layers_[i];
319  double zz = zi;
320  double thickTot(0);
321  for (int ly = laymin; ly < laymax; ++ly) {
322  int ii = layerType_[ly];
323  int copy = copyNumber_[ii];
324  double hthick = 0.5 * thick_[ii];
325  double rinB = HGCalGeomTools::radius(zo, zFrontB_, rMinFront_, slopeB_);
326  zz += hthick;
327  thickTot += thick_[ii];
328 
329  std::string name = names_[ii] + std::to_string(copy);
330 #ifdef EDM_ML_DEBUG
331  edm::LogVerbatim("HGCalGeom") << "DDHGCalMixLayer: Layer " << ly << ":" << ii << " Front " << zi << ", " << routF
332  << " Back " << zo << ", " << rinB << " superlayer thickness " << layerThick_[i];
333 #endif
334  DDName matName(DDSplit(materials_[ii]).first, DDSplit(materials_[ii]).second);
335  DDMaterial matter(matName);
336  DDLogicalPart glog;
337  if (layerSense_[ly] < 1) {
338  std::vector<double> pgonZ, pgonRin, pgonRout;
339  double rmax =
340  (std::min(routF, HGCalGeomTools::radius(zz + hthick, zFrontT_, rMaxFront_, slopeT_)) * cosAlpha_) - tol1_;
341  HGCalGeomTools::radius(zz - hthick,
342  zz + hthick,
343  zFrontB_,
344  rMinFront_,
345  slopeB_,
346  zFrontT_,
347  rMaxFront_,
348  slopeT_,
349  -layerSense_[ly],
350  pgonZ,
351  pgonRin,
352  pgonRout);
353  for (unsigned int isec = 0; isec < pgonZ.size(); ++isec) {
354  pgonZ[isec] -= zz;
355  if (layerSense_[ly] == 0 || absorbMode_ == 0)
356  pgonRout[isec] = rmax;
357  else
358  pgonRout[isec] = pgonRout[isec] * cosAlpha_ - tol1_;
359  }
360  DDSolid solid =
361  DDSolidFactory::polyhedra(DDName(name, nameSpace_), sectors_, -alpha_, 2._pi, pgonZ, pgonRin, pgonRout);
362  glog = DDLogicalPart(solid.ddname(), matter, solid);
363 #ifdef EDM_ML_DEBUG
364  edm::LogVerbatim("HGCalGeom") << "DDHGCalMixLayer: " << solid.name() << " polyhedra of " << sectors_
365  << " sectors covering " << convertRadToDeg(-alpha_) << ":"
366  << convertRadToDeg(-alpha_ + 2._pi) << " with " << pgonZ.size() << " sections";
367  for (unsigned int k = 0; k < pgonZ.size(); ++k)
368  edm::LogVerbatim("HGCalGeom") << "[" << k << "] z " << pgonZ[k] << " R " << pgonRin[k] << ":" << pgonRout[k];
369 #endif
370  } else {
371  double rins = (sensitiveMode_ < 1) ? rinB : HGCalGeomTools::radius(zz + hthick, zFrontB_, rMinFront_, slopeB_);
372  double routs =
373  (sensitiveMode_ < 1) ? routF : HGCalGeomTools::radius(zz - hthick, zFrontT_, rMaxFront_, slopeT_);
374  DDSolid solid = DDSolidFactory::tubs(DDName(name, nameSpace_), hthick, rins, routs, 0.0, 2._pi);
375  glog = DDLogicalPart(solid.ddname(), matter, solid);
376 #ifdef EDM_ML_DEBUG
377  edm::LogVerbatim("HGCalGeom") << "DDHGCalMixLayer: " << solid.name() << " Tubs made of " << matName
378  << " of dimensions " << rinB << ":" << rins << ", " << routF << ":" << routs
379  << ", " << hthick << ", 0.0, 360.0 and positioned in: " << glog.name()
380  << " number " << copy;
381 #endif
382  positionMix(glog, name, copy, thick_[ii], matter, cpv);
383  }
384  DDTranslation r1(0, 0, zz);
385  DDRotation rot;
386  cpv.position(glog, module, copy, r1, rot);
387  ++copyNumber_[ii];
388 #ifdef EDM_ML_DEBUG
389  edm::LogVerbatim("HGCalGeom") << "DDHGCalMixLayer: " << glog.name() << " number " << copy << " positioned in "
390  << module.name() << " at " << r1 << " with no rotation";
391 #endif
392  zz += hthick;
393  } // End of loop over layers in a block
394  zi = zo;
395  laymin = laymax;
396  // Make consistency check of all the partitions of the block
397  if (std::abs(thickTot - layerThick_[i]) >= tol2_) {
398  if (thickTot > layerThick_[i]) {
399  edm::LogError("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " is smaller than " << thickTot
400  << ": thickness of all its components **** ERROR ****";
401  } else {
402  edm::LogWarning("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " does not match with "
403  << thickTot << " of the components";
404  }
405  }
406  } // End of loop over blocks
407 }
408 
410  const std::string& nameM,
411  int copyM,
412  double thick,
413  const DDMaterial& matter,
414  DDCompactView& cpv) {
415  DDRotation rot;
416 
417  // Make the top part first
418  for (unsigned int ly = 0; ly < layerTypeTop_.size(); ++ly) {
419  int ii = layerTypeTop_[ly];
420  copyNumberTop_[ii] = copyM;
421  }
422  double hthick = 0.5 * thick;
423  double dphi = (2._pi) / phiBinsScint_;
424  double thickTot(0), zpos(-hthick);
425  for (unsigned int ly = 0; ly < layerTypeTop_.size(); ++ly) {
426  int ii = layerTypeTop_[ly];
427  int copy = copyNumberTop_[ii];
428  int layer = copy - firstLayer_;
429  double hthickl = 0.5 * layerThickTop_[ii];
430  thickTot += layerThickTop_[ii];
431  zpos += hthickl;
432  DDName matName(DDSplit(materialTop_[ii]).first, DDSplit(materialTop_[ii]).second);
433  DDMaterial matter1(matName);
434  unsigned int k = 0;
435  int firstTile = tileLayerStart_[layer];
436  int lastTile = ((layer + 1 < static_cast<int>(tileLayerStart_.size())) ? tileLayerStart_[layer + 1]
437  : static_cast<int>(tileIndex_.size()));
438 #ifdef EDM_ML_DEBUG
439  edm::LogVerbatim("HGCalGeom") << "DDHGCalMixLayer: Layer " << ly << ":" << ii << " Copy " << copy << " Tiles "
440  << firstTile << ":" << lastTile;
441 #endif
442  for (int ti = firstTile; ti < lastTile; ++ti) {
443  double r1 = tileRMin_[std::get<1>(HGCalTileIndex::tileUnpack(tileIndex_[ti])) - 1];
444  double r2 = tileRMax_[std::get<2>(HGCalTileIndex::tileUnpack(tileIndex_[ti])) - 1];
445  int fimin = std::get<1>(HGCalTileIndex::tileUnpack(tilePhis_[ti]));
446  int fimax = std::get<2>(HGCalTileIndex::tileUnpack(tilePhis_[ti]));
447  double phi1 = dphi * (fimin - 1);
448  double phi2 = dphi * (fimax - fimin + 1);
449 #ifdef EDM_ML_DEBUG
450  edm::LogVerbatim("HGCalGeom") << "DDHGCalMixLayer: Layer " << copy << " iR "
451  << std::get<1>(HGCalTileIndex::tileUnpack(tileIndex_[ti])) << ":"
452  << std::get<2>(HGCalTileIndex::tileUnpack(tileIndex_[ti])) << " R " << r1 << ":"
453  << r2 << " Thick " << (2.0 * hthickl) << " phi " << fimin << ":" << fimax << ":"
454  << convertRadToDeg(phi1) << ":" << convertRadToDeg(phi2);
455  ;
456 #endif
457  std::string name = namesTop_[ii] + "L" + std::to_string(copy) + "F" + std::to_string(k);
458  ++k;
459  DDSolid solid = DDSolidFactory::tubs(DDName(name, nameSpace_), hthickl, r1, r2, phi1, phi2);
460  DDLogicalPart glog1 = DDLogicalPart(solid.ddname(), matter1, solid);
461 #ifdef EDM_ML_DEBUG
462  edm::LogVerbatim("HGCalGeom") << "DDHGCalMixLayer: " << glog1.name() << " Tubs made of " << matName
463  << " of dimensions " << r1 << ", " << r2 << ", " << hthickl << ", "
464  << convertRadToDeg(phi1) << ", " << convertRadToDeg(phi2);
465 #endif
466  DDTranslation tran(0, 0, zpos);
467  cpv.position(glog1, glog, copy, tran, rot);
468 #ifdef EDM_ML_DEBUG
469  edm::LogVerbatim("HGCalGeom") << "DDHGCalMixLayer: Position " << glog1.name() << " number " << copy << " in "
470  << glog.name() << " at " << tran << " with no rotation";
471 #endif
472  }
473  ++copyNumberTop_[ii];
474  zpos += hthickl;
475  }
476  if (std::abs(thickTot - thick) >= tol2_) {
477  if (thickTot > thick) {
478  edm::LogError("HGCalGeom") << "Thickness of the partition " << thick << " is smaller than " << thickTot
479  << ": thickness of all its components in the top part **** ERROR ****";
480  } else {
481  edm::LogWarning("HGCalGeom") << "Thickness of the partition " << thick << " does not match with " << thickTot
482  << " of the components in top part";
483  }
484  }
485 
486  // Make the bottom part next
487  int layer = (copyM - firstLayer_);
488  static const double sqrt3 = std::sqrt(3.0);
489  int layercenter = layerOrient_[layer];
490  int layerType = (layerOrient_[layer] == HGCalTypes::WaferCenterB) ? 1 : 0;
491  int firstWafer = waferLayerStart_[layer];
492  int lastWafer = ((layer + 1 < static_cast<int>(waferLayerStart_.size())) ? waferLayerStart_[layer + 1]
493  : static_cast<int>(waferIndex_.size()));
494  double r = 0.5 * (waferSize_ + waferSepar_);
495  double R = 2.0 * r / sqrt3;
496  double dy = 0.75 * R;
497  const auto& xyoff = geomTools_.shiftXY(layercenter, (waferSize_ + waferSepar_));
498 #ifdef EDM_ML_DEBUG
499  int ium(0), ivm(0), kount(0);
500  std::vector<int> ntype(3, 0);
501  edm::LogVerbatim("HGCalGeom") << "DDHGCalMixLayer: " << glog.ddname() << " r " << r << " R " << R << " dy " << dy
502  << " Shift " << xyoff.first << ":" << xyoff.second << " WaferSize "
503  << (waferSize_ + waferSepar_) << " index " << firstWafer << ":" << (lastWafer - 1);
504 #endif
505  for (int k = firstWafer; k < lastWafer; ++k) {
506  int u = HGCalWaferIndex::waferU(waferIndex_[k]);
507  int v = HGCalWaferIndex::waferV(waferIndex_[k]);
508 #ifdef EDM_ML_DEBUG
509  int iu = std::abs(u);
510  int iv = std::abs(v);
511 #endif
512  int nr = 2 * v;
513  int nc = -2 * u + v;
514  double xpos = xyoff.first + nc * r;
515  double ypos = xyoff.second + nr * dy;
516  int type = HGCalProperty::waferThick(waferProperty_[k]);
517  int part = HGCalProperty::waferPartial(waferProperty_[k]);
518  int orien = HGCalProperty::waferOrient(waferProperty_[k]);
519  std::string wafer;
520  int i(999);
521  if (part == HGCalTypes::WaferFull) {
522  i = layerType * waferTypes_ + type;
523  wafer = waferFull_[i];
524  } else {
525  i = (part - 1) * waferTypes_ * facingTypes_ * orientationTypes_ + layerType * waferTypes_ * orientationTypes_ +
526  type * orientationTypes_ + orien;
527 #ifdef EDM_ML_DEBUG
528  edm::LogVerbatim("HGCalGeom") << " layertype:type:part:orien:ind " << layerType << ":" << type << ":" << part
529  << ":" << orien << ":" << i << ":" << waferPart_.size();
530 #endif
531  wafer = waferPart_[i];
532  }
533  int copy = HGCalTypes::packTypeUV(type, u, v);
534 #ifdef EDM_ML_DEBUG
535  edm::LogVerbatim("HGCalGeom") << " DDHGCalMixLayer: Layer " << HGCalWaferIndex::waferLayer(waferIndex_[k])
536  << " Wafer " << wafer << " number " << copy << " type :part:orien:ind " << type << ":"
537  << part << ":" << orien << ":" << i << " layer:u:v " << (layer + firstLayer_) << ":"
538  << u << ":" << v;
539  if (iu > ium)
540  ium = iu;
541  if (iv > ivm)
542  ivm = iv;
543  kount++;
544  if (copies_.count(copy) == 0)
545  copies_.insert(copy);
546 #endif
547  DDTranslation tran(xpos, ypos, 0.0);
548  DDName name = DDName(DDSplit(wafer).first, DDSplit(wafer).second);
549  cpv.position(name, glog.ddname(), copy, tran, rot);
550 #ifdef EDM_ML_DEBUG
551  ++ntype[type];
552  edm::LogVerbatim("HGCalGeom") << " DDHGCalMixLayer: " << name << " number " << copy << " type " << layerType << ":"
553  << type << " positioned in " << glog.ddname() << " at " << tran
554  << " with no rotation";
555 #endif
556  }
557 #ifdef EDM_ML_DEBUG
558  edm::LogVerbatim("HGCalGeom") << "DDHGCalMixLayer: Maximum # of u " << ium << " # of v " << ivm << " and " << kount
559  << " wafers (" << ntype[0] << ":" << ntype[1] << ":" << ntype[2] << ") for "
560  << glog.ddname();
561 #endif
562 }
563 
564 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDHGCalMixLayer, "hgcal:DDHGCalMixLayer");
Log< level::Info, true > LogVerbatim
static AlgebraicMatrix initialize()
std::vector< double > zFrontT_
std::vector< int > tileIndex_
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)
std::vector< int > layerOrient_
std::vector< double > rMinFront_
int32_t *__restrict__ iv
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
int32_t waferU(const int32_t index)
int32_t waferLayer(const int32_t index)
std::vector< double > layerThickTop_
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
std::vector< double > thick_
HGCalGeomTools geomTools_
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
std::string to_string(const V &value)
Definition: OMSAccess.h:77
void constructLayers(const DDLogicalPart &, DDCompactView &cpv)
std::unordered_set< int > copies_
static std::string & ns()
std::vector< int > tilePhis_
Log< level::Error, false > LogError
std::string nameSpace_
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
int32_t waferOrient(const int32_t property)
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
std::vector< double > tileRMax_
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
std::vector< double > slopeB_
U second(std::pair< T, U > const &p)
std::vector< int > copyNumberTop_
static constexpr int32_t WaferFull
Definition: HGCalTypes.h:35
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
std::vector< std::string > materialTop_
T sqrt(T t)
Definition: SSEVec.h:19
std::vector< int > waferIndex_
std::vector< int > waferLayerStart_
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
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)
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
static DDSolid tubs(const DDName &name, double zhalf, double rIn, double rOut, double startPhi, double deltaPhi)
Definition: DDSolid.cc:667
int32_t waferThick(const int32_t property)
std::vector< std::string > namesTop_
ii
Definition: cuy.py:589
std::vector< int > dbl_to_int(const std::vector< double > &vecdbl)
Converts a std::vector of doubles to a std::vector of int.
Definition: DDutils.h:7
void positionMix(const DDLogicalPart &glog, const std::string &nameM, int copyM, double thick, const DDMaterial &matter, DDCompactView &cpv)
const N & name() const
Definition: DDBase.h:59
std::tuple< int32_t, int32_t, int32_t > tileUnpack(int32_t index)
std::vector< int > layerTypeTop_
std::vector< int > copyNumber_
std::vector< int > tileLayerStart_
part
Definition: HCALResponse.h:20
const N & ddname() const
Definition: DDBase.h:61
std::vector< std::string > waferPart_
std::vector< double > layerThick_
std::vector< double > slopeT_
int32_t waferPartial(const int32_t property)
void execute(DDCompactView &cpv) override
std::vector< int > layers_
std::vector< int > waferProperty_
std::vector< std::string > names_
std::vector< int > layerType_
int32_t waferV(const int32_t index)
static int32_t packTypeUV(int type, int u, int v)
Definition: HGCalTypes.cc:3
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::vector< std::string > waferFull_
std::vector< double > rMaxFront_
Log< level::Warning, false > LogWarning
static int32_t layerType(int type)
Definition: HGCalTypes.cc:42
static constexpr int32_t WaferCenterB
Definition: HGCalTypes.h:26
std::vector< double > zFrontB_
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:3
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
static DDSolid polyhedra(const DDName &name, int sides, double startPhi, double deltaPhi, const std::vector< double > &z, const std::vector< double > &rmin, const std::vector< double > &rmax)
Creates a polyhedra (refere to Geant3 or Geant4 documentation)
Definition: DDSolid.cc:565
std::vector< std::string > materials_
std::vector< double > tileRMin_
std::vector< int > layerSense_