CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions
HGCalParametersFromDD Class Reference

#include <HGCalParametersFromDD.h>

Public Member Functions

bool build (const DDCompactView *, HGCalParameters &, const std::string &, const std::string &, const std::string &, const std::string &)
 
 HGCalParametersFromDD ()
 
virtual ~HGCalParametersFromDD ()
 

Private Member Functions

void getCellPosition (HGCalParameters &php, int type)
 
std::vector< double > getDDDArray (const char *s, const DDsvalues_type &sv)
 
double getDDDValue (const char *s, const DDsvalues_type &sv)
 

Detailed Description

Definition at line 11 of file HGCalParametersFromDD.h.

Constructor & Destructor Documentation

HGCalParametersFromDD::HGCalParametersFromDD ( )
inline

Definition at line 13 of file HGCalParametersFromDD.h.

13 {}
virtual HGCalParametersFromDD::~HGCalParametersFromDD ( )
inlinevirtual

Member Function Documentation

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

Definition at line 50 of file HGCalParametersFromDD.cc.

References HGCalParameters::cellSize_, funct::cos(), dbl_to_int(), HGCalParameters::defineFull_, HGCalParameters::detectorType_, Exception, HGCalGeometryMode::ExtrudedPolygon, ALCARECOTkAlBeamHalo_cff::filter, DDFilteredView::firstChild(), HGCalParameters::firstLayer_, HGCalParameters::firstMixedLayer_, relativeConstraints::geom, HGCalGeometryMode::Hexagon, HGCalGeometryMode::Hexagon8, HGCalGeometryMode::Hexagon8Full, HGCalGeometryMode::HexagonFull, createfilelist::int, gen::k, HGCalParameters::k_ScaleFromDDD, HGCalParameters::k_ScaleToDDD, HGCalParameters::levelT_, HGCalParameters::levelZSide_, HGCalGeomParameters::loadCellParsHexagon(), HGCalGeomParameters::loadCellTrapezoid(), HGCalGeomParameters::loadGeometryHexagon(), HGCalGeomParameters::loadGeometryHexagon8(), HGCalGeomParameters::loadSpecParsHexagon(), HGCalGeomParameters::loadSpecParsHexagon8(), HGCalGeomParameters::loadSpecParsTrapezoid(), HGCalGeomParameters::loadWaferHexagon(), HGCalGeomParameters::loadWaferHexagon8(), DDFilteredView::mergedSpecifics(), HGCalParameters::minTileSize_, ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, HGCalParameters::mode_, HGCalParameters::mouseBite_, dataset::name, HGCalParameters::nCellsCoarse_, HGCalParameters::nCellsFine_, convertSQLiteXML::ok, HGCalGeometryMode::Polyhedra, HGCalParameters::sensorSeparation_, AlCaHLTBitMon_QueryRunRegistry::string, pfDeepBoostedJetPreprocessParams_cfi::sv, HGCalGeometryMode::Trapezoid, heppy_batch::val, HGCalParameters::waferR_, HGCalParameters::waferSize_, and HGCalParameters::waferThick_.

Referenced by PHGCalParametersDBBuilder::beginRun(), HGCalParametersESModule::produce(), and ~HGCalParametersFromDD().

54  {
55 #ifdef EDM_ML_DEBUG
56  edm::LogVerbatim("HGCalGeom")
57  << "HGCalParametersFromDD::build called with "
58  << "names " << name << ":" << namew << ":" << namec << ":" << namet;
59 #endif
60 
61  // Special parameters at simulation level
62  std::string attribute = "Volume";
64  DDValue val(attribute, value, 0.0);
66  DDFilteredView fv(*cpv, filter);
67  bool ok = fv.firstChild();
69 
70  if (ok) {
71  DDsvalues_type sv(fv.mergedSpecifics());
72  php.mode_ = getGeometryMode("GeometryMode", sv);
73 #ifdef EDM_ML_DEBUG
74  edm::LogVerbatim("HGCalGeom")
75  << "GeometryMode " << php.mode_ << ":" << HGCalGeometryMode::Hexagon
76  << ":" << HGCalGeometryMode::HexagonFull << ":"
77  << ":" << HGCalGeometryMode::Hexagon8 << ":"
80 #endif
81  php.levelZSide_ = 3; // Default level for ZSide
82  php.detectorType_ = 0; // These two parameters are
83  php.firstMixedLayer_ = -1; // defined for post TDR geometry
85  if ((php.mode_ == HGCalGeometryMode::Hexagon) ||
87  attribute = "OnlyForHGCalNumbering";
88  value = namet;
89  DDValue val2(attribute, value, 0.0);
90  DDSpecificsMatchesValueFilter filter2{val2};
91  DDFilteredView fv2(*cpv, filter2);
92  bool ok2 = fv2.firstChild();
93  if (ok2) {
94  DDsvalues_type sv2(fv2.mergedSpecifics());
95  mode = getGeometryWaferMode("WaferMode", sv2);
96 #ifdef EDM_ML_DEBUG
97  edm::LogVerbatim("HGCalGeom")
98  << "WaferMode " << mode << ":" << HGCalGeometryMode::Polyhedra
100 #endif
101  }
102  php.minTileSize_ = 0;
103  }
104  if ((php.mode_ == HGCalGeometryMode::Hexagon8) ||
106  php.levelT_ = dbl_to_int(getDDDArray("LevelTop", sv));
107  php.levelZSide_ = (int)(getDDDValue("LevelZSide", sv));
108  php.nCellsFine_ = php.nCellsCoarse_ = 0;
109  php.firstLayer_ = 1;
110  php.firstMixedLayer_ = (int)(getDDDValue("FirstMixedLayer", sv));
111  php.detectorType_ = (int)(getDDDValue("DetectorType", sv));
112  php.minTileSize_ = 0;
113 #ifdef EDM_ML_DEBUG
114  edm::LogVerbatim("HGCalGeom")
115  << "Top levels " << php.levelT_[0] << ":" << php.levelT_[1]
116  << " ZSide Level " << php.levelZSide_ << " first layers "
117  << php.firstLayer_ << ":" << php.firstMixedLayer_ << " Det Type "
118  << php.detectorType_;
119 #endif
120  attribute = "OnlyForHGCalNumbering";
121  value = namet;
122  DDValue val2(attribute, value, 0.0);
123  DDSpecificsMatchesValueFilter filter2{val2};
124  DDFilteredView fv2(*cpv, filter2);
125  bool ok2 = fv2.firstChild();
126  if (ok2) {
127  DDsvalues_type sv2(fv2.mergedSpecifics());
128  mode = getGeometryWaferMode("WaferMode", sv2);
129  php.nCellsFine_ = (int)(getDDDValue("NumberOfCellsFine", sv2));
130  php.nCellsCoarse_ = (int)(getDDDValue("NumberOfCellsCoarse", sv2));
131  php.waferSize_ =
132  HGCalParameters::k_ScaleFromDDD * getDDDValue("WaferSize", sv2);
134  getDDDValue("WaferThickness", sv2);
136  getDDDValue("SensorSeparation", sv2);
137  php.mouseBite_ =
138  HGCalParameters::k_ScaleFromDDD * getDDDValue("MouseBite", sv2);
140  std::cos(30._deg);
141  php.cellSize_.emplace_back(HGCalParameters::k_ScaleToDDD *
142  php.waferSize_ / php.nCellsFine_);
143  php.cellSize_.emplace_back(HGCalParameters::k_ScaleToDDD *
144  php.waferSize_ / php.nCellsCoarse_);
145 #ifdef EDM_ML_DEBUG
146  edm::LogVerbatim("HGCalGeom")
147  << "WaferMode " << mode << ":" << HGCalGeometryMode::Polyhedra
149  << " # of cells|size for fine/coarse " << php.nCellsFine_ << ":"
150  << php.cellSize_[0] << ":" << php.nCellsCoarse_ << ":"
151  << php.cellSize_[1] << " wafer Params " << php.waferSize_ << ":"
152  << php.waferR_ << ":" << php.waferThick_ << ":"
153  << php.sensorSeparation_ << ":" << php.mouseBite_ << ":"
154  << php.waferR_;
155 #endif
156  for (int k = 0; k < 2; ++k) getCellPosition(php, k);
157  }
158  }
159  if (php.mode_ == HGCalGeometryMode::Hexagon) {
160  // Load the SpecPars
161  php.firstLayer_ = 1;
162  geom->loadSpecParsHexagon(fv, php, cpv, namew, namec);
163  // Load the Geometry parameters
164  geom->loadGeometryHexagon(fv, php, name, cpv, namew, namec, mode);
165  // Load cell parameters
166  geom->loadCellParsHexagon(cpv, php);
167  // Set complete fill mode
168  php.defineFull_ = false;
169  } else if (php.mode_ == HGCalGeometryMode::HexagonFull) {
170  // Load the SpecPars
171  php.firstLayer_ = 1;
172  geom->loadSpecParsHexagon(fv, php, cpv, namew, namec);
173  // Load the Geometry parameters
174  geom->loadGeometryHexagon(fv, php, name, cpv, namew, namec, mode);
175  // Modify some constants
176  geom->loadWaferHexagon(php);
177  // Load cell parameters
178  geom->loadCellParsHexagon(cpv, php);
179  // Set complete fill mode
180  php.defineFull_ = true;
181  } else if (php.mode_ == HGCalGeometryMode::Hexagon8) {
182  // Load the SpecPars
183  geom->loadSpecParsHexagon8(fv, php);
184  // Load Geometry parameters
185  geom->loadGeometryHexagon8(fv, php, 1);
186  // Set complete fill mode
187  php.defineFull_ = false;
188  // Load wafer positions
189  geom->loadWaferHexagon8(php);
190  } else if (php.mode_ == HGCalGeometryMode::Hexagon8Full) {
191  // Load the SpecPars
192  geom->loadSpecParsHexagon8(fv, php);
193  // Load Geometry parameters
194  geom->loadGeometryHexagon8(fv, php, 1);
195  // Set complete fill mode
196  php.defineFull_ = true;
197  // Load wafer positions
198  geom->loadWaferHexagon8(php);
199  } else if (php.mode_ == HGCalGeometryMode::Trapezoid) {
200  // Load maximum eta & top level
201  php.levelT_ = dbl_to_int(getDDDArray("LevelTop", sv));
202  php.firstLayer_ = (int)(getDDDValue("FirstLayer", sv));
203  php.firstMixedLayer_ = (int)(getDDDValue("FirstMixedLayer", sv));
204  php.detectorType_ = (int)(getDDDValue("DetectorType", sv));
205  php.waferThick_ =
206  HGCalParameters::k_ScaleFromDDD * getDDDValue("WaferThickness", sv);
207  php.minTileSize_ =
208  HGCalParameters::k_ScaleFromDDD * getDDDValue("MinimumTileSize", sv);
209  php.waferSize_ = php.waferR_ = 0;
210  php.sensorSeparation_ = php.mouseBite_ = 0;
211 #ifdef EDM_ML_DEBUG
212  edm::LogVerbatim("HGCalGeom")
213  << "Top levels " << php.levelT_[0] << ":" << php.levelT_[1]
214  << " first layers " << php.firstLayer_ << ":" << php.firstMixedLayer_
215  << " Det Type " << php.detectorType_ << " thickenss "
216  << php.waferThick_;
217 #endif
218  // Load the SpecPars
219  geom->loadSpecParsTrapezoid(fv, php);
220  // Load Geometry parameters
221  geom->loadGeometryHexagon8(fv, php, php.firstLayer_);
222  // Load cell positions
223  geom->loadCellTrapezoid(php);
224  } else {
225  edm::LogError("HGCalGeom")
226  << "Unknown Geometry type " << php.mode_ << " for HGCal " << name
227  << ":" << namew << ":" << namec;
228  throw cms::Exception("DDException")
229  << "Unknown Geometry type " << php.mode_ << " for HGCal " << name
230  << ":" << namew << ":" << namec;
231  }
232  } else {
233  edm::LogError("HGCalGeom")
234  << " Attribute " << val << " not found but needed.";
235  throw cms::Exception("DDException")
236  << "Attribute " << val << " not found but needed.";
237  }
238 #ifdef EDM_ML_DEBUG
239  edm::LogVerbatim("HGCalGeom") << "Return from HGCalParametersFromDD::build"
240  << " with flag " << ok;
241 #endif
242  return ok;
243 }
void loadSpecParsHexagon(const DDFilteredView &, HGCalParameters &, const DDCompactView *, const std::string &, const std::string &)
HGCalGeometryMode::GeometryMode mode_
void loadSpecParsHexagon8(const DDFilteredView &, HGCalParameters &)
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
void loadCellTrapezoid(HGCalParameters &php)
std::vector< double > cellSize_
void loadCellParsHexagon(const DDCompactView *cpv, HGCalParameters &php)
static double k_ScaleFromDDD
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Definition: value.py:1
void loadSpecParsTrapezoid(const DDFilteredView &, HGCalParameters &)
void loadGeometryHexagon8(const DDFilteredView &, HGCalParameters &, int)
void loadWaferHexagon(HGCalParameters &php)
int k[5][pyjets_maxn]
static double k_ScaleToDDD
double getDDDValue(const char *s, const DDsvalues_type &sv)
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
Definition: DDsvalues.h:12
std::vector< int > levelT_
std::vector< double > getDDDArray(const char *s, const DDsvalues_type &sv)
void loadWaferHexagon8(HGCalParameters &php)
void loadGeometryHexagon(const DDFilteredView &, HGCalParameters &, const std::string &, const DDCompactView *, const std::string &, const std::string &, HGCalGeometryMode::WaferMode)
void getCellPosition(HGCalParameters &php, int type)
void HGCalParametersFromDD::getCellPosition ( HGCalParameters php,
int  type 
)
private

Definition at line 245 of file HGCalParametersFromDD.cc.

References HGCalParameters::cellCoarseIndex_, HGCalParameters::cellCoarseX_, HGCalParameters::cellCoarseY_, HGCalParameters::cellFineIndex_, HGCalParameters::cellFineX_, HGCalParameters::cellFineY_, triggerObjects_cff::id, gen::k, N, HGCalParameters::nCellsCoarse_, HGCalParameters::nCellsFine_, dttmaxenums::R, alignCSCRings::r, mathSSE::sqrt(), findQualityFiles::v, and HGCalParameters::waferSize_.

Referenced by ~HGCalParametersFromDD().

245  {
246  if (type == 1) {
247  php.cellCoarseX_.clear();
248  php.cellCoarseY_.clear();
249  } else {
250  php.cellFineX_.clear();
251  php.cellFineY_.clear();
252  }
253  HGCalParameters::wafer_map cellIndex;
254 #ifdef EDM_ML_DEBUG
255  std::vector<int> indtypes;
256 #endif
257  int N = (type == 1) ? php.nCellsCoarse_ : php.nCellsFine_;
258  double R = php.waferSize_ / (3 * N);
259  double r = 0.5 * R * sqrt(3.0);
260  int n2 = N / 2;
261  int ipos(0);
262  for (int u = 0; u < 2 * N; ++u) {
263  for (int v = 0; v < 2 * N; ++v) {
264  if (((v - u) < N) && (u - v) <= N) {
265  double yp = (u - 0.5 * v - n2) * 2 * r;
266  double xp = (1.5 * (v - N) + 1.0) * R;
267  int id = v * 100 + u;
268 #ifdef EDM_ML_DEBUG
269  indtypes.emplace_back(id);
270 #endif
271  if (type == 1) {
272  php.cellCoarseX_.emplace_back(xp);
273  php.cellCoarseY_.emplace_back(yp);
274  } else {
275  php.cellFineX_.emplace_back(xp);
276  php.cellFineY_.emplace_back(yp);
277  }
278  cellIndex[id] = ipos;
279  ++ipos;
280  }
281  }
282  }
283  if (type == 1)
284  php.cellCoarseIndex_ = cellIndex;
285  else
286  php.cellFineIndex_ = cellIndex;
287 #ifdef EDM_ML_DEBUG
288  if (type == 1) {
289  edm::LogVerbatim("HGCalGeom")
290  << "CellPosition for type " << type << " for "
291  << php.cellCoarseX_.size() << " cells";
292  for (unsigned int k = 0; k < php.cellCoarseX_.size(); ++k) {
293  int id = indtypes[k];
294  edm::LogVerbatim("HGCalGeom")
295  << "[" << k << "] ID " << id << ":" << php.cellCoarseIndex_[id]
296  << " X " << php.cellCoarseX_[k] << " Y " << php.cellCoarseY_[k];
297  }
298  } else {
299  edm::LogVerbatim("HGCalGeom")
300  << "CellPosition for type " << type << " for " << php.cellFineX_.size()
301  << " cells";
302  for (unsigned int k = 0; k < php.cellCoarseX_.size(); ++k) {
303  int id = indtypes[k];
304  edm::LogVerbatim("HGCalGeom")
305  << "[" << k << "] ID " << id << ":" << php.cellFineIndex_[k] << " X "
306  << php.cellFineX_[k] << " Y " << php.cellFineY_[k];
307  }
308  }
309 #endif
310 }
type
Definition: HCALResponse.h:21
wafer_map cellFineIndex_
std::vector< double > cellFineY_
std::vector< double > cellCoarseX_
T sqrt(T t)
Definition: SSEVec.h:18
int k[5][pyjets_maxn]
#define N
Definition: blowfish.cc:9
std::unordered_map< int32_t, int32_t > wafer_map
wafer_map cellCoarseIndex_
std::vector< double > cellFineX_
std::vector< double > cellCoarseY_
std::vector< double > HGCalParametersFromDD::getDDDArray ( const char *  s,
const DDsvalues_type sv 
)
private

Definition at line 326 of file HGCalParametersFromDD.cc.

References DDfetch(), DDValue::doubles(), Exception, and heppy_batch::val.

Referenced by ~HGCalParametersFromDD().

327  {
328  DDValue val(s);
329  if (DDfetch(&sv, val)) {
330  const std::vector<double>& fvec = val.doubles();
331  if (fvec.empty()) {
332  throw cms::Exception("HGCalGeom") << "Failed to get " << s << " tag.";
333  }
334  return fvec;
335  } else {
336  throw cms::Exception("HGCalGeom") << "Failed to get " << s << " tag";
337  }
338 }
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:81
double HGCalParametersFromDD::getDDDValue ( const char *  s,
const DDsvalues_type sv 
)
private

Definition at line 312 of file HGCalParametersFromDD.cc.

References DDfetch(), DDValue::doubles(), Exception, and heppy_batch::val.

Referenced by ~HGCalParametersFromDD().

313  {
314  DDValue val(s);
315  if (DDfetch(&sv, val)) {
316  const std::vector<double>& fvec = val.doubles();
317  if (fvec.empty()) {
318  throw cms::Exception("HGCalGeom") << "Failed to get " << s << " tag.";
319  }
320  return fvec[0];
321  } else {
322  throw cms::Exception("HGCalGeom") << "Failed to get " << s << " tag";
323  }
324 }
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:81