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_ << ":"
49 #endif
50  php.levelZSide_ = 3; // Default level for ZSide
51  php.detectorType_ = 0; // These two parameters are
52  php.firstMixedLayer_ = -1; // defined for post TDR geometry
53  php.useSimWt_ = 1; // energy weighting for SimHits
54  php.layerRotation_ = 0; // default layer rotation angle
55  php.cassettes_ = 0; // default number of cassettes
56  php.nphiCassette_ = 0; // default number of phi's per cassette
57  php.phiOffset_ = 0; // default value of phi offset for cassette
58  php.calibCellRHD_ = 0; // default value of R of HD calibration cells
59  php.calibCellRLD_ = 0; // default value of R of LD calibration cells
60  std::unique_ptr<HGCalGeomParameters> geom = std::make_unique<HGCalGeomParameters>();
62  attribute = "OnlyForHGCalNumbering";
63  value = namet;
64  DDValue val2(attribute, value, 0.0);
65  DDSpecificsMatchesValueFilter filter2{val2};
66  DDFilteredView fv2(*cpv, filter2);
67  bool ok2 = fv2.firstChild();
68  if (ok2) {
71 #ifdef EDM_ML_DEBUG
72  edm::LogVerbatim("HGCalGeom") << "WaferMode " << mode << ":" << HGCalGeometryMode::Polyhedra << ":"
74 #endif
75  }
76  php.minTileSize_ = 0;
77  php.waferMaskMode_ = 0;
78  php.waferZSide_ = 0;
79  }
83  php.levelT_ = dbl_to_int(getDDDArray("LevelTop", sv));
84  php.levelZSide_ = static_cast<int>(getDDDValue("LevelZSide", sv));
85  php.nCellsFine_ = php.nCellsCoarse_ = 0;
86  php.firstLayer_ = 1;
87  php.firstMixedLayer_ = static_cast<int>(getDDDValue("FirstMixedLayer", sv));
88  php.detectorType_ = static_cast<int>(getDDDValue("DetectorType", sv));
89  php.minTileSize_ = 0;
90  php.waferMaskMode_ = static_cast<int>(getDDDValue("WaferMaskMode", sv));
91  php.waferZSide_ = static_cast<int>(getDDDValue("WaferZside", sv));
94  php.useSimWt_ = static_cast<int>(getDDDValue("UseSimWt", sv));
95  php.layerRotation_ = getDDDValue("LayerRotation", sv);
96  }
99  php.cassettes_ = getDDDValue("Cassettes", sv);
100 #ifdef EDM_ML_DEBUG
101  edm::LogVerbatim("HGCalGeom") << "Top levels " << php.levelT_[0] << ":" << php.levelT_[1] << " ZSide Level "
102  << php.levelZSide_ << " first layers " << php.firstLayer_ << ":"
103  << php.firstMixedLayer_ << " Det Type " << php.detectorType_ << " Wafer Mask Mode "
104  << php.waferMaskMode_ << " ZSide " << php.waferZSide_ << " Layer Rotation "
105  << convertRadToDeg(php.layerRotation_) << " Cassettes " << php.cassettes_
106  << " UseSimWt " << php.useSimWt_;
107 #endif
108  attribute = "OnlyForHGCalNumbering";
109  value = namet;
110  DDValue val2(attribute, value, 0.0);
111  DDSpecificsMatchesValueFilter filter2{val2};
112  DDFilteredView fv2(*cpv, filter2);
113  bool ok2 = fv2.firstChild();
114  if (ok2) {
115  DDsvalues_type sv2(fv2.mergedSpecifics());
116  mode = HGCalGeometryMode::getGeometryWaferMode("WaferMode", sv2);
117  php.nCellsFine_ = static_cast<int>(getDDDValue("NumberOfCellsFine", sv2));
118  php.nCellsCoarse_ = static_cast<int>(getDDDValue("NumberOfCellsCoarse", sv2));
119  php.waferSize_ = HGCalParameters::k_ScaleFromDDD * getDDDValue("WaferSize", sv2);
120  php.waferThick_ = HGCalParameters::k_ScaleFromDDD * getDDDValue("WaferThickness", sv2);
121  php.sensorSeparation_ = HGCalParameters::k_ScaleFromDDD * getDDDValue("SensorSeparation", sv2);
122  php.sensorSizeOffset_ = HGCalParameters::k_ScaleFromDDD * getDDDValue("SensorSizeOffset", sv2);
123  php.guardRingOffset_ = HGCalParameters::k_ScaleFromDDD * getDDDValue("GuardRingOffset", sv2);
124  php.mouseBite_ = HGCalParameters::k_ScaleFromDDD * getDDDValue("MouseBite", sv2);
125  php.useOffset_ = static_cast<int>(getDDDValue("UseOffset", sv2));
126  php.waferR_ = HGCalParameters::k_ScaleToDDD * php.waferSize_ * tan30deg_;
127  assert(php.nCellsFine_ != 0);
128  assert(php.nCellsCoarse_ != 0);
129  php.cellSize_.emplace_back(HGCalParameters::k_ScaleToDDD * php.waferSize_ / php.nCellsFine_);
130  php.cellSize_.emplace_back(HGCalParameters::k_ScaleToDDD * php.waferSize_ / php.nCellsCoarse_);
131 #ifdef EDM_ML_DEBUG
132  edm::LogVerbatim("HGCalGeom") << "WaferMode " << mode << ":" << HGCalGeometryMode::Polyhedra << ":"
133  << HGCalGeometryMode::ExtrudedPolygon << " # of cells|size for fine/coarse "
134  << php.nCellsFine_ << ":" << php.cellSize_[0] << ":" << php.nCellsCoarse_ << ":"
135  << php.cellSize_[1] << " wafer Params " << php.waferSize_ << ":" << php.waferR_
136  << ":" << php.waferThick_ << ":" << php.sensorSeparation_ << ":"
137  << php.sensorSizeOffset_ << ":" << php.guardRingOffset_ << ":" << php.mouseBite_
138  << ":" << php.useOffset_ << ":" << php.waferR_;
139 #endif
140  for (int k = 0; k < 2; ++k)
141  getCellPosition(php, k);
142  }
143  }
144  if (php.mode_ == HGCalGeometryMode::Hexagon) {
145  // Load the SpecPars
146  php.firstLayer_ = 1;
147  geom->loadSpecParsHexagon(fv, php, cpv, namew, namec);
148  // Load the Geometry parameters
149  geom->loadGeometryHexagon(fv, php, name, cpv, namew, namec, mode);
150  // Load cell parameters
151  geom->loadCellParsHexagon(cpv, php);
152  // Set complete fill mode
153  php.defineFull_ = false;
154  } else if (php.mode_ == HGCalGeometryMode::HexagonFull) {
155  // Load the SpecPars
156  php.firstLayer_ = 1;
157  geom->loadSpecParsHexagon(fv, php, cpv, namew, namec);
158  // Load the Geometry parameters
159  geom->loadGeometryHexagon(fv, php, name, cpv, namew, namec, mode);
160  // Modify some constants
161  geom->loadWaferHexagon(php);
162  // Load cell parameters
163  geom->loadCellParsHexagon(cpv, php);
164  // Set complete fill mode
165  php.defineFull_ = true;
166  } else if (php.mode_ == HGCalGeometryMode::Hexagon8) {
167  // Load the SpecPars
168  geom->loadSpecParsHexagon8(fv, php);
169  // Load Geometry parameters
170  geom->loadGeometryHexagon8(fv, php, 1);
171  // Set complete fill mode
172  php.defineFull_ = false;
173  // Load wafer positions
174  geom->loadWaferHexagon8(php);
176  // Load the SpecPars
177  geom->loadSpecParsHexagon8(fv, php);
178  // Load Geometry parameters
179  geom->loadGeometryHexagon8(fv, php, 1);
180  // Set complete fill mode
181  php.defineFull_ = true;
182  // Load wafer positions
183  geom->loadWaferHexagon8(php);
186  // Load the SpecPars
187  geom->loadSpecParsHexagon8(fv, php);
188  // Load Geometry parameters
189  geom->loadGeometryHexagonModule(cpv, php, name, namec, 1);
190  // Set complete fill mode
191  php.defineFull_ = true;
192  // Load wafer positions
193  geom->loadWaferHexagon8(php);
198  // Load maximum eta & top level
199  php.levelT_ = dbl_to_int(getDDDArray("LevelTop", sv));
200  php.levelZSide_ = static_cast<int>(getDDDValue("LevelZSide", sv));
201  php.firstLayer_ = (int)(getDDDValue("FirstLayer", sv));
202  php.firstMixedLayer_ = (int)(getDDDValue("FirstMixedLayer", sv));
203  php.detectorType_ = (int)(getDDDValue("DetectorType", sv));
204  php.waferThick_ = HGCalParameters::k_ScaleFromDDD * getDDDValue("WaferThickness", sv);
205  php.minTileSize_ = HGCalParameters::k_ScaleFromDDD * getDDDValue("MinimumTileSize", sv);
206  php.nCellsFine_ = php.nCellsCoarse_ = 0;
207  php.waferSize_ = php.waferR_ = 0;
208  php.sensorSeparation_ = php.mouseBite_ = 0;
209  php.sensorSizeOffset_ = php.guardRingOffset_ = php.useOffset_ = 0;
210  php.waferMaskMode_ = static_cast<int>(getDDDValue("WaferMaskMode", sv));
211  php.waferZSide_ = static_cast<int>(getDDDValue("WaferZside", sv));
214  php.useSimWt_ = static_cast<int>(getDDDValue("UseSimWt", sv));
217  php.cassettes_ = getDDDValue("Cassettes", sv);
218 #ifdef EDM_ML_DEBUG
219  edm::LogVerbatim("HGCalGeom") << "Top levels " << php.levelT_[0] << ":" << php.levelT_[1] << " first layers "
220  << php.firstLayer_ << ":" << php.firstMixedLayer_ << " Det Type "
221  << php.detectorType_ << " thickenss " << php.waferThick_ << " Tile Mask Mode "
222  << php.waferMaskMode_ << " Zside " << php.waferZSide_ << " Cassettes "
223  << php.cassettes_ << " UseSimWt " << php.useSimWt_;
224 #endif
225  // Load the SpecPars
226  geom->loadSpecParsTrapezoid(fv, php);
227  // Load Geometry parameters
228  geom->loadGeometryHexagon8(fv, php, php.firstLayer_);
229  // Load cell positions
230  geom->loadCellTrapezoid(php);
231  } else {
232  edm::LogError("HGCalGeom") << "Unknown Geometry type " << php.mode_ << " for HGCal " << name << ":" << namew
233  << ":" << namec;
234  throw cms::Exception("DDException")
235  << "Unknown Geometry type " << php.mode_ << " for HGCal " << name << ":" << namew << ":" << namec;
236  }
237  } else {
238  edm::LogError("HGCalGeom") << " Attribute " << val << " not found but needed.";
239  throw cms::Exception("DDException") << "Attribute " << val << " not found but needed.";
240  }
241 #ifdef EDM_ML_DEBUG
242  edm::LogVerbatim("HGCalGeom") << "Return from HGCalParametersFromDD::build"
243  << " with flag " << ok;
244 #endif
245  return ok;
246 }
247 
249  HGCalParameters& php,
250  const std::string& name,
251  const std::string& namew,
252  const std::string& namec,
253  const std::string& namet,
254  const std::string& name2) {
255 #ifdef EDM_ML_DEBUG
256  edm::LogVerbatim("HGCalGeom") << "HGCalParametersFromDD (DD4hep)::build called with "
257  << "names " << name << ":" << namew << ":" << namec << ":" << namet << ":" << name2;
258 #endif
259  cms::DDVectorsMap vmap = cpv->detector()->vectors();
260  const cms::DDFilter filter("Volume", name);
261  cms::DDFilteredView fv((*cpv), filter);
262  std::vector<std::string> tempS;
263  std::vector<double> tempD;
264  bool ok = fv.firstChild();
265  tempS = fv.get<std::vector<std::string> >(name2, "GeometryMode");
266  if (tempS.empty()) {
267  tempS = fv.get<std::vector<std::string> >(name, "GeometryMode");
268  }
269  std::string sv = (!tempS.empty()) ? tempS[0] : "HGCalGeometryMode::Hexagon8Full";
271 #ifdef EDM_ML_DEBUG
272  edm::LogVerbatim("HGCalGeom") << "Volume " << name << " GeometryMode ";
273 #endif
274 
275  if (ok) {
277 #ifdef EDM_ML_DEBUG
278  edm::LogVerbatim("HGCalGeom") << "Volume " << name << " GeometryMode " << php.mode_ << ":"
284  << ":" << HGCalGeometryMode::TrapezoidCassette << ":"
287 #endif
288  php.levelZSide_ = 3; // Default level for ZSide
289  php.detectorType_ = 0; // These two parameters are
290  php.firstMixedLayer_ = -1; // defined for post TDR geometry
291  php.useSimWt_ = 1; // energy weighting for SimHits
292  php.layerRotation_ = 0; // default layer rotation angle
293  php.cassettes_ = 0; // default number of cassettes
294  php.nphiCassette_ = 0; // default number of phi's per cassette
295  php.phiOffset_ = 0; // default value of phi offset for cassette
296  php.calibCellRHD_ = 0; // default value of R of HD calibration cells
297  php.calibCellRLD_ = 0; // default value of R of LD calibration cells
298  std::unique_ptr<HGCalGeomParameters> geom = std::make_unique<HGCalGeomParameters>();
300  tempS = fv.get<std::vector<std::string> >(namet, "WaferMode");
301  std::string sv2 = (!tempS.empty()) ? tempS[0] : "HGCalGeometryMode::Polyhedra";
303 #ifdef EDM_ML_DEBUG
304  edm::LogVerbatim("HGCalGeom") << "WaferMode " << mode << ":" << HGCalGeometryMode::Polyhedra << ":"
306 #endif
307  php.minTileSize_ = 0;
308  php.waferMaskMode_ = 0;
309  php.waferZSide_ = 0;
310  }
314  php.levelT_ = dbl_to_int(fv.get<std::vector<double> >(name, "LevelTop"));
315  tempD = fv.get<std::vector<double> >(name, "LevelZSide");
316  php.levelZSide_ = static_cast<int>(tempD[0]);
317  php.nCellsFine_ = php.nCellsCoarse_ = 0;
318  php.firstLayer_ = 1;
319  tempD = fv.get<std::vector<double> >(name, "FirstMixedLayer");
320  php.firstMixedLayer_ = static_cast<int>(tempD[0]);
321  tempD = fv.get<std::vector<double> >(name, "DetectorType");
322  php.detectorType_ = static_cast<int>(tempD[0]);
323  php.minTileSize_ = 0;
324  tempD = fv.get<std::vector<double> >(name, "WaferMaskMode");
325  php.waferMaskMode_ = static_cast<int>(tempD[0]);
326  tempD = fv.get<std::vector<double> >(name, "WaferZside");
327  php.waferZSide_ = static_cast<int>(tempD[0]);
330  tempD = fv.get<std::vector<double> >(name, "LayerRotation");
331  php.layerRotation_ = tempD[0];
332  tempD = fv.get<std::vector<double> >(name, "UseSimWt");
333  php.useSimWt_ = tempD[0];
334  }
337  tempD = fv.get<std::vector<double> >(name, "Cassettes");
338  php.cassettes_ = static_cast<int>(tempD[0]);
339  }
340 #ifdef EDM_ML_DEBUG
341  edm::LogVerbatim("HGCalGeom") << "Top levels " << php.levelT_[0] << ":" << php.levelT_[1] << " ZSide Level "
342  << php.levelZSide_ << " first layers " << php.firstLayer_ << ":"
343  << php.firstMixedLayer_ << " Det Type " << php.detectorType_ << " Wafer Mask Mode "
344  << php.waferMaskMode_ << " ZSide " << php.waferZSide_ << " Layer Rotation "
345  << convertRadToDeg(php.layerRotation_) << " Cassettes " << php.cassettes_
346  << " UseSimWt " << php.useSimWt_;
347 #endif
348 
349  tempS = fv.get<std::vector<std::string> >(namet, "WaferMode");
350  std::string sv2 = (!tempS.empty()) ? tempS[0] : "HGCalGeometryMode::ExtrudedPolygon";
352  tempD = fv.get<std::vector<double> >(namet, "NumberOfCellsFine");
353  php.nCellsFine_ = static_cast<int>(tempD[0]);
354  tempD = fv.get<std::vector<double> >(namet, "NumberOfCellsCoarse");
355  php.nCellsCoarse_ = static_cast<int>(tempD[0]);
356  tempD = fv.get<std::vector<double> >(namet, "WaferSize");
358  tempD = fv.get<std::vector<double> >(namet, "WaferThickness");
360  tempD = fv.get<std::vector<double> >(namet, "SensorSeparation");
362  tempD = fv.get<std::vector<double> >(namet, "SensorSizeOffset");
364  tempD = fv.get<std::vector<double> >(namet, "GuardRingOffset");
366  tempD = fv.get<std::vector<double> >(namet, "MouseBite");
368  tempD = fv.get<std::vector<double> >(namet, "UseOffset");
369  php.useOffset_ = static_cast<int>(tempD[0]);
370  php.waferR_ = HGCalParameters::k_ScaleToDDD * php.waferSize_ * tan30deg_;
371  assert(php.nCellsFine_ != 0);
372  assert(php.nCellsCoarse_ != 0);
373  php.cellSize_.emplace_back(HGCalParameters::k_ScaleToDDD * php.waferSize_ / php.nCellsFine_);
374  php.cellSize_.emplace_back(HGCalParameters::k_ScaleToDDD * php.waferSize_ / php.nCellsCoarse_);
375 #ifdef EDM_ML_DEBUG
376  edm::LogVerbatim("HGCalGeom") << "WaferMode " << mode << ":" << HGCalGeometryMode::Polyhedra << ":"
377  << HGCalGeometryMode::ExtrudedPolygon << " # of cells|size for fine/coarse "
378  << php.nCellsFine_ << ":" << php.cellSize_[0] << ":" << php.nCellsCoarse_ << ":"
379  << php.cellSize_[1] << " wafer Params " << php.waferSize_ << ":" << php.waferR_
380  << ":" << php.waferThick_ << ":" << php.sensorSeparation_ << ":"
381  << php.sensorSizeOffset_ << ":" << php.guardRingOffset_ << ":" << php.mouseBite_
382  << ":" << php.useOffset_ << ":" << php.waferR_;
383 #endif
384  for (int k = 0; k < 2; ++k)
385  getCellPosition(php, k);
386  }
387  if (php.mode_ == HGCalGeometryMode::Hexagon) {
388  // Load the SpecPars
389  php.firstLayer_ = 1;
390  geom->loadSpecParsHexagon(fv, php, name, namew, namec, name2);
391  // Load the Geometry parameters
392  geom->loadGeometryHexagon(cpv, php, name, namew, namec, mode);
393  // Load cell parameters
394  geom->loadCellParsHexagon(vmap, php);
395  // Set complete fill mode
396  php.defineFull_ = false;
397  } else if (php.mode_ == HGCalGeometryMode::HexagonFull) {
398  // Load the SpecPars
399  php.firstLayer_ = 1;
400  geom->loadSpecParsHexagon(fv, php, name, namew, namec, name2);
401  // Load the Geometry parameters
402  geom->loadGeometryHexagon(cpv, php, name, namew, namec, mode);
403  // Modify some constants
404  geom->loadWaferHexagon(php);
405  // Load cell parameters
406  geom->loadCellParsHexagon(vmap, php);
407  // Set complete fill mode
408  php.defineFull_ = true;
409  } else if (php.mode_ == HGCalGeometryMode::Hexagon8) {
410  // Load the SpecPars
411  geom->loadSpecParsHexagon8(fv, vmap, php, name);
412  // Load Geometry parameters
413  geom->loadGeometryHexagon8(cpv, php, name, 1);
414  // Set complete fill mode
415  php.defineFull_ = false;
416  // Load wafer positions
417  geom->loadWaferHexagon8(php);
419  // Load the SpecPars
420  geom->loadSpecParsHexagon8(fv, vmap, php, name);
421  // Load Geometry parameters
422  geom->loadGeometryHexagon8(cpv, php, name, 1);
423  // Set complete fill mode
424  php.defineFull_ = true;
425  // Load wafer positions
426  geom->loadWaferHexagon8(php);
429  // Load the SpecPars
430  geom->loadSpecParsHexagon8(fv, vmap, php, name);
431  // Load Geometry parameters
432  geom->loadGeometryHexagonModule(cpv, php, name, namec, 1);
433  // Set complete fill mode
434  php.defineFull_ = true;
435  // Load wafer positions
436  geom->loadWaferHexagon8(php);
441  // Load maximum eta & top level
442  php.levelT_ = dbl_to_int(fv.get<std::vector<double> >(name, "LevelTop"));
443  tempD = fv.get<std::vector<double> >(name, "LevelZSide");
444  php.levelZSide_ = static_cast<int>(tempD[0]);
445  tempD = fv.get<std::vector<double> >(name, "FirstLayer");
446  php.firstLayer_ = static_cast<int>(tempD[0]);
447  tempD = fv.get<std::vector<double> >(name, "FirstMixedLayer");
448  php.firstMixedLayer_ = static_cast<int>(tempD[0]);
449  tempD = fv.get<std::vector<double> >(name, "DetectorType");
450  php.detectorType_ = static_cast<int>(tempD[0]);
451  tempD = fv.get<std::vector<double> >(name, "WaferThickness");
453  tempD = fv.get<std::vector<double> >(name, "MinimumTileSize");
455  php.nCellsFine_ = php.nCellsCoarse_ = 0;
456  php.waferSize_ = php.waferR_ = 0;
457  php.sensorSeparation_ = php.mouseBite_ = 0;
458  php.sensorSizeOffset_ = php.guardRingOffset_ = php.useOffset_ = 0;
459  tempD = fv.get<std::vector<double> >(name, "WaferMaskMode");
460  php.waferMaskMode_ = static_cast<int>(tempD[0]);
461  tempD = fv.get<std::vector<double> >(name, "WaferZside");
462  php.waferZSide_ = static_cast<int>(tempD[0]);
465  tempD = fv.get<std::vector<double> >(name, "UseSimWt");
466  php.useSimWt_ = tempD[0];
467  }
470  tempD = fv.get<std::vector<double> >(name, "Cassettes");
471  php.cassettes_ = static_cast<int>(tempD[0]);
472  }
473 #ifdef EDM_ML_DEBUG
474  edm::LogVerbatim("HGCalGeom") << "Top levels " << php.levelT_[0] << ":" << php.levelT_[1] << " first layers "
475  << php.firstLayer_ << ":" << php.firstMixedLayer_ << " Det Type "
476  << php.detectorType_ << " thickenss " << php.waferThick_ << " min tile size "
477  << php.minTileSize_ << " Tile Mask Mode " << php.waferMaskMode_ << " ZSide "
478  << php.waferZSide_ << " Cassettes " << php.cassettes_ << " UseSimWt "
479  << php.useSimWt_;
480 #endif
481  // Load the SpecPars
482  geom->loadSpecParsTrapezoid(fv, vmap, php, name);
483  // Load Geometry parameters
484  geom->loadGeometryHexagon8(cpv, php, name, php.firstLayer_);
485  // Load cell positions
486  geom->loadCellTrapezoid(php);
487  } else {
488  edm::LogError("HGCalGeom") << "Unknown Geometry type " << php.mode_ << " for HGCal " << name << ":" << namew
489  << ":" << namec;
490  throw cms::Exception("DDException")
491  << "Unknown Geometry type " << php.mode_ << " for HGCal " << name << ":" << namew << ":" << namec;
492  }
493  } else {
494  edm::LogError("HGCalGeom") << " Attribute Volume:" << name << " not found but needed.";
495  throw cms::Exception("DDException") << "Attribute Volume:" << name << " not found but needed.";
496  }
497 #ifdef EDM_ML_DEBUG
498  edm::LogVerbatim("HGCalGeom") << "Return from HGCalParametersFromDD::build"
499  << " with flag " << ok;
500 #endif
501  return ok;
502 }
503 
505  if (type == 1) {
506  php.cellCoarseX_.clear();
507  php.cellCoarseY_.clear();
508  } else {
509  php.cellFineX_.clear();
510  php.cellFineY_.clear();
511  }
512  HGCalParameters::wafer_map cellIndex;
513 #ifdef EDM_ML_DEBUG
514  std::vector<int> indtypes;
515 #endif
516  int N = (type == 1) ? php.nCellsCoarse_ : php.nCellsFine_;
517  assert(N != 0);
518  double R = php.waferSize_ / (3 * N);
519  double r = 0.5 * R * sqrt(3.0);
520  int n2 = N / 2;
521  int ipos(0);
522  for (int u = 0; u < 2 * N; ++u) {
523  for (int v = 0; v < 2 * N; ++v) {
524  if (((v - u) < N) && (u - v) <= N) {
525  double yp = (u - 0.5 * v - n2) * 2 * r;
526  double xp = (1.5 * (v - N) + 1.0) * R;
527  int id = v * 100 + u;
528 #ifdef EDM_ML_DEBUG
529  indtypes.emplace_back(id);
530 #endif
531  if (type == 1) {
532  php.cellCoarseX_.emplace_back(xp);
533  php.cellCoarseY_.emplace_back(yp);
534  } else {
535  php.cellFineX_.emplace_back(xp);
536  php.cellFineY_.emplace_back(yp);
537  }
538  cellIndex[id] = ipos;
539  ++ipos;
540  }
541  }
542  }
543  if (type == 1)
544  php.cellCoarseIndex_ = cellIndex;
545  else
546  php.cellFineIndex_ = cellIndex;
547 
548 #ifdef EDM_ML_DEBUG
549  if (type == 1) {
550  edm::LogVerbatim("HGCalGeom") << "CellPosition for type " << type << " for " << php.cellCoarseX_.size()
551  << " cells";
552  for (unsigned int k = 0; k < php.cellCoarseX_.size(); ++k) {
553  int id = indtypes[k];
554  edm::LogVerbatim("HGCalGeom") << "[" << k << "] ID " << id << ":" << php.cellCoarseIndex_[id] << " X "
555  << php.cellCoarseX_[k] << " Y " << php.cellCoarseY_[k];
556  }
557  } else {
558  edm::LogVerbatim("HGCalGeom") << "CellPosition for type " << type << " for " << php.cellFineX_.size() << " cells";
559  for (unsigned int k = 0; k < php.cellFineX_.size(); ++k) {
560  int id = indtypes[k];
561  edm::LogVerbatim("HGCalGeom") << "[" << k << "] ID " << id << ":" << php.cellFineIndex_[k] << " X "
562  << php.cellFineX_[k] << " Y " << php.cellFineY_[k];
563  }
564  }
565 #endif
566 }
567 
569  DDValue val(s);
570  if (DDfetch(&sv, val)) {
571  const std::vector<double>& fvec = val.doubles();
572  if (fvec.empty()) {
573  throw cms::Exception("HGCalGeom") << "getDDDValue::Failed to get " << s << " tag.";
574  }
575  return fvec[0];
576  } else {
577  throw cms::Exception("HGCalGeom") << "getDDDValue::Failed to fetch " << s << " tag";
578  }
579 }
580 
581 std::vector<double> HGCalParametersFromDD::getDDDArray(const char* s, const DDsvalues_type& sv) {
582  DDValue val(s);
583  if (DDfetch(&sv, val)) {
584  const std::vector<double>& fvec = val.doubles();
585  if (fvec.empty()) {
586  throw cms::Exception("HGCalGeom") << "getDDDArray::Failed to get " << s << " tag.";
587  }
588  return fvec;
589  } else {
590  throw cms::Exception("HGCalGeom") << "getDDDArray:Failed to fetch " << s << " tag";
591  }
592 }
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)
assert(be >=bs)
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:23
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)
static constexpr int scintillatorFineCell