CMS 3D CMS Logo

HGCalParametersFromDD.cc
Go to the documentation of this file.
2 
10 
11 //#define EDM_ML_DEBUG
12 using namespace geant_units::operators;
13 
15  HGCalParameters& php,
16  const std::string& name,
17  const std::string& namew,
18  const std::string& namec,
19  const std::string& namet) {
20 #ifdef EDM_ML_DEBUG
21  edm::LogVerbatim("HGCalGeom") << "HGCalParametersFromDD (DDD)::build called with "
22  << "names " << name << ":" << namew << ":" << namec << ":" << namet;
23 #endif
24 
25  // Special parameters at simulation level
26  std::string attribute = "Volume";
28  DDValue val(attribute, value, 0.0);
30  DDFilteredView fv(*cpv, filter);
31  bool ok = fv.firstChild();
33 #ifdef EDM_ML_DEBUG
34  edm::LogVerbatim("HGCalGeom") << "Volume " << name << " GeometryMode ";
35 #endif
36  if (ok) {
38  php.mode_ = HGCalGeometryMode::getGeometryMode("GeometryMode", sv);
39 #ifdef EDM_ML_DEBUG
40  edm::LogVerbatim("HGCalGeom") << "Volume " << name << " GeometryMode " << php.mode_ << ":"
46 #endif
47  php.levelZSide_ = 3; // Default level for ZSide
48  php.detectorType_ = 0; // These two parameters are
49  php.firstMixedLayer_ = -1; // defined for post TDR geometry
50  php.useSimWt_ = 1; // energy weighting for SimHits
51  php.layerRotation_ = 0; // default layer rotation angle
52  php.cassettes_ = 0; // default number of cassettes
53  php.nphiCassette_ = 0; // default number of phi's per cassette
54  php.phiOffset_ = 0; // default value of phi offset for cassette
55  php.calibCellRHD_ = 0; // default value of R of HD calibration cells
56  php.calibCellRLD_ = 0; // default value of R of LD calibration cells
57  std::unique_ptr<HGCalGeomParameters> geom = std::make_unique<HGCalGeomParameters>();
59  attribute = "OnlyForHGCalNumbering";
60  value = namet;
61  DDValue val2(attribute, value, 0.0);
62  DDSpecificsMatchesValueFilter filter2{val2};
63  DDFilteredView fv2(*cpv, filter2);
64  bool ok2 = fv2.firstChild();
65  if (ok2) {
68 #ifdef EDM_ML_DEBUG
69  edm::LogVerbatim("HGCalGeom") << "WaferMode " << mode << ":" << HGCalGeometryMode::Polyhedra << ":"
71 #endif
72  }
73  php.minTileSize_ = 0;
74  php.waferMaskMode_ = 0;
75  php.waferZSide_ = 0;
76  }
80  php.levelT_ = dbl_to_int(getDDDArray("LevelTop", sv));
81  php.levelZSide_ = static_cast<int>(getDDDValue("LevelZSide", sv));
82  php.nCellsFine_ = php.nCellsCoarse_ = 0;
83  php.firstLayer_ = 1;
84  php.firstMixedLayer_ = static_cast<int>(getDDDValue("FirstMixedLayer", sv));
85  php.detectorType_ = static_cast<int>(getDDDValue("DetectorType", sv));
86  php.minTileSize_ = 0;
87  php.waferMaskMode_ = static_cast<int>(getDDDValue("WaferMaskMode", sv));
88  php.waferZSide_ = static_cast<int>(getDDDValue("WaferZside", sv));
91  php.useSimWt_ = static_cast<int>(getDDDValue("UseSimWt", sv));
92  php.layerRotation_ = getDDDValue("LayerRotation", sv);
93  }
96  php.cassettes_ = getDDDValue("Cassettes", sv);
97 #ifdef EDM_ML_DEBUG
98  edm::LogVerbatim("HGCalGeom") << "Top levels " << php.levelT_[0] << ":" << php.levelT_[1] << " ZSide Level "
99  << php.levelZSide_ << " first layers " << php.firstLayer_ << ":"
100  << php.firstMixedLayer_ << " Det Type " << php.detectorType_ << " Wafer Mask Mode "
101  << php.waferMaskMode_ << " Zside " << php.waferZSide_ << " Layer Rotation "
102  << convertRadToDeg(php.layerRotation_) << " Cassettes " << php.cassettes_
103  << " UseSimWt " << php.useSimWt_;
104 #endif
105  attribute = "OnlyForHGCalNumbering";
106  value = namet;
107  DDValue val2(attribute, value, 0.0);
108  DDSpecificsMatchesValueFilter filter2{val2};
109  DDFilteredView fv2(*cpv, filter2);
110  bool ok2 = fv2.firstChild();
111  if (ok2) {
112  DDsvalues_type sv2(fv2.mergedSpecifics());
113  mode = HGCalGeometryMode::getGeometryWaferMode("WaferMode", sv2);
114  php.nCellsFine_ = static_cast<int>(getDDDValue("NumberOfCellsFine", sv2));
115  php.nCellsCoarse_ = static_cast<int>(getDDDValue("NumberOfCellsCoarse", sv2));
116  php.waferSize_ = HGCalParameters::k_ScaleFromDDD * getDDDValue("WaferSize", sv2);
117  php.waferThick_ = HGCalParameters::k_ScaleFromDDD * getDDDValue("WaferThickness", sv2);
118  php.sensorSeparation_ = HGCalParameters::k_ScaleFromDDD * getDDDValue("SensorSeparation", sv2);
119  php.sensorSizeOffset_ = HGCalParameters::k_ScaleFromDDD * getDDDValue("SensorSizeOffset", sv2);
120  php.guardRingOffset_ = HGCalParameters::k_ScaleFromDDD * getDDDValue("GuardRingOffset", sv2);
121  php.mouseBite_ = HGCalParameters::k_ScaleFromDDD * getDDDValue("MouseBite", sv2);
122  php.useOffset_ = static_cast<int>(getDDDValue("UseOffset", sv2));
123  php.waferR_ = HGCalParameters::k_ScaleToDDD * php.waferSize_ * tan30deg_;
124  php.cellSize_.emplace_back(HGCalParameters::k_ScaleToDDD * php.waferSize_ / php.nCellsFine_);
125  php.cellSize_.emplace_back(HGCalParameters::k_ScaleToDDD * php.waferSize_ / php.nCellsCoarse_);
126 #ifdef EDM_ML_DEBUG
127  edm::LogVerbatim("HGCalGeom") << "WaferMode " << mode << ":" << HGCalGeometryMode::Polyhedra << ":"
128  << HGCalGeometryMode::ExtrudedPolygon << " # of cells|size for fine/coarse "
129  << php.nCellsFine_ << ":" << php.cellSize_[0] << ":" << php.nCellsCoarse_ << ":"
130  << php.cellSize_[1] << " wafer Params " << php.waferSize_ << ":" << php.waferR_
131  << ":" << php.waferThick_ << ":" << php.sensorSeparation_ << ":"
132  << php.sensorSizeOffset_ << ":" << php.guardRingOffset_ << ":" << php.mouseBite_
133  << ":" << php.useOffset_ << ":" << php.waferR_;
134 #endif
135  for (int k = 0; k < 2; ++k)
136  getCellPosition(php, k);
137  }
138  }
139  if (php.mode_ == HGCalGeometryMode::Hexagon) {
140  // Load the SpecPars
141  php.firstLayer_ = 1;
142  geom->loadSpecParsHexagon(fv, php, cpv, namew, namec);
143  // Load the Geometry parameters
144  geom->loadGeometryHexagon(fv, php, name, cpv, namew, namec, mode);
145  // Load cell parameters
146  geom->loadCellParsHexagon(cpv, php);
147  // Set complete fill mode
148  php.defineFull_ = false;
149  } else if (php.mode_ == HGCalGeometryMode::HexagonFull) {
150  // Load the SpecPars
151  php.firstLayer_ = 1;
152  geom->loadSpecParsHexagon(fv, php, cpv, namew, namec);
153  // Load the Geometry parameters
154  geom->loadGeometryHexagon(fv, php, name, cpv, namew, namec, mode);
155  // Modify some constants
156  geom->loadWaferHexagon(php);
157  // Load cell parameters
158  geom->loadCellParsHexagon(cpv, php);
159  // Set complete fill mode
160  php.defineFull_ = true;
161  } else if (php.mode_ == HGCalGeometryMode::Hexagon8) {
162  // Load the SpecPars
163  geom->loadSpecParsHexagon8(fv, php);
164  // Load Geometry parameters
165  geom->loadGeometryHexagon8(fv, php, 1);
166  // Set complete fill mode
167  php.defineFull_ = false;
168  // Load wafer positions
169  geom->loadWaferHexagon8(php);
171  // Load the SpecPars
172  geom->loadSpecParsHexagon8(fv, php);
173  // Load Geometry parameters
174  geom->loadGeometryHexagon8(fv, php, 1);
175  // Set complete fill mode
176  php.defineFull_ = true;
177  // Load wafer positions
178  geom->loadWaferHexagon8(php);
181  // Load the SpecPars
182  geom->loadSpecParsHexagon8(fv, php);
183  // Load Geometry parameters
184  geom->loadGeometryHexagonModule(cpv, php, name, namec, 1);
185  // Set complete fill mode
186  php.defineFull_ = true;
187  // Load wafer positions
188  geom->loadWaferHexagon8(php);
192  // Load maximum eta & top level
193  php.levelT_ = dbl_to_int(getDDDArray("LevelTop", sv));
194  php.firstLayer_ = (int)(getDDDValue("FirstLayer", sv));
195  php.firstMixedLayer_ = (int)(getDDDValue("FirstMixedLayer", sv));
196  php.detectorType_ = (int)(getDDDValue("DetectorType", sv));
197  php.waferThick_ = HGCalParameters::k_ScaleFromDDD * getDDDValue("WaferThickness", sv);
198  php.minTileSize_ = HGCalParameters::k_ScaleFromDDD * getDDDValue("MinimumTileSize", sv);
199  php.waferSize_ = php.waferR_ = 0;
200  php.sensorSeparation_ = php.mouseBite_ = 0;
201  php.sensorSizeOffset_ = php.guardRingOffset_ = php.useOffset_ = 0;
202  php.waferMaskMode_ = static_cast<int>(getDDDValue("WaferMaskMode", sv));
203  php.waferZSide_ = static_cast<int>(getDDDValue("WaferZside", sv));
205  php.useSimWt_ = static_cast<int>(getDDDValue("UseSimWt", sv));
207  php.cassettes_ = getDDDValue("Cassettes", sv);
208 #ifdef EDM_ML_DEBUG
209  edm::LogVerbatim("HGCalGeom") << "Top levels " << php.levelT_[0] << ":" << php.levelT_[1] << " first layers "
210  << php.firstLayer_ << ":" << php.firstMixedLayer_ << " Det Type "
211  << php.detectorType_ << " thickenss " << php.waferThick_ << " Tile Mask Mode "
212  << php.waferMaskMode_ << " Zside " << php.waferZSide_ << " Cassettes "
213  << php.cassettes_ << " UseSimWt " << php.useSimWt_;
214 #endif
215  // Load the SpecPars
216  geom->loadSpecParsTrapezoid(fv, php);
217  // Load Geometry parameters
218  geom->loadGeometryHexagon8(fv, php, php.firstLayer_);
219  // Load cell positions
220  geom->loadCellTrapezoid(php);
221  } else {
222  edm::LogError("HGCalGeom") << "Unknown Geometry type " << php.mode_ << " for HGCal " << name << ":" << namew
223  << ":" << namec;
224  throw cms::Exception("DDException")
225  << "Unknown Geometry type " << php.mode_ << " for HGCal " << name << ":" << namew << ":" << namec;
226  }
227  } else {
228  edm::LogError("HGCalGeom") << " Attribute " << val << " not found but needed.";
229  throw cms::Exception("DDException") << "Attribute " << val << " not found but needed.";
230  }
231 #ifdef EDM_ML_DEBUG
232  edm::LogVerbatim("HGCalGeom") << "Return from HGCalParametersFromDD::build"
233  << " with flag " << ok;
234 #endif
235  return ok;
236 }
237 
239  HGCalParameters& php,
240  const std::string& name,
241  const std::string& namew,
242  const std::string& namec,
243  const std::string& namet,
244  const std::string& name2) {
245 #ifdef EDM_ML_DEBUG
246  edm::LogVerbatim("HGCalGeom") << "HGCalParametersFromDD (DD4hep)::build called with "
247  << "names " << name << ":" << namew << ":" << namec << ":" << namet << ":" << name2;
248 #endif
249  cms::DDVectorsMap vmap = cpv->detector()->vectors();
250  const cms::DDFilter filter("Volume", name);
251  cms::DDFilteredView fv((*cpv), filter);
252  std::vector<std::string> tempS;
253  std::vector<double> tempD;
254  bool ok = fv.firstChild();
255  tempS = fv.get<std::vector<std::string> >(name2, "GeometryMode");
256  if (tempS.empty()) {
257  tempS = fv.get<std::vector<std::string> >(name, "GeometryMode");
258  }
259  std::string sv = (!tempS.empty()) ? tempS[0] : "HGCalGeometryMode::Hexagon8Full";
261 #ifdef EDM_ML_DEBUG
262  edm::LogVerbatim("HGCalGeom") << "Volume " << name << " GeometryMode ";
263 #endif
264 
265  if (ok) {
267 #ifdef EDM_ML_DEBUG
268  edm::LogVerbatim("HGCalGeom") << "Volume " << name << " GeometryMode " << php.mode_ << ":"
274  << ":" << HGCalGeometryMode::TrapezoidCassette << ":"
276 #endif
277  php.levelZSide_ = 3; // Default level for ZSide
278  php.detectorType_ = 0; // These two parameters are
279  php.firstMixedLayer_ = -1; // defined for post TDR geometry
280  php.useSimWt_ = 1; // energy weighting for SimHits
281  php.layerRotation_ = 0; // default layer rotation angle
282  php.cassettes_ = 0; // default number of cassettes
283  std::unique_ptr<HGCalGeomParameters> geom = std::make_unique<HGCalGeomParameters>();
285  tempS = fv.get<std::vector<std::string> >(namet, "WaferMode");
286  std::string sv2 = (!tempS.empty()) ? tempS[0] : "HGCalGeometryMode::Polyhedra";
288 #ifdef EDM_ML_DEBUG
289  edm::LogVerbatim("HGCalGeom") << "WaferMode " << mode << ":" << HGCalGeometryMode::Polyhedra << ":"
291 #endif
292  php.minTileSize_ = 0;
293  php.waferMaskMode_ = 0;
294  php.waferZSide_ = 0;
295  }
299  php.levelT_ = dbl_to_int(fv.get<std::vector<double> >(name, "LevelTop"));
300  tempD = fv.get<std::vector<double> >(name, "LevelZSide");
301  php.levelZSide_ = static_cast<int>(tempD[0]);
302  php.nCellsFine_ = php.nCellsCoarse_ = 0;
303  php.firstLayer_ = 1;
304  tempD = fv.get<std::vector<double> >(name, "FirstMixedLayer");
305  php.firstMixedLayer_ = static_cast<int>(tempD[0]);
306  tempD = fv.get<std::vector<double> >(name, "DetectorType");
307  php.detectorType_ = static_cast<int>(tempD[0]);
308  php.minTileSize_ = 0;
309  tempD = fv.get<std::vector<double> >(name, "WaferMaskMode");
310  php.waferMaskMode_ = static_cast<int>(tempD[0]);
311  tempD = fv.get<std::vector<double> >(name, "WaferZside");
312  php.waferZSide_ = static_cast<int>(tempD[0]);
315  tempD = fv.get<std::vector<double> >(name, "LayerRotation");
316  php.layerRotation_ = tempD[0];
317  tempD = fv.get<std::vector<double> >(name, "UseSimWt");
318  php.useSimWt_ = tempD[0];
319  }
322  tempD = fv.get<std::vector<double> >(name, "Cassettes");
323  php.cassettes_ = static_cast<int>(tempD[0]);
324  }
325 #ifdef EDM_ML_DEBUG
326  edm::LogVerbatim("HGCalGeom") << "Top levels " << php.levelT_[0] << ":" << php.levelT_[1] << " ZSide Level "
327  << php.levelZSide_ << " first layers " << php.firstLayer_ << ":"
328  << php.firstMixedLayer_ << " Det Type " << php.detectorType_ << " Wafer Mask Mode "
329  << php.waferMaskMode_ << " ZSide " << php.waferZSide_ << " Layer Rotation "
330  << convertRadToDeg(php.layerRotation_) << " Cassettes " << php.cassettes_
331  << " UseSimWt " << php.useSimWt_;
332 #endif
333 
334  tempS = fv.get<std::vector<std::string> >(namet, "WaferMode");
335  std::string sv2 = (!tempS.empty()) ? tempS[0] : "HGCalGeometryMode::ExtrudedPolygon";
337  tempD = fv.get<std::vector<double> >(namet, "NumberOfCellsFine");
338  php.nCellsFine_ = static_cast<int>(tempD[0]);
339  tempD = fv.get<std::vector<double> >(namet, "NumberOfCellsCoarse");
340  php.nCellsCoarse_ = static_cast<int>(tempD[0]);
341  tempD = fv.get<std::vector<double> >(namet, "WaferSize");
343  tempD = fv.get<std::vector<double> >(namet, "WaferThickness");
345  tempD = fv.get<std::vector<double> >(namet, "SensorSeparation");
347  tempD = fv.get<std::vector<double> >(namet, "SensorSizeOffset");
349  tempD = fv.get<std::vector<double> >(namet, "GuardRingOffset");
351  tempD = fv.get<std::vector<double> >(namet, "MouseBite");
353  tempD = fv.get<std::vector<double> >(namet, "UseOffset");
354  php.useOffset_ = static_cast<int>(tempD[0]);
355  php.waferR_ = HGCalParameters::k_ScaleToDDD * php.waferSize_ * tan30deg_;
356  php.cellSize_.emplace_back(HGCalParameters::k_ScaleToDDD * php.waferSize_ / php.nCellsFine_);
357  php.cellSize_.emplace_back(HGCalParameters::k_ScaleToDDD * php.waferSize_ / php.nCellsCoarse_);
358 #ifdef EDM_ML_DEBUG
359  edm::LogVerbatim("HGCalGeom") << "WaferMode " << mode << ":" << HGCalGeometryMode::Polyhedra << ":"
360  << HGCalGeometryMode::ExtrudedPolygon << " # of cells|size for fine/coarse "
361  << php.nCellsFine_ << ":" << php.cellSize_[0] << ":" << php.nCellsCoarse_ << ":"
362  << php.cellSize_[1] << " wafer Params " << php.waferSize_ << ":" << php.waferR_
363  << ":" << php.waferThick_ << ":" << php.sensorSeparation_ << ":"
364  << php.sensorSizeOffset_ << ":" << php.guardRingOffset_ << ":" << php.mouseBite_
365  << ":" << php.useOffset_ << ":" << php.waferR_;
366 #endif
367  for (int k = 0; k < 2; ++k)
368  getCellPosition(php, k);
369  }
370  if (php.mode_ == HGCalGeometryMode::Hexagon) {
371  // Load the SpecPars
372  php.firstLayer_ = 1;
373  geom->loadSpecParsHexagon(fv, php, name, namew, namec, name2);
374  // Load the Geometry parameters
375  geom->loadGeometryHexagon(cpv, php, name, namew, namec, mode);
376  // Load cell parameters
377  geom->loadCellParsHexagon(vmap, php);
378  // Set complete fill mode
379  php.defineFull_ = false;
380  } else if (php.mode_ == HGCalGeometryMode::HexagonFull) {
381  // Load the SpecPars
382  php.firstLayer_ = 1;
383  geom->loadSpecParsHexagon(fv, php, name, namew, namec, name2);
384  // Load the Geometry parameters
385  geom->loadGeometryHexagon(cpv, php, name, namew, namec, mode);
386  // Modify some constants
387  geom->loadWaferHexagon(php);
388  // Load cell parameters
389  geom->loadCellParsHexagon(vmap, php);
390  // Set complete fill mode
391  php.defineFull_ = true;
392  } else if (php.mode_ == HGCalGeometryMode::Hexagon8) {
393  // Load the SpecPars
394  geom->loadSpecParsHexagon8(fv, vmap, php, name);
395  // Load Geometry parameters
396  geom->loadGeometryHexagon8(cpv, php, name, 1);
397  // Set complete fill mode
398  php.defineFull_ = false;
399  // Load wafer positions
400  geom->loadWaferHexagon8(php);
402  // Load the SpecPars
403  geom->loadSpecParsHexagon8(fv, vmap, php, name);
404  // Load Geometry parameters
405  geom->loadGeometryHexagon8(cpv, php, name, 1);
406  // Set complete fill mode
407  php.defineFull_ = true;
408  // Load wafer positions
409  geom->loadWaferHexagon8(php);
412  // Load the SpecPars
413  geom->loadSpecParsHexagon8(fv, vmap, php, name);
414  // Load Geometry parameters
415  geom->loadGeometryHexagonModule(cpv, php, name, namec, 1);
416  // Set complete fill mode
417  php.defineFull_ = true;
418  // Load wafer positions
419  geom->loadWaferHexagon8(php);
423  // Load maximum eta & top level
424  php.levelT_ = dbl_to_int(fv.get<std::vector<double> >(name, "LevelTop"));
425  tempD = fv.get<std::vector<double> >(name, "LevelZSide");
426  php.levelZSide_ = static_cast<int>(tempD[0]);
427  php.nCellsFine_ = php.nCellsCoarse_ = 0;
428  tempD = fv.get<std::vector<double> >(name, "FirstLayer");
429  php.firstLayer_ = static_cast<int>(tempD[0]);
430  tempD = fv.get<std::vector<double> >(name, "FirstMixedLayer");
431  php.firstMixedLayer_ = static_cast<int>(tempD[0]);
432  tempD = fv.get<std::vector<double> >(name, "DetectorType");
433  php.detectorType_ = static_cast<int>(tempD[0]);
434  tempD = fv.get<std::vector<double> >(name, "WaferThickness");
436  tempD = fv.get<std::vector<double> >(name, "MinimumTileSize");
438  php.waferSize_ = php.waferR_ = 0;
439  php.sensorSeparation_ = php.mouseBite_ = 0;
440  php.sensorSizeOffset_ = php.guardRingOffset_ = php.useOffset_ = 0;
441  tempD = fv.get<std::vector<double> >(name, "WaferMaskMode");
442  php.waferMaskMode_ = static_cast<int>(tempD[0]);
443  tempD = fv.get<std::vector<double> >(name, "WaferZside");
444  php.waferZSide_ = static_cast<int>(tempD[0]);
446  tempD = fv.get<std::vector<double> >(name, "UseSimWt");
447  php.useSimWt_ = tempD[0];
448  }
450  tempD = fv.get<std::vector<double> >(name, "Cassettes");
451  php.cassettes_ = static_cast<int>(tempD[0]);
452  }
453 #ifdef EDM_ML_DEBUG
454  edm::LogVerbatim("HGCalGeom") << "Top levels " << php.levelT_[0] << ":" << php.levelT_[1] << " first layers "
455  << php.firstLayer_ << ":" << php.firstMixedLayer_ << " Det Type "
456  << php.detectorType_ << " thickenss " << php.waferThick_ << " min tile size "
457  << php.minTileSize_ << " Tile Mask Mode " << php.waferMaskMode_ << " ZSide "
458  << php.waferZSide_ << " Cassettes " << php.cassettes_ << " UseSimWt "
459  << php.useSimWt_;
460 #endif
461  // Load the SpecPars
462  geom->loadSpecParsTrapezoid(fv, vmap, php, name);
463  // Load Geometry parameters
464  geom->loadGeometryHexagon8(cpv, php, name, php.firstLayer_);
465  // Load cell positions
466  geom->loadCellTrapezoid(php);
467  } else {
468  edm::LogError("HGCalGeom") << "Unknown Geometry type " << php.mode_ << " for HGCal " << name << ":" << namew
469  << ":" << namec;
470  throw cms::Exception("DDException")
471  << "Unknown Geometry type " << php.mode_ << " for HGCal " << name << ":" << namew << ":" << namec;
472  }
473  } else {
474  edm::LogError("HGCalGeom") << " Attribute Volume:" << name << " not found but needed.";
475  throw cms::Exception("DDException") << "Attribute Volume:" << name << " not found but needed.";
476  }
477 #ifdef EDM_ML_DEBUG
478  edm::LogVerbatim("HGCalGeom") << "Return from HGCalParametersFromDD::build"
479  << " with flag " << ok;
480 #endif
481  return ok;
482 }
483 
485  if (type == 1) {
486  php.cellCoarseX_.clear();
487  php.cellCoarseY_.clear();
488  } else {
489  php.cellFineX_.clear();
490  php.cellFineY_.clear();
491  }
492  HGCalParameters::wafer_map cellIndex;
493 #ifdef EDM_ML_DEBUG
494  std::vector<int> indtypes;
495 #endif
496  int N = (type == 1) ? php.nCellsCoarse_ : php.nCellsFine_;
497  double R = php.waferSize_ / (3 * N);
498  double r = 0.5 * R * sqrt(3.0);
499  int n2 = N / 2;
500  int ipos(0);
501  for (int u = 0; u < 2 * N; ++u) {
502  for (int v = 0; v < 2 * N; ++v) {
503  if (((v - u) < N) && (u - v) <= N) {
504  double yp = (u - 0.5 * v - n2) * 2 * r;
505  double xp = (1.5 * (v - N) + 1.0) * R;
506  int id = v * 100 + u;
507 #ifdef EDM_ML_DEBUG
508  indtypes.emplace_back(id);
509 #endif
510  if (type == 1) {
511  php.cellCoarseX_.emplace_back(xp);
512  php.cellCoarseY_.emplace_back(yp);
513  } else {
514  php.cellFineX_.emplace_back(xp);
515  php.cellFineY_.emplace_back(yp);
516  }
517  cellIndex[id] = ipos;
518  ++ipos;
519  }
520  }
521  }
522  if (type == 1)
523  php.cellCoarseIndex_ = cellIndex;
524  else
525  php.cellFineIndex_ = cellIndex;
526 
527 #ifdef EDM_ML_DEBUG
528  if (type == 1) {
529  edm::LogVerbatim("HGCalGeom") << "CellPosition for type " << type << " for " << php.cellCoarseX_.size()
530  << " cells";
531  for (unsigned int k = 0; k < php.cellCoarseX_.size(); ++k) {
532  int id = indtypes[k];
533  edm::LogVerbatim("HGCalGeom") << "[" << k << "] ID " << id << ":" << php.cellCoarseIndex_[id] << " X "
534  << php.cellCoarseX_[k] << " Y " << php.cellCoarseY_[k];
535  }
536  } else {
537  edm::LogVerbatim("HGCalGeom") << "CellPosition for type " << type << " for " << php.cellFineX_.size() << " cells";
538  for (unsigned int k = 0; k < php.cellFineX_.size(); ++k) {
539  int id = indtypes[k];
540  edm::LogVerbatim("HGCalGeom") << "[" << k << "] ID " << id << ":" << php.cellFineIndex_[k] << " X "
541  << php.cellFineX_[k] << " Y " << php.cellFineY_[k];
542  }
543  }
544 #endif
545 }
546 
548  DDValue val(s);
549  if (DDfetch(&sv, val)) {
550  const std::vector<double>& fvec = val.doubles();
551  if (fvec.empty()) {
552  throw cms::Exception("HGCalGeom") << "getDDDValue::Failed to get " << s << " tag.";
553  }
554  return fvec[0];
555  } else {
556  throw cms::Exception("HGCalGeom") << "getDDDValue::Failed to fetch " << s << " tag";
557  }
558 }
559 
560 std::vector<double> HGCalParametersFromDD::getDDDArray(const char* s, const DDsvalues_type& sv) {
561  DDValue val(s);
562  if (DDfetch(&sv, val)) {
563  const std::vector<double>& fvec = val.doubles();
564  if (fvec.empty()) {
565  throw cms::Exception("HGCalGeom") << "getDDDArray::Failed to get " << s << " tag.";
566  }
567  return fvec;
568  } else {
569  throw cms::Exception("HGCalGeom") << "getDDDArray:Failed to fetch " << s << " tag";
570  }
571 }
Log< level::Info, true > LogVerbatim
static constexpr int scintillatorCassette
wafer_map cellFineIndex_
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
std::vector< double > cellFineY_
const cms::DDDetector * detector() const
Definition: DDCompactView.h:34
Log< level::Error, false > LogError
bool build(const DDCompactView *cpv, HGCalParameters &php, const std::string &name, const std::string &namew, const std::string &namec, const std::string &namet)
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:79
HGCalGeometryMode::GeometryMode mode_
std::unordered_map< std::string, std::vector< double > > DDVectorsMap
Definition: DDNamespace.h:20
WaferMode getGeometryWaferMode(const char *s, const DDsvalues_type &sv)
std::vector< double > cellCoarseX_
static constexpr int siliconCassetteHE
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
Definition: DDsvalues.h:12
std::vector< double > cellSize_
T sqrt(T t)
Definition: SSEVec.h:19
static constexpr int siliconCassetteEE
GeometryMode getGeometryMode(const char *s, const DDsvalues_type &sv)
static constexpr double k_ScaleFromDD4hep
Definition: value.py:1
bool firstChild()
set the current node to the first child
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
DDsvalues_type mergedSpecifics() const
T get(const std::string &)
extract attribute value
static constexpr double k_ScaleToDDD
#define N
Definition: blowfish.cc:9
std::unordered_map< int32_t, int32_t > wafer_map
double getDDDValue(const char *s, const DDsvalues_type &sv)
wafer_map cellCoarseIndex_
std::vector< double > cellFineX_
static constexpr double k_ScaleFromDDD
bool firstChild()
set the current node to the first child ...
std::vector< int > levelT_
std::vector< double > cellCoarseY_
cms::DDVectorsMap const & vectors() const
Definition: DDDetector.h:17
std::vector< double > getDDDArray(const char *s, const DDsvalues_type &sv)
void getCellPosition(HGCalParameters &php, int type)