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