CMS 3D CMS Logo

HGCalDDDConstants.cc
Go to the documentation of this file.
2 
16 
17 #include <algorithm>
18 #include <iterator>
19 #include <functional>
20 #include <numeric>
21 
22 //#define EDM_ML_DEBUG
23 using namespace geant_units::operators;
24 
26  : hgpar_(hp), sqrt3_(std::sqrt(3.0)) {
27  mode_ = hgpar_->mode_;
29 #ifdef EDM_ML_DEBUG
30  edm::LogVerbatim("HGCalGeom") << "Mode " << mode_ << " FullAndPart " << fullAndPart_;
31 #endif
32  if (waferHexagon6() || waferHexagon8()) {
34  hexside_ = 2.0 * rmax_ * tan30deg_;
35 #ifdef EDM_ML_DEBUG
36  edm::LogVerbatim("HGCalGeom") << "rmax_ " << rmax_ << ":" << hexside_ << " CellSize "
39 #endif
40  }
41  // init maps and constants
42  modHalf_ = 0;
44  for (int simreco = 0; simreco < 2; ++simreco) {
45  tot_layers_[simreco] = layersInit((bool)simreco);
46  max_modules_layer_[simreco].resize(tot_layers_[simreco] + 1);
47  for (unsigned int layer = 1; layer <= tot_layers_[simreco]; ++layer) {
48  max_modules_layer_[simreco][layer] = modulesInit(layer, (bool)simreco);
49  if (simreco == 1) {
50  modHalf_ += max_modules_layer_[simreco][layer];
52 #ifdef EDM_ML_DEBUG
53  edm::LogVerbatim("HGCalGeom") << "Layer " << layer << " with " << max_modules_layer_[simreco][layer] << ":"
54  << modHalf_ << " modules in RECO";
55  } else {
56  edm::LogVerbatim("HGCalGeom") << "Layer " << layer << " with " << max_modules_layer_[simreco][layer]
57  << " modules in SIM";
58 #endif
59  }
60  }
61 #ifdef EDM_ML_DEBUG
62  edm::LogVerbatim("HGCalGeom") << "SimReco " << simreco << " with " << tot_layers_[simreco] << " Layers";
63 #endif
64  }
65  tot_wafers_ = wafers();
66 
67 #ifdef EDM_ML_DEBUG
68  edm::LogVerbatim("HGCalGeom") << "HGCalDDDConstants initialized for " << name << " with " << layers(false) << ":"
69  << layers(true) << " layers, " << wafers() << ":" << 2 * modHalf_
70  << " wafers with maximum " << maxWafersPerLayer_ << " per layer and "
71  << "maximum of " << maxCells(false) << ":" << maxCells(true) << " cells";
72 #endif
73  if (waferHexagon6() || waferHexagon8()) {
74  int wminT(9999999), wmaxT(-9999999), kount1(0), kount2(0);
75  for (unsigned int i = 0; i < getTrFormN(); ++i) {
76  int lay0 = getTrForm(i).lay;
77  int wmin(9999999), wmax(-9999999), kount(0);
78  for (int wafer = 0; wafer < sectors(); ++wafer) {
79  bool waferIn = waferInLayer(wafer, lay0, true);
80  if (waferHexagon8()) {
81  int kndx = HGCalWaferIndex::waferIndex(lay0,
84  waferIn_[kndx] = waferIn;
85  }
86  if (waferIn) {
87  int waferU = ((waferHexagon6()) ? wafer : HGCalWaferIndex::waferU(hgpar_->waferCopy_[wafer]));
88  if (waferU < wmin)
89  wmin = waferU;
90  if (waferU > wmax)
91  wmax = waferU;
92  ++kount;
93  }
94  }
95  if (wminT > wmin)
96  wminT = wmin;
97  if (wmaxT < wmax)
98  wmaxT = wmax;
99  if (kount1 < kount)
100  kount1 = kount;
101  kount2 += kount;
102 #ifdef EDM_ML_DEBUG
103  int lay1 = getIndex(lay0, true).first;
104  edm::LogVerbatim("HGCalGeom") << "Index " << i << " Layer " << lay0 << ":" << lay1 << " Wafer " << wmin << ":"
105  << wmax << ":" << kount;
106 #endif
107  HGCWaferParam a1{{wmin, wmax, kount}};
108  waferLayer_[lay0] = a1;
109  }
110  waferMax_ = std::array<int, 4>{{wminT, wmaxT, kount1, kount2}};
111 #ifdef EDM_ML_DEBUG
112  edm::LogVerbatim("HGCalGeom") << "Overall wafer statistics: " << wminT << ":" << wmaxT << ":" << kount1 << ":"
113  << kount2;
114 #endif
115  }
116 }
117 
119 
120 std::pair<int, int> HGCalDDDConstants::assignCell(float x, float y, int lay, int subSec, bool reco) const {
121  const auto& index = getIndex(lay, reco);
122  if (index.first < 0)
123  return std::make_pair(-1, -1);
124  if (waferHexagon6()) {
125  float xx = (reco) ? x : HGCalParameters::k_ScaleFromDDD * x;
126  float yy = (reco) ? y : HGCalParameters::k_ScaleFromDDD * y;
127 
128  // First the wafer
129  int wafer = cellHex(xx, yy, rmax_, hgpar_->waferPosX_, hgpar_->waferPosY_);
130  if (wafer < 0 || wafer >= (int)(hgpar_->waferTypeT_.size())) {
131  edm::LogWarning("HGCalGeom") << "Wafer no. out of bound for " << wafer << ":" << (hgpar_->waferTypeT_).size()
132  << ":" << (hgpar_->waferPosX_).size() << ":" << (hgpar_->waferPosY_).size()
133  << " ***** ERROR *****";
134  return std::make_pair(-1, -1);
135  } else {
136  // Now the cell
137  std::pair<double, double> xy = getXY(lay, xx, yy, false);
138  xx = xy.first - hgpar_->waferPosX_[wafer];
139  yy = xy.second - hgpar_->waferPosY_[wafer];
140  if (hgpar_->waferTypeT_[wafer] == 1)
141  return std::make_pair(wafer,
142  cellHex(xx,
143  yy,
146  hgpar_->cellFineY_));
147  else
148  return std::make_pair(wafer,
149  cellHex(xx,
150  yy,
153  hgpar_->cellCoarseY_));
154  }
155  } else {
156  return std::make_pair(-1, -1);
157  }
158 }
159 
160 std::array<int, 5> HGCalDDDConstants::assignCellHex(float x, float y, int lay, bool reco) const {
161  int waferU(0), waferV(0), waferType(-1), cellU(0), cellV(0);
162  if (waferHexagon8()) {
163  double xx = (reco) ? HGCalParameters::k_ScaleToDDD * x : x;
164  double yy = (reco) ? HGCalParameters::k_ScaleToDDD * y : y;
165  double wt(1.0);
166  waferFromPosition(xx, yy, lay, waferU, waferV, cellU, cellV, waferType, wt);
167  }
168  return std::array<int, 5>{{waferU, waferV, waferType, cellU, cellV}};
169 }
170 
171 std::array<int, 3> HGCalDDDConstants::assignCellTrap(float x, float y, float z, int layer, bool reco) const {
172  int irad(-1), iphi(-1), type(-1);
173  const auto& indx = getIndex(layer, reco);
174  if (indx.first < 0)
175  return std::array<int, 3>{{irad, iphi, type}};
176  double xx = (z > 0) ? x : -x;
177  double r = (reco ? std::sqrt(x * x + y * y) : HGCalParameters::k_ScaleFromDDD * std::sqrt(x * x + y * y));
178  double phi = (r == 0. ? 0. : std::atan2(y, xx));
179  if (phi < 0)
180  phi += (2.0 * M_PI);
182  auto ir = std::lower_bound(hgpar_->radiusLayer_[type].begin(), hgpar_->radiusLayer_[type].end(), r);
183  irad = (int)(ir - hgpar_->radiusLayer_[type].begin());
184  irad = std::clamp(irad, hgpar_->iradMinBH_[indx.first], hgpar_->iradMaxBH_[indx.first]);
185  iphi = 1 + (int)(phi / indx.second);
186 #ifdef EDM_ML_DEBUG
187  edm::LogVerbatim("HGCalGeom") << "assignCellTrap Input " << x << ":" << y << ":" << z << ":" << layer << ":" << reco
188  << " x|r " << xx << ":" << r << " phi " << phi << " o/p " << irad << ":" << iphi << ":"
189  << type;
190 #endif
191  return std::array<int, 3>{{irad, iphi, type}};
192 }
193 
194 std::pair<double, double> HGCalDDDConstants::cellEtaPhiTrap(int type, int irad) const {
195  double dr(0), df(0);
196  if (tileTrapezoid()) {
197  double r = 0.5 * ((hgpar_->radiusLayer_[type][irad - 1] + hgpar_->radiusLayer_[type][irad]));
198  dr = (hgpar_->radiusLayer_[type][irad] - hgpar_->radiusLayer_[type][irad - 1]);
199  df = r * hgpar_->cellSize_[type];
200  }
201  return std::make_pair(dr, df);
202 }
203 
204 bool HGCalDDDConstants::cellInLayer(int waferU, int waferV, int cellU, int cellV, int lay, bool reco) const {
205  const auto& indx = getIndex(lay, true);
206  if (indx.first >= 0) {
207  if (waferHexagon8() || waferHexagon6()) {
208  const auto& xy = ((waferHexagon8()) ? locateCell(lay, waferU, waferV, cellU, cellV, reco, true, false)
209  : locateCell(cellU, lay, waferU, reco));
210  double rpos = sqrt(xy.first * xy.first + xy.second * xy.second);
211  return ((rpos >= hgpar_->rMinLayHex_[indx.first]) && (rpos <= hgpar_->rMaxLayHex_[indx.first]));
212  } else {
213  return true;
214  }
215  } else {
216  return false;
217  }
218 }
219 
221  double thick(-1);
222  int type = waferType(layer, waferU, waferV, false);
223  if (type >= 0) {
224  if (waferHexagon8()) {
225  thick = 10000.0 * hgpar_->cellThickness_[type]; // cm to micron
226  } else if (waferHexagon6()) {
227  thick = 100.0 * (type + 1); // type = 1,2,3 for 100,200,300 micron
228  }
229  }
230  return thick;
231 }
232 
234  int indx = ((waferHexagon8()) ? ((type >= 1) ? 1 : 0) : ((type == 1) ? 1 : 0));
235  double cell = (tileTrapezoid() ? 0.5 * hgpar_->cellSize_[indx]
237  return cell;
238 }
239 
240 HGCalTypes::CellType HGCalDDDConstants::cellType(int type, int cellU, int cellV) const {
241  // type=0: in the middle; 1..6: the edges clocwise from bottom left;
242  // =11..16: the corners clockwise from bottom
243  int N = (type == 0) ? hgpar_->nCellsFine_ : hgpar_->nCellsCoarse_;
244  if (cellU == 0) {
245  if (cellV == 0)
247  else if (cellV - cellU == N - 1)
249  else
251  } else if (cellV == 0) {
252  if (cellU - cellV == N)
254  else
256  } else if (cellU - cellV == N) {
257  if (cellU == 2 * N - 1)
259  else
261  } else if (cellU == 2 * N - 1) {
262  if (cellV == 2 * N - 1)
264  else
266  } else if (cellV == 2 * N - 1) {
267  if (cellV - cellU == N - 1)
269  else
271  } else if (cellV - cellU == N - 1) {
273  } else if ((cellU > 2 * N - 1) || (cellV > 2 * N - 1) || (cellV >= (cellU + N)) || (cellU > (cellV + N))) {
275  } else {
277  }
278 }
279 
280 double HGCalDDDConstants::distFromEdgeHex(double x, double y, double z) const {
281  // Assming the point is within a hexagonal plane of the wafer, calculate
282  // the shortest distance from the edge
283  if (z < 0)
284  x = -x;
285  double dist(0);
286  // Input x, y in Geant4 unit and transformed to CMSSW standard
289  if (waferHexagon8()) {
290  int ll = layerIndex(getLayer(z, false), false);
291  xx -= hgpar_->xLayerHex_[ll];
292  yy -= hgpar_->yLayerHex_[ll];
293  }
294  int sizew = (int)(hgpar_->waferPosX_.size());
295  int wafer = sizew;
296  // Transform to the local coordinate frame of the wafer first
297  for (int k = 0; k < sizew; ++k) {
298  double dx = std::abs(xx - hgpar_->waferPosX_[k]);
299  double dy = std::abs(yy - hgpar_->waferPosY_[k]);
300  if ((dx <= rmax_) && (dy <= hexside_) && ((dy <= 0.5 * hexside_) || (dx * tan30deg_ <= (hexside_ - dy)))) {
301  wafer = k;
302  xx -= hgpar_->waferPosX_[k];
303  yy -= hgpar_->waferPosY_[k];
304  break;
305  }
306  }
307  // Look at only one quarter (both x,y are positive)
308  if (wafer < sizew) {
309  if (std::abs(yy) < 0.5 * hexside_) {
310  dist = rmax_ - std::abs(xx);
311  } else {
312  dist = 0.5 * ((rmax_ - std::abs(xx)) - sqrt3_ * (std::abs(yy) - 0.5 * hexside_));
313  }
314  } else {
315  dist = 0;
316  }
318 #ifdef EDM_ML_DEBUG
319  edm::LogVerbatim("HGCalGeom") << "DistFromEdgeHex: Local " << xx << ":" << yy << " wafer " << wafer << " flag "
320  << (wafer < sizew) << " Distance " << rmax_ << ":" << (rmax_ - std::abs(xx)) << ":"
321  << (std::abs(yy) - 0.5 * hexside_) << ":" << 0.5 * hexside_ << ":" << dist;
322 #endif
323  return dist;
324 }
325 
326 double HGCalDDDConstants::distFromEdgeTrap(double x, double y, double z) const {
327  // Assming the point is within the eta-phi plane of the scintillator tile,
328  // calculate the shortest distance from the edge
329  int lay = getLayer(z, false);
330  double xx = (z < 0) ? -x : x;
331  int indx = layerIndex(lay, false);
332  double r = HGCalParameters::k_ScaleFromDDD * std::sqrt(x * x + y * y);
333  double phi = (r == 0. ? 0. : std::atan2(y, xx));
334  if (phi < 0)
335  phi += (2.0 * M_PI);
336  int type = hgpar_->scintType(lay);
337  double cell = hgpar_->scintCellSize(lay);
338  // Compare with the center of the tile find distances along R and also phi
339  // Take the smaller value
340  auto ir = std::lower_bound(hgpar_->radiusLayer_[type].begin(), hgpar_->radiusLayer_[type].end(), r);
341  int irad = (int)(ir - hgpar_->radiusLayer_[type].begin());
342  irad = std::clamp(irad, hgpar_->iradMinBH_[indx], hgpar_->iradMaxBH_[indx]);
343  int iphi = 1 + (int)(phi / cell);
344  double dphi = std::max(0.0, (0.5 * cell - std::abs(phi - (iphi - 0.5) * cell)));
345  double dist = std::min((r - hgpar_->radiusLayer_[type][irad - 1]), (hgpar_->radiusLayer_[type][irad] - r));
346 #ifdef EDM_ML_DEBUG
347  edm::LogVerbatim("HGCalGeom") << "DistFromEdgeTrap: Global " << x << ":" << y << ":" << z << " Layer " << lay
348  << " Index " << indx << ":" << type << " xx " << xx << " R " << r << ":" << irad << ":"
349  << hgpar_->radiusLayer_[type][irad - 1] << ":" << hgpar_->radiusLayer_[type][irad]
350  << " Phi " << phi << ":" << iphi << ":" << (iphi - 0.5) * cell << " cell " << cell
351  << " Dphi " << dphi << " Dist " << dist << ":" << r * dphi;
352 #endif
353  return HGCalParameters::k_ScaleToDDD * std::min(r * dphi, dist);
354 }
355 
356 int HGCalDDDConstants::getLayer(double z, bool reco) const {
357  // Get the layer # from the gloabl z coordinate
358  unsigned int k = 0;
360  const auto& zLayerHex = hgpar_->zLayerHex_;
361  auto itr = std::find_if(zLayerHex.begin() + 1, zLayerHex.end(), [&k, &zz, &zLayerHex](double zLayer) {
362  ++k;
363  return zz < 0.5 * (zLayerHex[k - 1] + zLayerHex[k]);
364  });
365  int lay = (itr == zLayerHex.end()) ? static_cast<int>(zLayerHex.size()) : k;
366  if (waferHexagon6() && reco) {
367  int indx = layerIndex(lay, false);
368  if (indx >= 0)
369  lay = hgpar_->layerGroupO_[indx];
370  } else {
371  lay += (hgpar_->firstLayer_ - 1);
372  }
373  return lay;
374 }
375 
376 HGCalParameters::hgtrap HGCalDDDConstants::getModule(unsigned int indx, bool hexType, bool reco) const {
378  if (hexType) {
379  if (indx >= hgpar_->waferTypeL_.size())
380  edm::LogWarning("HGCalGeom") << "Wafer no. out bound for index " << indx << ":" << (hgpar_->waferTypeL_).size()
381  << ":" << (hgpar_->waferPosX_).size() << ":" << (hgpar_->waferPosY_).size()
382  << " ***** ERROR *****";
383  unsigned int type =
384  ((indx < hgpar_->waferTypeL_.size()) ? hgpar_->waferTypeL_[indx] - 1 : HGCSiliconDetId::HGCalCoarseThick);
385  mytr = hgpar_->getModule(type, reco);
386  } else {
387  mytr = hgpar_->getModule(indx, reco);
388  }
389  return mytr;
390 }
391 
392 std::vector<HGCalParameters::hgtrap> HGCalDDDConstants::getModules() const {
393  std::vector<HGCalParameters::hgtrap> mytrs;
394  for (unsigned int k = 0; k < hgpar_->moduleLayR_.size(); ++k)
395  mytrs.emplace_back(hgpar_->getModule(k, true));
396  return mytrs;
397 }
398 
399 int HGCalDDDConstants::getPhiBins(int lay) const { return (tileTrapezoid() ? hgpar_->scintCells(lay) : 0); }
400 
401 std::pair<int, int> HGCalDDDConstants::getREtaRange(int lay) const {
402  int irmin(0), irmax(0);
403  if (tileTrapezoid()) {
404  int indx = layerIndex(lay, false);
405  if ((indx >= 0) && (indx < static_cast<int>(hgpar_->iradMinBH_.size()))) {
406  irmin = hgpar_->iradMinBH_[indx];
407  irmax = hgpar_->iradMaxBH_[indx];
408  }
409  }
410  return std::make_pair(irmin, irmax);
411 }
412 
413 std::vector<HGCalParameters::hgtrform> HGCalDDDConstants::getTrForms() const {
414  std::vector<HGCalParameters::hgtrform> mytrs;
415  for (unsigned int k = 0; k < hgpar_->trformIndex_.size(); ++k)
416  mytrs.emplace_back(hgpar_->getTrForm(k));
417  return mytrs;
418 }
419 
421  // Get the module type for scinitllator
422  if (tileTrapezoid()) {
423  return hgpar_->scintType(layer);
424  } else {
425  return -1;
426  }
427 }
428 
430  // Get the module type for a silicon wafer
431  if (waferHexagon8()) {
433  return ((itr == hgpar_->typesInLayers_.end() ? 2 : hgpar_->waferTypeL_[itr->second]));
434  } else {
435  return -1;
436  }
437 }
438 
439 std::pair<double, double> HGCalDDDConstants::getXY(int layer, double x, double y, bool forwd) const {
440  int ll = layer - hgpar_->firstLayer_;
441  double x0(x), y0(y);
442  if (ll < static_cast<int>(hgpar_->layerRotV_.size())) {
443  if (forwd) {
444  x0 = x * hgpar_->layerRotV_[ll].first + y * hgpar_->layerRotV_[ll].second;
445  y0 = y * hgpar_->layerRotV_[ll].first - x * hgpar_->layerRotV_[ll].second;
446  } else {
447  x0 = x * hgpar_->layerRotV_[ll].first - y * hgpar_->layerRotV_[ll].second;
448  y0 = y * hgpar_->layerRotV_[ll].first + x * hgpar_->layerRotV_[ll].second;
449  }
450  }
451  return std::make_pair(x0, y0);
452 }
453 
454 bool HGCalDDDConstants::isHalfCell(int waferType, int cell) const {
455  if (waferType < 1 || cell < 0)
456  return false;
457  return waferType == 2 ? hgpar_->cellCoarseHalf_[cell] : hgpar_->cellFineHalf_[cell];
458 }
459 
460 bool HGCalDDDConstants::isValidHex(int lay, int mod, int cell, bool reco) const {
461  // Check validity for a layer|wafer|cell of pre-TDR version
462  bool result(false), resultMod(false);
463  int cellmax(0);
464  if (waferHexagon6()) {
465  int32_t copyNumber = hgpar_->waferCopy_[mod];
466  result = ((lay > 0 && lay <= (int)(layers(reco))));
467  if (result) {
468  const int32_t lay_idx = reco ? (lay - 1) * 3 + 1 : lay;
469  const auto& the_modules = hgpar_->copiesInLayers_[lay_idx];
470  auto moditr = the_modules.find(copyNumber);
471  result = resultMod = (moditr != the_modules.end());
472 #ifdef EDM_ML_DEBUG
473  if (!result)
474  edm::LogVerbatim("HGCalGeom") << "HGCalDDDConstants: Layer " << lay << ":" << lay_idx << " Copy " << copyNumber
475  << ":" << mod << " Flag " << result;
476 #endif
477  if (result) {
478  if (moditr->second >= 0) {
479  if (mod >= (int)(hgpar_->waferTypeT_.size()))
480  edm::LogWarning("HGCalGeom") << "Module no. out of bound for " << mod << " to be compared with "
481  << (hgpar_->waferTypeT_).size() << " ***** ERROR *****";
482  cellmax = ((hgpar_->waferTypeT_[mod] - 1 == HGCSiliconDetId::HGCalFine) ? (int)(hgpar_->cellFineX_.size())
483  : (int)(hgpar_->cellCoarseX_.size()));
484  result = (cell >= 0 && cell <= cellmax);
485  } else {
486  result = isValidCell(lay_idx, mod, cell);
487  }
488  }
489  }
490  }
491 
492 #ifdef EDM_ML_DEBUG
493  if (!result)
494  edm::LogVerbatim("HGCalGeom") << "HGCalDDDConstants: Layer " << lay << ":"
495  << (lay > 0 && (lay <= (int)(layers(reco)))) << " Module " << mod << ":" << resultMod
496  << " Cell " << cell << ":" << cellmax << ":" << (cell >= 0 && cell <= cellmax) << ":"
497  << maxCells(reco);
498 #endif
499  return result;
500 }
501 
502 bool HGCalDDDConstants::isValidHex8(int layer, int modU, int modV, bool fullAndPart) const {
503  // Check validity for a layer|wafer|cell of post-TDR version
504  int indx = HGCalWaferIndex::waferIndex(layer, modU, modV);
505  auto itr = hgpar_->typesInLayers_.find(indx);
506 #ifdef EDM_ML_DEBUG
507  edm::LogVerbatim("HGCalGeom") << "HGCalDDDConstants::isValidHex8:WaferType " << layer << ":" << modU << ":" << modV
508  << ":" << indx << " Test " << (itr != hgpar_->typesInLayers_.end());
509 #endif
510  if (itr == hgpar_->typesInLayers_.end())
511  return false;
512 
513  if (fullAndPart_) {
514  auto ktr = hgpar_->waferInfoMap_.find(indx);
515 #ifdef EDM_ML_DEBUG
516  edm::LogVerbatim("HGCalGeom") << "HGCalDDDConstants::isValidHex8:WaferInfoMap " << layer << ":" << modU << ":"
517  << modV << ":" << indx << " Test " << (ktr != hgpar_->waferInfoMap_.end());
518 #endif
519  if (ktr == hgpar_->waferInfoMap_.end())
520  return false;
521  } else {
522  auto jtr = waferIn_.find(indx);
523 #ifdef EDM_ML_DEBUG
524  edm::LogVerbatim("HGCalGeom") << "HGCalDDDConstants::isValidHex8:WaferIn " << jtr->first << ":" << jtr->second;
525 #endif
526  if (!(jtr->second))
527  return false;
528  }
529 
530  if (fullAndPart || fullAndPart_) {
531  auto ktr = hgpar_->waferTypes_.find(indx);
532  if (ktr != hgpar_->waferTypes_.end()) {
533  if (hgpar_->waferMaskMode_ > 0) {
534  if (ktr->second.first == HGCalTypes::WaferOut)
535  return false;
536  } else {
537  if (ktr->second.first < HGCalTypes::WaferCornerMin)
538  return false;
539  }
540  }
541  }
542  return true;
543 }
544 
545 bool HGCalDDDConstants::isValidHex8(int layer, int modU, int modV, int cellU, int cellV, bool fullAndPart) const {
546  // First check validity for a layer|wafer| of post TDR version
547  if (!isValidHex8(layer, modU, modV, fullAndPart))
548  return false;
549  int indx = HGCalWaferIndex::waferIndex(layer, modU, modV);
550  auto itr = hgpar_->typesInLayers_.find(indx);
551  int type = hgpar_->waferTypeL_[itr->second];
552  int N = ((hgpar_->waferTypeL_[itr->second] == 0) ? hgpar_->nCellsFine_ : hgpar_->nCellsCoarse_);
553 #ifdef EDM_ML_DEBUG
554  edm::LogVerbatim("HGCalGeom") << "HGCalDDDConstants::isValidHex8:Cell " << cellU << ":" << cellV << ":" << N
555  << " Tests " << (cellU >= 0) << ":" << (cellU < 2 * N) << ":" << (cellV >= 0) << ":"
556  << (cellV < 2 * N) << ":" << ((cellV - cellU) < N) << ":" << ((cellU - cellV) <= N);
557 #endif
558  if ((cellU < 0) || (cellU >= 2 * N) || (cellV < 0) || (cellV >= 2 * N))
559  return false;
560  if (((cellV - cellU) >= N) || ((cellU - cellV) > N))
561  return false;
562 
563  return isValidCell8(layer, modU, modV, cellU, cellV, type);
564 }
565 
566 bool HGCalDDDConstants::isValidTrap(int layer, int irad, int iphi) const {
567  // Check validity for a layer|eta|phi of scintillator
568  const auto& indx = getIndex(layer, true);
569  if (indx.first < 0)
570  return false;
571  return ((irad >= hgpar_->iradMinBH_[indx.first]) && (irad <= hgpar_->iradMaxBH_[indx.first]) && (iphi > 0) &&
572  (iphi <= hgpar_->scintCells(layer)));
573 }
574 
575 int HGCalDDDConstants::lastLayer(bool reco) const { return (hgpar_->firstLayer_ + tot_layers_[(int)reco] - 1); }
576 
577 unsigned int HGCalDDDConstants::layers(bool reco) const { return tot_layers_[(int)reco]; }
578 
579 int HGCalDDDConstants::layerIndex(int lay, bool reco) const {
580  int ll = lay - hgpar_->firstLayer_;
581  if (ll < 0 || ll >= (int)(hgpar_->layerIndex_.size()))
582  return -1;
583  if (waferHexagon6()) {
584  if (reco && ll >= (int)(hgpar_->depthIndex_.size()))
585  return -1;
586  return (reco ? hgpar_->depthLayerF_[ll] : hgpar_->layerIndex_[ll]);
587  } else {
588  return (hgpar_->layerIndex_[ll]);
589  }
590 }
591 
592 unsigned int HGCalDDDConstants::layersInit(bool reco) const {
593  return (reco ? hgpar_->depthIndex_.size() : hgpar_->layerIndex_.size());
594 }
595 
596 std::pair<float, float> HGCalDDDConstants::locateCell(int cell, int lay, int type, bool reco) const {
597  // type refers to wafer # for hexagon cell
598  float x(999999.), y(999999.);
599  const auto& index = getIndex(lay, reco);
600  int i = index.first;
601  if (i < 0)
602  return std::make_pair(x, y);
603  if (waferHexagon6()) {
604  x = hgpar_->waferPosX_[type];
605  y = hgpar_->waferPosY_[type];
606 #ifdef EDM_ML_DEBUG
607  float x0(x), y0(y);
608 #endif
610  x += hgpar_->cellFineX_[cell];
611  y += hgpar_->cellFineY_[cell];
612  } else {
613  x += hgpar_->cellCoarseX_[cell];
614  y += hgpar_->cellCoarseY_[cell];
615  }
616 #ifdef EDM_ML_DEBUG
617  edm::LogVerbatim("HGCalGeom") << "LocateCell (Wafer) " << x0 << ":" << y0 << " Final " << x << ":" << y;
618 #endif
619  if (!reco) {
622  }
623  }
624  return getXY(lay, x, y, true);
625 }
626 
627 std::pair<float, float> HGCalDDDConstants::locateCell(
628  int lay, int waferU, int waferV, int cellU, int cellV, bool reco, bool all, bool debug) const {
629  float x(0), y(0);
630  int indx = HGCalWaferIndex::waferIndex(lay, waferU, waferV);
631  auto itr = hgpar_->typesInLayers_.find(indx);
632  int type = ((itr == hgpar_->typesInLayers_.end()) ? 2 : hgpar_->waferTypeL_[itr->second]);
633 #ifdef EDM_ML_DEBUG
634  if (debug) {
635  edm::LogVerbatim("HGCalGeom") << "LocateCell " << lay << ":" << waferU << ":" << waferV << ":" << indx << ":"
636  << (itr == hgpar_->typesInLayers_.end()) << ":" << type;
637  }
638 #endif
639  int kndx = cellV * 100 + cellU;
640  if (type == 0) {
641  auto ktr = hgpar_->cellFineIndex_.find(kndx);
642  if (ktr != hgpar_->cellFineIndex_.end()) {
643  x = hgpar_->cellFineX_[ktr->second];
644  y = hgpar_->cellFineY_[ktr->second];
645  }
646 #ifdef EDM_ML_DEBUG
647  if (debug)
648  edm::LogVerbatim("HGCalGeom") << "Fine " << cellU << ":" << cellV << ":" << kndx << ":" << x << ":" << y << ":"
649  << (ktr != hgpar_->cellFineIndex_.end());
650 #endif
651  } else {
652  auto ktr = hgpar_->cellCoarseIndex_.find(kndx);
653  if (ktr != hgpar_->cellCoarseIndex_.end()) {
654  x = hgpar_->cellCoarseX_[ktr->second];
655  y = hgpar_->cellCoarseY_[ktr->second];
656  }
657 #ifdef EDM_ML_DEBUG
658  if (debug)
659  edm::LogVerbatim("HGCalGeom") << "Coarse " << cellU << ":" << cellV << ":" << kndx << ":" << x << ":" << y << ":"
660  << (ktr != hgpar_->cellCoarseIndex_.end());
661 #endif
662  }
663  if (!reco) {
666  }
667  if (all) {
668  const auto& xy = waferPosition(lay, waferU, waferV, reco, debug);
669  x += xy.first;
670  y += xy.second;
671 #ifdef EDM_ML_DEBUG
672  if (debug)
673  edm::LogVerbatim("HGCalGeom") << "With wafer " << x << ":" << y << ":" << xy.first << ":" << xy.second;
674 #endif
675  }
676  return getXY(lay, x, y, true);
677 }
678 
679 std::pair<float, float> HGCalDDDConstants::locateCell(const HGCSiliconDetId& id, bool debug) const {
680  int lay(id.layer());
681  double r = 0.5 * (hgpar_->waferSize_ + hgpar_->sensorSeparation_);
682  double R = 2.0 * r / sqrt3_;
683  int ncells = (id.type() == 0) ? hgpar_->nCellsFine_ : hgpar_->nCellsCoarse_;
684  int n2 = ncells / 2;
685  auto xyoff = geomTools_.shiftXY(hgpar_->layerCenter_[lay - 1], (2.0 * r));
686  double xpos = xyoff.first + ((-2 * id.waferU() + id.waferV()) * r);
687  double ypos = xyoff.second + (1.5 * id.waferV() * R);
688  if (debug)
689  edm::LogVerbatim("HGCalGeom") << "LocateCell " << id << " Lay " << lay << " r:R " << r << ":" << R << " N "
690  << ncells << ":" << n2 << " Off " << xyoff.first << ":" << xyoff.second << " Pos "
691  << xpos << ":" << ypos;
692  double R1 = hgpar_->waferSize_ / (3.0 * ncells);
693  double r1 = 0.5 * R1 * sqrt3_;
694  xpos += ((1.5 * (id.cellV() - ncells) + 1.0) * R1);
695  ypos += ((id.cellU() - 0.5 * id.cellV() - n2) * 2 * r1);
696  if (debug)
697  edm::LogVerbatim("HGCalGeom") << "LocateCell r1:R1 " << r1 << ":" << R1 << " dx:dy "
698  << ((1.5 * (id.cellV() - ncells) + 1.0) * R1) << ":"
699  << ((id.cellU() - 0.5 * id.cellV() - n2) * 2 * r1) << " Pos " << xpos << ":" << ypos;
700  std::pair<double, double> xy = getXY(id.layer(), xpos, ypos, true);
701  return std::make_pair(xy.first * id.zside(), xy.second);
702 }
703 
704 std::pair<float, float> HGCalDDDConstants::locateCell(const HGCScintillatorDetId& id, bool debug) const {
705  int lay(id.layer()), iphi(id.iphi()), ir(id.iradiusAbs());
706  double phi = (iphi - 0.5) * hgpar_->scintCellSize(lay);
707  int type = (id.type() > 0) ? 1 : 0;
708  double r = (((ir + 1) < static_cast<int>(hgpar_->radiusLayer_[type].size()))
709  ? (0.5 * (hgpar_->radiusLayer_[type][ir] + hgpar_->radiusLayer_[type][ir - 1]))
710  : (1.5 * hgpar_->radiusLayer_[type][ir] - 0.5 * hgpar_->radiusLayer_[type][ir - 1]));
711  if (debug)
712  edm::LogVerbatim("HGCalGeom") << "LocateCell lay:ir:iphi:type " << lay << ":" << ir << ":" << iphi << ":" << type
713  << " r:phi " << r << ":" << convertRadToDeg(phi) << " x:y "
714  << (r * cos(phi) * id.zside()) << ":" << (r * sin(phi));
715  return std::make_pair(r * cos(phi) * id.zside(), r * sin(phi));
716 }
717 
718 std::pair<float, float> HGCalDDDConstants::locateCellHex(int cell, int wafer, bool reco) const {
719  float x(0), y(0);
720  if (hgpar_->waferTypeT_[wafer] - 1 == HGCSiliconDetId::HGCalFine) {
721  x = hgpar_->cellFineX_[cell];
722  y = hgpar_->cellFineY_[cell];
723  } else {
724  x = hgpar_->cellCoarseX_[cell];
725  y = hgpar_->cellCoarseY_[cell];
726  }
727  if (!reco) {
730  }
731  return std::make_pair(x, y);
732 }
733 
734 std::pair<float, float> HGCalDDDConstants::locateCellTrap(int lay, int irad, int iphi, bool reco) const {
735  float x(0), y(0);
736  const auto& indx = getIndex(lay, reco);
737  if (indx.first >= 0) {
738  int ir = std::abs(irad);
739  int type = hgpar_->scintType(lay);
740  double phi = (iphi - 0.5) * indx.second;
741  double z = hgpar_->zLayerHex_[indx.first];
742  double r = 0.5 * (hgpar_->radiusLayer_[type][ir - 1] + hgpar_->radiusLayer_[type][ir]);
743  std::pair<double, double> range = rangeR(z, true);
744 #ifdef EDM_ML_DEBUG
745  edm::LogVerbatim("HGCalGeom") << "locateCellTrap:: Input " << lay << ":" << irad << ":" << iphi << ":" << reco
746  << " IR " << ir << ":" << hgpar_->iradMinBH_[indx.first] << ":"
747  << hgpar_->iradMaxBH_[indx.first] << " Type " << type << " Z " << indx.first << ":"
748  << z << " phi " << phi << " R " << r << ":" << range.first << ":" << range.second;
749 #endif
751  r = std::max(range.first, std::min(r, range.second));
752  x = r * std::cos(phi);
753  y = r * std::sin(phi);
754  if (irad < 0)
755  x = -x;
756  }
757  if (!reco) {
760  }
761  return std::make_pair(x, y);
762 }
763 
764 bool HGCalDDDConstants::maskCell(const DetId& detId, int corners) const {
765  bool mask(false);
766  if (corners > 2 && corners <= (int)(HGCalParameters::k_CornerSize)) {
767  if (waferHexagon8()) {
768  int N(0), layer(0), waferU(0), waferV(0), u(0), v(0);
769  if (detId.det() == DetId::Forward) {
770  HFNoseDetId id(detId);
771  N = getUVMax(id.type());
772  layer = id.layer();
773  waferU = id.waferU();
774  waferV = id.waferV();
775  u = id.cellU();
776  v = id.cellV();
777  } else {
778  HGCSiliconDetId id(detId);
779  N = getUVMax(id.type());
780  layer = id.layer();
781  waferU = id.waferU();
782  waferV = id.waferV();
783  u = id.cellU();
784  v = id.cellV();
785  }
787  auto itr = hgpar_->waferTypes_.find(wl);
788 #ifdef EDM_ML_DEBUG
789  edm::LogVerbatim("HGCalGeom") << "MaskCell: Layer " << layer << " Wafer " << waferU << ":" << waferV << " Index "
790  << wl << ":" << (itr != hgpar_->waferTypes_.end());
791 #endif
792  if (itr != hgpar_->waferTypes_.end()) {
793  if ((itr->second).second <= HGCalWaferMask::k_OffsetRotation)
794  mask = HGCalWaferMask::maskCell(u, v, N, (itr->second).first, (itr->second).second, corners);
795  else
796  mask = !(HGCalWaferMask::goodCell(
797  u, v, N, (itr->second).first, ((itr->second).second - HGCalWaferMask::k_OffsetRotation)));
798  }
799  }
800  }
801  return mask;
802 }
803 
805  int cells(0);
806  for (unsigned int i = 0; i < layers(reco); ++i) {
807  int lay = reco ? hgpar_->depth_[i] : hgpar_->layer_[i];
808  if (cells < maxCells(lay, reco))
809  cells = maxCells(lay, reco);
810  }
811  return cells;
812 }
813 
814 int HGCalDDDConstants::maxCells(int lay, bool reco) const {
815  const auto& index = getIndex(lay, reco);
816  if (index.first < 0)
817  return 0;
818  if (waferHexagon6()) {
819  unsigned int cells(0);
820  for (unsigned int k = 0; k < hgpar_->waferTypeT_.size(); ++k) {
821  if (waferInLayerTest(k, index.first, hgpar_->defineFull_)) {
822  unsigned int cell = (hgpar_->waferTypeT_[k] - 1 == HGCSiliconDetId::HGCalFine) ? (hgpar_->cellFineX_.size())
823  : (hgpar_->cellCoarseX_.size());
824  if (cell > cells)
825  cells = cell;
826  }
827  }
828  return (int)(cells);
829  } else if (waferHexagon8()) {
830  int cells(0);
831  for (unsigned int k = 0; k < hgpar_->waferCopy_.size(); ++k) {
832  if (waferInLayerTest(k, index.first, hgpar_->defineFull_)) {
836  : hgpar_->waferTypeL_[itr->second]);
838  cells = std::max(cells, 3 * N * N);
839  }
840  }
841  return cells;
842  } else if (tileTrapezoid()) {
843  return hgpar_->scintCells(index.first + hgpar_->firstLayer_);
844  } else {
845  return 0;
846  }
847 }
848 
849 int HGCalDDDConstants::maxRows(int lay, bool reco) const {
850  int kymax(0);
851  const auto& index = getIndex(lay, reco);
852  int i = index.first;
853  if (i < 0)
854  return kymax;
855  if (waferHexagon6()) {
856  for (unsigned int k = 0; k < hgpar_->waferCopy_.size(); ++k) {
858  int ky = ((hgpar_->waferCopy_[k]) / 100) % 100;
859  if (ky > kymax)
860  kymax = ky;
861  }
862  }
863  } else if (waferHexagon8()) {
864  kymax = 1 + 2 * hgpar_->waferUVMaxLayer_[index.first];
865  }
866  return kymax;
867 }
868 
869 int HGCalDDDConstants::modifyUV(int uv, int type1, int type2) const {
870  // Modify u/v for transition of type1 to type2
871  return (((type1 == type2) || (type1 * type2 != 0)) ? uv : ((type1 == 0) ? (2 * uv + 1) / 3 : (3 * uv) / 2));
872 }
873 
874 int HGCalDDDConstants::modules(int lay, bool reco) const {
875  if (getIndex(lay, reco).first < 0)
876  return 0;
877  else
878  return max_modules_layer_[(int)reco][lay];
879 }
880 
881 int HGCalDDDConstants::modulesInit(int lay, bool reco) const {
882  int nmod(0);
883  const auto& index = getIndex(lay, reco);
884  if (index.first < 0)
885  return nmod;
886  if (!tileTrapezoid()) {
887  for (unsigned int k = 0; k < hgpar_->waferPosX_.size(); ++k) {
888  if (waferInLayerTest(k, index.first, hgpar_->defineFull_))
889  ++nmod;
890  }
891  } else {
892  nmod = 1 + hgpar_->lastModule_[index.first] - hgpar_->firstModule_[index.first];
893  }
894  return nmod;
895 }
896 
897 double HGCalDDDConstants::mouseBite(bool reco) const {
899 }
900 
902  int cells(0);
903  unsigned int nlayer = (reco) ? hgpar_->depth_.size() : hgpar_->layer_.size();
904  for (unsigned k = 0; k < nlayer; ++k) {
905  std::vector<int> ncells = numberCells(((reco) ? hgpar_->depth_[k] : hgpar_->layer_[k]), reco);
906  cells = std::accumulate(ncells.begin(), ncells.end(), cells);
907  }
908  return cells;
909 }
910 
911 std::vector<int> HGCalDDDConstants::numberCells(int lay, bool reco) const {
912  const auto& index = getIndex(lay, reco);
913  int i = index.first;
914  std::vector<int> ncell;
915  if (i >= 0) {
916  if (waferHexagon6()) {
917  for (unsigned int k = 0; k < hgpar_->waferTypeT_.size(); ++k) {
919  unsigned int cell = (hgpar_->waferTypeT_[k] - 1 == HGCSiliconDetId::HGCalFine)
920  ? (hgpar_->cellFineX_.size())
921  : (hgpar_->cellCoarseX_.size());
922  ncell.emplace_back((int)(cell));
923  }
924  }
925  } else if (tileTrapezoid()) {
926  int nphi = hgpar_->scintCells(lay);
927  for (int k = hgpar_->firstModule_[i]; k <= hgpar_->lastModule_[i]; ++k)
928  ncell.emplace_back(nphi);
929  } else {
930  for (unsigned int k = 0; k < hgpar_->waferCopy_.size(); ++k) {
931  if (waferInLayerTest(k, index.first, hgpar_->defineFull_)) {
932  int cell = numberCellsHexagon(lay,
935  true);
936  ncell.emplace_back(cell);
937  }
938  }
939  }
940  }
941  return ncell;
942 }
943 
945  if (wafer >= 0 && wafer < (int)(hgpar_->waferTypeT_.size())) {
946  if (hgpar_->waferTypeT_[wafer] - 1 == HGCSiliconDetId::HGCalFine)
947  return (int)(hgpar_->cellFineX_.size());
948  else
949  return (int)(hgpar_->cellCoarseX_.size());
950  } else {
951  return 0;
952  }
953 }
954 
955 int HGCalDDDConstants::numberCellsHexagon(int lay, int waferU, int waferV, bool flag) const {
957  int type =
958  ((itr == hgpar_->typesInLayers_.end()) ? HGCSiliconDetId::HGCalCoarseThick : hgpar_->waferTypeL_[itr->second]);
959  int N = (type == 0) ? hgpar_->nCellsFine_ : hgpar_->nCellsCoarse_;
960  if (flag)
961  return (3 * N * N);
962  else
963  return N;
964 }
965 
966 std::pair<double, double> HGCalDDDConstants::rangeR(double z, bool reco) const {
967  double rmin(0), rmax(0), zz(0);
968  if (hgpar_->detectorType_ > 0) {
970  if (hgpar_->detectorType_ <= 2) {
972  } else {
973  rmin = HGCalGeomTools::radius(
975  }
976  if ((hgpar_->detectorType_ == 2) && (zz >= hgpar_->zLayerHex_[hgpar_->firstMixedLayer_ - 1])) {
977  rmax = HGCalGeomTools::radius(
979  } else {
981  }
982  }
983  if (!reco) {
986  }
987 #ifdef EDM_ML_DEBUG
988  edm::LogVerbatim("HGCalGeom") << "HGCalDDDConstants:rangeR: " << z << ":" << zz << " R " << rmin << ":" << rmax;
989 #endif
990  return std::make_pair(rmin, rmax);
991 }
992 
993 std::pair<double, double> HGCalDDDConstants::rangeRLayer(int lay, bool reco) const {
994  double rmin(0), rmax(0);
995  const auto& index = getIndex(lay, reco);
996  if (index.first >= 0 && index.first < static_cast<int>(hgpar_->rMinLayHex_.size())) {
997  rmin = hgpar_->rMinLayHex_[index.first];
998  rmax = hgpar_->rMaxLayHex_[index.first];
999  }
1000  if (!reco) {
1003  }
1004 #ifdef EDM_ML_DEBUG
1005  edm::LogVerbatim("HGCalGeom") << "HGCalDDDConstants:rangeR: " << lay << ":" << index.first << " R " << rmin << ":"
1006  << rmax;
1007 #endif
1008  return std::make_pair(rmin, rmax);
1009 }
1010 
1011 std::pair<double, double> HGCalDDDConstants::rangeZ(bool reco) const {
1012  double zmin = (hgpar_->zLayerHex_[0] - hgpar_->waferThick_);
1013  double zmax = (hgpar_->zLayerHex_[hgpar_->zLayerHex_.size() - 1] + hgpar_->waferThick_);
1014 #ifdef EDM_ML_DEBUG
1015  edm::LogVerbatim("HGCalGeom") << "HGCalDDDConstants:rangeZ: " << zmin << ":" << zmax << ":" << hgpar_->waferThick_;
1016 #endif
1017  if (!reco) {
1020  }
1021  return std::make_pair(zmin, zmax);
1022 }
1023 
1024 std::pair<int, int> HGCalDDDConstants::rowColumnWafer(int wafer) const {
1025  int row(0), col(0);
1026  if (wafer < (int)(hgpar_->waferCopy_.size())) {
1027  int copy = hgpar_->waferCopy_[wafer];
1030  ;
1031  }
1032  return std::make_pair(row, col);
1033 }
1034 
1035 std::pair<int, int> HGCalDDDConstants::simToReco(int cell, int lay, int mod, bool half) const {
1036  if (!waferHexagon6()) {
1037  return std::make_pair(cell, lay);
1038  } else {
1039  const auto& index = getIndex(lay, false);
1040  int i = index.first;
1041  if (i < 0) {
1042  edm::LogWarning("HGCalGeom") << "Wrong Layer # " << lay << " not in the list ***** ERROR *****";
1043  return std::make_pair(-1, -1);
1044  }
1045  if (mod >= (int)(hgpar_->waferTypeL_).size()) {
1046  edm::LogWarning("HGCalGeom") << "Invalid Wafer # " << mod << "should be < " << (hgpar_->waferTypeL_).size()
1047  << " ***** ERROR *****";
1048  return std::make_pair(-1, -1);
1049  }
1050  int depth(-1);
1051  int kx = cell;
1052  int type = hgpar_->waferTypeL_[mod];
1053  if (type == 1) {
1054  depth = hgpar_->layerGroup_[i];
1055  } else if (type == 2) {
1056  depth = hgpar_->layerGroupM_[i];
1057  } else {
1058  depth = hgpar_->layerGroupO_[i];
1059  }
1060  return std::make_pair(kx, depth);
1061  }
1062 }
1063 
1065  const int ncopies = hgpar_->waferCopy_.size();
1066  int wafer(ncopies);
1067  bool result(false);
1068  for (int k = 0; k < ncopies; ++k) {
1069  if (copy == hgpar_->waferCopy_[k]) {
1070  wafer = k;
1071  result = true;
1072  break;
1073  }
1074  }
1075  if (!result) {
1076  wafer = -1;
1077 #ifdef EDM_ML_DEBUG
1078  edm::LogVerbatim("HGCalGeom") << "Cannot find " << copy << " in a list of " << ncopies << " members";
1079  for (int k = 0; k < ncopies; ++k)
1080  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << hgpar_->waferCopy_[k];
1081 #endif
1082  }
1083 #ifdef EDM_ML_DEBUG
1084  edm::LogVerbatim("HGCalGeom") << "WaferFromCopy " << copy << ":" << wafer << ":" << result;
1085 #endif
1086  return wafer;
1087 }
1088 
1089 void HGCalDDDConstants::waferFromPosition(const double x, const double y, int& wafer, int& icell, int& celltyp) const {
1090  // Input x, y in Geant4 unit and transformed to CMSSW standard
1093  int size_ = static_cast<int>(hgpar_->waferCopy_.size());
1094  wafer = size_;
1095  for (int k = 0; k < size_; ++k) {
1096  double dx = std::abs(xx - hgpar_->waferPosX_[k]);
1097  double dy = std::abs(yy - hgpar_->waferPosY_[k]);
1098  if (dx <= rmax_ && dy <= hexside_) {
1099  if ((dy <= 0.5 * hexside_) || (dx * tan30deg_ <= (hexside_ - dy))) {
1100  wafer = k;
1101  celltyp = hgpar_->waferTypeT_[k];
1102  xx -= hgpar_->waferPosX_[k];
1103  yy -= hgpar_->waferPosY_[k];
1104  break;
1105  }
1106  }
1107  }
1108  if (wafer < size_) {
1109  if (celltyp - 1 == HGCSiliconDetId::HGCalFine)
1110  icell = cellHex(
1112  else
1113  icell = cellHex(xx,
1114  yy,
1117  hgpar_->cellCoarseY_);
1118  } else {
1119  wafer = -1;
1120 #ifdef EDM_ML_DEBUG
1121  edm::LogWarning("HGCalGeom") << "Cannot get wafer type corresponding to " << x << ":" << y << " " << xx << ":"
1122  << yy;
1123 #endif
1124  }
1125 #ifdef EDM_ML_DEBUG
1126  edm::LogVerbatim("HGCalGeom") << "Position " << x << ":" << y << " Wafer " << wafer << ":" << size_ << " XX " << xx
1127  << ":" << yy << " Cell " << icell << " Type " << celltyp;
1128 #endif
1129 }
1130 
1132  const double y,
1133  const int layer,
1134  int& waferU,
1135  int& waferV,
1136  int& cellU,
1137  int& cellV,
1138  int& celltype,
1139  double& wt,
1140  bool debug) const {
1141  waferU = waferV = 1 + hgpar_->waferUVMax_;
1142  cellU = cellV = celltype = 0;
1143  if ((hgpar_->xLayerHex_.empty()) || (hgpar_->yLayerHex_.empty()))
1144  return;
1145  int ll = layer - hgpar_->firstLayer_;
1146  std::pair<double, double> xy =
1148  double xx = xy.first - hgpar_->xLayerHex_[ll];
1149  double yy = xy.second - hgpar_->yLayerHex_[ll];
1150  for (unsigned int k = 0; k < hgpar_->waferPosX_.size(); ++k) {
1151  double dx = std::abs(xx - hgpar_->waferPosX_[k]);
1152  double dy = std::abs(yy - hgpar_->waferPosY_[k]);
1153  if (dx <= rmax_ && dy <= hexside_) {
1154  if ((dy <= 0.5 * hexside_) || (dx * tan30deg_ <= (hexside_ - dy))) {
1160  } else {
1162  celltype = ((itr == hgpar_->typesInLayers_.end()) ? HGCSiliconDetId::HGCalCoarseThick
1163  : hgpar_->waferTypeL_[itr->second]);
1164  }
1165 #ifdef EDM_ML_DEBUG
1166  if (debug)
1167  edm::LogVerbatim("HGCalGeom") << "WaferFromPosition:: Input " << layer << ":" << ll << ":"
1168  << hgpar_->firstLayer_ << ":" << x << ":" << y << ":" << hgpar_->xLayerHex_[ll]
1169  << ":" << hgpar_->yLayerHex_[ll] << ":" << xx << ":" << yy << " compared with "
1170  << hgpar_->waferPosX_[k] << ":" << hgpar_->waferPosY_[k] << " difference " << dx
1171  << ":" << dy << ":" << dx * tan30deg_ << ":" << (hexside_ - dy)
1172  << " comparator " << rmax_ << ":" << hexside_ << " wafer " << waferU << ":"
1173  << waferV << ":" << celltype;
1174 #endif
1175  xx -= hgpar_->waferPosX_[k];
1176  yy -= hgpar_->waferPosY_[k];
1177  break;
1178  }
1179  }
1180  }
1181  if ((std::abs(waferU) <= hgpar_->waferUVMax_) && (celltype >= 0)) {
1182  cellHex(xx, yy, celltype, cellU, cellV, debug);
1183  wt = ((celltype < 2) ? (hgpar_->cellThickness_[celltype] / hgpar_->waferThick_) : 1.0);
1184  } else {
1185  cellU = cellV = 2 * hgpar_->nCellsFine_;
1186  wt = 1.0;
1187  celltype = -1;
1188  }
1189 #ifdef EDM_ML_DEBUG
1190  if (celltype < 0) {
1193  edm::LogVerbatim("HGCalGeom") << "waferFromPosition: Bad type for X " << x << ":" << x1 << ":" << xx << " Y " << y
1194  << ":" << y1 << ":" << yy << " Wafer " << waferU << ":" << waferV << " Cell " << cellU
1195  << ":" << cellV;
1196  for (unsigned int k = 0; k < hgpar_->waferPosX_.size(); ++k) {
1197  double dx = std::abs(x1 - hgpar_->waferPosX_[k]);
1198  double dy = std::abs(y1 - hgpar_->waferPosY_[k]);
1199  edm::LogVerbatim("HGCalGeom") << "Wafer [" << k << "] Position (" << hgpar_->waferPosX_[k] << ", "
1200  << hgpar_->waferPosY_[k] << ") difference " << dx << ":" << dy << ":"
1201  << dx * tan30deg_ << ":" << hexside_ - dy << " Paramerers " << rmax_ << ":"
1202  << hexside_;
1203  }
1204  }
1205 #endif
1206 }
1207 
1208 bool HGCalDDDConstants::waferInLayer(int wafer, int lay, bool reco) const {
1209  const auto& indx = getIndex(lay, reco);
1210  if (indx.first < 0)
1211  return false;
1212  return waferInLayerTest(wafer, indx.first, hgpar_->defineFull_);
1213 }
1214 
1215 bool HGCalDDDConstants::waferFullInLayer(int wafer, int lay, bool reco) const {
1216  const auto& indx = getIndex(lay, reco);
1217  if (indx.first < 0)
1218  return false;
1219  return waferInLayerTest(wafer, indx.first, false);
1220 }
1221 
1222 std::pair<double, double> HGCalDDDConstants::waferParameters(bool reco) const {
1223  if (reco)
1224  return std::make_pair(rmax_, hexside_);
1225  else
1227 }
1228 
1229 std::pair<double, double> HGCalDDDConstants::waferPosition(int wafer, bool reco) const {
1230  double xx(0), yy(0);
1231  if (wafer >= 0 && wafer < (int)(hgpar_->waferPosX_.size())) {
1232  xx = hgpar_->waferPosX_[wafer];
1233  yy = hgpar_->waferPosY_[wafer];
1234  }
1235  if (!reco) {
1238  }
1239  return std::make_pair(xx, yy);
1240 }
1241 
1242 std::pair<double, double> HGCalDDDConstants::waferPosition(
1243  int lay, int waferU, int waferV, bool reco, bool debug) const {
1244  int ll = lay - hgpar_->firstLayer_;
1245  double x = hgpar_->xLayerHex_[ll];
1246  double y = hgpar_->yLayerHex_[ll];
1247 #ifdef EDM_ML_DEBUG
1248  if (debug)
1249  edm::LogVerbatim("HGCalGeom") << "Layer " << lay << ":" << ll << " Shift " << hgpar_->xLayerHex_[ll] << ":"
1250  << hgpar_->yLayerHex_[ll];
1251 #endif
1252  if (!reco) {
1255  }
1256 
1257  const auto& xy = waferPosition(waferU, waferV, reco);
1258  x += xy.first;
1259  y += xy.second;
1260 #ifdef EDM_ML_DEBUG
1261  if (debug)
1262  edm::LogVerbatim("HGCalGeom") << "With wafer " << x << ":" << y << ":" << xy.first << ":" << xy.second;
1263 #endif
1264  return std::make_pair(x, y);
1265 }
1266 
1267 int HGCalDDDConstants::waferType(DetId const& id, bool fromFile) const {
1268  int type(1);
1269  if (waferHexagon8()) {
1270  if (fromFile && (waferFileSize() > 0)) {
1271  int layer(0), waferU(0), waferV(0);
1272  if (id.det() != DetId::Forward) {
1273  HGCSiliconDetId hid(id);
1274  layer = hid.layer();
1275  waferU = hid.waferU();
1276  waferV = hid.waferV();
1277  } else {
1278  HFNoseDetId hid(id);
1279  layer = hid.layer();
1280  waferU = hid.waferU();
1281  waferV = hid.waferV();
1282  }
1284  if (itr != hgpar_->waferInfoMap_.end())
1285  type = (itr->second).type;
1286  } else {
1287  type = ((id.det() != DetId::Forward) ? HGCSiliconDetId(id).type() : HFNoseDetId(id).type());
1288  }
1289  } else if (waferHexagon6()) {
1290  type = waferTypeL(HGCalDetId(id).wafer()) - 1;
1291  }
1292  return type;
1293 }
1294 
1295 int HGCalDDDConstants::waferType(int layer, int waferU, int waferV, bool fromFile) const {
1297  if (waferHexagon8()) {
1298  if (fromFile && (waferFileSize() > 0)) {
1300  if (itr != hgpar_->waferInfoMap_.end())
1301  type = (itr->second).type;
1302  } else {
1304  if (itr != hgpar_->typesInLayers_.end())
1305  type = hgpar_->waferTypeL_[itr->second];
1306  }
1307  } else if (waferHexagon6()) {
1308  if ((waferU >= 0) && (waferU < (int)(hgpar_->waferTypeL_.size())))
1309  type = (hgpar_->waferTypeL_[waferU] - 1);
1310  }
1311  return type;
1312 }
1313 
1314 std::tuple<int, int, int> HGCalDDDConstants::waferType(HGCSiliconDetId const& id, bool fromFile) const {
1315  const auto& index = HGCalWaferIndex::waferIndex(id.layer(), id.waferU(), id.waferV());
1316  int type(-1), part(-1), orient(-1);
1317  if (fromFile && (waferFileSize() > 0)) {
1318  auto itr = hgpar_->waferInfoMap_.find(index);
1319  if (itr != hgpar_->waferInfoMap_.end()) {
1320  type = (itr->second).type;
1321  part = (itr->second).part;
1322  orient = (itr->second).orient;
1323  }
1324  } else {
1325  auto ktr = hgpar_->typesInLayers_.find(index);
1326  if (ktr != hgpar_->typesInLayers_.end())
1327  type = hgpar_->waferTypeL_[ktr->second];
1328  auto itr = hgpar_->waferTypes_.find(index);
1329  if (itr != hgpar_->waferTypes_.end()) {
1330  if ((itr->second).second < HGCalWaferMask::k_OffsetRotation) {
1331  orient = (itr->second).second;
1332  if ((itr->second).first == HGCalGeomTools::k_allCorners) {
1334  } else if ((itr->second).first == HGCalGeomTools::k_fiveCorners) {
1336  } else if ((itr->second).first == HGCalGeomTools::k_fourCorners) {
1338  } else if ((itr->second).first == HGCalGeomTools::k_threeCorners) {
1340  }
1341  } else {
1342  part = (itr->second).first;
1343  orient = ((itr->second).second - HGCalWaferMask::k_OffsetRotation);
1344  }
1345  } else {
1347  orient = 0;
1348  }
1349  }
1350  return std::make_tuple(type, part, orient);
1351 }
1352 
1354  int layer, int waferU, int waferV, bool fromFile, bool debug) const {
1355  int type(HGCalTypes::WaferOut), rotn(0);
1357  bool withinList(true);
1358  if (fromFile && (waferFileSize() > 0)) {
1359  auto itr = hgpar_->waferInfoMap_.find(wl);
1360  withinList = (itr != hgpar_->waferInfoMap_.end());
1361  if (withinList) {
1362  type = (itr->second).part;
1363  rotn = (itr->second).orient;
1364  }
1365  } else {
1366  auto itr = hgpar_->waferTypes_.find(wl);
1367  if (waferHexagon8()) {
1368  withinList = (itr != hgpar_->waferTypes_.end());
1369  if (withinList) {
1370  if ((itr->second).second < HGCalWaferMask::k_OffsetRotation) {
1371  rotn = (itr->second).second;
1372  if ((itr->second).first == HGCalGeomTools::k_allCorners) {
1374  } else if ((itr->second).first == HGCalGeomTools::k_fiveCorners) {
1376  } else if ((itr->second).first == HGCalGeomTools::k_fourCorners) {
1378  } else if ((itr->second).first == HGCalGeomTools::k_threeCorners) {
1380  }
1381  } else {
1382  type = (itr->second).first;
1383  rotn = ((itr->second).second - HGCalWaferMask::k_OffsetRotation);
1384  }
1385  } else {
1387  rotn = HGCalTypes::WaferCorner0;
1388  }
1389  }
1390  }
1391 #ifdef EDM_ML_DEBUG
1392  if (debug)
1393  edm::LogVerbatim("HGCalGeom") << "waferTypeRotation: Layer " << layer << " Wafer " << waferU << ":" << waferV
1394  << " Index " << std::hex << wl << std::dec << ":" << withinList << " Type " << type
1395  << " Rotation " << rotn;
1396 #endif
1397  return std::make_pair(type, rotn);
1398 }
1399 
1401  bool type(false);
1402  if (waferHexagon8()) {
1404  type = (hgpar_->waferTypes_.find(wl) != hgpar_->waferTypes_.end());
1405  } else if (waferHexagon6()) {
1406  int wl = HGCalWaferIndex::waferIndex(layer, waferU, 0, true);
1407  type = (hgpar_->waferTypes_.find(wl) != hgpar_->waferTypes_.end());
1408  }
1409  return type;
1410 }
1411 
1412 double HGCalDDDConstants::waferZ(int lay, bool reco) const {
1413  const auto& index = getIndex(lay, reco);
1414  if (index.first < 0)
1415  return 0;
1416  else
1418 }
1419 
1421  int wafer(0);
1422  if (!tileTrapezoid()) {
1423  for (unsigned int i = 0; i < layers(true); ++i) {
1424  int lay = hgpar_->depth_[i];
1425  wafer += modules(lay, true);
1426  }
1427  } else {
1428  wafer = (int)(hgpar_->moduleLayR_.size());
1429  }
1430  return wafer;
1431 }
1432 
1433 int HGCalDDDConstants::wafers(int layer, int type) const {
1434  int wafer(0);
1435  if (!tileTrapezoid()) {
1436  auto itr = waferLayer_.find(layer);
1437  if (itr != waferLayer_.end()) {
1438  unsigned ity = (type > 0 && type <= 2) ? type : 0;
1439  wafer = (itr->second)[ity];
1440  }
1441  } else {
1442  const auto& index = getIndex(layer, true);
1443  wafer = 1 + hgpar_->lastModule_[index.first] - hgpar_->firstModule_[index.first];
1444  }
1445  return wafer;
1446 }
1447 
1449  double xx, double yy, const double& cellR, const std::vector<double>& posX, const std::vector<double>& posY) const {
1450  int num(0);
1451  const double tol(0.00001);
1452  double cellY = 2.0 * cellR * tan30deg_;
1453  for (unsigned int k = 0; k < posX.size(); ++k) {
1454  double dx = std::abs(xx - posX[k]);
1455  double dy = std::abs(yy - posY[k]);
1456  if (dx <= (cellR + tol) && dy <= (cellY + tol)) {
1457  double xmax = (dy <= 0.5 * cellY) ? cellR : (cellR - (dy - 0.5 * cellY) / tan30deg_);
1458  if (dx <= (xmax + tol)) {
1459  num = k;
1460  break;
1461  }
1462  }
1463  }
1464  return num;
1465 }
1466 
1467 void HGCalDDDConstants::cellHex(double xloc, double yloc, int cellType, int& cellU, int& cellV, bool debug) const {
1468  int N = (cellType == 0) ? hgpar_->nCellsFine_ : hgpar_->nCellsCoarse_;
1469  double Rc = 2 * rmax_ / (3 * N);
1470  double rc = 0.5 * Rc * sqrt3_;
1471  double v0 = ((xloc / Rc - 1.0) / 1.5);
1472  int cv0 = (v0 > 0) ? (N + (int)(v0 + 0.5)) : (N - (int)(-v0 + 0.5));
1473  double u0 = (0.5 * yloc / rc + 0.5 * cv0);
1474  int cu0 = (u0 > 0) ? (N / 2 + (int)(u0 + 0.5)) : (N / 2 - (int)(-u0 + 0.5));
1475  cu0 = std::max(0, std::min(cu0, 2 * N - 1));
1476  cv0 = std::max(0, std::min(cv0, 2 * N - 1));
1477  if (cv0 - cu0 >= N)
1478  cv0 = cu0 + N - 1;
1479 #ifdef EDM_ML_DEBUG
1480  if (debug)
1481  edm::LogVerbatim("HGCalGeom") << "cellHex: input " << xloc << ":" << yloc << ":" << cellType << " parameter " << rc
1482  << ":" << Rc << " u0 " << u0 << ":" << cu0 << " v0 " << v0 << ":" << cv0;
1483 #endif
1484  bool found(false);
1485  static constexpr int shift[3] = {0, 1, -1};
1486  for (int i1 = 0; i1 < 3; ++i1) {
1487  cellU = cu0 + shift[i1];
1488  for (int i2 = 0; i2 < 3; ++i2) {
1489  cellV = cv0 + shift[i2];
1490  if (((cellV - cellU) < N) && ((cellU - cellV) <= N) && (cellU >= 0) && (cellV >= 0) && (cellU < 2 * N) &&
1491  (cellV < 2 * N)) {
1492  double xc = (1.5 * (cellV - N) + 1.0) * Rc;
1493  double yc = (2 * cellU - cellV - N) * rc;
1494  if ((std::abs(yloc - yc) <= rc) && (std::abs(xloc - xc) <= Rc) &&
1495  ((std::abs(xloc - xc) <= 0.5 * Rc) || (std::abs(yloc - yc) <= sqrt3_ * (Rc - std::abs(xloc - xc))))) {
1496 #ifdef EDM_ML_DEBUG
1497  if (debug)
1498  edm::LogVerbatim("HGCalGeom")
1499  << "cellHex: local " << xc << ":" << yc << " difference " << std::abs(xloc - xc) << ":"
1500  << std::abs(yloc - yc) << ":" << sqrt3_ * (Rc - std::abs(yloc - yc)) << " comparator " << rc << ":"
1501  << Rc << " (u,v) = (" << cellU << "," << cellV << ")";
1502 #endif
1503  found = true;
1504  break;
1505  }
1506  }
1507  }
1508  if (found)
1509  break;
1510  }
1511  if (!found) {
1512  cellU = cu0;
1513  cellV = cv0;
1514  }
1515 }
1516 
1517 std::pair<int, float> HGCalDDDConstants::getIndex(int lay, bool reco) const {
1518  int indx = layerIndex(lay, reco);
1519  if (indx < 0)
1520  return std::make_pair(-1, 0);
1521  float cell(0);
1522  if (waferHexagon6()) {
1523  cell = (reco ? hgpar_->moduleCellR_[0] : hgpar_->moduleCellS_[0]);
1524  } else {
1525  if (waferHexagon8()) {
1526  cell = (reco ? hgpar_->moduleCellR_[0] : hgpar_->moduleCellS_[0]);
1527  } else {
1528  cell = hgpar_->scintCellSize(lay);
1529  }
1530  }
1531  return std::make_pair(indx, cell);
1532 }
1533 
1535  int ll(-1);
1536  if (waferHexagon6() && reco) {
1537  ll = static_cast<int>(std::find(hgpar_->depthLayerF_.begin(), hgpar_->depthLayerF_.end(), index) -
1538  hgpar_->depthLayerF_.begin());
1539  if (ll == static_cast<int>(hgpar_->depthLayerF_.size()))
1540  ll = -1;
1541  } else {
1542  ll = static_cast<int>(std::find(hgpar_->layerIndex_.begin(), hgpar_->layerIndex_.end(), index) -
1543  hgpar_->layerIndex_.begin());
1544  if (ll == static_cast<int>(hgpar_->layerIndex_.size()))
1545  ll = -1;
1546  }
1547 #ifdef EDM_ML_DEBUG
1548  edm::LogVerbatim("HGCalGeom") << "LayerFromIndex for " << index << ":" << reco << ":" << waferHexagon6() << " is"
1549  << ll << ":" << (ll + hgpar_->firstLayer_);
1550 #endif
1551  return ((ll < 0) ? ll : (ll + hgpar_->firstLayer_));
1552 }
1553 
1554 bool HGCalDDDConstants::isValidCell(int lay, int wafer, int cell) const {
1555  // Calculate the position of the cell
1556  // Works for options HGCalHexagon/HGCalHexagonFull
1557  double x = hgpar_->waferPosX_[wafer];
1558  double y = hgpar_->waferPosY_[wafer];
1559  if (hgpar_->waferTypeT_[wafer] - 1 == HGCSiliconDetId::HGCalFine) {
1560  x += hgpar_->cellFineX_[cell];
1561  y += hgpar_->cellFineY_[cell];
1562  } else {
1563  x += hgpar_->cellCoarseX_[cell];
1564  y += hgpar_->cellCoarseY_[cell];
1565  }
1566  double rr = sqrt(x * x + y * y);
1567  bool result = ((rr >= hgpar_->rMinLayHex_[lay - 1]) && (rr <= hgpar_->rMaxLayHex_[lay - 1]) &&
1568  (wafer < (int)(hgpar_->waferPosX_.size())));
1569 #ifdef EDM_ML_DEBUG
1570  if (!result)
1571  edm::LogVerbatim("HGCalGeom") << "Input " << lay << ":" << wafer << ":" << cell << " Position " << x << ":" << y
1572  << ":" << rr << " Compare Limits " << hgpar_->rMinLayHex_[lay - 1] << ":"
1573  << hgpar_->rMaxLayHex_[lay - 1] << " Flag " << result;
1574 #endif
1575  return result;
1576 }
1577 
1578 bool HGCalDDDConstants::isValidCell8(int lay, int waferU, int waferV, int cellU, int cellV, int type) const {
1579  float x(0), y(0);
1580  int kndx = cellV * 100 + cellU;
1581  if (type == 0) {
1582  auto ktr = hgpar_->cellFineIndex_.find(kndx);
1583  if (ktr != hgpar_->cellFineIndex_.end()) {
1584  x = hgpar_->cellFineX_[ktr->second];
1585  y = hgpar_->cellFineY_[ktr->second];
1586  }
1587 #ifdef EDM_ML_DEBUG
1588  edm::LogVerbatim("HGCalGeom") << "Fine " << cellU << ":" << cellV << ":" << kndx << ":" << x << ":" << y << ":"
1589  << (ktr != hgpar_->cellFineIndex_.end());
1590 #endif
1591  } else {
1592  auto ktr = hgpar_->cellCoarseIndex_.find(kndx);
1593  if (ktr != hgpar_->cellCoarseIndex_.end()) {
1594  x = hgpar_->cellCoarseX_[ktr->second];
1595  y = hgpar_->cellCoarseY_[ktr->second];
1596  }
1597 #ifdef EDM_ML_DEBUG
1598  edm::LogVerbatim("HGCalGeom") << "Coarse " << cellU << ":" << cellV << ":" << kndx << ":" << x << ":" << y << ":"
1599  << (ktr != hgpar_->cellCoarseIndex_.end());
1600 #endif
1601  }
1602  const auto& xy = waferPosition(lay, waferU, waferV, true, false);
1603  x += xy.first;
1604  y += xy.second;
1605 #ifdef EDM_ML_DEBUG
1606  edm::LogVerbatim("HGCalGeom") << "With wafer (" << waferU << "," << waferV << ") " << x << ":" << y;
1607 #endif
1608  double rr = sqrt(x * x + y * y);
1609  int ll = lay - hgpar_->firstLayer_;
1610  bool result = ((rr >= hgpar_->rMinLayHex_[ll]) && (rr <= hgpar_->rMaxLayHex_[ll]));
1611 #ifdef EDM_ML_DEBUG
1612  edm::LogVerbatim("HGCalGeom") << "Input " << lay << ":" << ll << ":" << waferU << ":" << waferV << ":" << cellU << ":"
1613  << cellV << " Position " << x << ":" << y << ":" << rr << " Compare Limits "
1614  << hgpar_->rMinLayHex_[ll] << ":" << hgpar_->rMaxLayHex_[ll] << " Flag " << result;
1615 #endif
1617  int N = (type == 0) ? hgpar_->nCellsFine_ : hgpar_->nCellsCoarse_;
1618  auto partn = waferTypeRotation(lay, waferU, waferV, false, false);
1619  result = HGCalWaferMask::goodCell(cellU, cellV, N, partn.first, partn.second);
1620 #ifdef EDM_ML_DEBUG
1621  edm::LogVerbatim("HGCalGeom") << "Input " << lay << ":" << waferU << ":" << waferV << ":" << cellU << ":" << cellV
1622  << " N " << N << " part " << partn.first << ":" << partn.second << " Result "
1623  << result;
1624 #endif
1625  }
1626  return result;
1627 }
1628 
1629 int32_t HGCalDDDConstants::waferIndex(int wafer, int index) const {
1630  int layer = layerFromIndex(index, true);
1634 #ifdef EDM_ML_DEBUG
1635  edm::LogVerbatim("HGCalGeom") << "WaferIndex for " << wafer << ":" << index << " (" << layer << ":" << waferU << ":"
1636  << waferV << ") " << indx;
1637 #endif
1638  return indx;
1639 }
1640 
1641 bool HGCalDDDConstants::waferInLayerTest(int wafer, int lay, bool full) const {
1642  bool in = (waferHexagon6()) ? true : false;
1643  if (!in) {
1644  double xpos = hgpar_->waferPosX_[wafer] + hgpar_->xLayerHex_[lay];
1645  double ypos = hgpar_->waferPosY_[wafer] + hgpar_->yLayerHex_[lay];
1646  std::pair<int, int> corner = HGCalGeomTools::waferCorner(
1647  xpos, ypos, rmax_, hexside_, hgpar_->rMinLayHex_[lay], hgpar_->rMaxLayHex_[lay], in);
1648  in = (full ? (corner.first > 0) : (corner.first == (int)(HGCalParameters::k_CornerSize)));
1649  if (in && fullAndPart_) {
1650  int indx = waferIndex(wafer, lay);
1651  in = (hgpar_->waferInfoMap_.find(indx) != hgpar_->waferInfoMap_.end());
1652 #ifdef EDM_ML_DEBUG
1653  if (!in)
1654  edm::LogVerbatim("HGCalGeom") << "WaferInLayerTest: Layer " << lay << " wafer " << wafer << " index " << indx
1655  << "( " << HGCalWaferIndex::waferLayer(indx) << ", "
1656  << HGCalWaferIndex::waferU(indx) << ", " << HGCalWaferIndex::waferV(indx)
1657  << ") in " << in;
1658 #endif
1659  }
1660 #ifdef EDM_ML_DEBUG
1661  edm::LogVerbatim("HGCalGeom") << "WaferInLayerTest: Layer " << lay << " wafer " << wafer << " R-limits "
1662  << hgpar_->rMinLayHex_[lay] << ":" << hgpar_->rMaxLayHex_[lay] << " Corners "
1663  << corner.first << ":" << corner.second << " In " << in;
1664 #endif
1665  }
1666  return in;
1667 }
1668 
1669 std::pair<double, double> HGCalDDDConstants::waferPosition(int waferU, int waferV, bool reco) const {
1670  double xx(0), yy(0);
1671  int indx = HGCalWaferIndex::waferIndex(0, waferU, waferV);
1672  auto itr = hgpar_->wafersInLayers_.find(indx);
1673  if (itr != hgpar_->wafersInLayers_.end()) {
1674  xx = hgpar_->waferPosX_[itr->second];
1675  yy = hgpar_->waferPosY_[itr->second];
1676  }
1677  if (!reco) {
1680  }
1681  return std::make_pair(xx, yy);
1682 }
1683 
1685 
HGCalGeomTools::k_allCorners
static constexpr int k_allCorners
Definition: HGCalGeomTools.h:13
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
DDAxes::y
testProducerWithPsetDescEmpty_cfi.i2
i2
Definition: testProducerWithPsetDescEmpty_cfi.py:46
HGCalDDDConstants::tot_wafers_
int32_t tot_wafers_
Definition: HGCalDDDConstants.h:235
HGCalParameters::cellCoarseHalf_
std::vector< bool > cellCoarseHalf_
Definition: HGCalParameters.h:127
HGCalGeomTools::waferCorner
static std::pair< int32_t, int32_t > waferCorner(double xpos, double ypos, double r, double R, double rMin, double rMax, bool oldBug=false)
Definition: HGCalGeomTools.cc:287
cms::cuda::wmax
__host__ __device__ V V wmax
Definition: HistoContainer.h:85
V0Monitor_cff.v0
v0
Definition: V0Monitor_cff.py:7
mps_fire.i
i
Definition: mps_fire.py:428
geometryCSVtoXML.zz
zz
Definition: geometryCSVtoXML.py:19
HGCalGeometryMode::TrapezoidFile
Definition: HGCalGeometryMode.h:33
HGCalDDDConstants::tan30deg_
constexpr static double tan30deg_
Definition: HGCalDDDConstants.h:230
HGCalParameters::moduleCellS_
std::vector< double > moduleCellS_
Definition: HGCalParameters.h:82
HGCalParameters::firstLayer_
int firstLayer_
Definition: HGCalParameters.h:173
MessageLogger.h
HGCalDDDConstants::getXY
std::pair< double, double > getXY(int layer, double x, double y, bool forwd) const
Definition: HGCalDDDConstants.cc:439
HGCScintillatorDetId.h
HGCalDDDConstants::waferFromPosition
void waferFromPosition(const double x, const double y, int &wafer, int &icell, int &celltyp) const
Definition: HGCalDDDConstants.cc:1089
HGCalDDDConstants::maxWafersPerLayer_
int32_t maxWafersPerLayer_
Definition: HGCalDDDConstants.h:238
HGCalWaferMask::goodCell
static bool goodCell(int u, int v, int N, int type, int rotn)
Definition: HGCalWaferMask.cc:108
HGCalDDDConstants::cellHex
int cellHex(double xx, double yy, const double &cellR, const std::vector< double > &posX, const std::vector< double > &posY) const
Definition: HGCalDDDConstants.cc:1448
HGCalDDDConstants::rangeZ
std::pair< double, double > rangeZ(bool reco) const
Definition: HGCalDDDConstants.cc:1011
HGCalDDDConstants::sqrt3_
const double sqrt3_
Definition: HGCalDDDConstants.h:231
HGCalDDDConstants::modulesInit
int modulesInit(int lay, bool reco) const
Definition: HGCalDDDConstants.cc:881
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
HGCalParameters::zLayerHex_
std::vector< double > zLayerHex_
Definition: HGCalParameters.h:112
HGCalDDDConstants::waferIn_
std::unordered_map< int32_t, bool > waferIn_
Definition: HGCalDDDConstants.h:241
detailsBasic3DVector::z
float float float z
Definition: extBasic3DVector.h:14
HGCalDDDConstants::isValidCell
bool isValidCell(int layindex, int wafer, int cell) const
Definition: HGCalDDDConstants.cc:1554
LaserClient_cfi.wl
wl
Definition: LaserClient_cfi.py:46
HGCalParameters::moduleCellR_
std::vector< double > moduleCellR_
Definition: HGCalParameters.h:89
HGCalParameters::zFrontMin_
std::vector< double > zFrontMin_
Definition: HGCalParameters.h:139
HGCalDDDConstants::locateCellTrap
std::pair< float, float > locateCellTrap(int lay, int ieta, int iphi, bool reco) const
Definition: HGCalDDDConstants.cc:734
HGCalParameters::getModule
hgtrap getModule(unsigned int k, bool reco) const
Definition: HGCalParameters.cc:35
min
T min(T a, T b)
Definition: MathUtil.h:58
HGCalDDDConstants::isValidHex
bool isValidHex(int lay, int mod, int cell, bool reco) const
Definition: HGCalDDDConstants.cc:460
ecaldqm::zside
int zside(DetId const &)
Definition: EcalDQMCommonUtils.cc:189
HGCalWaferMask.h
findQualityFiles.rr
string rr
Definition: findQualityFiles.py:185
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
HGCalParameters::rMaxLayHex_
std::vector< double > rMaxLayHex_
Definition: HGCalParameters.h:114
HGCalParameters::cellFineY_
std::vector< double > cellFineY_
Definition: HGCalParameters.h:121
HFNoseDetId::layer
int layer() const
get the layer #
Definition: HFNoseDetId.h:56
HGCalGeometryMode.h
HGCalDDDConstants::cellEtaPhiTrap
std::pair< double, double > cellEtaPhiTrap(int type, int irad) const
Definition: HGCalDDDConstants.cc:194
DetId::det
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
mod
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
cuy.col
col
Definition: cuy.py:1009
HGCalDDDConstants::rangeRLayer
std::pair< double, double > rangeRLayer(int lay, bool reco) const
Definition: HGCalDDDConstants.cc:993
HGCalDDDConstants::waferZ
double waferZ(int layer, bool reco) const
Definition: HGCalDDDConstants.cc:1412
HGCalDDDConstants::getREtaRange
std::pair< int, int > getREtaRange(int lay) const
Definition: HGCalDDDConstants.cc:401
HGCalParameters::k_CornerSize
static constexpr uint32_t k_CornerSize
Definition: HGCalParameters.h:44
testProducerWithPsetDescEmpty_cfi.i1
i1
Definition: testProducerWithPsetDescEmpty_cfi.py:45
HGCSiliconDetId.h
HGCalTypes::WaferOut
Definition: HGCalTypes.h:79
HGCalWaferIndex::waferU
int32_t waferU(const int32_t index)
Definition: HGCalWaferIndex.cc:27
HGCalDDDConstants::waferHexagon8
bool waferHexagon8() const
Definition: HGCalDDDConstants.h:143
HGCalParameters::slopeTop_
std::vector< double > slopeTop_
Definition: HGCalParameters.h:169
HGCalDDDConstants::waferFullInLayer
bool waferFullInLayer(int wafer, int lay, bool reco) const
Definition: HGCalDDDConstants.cc:1215
HGCalParameters::layerIndex_
std::vector< int > layerIndex_
Definition: HGCalParameters.h:104
HGCalDDDConstants::distFromEdgeTrap
double distFromEdgeTrap(double x, double y, double z) const
Definition: HGCalDDDConstants.cc:326
HGCalWaferIndex::waferIndex
int32_t waferIndex(int32_t layer, int32_t waferU, int32_t waferV, bool old=false)
Definition: HGCalWaferIndex.cc:4
HGCalTypes::WaferFive
Definition: HGCalTypes.h:59
if
if(0==first)
Definition: CAHitNtupletGeneratorKernelsImpl.h:58
cells
const caConstants::TupleMultiplicity const CAHitNtupletGeneratorKernelsGPU::HitToTuple cms::cuda::AtomicPairCounter const GPUCACell *__restrict__ cells
Definition: CAHitNtupletGeneratorKernelsImpl.h:43
typelookup.h
HGCalParameters::yLayerHex_
std::vector< double > yLayerHex_
Definition: HGCalParameters.h:111
HGCalParameters::scintCellSize
double scintCellSize(const int layer) const
Definition: HGCalParameters.h:67
HGCalTypes::CellType::TopLeftEdge
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
HGCalParameters::nCellsCoarse_
int nCellsCoarse_
Definition: HGCalParameters.h:143
HGCalParameters::wafersInLayers_
wafer_map wafersInLayers_
Definition: HGCalParameters.h:179
HGCalParameters::waferSize_
double waferSize_
Definition: HGCalParameters.h:144
HGCalTypes::WaferCornerMin
static constexpr int32_t WaferCornerMin
Definition: HGCalTypes.h:90
HGCalGeomTools::shiftXY
std::pair< double, double > shiftXY(int waferPosition, double waferSize) const
Definition: HGCalGeomTools.cc:234
full
Definition: GenABIO.cc:168
DDAxes::x
HFNoseDetId.h
HGCalDDDConstants::assignCellHex
std::array< int, 5 > assignCellHex(float x, float y, int lay, bool reco) const
Definition: HGCalDDDConstants.cc:160
HGCalGeometryMode::Hexagon8Module
Definition: HGCalGeometryMode.h:34
HGCalDDDConstants::getPhiBins
int getPhiBins(int lay) const
Definition: HGCalDDDConstants.cc:399
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
geant_units::operators
Definition: GeantUnits.h:18
findQualityFiles.v
v
Definition: findQualityFiles.py:179
HGCalParameters::moduleLayR_
std::vector< int > moduleLayR_
Definition: HGCalParameters.h:83
HGCalDDDConstants::getTypeHex
int getTypeHex(int layer, int waferU, int waferV) const
Definition: HGCalDDDConstants.cc:429
HGCalDDDConstants::isHalfCell
bool isHalfCell(int waferType, int cell) const
Definition: HGCalDDDConstants.cc:454
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
HGCalParameters::waferUVMaxLayer_
std::vector< int > waferUVMaxLayer_
Definition: HGCalParameters.h:149
HFNoseDetId
Definition: HFNoseDetId.h:22
HGCalParameters::iradMaxBH_
std::vector< int > iradMaxBH_
Definition: HGCalParameters.h:165
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
HGCalDDDConstants::waferParameters
std::pair< double, double > waferParameters(bool reco) const
Definition: HGCalDDDConstants.cc:1222
HGCalTypes::CellType::TopRightEdge
HGCalDDDConstants::lastLayer
int lastLayer(bool reco) const
Definition: HGCalDDDConstants.cc:575
SiStripMonitorCluster_cfi.zmin
zmin
Definition: SiStripMonitorCluster_cfi.py:200
HGCalTypes::CellType::UndefinedType
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
HGCSiliconDetId
Definition: HGCSiliconDetId.h:22
python.cmstools.all
def all(container)
workaround iterator generators for ROOT classes
Definition: cmstools.py:25
HGCalDDDConstants::max_modules_layer_
Simrecovecs max_modules_layer_
Definition: HGCalDDDConstants.h:237
HGCSiliconDetId::HGCalCoarseThick
Definition: HGCSiliconDetId.h:24
HGCalDDDConstants::geomTools_
HGCalGeomTools geomTools_
Definition: HGCalDDDConstants.h:224
HGCalDDDConstants
Definition: HGCalDDDConstants.h:27
HGCalParameters::waferPosY_
std::vector< double > waferPosY_
Definition: HGCalParameters.h:119
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
HGCalDDDConstants::layerFromIndex
int layerFromIndex(int index, bool reco) const
Definition: HGCalDDDConstants.cc:1534
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
HGCalParameters::sensorSeparation_
double sensorSeparation_
Definition: HGCalParameters.h:146
HFNoseDetId::waferU
int waferU() const
Definition: HFNoseDetId.h:75
DetId
Definition: DetId.h:17
HGCalDDDConstants::waferTypeRotation
std::pair< int, int > waferTypeRotation(int layer, int waferU, int waferV, bool fromFile=false, bool debug=false) const
Definition: HGCalDDDConstants.cc:1353
HGCalDDDConstants::isValidHex8
bool isValidHex8(int lay, int waferU, int waferV, bool fullAndPart=false) const
Definition: HGCalDDDConstants.cc:502
nphi
const int nphi
Definition: CMTRawAnalyzer.h:424
HGCalTypes::CellType::BottomCorner
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
HGCalDDDConstants::waferType
int waferType(DetId const &id, bool fromFile=false) const
Definition: HGCalDDDConstants.cc:1267
HGCalDDDConstants::waferHexagon6
bool waferHexagon6() const
Definition: HGCalDDDConstants.h:140
testProducerWithPsetDescEmpty_cfi.y1
y1
Definition: testProducerWithPsetDescEmpty_cfi.py:29
debug
#define debug
Definition: HDRShower.cc:19
part
part
Definition: HCALResponse.h:20
HGCalParameters::trformIndex_
std::vector< uint32_t > trformIndex_
Definition: HGCalParameters.h:90
HGCalDDDConstants::simToReco
std::pair< int, int > simToReco(int cell, int layer, int mod, bool half) const
Definition: HGCalDDDConstants.cc:1035
HGCalDDDConstants::isValidCell8
bool isValidCell8(int lay, int waferU, int waferV, int cellU, int cellV, int type) const
Definition: HGCalDDDConstants.cc:1578
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
HGCalDDDConstants::mode_
HGCalGeometryMode::GeometryMode mode_
Definition: HGCalDDDConstants.h:233
HGCalWaferIndex.h
trackingPlots.hp
hp
Definition: trackingPlots.py:1231
HGCalParameters::radiusLayer_
std::vector< double > radiusLayer_[2]
Definition: HGCalParameters.h:163
HGCalParameters::cellFineHalf_
std::vector< bool > cellFineHalf_
Definition: HGCalParameters.h:123
HGCalDDDConstants::maxCells
int maxCells(bool reco) const
Definition: HGCalDDDConstants.cc:804
SiStripMonitorCluster_cfi.zmax
zmax
Definition: SiStripMonitorCluster_cfi.py:201
HGCalParameters::layerGroup_
std::vector< int > layerGroup_
Definition: HGCalParameters.h:105
HGCalParameters::layerRotV_
std::vector< std::pair< double, double > > layerRotV_
Definition: HGCalParameters.h:185
HGCalParameters::radiusMixBoundary_
std::vector< double > radiusMixBoundary_
Definition: HGCalParameters.h:159
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
HGCalParameters::waferPosX_
std::vector< double > waferPosX_
Definition: HGCalParameters.h:118
HGCalDDDConstants::waferInLayer
bool waferInLayer(int wafer, int lay, bool reco) const
Definition: HGCalDDDConstants.cc:1208
HGCalParameters::waferUVMax_
int waferUVMax_
Definition: HGCalParameters.h:148
DDAxes::z
HGCalDDDConstants::HGCalDDDConstants
HGCalDDDConstants(const HGCalParameters *hp, const std::string &name)
Definition: HGCalDDDConstants.cc:25
HGCalWaferType.h
HGCalDDDConstants::layerIndex
int layerIndex(int lay, bool reco) const
Definition: HGCalDDDConstants.cc:579
N
#define N
Definition: blowfish.cc:9
HGCalTypes::WaferFull
Definition: HGCalTypes.h:58
HGCalWaferIndex::waferV
int32_t waferV(const int32_t index)
Definition: HGCalWaferIndex.cc:32
HGCalParameters::rMinLayHex_
std::vector< double > rMinLayHex_
Definition: HGCalParameters.h:113
RecoTauValidation_cfi.posX
posX
Definition: RecoTauValidation_cfi.py:287
HGCalWaferType::getType
int getType(double xpos, double ypos, double zpos)
Definition: HGCalWaferType.cc:36
HGCalDDDConstants::waferFileSize
unsigned int waferFileSize() const
Definition: HGCalDDDConstants.h:155
HGCalDDDConstants::wafers
int wafers() const
Definition: HGCalDDDConstants.cc:1420
HGCalTypes::CellType
CellType
Definition: HGCalTypes.h:12
HGCalParameters::typesInLayers_
wafer_map typesInLayers_
Definition: HGCalParameters.h:180
HGCalParameters::getTrForm
hgtrform getTrForm(unsigned int k) const
Definition: HGCalParameters.cc:108
dqmdumpme.k
k
Definition: dqmdumpme.py:60
callgraph.n2
n2
Definition: callgraph.py:50
HGCalParameters::waferCopy_
std::vector< int > waferCopy_
Definition: HGCalParameters.h:115
HGCalDDDConstants::rangeR
std::pair< double, double > rangeR(double z, bool reco) const
Definition: HGCalDDDConstants.cc:966
LEDCalibrationChannels.depth
depth
Definition: LEDCalibrationChannels.py:65
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:125
HGCalParameters::iradMinBH_
std::vector< int > iradMinBH_
Definition: HGCalParameters.h:164
HGCalDDDConstants::assignCell
std::pair< int, int > assignCell(float x, float y, int lay, int subSec, bool reco) const
Definition: HGCalDDDConstants.cc:120
geometryCSVtoXML.xy
xy
Definition: geometryCSVtoXML.py:19
HGCalTypes::getUnpackedU
static int32_t getUnpackedU(int id)
Definition: HGCalTypes.cc:16
HGCSiliconDetId::HGCalFine
Definition: HGCSiliconDetId.h:24
HGCalDDDConstants::mouseBite
double mouseBite(bool reco) const
Definition: HGCalDDDConstants.cc:897
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
HGCalParameters::cellSize_
std::vector< double > cellSize_
Definition: HGCalParameters.h:75
HGCalDDDConstants::tileTrapezoid
bool tileTrapezoid() const
Definition: HGCalDDDConstants.h:113
HGCalParameters::mouseBite_
double mouseBite_
Definition: HGCalParameters.h:147
HGCalDDDConstants::cellInLayer
bool cellInLayer(int waferU, int waferV, int cellU, int cellV, int lay, bool reco) const
Definition: HGCalDDDConstants.cc:204
HGCalParameters::nCellsFine_
int nCellsFine_
Definition: HGCalParameters.h:142
HGCalParameters::firstModule_
std::vector< int > firstModule_
Definition: HGCalParameters.h:167
pfDeepBoostedJetPreprocessParams_cfi.lower_bound
lower_bound
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:15
HGCalDDDConstants::hexside_
double hexside_
Definition: HGCalDDDConstants.h:232
HFNoseDetId::type
int type() const
get the type
Definition: HFNoseDetId.h:50
HGCalDDDConstants::waferLayer_
std::map< int, HGCWaferParam > waferLayer_
Definition: HGCalDDDConstants.h:239
HGCalDDDConstants::modHalf_
int32_t modHalf_
Definition: HGCalDDDConstants.h:235
HGCalDDDConstants::numberCells
int numberCells(bool reco) const
Definition: HGCalDDDConstants.cc:901
HGCalParameters::depth_
std::vector< int > depth_
Definition: HGCalParameters.h:107
HGCalGeometryMode::TrapezoidModule
Definition: HGCalGeometryMode.h:35
HGCalParameters::rMaxFront_
std::vector< double > rMaxFront_
Definition: HGCalParameters.h:171
geometryCSVtoXML.yy
yy
Definition: geometryCSVtoXML.py:19
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
HGCalParameters::cellFineIndex_
wafer_map cellFineIndex_
Definition: HGCalParameters.h:122
HGCalDDDConstants::getIndex
std::pair< int, float > getIndex(int lay, bool reco) const
Definition: HGCalDDDConstants.cc:1517
HGCalParameters::mode_
HGCalGeometryMode::GeometryMode mode_
Definition: HGCalParameters.h:137
GeantUnits.h
type
type
Definition: SiPixelVCal_PayloadInspector.cc:39
HGCalParameters::cellCoarseY_
std::vector< double > cellCoarseY_
Definition: HGCalParameters.h:125
recoMuon::in
Definition: RecoMuonEnumerators.h:6
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:40
HGCalTypes::getUnpackedV
static int32_t getUnpackedV(int id)
Definition: HGCalTypes.cc:22
HGCalWaferMask::k_OffsetRotation
static constexpr int k_OffsetRotation
Definition: HGCalWaferMask.h:37
HGCalDDDConstants::layers
unsigned int layers(bool reco) const
Definition: HGCalDDDConstants.cc:577
HGCalParameters::scintType
int scintType(const int layer) const
Definition: HGCalParameters.h:68
createfilelist.int
int
Definition: createfilelist.py:10
cms::cuda::wmin
__host__ __device__ V wmin
Definition: HistoContainer.h:85
HGCalParameters::scintCells
int scintCells(const int layer) const
Definition: HGCalParameters.h:66
HGCalParameters::layerGroupO_
std::vector< int > layerGroupO_
Definition: HGCalParameters.h:129
HGCalDDDConstants::getTrForms
std::vector< HGCalParameters::hgtrform > getTrForms() const
Definition: HGCalDDDConstants.cc:413
HGCalDDDConstants::getTypeTrap
int getTypeTrap(int layer) const
Definition: HGCalDDDConstants.cc:420
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
HGCalTypes::CellType::TopLeftCorner
HGCalDDDConstants::cellSizeHex
double cellSizeHex(int type) const
Definition: HGCalDDDConstants.cc:233
HGCalTypes::CellType::LeftEdge
PVValHelper::dy
Definition: PVValidationHelpers.h:50
HGCalParameters::layerGroupM_
std::vector< int > layerGroupM_
Definition: HGCalParameters.h:128
HGCalDDDConstants::cellThickness
double cellThickness(int layer, int waferU, int waferV) const
Definition: HGCalDDDConstants.cc:220
HGCalDDDConstants::sectors
int sectors() const
Definition: HGCalDDDConstants.h:110
HGCalParameters::waferR_
double waferR_
Definition: HGCalParameters.h:134
HGCalDDDConstants::isValidTrap
bool isValidTrap(int lay, int ieta, int iphi) const
Definition: HGCalDDDConstants.cc:566
HGCalDDDConstants::getUVMax
int getUVMax(int type) const
Definition: HGCalDDDConstants.h:72
HGCalGeomTools::k_fiveCorners
static constexpr int k_fiveCorners
Definition: HGCalGeomTools.h:14
TYPELOOKUP_DATA_REG
#define TYPELOOKUP_DATA_REG(_dataclass_)
Definition: typelookup.h:102
HGCalTypes::WaferHalf
Definition: HGCalTypes.h:62
HGCalParameters::waferThick_
double waferThick_
Definition: HGCalParameters.h:145
HGCalDDDConstants::rmax_
double rmax_
Definition: HGCalDDDConstants.h:232
HGCalParameters::hgtrform::lay
int lay
Definition: HGCalParameters.h:53
HGCalTypes::CellType::TopCorner
HGCalDDDConstants::rowColumnWafer
std::pair< int, int > rowColumnWafer(const int wafer) const
Definition: HGCalDDDConstants.cc:1024
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HGCalDDDConstants::waferVirtual
bool waferVirtual(int layer, int waferU, int waferV) const
Definition: HGCalDDDConstants.cc:1400
HGCalDDDConstants::getTrForm
HGCalParameters::hgtrform getTrForm(unsigned int k) const
Definition: HGCalDDDConstants.h:66
EgammaValidation_cff.num
num
Definition: EgammaValidation_cff.py:33
HGCalDDDConstants::getModules
std::vector< HGCalParameters::hgtrap > getModules() const
Definition: HGCalDDDConstants.cc:392
HGCalParameters::k_ScaleFromDDD
static constexpr double k_ScaleFromDDD
Definition: HGCalParameters.h:36
HGCalParameters::waferTypeT_
std::vector< int > waferTypeT_
Definition: HGCalParameters.h:117
HGCalDDDConstants::waferMax_
std::array< int, 4 > waferMax_
Definition: HGCalDDDConstants.h:240
HGCalTypes::CellType::BottomRightCorner
alignCSCRings.r
r
Definition: alignCSCRings.py:93
HGCalDDDConstants::tot_layers_
std::array< uint32_t, 2 > tot_layers_
Definition: HGCalDDDConstants.h:236
HGCalDDDConstants::numberCellsHexagon
int numberCellsHexagon(int wafer) const
Definition: HGCalDDDConstants.cc:944
HGCalParameters
Definition: HGCalParameters.h:14
HGCalDDDConstants::assignCellTrap
std::array< int, 3 > assignCellTrap(float x, float y, float z, int lay, bool reco) const
Definition: HGCalDDDConstants.cc:171
HGCalParameters::k_ScaleToDDD
static constexpr double k_ScaleToDDD
Definition: HGCalParameters.h:37
DDAxes::phi
HGCalDetId
Definition: HGCalDetId.h:8
HGCalGeomTools.h
HGCalWaferIndex::waferLayer
int32_t waferLayer(const int32_t index)
Definition: HGCalWaferIndex.cc:23
HGCalGeomTools::radius
static void radius(double zf, double zb, std::vector< double > const &zFront1, std::vector< double > const &rFront1, std::vector< double > const &slope1, std::vector< double > const &zFront2, std::vector< double > const &rFront2, std::vector< double > const &slope2, int flag, std::vector< double > &zz, std::vector< double > &rin, std::vector< double > &rout)
Definition: HGCalGeomTools.cc:12
HGCalParameters::detectorType_
int detectorType_
Definition: HGCalParameters.h:72
HGCalDetId.h
HGCalDDDConstants::cellType
HGCalTypes::CellType cellType(int type, int waferU, int waferV) const
Definition: HGCalDDDConstants.cc:240
std
Definition: JetResolutionObject.h:76
HGCalParameters::waferMaskMode_
int waferMaskMode_
Definition: HGCalParameters.h:182
HGCalDDDConstants::locateCellHex
std::pair< float, float > locateCellHex(int cell, int wafer, bool reco) const
Definition: HGCalDDDConstants.cc:718
HGCalTypes::CellType::BottomLeftCorner
HGCalParameters::waferInfoMap_
waferInfo_map waferInfoMap_
Definition: HGCalParameters.h:184
edm::shift
static unsigned const int shift
Definition: LuminosityBlockID.cc:7
hgcalPerformanceValidation.df
df
Definition: hgcalPerformanceValidation.py:733
HGCalParameters::slopeMin_
std::vector< double > slopeMin_
Definition: HGCalParameters.h:138
HGCalParameters::depthIndex_
std::vector< int > depthIndex_
Definition: HGCalParameters.h:108
hgcalPerformanceValidation.orient
orient
Definition: hgcalPerformanceValidation.py:733
HGCalParameters::defineFull_
bool defineFull_
Definition: HGCalParameters.h:150
HGCalParameters::xLayerHex_
std::vector< double > xLayerHex_
Definition: HGCalParameters.h:110
HGCalTypes::CellType::RightEdge
diffTwoXMLs.r1
r1
Definition: diffTwoXMLs.py:53
HGCScintillatorDetId
Definition: HGCScintillatorDetId.h:23
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
HGCalParameters::waferTypes_
waferT_map waferTypes_
Definition: HGCalParameters.h:181
HGCalTypes::CellType::BottomRightEdge
HGCalDDDConstants::waferPosition
std::pair< double, double > waferPosition(int wafer, bool reco) const
Definition: HGCalDDDConstants.cc:1229
TrackerOfflineValidation_Dqm_cff.xmax
xmax
Definition: TrackerOfflineValidation_Dqm_cff.py:11
dt_dqm_sourceclient_common_cff.reco
reco
Definition: dt_dqm_sourceclient_common_cff.py:111
flavorHistoryFilter_cfi.dr
dr
Definition: flavorHistoryFilter_cfi.py:37
genVertex_cff.x
x
Definition: genVertex_cff.py:13
HGCalParameters::layerCenter_
std::vector< int > layerCenter_
Definition: HGCalParameters.h:178
HGCalParameters::rMinFront_
std::vector< double > rMinFront_
Definition: HGCalParameters.h:140
HGCalDDDConstants::maxRows
int maxRows(int lay, bool reco) const
Definition: HGCalDDDConstants.cc:849
detailsBasic3DVector::y
float float y
Definition: extBasic3DVector.h:14
HGCalGeometryMode::Hexagon8File
Definition: HGCalGeometryMode.h:32
HGCalParameters::lastModule_
std::vector< int > lastModule_
Definition: HGCalParameters.h:168
HGCalDDDConstants::modules
int modules(int lay, bool reco) const
Definition: HGCalDDDConstants.cc:874
HGCSiliconDetId::type
int type() const
get the type
Definition: HGCSiliconDetId.h:51
HGCalParameters::cellFineX_
std::vector< double > cellFineX_
Definition: HGCalParameters.h:120
HGCSiliconDetId::waferU
int waferU() const
Definition: HGCSiliconDetId.h:76
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
HGCalDDDConstants::distFromEdgeHex
double distFromEdgeHex(double x, double y, double z) const
Definition: HGCalDDDConstants.cc:280
TCMET_cfi.corner
corner
Definition: TCMET_cfi.py:34
Exception.h
HGCalParameters::cellThickness_
std::vector< double > cellThickness_
Definition: HGCalParameters.h:152
HGCalTypes::WaferThree
Definition: HGCalTypes.h:65
HGCalParameters::firstMixedLayer_
int firstMixedLayer_
Definition: HGCalParameters.h:174
HGCalDDDConstants::getLayer
int getLayer(double z, bool reco) const
Definition: HGCalDDDConstants.cc:356
HGCalTypes::CellType::CentralType
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
HGCalDDDConstants::waferTypeL
int waferTypeL(int wafer) const
Definition: HGCalDDDConstants.h:197
HGCalParameters::waferTypeL_
std::vector< int > waferTypeL_
Definition: HGCalParameters.h:116
HGCalParameters::cellCoarseX_
std::vector< double > cellCoarseX_
Definition: HGCalParameters.h:124
HGCalDDDConstants::~HGCalDDDConstants
~HGCalDDDConstants()
Definition: HGCalDDDConstants.cc:118
mps_fire.result
result
Definition: mps_fire.py:311
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
HGCalDDDConstants.h
HGCalParameters::layer_
std::vector< int > layer_
Definition: HGCalParameters.h:103
HGCalDDDConstants::getTrFormN
unsigned int getTrFormN() const
Definition: HGCalDDDConstants.h:67
HFNoseDetId::waferV
int waferV() const
Definition: HFNoseDetId.h:78
HGCalDDDConstants::fullAndPart_
bool fullAndPart_
Definition: HGCalDDDConstants.h:234
HGCalDDDConstants::layersInit
unsigned int layersInit(bool reco) const
Definition: HGCalDDDConstants.cc:592
HGCalDDDConstants::locateCell
std::pair< float, float > locateCell(int cell, int lay, int type, bool reco) const
Definition: HGCalDDDConstants.cc:596
HGCalParameters::cellCoarseIndex_
wafer_map cellCoarseIndex_
Definition: HGCalParameters.h:126
DetId::Forward
Definition: DetId.h:30
HGCalParameters::depthLayerF_
std::vector< int > depthLayerF_
Definition: HGCalParameters.h:109
HGCalTypes.h
HGCalDDDConstants::waferIndex
int32_t waferIndex(int wafer, int index) const
Definition: HGCalDDDConstants.cc:1629
HGCalParameters::zFrontTop_
std::vector< double > zFrontTop_
Definition: HGCalParameters.h:170
HGCalParameters::hgtrap
Definition: HGCalParameters.h:47
edm::Log
Definition: MessageLogger.h:70
HGCalDDDConstants::modifyUV
int modifyUV(int uv, int type1, int type2) const
Definition: HGCalDDDConstants.cc:869
dttmaxenums::R
Definition: DTTMax.h:29
HGCalDDDConstants::waferFromCopy
int waferFromCopy(int copy) const
Definition: HGCalDDDConstants.cc:1064
TauDecayModes.dec
dec
Definition: TauDecayModes.py:142
HGCalGeomTools::k_fourCorners
static constexpr int k_fourCorners
Definition: HGCalGeomTools.h:15
PVValHelper::dx
Definition: PVValidationHelpers.h:49
HGCalDDDConstants::hgpar_
const HGCalParameters * hgpar_
Definition: HGCalDDDConstants.h:229
HGCalDDDConstants::maskCell
bool maskCell(const DetId &id, int corners) const
Definition: HGCalDDDConstants.cc:764
HGCalWaferMask::maskCell
static bool maskCell(int u, int v, int N, int ncor, int fcor, int corners)
Definition: HGCalWaferMask.cc:11
HGCalTypes::CellType::BottomLeftEdge
geometryCSVtoXML.xx
xx
Definition: geometryCSVtoXML.py:19
RecoTauValidation_cfi.posY
posY
Definition: RecoTauValidation_cfi.py:288
HGCalDDDConstants::HGCWaferParam
std::array< int, 3 > HGCWaferParam
Definition: HGCalDDDConstants.h:228
HGCSiliconDetId::waferV
int waferV() const
Definition: HGCSiliconDetId.h:77
HGCalDDDConstants::waferInLayerTest
bool waferInLayerTest(int wafer, int lay, bool full) const
Definition: HGCalDDDConstants.cc:1641
HGCalGeomTools::k_threeCorners
static constexpr int k_threeCorners
Definition: HGCalGeomTools.h:16
RemoveAddSevLevel.flag
flag
Definition: RemoveAddSevLevel.py:117
HGCalTypes::CellType::TopRightCorner
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
HGCSiliconDetId::layer
int layer() const
get the layer #
Definition: HGCSiliconDetId.h:57
HGCalTypes::WaferCorner0
Definition: HGCalTypes.h:30
HGCalDDDConstants::getModule
HGCalParameters::hgtrap getModule(unsigned int k, bool hexType, bool reco) const
Definition: HGCalDDDConstants.cc:376
HGCalParameters::copiesInLayers_
layer_map copiesInLayers_
Definition: HGCalParameters.h:141