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 52 of file HGCalParametersFromDD.cc.

References HGCalParameters::cellSize_, funct::cos(), dbl_to_int(), HGCalParameters::defineFull_, HGCalParameters::etaMinBH_, Exception, HGCalGeometryMode::ExtrudedPolygon, ALCARECOTkAlBeamHalo_cff::filter, DDFilteredView::firstChild(), HGCalParameters::firstLayer_, 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_, HGCalGeomParameters::loadCellParsHexagon(), HGCalGeomParameters::loadCellTrapezoid(), HGCalGeomParameters::loadGeometryHexagon(), HGCalGeomParameters::loadGeometryHexagon8(), HGCalGeomParameters::loadSpecParsHexagon(), HGCalGeomParameters::loadSpecParsHexagon8(), HGCalGeomParameters::loadSpecParsTrapezoid(), HGCalGeomParameters::loadWaferHexagon(), HGCalGeomParameters::loadWaferHexagon8(), DDFilteredView::mergedSpecifics(), 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().

57  {
58 
59 #ifdef EDM_ML_DEBUG
60  edm::LogVerbatim("HGCalGeom") << "HGCalParametersFromDD::build called with "
61  << "names " << name << ":" << namew << ":"
62  << namec;
63 #endif
64 
65  //Special parameters at simulation level
66  std::string attribute = "Volume";
68  DDValue val(attribute, value, 0.0);
70  DDFilteredView fv(*cpv,filter);
71  bool ok = fv.firstChild();
73 
74  if (ok) {
75  DDsvalues_type sv(fv.mergedSpecifics());
76  php.mode_ = getGeometryMode("GeometryMode", sv);
77 #ifdef EDM_ML_DEBUG
78  edm::LogVerbatim("HGCalGeom") << "GeometryMode " << php.mode_
79  << ":" << HGCalGeometryMode::Hexagon << ":"
81  << ":" << HGCalGeometryMode::Hexagon8 << ":"
84 #endif
86  if ((php.mode_ == HGCalGeometryMode::Hexagon) ||
88  attribute = "OnlyForHGCalNumbering";
89  value = namet;
90  DDValue val2(attribute, value, 0.0);
91  DDSpecificsMatchesValueFilter filter2{val2};
92  DDFilteredView fv2(*cpv,filter2);
93  bool ok2 = fv2.firstChild();
94  if (ok2) {
95  DDsvalues_type sv2(fv2.mergedSpecifics());
96  mode = getGeometryWaferMode("WaferMode", sv2);
97 #ifdef EDM_ML_DEBUG
98  edm::LogVerbatim("HGCalGeom") << "WaferMode " << mode << ":"
101 #endif
102  }
103  }
104  if ((php.mode_ == HGCalGeometryMode::Hexagon8) ||
106  php.levelT_ = dbl_to_int(getDDDArray("LevelTop",sv));
107  php.nCellsFine_ = php.nCellsCoarse_ = 0;
108 #ifdef EDM_ML_DEBUG
109  edm::LogVerbatim("HGCalGeom") << "Top levels " << php.levelT_[0] << ":"
110  << php.levelT_[1];
111 #endif
112  attribute = "OnlyForHGCalNumbering";
113  value = namet;
114  DDValue val2(attribute, value, 0.0);
115  DDSpecificsMatchesValueFilter filter2{val2};
116  DDFilteredView fv2(*cpv,filter2);
117  bool ok2 = fv2.firstChild();
118  if (ok2) {
119  DDsvalues_type sv2(fv2.mergedSpecifics());
120  mode = getGeometryWaferMode("WaferMode", sv2);
121  php.nCellsFine_ = (int)(getDDDValue("NumberOfCellsFine", sv2));
122  php.nCellsCoarse_ = (int)(getDDDValue("NumberOfCellsCoarse",sv2));
124  php.waferThick_ = HGCalParameters::k_ScaleFromDDD*getDDDValue("WaferThickness", sv2);
125  php.sensorSeparation_ = HGCalParameters::k_ScaleFromDDD*getDDDValue("SensorSeparation", sv2);
127  php.waferR_ = 0.5*HGCalParameters::k_ScaleToDDD*php.waferSize_/std::cos(30.0*CLHEP::deg);
128  php.etaMinBH_ = 0;
131 #ifdef EDM_ML_DEBUG
132  edm::LogVerbatim("HGCalGeom") << "WaferMode " << mode << ":"
135  << " # of cells|size for fine/coarse "
136  << php.nCellsFine_ << ":"
137  << php.cellSize_[0] << ":"
138  << php.nCellsCoarse_ << ":"
139  << php.cellSize_[1] << " wafer Params "
140  << php.waferSize_ << ":"
141  << php.waferR_ << ":"
142  << php.waferThick_ << ":"
143  << php.sensorSeparation_ << ":"
144  << php.mouseBite_ << ":" << php.waferR_;
145 #endif
146  for (int k=0; k<2; ++k) getCellPosition(php, k);
147  }
148  }
149  if (php.mode_ == HGCalGeometryMode::Hexagon) {
150  //Load the SpecPars
151  php.firstLayer_ = 1;
152  geom->loadSpecParsHexagon(fv, php, cpv, namew, namec);
153  //Load the Geometry parameters
154  geom->loadGeometryHexagon(fv, php, name, cpv, namew, namec, mode);
155  //Load cell parameters
156  geom->loadCellParsHexagon(cpv, php);
157  //Set complete fill mode
158  php.defineFull_ = false;
159  } else if (php.mode_ == HGCalGeometryMode::HexagonFull) {
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  //Modify some constants
166  geom->loadWaferHexagon(php);
167  //Load cell parameters
168  geom->loadCellParsHexagon(cpv, php);
169  //Set complete fill mode
170  php.defineFull_ = true;
171  } else if (php.mode_ == HGCalGeometryMode::Hexagon8) {
172  //Load the SpecPars
173  php.firstLayer_ = 1;
174  geom->loadSpecParsHexagon8(fv, php);
175  //Load Geometry parameters
176  geom->loadGeometryHexagon8(fv, php, 1);
177  //Set complete fill mode
178  php.defineFull_ = false;
179  //Load wafer positions
180  geom->loadWaferHexagon8(php);
181  } else if (php.mode_ == HGCalGeometryMode::Hexagon8Full) {
182  //Load the SpecPars
183  php.firstLayer_ = 1;
184  geom->loadSpecParsHexagon8(fv, php);
185  //Load Geometry parameters
186  geom->loadGeometryHexagon8(fv, php, 1);
187  //Set complete fill mode
188  php.defineFull_ = true;
189  //Load wafer positions
190  geom->loadWaferHexagon8(php);
191  } else if (php.mode_ == HGCalGeometryMode::Trapezoid) {
192  //Load maximum eta & top level
193  php.etaMinBH_ = getDDDValue("etaMinBH", sv);
194  php.levelT_ = dbl_to_int(getDDDArray("LevelTop",sv));
195  php.firstLayer_ = (int)(getDDDValue("FirstLayer", sv));
197  php.waferSize_ = php.waferR_ = 0;
198  php.waferThick_ = php.sensorSeparation_= php.mouseBite_ = 0;
199 #ifdef EDM_ML_DEBUG
200  edm::LogVerbatim("HGCalGeom") << "Top levels " << php.levelT_[0] << ":"
201  << php.levelT_[1] << " EtaMinBH "
202  << php.etaMinBH_ << " first layer "
203  << php.firstLayer_ << " thickenss "
204  << php.waferThick_;
205 #endif
206  //Load the SpecPars
207  geom->loadSpecParsTrapezoid(fv, php);
208  //Load Geometry parameters
209  geom->loadGeometryHexagon8(fv, php, php.firstLayer_);
210  //Load cell positions
211  geom->loadCellTrapezoid(php);
212  } else {
213  edm::LogError("HGCalGeom") << "Unknown Geometry type " << php.mode_
214  << " for HGCal " << name << ":" << namew
215  << ":" << namec;
216  throw cms::Exception("DDException")
217  << "Unknown Geometry type " << php.mode_ << " for HGCal " << name
218  << ":" << namew << ":" << namec;
219  }
220  } else {
221  edm::LogError("HGCalGeom") << " Attribute " << val
222  << " not found but needed.";
223  throw cms::Exception("DDException") << "Attribute " << val
224  << " not found but needed.";
225  }
226 #ifdef EDM_ML_DEBUG
227  edm::LogVerbatim("HGCalGeom") << "Return from HGCalParametersFromDD::build"
228  << " with flag " << ok;
229 #endif
230  return ok;
231 }
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
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 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< 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 233 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().

233  {
234  if (type == 1) {
235  php.cellCoarseX_.clear();
236  php.cellCoarseY_.clear();
237  } else {
238  php.cellFineX_.clear();
239  php.cellFineY_.clear();
240  }
241  HGCalParameters::wafer_map cellIndex;
242 #ifdef EDM_ML_DEBUG
243  std::vector<int> indtypes;
244 #endif
245  int N = (type == 1) ? php.nCellsCoarse_ : php.nCellsFine_;
246  double R = php.waferSize_/(3*N);
247  double r = 0.5*R*sqrt(3.0);
248  int n2 = N/2;
249  int ipos(0);
250  for (int u=0; u<2*N; ++u) {
251  for (int v=0; v<2*N; ++v) {
252  if (((v-u) < N) && (u-v) <= N) {
253  double yp = (u-0.5*v-n2)*2*r;
254  double xp = (1.5*(v-N)+1.0)*R;
255  int id = v*100 + u;
256 #ifdef EDM_ML_DEBUG
257  indtypes.emplace_back(id);
258 #endif
259  if (type == 1) {
260  php.cellCoarseX_.emplace_back(xp);
261  php.cellCoarseY_.emplace_back(yp);
262  } else {
263  php.cellFineX_.emplace_back(xp);
264  php.cellFineY_.emplace_back(yp);
265  }
266  cellIndex[id] = ipos;
267  ++ipos;
268  }
269  }
270  }
271  if (type == 1) php.cellCoarseIndex_ = cellIndex;
272  else php.cellFineIndex_ = cellIndex;
273 #ifdef EDM_ML_DEBUG
274  if (type == 1) {
275  edm::LogVerbatim("HGCalGeom") << "CellPosition for type " << type
276  << " for " << php.cellCoarseX_.size()
277  << " cells";
278  for (unsigned int k=0; k<php.cellCoarseX_.size(); ++k) {
279  int id = indtypes[k];
280  edm::LogVerbatim("HGCalGeom") << "[" << k << "] ID " << id << ":"
281  << php.cellCoarseIndex_[id] << " X "
282  << php.cellCoarseX_[k] << " Y "
283  << php.cellCoarseY_[k];
284  }
285  } else {
286  edm::LogVerbatim("HGCalGeom") << "CellPosition for type " << type
287  << " for " << php.cellFineX_.size()
288  << " cells";
289  for (unsigned int k=0; k<php.cellCoarseX_.size(); ++k) {
290  int id = indtypes[k];
291  edm::LogVerbatim("HGCalGeom") << "[" << k << "] ID " << id << ":"
292  << php.cellFineIndex_[k] << " X "
293  << php.cellFineX_[k] << " Y "
294  << php.cellFineY_[k];
295  }
296  }
297 #endif
298 }
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 314 of file HGCalParametersFromDD.cc.

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

Referenced by build(), and ~HGCalParametersFromDD().

315  {
316  DDValue val(s);
317  if (DDfetch(&sv, val)) {
318  const std::vector<double> & fvec = val.doubles();
319  if (fvec.empty()) {
320  throw cms::Exception("HGCalGeom") << "Failed to get " << s << " tag.";
321  }
322  return fvec;
323  } else {
324  throw cms::Exception("HGCalGeom") << "Failed to get "<< s << " tag";
325  }
326 }
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 300 of file HGCalParametersFromDD.cc.

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

Referenced by build(), and ~HGCalParametersFromDD().

301  {
302  DDValue val(s);
303  if (DDfetch(&sv, val)) {
304  const std::vector<double> & fvec = val.doubles();
305  if (fvec.empty()) {
306  throw cms::Exception("HGCalGeom") << "Failed to get " << s << " tag.";
307  }
308  return fvec[0];
309  } else {
310  throw cms::Exception("HGCalGeom") << "Failed to get "<< s << " tag";
311  }
312 }
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:81