Skip to content

Commit

Permalink
Merge pull request #40668 from bsunanda/Phase2-hgx335P
Browse files Browse the repository at this point in the history
Phase2-hgx335P Take care of invalid HGCal scintillator DetIDs
  • Loading branch information
cmsbuild committed Feb 2, 2023
2 parents 4dd9638 + 3766654 commit 8dd9b3a
Show file tree
Hide file tree
Showing 7 changed files with 407 additions and 19 deletions.
102 changes: 102 additions & 0 deletions Geometry/HGCalCommonData/data/errorScintD88.txt
@@ -0,0 +1,102 @@
10 0 -1 2 1 20 23 289 -168.470 -4.12226e-14
10 0 -1 2 0 13 39 95 110.598 212.458
10 0 -1 1 0 11 33 71 -9.28639 212.693
10 0 -1 1 0 18 3 289 -109.880 -3.66263e-14
10 0 1 1 0 9 30 145 -191.175 -1.36064
10 0 1 2 1 20 19 289 156.967 -3.84581e-14
10 0 1 1 1 12 37 95 -106.270 204.143
10 0 -1 1 0 15 13 289 -135.553 -3.4972e-15
10 0 -1 1 0 10 33 120 178.643 107.735
10 0 1 2 0 13 39 240 116.979 -207.030
10 0 -1 1 0 11 33 263 -177.640 -109.382
10 0 -1 1 0 10 34 263 -183.509 -116.908
10 0 -1 1 0 8 29 218 -5.81286 -191.092
10 0 -1 1 1 17 18 289 -151.626 -3.86968e-14
10 0 -1 1 1 14 19 289 -155.871 -3.74811e-14
10 0 -1 1 1 19 13 289 -136.910 -5.26176e-15
10 0 -1 2 1 19 26 289 -180.933 -4.14335e-14
10 0 1 2 0 13 39 167 -213.155 -110.961
10 0 1 1 0 16 13 289 137.141 -3.35953e-14
10 0 -1 1 0 10 32 289 -208.034 -3.87690e-14
10 0 -1 1 0 11 32 289 -208.556 -3.91423e-14
10 0 -1 1 0 11 32 289 -208.608 -3.91598e-14
10 0 -1 1 0 11 33 288 -208.615 -0.0876511
10 0 -1 1 0 20 6 289 -116.414 -9.54792e-15
10 0 1 1 0 8 28 264 157.818 -95.7662
10 0 1 2 0 13 40 119 -207.219 132.013
10 0 1 2 0 13 40 119 -207.211 132.008
10 0 -1 1 1 14 19 289 -154.363 -3.76588e-14
10 0 -1 1 0 10 33 265 -182.674 -100.749
10 0 -1 1 0 10 34 239 -100.170 -192.425
10 0 -1 1 0 13 17 289 -149.286 -3.65485e-14
10 0 1 1 0 8 29 264 162.485 -98.5982
10 0 1 1 0 14 17 289 149.819 -3.69482e-14
10 0 -1 2 0 13 39 242 -124.803 -202.410
10 0 -1 1 0 9 31 192 102.518 -168.944
10 0 -1 1 0 9 31 23 -177.712 92.5111
10 0 -1 1 0 9 31 23 -177.717 92.5135
10 0 1 2 0 15 31 289 200.734 -4.91829e-14
10 0 1 2 0 15 37 289 228.833 -5.60441e-14
10 0 -1 1 0 8 29 71 -8.49058 194.466
10 0 -1 1 1 12 37 264 -196.587 -114.776
10 0 -1 1 0 11 33 265 -182.212 -101.582
10 0 -1 1 1 12 37 143 229.907 10.0379
10 0 -1 1 0 10 33 121 180.842 104.003
10 0 1 1 0 9 31 23 180.988 94.2162
10 0 1 1 0 10 33 241 104.364 -180.633
10 0 -1 1 0 12 19 289 -155.089 -3.64153e-14
10 0 -1 2 0 15 41 194 115.095 -220.126
10 0 -1 1 0 10 33 169 178.762 -107.538
10 0 -1 1 0 10 31 289 -203.199 -3.84359e-14
10 0 1 1 0 10 20 289 158.044 -3.87135e-14
10 0 1 2 0 14 41 240 121.631 -216.582
10 0 -1 1 1 12 38 287 -236.137 -10.310
10 0 -1 1 0 10 33 25 -180.449 104.682
10 0 1 1 0 11 33 47 114.163 179.201
10 0 1 1 0 9 31 266 175.286 -95.6986
10 0 1 1 1 14 24 289 174.704 -4.27769e-14
10 0 -1 1 1 13 31 289 -200.276 -3.94351e-14
10 0 -1 1 1 12 31 289 -202.017 -3.92492e-14
10 0 -1 1 1 13 32 289 -207.483 -4.01013e-14
10 0 -1 1 1 12 31 289 -200.993 -3.91964e-14
10 0 -1 2 0 17 21 289 -162.277 -3.97904e-14
10 0 1 1 0 9 31 2 199.649 4.85818
10 0 1 2 0 13 39 265 206.104 -118.603
10 0 -1 2 1 16 41 47 -135.697 213.002
10 0 -1 1 0 9 32 95 95.2892 183.049
10 0 -1 2 0 15 30 289 -198.688 -4.05009e-14
10 0 1 1 0 10 34 143 -217.677 9.50397
10 0 -1 1 0 8 30 167 174.845 -91.0186
10 0 1 1 0 11 33 264 179.502 -106.297
10 0 -1 1 0 16 13 289 -135.318 -4.08562e-15
10 0 -1 1 0 10 33 143 209.810 9.16049
10 0 1 1 0 9 31 242 106.144 -169.165
10 0 1 1 1 15 24 289 172.188 -4.21885e-14
10 0 1 1 0 12 15 289 142.800 -3.49748e-14
10 0 1 1 1 13 28 289 188.755 -4.62297e-14
10 0 -1 1 0 19 3 289 -110.767 -3.72147e-14
10 0 -1 1 1 15 26 289 -179.288 -3.93685e-14
10 0 -1 2 0 16 24 289 -172.605 -3.94351e-14
10 0 -1 2 0 15 35 289 -222.079 -4.19664e-14
10 0 -1 1 0 9 31 215 8.73405 -200.043
10 0 1 1 1 14 21 289 162.606 -3.98348e-14
10 0 1 2 0 13 39 191 -126.945 -201.073
10 0 1 2 1 16 36 289 225.529 -5.52387e-14
10 0 1 1 0 8 30 167 -174.609 -90.8958
10 0 1 1 1 13 26 289 179.139 -4.38982e-14
10 0 1 1 1 12 37 192 -117.029 -195.254
10 0 -1 2 1 18 41 119 212.141 135.148
10 0 -1 2 1 18 42 119 216.107 137.675
10 0 -1 2 1 17 41 119 212.015 135.069
10 0 1 1 0 9 32 71 8.93125 204.559
10 0 -1 1 0 10 33 263 -176.125 -112.204
10 0 -1 1 0 10 33 263 -176.871 -110.621
10 0 -1 1 0 10 33 263 -177.471 -109.655
10 0 -1 1 0 11 33 215 9.11779 -208.832
10 0 1 1 1 12 27 289 185.054 -4.52971e-14
10 0 -1 1 0 8 28 241 -92.5733 -157.878
10 0 1 1 0 8 29 119 -162.030 103.225
10 0 1 1 0 10 33 119 -179.204 114.165
10 0 1 1 0 9 30 96 -92.7657 169.090
10 0 1 1 0 9 30 96 -92.7721 169.101
10 0 1 1 0 9 30 96 -92.7572 169.074
7 changes: 5 additions & 2 deletions Geometry/HGCalCommonData/interface/HGCalDDDConstants.h
Expand Up @@ -131,6 +131,8 @@ class HGCalDDDConstants {
int tileCount(int layer, int ring) const;
bool tileExist(int zside, int layer, int ring, int phi) const;
HGCalParameters::tileInfo tileInfo(int zside, int layer, int ring) const;
bool tilePhiEdge(double phi, int layer, int iphi) const;
bool tileRingEdge(double rho, int layer, int ring) const;
std::pair<int, int> tileRings(int layer) const;
inline int tileSiPM(int sipm) const { return ((sipm > 0) ? HGCalTypes::SiPMSmall : HGCalTypes::SiPMLarge); }
bool tileTrapezoid() const {
Expand Down Expand Up @@ -238,12 +240,13 @@ class HGCalDDDConstants {
std::unique_ptr<HGCalCell> hgcell_;
std::unique_ptr<HGCalCellUV> hgcellUV_;
HGCalGeomTools geomTools_;
const double k_horizontalShift = 1.0;
const float dPhiMin = 0.02;
constexpr static double k_horizontalShift = 1.0;
constexpr static float dPhiMin = 0.02;
typedef std::array<std::vector<int32_t>, 2> Simrecovecs;
typedef std::array<int, 3> HGCWaferParam;
const HGCalParameters* hgpar_;
constexpr static double tan30deg_ = 0.5773502693;
constexpr static double tol_ = 0.001;
const double sqrt3_;
const HGCalGeometryMode::GeometryMode mode_;
const bool fullAndPart_;
Expand Down
77 changes: 70 additions & 7 deletions Geometry/HGCalCommonData/src/HGCalDDDConstants.cc
Expand Up @@ -193,8 +193,8 @@ std::array<int, 3> HGCalDDDConstants::assignCellTrap(float x, float y, float z,
int cassette = HGCalTileIndex::tileCassette(iphi, hgpar_->phiOffset_, hgpar_->nphiCassette_, hgpar_->cassettes_);
auto cshift = hgcassette_.getShift(layer, zside, cassette);
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HGCalGeom") << "Cassette " << cassette << " Shift " << -(zside * cshift.first) << ":"
<< cshift.second;
edm::LogVerbatim("HGCalGeomT") << "Cassette " << cassette << " Shift " << -(zside * cshift.first) << ":"
<< cshift.second;
#endif
xx += (zside * cshift.first);
yy -= cshift.second;
Expand All @@ -203,17 +203,51 @@ std::array<int, 3> HGCalDDDConstants::assignCellTrap(float x, float y, float z,
if (phi < 0)
phi += (2.0 * M_PI);
if (indx.second != 0)
iphi = 1 + static_cast<int>(phi / indx.second);
iphi = (1 + static_cast<int>(phi / indx.second)) % hgpar_->scintCells(layer);
if (iphi == 0)
iphi = hgpar_->scintCells(layer);
type = hgpar_->scintType(layer);
double r = std::sqrt(xx * xx + yy * yy);
auto ir = std::lower_bound(hgpar_->radiusLayer_[type].begin(), hgpar_->radiusLayer_[type].end(), r);
irad = static_cast<int>(ir - hgpar_->radiusLayer_[type].begin());
irad = std::clamp(irad, hgpar_->iradMinBH_[indx.first], hgpar_->iradMaxBH_[indx.first]);
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HGCalGeom") << "assignCellTrap Input " << x << ":" << y << ":" << z << ":" << layer << ":" << reco
<< " x|y|r " << xx << ":" << yy << ":" << r << " phi " << phi << ":"
<< convertRadToDeg(phi) << " o/p " << irad << ":" << iphi << ":" << type;
edm::LogVerbatim("HGCalGeomT") << "assignCellTrap Input " << x << ":" << y << ":" << z << ":" << layer << ":" << reco
<< " x|y|r " << xx << ":" << yy << ":" << r << " phi " << phi << ":"
<< convertRadToDeg(phi) << " o/p " << irad << ":" << iphi << ":" << type;
#endif
if (!tileExist(zside, layer, irad, iphi)) {
if (tileRingEdge(r, layer, irad)) {
if (std::abs(r - hgpar_->radiusLayer_[type][irad - 1]) < tol_) {
--irad;
if (irad <= hgpar_->iradMinBH_[indx.first])
irad = hgpar_->iradMinBH_[indx.first];
} else {
++irad;
if (irad > hgpar_->iradMaxBH_[indx.first])
irad = hgpar_->iradMaxBH_[indx.first];
}
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HGCalGeomT") << "assignCellTrap: ring # modified to " << irad << ":"
<< hgpar_->iradMinBH_[indx.first] << ":" << hgpar_->iradMaxBH_[indx.first];
;
#endif
} else if (tilePhiEdge(phi, layer, iphi)) {
if (std::abs(phi - hgpar_->scintCellSize(layer) * (iphi - 1)) < tol_) {
--iphi;
if (iphi <= 0)
iphi = 1;
} else {
++iphi;
if (iphi > hgpar_->scintCells(layer))
iphi = 1;
}
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HGCalGeomT") << "assignCellTrap: iphi # modified to " << iphi << ":"
<< hgpar_->scintCells(layer);
#endif
}
}
return std::array<int, 3>{{irad, iphi, type}};
}

Expand Down Expand Up @@ -665,7 +699,16 @@ bool HGCalDDDConstants::isValidTrap(int zside, int layer, int irad, int iphi) co
return false;
bool ok = ((irad >= hgpar_->iradMinBH_[indx.first]) && (irad <= (hgpar_->iradMaxBH_[indx.first] + 1)) && (iphi > 0) &&
(iphi <= hgpar_->scintCells(layer)));
return ((ok && trapezoidFile()) ? tileExist(zside, layer, irad, iphi) : ok);
bool valid = ((ok && trapezoidFile()) ? tileExist(zside, layer, irad, iphi) : ok);
#ifdef EDM_ML_DEBUG
bool tileEx = trapezoidFile() ? tileExist(zside, layer, irad, iphi) : true;
edm::LogVerbatim("HGCalGeomT") << "HGCalDDDConstants::isValidityTrap: Input " << zside << ":" << layer << ":" << irad
<< ":" << iphi << " Range on Ring " << hgpar_->iradMinBH_[indx.first] << ":"
<< (hgpar_->iradMaxBH_[indx.first] + 1)
<< " Range on phi 0:" << hgpar_->scintCells(layer) << " tileExist " << tileEx
<< " Valid " << ok << ":" << valid;
#endif
return valid;
}

int HGCalDDDConstants::lastLayer(bool reco) const {
Expand Down Expand Up @@ -1267,6 +1310,26 @@ HGCalParameters::tileInfo HGCalDDDConstants::tileInfo(int zside, int layer, int
return ((itr == hgpar_->tileInfoMap_.end()) ? HGCalParameters::tileInfo() : itr->second);
}

bool HGCalDDDConstants::tilePhiEdge(double phi, int layer, int iphi) const {
double dif1 = std::abs(phi - hgpar_->scintCellSize(layer) * (iphi - 1));
double dif2 = std::abs(phi - hgpar_->scintCellSize(layer) * iphi);
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HGCalGeomT") << "HGCalDDDConstants::tilePhiEdge:: input: " << phi << ":" << layer << ":" << iphi
<< " Differences " << dif1 << ":" << dif2;
#endif
return ((dif1 < tol_) || (dif2 < tol_));
}

bool HGCalDDDConstants::tileRingEdge(double r, int layer, int ring) const {
int type = hgpar_->scintType(layer);
double dif1 = std::abs(r - hgpar_->radiusLayer_[type][ring - 1]);
double dif2 = std::abs(r - hgpar_->radiusLayer_[type][ring]);
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HGCalGeomT") << "HGCalDDDConstants::tileRingEdge:: input: " << r << ":" << layer << ":" << ring
<< " Differences " << dif1 << ":" << dif2;
#endif
return ((dif1 < tol_) || (dif2 < tol_));
}
std::pair<int, int> HGCalDDDConstants::tileRings(int layer) const {
if ((mode_ == HGCalGeometryMode::TrapezoidFile) || (mode_ == HGCalGeometryMode::TrapezoidModule) ||
(mode_ == HGCalGeometryMode::TrapezoidCassette)) {
Expand Down
3 changes: 2 additions & 1 deletion Geometry/HGCalCommonData/src/HGCalWaferMask.cc
Expand Up @@ -291,7 +291,8 @@ bool HGCalWaferMask::goodCell(int u, int v, int n, int type, int rotn) {
break;
}
default: {
good = ((u - 2 * v) >= 0);
int uv = u - 2 * v;
good = (uv >= 0);
break;
}
}
Expand Down

0 comments on commit 8dd9b3a

Please sign in to comment.