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