CMS 3D CMS Logo

HGCalParametersFromDD.cc
Go to the documentation of this file.
9 
11 #include "CLHEP/Units/GlobalSystemOfUnits.h"
12 #include <iostream>
13 #include <iomanip>
14 
15 //#define EDM_ML_DEBUG
16 
17 namespace {
18  HGCalGeometryMode::GeometryMode getGeometryMode(const char* s,
19  const DDsvalues_type & sv) {
20  DDValue val(s);
21  if (DDfetch(&sv, val)) {
22  const std::vector<std::string> & fvec = val.strings();
23  if (fvec.empty()) {
24  throw cms::Exception("HGCalGeom") << "Failed to get " << s << " tag.";
25  }
26 
29  return result;
30  } else {
31  throw cms::Exception("HGCalGeom") << "Failed to get "<< s << " tag";
32  }
33  }
34  HGCalGeometryMode::WaferMode getGeometryWaferMode(const char* s,
35  const DDsvalues_type & sv){
36  DDValue val(s);
37  if (DDfetch(&sv, val)) {
38  const std::vector<std::string> & fvec = val.strings();
39  if (fvec.empty()) {
40  throw cms::Exception("HGCalGeom") << "Failed to get " << s << " tag.";
41  }
42 
45  return result;
46  } else {
47  throw cms::Exception("HGCalGeom") << "Failed to get "<< s << " tag";
48  }
49  }
50 }
51 
53  HGCalParameters& php,
54  const std::string& name,
55  const std::string& namew,
56  const std::string& namec) {
57 
58 #ifdef EDM_ML_DEBUG
59  std::cout << "HGCalParametersFromDD::build called with names " << name << ":"
60  << namew << ":" << namec << std::endl;
61 #endif
62 
63  //Special parameters at simulation level
64  std::string attribute = "Volume";
66  DDValue val(attribute, value, 0.0);
68  DDFilteredView fv(*cpv,filter);
69  bool ok = fv.firstChild();
71 
72  if (ok) {
74  php.mode_ = getGeometryMode("GeometryMode", sv);
75 #ifdef EDM_ML_DEBUG
76  std::cout << "GeometryMode " << php.mode_
77  << ":" << HGCalGeometryMode::Hexagon << ":"
78  << HGCalGeometryMode::HexagonFull << std::endl;
79 #endif
81  if ((php.mode_ == HGCalGeometryMode::Hexagon) ||
83  attribute = "OnlyForHGCalNumbering";
84  value = "HGCal";
85  DDValue val2(attribute, value, 0.0);
86  DDSpecificsMatchesValueFilter filter2{val2};
87  DDFilteredView fv2(*cpv,filter2);
88  bool ok2 = fv2.firstChild();
89  if (ok2) {
91  mode = getGeometryWaferMode("WaferMode", sv2);
92 #ifdef EDM_ML_DEBUG
93  std::cout << "WaferMode " << mode << ":" << HGCalGeometryMode::Polyhedra
94  << ":" << HGCalGeometryMode::ExtrudedPolygon << std::endl;
95 #endif
96  }
97  }
98  if (php.mode_ == HGCalGeometryMode::Hexagon) {
99  //Load the SpecPars
100  geom->loadSpecParsHexagon(fv, php, cpv, namew, namec);
101  //Load the Geometry parameters
102  geom->loadGeometryHexagon(fv, php, name, cpv, namew, namec, mode);
103  //Load cell parameters
104  geom->loadCellParsHexagon(cpv, php);
105  } else if (php.mode_ == HGCalGeometryMode::HexagonFull) {
106  //Load the SpecPars
107  geom->loadSpecParsHexagon(fv, php, cpv, namew, namec);
108  //Load the Geometry parameters
109  geom->loadGeometryHexagon(fv, php, name, cpv, namew, namec, mode);
110  //Modify some constants
111  geom->loadWaferHexagon(php);
112  //Load cell parameters
113  geom->loadCellParsHexagon(cpv, php);
114  } else {
115  edm::LogError("HGCalGeom") << "Unknown Geometry type " << php.mode_
116  << " for HGCal " << name << ":" << namew
117  << ":" << namec;
118  throw cms::Exception("DDException")
119  << "Unknown Geometry type " << php.mode_ << " for HGCal " << name
120  << ":" << namew << ":" << namec;
121  }
122  } else {
123  edm::LogError("HGCalGeom") << " Attribute " << val
124  << " not found but needed.";
125  throw cms::Exception("DDException") << "Attribute " << val
126  << " not found but needed.";
127  }
128 
129  edm::LogInfo("HGCalGeom") << "Return from HGCalParametersFromDD::build with "
130  << ok;
131  return ok;
132 }
T parseString(const std::string &value)
void loadSpecParsHexagon(const DDFilteredView &, HGCalParameters &, const DDCompactView *, const std::string &, const std::string &)
bool build(const DDCompactView *, HGCalParameters &, const std::string &, const std::string &, const std::string &)
type of data representation of DDCompactView
Definition: DDCompactView.h:90
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:81
HGCalGeometryMode::GeometryMode mode_
void loadCellParsHexagon(const DDCompactView *cpv, HGCalParameters &php)
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
std::maps an index to a DDValue. The index corresponds to the index assigned to the name of the std::...
Definition: DDsvalues.h:20
Definition: value.py:1
void loadWaferHexagon(HGCalParameters &php)
DDsvalues_type mergedSpecifics() const
bool firstChild()
set the current node to the first child ...
void loadGeometryHexagon(const DDFilteredView &, HGCalParameters &, const std::string &, const DDCompactView *, const std::string &, const std::string &, HGCalGeometryMode::WaferMode)