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_ <<":" << HGCalGeometryMode::Square
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::Square) {
99  //Load the SpecPars
100  geom->loadSpecParsSquare(fv, php);
101  //Load the Geometry parameters
102  geom->loadGeometrySquare(fv, php, name);
103  } else if (php.mode_ == HGCalGeometryMode::Hexagon) {
104  //Load the SpecPars
105  geom->loadSpecParsHexagon(fv, php, cpv, namew, namec);
106  //Load the Geometry parameters
107  geom->loadGeometryHexagon(fv, php, name, cpv, namew, namec, mode);
108  //Load cell parameters
109  geom->loadCellParsHexagon(cpv, php);
110  } else if (php.mode_ == HGCalGeometryMode::HexagonFull) {
111  //Load the SpecPars
112  geom->loadSpecParsHexagon(fv, php, cpv, namew, namec);
113  //Load the Geometry parameters
114  geom->loadGeometryHexagon(fv, php, name, cpv, namew, namec, mode);
115  //Modify some constants
116  geom->loadWaferHexagon(php);
117  //Load cell parameters
118  geom->loadCellParsHexagon(cpv, php);
119  } else {
120  edm::LogError("HGCalGeom") << "Unknown Geometry type " << php.mode_
121  << " for HGCal " << name << ":" << namew
122  << ":" << namec;
123  throw cms::Exception("DDException")
124  << "Unknown Geometry type " << php.mode_ << " for HGCal " << name
125  << ":" << namew << ":" << namec;
126  }
127  } else {
128  edm::LogError("HGCalGeom") << " Attribute " << val
129  << " not found but needed.";
130  throw cms::Exception("DDException") << "Attribute " << val
131  << " not found but needed.";
132  }
133 
134  edm::LogInfo("HGCalGeom") << "Return from HGCalParametersFromDD::build with "
135  << ok;
136  return ok;
137 }
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)
void loadSpecParsSquare(const DDFilteredView &, HGCalParameters &)
DDsvalues_type mergedSpecifics() const
bool firstChild()
set the current node to the first child ...
void loadGeometrySquare(const DDFilteredView &, HGCalParameters &, const std::string &)
void loadGeometryHexagon(const DDFilteredView &, HGCalParameters &, const std::string &, const DDCompactView *, const std::string &, const std::string &, HGCalGeometryMode::WaferMode)