CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 DebugLog
16 
17 namespace {
18  int getGeometryMode(const char* s, const DDsvalues_type & sv) {
19  DDValue val(s);
20  if (DDfetch(&sv, val)) {
21  const std::vector<std::string> & fvec = val.strings();
22  if (fvec.size() == 0) {
23  throw cms::Exception("HGCalGeom") << "Failed to get " << s << " tag.";
24  }
25 
26  int result(-1);
29  result = (int)(mode);
30  return result;
31  } else {
32  throw cms::Exception("HGCalGeom") << "Failed to get "<< s << " tag.";
33  }
34  }
35 }
36 
38  HGCalParameters& php,
39  const std::string& name,
40  const std::string& namew,
41  const std::string& namec) {
42 
43 #ifdef DebugLog
44  std::cout << "HGCalParametersFromDD::build called with names " << name << ":"
45  << namew << ":" << namec << std::endl;
46 #endif
47 
48  //Special parameters at simulation level
49  std::string attribute = "Volume";
51  DDValue val(attribute, value, 0.0);
53  filter.setCriteria(val, DDCompOp::equals);
54  DDFilteredView fv(*cpv);
55  fv.addFilter(filter);
56  bool ok = fv.firstChild();
57 
58  if (ok) {
60  php.mode_ = getGeometryMode("GeometryMode", sv);
62  if (php.mode_ == static_cast<int> (HGCalGeometryMode::Square)) {
63  //Load the SpecPars
64  geom->loadSpecParsSquare(fv, php);
65  //Load the Geometry parameters
66  geom->loadGeometrySquare(fv, php, name);
67  } else if (php.mode_ == static_cast<int> (HGCalGeometryMode::Hexagon)) {
68  //Load the SpecPars
69  geom->loadSpecParsHexagon(fv, php, cpv, namew, namec);
70  //Load the Geometry parameters
71  geom->loadGeometryHexagon(fv, php, name, cpv, namew, namec);
72  } else {
73  edm::LogError("HGCalGeom") << "Unknown Geometry type " << php.mode_
74  << " for HGCal " << name << ":" << namew
75  << ":" << namec;
76  throw cms::Exception("DDException")
77  << "Unknown Geometry type " << php.mode_ << " for HGCal " << name
78  << ":" << namew << ":" << namec;
79  }
80  } else {
81  edm::LogError("HGCalGeom") << " Attribute " << val
82  << " not found but needed.";
83  throw cms::Exception("DDException") << "Attribute " << val
84  << " not found but needed.";
85  }
86 
87  edm::LogInfo("HGCalGeom") << "Return from HGCalParametersFromDD::build with "
88  << ok;
89  return ok;
90 }
T parseString(const std::string &value)
void addFilter(const DDFilter &, DDLogOp op=DDLogOp::AND)
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:77
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:80
tuple result
Definition: mps_fire.py:84
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:19
HGCalGeometryMode
void loadSpecParsSquare(const DDFilteredView &, HGCalParameters &)
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 &)
tuple cout
Definition: gather_cfg.py:145
void loadGeometrySquare(const DDFilteredView &, HGCalParameters &, const std::string &)
void setCriteria(const DDValue &nameVal, DDCompOp, DDLogOp l=DDLogOp::AND, bool asString=true, bool merged=true)
Definition: DDFilter.cc:245
The DDGenericFilter is a runtime-parametrized Filter looking on DDSpecifcs.
Definition: DDFilter.h:32