CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Static Private Attributes
HGCalTBParametersFromDD Class Reference

#include <HGCalTBParametersFromDD.h>

Public Member Functions

bool build (const DDCompactView *cpv, HGCalTBParameters &php, const std::string &name, const std::string &namew, const std::string &namec, const std::string &namet)
 
bool build (const cms::DDCompactView *cpv, HGCalTBParameters &php, const std::string &name, const std::string &namew, const std::string &namec, const std::string &namet, const std::string &name2)
 
 HGCalTBParametersFromDD ()=default
 
virtual ~HGCalTBParametersFromDD ()=default
 

Private Member Functions

std::vector< double > getDDDArray (const char *s, const DDsvalues_type &sv)
 
double getDDDValue (const char *s, const DDsvalues_type &sv)
 

Static Private Attributes

static constexpr double tan30deg_ = 0.5773502693
 

Detailed Description

Definition at line 12 of file HGCalTBParametersFromDD.h.

Constructor & Destructor Documentation

◆ HGCalTBParametersFromDD()

HGCalTBParametersFromDD::HGCalTBParametersFromDD ( )
default

◆ ~HGCalTBParametersFromDD()

virtual HGCalTBParametersFromDD::~HGCalTBParametersFromDD ( )
virtualdefault

Member Function Documentation

◆ build() [1/2]

bool HGCalTBParametersFromDD::build ( const DDCompactView cpv,
HGCalTBParameters php,
const std::string &  name,
const std::string &  namew,
const std::string &  namec,
const std::string &  namet 
)

Definition at line 14 of file HGCalTBParametersFromDD.cc.

References HGCalTBParameters::defineFull_, HGCalTBParameters::detectorType_, Exception, HGCalGeometryMode::ExtrudedPolygon, ALCARECOTkAlBeamHalo_cff::filter, DDFilteredView::firstChild(), HGCalTBParameters::firstLayer_, relativeConstraints::geom, HGCalGeometryMode::getGeometryMode(), HGCalGeometryMode::getGeometryWaferMode(), HGCalGeometryMode::Hexagon, HGCalGeometryMode::HexagonFull, HGCalTBParameters::levelZSide_, DDFilteredView::mergedSpecifics(), ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, HGCalTBParameters::mode_, Skims_PA_cff::name, convertSQLiteXML::ok, HGCalGeometryMode::Polyhedra, AlCaHLTBitMon_QueryRunRegistry::string, pfDeepBoostedJetPreprocessParams_cfi::sv, HGCalTBParameters::useSimWt_, and heppy_batch::val.

19  {
20 #ifdef EDM_ML_DEBUG
21  edm::LogVerbatim("HGCalGeom") << "HGCalTBParametersFromDD (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) {
37  DDsvalues_type sv(fv.mergedSpecifics());
38  php.mode_ = HGCalGeometryMode::getGeometryMode("GeometryMode", sv);
39 #ifdef EDM_ML_DEBUG
40  edm::LogVerbatim("HGCalGeom") << "Volume " << name << " GeometryMode " << php.mode_ << ":"
42 #endif
43  php.levelZSide_ = 3; // Default level for ZSide
44  php.detectorType_ = 0; // These two parameters are
45  php.useSimWt_ = 1; // energy weighting for SimHits
46  std::unique_ptr<HGCalTBGeomParameters> geom = std::make_unique<HGCalTBGeomParameters>();
48  attribute = "OnlyForHGCalNumbering";
49  value = namet;
50  DDValue val2(attribute, value, 0.0);
51  DDSpecificsMatchesValueFilter filter2{val2};
52  DDFilteredView fv2(*cpv, filter2);
53  bool ok2 = fv2.firstChild();
54  if (ok2) {
55  DDsvalues_type sv2(fv2.mergedSpecifics());
57 #ifdef EDM_ML_DEBUG
58  edm::LogVerbatim("HGCalGeom") << "WaferMode " << mode << ":" << HGCalGeometryMode::Polyhedra << ":"
60 #endif
61  }
62  }
63  php.firstLayer_ = 1;
64  if (php.mode_ == HGCalGeometryMode::Hexagon) {
65  // Load the SpecPars
66  geom->loadSpecParsHexagon(fv, php, cpv, namew, namec);
67  // Load the Geometry parameters
68  geom->loadGeometryHexagon(fv, php, name, cpv, namew, namec, mode);
69  // Load cell parameters
70  geom->loadCellParsHexagon(cpv, php);
71  // Set complete fill mode
72  php.defineFull_ = false;
73  } else if (php.mode_ == HGCalGeometryMode::HexagonFull) {
74  // Load the SpecPars
75  geom->loadSpecParsHexagon(fv, php, cpv, namew, namec);
76  // Load the Geometry parameters
77  geom->loadGeometryHexagon(fv, php, name, cpv, namew, namec, mode);
78  // Modify some constants
79  geom->loadWaferHexagon(php);
80  // Load cell parameters
81  geom->loadCellParsHexagon(cpv, php);
82  // Set complete fill mode
83  php.defineFull_ = true;
84  } else {
85  edm::LogError("HGCalGeom") << "Unknown Geometry type " << php.mode_ << " for HGCal " << name << ":" << namew
86  << ":" << namec;
87  throw cms::Exception("DDException")
88  << "Unknown Geometry type " << php.mode_ << " for HGCal " << name << ":" << namew << ":" << namec;
89  }
90  } else {
91  edm::LogError("HGCalGeom") << " Attribute " << val << " not found but needed.";
92  throw cms::Exception("DDException") << "Attribute " << val << " not found but needed.";
93  }
94 #ifdef EDM_ML_DEBUG
95  edm::LogVerbatim("HGCalGeom") << "Return from HGCalTBParametersFromDD::build"
96  << " with flag " << ok;
97 #endif
98  return ok;
99 }
Log< level::Info, true > LogVerbatim
Log< level::Error, false > LogError
WaferMode getGeometryWaferMode(const char *s, const DDsvalues_type &sv)
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
Definition: DDsvalues.h:12
GeometryMode getGeometryMode(const char *s, const DDsvalues_type &sv)
Definition: value.py:1
HGCalGeometryMode::GeometryMode mode_

◆ build() [2/2]

bool HGCalTBParametersFromDD::build ( const cms::DDCompactView cpv,
HGCalTBParameters php,
const std::string &  name,
const std::string &  namew,
const std::string &  namec,
const std::string &  namet,
const std::string &  name2 
)

Definition at line 101 of file HGCalTBParametersFromDD.cc.

References HGCalTBParameters::defineFull_, cms::DDCompactView::detector(), HGCalTBParameters::detectorType_, Exception, HGCalGeometryMode::ExtrudedPolygon, ALCARECOTkAlBeamHalo_cff::filter, cms::DDFilteredView::firstChild(), HGCalTBParameters::firstLayer_, relativeConstraints::geom, cms::DDFilteredView::get(), HGCalGeometryMode::getGeometryMode(), HGCalGeometryMode::getGeometryWaferMode(), HGCalGeometryMode::Hexagon, HGCalGeometryMode::HexagonFull, HGCalTBParameters::levelZSide_, ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, HGCalTBParameters::mode_, Skims_PA_cff::name, hfnoseParametersInitialization_cfi::name2, convertSQLiteXML::ok, HGCalGeometryMode::Polyhedra, AlCaHLTBitMon_QueryRunRegistry::string, pfDeepBoostedJetPreprocessParams_cfi::sv, HGCalTBParameters::useSimWt_, and cms::DDDetector::vectors().

107  {
108 #ifdef EDM_ML_DEBUG
109  edm::LogVerbatim("HGCalGeom") << "HGCalTBParametersFromDD (DD4hep)::build called with "
110  << "names " << name << ":" << namew << ":" << namec << ":" << namet << ":" << name2;
111 #endif
112  cms::DDVectorsMap vmap = cpv->detector()->vectors();
113  const cms::DDFilter filter("Volume", name);
114  cms::DDFilteredView fv((*cpv), filter);
115  std::vector<std::string> tempS;
116  std::vector<double> tempD;
117  bool ok = fv.firstChild();
118  tempS = fv.get<std::vector<std::string> >(name2, "GeometryMode");
119  if (tempS.empty()) {
120  tempS = fv.get<std::vector<std::string> >(name, "GeometryMode");
121  }
122  std::string sv = (!tempS.empty()) ? tempS[0] : "HGCalGeometryMode::Hexagon8Full";
124 #ifdef EDM_ML_DEBUG
125  edm::LogVerbatim("HGCalGeom") << "Volume " << name << " GeometryMode ";
126 #endif
127 
128  if (ok) {
130 #ifdef EDM_ML_DEBUG
131  edm::LogVerbatim("HGCalGeom") << "Volume " << name << " GeometryMode " << php.mode_ << ":"
133 #endif
134  php.levelZSide_ = 3; // Default level for ZSide
135  php.detectorType_ = 0; // These two parameters are
136  php.useSimWt_ = 1; // energy weighting for SimHits
137  std::unique_ptr<HGCalTBGeomParameters> geom = std::make_unique<HGCalTBGeomParameters>();
139  tempS = fv.get<std::vector<std::string> >(namet, "WaferMode");
140  std::string sv2 = (!tempS.empty()) ? tempS[0] : "HGCalGeometryMode::Polyhedra";
142 #ifdef EDM_ML_DEBUG
143  edm::LogVerbatim("HGCalGeom") << "WaferMode " << mode << ":" << HGCalGeometryMode::Polyhedra << ":"
145 #endif
146  }
147  if (php.mode_ == HGCalGeometryMode::Hexagon) {
148  // Load the SpecPars
149  php.firstLayer_ = 1;
150  geom->loadSpecParsHexagon(fv, php, name, namew, namec, name2);
151  // Load the Geometry parameters
152  geom->loadGeometryHexagon(cpv, php, name, namew, namec, mode);
153  // Load cell parameters
154  geom->loadCellParsHexagon(vmap, php);
155  // Set complete fill mode
156  php.defineFull_ = false;
157  } else if (php.mode_ == HGCalGeometryMode::HexagonFull) {
158  // Load the SpecPars
159  php.firstLayer_ = 1;
160  geom->loadSpecParsHexagon(fv, php, name, namew, namec, name2);
161  // Load the Geometry parameters
162  geom->loadGeometryHexagon(cpv, php, name, namew, namec, mode);
163  // Modify some constants
164  geom->loadWaferHexagon(php);
165  // Load cell parameters
166  geom->loadCellParsHexagon(vmap, php);
167  // Set complete fill mode
168  php.defineFull_ = true;
169  }
170  } else {
171  edm::LogError("HGCalGeom") << " Attribute Volume:" << name << " not found but needed.";
172  throw cms::Exception("DDException") << "Attribute Volume:" << name << " not found but needed.";
173  }
174 #ifdef EDM_ML_DEBUG
175  edm::LogVerbatim("HGCalGeom") << "Return from HGCalTBParametersFromDD::build"
176  << " with flag " << ok;
177 #endif
178  return ok;
179 }
Log< level::Info, true > LogVerbatim
const cms::DDDetector * detector() const
Definition: DDCompactView.h:34
Log< level::Error, false > LogError
std::unordered_map< std::string, std::vector< double > > DDVectorsMap
Definition: DDNamespace.h:20
WaferMode getGeometryWaferMode(const char *s, const DDsvalues_type &sv)
GeometryMode getGeometryMode(const char *s, const DDsvalues_type &sv)
HGCalGeometryMode::GeometryMode mode_
cms::DDVectorsMap const & vectors() const
Definition: DDDetector.h:17

◆ getDDDArray()

std::vector< double > HGCalTBParametersFromDD::getDDDArray ( const char *  s,
const DDsvalues_type sv 
)
private

Definition at line 194 of file HGCalTBParametersFromDD.cc.

References DDfetch(), Exception, alignCSCRings::s, pfDeepBoostedJetPreprocessParams_cfi::sv, and heppy_batch::val.

194  {
195  DDValue val(s);
196  if (DDfetch(&sv, val)) {
197  const std::vector<double>& fvec = val.doubles();
198  if (fvec.empty()) {
199  throw cms::Exception("HGCalGeom") << "getDDDArray::Failed to get " << s << " tag.";
200  }
201  return fvec;
202  } else {
203  throw cms::Exception("HGCalGeom") << "getDDDArray:Failed to fetch " << s << " tag";
204  }
205 }
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:79

◆ getDDDValue()

double HGCalTBParametersFromDD::getDDDValue ( const char *  s,
const DDsvalues_type sv 
)
private

Definition at line 181 of file HGCalTBParametersFromDD.cc.

References DDfetch(), Exception, alignCSCRings::s, pfDeepBoostedJetPreprocessParams_cfi::sv, and heppy_batch::val.

181  {
182  DDValue val(s);
183  if (DDfetch(&sv, val)) {
184  const std::vector<double>& fvec = val.doubles();
185  if (fvec.empty()) {
186  throw cms::Exception("HGCalGeom") << "getDDDValue::Failed to get " << s << " tag.";
187  }
188  return fvec[0];
189  } else {
190  throw cms::Exception("HGCalGeom") << "getDDDValue::Failed to fetch " << s << " tag";
191  }
192 }
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:79

Member Data Documentation

◆ tan30deg_

constexpr double HGCalTBParametersFromDD::tan30deg_ = 0.5773502693
staticprivate

Definition at line 34 of file HGCalTBParametersFromDD.h.