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 51 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, getCellPosition(), getDDDArray(), getDDDValue(), 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().

56  {
57 
58 #ifdef EDM_ML_DEBUG
59  edm::LogVerbatim("HGCalGeom") << "HGCalParametersFromDD::build called with "
60  << "names " << name << ":" << namew << ":"
61  << namec << ":" << namet;
62 #endif
63 
64  //Special parameters at simulation level
65  std::string attribute = "Volume";
67  DDValue val(attribute, value, 0.0);
69  DDFilteredView fv(*cpv,filter);
70  bool ok = fv.firstChild();
72 
73  if (ok) {
74  DDsvalues_type sv(fv.mergedSpecifics());
75  php.mode_ = getGeometryMode("GeometryMode", sv);
76 #ifdef EDM_ML_DEBUG
77  edm::LogVerbatim("HGCalGeom") << "GeometryMode " << php.mode_
78  << ":" << HGCalGeometryMode::Hexagon << ":"
80  << ":" << HGCalGeometryMode::Hexagon8 << ":"
83 #endif
84  php.levelZSide_ = 3; // Default level for ZSide
85  php.detectorType_ = 0; // These two parameters are
86  php.firstMixedLayer_ =-1; // defined for post TDR geometry
88  if ((php.mode_ == HGCalGeometryMode::Hexagon) ||
90  attribute = "OnlyForHGCalNumbering";
91  value = namet;
92  DDValue val2(attribute, value, 0.0);
93  DDSpecificsMatchesValueFilter filter2{val2};
94  DDFilteredView fv2(*cpv,filter2);
95  bool ok2 = fv2.firstChild();
96  if (ok2) {
97  DDsvalues_type sv2(fv2.mergedSpecifics());
98  mode = getGeometryWaferMode("WaferMode", sv2);
99 #ifdef EDM_ML_DEBUG
100  edm::LogVerbatim("HGCalGeom") << "WaferMode " << mode << ":"
103 #endif
104  }
105  php.minTileSize_ = 0;
106  }
107  if ((php.mode_ == HGCalGeometryMode::Hexagon8) ||
109  php.levelT_ = dbl_to_int(getDDDArray("LevelTop",sv));
110  php.levelZSide_ = (int)(getDDDValue("LevelZSide",sv));
111  php.nCellsFine_ = php.nCellsCoarse_ = 0;
112  php.firstLayer_ = 1;
113  php.firstMixedLayer_ = (int)(getDDDValue("FirstMixedLayer", sv));
114  php.detectorType_ = (int)(getDDDValue("DetectorType", sv));
115  php.minTileSize_ = 0;
116 #ifdef EDM_ML_DEBUG
117  edm::LogVerbatim("HGCalGeom") << "Top levels " << php.levelT_[0] << ":"
118  << php.levelT_[1] << " ZSide Level "
119  << php.levelZSide_ << " first layers "
120  << php.firstLayer_ << ":"
121  << php.firstMixedLayer_ << " Det Type "
122  << php.detectorType_;
123 #endif
124  attribute = "OnlyForHGCalNumbering";
125  value = namet;
126  DDValue val2(attribute, value, 0.0);
127  DDSpecificsMatchesValueFilter filter2{val2};
128  DDFilteredView fv2(*cpv,filter2);
129  bool ok2 = fv2.firstChild();
130  if (ok2) {
131  DDsvalues_type sv2(fv2.mergedSpecifics());
132  mode = getGeometryWaferMode("WaferMode", sv2);
133  php.nCellsFine_ = (int)(getDDDValue("NumberOfCellsFine", sv2));
134  php.nCellsCoarse_ = (int)(getDDDValue("NumberOfCellsCoarse",sv2));
136  php.waferThick_ = HGCalParameters::k_ScaleFromDDD*getDDDValue("WaferThickness", sv2);
137  php.sensorSeparation_ = HGCalParameters::k_ScaleFromDDD*getDDDValue("SensorSeparation", sv2);
139  php.waferR_ = 0.5*HGCalParameters::k_ScaleToDDD*php.waferSize_/std::cos(30.0*CLHEP::deg);
142 #ifdef EDM_ML_DEBUG
143  edm::LogVerbatim("HGCalGeom") << "WaferMode " << mode << ":"
146  << " # of cells|size for fine/coarse "
147  << php.nCellsFine_ << ":"
148  << php.cellSize_[0] << ":"
149  << php.nCellsCoarse_ << ":"
150  << php.cellSize_[1] << " wafer Params "
151  << php.waferSize_ << ":"
152  << php.waferR_ << ":"
153  << php.waferThick_ << ":"
154  << php.sensorSeparation_ << ":"
155  << php.mouseBite_ << ":" << php.waferR_;
156 #endif
157  for (int k=0; k<2; ++k) getCellPosition(php, k);
158  }
159  }
160  if (php.mode_ == HGCalGeometryMode::Hexagon) {
161  //Load the SpecPars
162  php.firstLayer_ = 1;
163  geom->loadSpecParsHexagon(fv, php, cpv, namew, namec);
164  //Load the Geometry parameters
165  geom->loadGeometryHexagon(fv, php, name, cpv, namew, namec, mode);
166  //Load cell parameters
167  geom->loadCellParsHexagon(cpv, php);
168  //Set complete fill mode
169  php.defineFull_ = false;
170  } else if (php.mode_ == HGCalGeometryMode::HexagonFull) {
171  //Load the SpecPars
172  php.firstLayer_ = 1;
173  geom->loadSpecParsHexagon(fv, php, cpv, namew, namec);
174  //Load the Geometry parameters
175  geom->loadGeometryHexagon(fv, php, name, cpv, namew, namec, mode);
176  //Modify some constants
177  geom->loadWaferHexagon(php);
178  //Load cell parameters
179  geom->loadCellParsHexagon(cpv, php);
180  //Set complete fill mode
181  php.defineFull_ = true;
182  } else if (php.mode_ == HGCalGeometryMode::Hexagon8) {
183  //Load the SpecPars
184  geom->loadSpecParsHexagon8(fv, php);
185  //Load Geometry parameters
186  geom->loadGeometryHexagon8(fv, php, 1);
187  //Set complete fill mode
188  php.defineFull_ = false;
189  //Load wafer positions
190  geom->loadWaferHexagon8(php);
191  } else if (php.mode_ == HGCalGeometryMode::Hexagon8Full) {
192  //Load the SpecPars
193  geom->loadSpecParsHexagon8(fv, php);
194  //Load Geometry parameters
195  geom->loadGeometryHexagon8(fv, php, 1);
196  //Set complete fill mode
197  php.defineFull_ = true;
198  //Load wafer positions
199  geom->loadWaferHexagon8(php);
200  } else if (php.mode_ == HGCalGeometryMode::Trapezoid) {
201  //Load maximum eta & top level
202  php.levelT_ = dbl_to_int(getDDDArray("LevelTop",sv));
203  php.firstLayer_ = (int)(getDDDValue("FirstLayer", sv));
204  php.firstMixedLayer_ = (int)(getDDDValue("FirstMixedLayer", sv));
205  php.detectorType_ = (int)(getDDDValue("DetectorType", sv));
208  php.waferSize_ = php.waferR_ = 0;
209  php.sensorSeparation_= php.mouseBite_ = 0;
210 #ifdef EDM_ML_DEBUG
211  edm::LogVerbatim("HGCalGeom") << "Top levels " << php.levelT_[0] << ":"
212  << php.levelT_[1] << " first layers "
213  << php.firstLayer_ << ":"
214  << php.firstMixedLayer_ << " Det Type "
215  << 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") << "Unknown Geometry type " << php.mode_
226  << " for HGCal " << name << ":" << namew
227  << ":" << 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") << " Attribute " << val
234  << " not found but needed.";
235  throw cms::Exception("DDException") << "Attribute " << val
236  << " 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 build(), and ~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) php.cellCoarseIndex_ = cellIndex;
284  else php.cellFineIndex_ = cellIndex;
285 #ifdef EDM_ML_DEBUG
286  if (type == 1) {
287  edm::LogVerbatim("HGCalGeom") << "CellPosition for type " << type
288  << " for " << php.cellCoarseX_.size()
289  << " cells";
290  for (unsigned int k=0; k<php.cellCoarseX_.size(); ++k) {
291  int id = indtypes[k];
292  edm::LogVerbatim("HGCalGeom") << "[" << k << "] ID " << id << ":"
293  << php.cellCoarseIndex_[id] << " X "
294  << php.cellCoarseX_[k] << " Y "
295  << php.cellCoarseY_[k];
296  }
297  } else {
298  edm::LogVerbatim("HGCalGeom") << "CellPosition for type " << type
299  << " for " << php.cellFineX_.size()
300  << " cells";
301  for (unsigned int k=0; k<php.cellCoarseX_.size(); ++k) {
302  int id = indtypes[k];
303  edm::LogVerbatim("HGCalGeom") << "[" << k << "] ID " << id << ":"
304  << php.cellFineIndex_[k] << " X "
305  << php.cellFineX_[k] << " Y "
306  << 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 build(), and ~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 build(), and ~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