File indexing completed on 2023-04-28 22:44:53
0001 #include "Geometry/HGCalCommonData/interface/HGCalCalibrationCell.h"
0002 #include "Geometry/HGCalCommonData/interface/HGCalTypes.h"
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004
0005 #include <algorithm>
0006 #include <sstream>
0007
0008
0009
0010 HGCalCalibrationCell::HGCalCalibrationCell(const HGCalDDDConstants* cons) : cons_(cons) {
0011 wafer_ = std::make_unique<HGCalCell>(
0012 cons_->getParameter()->waferSize_, cons_->getParameter()->nCellsFine_, cons_->getParameter()->nCellsCoarse_);
0013
0014 radius_[0] = cons_->getParameter()->calibCellRHD_;
0015 cells_[0].insert(
0016 cells_[0].end(), cons_->getParameter()->calibCellFullHD_.begin(), cons_->getParameter()->calibCellFullHD_.end());
0017 cells_[1].insert(
0018 cells_[1].end(), cons_->getParameter()->calibCellPartHD_.begin(), cons_->getParameter()->calibCellPartHD_.end());
0019 radius_[1] = cons_->getParameter()->calibCellRLD_;
0020 cells_[2].insert(
0021 cells_[2].end(), cons_->getParameter()->calibCellFullLD_.begin(), cons_->getParameter()->calibCellFullLD_.end());
0022 cells_[3].insert(
0023 cells_[3].end(), cons_->getParameter()->calibCellPartLD_.begin(), cons_->getParameter()->calibCellPartLD_.end());
0024 for (int k = 0; k < 2; ++k)
0025 radius_[k] *= radius_[k];
0026
0027 #ifdef EDM_ML_DEBUG
0028 edm::LogVerbatim("HGCalGeom") << "HGCalCalibrationCell: " << cells_[0].size() << " HD calibration cells of radius "
0029 << std::sqrt(radius_[0]);
0030 for (unsigned int k = 0; k < cells_[0].size(); ++k)
0031 edm::LogVerbatim("HGCalGeom") << " [" << k << "] " << cells_[0][k] << ":" << cells_[1][k];
0032 edm::LogVerbatim("HGCalGeom") << "HGCalCalibrationCell: " << cells_[2].size() << " LD calibration cells of radius "
0033 << std::sqrt(radius_[1]);
0034 for (unsigned int k = 0; k < cells_[2].size(); ++k)
0035 edm::LogVerbatim("HGCalGeom") << " [" << k << "] " << cells_[2][k] << ":" << cells_[3][k];
0036 #endif
0037 }
0038
0039 int HGCalCalibrationCell::findCell(
0040 int zside, int layer, int waferU, int waferV, int cellUV, const std::pair<double, double>& xy) const {
0041 const auto& info = cons_->waferInfo(layer, waferU, waferV);
0042 int ld = (info.type == HGCalTypes::WaferFineThin) ? 1 : 0;
0043 int part = (info.part == HGCalTypes::WaferFull) ? 1 : 0;
0044 int indx = 2 * ld + part;
0045 #ifdef EDM_ML_DEBUG
0046 std::ostringstream st1;
0047 st1 << "HGCalCalibrationCell::findCell::input " << layer << ":" << waferU << ":" << waferV << ":" << cellUV << ":"
0048 << xy.first << ":" << xy.second << " Type:Part " << info.type << ":" << info.part << ":" << ld << ":" << part
0049 << ":" << indx;
0050 #endif
0051 bool ok = (std::find(cells_[indx].begin(), cells_[indx].end(), cellUV) != cells_[indx].end());
0052 int retval(-1);
0053 if (ok) {
0054 int layertype = (cons_->layerType(layer) == HGCalTypes::WaferCenterB) ? 1 : 0;
0055 int place = HGCalCell::cellPlacementIndex(zside, layertype, info.orient);
0056 int cellU = (cellUV / 100) % 100;
0057 int cellV = cellUV % 100;
0058 auto xyc = wafer_->cellUV2XY1(cellU, cellV, place, (1 - ld));
0059 double xx = xy.first - xyc.first;
0060 double yy = xy.second - xyc.second;
0061 double r2 = (xx * xx + yy * yy);
0062 retval = (r2 > radius_[ld]) ? 0 : 1;
0063 #ifdef EDM_ML_DEBUG
0064 st1 << " layertype:place:cellU:cellV " << layertype << ":" << place << ":" << cellU << ":" << cellV << " xx "
0065 << xy.first << ":" << xyc.first << ":" << xx << " yy " << xy.second << ":" << xyc.second << ":" << yy << " R2 "
0066 << r2 << ":" << radius_[ld];
0067 #endif
0068 }
0069 #ifdef EDM_ML_DEBUG
0070 st1 << " Return Value " << ok << ":" << retval;
0071 edm::LogVerbatim("HGCalGeom") << st1.str();
0072 #endif
0073 return retval;
0074 }