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