CMS 3D CMS Logo

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