From 6f7800dd5037ce46231d8afaf2954142e273bff4 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Thu, 2 Jul 2020 19:49:01 +0200 Subject: [PATCH] Backport #30323 #30413 #30425 --- .../CaloTopology/interface/HGCalTopology.h | 2 + Geometry/CaloTopology/src/HGCalTopology.cc | 55 ++- .../data/hgcalCons/v10/hgcalCons.xml | 3 +- .../data/hgcalCons/v11/hgcalCons.xml | 3 +- .../data/hgcalCons/v11m/hgcalCons.xml | 5 +- .../data/hgcalCons/v12/hgcalCons.xml | 5 +- .../data/hgcalCons/v9/hgcalCons.xml | 3 +- .../interface/HGCalDDDConstants.h | 63 ++-- .../interface/HGCalGeomParameters.h | 13 +- .../interface/HGCalGeomTools.h | 32 +- .../interface/HGCalParameters.h | 15 + .../interface/HGCalParametersFromDD.h | 1 + .../interface/HGCalTileIndex.h | 25 ++ .../HGCalCommonData/interface/HGCalTypes.h | 68 ++++ .../interface/HGCalWaferMask.h | 5 +- .../plugins/HGCalNumberingInitialization.cc | 2 +- .../python/testHGCalV11XML_cfi.py | 1 - .../python/testHGCalV12XML_cfi.py | 1 - .../HGCalCommonData/src/HGCalDDDConstants.cc | 250 ++++++++++++-- .../src/HGCalGeomParameters.cc | 188 ++++++++++- .../HGCalCommonData/src/HGCalGeomTools.cc | 11 +- .../src/HGCalParametersFromDD.cc | 22 +- .../HGCalCommonData/src/HGCalTileIndex.cc | 14 + .../HGCalCommonData/src/HGCalWaferMask.cc | 315 +++++++++--------- .../HGCalCommonData/src/HGCalWaferType.cc | 21 +- .../test/HGCalNumberingTester.cc | 13 +- .../test/HGCalParameterTester.cc | 79 ++++- .../HGCalGeometry/interface/HGCalGeometry.h | 1 + .../plugins/HGCalGeometryESProducer.cc | 13 +- Geometry/HGCalGeometry/src/HGCalGeometry.cc | 20 ++ 30 files changed, 925 insertions(+), 324 deletions(-) create mode 100644 Geometry/HGCalCommonData/interface/HGCalTileIndex.h create mode 100644 Geometry/HGCalCommonData/interface/HGCalTypes.h create mode 100644 Geometry/HGCalCommonData/src/HGCalTileIndex.cc diff --git a/Geometry/CaloTopology/interface/HGCalTopology.h b/Geometry/CaloTopology/interface/HGCalTopology.h index 6cda2a63c7a73..44881c34301d9 100644 --- a/Geometry/CaloTopology/interface/HGCalTopology.h +++ b/Geometry/CaloTopology/interface/HGCalTopology.h @@ -85,7 +85,9 @@ class HGCalTopology : public CaloSubdetectorTopology { ///Is this a valid cell id bool valid(const DetId& id) const override; + bool valid(const DetId& id, int cornerMin) const; bool validHashIndex(uint32_t ix) const { return (ix < kSizeForDenseIndexing); } + bool validModule(const DetId& id, int cornerMin) const; unsigned int totalModules() const { return kSizeForDenseIndexing; } unsigned int totalGeomModules() const { return (unsigned int)(2 * kHGeomHalf_); } diff --git a/Geometry/CaloTopology/src/HGCalTopology.cc b/Geometry/CaloTopology/src/HGCalTopology.cc index 762a1a152d2c6..f702195520ecc 100644 --- a/Geometry/CaloTopology/src/HGCalTopology.cc +++ b/Geometry/CaloTopology/src/HGCalTopology.cc @@ -3,6 +3,7 @@ #include "DataFormats/ForwardDetId/interface/HGCSiliconDetId.h" #include "DataFormats/ForwardDetId/interface/HGCScintillatorDetId.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "Geometry/HGCalCommonData/interface/HGCalTypes.h" #include "Geometry/CaloTopology/interface/HGCalTopology.h" #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h" @@ -57,14 +58,14 @@ std::vector HGCalTopology::neighbors(const DetId& idin) const { std::vector ids; HGCalTopology::DecodedDetId id = decode(idin); if ((mode_ == HGCalGeometryMode::Hexagon8) || (mode_ == HGCalGeometryMode::Hexagon8Full)) { - HGCalDDDConstants::CellType celltype = hdcons_.cellType(id.iType, id.iCell1, id.iCell2); + HGCalTypes::CellType celltype = hdcons_.cellType(id.iType, id.iCell1, id.iCell2); #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "Type:WaferU:WaferV " << id.iType << ":" << id.iCell1 << ":" << id.iCell2 << " CellType " - << static_cast::type>(celltype); + << static_cast::type>(celltype); #endif switch (celltype) { - case (HGCalDDDConstants::CellType::CentralType): { + case (HGCalTypes::CellType::CentralType): { // cell within the wafer #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "Cell Type 0"; @@ -77,7 +78,7 @@ std::vector HGCalTopology::neighbors(const DetId& idin) const { addHGCSiliconId(ids, id.det, id.zSide, id.iType, id.iLay, id.iSec1, id.iSec2, id.iCell1 + 1, id.iCell2 + 1); break; } - case (HGCalDDDConstants::CellType::BottomLeftEdge): { + case (HGCalTypes::CellType::BottomLeftEdge): { // bottom left edge int wu1(id.iSec1), wv1(id.iSec2 - 1); int t1 = hdcons_.getTypeHex(id.iLay, wu1, wv1); @@ -95,7 +96,7 @@ std::vector HGCalTopology::neighbors(const DetId& idin) const { addHGCSiliconId(ids, id.det, id.zSide, id.iType, id.iLay, id.iSec1, id.iSec2, id.iCell1 + 1, id.iCell2 + 1); break; } - case (HGCalDDDConstants::CellType::LeftEdge): { + case (HGCalTypes::CellType::LeftEdge): { // left edege int wu1(id.iSec1 + 1), wv1(id.iSec2); int t1 = hdcons_.getTypeHex(id.iLay, wu1, wv1); @@ -113,7 +114,7 @@ std::vector HGCalTopology::neighbors(const DetId& idin) const { addHGCSiliconId(ids, id.det, id.zSide, id.iType, id.iLay, id.iSec1, id.iSec2, id.iCell1 + 1, id.iCell2 + 1); break; } - case (HGCalDDDConstants::CellType::TopLeftEdge): { + case (HGCalTypes::CellType::TopLeftEdge): { // top left edge int wu1(id.iSec1 + 1), wv1(id.iSec2 + 1); int t1 = hdcons_.getTypeHex(id.iLay, wu1, wv1); @@ -131,7 +132,7 @@ std::vector HGCalTopology::neighbors(const DetId& idin) const { addHGCSiliconId(ids, id.det, id.zSide, id.iType, id.iLay, id.iSec1, id.iSec2, id.iCell1 + 1, id.iCell2 + 1); break; } - case (HGCalDDDConstants::CellType::TopRightEdge): { + case (HGCalTypes::CellType::TopRightEdge): { // top right edge int wu1(id.iSec1), wv1(id.iSec2 + 1); int t1 = hdcons_.getTypeHex(id.iLay, wu1, wv1); @@ -149,7 +150,7 @@ std::vector HGCalTopology::neighbors(const DetId& idin) const { addHGCSiliconId(ids, id.det, id.zSide, t1, id.iLay, wu1, wv1, 0, v1 - N1 + 1); break; } - case (HGCalDDDConstants::CellType::RightEdge): { + case (HGCalTypes::CellType::RightEdge): { // right edge int wu1(id.iSec1 - 1), wv1(id.iSec2); int t1 = hdcons_.getTypeHex(id.iLay, wu1, wv1); @@ -167,7 +168,7 @@ std::vector HGCalTopology::neighbors(const DetId& idin) const { addHGCSiliconId(ids, id.det, id.zSide, t1, id.iLay, wu1, wv1, u1 - N1 + 1, 0); break; } - case (HGCalDDDConstants::CellType::BottomRightEdge): { + case (HGCalTypes::CellType::BottomRightEdge): { // bottom right edge int wu1(id.iSec1 - 1), wv1(id.iSec2 - 1); int t1 = hdcons_.getTypeHex(id.iLay, wu1, wv1); @@ -185,7 +186,7 @@ std::vector HGCalTopology::neighbors(const DetId& idin) const { addHGCSiliconId(ids, id.det, id.zSide, id.iType, id.iLay, id.iSec1, id.iSec2, id.iCell1 + 1, id.iCell2 + 1); break; } - case (HGCalDDDConstants::CellType::BottomCorner): { + case (HGCalTypes::CellType::BottomCorner): { // bottom corner int wu1(id.iSec1), wv1(id.iSec2 - 1); int t1 = hdcons_.getTypeHex(id.iLay, wu1, wv1); @@ -208,7 +209,7 @@ std::vector HGCalTopology::neighbors(const DetId& idin) const { addHGCSiliconId(ids, id.det, id.zSide, id.iType, id.iLay, id.iSec1, id.iSec2, id.iCell1 + 1, id.iCell2 + 1); break; } - case (HGCalDDDConstants::CellType::BottomLeftCorner): { + case (HGCalTypes::CellType::BottomLeftCorner): { // bottom left corner int wu1(id.iSec1 + 1), wv1(id.iSec2); int t1 = hdcons_.getTypeHex(id.iLay, wu1, wv1); @@ -231,7 +232,7 @@ std::vector HGCalTopology::neighbors(const DetId& idin) const { addHGCSiliconId(ids, id.det, id.zSide, id.iType, id.iLay, id.iSec1, id.iSec2, id.iCell1 + 1, id.iCell2 + 1); break; } - case (HGCalDDDConstants::CellType::TopLeftCorner): { + case (HGCalTypes::CellType::TopLeftCorner): { // top left corner int wu1(id.iSec1 + 1), wv1(id.iSec2 + 1); int t1 = hdcons_.getTypeHex(id.iLay, wu1, wv1); @@ -254,7 +255,7 @@ std::vector HGCalTopology::neighbors(const DetId& idin) const { addHGCSiliconId(ids, id.det, id.zSide, id.iType, id.iLay, id.iSec1, id.iSec2, id.iCell1 + 1, id.iCell2 + 1); break; } - case (HGCalDDDConstants::CellType::TopCorner): { + case (HGCalTypes::CellType::TopCorner): { // top corner int wu1(id.iSec1 + 1), wv1(id.iSec2 + 1); int t1 = hdcons_.getTypeHex(id.iLay, wu1, wv1); @@ -277,7 +278,7 @@ std::vector HGCalTopology::neighbors(const DetId& idin) const { addHGCSiliconId(ids, id.det, id.zSide, t2, id.iLay, wu2, wv2, 0, v2 - N2 + 1); break; } - case (HGCalDDDConstants::CellType::TopRightCorner): { + case (HGCalTypes::CellType::TopRightCorner): { // top right corner int wu1(id.iSec1), wv1(id.iSec2 + 1); int t1 = hdcons_.getTypeHex(id.iLay, wu1, wv1); @@ -300,7 +301,7 @@ std::vector HGCalTopology::neighbors(const DetId& idin) const { addHGCSiliconId(ids, id.det, id.zSide, t2, id.iLay, wu2, wv2, u2 - N2 + 1, 0); break; } - case (HGCalDDDConstants::CellType::BottomRightCorner): { + case (HGCalTypes::CellType::BottomRightCorner): { // bottom right corner int wu1(id.iSec1 - 1), wv1(id.iSec2 - 1); int t1 = hdcons_.getTypeHex(id.iLay, wu1, wv1); @@ -476,6 +477,30 @@ bool HGCalTopology::valid(const DetId& idin) const { return flag; } +bool HGCalTopology::valid(const DetId& idin, int cornerMin) const { + if ((mode_ == HGCalGeometryMode::Hexagon8) || (mode_ == HGCalGeometryMode::Hexagon8Full)) { + HGCalTopology::DecodedDetId id = decode(idin); + bool mask = (cornerMin < HGCalTypes::WaferCornerMin) ? false : hdcons_.maskCell(idin, cornerMin); + bool flag = ((idin.det() == det_) && + hdcons_.isValidHex8( + id.iLay, id.iSec1, id.iSec2, id.iCell1, id.iCell2, (cornerMin >= HGCalTypes::WaferCornerMin))); + return (flag && (!mask)); + } else { + return valid(idin); + } +} + +bool HGCalTopology::validModule(const DetId& idin, int cornerMin) const { + if (idin.det() != det_) { + return false; + } else if ((idin.det() == DetId::HGCalEE) || (idin.det() == DetId::HGCalHSi)) { + HGCalTopology::DecodedDetId id = decode(idin); + return hdcons_.isValidHex8(id.iLay, id.iSec1, id.iSec2, (cornerMin >= HGCalTypes::WaferCornerMin)); + } else { + return valid(idin); + } +} + DetId HGCalTopology::offsetBy(const DetId startId, int nrStepsX, int nrStepsY) const { if (startId.det() == DetId::Forward && startId.subdetId() == (int)(subdet_)) { DetId id = changeXY(startId, nrStepsX, nrStepsY); diff --git a/Geometry/HGCalCommonData/data/hgcalCons/v10/hgcalCons.xml b/Geometry/HGCalCommonData/data/hgcalCons/v10/hgcalCons.xml index f90ea46f618b5..dd4d0a55023a4 100644 --- a/Geometry/HGCalCommonData/data/hgcalCons/v10/hgcalCons.xml +++ b/Geometry/HGCalCommonData/data/hgcalCons/v10/hgcalCons.xml @@ -1,5 +1,5 @@ - + @@ -137,6 +137,7 @@ + diff --git a/Geometry/HGCalCommonData/data/hgcalCons/v11/hgcalCons.xml b/Geometry/HGCalCommonData/data/hgcalCons/v11/hgcalCons.xml index d0b101321d342..a35bcfb2a10b9 100644 --- a/Geometry/HGCalCommonData/data/hgcalCons/v11/hgcalCons.xml +++ b/Geometry/HGCalCommonData/data/hgcalCons/v11/hgcalCons.xml @@ -1,5 +1,5 @@ - + @@ -137,6 +137,7 @@ + diff --git a/Geometry/HGCalCommonData/data/hgcalCons/v11m/hgcalCons.xml b/Geometry/HGCalCommonData/data/hgcalCons/v11m/hgcalCons.xml index b11e8c2fcaa52..9024454b5ff6c 100644 --- a/Geometry/HGCalCommonData/data/hgcalCons/v11m/hgcalCons.xml +++ b/Geometry/HGCalCommonData/data/hgcalCons/v11m/hgcalCons.xml @@ -1,5 +1,5 @@ - + @@ -86,7 +86,7 @@ - + @@ -137,6 +137,7 @@ + diff --git a/Geometry/HGCalCommonData/data/hgcalCons/v12/hgcalCons.xml b/Geometry/HGCalCommonData/data/hgcalCons/v12/hgcalCons.xml index b11e8c2fcaa52..9024454b5ff6c 100644 --- a/Geometry/HGCalCommonData/data/hgcalCons/v12/hgcalCons.xml +++ b/Geometry/HGCalCommonData/data/hgcalCons/v12/hgcalCons.xml @@ -1,5 +1,5 @@ - + @@ -86,7 +86,7 @@ - + @@ -137,6 +137,7 @@ + diff --git a/Geometry/HGCalCommonData/data/hgcalCons/v9/hgcalCons.xml b/Geometry/HGCalCommonData/data/hgcalCons/v9/hgcalCons.xml index 9afe60a7bf08c..9e027afcee3ca 100644 --- a/Geometry/HGCalCommonData/data/hgcalCons/v9/hgcalCons.xml +++ b/Geometry/HGCalCommonData/data/hgcalCons/v9/hgcalCons.xml @@ -1,5 +1,5 @@ - + @@ -125,6 +125,7 @@ + diff --git a/Geometry/HGCalCommonData/interface/HGCalDDDConstants.h b/Geometry/HGCalCommonData/interface/HGCalDDDConstants.h index 27625b0870ba0..a3dc4f0552dba 100644 --- a/Geometry/HGCalCommonData/interface/HGCalDDDConstants.h +++ b/Geometry/HGCalCommonData/interface/HGCalDDDConstants.h @@ -14,9 +14,11 @@ #include #include #include "DataFormats/DetId/interface/DetId.h" -#include "DetectorDescription/Core/interface/DDsvalues.h" +#include "DataFormats/ForwardDetId/interface/HGCSiliconDetId.h" #include "Geometry/HGCalCommonData/interface/HGCalGeometryMode.h" +#include "Geometry/HGCalCommonData/interface/HGCalGeomTools.h" #include "Geometry/HGCalCommonData/interface/HGCalParameters.h" +#include "Geometry/HGCalCommonData/interface/HGCalTypes.h" #include @@ -25,23 +27,6 @@ class HGCalDDDConstants { HGCalDDDConstants(const HGCalParameters* hp, const std::string& name); ~HGCalDDDConstants(); - enum class CellType { - UndefinedType = -1, - CentralType = 0, - BottomLeftEdge = 1, - LeftEdge = 2, - TopLeftEdge = 3, - TopRightEdge = 4, - RightEdge = 5, - BottomRightEdge = 6, - BottomCorner = 11, - BottomLeftCorner = 12, - TopLeftCorner = 13, - TopCorner = 14, - TopRightCorner = 15, - BottomRightCorner = 16 - }; - std::pair assignCell(float x, float y, int lay, int subSec, bool reco) const; std::array assignCellHex(float x, float y, int lay, bool reco) const; std::array assignCellTrap(float x, float y, float z, int lay, bool reco) const; @@ -52,7 +37,7 @@ class HGCalDDDConstants { return std::make_pair(hgpar_->radiusLayer_[type][irad - 1], hgpar_->radiusLayer_[type][irad]); } double cellThickness(int layer, int waferU, int waferV) const; - CellType cellType(int type, int waferU, int waferV) const; + HGCalTypes::CellType cellType(int type, int waferU, int waferV) const; double distFromEdgeHex(double x, double y, double z) const; double distFromEdgeTrap(double x, double y, double z) const; void etaPhiFromPosition(const double x, @@ -66,6 +51,7 @@ class HGCalDDDConstants { int firstLayer() const { return hgpar_->firstLayer_; } HGCalGeometryMode::GeometryMode geomMode() const { return mode_; } int getLayer(double z, bool reco) const; + int getLayerOffset() const { return hgpar_->layerOffset_; } HGCalParameters::hgtrap getModule(unsigned int k, bool hexType, bool reco) const; std::vector getModules() const; const HGCalParameters* getParameter() const { return hgpar_; } @@ -83,7 +69,8 @@ class HGCalDDDConstants { int getUVMax(int type) const { return ((type == 0) ? hgpar_->nCellsFine_ : hgpar_->nCellsCoarse_); } bool isHalfCell(int waferType, int cell) const; bool isValidHex(int lay, int mod, int cell, bool reco) const; - bool isValidHex8(int lay, int modU, int modV, int cellU, int cellV) const; + bool isValidHex8(int lay, int waferU, int waferV, bool fullAndPart = false) const; + bool isValidHex8(int lay, int modU, int modV, int cellU, int cellV, bool fullAndPart = false) const; bool isValidTrap(int lay, int ieta, int iphi) const; int lastLayer(bool reco) const; int layerIndex(int lay, bool reco) const; @@ -92,6 +79,7 @@ class HGCalDDDConstants { std::pair locateCell(int cell, int lay, int type, bool reco) const; std::pair locateCell( int lay, int waferU, int waferV, int cellU, int cellV, bool reco, bool all, bool debug = false) const; + std::pair locateCell(const HGCSiliconDetId&, bool debug = false) const; std::pair locateCellHex(int cell, int wafer, bool reco) const; std::pair locateCellTrap(int lay, int ieta, int iphi, bool reco) const; int levelTop(int ind = 0) const { return hgpar_->levelT_[ind]; } @@ -114,6 +102,7 @@ class HGCalDDDConstants { int numberCellsHexagon(int wafer) const; int numberCellsHexagon(int lay, int waferU, int waferV, bool flag) const; std::pair rangeR(double z, bool reco) const; + std::pair rangeRLayer(int lay, bool reco) const; std::pair rangeZ(bool reco) const; std::pair rowColumnWafer(const int wafer) const; int sectors() const { return hgpar_->nSectors_; } @@ -136,8 +125,34 @@ class HGCalDDDConstants { int waferCount(const int type) const { return ((type == 0) ? waferMax_[2] : waferMax_[3]); } int waferMax() const { return waferMax_[1]; } int waferMin() const { return waferMax_[0]; } + std::pair waferParameters(bool reco) const; std::pair waferPosition(int wafer, bool reco) const; std::pair waferPosition(int lay, int waferU, int waferV, bool reco, bool debug = false) const; + unsigned int waferFileSize() const { return hgpar_->waferInfoMap_.size(); } + int waferFileIndex(unsigned int kk) const { + if (kk < hgpar_->waferInfoMap_.size()) { + auto itr = hgpar_->waferInfoMap_.begin(); + std::advance(itr, kk); + return itr->first; + } else + return 0; + } + std::tuple waferFileInfo(unsigned int kk) const { + if (kk < hgpar_->waferInfoMap_.size()) { + auto itr = hgpar_->waferInfoMap_.begin(); + std::advance(itr, kk); + return std::make_tuple(itr->second.type, itr->second.part, itr->second.orient); + } else + return std::make_tuple(0, 0, 0); + } + std::tuple waferFileInfoFromIndex(int kk) const { + auto itr = hgpar_->waferInfoMap_.find(kk); + if (itr != hgpar_->waferInfoMap_.end()) { + return std::make_tuple(itr->second.type, itr->second.part, itr->second.orient); + } else + return std::make_tuple(0, 0, 0); + } + bool waferFileInfoExist(int kk) const { return (hgpar_->waferInfoMap_.find(kk) != hgpar_->waferInfoMap_.end()); } double waferSepar(bool reco) const { return (reco ? hgpar_->sensorSeparation_ : HGCalParameters::k_ScaleToDDD * hgpar_->sensorSeparation_); } @@ -158,8 +173,11 @@ class HGCalDDDConstants { int waferTypeL(int wafer) const { return ((wafer >= 0) && (wafer < (int)(hgpar_->waferTypeL_.size()))) ? hgpar_->waferTypeL_[wafer] : 0; } - int waferType(DetId const& id) const; - int waferType(int layer, int waferU, int waferV) const; + int waferType(DetId const& id, bool fromFile = false) const; + int waferType(int layer, int waferU, int waferV, bool fromFile = false) const; + std::tuple waferType(HGCSiliconDetId const& id, bool fromFile = false) const; + std::pair waferTypeRotation( + int layer, int waferU, int waferV, bool fromFile = false, bool debug = false) const; int waferUVMax() const { return hgpar_->waferUVMax_; } bool waferVirtual(int layer, int waferU, int waferV) const; double waferZ(int layer, bool reco) const; @@ -177,6 +195,7 @@ class HGCalDDDConstants { bool waferInLayerTest(int wafer, int lay, bool full) const; std::pair waferPosition(int waferU, int waferV, bool reco) const; + HGCalGeomTools geomTools_; const double k_horizontalShift = 1.0; const float dPhiMin = 0.02; typedef std::array, 2> Simrecovecs; diff --git a/Geometry/HGCalCommonData/interface/HGCalGeomParameters.h b/Geometry/HGCalCommonData/interface/HGCalGeomParameters.h index 9ac190d8fda6b..1afb29bd09adc 100644 --- a/Geometry/HGCalCommonData/interface/HGCalGeomParameters.h +++ b/Geometry/HGCalCommonData/interface/HGCalGeomParameters.h @@ -106,8 +106,8 @@ class HGCalGeomParameters { const int& firstLayer, HGCalParameters& php); void loadSpecParsHexagon(const HGCalParameters& php); - void loadSpecParsHexagon8(const HGCalParameters& php); - void loadSpecParsTrapezoid(const HGCalParameters& php); + void loadSpecParsHexagon8(HGCalParameters& php); + void loadSpecParsTrapezoid(HGCalParameters& php); std::vector getDDDArray(const std::string& str, const DDsvalues_type& sv, const int nmin); std::pair cellPosition(const std::vector& wafers, std::vector::const_iterator& itrf, @@ -117,9 +117,18 @@ class HGCalGeomParameters { void rescale(std::vector&, const double s); void resetZero(std::vector&); + constexpr static double tan30deg_ = 0.5773502693; + constexpr static int siliconFileEE = 2; + constexpr static int siliconFileHE = 3; + constexpr static int scintillatorFile = 4; HGCalGeomTools geomTools_; const double sqrt3_; double waferSize_; + std::vector waferIndex_, waferTypes_, waferParts_, waferOrien_; + std::vector tileIndx_, tileType_, tileSiPM_; + std::vector tileHEX1_, tileHEX2_, tileHEX3_, tileHEX4_; + std::vector tileRMin_, tileRMax_; + std::vector tileRingMin_, tileRingMax_; }; #endif diff --git a/Geometry/HGCalCommonData/interface/HGCalGeomTools.h b/Geometry/HGCalCommonData/interface/HGCalGeomTools.h index d62e810641852..c42ffde8538c5 100644 --- a/Geometry/HGCalCommonData/interface/HGCalGeomTools.h +++ b/Geometry/HGCalCommonData/interface/HGCalGeomTools.h @@ -10,36 +10,6 @@ class HGCalGeomTools { HGCalGeomTools(); ~HGCalGeomTools() {} - enum WaferCorner { - WaferCorner0 = 0, - WaferCorner1 = 1, - WaferCorner2 = 2, - WaferCorner3 = 3, - WaferCorner4 = 4, - WaferCorner5 = 5 - }; - - enum WaferPosition { - UnknownPosition = -1, - WaferCenter = 0, - CornerCenterYp = 1, - CornerCenterYm = 2, - CornerCenterXp = 3, - CornerCenterXm = 4 - }; - - enum WaferType { - WaferFull = 0, - WaferFive = 1, - WaferChopTwo = 2, - WaferChopTwoM = 3, - WaferHalf = 4, - WaferSemi = 5, - WaferSemi2 = 6, - WaferThree = 7, - WaferOut = 99 - }; - static const int k_allCorners = 6; static const int k_fiveCorners = 5; static const int k_fourCorners = 4; @@ -63,7 +33,7 @@ class HGCalGeomTools { std::vector const& slope); static double radius( double z, int layer0, int layerf, std::vector const& zFront, std::vector const& rFront); - std::pair shiftXY(int waferPosition, double waferSize); + std::pair shiftXY(int waferPosition, double waferSize) const; static double slope(double z, std::vector const& zFront, std::vector const& slope); static std::pair zradius(double z1, double z2, diff --git a/Geometry/HGCalCommonData/interface/HGCalParameters.h b/Geometry/HGCalCommonData/interface/HGCalParameters.h index ab52aba3caec8..62de72f0b098d 100644 --- a/Geometry/HGCalCommonData/interface/HGCalParameters.h +++ b/Geometry/HGCalCommonData/interface/HGCalParameters.h @@ -12,9 +12,20 @@ class HGCalParameters { public: + struct waferInfo { + int32_t type, part, orient; + waferInfo(int32_t t = 0, int32_t p = 0, int32_t o = 0) : type(t), part(p), orient(o){}; + }; + struct tileInfo { + int32_t type, sipm, hex1, hex2, hex3, hex4; + tileInfo(int32_t t = 0, int32_t s = 0, int32_t h1 = 0, int32_t h2 = 0, int32_t h3 = 0, int32_t h4 = 0) + : type(t), sipm(s), hex1(h1), hex2(h2), hex3(h3), hex4(h4){}; + }; typedef std::vector > layer_map; typedef std::unordered_map wafer_map; typedef std::unordered_map > waferT_map; + typedef std::unordered_map waferInfo_map; + typedef std::unordered_map tileInfo_map; static constexpr double k_ScaleFromDDD = 0.1; static constexpr double k_ScaleToDDD = 10.0; @@ -160,6 +171,10 @@ class HGCalParameters { wafer_map typesInLayers_; waferT_map waferTypes_; int waferMaskMode_; + waferInfo_map waferInfoMap_; + tileInfo_map tileInfoMap_; + std::vector > tileRingR_; + std::vector > tileRingRange_; COND_SERIALIZABLE; diff --git a/Geometry/HGCalCommonData/interface/HGCalParametersFromDD.h b/Geometry/HGCalCommonData/interface/HGCalParametersFromDD.h index 4b192259879a6..600aabed3330d 100644 --- a/Geometry/HGCalCommonData/interface/HGCalParametersFromDD.h +++ b/Geometry/HGCalCommonData/interface/HGCalParametersFromDD.h @@ -32,6 +32,7 @@ class HGCalParametersFromDD { void getCellPosition(HGCalParameters& php, int type); double getDDDValue(const char* s, const DDsvalues_type& sv); std::vector getDDDArray(const char* s, const DDsvalues_type& sv); + constexpr static double tan30deg_ = 0.5773502693; }; #endif diff --git a/Geometry/HGCalCommonData/interface/HGCalTileIndex.h b/Geometry/HGCalCommonData/interface/HGCalTileIndex.h new file mode 100644 index 0000000000000..4201bd277590a --- /dev/null +++ b/Geometry/HGCalCommonData/interface/HGCalTileIndex.h @@ -0,0 +1,25 @@ +#ifndef Geometry_HGCalCommonData_HGCalTileIndex_h +#define Geometry_HGCalCommonData_HGCalTileIndex_h + +#include +#include + +class HGCalTileIndex { +public: + HGCalTileIndex() {} + ~HGCalTileIndex() {} + static int32_t tileIndex(int32_t layer, int32_t ring, int32_t phi); + static int32_t tileLayer(int32_t index); + static int32_t tileRing(int32_t index); + static int32_t tilePhi(int32_t index); + +private: + static constexpr int32_t kHGCalLayerOffset = 18; + static constexpr int32_t kHGCalLayerMask = 0x1F; + static constexpr int32_t kHGCalPhiOffset = 0; + static constexpr int32_t kHGCalPhiMask = 0x1FF; + static constexpr int32_t kHGCalRingOffset = 9; + static constexpr int32_t kHGCalRingMask = 0x1FF; +}; + +#endif diff --git a/Geometry/HGCalCommonData/interface/HGCalTypes.h b/Geometry/HGCalCommonData/interface/HGCalTypes.h new file mode 100644 index 0000000000000..4f235eb1fff5d --- /dev/null +++ b/Geometry/HGCalCommonData/interface/HGCalTypes.h @@ -0,0 +1,68 @@ +#ifndef Geometry_HGCalCommonData_HGCalTypes_h +#define Geometry_HGCalCommonData_HGCalTypes_h + +#include +#include +#include + +class HGCalTypes { +public: + HGCalTypes() {} + + enum class CellType { + UndefinedType = -1, + CentralType = 0, + BottomLeftEdge = 1, + LeftEdge = 2, + TopLeftEdge = 3, + TopRightEdge = 4, + RightEdge = 5, + BottomRightEdge = 6, + BottomCorner = 11, + BottomLeftCorner = 12, + TopLeftCorner = 13, + TopCorner = 14, + TopRightCorner = 15, + BottomRightCorner = 16 + }; + + enum WaferCorner { + WaferCorner0 = 0, + WaferCorner1 = 1, + WaferCorner2 = 2, + WaferCorner3 = 3, + WaferCorner4 = 4, + WaferCorner5 = 5 + }; + + enum WaferPosition { + UnknownPosition = -1, + WaferCenter = 0, + CornerCenterYp = 1, + CornerCenterYm = 2, + CornerCenterXp = 3, + CornerCenterXm = 4 + }; + + enum WaferType { WaferFineThin = 0, WaferCoarseThin = 1, WaferCoarseThick = 2, WaferFineThick = 3 }; + + enum WaferSizeType { + WaferFull = 0, + WaferFive = 1, + WaferChopTwo = 2, + WaferChopTwoM = 3, + WaferHalf = 4, + WaferSemi = 5, + WaferSemi2 = 6, + WaferThree = 7, + WaferOut = 99 + }; + + static constexpr int32_t WaferCornerMin = 3; + + enum TileType { TileFine = 0, TileCoarseCast = 1, TileCoarseMould = 2 }; + + enum TileSiPMType { SiPMUnknown = 0, SiPMSmall = 2, SiPMLarge = 4 }; +}; + +#endif diff --git a/Geometry/HGCalCommonData/interface/HGCalWaferMask.h b/Geometry/HGCalCommonData/interface/HGCalWaferMask.h index c5628d13cba60..8b4ac51473ff6 100644 --- a/Geometry/HGCalCommonData/interface/HGCalWaferMask.h +++ b/Geometry/HGCalCommonData/interface/HGCalWaferMask.h @@ -25,8 +25,9 @@ class HGCalWaferMask { const double& delY, const double& rin, const double& rout, - const int& nw, - const int& mode); + const int& waferType, + const int& mode, + bool deug = false); static const int k_OffsetRotation = 10; }; diff --git a/Geometry/HGCalCommonData/plugins/HGCalNumberingInitialization.cc b/Geometry/HGCalCommonData/plugins/HGCalNumberingInitialization.cc index 5649917d528e9..eba8976d41969 100644 --- a/Geometry/HGCalCommonData/plugins/HGCalNumberingInitialization.cc +++ b/Geometry/HGCalCommonData/plugins/HGCalNumberingInitialization.cc @@ -55,7 +55,7 @@ HGCalNumberingInitialization::~HGCalNumberingInitialization() {} // ------------ method called to produce the data ------------ HGCalNumberingInitialization::ReturnType HGCalNumberingInitialization::produce(const IdealGeometryRecord& iRecord) { - edm::LogVerbatim("HGCalGeom") << "in HGCalNumberingInitialization::produce"; + edm::LogVerbatim("HGCalGeom") << "in HGCalNumberingInitialization::produce for " << name_; const auto& pHGpar = iRecord.get(hgParToken_); return std::make_unique(&pHGpar, name_); } diff --git a/Geometry/HGCalCommonData/python/testHGCalV11XML_cfi.py b/Geometry/HGCalCommonData/python/testHGCalV11XML_cfi.py index 89c554d0f0336..8d966ef5f005e 100644 --- a/Geometry/HGCalCommonData/python/testHGCalV11XML_cfi.py +++ b/Geometry/HGCalCommonData/python/testHGCalV11XML_cfi.py @@ -31,7 +31,6 @@ 'Geometry/HcalCommonData/data/hcal/v2/hcalalgo.xml', 'Geometry/HcalCommonData/data/hcalbarrelalgo.xml', 'Geometry/HcalCommonData/data/hcalcablealgo/v2/hcalcablealgo.xml', - 'Geometry/HcalCommonData/data/hcalcablealgo/v2/hcalcablealgo.xml', 'Geometry/HcalCommonData/data/hcalouteralgo.xml', 'Geometry/HcalCommonData/data/hcalforwardalgo.xml', 'Geometry/HcalCommonData/data/hcalSimNumbering/NoHE/hcalSimNumbering.xml', diff --git a/Geometry/HGCalCommonData/python/testHGCalV12XML_cfi.py b/Geometry/HGCalCommonData/python/testHGCalV12XML_cfi.py index 93dda7c054b6b..e2569dacae092 100644 --- a/Geometry/HGCalCommonData/python/testHGCalV12XML_cfi.py +++ b/Geometry/HGCalCommonData/python/testHGCalV12XML_cfi.py @@ -31,7 +31,6 @@ 'Geometry/HcalCommonData/data/hcal/v2/hcalalgo.xml', 'Geometry/HcalCommonData/data/hcalbarrelalgo.xml', 'Geometry/HcalCommonData/data/hcalcablealgo/v2/hcalcablealgo.xml', - 'Geometry/HcalCommonData/data/hcalcablealgo/v2/hcalcablealgo.xml', 'Geometry/HcalCommonData/data/hcalouteralgo.xml', 'Geometry/HcalCommonData/data/hcalforwardalgo.xml', 'Geometry/HcalCommonData/data/hcalSimNumbering/NoHE/hcalSimNumbering.xml', diff --git a/Geometry/HGCalCommonData/src/HGCalDDDConstants.cc b/Geometry/HGCalCommonData/src/HGCalDDDConstants.cc index cf901199489ea..4885c699d55ff 100644 --- a/Geometry/HGCalCommonData/src/HGCalDDDConstants.cc +++ b/Geometry/HGCalCommonData/src/HGCalDDDConstants.cc @@ -23,6 +23,9 @@ using namespace geant_units::operators; HGCalDDDConstants::HGCalDDDConstants(const HGCalParameters* hp, const std::string& name) : hgpar_(hp), sqrt3_(std::sqrt(3.0)) { mode_ = hgpar_->mode_; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "Mode " << mode_; +#endif if ((mode_ == HGCalGeometryMode::Hexagon) || (mode_ == HGCalGeometryMode::HexagonFull) || (mode_ == HGCalGeometryMode::Hexagon8) || (mode_ == HGCalGeometryMode::Hexagon8Full)) { rmax_ = (HGCalParameters::k_ScaleFromDDD * (hgpar_->waferR_) * std::cos(30._deg)); @@ -46,10 +49,16 @@ HGCalDDDConstants::HGCalDDDConstants(const HGCalParameters* hp, const std::strin maxWafersPerLayer_ = std::max(maxWafersPerLayer_, max_modules_layer_[simreco][layer]); #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "Layer " << layer << " with " << max_modules_layer_[simreco][layer] << ":" - << modHalf_ << " modules"; + << modHalf_ << " modules in RECO"; + } else { + edm::LogVerbatim("HGCalGeom") << "Layer " << layer << " with " << max_modules_layer_[simreco][layer] + << " modules in SIM"; #endif } } +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "SimReco " << simreco << " with " << tot_layers_[simreco] << " Layers"; +#endif } tot_wafers_ = wafers(); @@ -212,7 +221,7 @@ bool HGCalDDDConstants::cellInLayer(int waferU, int waferV, int cellU, int cellV double HGCalDDDConstants::cellThickness(int layer, int waferU, int waferV) const { double thick(-1); - int type = waferType(layer, waferU, waferV); + int type = waferType(layer, waferU, waferV, false); if (type >= 0) { if ((mode_ == HGCalGeometryMode::Hexagon8) || (mode_ == HGCalGeometryMode::Hexagon8Full)) { thick = 10000.0 * hgpar_->cellThickness_[type]; // cm to micron @@ -233,43 +242,43 @@ double HGCalDDDConstants::cellSizeHex(int type) const { return cell; } -HGCalDDDConstants::CellType HGCalDDDConstants::cellType(int type, int cellU, int cellV) const { +HGCalTypes::CellType HGCalDDDConstants::cellType(int type, int cellU, int cellV) const { // type=0: in the middle; 1..6: the edges clocwise from bottom left; // =11..16: the corners clockwise from bottom int N = (type == 0) ? hgpar_->nCellsFine_ : hgpar_->nCellsCoarse_; if (cellU == 0) { if (cellV == 0) - return HGCalDDDConstants::CellType::BottomLeftCorner; + return HGCalTypes::CellType::BottomLeftCorner; else if (cellV - cellU == N - 1) - return HGCalDDDConstants::CellType::BottomCorner; + return HGCalTypes::CellType::BottomCorner; else - return HGCalDDDConstants::CellType::BottomLeftEdge; + return HGCalTypes::CellType::BottomLeftEdge; } else if (cellV == 0) { if (cellU - cellV == N) - return HGCalDDDConstants::CellType::TopLeftCorner; + return HGCalTypes::CellType::TopLeftCorner; else - return HGCalDDDConstants::CellType::LeftEdge; + return HGCalTypes::CellType::LeftEdge; } else if (cellU - cellV == N) { if (cellU == 2 * N - 1) - return HGCalDDDConstants::CellType::TopCorner; + return HGCalTypes::CellType::TopCorner; else - return HGCalDDDConstants::CellType::TopLeftEdge; + return HGCalTypes::CellType::TopLeftEdge; } else if (cellU == 2 * N - 1) { if (cellV == 2 * N - 1) - return HGCalDDDConstants::CellType::TopRightCorner; + return HGCalTypes::CellType::TopRightCorner; else - return HGCalDDDConstants::CellType::TopRightEdge; + return HGCalTypes::CellType::TopRightEdge; } else if (cellV == 2 * N - 1) { if (cellV - cellU == N - 1) - return HGCalDDDConstants::CellType::BottomRightCorner; + return HGCalTypes::CellType::BottomRightCorner; else - return HGCalDDDConstants::CellType::RightEdge; + return HGCalTypes::CellType::RightEdge; } else if (cellV - cellU == N - 1) { - return HGCalDDDConstants::CellType::BottomRightEdge; + return HGCalTypes::CellType::BottomRightEdge; } else if ((cellU > 2 * N - 1) || (cellV > 2 * N - 1) || (cellV >= (cellU + N)) || (cellU > (cellV + N))) { - return HGCalDDDConstants::CellType::UndefinedType; + return HGCalTypes::CellType::UndefinedType; } else { - return HGCalDDDConstants::CellType::CentralType; + return HGCalTypes::CellType::CentralType; } } @@ -482,7 +491,7 @@ bool HGCalDDDConstants::isValidHex(int lay, int mod, int cell, bool reco) const return result; } -bool HGCalDDDConstants::isValidHex8(int layer, int modU, int modV, int cellU, int cellV) const { +bool HGCalDDDConstants::isValidHex8(int layer, int modU, int modV, bool fullAndPart) const { // Check validity for a layer|wafer|cell of post-TDR version int indx = HGCalWaferIndex::waferIndex(layer, modU, modV); auto itr = hgpar_->typesInLayers_.find(indx); @@ -499,6 +508,28 @@ bool HGCalDDDConstants::isValidHex8(int layer, int modU, int modV, int cellU, in if (!(jtr->second)) return false; + if (fullAndPart) { + auto ktr = hgpar_->waferTypes_.find(indx); + if (ktr != hgpar_->waferTypes_.end()) { + if (hgpar_->waferMaskMode_ > 0) { + if (ktr->second.first == HGCalTypes::WaferOut) + return false; + } else { + if (ktr->second.first < HGCalTypes::WaferCornerMin) + return false; + } + } + } + return true; +} + +bool HGCalDDDConstants::isValidHex8(int layer, int modU, int modV, int cellU, int cellV, bool fullAndPart) const { + // First check validity for a layer|wafer| of post TDR version + if (!isValidHex8(layer, modU, modV, fullAndPart)) + return false; + int indx = HGCalWaferIndex::waferIndex(layer, modU, modV); + auto itr = hgpar_->typesInLayers_.find(indx); + int type = hgpar_->waferTypeL_[itr->second]; int N = ((hgpar_->waferTypeL_[itr->second] == 0) ? hgpar_->nCellsFine_ : hgpar_->nCellsCoarse_); #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "HGCalDDDConstants::isValidHex8:Cell " << cellU << ":" << cellV << ":" << N @@ -510,12 +541,6 @@ bool HGCalDDDConstants::isValidHex8(int layer, int modU, int modV, int cellU, in if (((cellV - cellU) >= N) || ((cellU - cellV) > N)) return false; - auto ktr = hgpar_->waferTypes_.find(indx); - if (ktr != hgpar_->waferTypes_.end()) - return false; - - // edm::LogVerbatim("HGCalGeom") << "Corners " << (ktr->second).first << ":" << waferVirtual(layer,modU,modV); - int type = ((itr == hgpar_->typesInLayers_.end()) ? 2 : hgpar_->waferTypeL_[itr->second]); return isValidCell8(layer, modU, modV, cellU, cellV, type); } @@ -631,6 +656,34 @@ std::pair HGCalDDDConstants::locateCell( return std::make_pair(x, y); } +std::pair HGCalDDDConstants::locateCell(const HGCSiliconDetId& id, bool debug) const { + int lay(id.layer()); + double r = 0.5 * (hgpar_->waferSize_ + hgpar_->sensorSeparation_); + double R = 2.0 * r / sqrt3_; + int ncells = (id.type() == 0) ? hgpar_->nCellsFine_ : hgpar_->nCellsCoarse_; + int n2 = ncells / 2; + auto xyoff = geomTools_.shiftXY(hgpar_->layerCenter_[lay - 1], (2.0 * r)); + double xpos = xyoff.first + ((-2 * id.waferU() + id.waferV()) * r); + double ypos = xyoff.second + (1.5 * id.waferV() * R); +#ifdef EDM_ML_DEBUG + if (debug) + edm::LogVerbatim("HGCalGeom") << "LocateCell " << id << " Lay " << lay << " r:R " << r << ":" << R << " N " + << ncells << ":" << n2 << " Off " << xyoff.first << ":" << xyoff.second << " Pos " + << xpos << ":" << ypos; +#endif + double R1 = hgpar_->waferSize_ / (3.0 * ncells); + double r1 = 0.5 * R1 * sqrt3_; + xpos += ((1.5 * (id.cellV() - ncells) + 1.0) * R1); + ypos += ((id.cellU() - 0.5 * id.cellV() - n2) * 2 * r1); +#ifdef EDM_ML_DEBUG + if (debug) + edm::LogVerbatim("HGCalGeom") << "LocateCell r1:R1 " << r1 << ":" << R1 << " dx:dy " + << ((1.5 * (id.cellV() - ncells) + 1.0) * R1) << ":" + << ((id.cellU() - 0.5 * id.cellV() - n2) * 2 * r1) << " Pos " << xpos << ":" << ypos; +#endif + return std::make_pair(xpos * id.zside(), ypos); +} + std::pair HGCalDDDConstants::locateCellHex(int cell, int wafer, bool reco) const { float x(0), y(0); if (hgpar_->waferTypeT_[wafer] - 1 == HGCSiliconDetId::HGCalFine) { @@ -905,6 +958,24 @@ std::pair HGCalDDDConstants::rangeR(double z, bool reco) const { return std::make_pair(rmin, rmax); } +std::pair HGCalDDDConstants::rangeRLayer(int lay, bool reco) const { + double rmin(0), rmax(0); + const auto& index = getIndex(lay, reco); + if (index.first >= 0 && index.first < static_cast(hgpar_->rMinLayHex_.size())) { + rmin = hgpar_->rMinLayHex_[index.first]; + rmax = hgpar_->rMaxLayHex_[index.first]; + } + if (!reco) { + rmin *= HGCalParameters::k_ScaleToDDD; + rmax *= HGCalParameters::k_ScaleToDDD; + } +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "HGCalDDDConstants:rangeR: " << lay << ":" << index.first << " R " << rmin << ":" + << rmax; +#endif + return std::make_pair(rmin, rmax); +} + std::pair HGCalDDDConstants::rangeZ(bool reco) const { double zmin = (hgpar_->zLayerHex_[0] - hgpar_->waferThick_); double zmax = (hgpar_->zLayerHex_[hgpar_->zLayerHex_.size() - 1] + hgpar_->waferThick_); @@ -1109,6 +1180,13 @@ bool HGCalDDDConstants::waferFullInLayer(int wafer, int lay, bool reco) const { return waferInLayerTest(wafer, indx.first, false); } +std::pair HGCalDDDConstants::waferParameters(bool reco) const { + if (reco) + return std::make_pair(rmax_, hexside_); + else + return std::make_pair(HGCalParameters::k_ScaleToDDD * rmax_, HGCalParameters::k_ScaleToDDD * hexside_); +} + std::pair HGCalDDDConstants::waferPosition(int wafer, bool reco) const { double xx(0), yy(0); if (wafer >= 0 && wafer < (int)(hgpar_->waferPosX_.size())) { @@ -1127,9 +1205,11 @@ std::pair HGCalDDDConstants::waferPosition( int ll = lay - hgpar_->firstLayer_; double x = hgpar_->xLayerHex_[ll]; double y = hgpar_->yLayerHex_[ll]; +#ifdef EDM_ML_DEBUG if (debug) edm::LogVerbatim("HGCalGeom") << "Layer " << lay << ":" << ll << " Shift " << hgpar_->xLayerHex_[ll] << ":" << hgpar_->yLayerHex_[ll]; +#endif if (!reco) { x *= HGCalParameters::k_ScaleToDDD; y *= HGCalParameters::k_ScaleToDDD; @@ -1138,27 +1218,53 @@ std::pair HGCalDDDConstants::waferPosition( const auto& xy = waferPosition(waferU, waferV, reco); x += xy.first; y += xy.second; +#ifdef EDM_ML_DEBUG if (debug) edm::LogVerbatim("HGCalGeom") << "With wafer " << x << ":" << y << ":" << xy.first << ":" << xy.second; +#endif return std::make_pair(x, y); } -int HGCalDDDConstants::waferType(DetId const& id) const { +int HGCalDDDConstants::waferType(DetId const& id, bool fromFile) const { int type(1); if ((mode_ == HGCalGeometryMode::Hexagon8) || (mode_ == HGCalGeometryMode::Hexagon8Full)) { - type = ((id.det() != DetId::Forward) ? HGCSiliconDetId(id).type() : HFNoseDetId(id).type()); + if (fromFile && (waferFileSize() > 0)) { + int layer(0), waferU(0), waferV(0); + if (id.det() != DetId::Forward) { + HGCSiliconDetId hid(id); + layer = hid.layer(); + waferU = hid.waferU(); + waferV = hid.waferV(); + } else { + HFNoseDetId hid(id); + layer = hid.layer(); + waferU = hid.waferU(); + waferV = hid.waferV(); + } + auto itr = hgpar_->waferInfoMap_.find(HGCalWaferIndex::waferIndex(layer, waferU, waferV)); + if (itr != hgpar_->waferInfoMap_.end()) + type = (itr->second).type; + } else { + type = ((id.det() != DetId::Forward) ? HGCSiliconDetId(id).type() : HFNoseDetId(id).type()); + } } else if ((mode_ == HGCalGeometryMode::Hexagon) || (mode_ == HGCalGeometryMode::HexagonFull)) { type = waferTypeL(HGCalDetId(id).wafer()) - 1; } return type; } -int HGCalDDDConstants::waferType(int layer, int waferU, int waferV) const { +int HGCalDDDConstants::waferType(int layer, int waferU, int waferV, bool fromFile) const { int type(HGCSiliconDetId::HGCalCoarseThick); if ((mode_ == HGCalGeometryMode::Hexagon8) || (mode_ == HGCalGeometryMode::Hexagon8Full)) { - auto itr = hgpar_->typesInLayers_.find(HGCalWaferIndex::waferIndex(layer, waferU, waferV)); - if (itr != hgpar_->typesInLayers_.end()) - type = hgpar_->waferTypeL_[itr->second]; + if (fromFile && (waferFileSize() > 0)) { + auto itr = hgpar_->waferInfoMap_.find(HGCalWaferIndex::waferIndex(layer, waferU, waferV)); + if (itr != hgpar_->waferInfoMap_.end()) + type = (itr->second).type; + } else { + auto itr = hgpar_->typesInLayers_.find(HGCalWaferIndex::waferIndex(layer, waferU, waferV)); + if (itr != hgpar_->typesInLayers_.end()) + type = hgpar_->waferTypeL_[itr->second]; + } } else if ((mode_ == HGCalGeometryMode::Hexagon) || (mode_ == HGCalGeometryMode::HexagonFull)) { if ((waferU >= 0) && (waferU < (int)(hgpar_->waferTypeL_.size()))) type = (hgpar_->waferTypeL_[waferU] - 1); @@ -1166,6 +1272,86 @@ int HGCalDDDConstants::waferType(int layer, int waferU, int waferV) const { return type; } +std::tuple HGCalDDDConstants::waferType(HGCSiliconDetId const& id, bool fromFile) const { + const auto& index = HGCalWaferIndex::waferIndex(id.layer(), id.waferU(), id.waferV()); + int type(-1), part(-1), orient(-1); + if (fromFile && (waferFileSize() > 0)) { + auto itr = hgpar_->waferInfoMap_.find(index); + if (itr != hgpar_->waferInfoMap_.end()) { + type = (itr->second).type; + part = (itr->second).part; + orient = (itr->second).orient; + } + } else { + auto ktr = hgpar_->typesInLayers_.find(index); + if (ktr != hgpar_->typesInLayers_.end()) + type = hgpar_->waferTypeL_[ktr->second]; + auto itr = hgpar_->waferTypes_.find(index); + if (itr != hgpar_->waferTypes_.end()) { + if ((itr->second).second < HGCalWaferMask::k_OffsetRotation) { + orient = (itr->second).second; + if ((itr->second).first == HGCalGeomTools::k_allCorners) { + part = HGCalTypes::WaferFull; + } else if ((itr->second).first == HGCalGeomTools::k_fiveCorners) { + part = HGCalTypes::WaferFive; + } else if ((itr->second).first == HGCalGeomTools::k_fourCorners) { + part = HGCalTypes::WaferHalf; + } else if ((itr->second).first == HGCalGeomTools::k_threeCorners) { + part = HGCalTypes::WaferThree; + } + } else { + part = (itr->second).first; + orient = ((itr->second).second - HGCalWaferMask::k_OffsetRotation); + } + } else { + part = HGCalTypes::WaferFull; + orient = 0; + } + } + return std::make_tuple(type, part, orient); +} + +std::pair HGCalDDDConstants::waferTypeRotation( + int layer, int waferU, int waferV, bool fromFile, bool debug) const { + int type(HGCalTypes::WaferOut), rotn(0); + int wl = HGCalWaferIndex::waferIndex(layer, waferU, waferV); + if (fromFile && (waferFileSize() > 0)) { + auto itr = hgpar_->waferInfoMap_.find(wl); + if (itr != hgpar_->waferInfoMap_.end()) { + type = (itr->second).part; + rotn = (itr->second).orient; + } + } else { + auto itr = hgpar_->waferTypes_.find(wl); + if ((mode_ == HGCalGeometryMode::Hexagon8) || (mode_ == HGCalGeometryMode::Hexagon8Full)) { + if (itr != hgpar_->waferTypes_.end()) { + if ((itr->second).second < HGCalWaferMask::k_OffsetRotation) { + rotn = (itr->second).second; + if ((itr->second).first == HGCalGeomTools::k_allCorners) { + type = HGCalTypes::WaferFull; + } else if ((itr->second).first == HGCalGeomTools::k_fiveCorners) { + type = HGCalTypes::WaferFive; + } else if ((itr->second).first == HGCalGeomTools::k_fourCorners) { + type = HGCalTypes::WaferHalf; + } else if ((itr->second).first == HGCalGeomTools::k_threeCorners) { + type = HGCalTypes::WaferThree; + } + } else { + type = (itr->second).first; + rotn = ((itr->second).second - HGCalWaferMask::k_OffsetRotation); + } + } + } + } +#ifdef EDM_ML_DEBUG + if (debug) + edm::LogVerbatim("HGCalGeom") << "waferTypeRotation: Layer " << layer << " Wafer " << waferU << ":" << waferV + << " Index " << std::hex << wl << std::dec << ":" + << (itr != hgpar_->waferTypes_.end()) << " Type " << type << " Rotation " << rotn; +#endif + return std::make_pair(type, rotn); +} + bool HGCalDDDConstants::waferVirtual(int layer, int waferU, int waferV) const { bool type(false); if ((mode_ == HGCalGeometryMode::Hexagon8) || (mode_ == HGCalGeometryMode::Hexagon8Full)) { @@ -1245,9 +1431,11 @@ void HGCalDDDConstants::cellHex(double xloc, double yloc, int cellType, int& cel cv0 = std::max(0, std::min(cv0, 2 * N - 1)); if (cv0 - cu0 >= N) cv0 = cu0 + N - 1; +#ifdef EDM_ML_DEBUG if (debug) edm::LogVerbatim("HGCalGeom") << "cellHex: input " << xloc << ":" << yloc << ":" << cellType << " parameter " << rc << ":" << Rc << " u0 " << u0 << ":" << cu0 << " v0 " << v0 << ":" << cv0; +#endif bool found(false); static const int shift[3] = {0, 1, -1}; for (int i1 = 0; i1 < 3; ++i1) { @@ -1260,11 +1448,13 @@ void HGCalDDDConstants::cellHex(double xloc, double yloc, int cellType, int& cel double yc = (2 * cellU - cellV - N) * rc; if ((std::abs(yloc - yc) <= rc) && (std::abs(xloc - xc) <= Rc) && ((std::abs(xloc - xc) <= 0.5 * Rc) || (std::abs(yloc - yc) <= sqrt3_ * (Rc - std::abs(xloc - xc))))) { +#ifdef EDM_ML_DEBUG if (debug) edm::LogVerbatim("HGCalGeom") << "cellHex: local " << xc << ":" << yc << " difference " << std::abs(xloc - xc) << ":" << std::abs(yloc - yc) << ":" << sqrt3_ * (Rc - std::abs(yloc - yc)) << " comparator " << rc << ":" << Rc << " (u,v) = (" << cellU << "," << cellV << ")"; +#endif found = true; break; } diff --git a/Geometry/HGCalCommonData/src/HGCalGeomParameters.cc b/Geometry/HGCalCommonData/src/HGCalGeomParameters.cc index f4831237b007d..793f4271707ca 100644 --- a/Geometry/HGCalCommonData/src/HGCalGeomParameters.cc +++ b/Geometry/HGCalCommonData/src/HGCalGeomParameters.cc @@ -170,7 +170,7 @@ void HGCalGeomParameters::loadGeometryHexagon(const DDFilteredView& _fv, zv = polygon.zVec(); rv = polygon.xVec(); } - php.waferR_ = HGCalParameters::k_ScaleFromDDDToG4 * rv[0] / std::cos(30._deg); + php.waferR_ = 2.0 * HGCalParameters::k_ScaleFromDDDToG4 * rv[0] * tan30deg_; php.waferSize_ = HGCalParameters::k_ScaleFromDDD * rv[0]; double dz = 0.5 * HGCalParameters::k_ScaleFromDDDToG4 * (zv[1] - zv[0]); #ifdef EDM_ML_DEBUG @@ -394,7 +394,7 @@ void HGCalGeomParameters::loadGeometryHexagon(const cms::DDCompactView* cpv, zv[1] = pars[9]; rv = pars[4]; } - php.waferR_ = HGCalParameters::k_ScaleFromDD4HepToG4 * rv / std::cos(30._deg); + php.waferR_ = 2.0 * HGCalParameters::k_ScaleFromDD4HepToG4 * rv * tan30deg_; php.waferSize_ = HGCalParameters::k_ScaleFromDD4Hep * rv; double dz = 0.5 * HGCalParameters::k_ScaleFromDD4HepToG4 * (zv[1] - zv[0]); #ifdef EDM_ML_DEBUG @@ -1008,6 +1008,19 @@ void HGCalGeomParameters::loadSpecParsHexagon8(const DDFilteredView& fv, HGCalPa php.layerOffset_ = dummy2[0]; php.layerCenter_ = dbl_to_int(DDVectorGetter::get("LayerCenter")); + // Read in parameters from Philip's file + if (php.waferMaskMode_ == siliconFileEE) { + waferIndex_ = dbl_to_int(DDVectorGetter::get("WaferIndexEE")); + waferTypes_ = dbl_to_int(DDVectorGetter::get("WaferTypesEE")); + waferParts_ = dbl_to_int(DDVectorGetter::get("WaferPartialEE")); + waferOrien_ = dbl_to_int(DDVectorGetter::get("WaferOrientEE")); + } else if (php.waferMaskMode_ == siliconFileHE) { + waferIndex_ = dbl_to_int(DDVectorGetter::get("WaferIndexHE")); + waferTypes_ = dbl_to_int(DDVectorGetter::get("WaferTypesHE")); + waferParts_ = dbl_to_int(DDVectorGetter::get("WaferPartialHE")); + waferOrien_ = dbl_to_int(DDVectorGetter::get("WaferOrientHE")); + } + loadSpecParsHexagon8(php); } @@ -1066,10 +1079,45 @@ void HGCalGeomParameters::loadSpecParsHexagon8(const cms::DDFilteredView& fv, } } + // Read in parameters from Philip's file + if (php.waferMaskMode_ == siliconFileEE) { + for (auto const& it : vmap) { + if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "WaferIndexEE")) { + for (const auto& i : it.second) + waferIndex_.emplace_back(std::round(i)); + } else if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "WaferTypesEE")) { + for (const auto& i : it.second) + waferTypes_.emplace_back(std::round(i)); + } else if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "WaferPartialEE")) { + for (const auto& i : it.second) + waferParts_.emplace_back(std::round(i)); + } else if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "WaferOrientEE")) { + for (const auto& i : it.second) + waferOrien_.emplace_back(std::round(i)); + } + } + } else if (php.waferMaskMode_ == siliconFileHE) { + for (auto const& it : vmap) { + if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "WaferIndexHE")) { + for (const auto& i : it.second) + waferIndex_.emplace_back(std::round(i)); + } else if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "WaferTypesHE")) { + for (const auto& i : it.second) + waferTypes_.emplace_back(std::round(i)); + } else if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "WaferPartialHE")) { + for (const auto& i : it.second) + waferParts_.emplace_back(std::round(i)); + } else if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "WaferOrientHE")) { + for (const auto& i : it.second) + waferOrien_.emplace_back(std::round(i)); + } + } + } + loadSpecParsHexagon8(php); } -void HGCalGeomParameters::loadSpecParsHexagon8(const HGCalParameters& php) { +void HGCalGeomParameters::loadSpecParsHexagon8(HGCalParameters& php) { #ifdef EDM_ML_DEBUG for (unsigned int k = 0; k < php.cellThickness_.size(); ++k) edm::LogVerbatim("HGCalGeom") << "HGCalGeomParameters: cell[" << k << "] Thickness " << php.cellThickness_[k]; @@ -1101,6 +1149,22 @@ void HGCalGeomParameters::loadSpecParsHexagon8(const HGCalParameters& php) { for (unsigned int k = 0; k < php.layerCenter_.size(); ++k) edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << php.layerCenter_[k]; #endif + + // Store parameters from Philip's file + if (php.waferMaskMode_ > 1) { + for (unsigned int k = 0; k < waferIndex_.size(); ++k) { + php.waferInfoMap_[waferIndex_[k]] = HGCalParameters::waferInfo(waferTypes_[k], waferParts_[k], waferOrien_[k]); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "[" << k << ":" << waferIndex_[k] << "] " + << " Type " << waferTypes_[k] << " Partial type " << waferParts_[k] + << " Orientation " << waferOrien_[k]; +#endif + } + waferIndex_.clear(); + waferTypes_.clear(); + waferParts_.clear(); + waferOrien_.clear(); + } } void HGCalGeomParameters::loadSpecParsTrapezoid(const DDFilteredView& fv, HGCalParameters& php) { @@ -1137,6 +1201,23 @@ void HGCalGeomParameters::loadSpecParsTrapezoid(const DDFilteredView& fv, HGCalP php.layerOffset_ = dummy2[0]; php.layerCenter_ = dbl_to_int(DDVectorGetter::get("LayerCenter")); + // tile parameters from Katja's file + if (php.waferMaskMode_ == scintillatorFile) { + tileIndx_ = dbl_to_int(DDVectorGetter::get("TileIndex")); + tileType_ = dbl_to_int(DDVectorGetter::get("TileType")); + tileSiPM_ = dbl_to_int(DDVectorGetter::get("TileSiPM")); + tileHEX1_ = dbl_to_int(DDVectorGetter::get("TileHEX1")); + tileHEX2_ = dbl_to_int(DDVectorGetter::get("TileHEX2")); + tileHEX3_ = dbl_to_int(DDVectorGetter::get("TileHEX3")); + tileHEX4_ = dbl_to_int(DDVectorGetter::get("TileHEX4")); + tileRMin_ = DDVectorGetter::get("TileRMin"); + tileRMax_ = DDVectorGetter::get("TileRMax"); + rescale(tileRMin_, HGCalParameters::k_ScaleFromDDD); + rescale(tileRMax_, HGCalParameters::k_ScaleFromDDD); + tileRingMin_ = dbl_to_int(DDVectorGetter::get("TileRingMin")); + tileRingMax_ = dbl_to_int(DDVectorGetter::get("TileRingMax")); + } + loadSpecParsTrapezoid(php); } @@ -1184,10 +1265,50 @@ void HGCalGeomParameters::loadSpecParsTrapezoid(const cms::DDFilteredView& fv, const auto& dummy2 = fv.get >(sdTag1, "LayerOffset"); php.layerOffset_ = dummy2[0]; + // tile parameters from Katja's file + if (php.waferMaskMode_ == scintillatorFile) { + for (auto const& it : vmap) { + if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "TileIndex")) { + for (const auto& i : it.second) + tileIndx_.emplace_back(std::round(i)); + } else if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "TileType")) { + for (const auto& i : it.second) + tileType_.emplace_back(std::round(i)); + } else if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "TileSiPM")) { + for (const auto& i : it.second) + tileSiPM_.emplace_back(std::round(i)); + } else if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "TileHEX1")) { + for (const auto& i : it.second) + tileHEX1_.emplace_back(std::round(i)); + } else if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "TileHEX2")) { + for (const auto& i : it.second) + tileHEX2_.emplace_back(std::round(i)); + } else if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "TileHEX3")) { + for (const auto& i : it.second) + tileHEX3_.emplace_back(std::round(i)); + } else if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "TileHEX4")) { + for (const auto& i : it.second) + tileHEX4_.emplace_back(std::round(i)); + } else if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "TileRMin")) { + for (const auto& i : it.second) + tileRMin_.emplace_back(HGCalParameters::k_ScaleFromDD4Hep * i); + } else if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "TileRMax")) { + for (const auto& i : it.second) + tileRMax_.emplace_back(HGCalParameters::k_ScaleFromDD4Hep * i); + } else if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "TileRingMin")) { + for (const auto& i : it.second) + tileRingMin_.emplace_back(std::round(i)); + } else if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "TileRingMax")) { + for (const auto& i : it.second) + tileRingMax_.emplace_back(std::round(i)); + } + } + } + loadSpecParsTrapezoid(php); } -void HGCalGeomParameters::loadSpecParsTrapezoid(const HGCalParameters& php) { +void HGCalGeomParameters::loadSpecParsTrapezoid(HGCalParameters& php) { #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "HGCalGeomParameters:nCells " << php.nCellsFine_ << ":" << php.nCellsCoarse_ << " cellSize: " << php.cellSize_[0] << ":" << php.cellSize_[1]; @@ -1216,6 +1337,42 @@ void HGCalGeomParameters::loadSpecParsTrapezoid(const HGCalParameters& php) { for (unsigned int k = 0; k < php.layerCenter_.size(); ++k) edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << php.layerCenter_[k]; #endif + + // tile parameters from Katja's file + if (php.waferMaskMode_ == scintillatorFile) { + for (unsigned int k = 0; k < tileIndx_.size(); ++k) { + php.tileInfoMap_[tileIndx_[k]] = + HGCalParameters::tileInfo(tileType_[k], tileSiPM_[k], tileHEX1_[k], tileHEX2_[k], tileHEX3_[k], tileHEX4_[k]); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "Tile[" << k << ":" << tileIndx_[k] << "] " + << " Type " << tileType_[k] << " SiPM " << tileSiPM_[k] << " HEX " << tileHEX1_[k] + << ":" << tileHEX2_[k] << ":" << tileHEX3_[k] << ":" << tileHEX4_[k]; +#endif + } + tileIndx_.clear(); + tileType_.clear(); + tileSiPM_.clear(); + tileHEX1_.clear(); + tileHEX2_.clear(); + tileHEX3_.clear(); + tileHEX4_.clear(); + for (unsigned int k = 0; k < tileRMin_.size(); ++k) { + php.tileRingR_.emplace_back(tileRMin_[k], tileRMax_[k]); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "TileRingR[" << k << "] " << tileRMin_[k] << ":" << tileRMax_[k]; + #endif + } + tileRMin_.clear(); + tileRMax_.clear(); + for (unsigned k = 0; k < tileRingMin_.size(); ++k) { + php.tileRingRange_.emplace_back(tileRingMin_[k], tileRingMax_[k]); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "TileRingRange[" << k << "] " << tileRingMin_[k] << ":" << tileRingMax_[k]; +#endif + } + tileRingMin_.clear(); + tileRingMax_.clear(); + } } void HGCalGeomParameters::loadWaferHexagon(HGCalParameters& php) { @@ -1343,11 +1500,14 @@ void HGCalGeomParameters::loadWaferHexagon8(HGCalParameters& php) { double r = 0.5 * (waferW + waferS); double R = 2.0 * r / sqrt3_; double dy = 0.75 * R; + double r1 = 0.5 * waferW; + double R1 = 2.0 * r1 / sqrt3_; int N = (r == 0) ? 3 : ((int)(0.5 * rout / r) + 3); int ns1 = (2 * N + 1) * (2 * N + 1); int ns2 = ns1 * php.zLayerHex_.size(); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "r " << r << " dy " << dy << " N " << N << " sizes " << ns1 << ":" << ns2; + edm::LogVerbatim("HGCalGeom") << "wafer " << waferW << ":" << waferS << " r " << r << " dy " << dy << " N " << N + << " sizes " << ns1 << ":" << ns2; std::vector indtypes(ns1 + 1); indtypes.clear(); #endif @@ -1368,7 +1528,7 @@ void HGCalGeomParameters::loadWaferHexagon8(HGCalParameters& php) { php.waferPosY_.emplace_back(ypos); wafersInLayers[indx] = ipos; ++ipos; - std::pair corner = HGCalGeomTools::waferCorner(xpos, ypos, r, R, 0, rout, false); + std::pair corner = HGCalGeomTools::waferCorner(xpos, ypos, r1, R1, 0, rout, false); if ((corner.first == (int)(HGCalParameters::k_CornerSize)) || ((corner.first > 0) && php.defineFull_)) { uvmax = std::max(uvmax, std::max(std::abs(u), std::abs(v))); } @@ -1376,9 +1536,11 @@ void HGCalGeomParameters::loadWaferHexagon8(HGCalParameters& php) { int copy = i + php.layerOffset_; std::pair xyoff = geomTools_.shiftXY(php.layerCenter_[copy], (waferW + waferS)); int lay = php.layer_[php.layerIndex_[i]]; + double xpos0 = xpos + xyoff.first; + double ypos0 = ypos + xyoff.second; double zpos = php.zLayerHex_[i]; - int type = wType->getType(HGCalParameters::k_ScaleToDDD * (xpos + xyoff.first), - HGCalParameters::k_ScaleToDDD * (ypos + xyoff.second), + int type = wType->getType(HGCalParameters::k_ScaleToDDD * xpos0, + HGCalParameters::k_ScaleToDDD * ypos0, HGCalParameters::k_ScaleToDDD * zpos); php.waferTypeL_.emplace_back(type); int kndx = HGCalWaferIndex::waferIndex(lay, u, v); @@ -1388,7 +1550,7 @@ void HGCalGeomParameters::loadWaferHexagon8(HGCalParameters& php) { indtypes.emplace_back(kndx); #endif std::pair corner = - HGCalGeomTools::waferCorner(xpos, ypos, r, R, php.rMinLayHex_[i], php.rMaxLayHex_[i], false); + HGCalGeomTools::waferCorner(xpos0, ypos0, r1, R1, php.rMinLayHex_[i], php.rMaxLayHex_[i], false); #ifdef EDM_ML_DEBUG if (((corner.first == 0) && std::abs(u) < 5 && std::abs(v) < 5) || (std::abs(u) < 2 && std::abs(v) < 2)) { edm::LogVerbatim("HGCalGeom") << "Layer " << lay << " R " << php.rMinLayHex_[i] << ":" << php.rMaxLayHex_[i] @@ -1406,12 +1568,14 @@ void HGCalGeomParameters::loadWaferHexagon8(HGCalParameters& php) { int wl = HGCalWaferIndex::waferIndex(lay, u, v); if (php.waferMaskMode_ > 0) { std::pair corner0 = HGCalWaferMask::getTypeMode( - xpos, ypos, r, R, php.rMinLayHex_[i], php.rMaxLayHex_[i], N, php.waferMaskMode_); + xpos0, ypos0, r1, R1, php.rMinLayHex_[i], php.rMaxLayHex_[i], type, php.waferMaskMode_); waferTypes[wl] = corner0; #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") - << "Layer " << lay << " u|v " << u << ":" << v << " with corner " << corner.first << ":" - << corner.second << " croner0 " << corner0.first << ":" << corner0.second; + << "Layer " << lay << " u|v " << u << ":" << v << " Index " << std::hex << wl << std::dec << " pos " + << xpos0 << ":" << ypos0 << " R " << r1 << ":" << R1 << " Range " << php.rMinLayHex_[i] << ":" + << php.rMaxLayHex_[i] << type << ":" << php.waferMaskMode_ << " corner " << corner.first << ":" + << corner.second << " croner0 " << corner0.first << ":" << corner0.second; #endif } else { waferTypes[wl] = corner; diff --git a/Geometry/HGCalCommonData/src/HGCalGeomTools.cc b/Geometry/HGCalCommonData/src/HGCalGeomTools.cc index 96623558b0259..327f9ed64b4b8 100644 --- a/Geometry/HGCalCommonData/src/HGCalGeomTools.cc +++ b/Geometry/HGCalCommonData/src/HGCalGeomTools.cc @@ -1,4 +1,5 @@ #include "Geometry/HGCalCommonData/interface/HGCalGeomTools.h" +#include "Geometry/HGCalCommonData/interface/HGCalTypes.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "Geometry/HGCalCommonData/interface/HGCalParameters.h" @@ -162,22 +163,22 @@ double HGCalGeomTools::radius( return r; } -std::pair HGCalGeomTools::shiftXY(int waferPosition, double waferSize) { +std::pair HGCalGeomTools::shiftXY(int waferPosition, double waferSize) const { double dx(0), dy(0); switch (waferPosition) { - case (CornerCenterYp): { + case (HGCalTypes::CornerCenterYp): { dy = factor_ * waferSize; break; } - case (CornerCenterYm): { + case (HGCalTypes::CornerCenterYm): { dy = -factor_ * waferSize; break; } - case (CornerCenterXp): { + case (HGCalTypes::CornerCenterXp): { dx = factor_ * waferSize; break; } - case (CornerCenterXm): { + case (HGCalTypes::CornerCenterXm): { dx = -factor_ * waferSize; break; } diff --git a/Geometry/HGCalCommonData/src/HGCalParametersFromDD.cc b/Geometry/HGCalCommonData/src/HGCalParametersFromDD.cc index 30d4ab16e993c..93403ed7d3e2e 100644 --- a/Geometry/HGCalCommonData/src/HGCalParametersFromDD.cc +++ b/Geometry/HGCalCommonData/src/HGCalParametersFromDD.cc @@ -103,6 +103,7 @@ bool HGCalParametersFromDD::build(const DDCompactView* cpv, #endif } php.minTileSize_ = 0; + php.waferMaskMode_ = 0; } if ((php.mode_ == HGCalGeometryMode::Hexagon8) || (php.mode_ == HGCalGeometryMode::Hexagon8Full)) { php.levelT_ = dbl_to_int(getDDDArray("LevelTop", sv)); @@ -134,7 +135,7 @@ bool HGCalParametersFromDD::build(const DDCompactView* cpv, php.waferThick_ = HGCalParameters::k_ScaleFromDDD * getDDDValue("WaferThickness", sv2); php.sensorSeparation_ = HGCalParameters::k_ScaleFromDDD * getDDDValue("SensorSeparation", sv2); php.mouseBite_ = HGCalParameters::k_ScaleFromDDD * getDDDValue("MouseBite", sv2); - php.waferR_ = 0.5 * HGCalParameters::k_ScaleToDDD * php.waferSize_ / std::cos(30._deg); + php.waferR_ = HGCalParameters::k_ScaleToDDD * php.waferSize_ * tan30deg_; php.cellSize_.emplace_back(HGCalParameters::k_ScaleToDDD * php.waferSize_ / php.nCellsFine_); php.cellSize_.emplace_back(HGCalParameters::k_ScaleToDDD * php.waferSize_ / php.nCellsCoarse_); #ifdef EDM_ML_DEBUG @@ -199,10 +200,13 @@ bool HGCalParametersFromDD::build(const DDCompactView* cpv, php.minTileSize_ = HGCalParameters::k_ScaleFromDDD * getDDDValue("MinimumTileSize", sv); php.waferSize_ = php.waferR_ = 0; php.sensorSeparation_ = php.mouseBite_ = 0; + php.waferMaskMode_ = static_cast(getDDDValue("WaferMaskMode", sv)); #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "Top levels " << php.levelT_[0] << ":" << php.levelT_[1] << " first layers " << php.firstLayer_ << ":" << php.firstMixedLayer_ << " Det Type " - << php.detectorType_ << " thickenss " << php.waferThick_; + << php.detectorType_ << " thickenss " << php.waferThick_ << " Tile Mask Mode " + << php.waferMaskMode_; + ; #endif // Load the SpecPars geom->loadSpecParsTrapezoid(fv, php); @@ -271,6 +275,7 @@ bool HGCalParametersFromDD::build(const cms::DDCompactView* cpv, << HGCalGeometryMode::ExtrudedPolygon; #endif php.minTileSize_ = 0; + php.waferMaskMode_ = 0; } if ((php.mode_ == HGCalGeometryMode::Hexagon8) || (php.mode_ == HGCalGeometryMode::Hexagon8Full)) { php.levelT_ = dbl_to_int(fv.get >(name, "LevelTop")); @@ -283,10 +288,14 @@ bool HGCalParametersFromDD::build(const cms::DDCompactView* cpv, tempD = fv.get >(name, "DetectorType"); php.detectorType_ = static_cast(tempD[0]); php.minTileSize_ = 0; + tempD = fv.get >(name, "WaferMaskMode"); + php.waferMaskMode_ = static_cast(tempD[0]); #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "Top levels " << php.levelT_[0] << ":" << php.levelT_[1] << " ZSide Level " << php.levelZSide_ << " first layers " << php.firstLayer_ << ":" - << php.firstMixedLayer_ << " Det Type " << php.detectorType_; + << php.firstMixedLayer_ << " Det Type " << php.detectorType_ << " Wafer Mask Mode " + << php.waferMaskMode_; + ; #endif tempS = fv.get >(namet, "WaferMode"); @@ -304,7 +313,7 @@ bool HGCalParametersFromDD::build(const cms::DDCompactView* cpv, php.sensorSeparation_ = HGCalParameters::k_ScaleFromDD4Hep * tempD[0]; tempD = fv.get >(namet, "MouseBite"); php.mouseBite_ = HGCalParameters::k_ScaleFromDD4Hep * tempD[0]; - php.waferR_ = 0.5 * HGCalParameters::k_ScaleToDDD * php.waferSize_ / std::cos(30._deg); + php.waferR_ = HGCalParameters::k_ScaleToDDD * php.waferSize_ * tan30deg_; php.cellSize_.emplace_back(HGCalParameters::k_ScaleToDDD * php.waferSize_ / php.nCellsFine_); php.cellSize_.emplace_back(HGCalParameters::k_ScaleToDDD * php.waferSize_ / php.nCellsCoarse_); #ifdef EDM_ML_DEBUG @@ -376,11 +385,14 @@ bool HGCalParametersFromDD::build(const cms::DDCompactView* cpv, php.minTileSize_ = HGCalParameters::k_ScaleFromDD4Hep * tempD[0]; php.waferSize_ = php.waferR_ = 0; php.sensorSeparation_ = php.mouseBite_ = 0; + tempD = fv.get >(name, "WaferMaskMode"); + php.waferMaskMode_ = static_cast(tempD[0]); #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "Top levels " << php.levelT_[0] << ":" << php.levelT_[1] << " first layers " << php.firstLayer_ << ":" << php.firstMixedLayer_ << " Det Type " << php.detectorType_ << " thickenss " << php.waferThick_ << " min tile size " - << php.minTileSize_; + << php.minTileSize_ << " Tile Mask Mode " << php.waferMaskMode_; + ; #endif // Load the SpecPars geom->loadSpecParsTrapezoid(fv, vmap, php, name); diff --git a/Geometry/HGCalCommonData/src/HGCalTileIndex.cc b/Geometry/HGCalCommonData/src/HGCalTileIndex.cc new file mode 100644 index 0000000000000..a1374ac447036 --- /dev/null +++ b/Geometry/HGCalCommonData/src/HGCalTileIndex.cc @@ -0,0 +1,14 @@ +#include "Geometry/HGCalCommonData/interface/HGCalTileIndex.h" + +int32_t HGCalTileIndex::tileIndex(int32_t layer, int32_t ring, int32_t phi) { + int32_t id(0); + id |= (((phi & kHGCalPhiMask) << kHGCalPhiOffset) | ((ring & kHGCalRingMask) << kHGCalRingOffset) | + ((layer & kHGCalLayerMask) << kHGCalLayerOffset)); + return id; +} + +int32_t HGCalTileIndex::tileLayer(int32_t id) { return ((id >> kHGCalLayerOffset) & kHGCalLayerMask); } + +int32_t HGCalTileIndex::tileRing(int32_t id) { return ((id >> kHGCalRingOffset) & kHGCalRingMask); } + +int32_t HGCalTileIndex::tilePhi(int32_t id) { return ((id >> kHGCalPhiOffset) & kHGCalPhiMask); } diff --git a/Geometry/HGCalCommonData/src/HGCalWaferMask.cc b/Geometry/HGCalCommonData/src/HGCalWaferMask.cc index 96fb2b3772f9f..8791bf6cfe965 100644 --- a/Geometry/HGCalCommonData/src/HGCalWaferMask.cc +++ b/Geometry/HGCalCommonData/src/HGCalWaferMask.cc @@ -1,4 +1,5 @@ #include "Geometry/HGCalCommonData/interface/HGCalWaferMask.h" +#include "Geometry/HGCalCommonData/interface/HGCalTypes.h" #include "Geometry/HGCalCommonData/interface/HGCalGeomTools.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" @@ -106,217 +107,219 @@ The argument 'corners' controls the types of wafers the user wants: for instance bool HGCalWaferMask::goodCell(int u, int v, int n, int type, int rotn) { bool good(false); int n2 = n / 2; + int n3 = (n + 1) / 3; + int n4 = n / 4; switch (type) { - case (HGCalGeomTools::WaferFull): { //WaferFull + case (HGCalTypes::WaferFull): { //WaferFull good = true; break; } - case (HGCalGeomTools::WaferFive): { //WaferFive + case (HGCalTypes::WaferFive): { //WaferFive switch (rotn) { - case (HGCalGeomTools::WaferCorner0): { - int u2 = (u + 1) / 2; + case (HGCalTypes::WaferCorner0): { + int u2 = u / 2; good = ((v - u2) < n); break; } - case (HGCalGeomTools::WaferCorner1): { - good = ((v + u) < (3 * n)); + case (HGCalTypes::WaferCorner1): { + good = ((v + u) < (3 * n - 1)); break; } - case (HGCalGeomTools::WaferCorner2): { - good = ((2 * u - v) <= (2 * n)); + case (HGCalTypes::WaferCorner2): { + int v2 = (v + 1) / 2; + good = ((u - v2) < n); break; } - case (HGCalGeomTools::WaferCorner3): { - int u2 = u / 2; - good = (v >= u2); + case (HGCalTypes::WaferCorner3): { + int u2 = (u + 1) / 2; + good = (u2 <= v); break; } - case (HGCalGeomTools::WaferCorner4): { - good = ((v + u) <= (n - 1)); + case (HGCalTypes::WaferCorner4): { + good = ((v + u) >= n); break; } default: { - good = (v <= (2 * u)); + int v2 = v / 2; + good = (u > v2); break; } } break; } - case (HGCalGeomTools::WaferChopTwo): { //WaferChopTwo + case (HGCalTypes::WaferChopTwo): { //WaferChopTwo switch (rotn) { - case (HGCalGeomTools::WaferCorner0): { - good = (v <= (3 * n2)); + case (HGCalTypes::WaferCorner0): { + good = (v < (3 * n2)); break; } - case (HGCalGeomTools::WaferCorner1): { - good = (u <= (3 * n2)); + case (HGCalTypes::WaferCorner1): { + good = (u < (3 * n2)); break; } - case (HGCalGeomTools::WaferCorner2): { - good = ((u - v) <= (n2 + 1)); + case (HGCalTypes::WaferCorner2): { + good = ((u - v) <= n2); break; } - case (HGCalGeomTools::WaferCorner3): { - good = (v >= (n2 - 1)); + case (HGCalTypes::WaferCorner3): { + good = (v >= n2); break; } - case (HGCalGeomTools::WaferCorner4): { - good = (u >= (n2 - 1)); + case (HGCalTypes::WaferCorner4): { + good = (u >= n2); break; } default: { - good = ((v - u) <= n2); + good = ((v - u) < n2); break; } } break; } - case (HGCalGeomTools::WaferChopTwoM): { //WaferChopTwoM + case (HGCalTypes::WaferChopTwoM): { //WaferChopTwoM switch (rotn) { - case (HGCalGeomTools::WaferCorner0): { - good = (v < (3 * n2)); + case (HGCalTypes::WaferCorner0): { + good = (v < (5 * n4)); break; } - case (HGCalGeomTools::WaferCorner1): { - good = (u < (3 * n2)); + case (HGCalTypes::WaferCorner1): { + good = (u < (5 * n4)); break; } - case (HGCalGeomTools::WaferCorner2): { - good = ((u - v) <= n2); + case (HGCalTypes::WaferCorner2): { + good = ((u - v) <= n4); break; } - case (HGCalGeomTools::WaferCorner3): { - good = (v >= n2); + case (HGCalTypes::WaferCorner3): { + good = (v >= (3 * n4)); break; } - case (HGCalGeomTools::WaferCorner4): { - good = (u >= n2); + case (HGCalTypes::WaferCorner4): { + good = (u >= (3 * n4)); break; } default: { - good = ((v - u) < n2); + good = ((v - u) < n4); break; } } break; } - case (HGCalGeomTools::WaferHalf): { //WaferHalf + case (HGCalTypes::WaferHalf): { //WaferHalf switch (rotn) { - case (HGCalGeomTools::WaferCorner0): { + case (HGCalTypes::WaferCorner0): { good = (v < n); break; } - case (HGCalGeomTools::WaferCorner1): { - good = (u <= n); + case (HGCalTypes::WaferCorner1): { + good = (u < n); break; } - case (HGCalGeomTools::WaferCorner2): { + case (HGCalTypes::WaferCorner2): { good = (v >= u); break; } - case (HGCalGeomTools::WaferCorner3): { - good = (v >= (n - 1)); + case (HGCalTypes::WaferCorner3): { + good = (v >= n); break; } - case (HGCalGeomTools::WaferCorner4): { + case (HGCalTypes::WaferCorner4): { good = (u >= n); break; } default: { - good = (u >= v); + good = (u > v); break; } } break; } - case (HGCalGeomTools::WaferSemi): { //WaferSemi + case (HGCalTypes::WaferSemi): { //WaferSemi switch (rotn) { - case (HGCalGeomTools::WaferCorner0): { - good = ((u + v) <= (2 * n - 1)); + case (HGCalTypes::WaferCorner0): { + good = ((u + v) < (2 * n)); break; } - case (HGCalGeomTools::WaferCorner1): { - good = ((2 * u - v) >= n); + case (HGCalTypes::WaferCorner1): { + good = ((2 * u - v) < n); break; } - case (HGCalGeomTools::WaferCorner2): { - int u2 = ((u + 1) / 2); - good = ((v - u2) >= (n2 - 1)); + case (HGCalTypes::WaferCorner2): { + good = ((2 * v - u) >= n); break; } - case (HGCalGeomTools::WaferCorner3): { - good = ((u + v) >= (2 * n - 1)); + case (HGCalTypes::WaferCorner3): { + good = ((u + v) >= (2 * n)); break; } - case (HGCalGeomTools::WaferCorner4): { - good = ((2 * u - v) <= n); + case (HGCalTypes::WaferCorner4): { + good = ((2 * u - v) > n); break; } default: { - int u2 = ((u + 1) / 2); - good = ((v - u2) <= (n2 - 1)); + good = ((2 * v - u) < n); break; } } break; } - case (HGCalGeomTools::WaferThree): { //WaferThree + case (HGCalTypes::WaferThree): { //WaferThree switch (rotn) { - case (HGCalGeomTools::WaferCorner0): { + case (HGCalTypes::WaferCorner0): { good = ((v + u) < n); break; } - case (HGCalGeomTools::WaferCorner1): { - good = (v >= (2 * u)); + case (HGCalTypes::WaferCorner1): { + int v2 = v / 2; + good = (u <= v2); break; } - case (HGCalGeomTools::WaferCorner2): { + case (HGCalTypes::WaferCorner2): { int u2 = (u / 2); good = ((v - u2) >= n); break; } - case (HGCalGeomTools::WaferCorner3): { + case (HGCalTypes::WaferCorner3): { good = ((v + u) >= (3 * n - 1)); break; } - case (HGCalGeomTools::WaferCorner4): { - good = ((2 * u - v) >= (2 * n)); + case (HGCalTypes::WaferCorner4): { + int v2 = v / 2; + good = ((u - v2) >= n); break; } default: { - int u2 = (u / 2); - good = (v <= u2); + int u2 = ((u + 1) / 2); + good = (v < u2); break; } } break; } - case (HGCalGeomTools::WaferSemi2): { //WaferSemi2 + case (HGCalTypes::WaferSemi2): { //WaferSemi2 switch (rotn) { - case (HGCalGeomTools::WaferCorner0): { - good = ((u + v) < (2 * n - 1)); + case (HGCalTypes::WaferCorner0): { + good = ((u + v) < (4 * n3)); break; } - case (HGCalGeomTools::WaferCorner1): { - good = ((2 * u - v) > n); + case (HGCalTypes::WaferCorner1): { + good = ((2 * u - v) <= n2); break; } - case (HGCalGeomTools::WaferCorner2): { - int u2 = ((u + 1) / 2); - good = ((v - u2) > (n2 - 1)); + case (HGCalTypes::WaferCorner2): { + good = ((2 * v - u) > (3 * n2)); break; } - case (HGCalGeomTools::WaferCorner3): { - good = ((u + v) > (2 * n - 1)); + case (HGCalTypes::WaferCorner3): { + good = ((u + v) >= (5 * n2 - 1)); break; } - case (HGCalGeomTools::WaferCorner4): { - good = ((2 * u - v) < n); + case (HGCalTypes::WaferCorner4): { + good = ((2 * u - v) < (3 * n2)); break; } default: { - int u2 = ((u + 1) / 2); - good = ((v - u2) < (n2 - 1)); + good = ((2 * v - u) <= n3); break; } } @@ -336,30 +339,20 @@ std::pair HGCalWaferMask::getTypeMode(const double& xpos, const double& delY, const double& rin, const double& rout, - const int& nw, - const int& mode) { - int ncor(0), fcor(0), iok(0); - int type(HGCalGeomTools::WaferFull), rotn(HGCalGeomTools::WaferCorner0); - static const double sqrt3 = std::sqrt(3.0); - double dxw = delX / (nw * sqrt3); - double dyw = 0.5 * delX / nw; + const int& wType, + const int& mode, + bool debug) { + int ncor(0), iok(0); + int type(HGCalTypes::WaferFull), rotn(HGCalTypes::WaferCorner0); static const int corners = 6; static const int base = 10; + double dx0[corners] = {0.0, delX, delX, 0.0, -delX, -delX}; + double dy0[corners] = {-delY, -0.5 * delY, 0.5 * delY, delY, 0.5 * delY, -0.5 * delY}; double xc[corners], yc[corners]; - xc[0] = xpos; - yc[0] = ypos + delY; - xc[1] = xpos - delX; - yc[1] = ypos + 0.5 * delY; - xc[2] = xpos - delX; - yc[2] = ypos - 0.5 * delY; - xc[3] = xpos; - yc[3] = ypos - delY; - xc[4] = xpos + delX; - yc[4] = ypos - 0.5 * delY; - xc[5] = xpos + delX; - yc[5] = ypos + 0.5 * delY; for (int k = 0; k < corners; ++k) { + xc[k] = xpos + dx0[k]; + yc[k] = ypos + dy0[k]; double rpos = sqrt(xc[k] * xc[k] + yc[k] * yc[k]); if (rpos <= rout && rpos >= rin) { ++ncor; @@ -368,65 +361,81 @@ std::pair HGCalWaferMask::getTypeMode(const double& xpos, iok *= base; } } - static const int ipat5[corners] = {111110, 11111, 101111, 110111, 111011, 111101}; - static const int ipat4[corners] = {111100, 11110, 1111, 100111, 110011, 111001}; - static const int ipat3[corners] = {111000, 11100, 1110, 111, 100011, 110001}; - double dx1[corners] = {(0.5 * delX + dxw), -0.5 * delX, -delX, -0.5 * delX, (0.5 * delX - dxw), delX}; - double dy1[corners] = {(0.75 * delY - dyw), 0.75 * delY, dyw, -0.75 * delY, -(0.75 * delY + dyw), 0.0}; - double dx2[corners] = {(0.5 * delX + dxw), delX, (0.5 * delX - dxw), -0.5 * delX, -delX, -0.5 * delX}; - double dy2[corners] = {-(0.75 * delY - dyw), 0.0, (0.75 * delY + dyw), 0.75 * delY, -dyw, -0.75 * delY}; - double dx3[corners] = {(0.5 * delX - dxw), -0.5 * delX, -delX, -0.5 * delX, (0.5 * delX + dxw), delX}; - double dy3[corners] = {(0.75 * delY + dyw), 0.75 * delY, -dyw, -0.75 * delY, -(0.75 * delY - dyw), 0.0}; - double dx4[corners] = {(0.5 * delX - dxw), delX, (0.5 * delX + dxw), 0.5 * delX, -delX, -0.5 * delX}; - double dy4[corners] = {-(0.75 * delY + dyw), 0.0, (0.75 * delY - dyw), 0.75 * delY, dyw, -0.75 * delY}; - double dx5[corners] = {0.5 * delX, -0.5 * delX, -delX, -0.5 * delX, 0.5 * delX, delX}; - double dy5[corners] = {0.75 * delY, 0.75 * delY, 0.0, -0.75 * delY, -0.75 * delY, 0.0}; - double dx6[corners] = {-0.5 * delX, 0.5 * delX, delX, 0.5 * delX, -0.5 * delX, -delX}; - double dy6[corners] = {-0.75 * delY, -0.75 * delY, 0.0, 0.75 * delY, 0.75 * delY, 0.0}; + if (debug) + edm::LogVerbatim("HGCalGeom") << "I/p " << xpos << ":" << ypos << ":" << delX << ":" << delY << ":" << rin << ":" + << rout << ":" << wType << ":" << mode << " Corners " << ncor << " iok " << iok; + + static const int ipat5[corners] = {101111, 110111, 111011, 111101, 111110, 11111}; + static const int ipat4[corners] = {100111, 110011, 111001, 111100, 11110, 1111}; + static const int ipat3[corners] = {100011, 110001, 111000, 11100, 1110, 111}; + double dx1[corners] = {0.5 * delX, delX, 0.5 * delX, -0.5 * delX, -delX, -0.5 * delX}; + double dy1[corners] = {-0.75 * delY, 0.0, 0.75 * delY, 0.75 * delY, 0.0, -0.75 * delY}; + double dx2[corners] = {0.5 * delX, -0.5 * delX, -delX, -0.5 * delX, 0.5 * delX, delX}; + double dy2[corners] = {0.75 * delY, 0.75 * delY, 0.0, -0.75 * delY, -0.75 * delY, 0.0}; + double dx3[corners] = {0.25 * delX, delX, 0.75 * delX, -0.25 * delX, -delX, -0.75 * delX}; + double dy3[corners] = {-0.875 * delY, -0.25 * delY, 0.625 * delY, 0.875 * delY, 0.25 * delY, -0.625 * delY}; + double dx4[corners] = {0.25 * delX, -0.75 * delX, -delX, -0.25 * delX, 0.75 * delX, delX}; + double dy4[corners] = {0.875 * delY, 0.625 * delY, -0.25 * delY, -0.875 * delY, -0.625 * delY, 0.25 * delY}; + double dx5[corners] = {-0.5 * delX, -delX, -0.5 * delX, 0.5 * delX, delX, 0.5 * delX}; + double dy5[corners] = {0.75 * delY, 0.0, -0.75 * delY, -0.75 * delY, 0.0, 0.75 * delY}; + double dx6[corners] = {-0.75 * delX, -delX, -0.25 * delX, 0.75 * delX, delX, 0.25 * delX}; + double dy6[corners] = {0.625 * delY, -0.25 * delY, -0.875 * delY, -0.625 * delY, 0.25 * delY, 0.875 * delY}; if (ncor == HGCalGeomTools::k_allCorners) { } else if (ncor == HGCalGeomTools::k_fiveCorners) { - fcor = static_cast(std::find(ipat5, ipat5 + 6, iok) - ipat5); - type = HGCalGeomTools::WaferFive; - rotn = fcor + 1; - if (rotn > 5) - rotn = 0; + rotn = static_cast(std::find(ipat5, ipat5 + 6, iok) - ipat5); + type = HGCalTypes::WaferFive; } else if (ncor == HGCalGeomTools::k_fourCorners) { - fcor = static_cast(std::find(ipat4, ipat4 + 6, iok) - ipat4); - type = HGCalGeomTools::WaferHalf; - rotn = fcor; - double rpos = sqrt((xpos + dx1[fcor]) * (xpos + dx1[fcor]) + (ypos + dy1[fcor]) * (ypos + dy1[fcor])); - if (rpos <= rout && rpos >= rin) { - rpos = sqrt((xpos + dx2[fcor]) * (xpos + dx2[fcor]) + (ypos + dy2[fcor]) * (ypos + dy2[fcor])); - if (rpos <= rout && rpos >= rin) - type = HGCalGeomTools::WaferChopTwo; + rotn = static_cast(std::find(ipat4, ipat4 + 6, iok) - ipat4); + type = HGCalTypes::WaferHalf; + double rpos1 = sqrt((xpos + dx1[rotn]) * (xpos + dx1[rotn]) + (ypos + dy1[rotn]) * (ypos + dy1[rotn])); + double rpos2(0); + if (rpos1 <= rout && rpos1 >= rin) { + rpos2 = sqrt((xpos + dx2[rotn]) * (xpos + dx2[rotn]) + (ypos + dy2[rotn]) * (ypos + dy2[rotn])); + if (rpos2 <= rout && rpos2 >= rin) + type = HGCalTypes::WaferChopTwo; } - if (type == HGCalGeomTools::WaferHalf) { - rpos = sqrt((xpos + dx3[fcor]) * (xpos + dx3[fcor]) + (ypos + dy3[fcor]) * (ypos + dy3[fcor])); - if (rpos <= rout && rpos >= rin) { - rpos = sqrt((xpos + dx4[fcor]) * (xpos + dx4[fcor]) + (ypos + dy4[fcor]) * (ypos + dy4[fcor])); - if (rpos <= rout && rpos >= rin) - type = HGCalGeomTools::WaferChopTwoM; + if (debug) + edm::LogVerbatim("HGCalGeom") << "Test for Chop2 " << rpos1 << ":" << rpos2 << " Type " << type; + if ((type == HGCalTypes::WaferHalf) && (wType == 0)) { + rpos1 = sqrt((xpos + dx3[rotn]) * (xpos + dx3[rotn]) + (ypos + dy3[rotn]) * (ypos + dy3[rotn])); + if (rpos1 <= rout && rpos1 >= rin) { + rpos2 = sqrt((xpos + dx4[rotn]) * (xpos + dx4[rotn]) + (ypos + dy4[rotn]) * (ypos + dy4[rotn])); + if (rpos2 <= rout && rpos2 >= rin) + type = HGCalTypes::WaferChopTwoM; } + if (debug) + edm::LogVerbatim("HGCalGeom") << "Test for Chop2M " << rpos1 << ":" << rpos2 << " Type " << type; } } else if (ncor == HGCalGeomTools::k_threeCorners) { - fcor = static_cast(std::find(ipat3, ipat3 + 6, iok) - ipat3); - type = HGCalGeomTools::WaferThree; - rotn = fcor - 1; - if (rotn < 0) - rotn = HGCalGeomTools::WaferCorner5; - double rpos = sqrt((xpos + dx5[fcor]) * (xpos + dx5[fcor]) + (ypos + dy5[fcor]) * (ypos + dy5[fcor])); - if (rpos <= rout && rpos >= rin) { - rpos = sqrt((xpos + dx6[fcor]) * (xpos + dx6[fcor]) + (ypos + dy6[fcor]) * (ypos + dy6[fcor])); - if (rpos <= rout && rpos >= rin) - type = HGCalGeomTools::WaferSemi; + rotn = static_cast(std::find(ipat3, ipat3 + 6, iok) - ipat3); + type = HGCalTypes::WaferThree; + double rpos1 = sqrt((xpos + dx1[rotn]) * (xpos + dx1[rotn]) + (ypos + dy1[rotn]) * (ypos + dy1[rotn])); + double rpos2(0); + if (rpos1 <= rout && rpos1 >= rin) { + rpos2 = sqrt((xpos + dx5[rotn]) * (xpos + dx5[rotn]) + (ypos + dy5[rotn]) * (ypos + dy5[rotn])); + if (rpos2 <= rout && rpos2 >= rin) + type = HGCalTypes::WaferSemi; + } + if (debug) + edm::LogVerbatim("HGCalGeom") << "Test for Semi " << rpos1 << ":" << rpos2 << " Type " << type; + if ((type == HGCalTypes::WaferThree) && (wType == 0)) { + rpos1 = sqrt((xpos + dx3[rotn]) * (xpos + dx3[rotn]) + (ypos + dy3[rotn]) * (ypos + dy3[rotn])); + if (rpos1 <= rout && rpos1 >= rin) { + rpos2 = sqrt((xpos + dx6[rotn]) * (xpos + dx6[rotn]) + (ypos + dy6[rotn]) * (ypos + dy6[rotn])); + if (rpos2 <= rout && rpos2 >= rin) + type = HGCalTypes::WaferSemi2; + } + if (debug) + edm::LogVerbatim("HGCalGeom") << "Test for SemiM " << rpos1 << ":" << rpos2 << " Type " << type; } } else { - type = HGCalGeomTools::WaferOut; + type = HGCalTypes::WaferOut; } -#ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "Corners " << ncor << ":" << fcor << " Type " << type << ":" << rotn; -#endif - return ((mode == 0) ? std::make_pair(ncor, fcor) : std::make_pair(type, k_OffsetRotation + rotn)); + if (debug) + edm::LogVerbatim("HGCalGeom") << "I/p " << xpos << ":" << ypos << ":" << delX << ":" << delY << ":" << rin << ":" + << rout << ":" << wType << ":" << mode << " o/p " << iok << ":" << ncor << ":" << type + << ":" << rotn; + return ((mode == 0) ? std::make_pair(ncor, rotn) : std::make_pair(type, (rotn + HGCalWaferMask::k_OffsetRotation))); } diff --git a/Geometry/HGCalCommonData/src/HGCalWaferType.cc b/Geometry/HGCalCommonData/src/HGCalWaferType.cc index 6c029ff72b9b6..402b119db2a2f 100644 --- a/Geometry/HGCalCommonData/src/HGCalWaferType.cc +++ b/Geometry/HGCalCommonData/src/HGCalWaferType.cc @@ -47,7 +47,7 @@ int HGCalWaferType::getType(double xpos, double ypos, double zpos) { yc[4] = ypos - R_; xc[5] = xpos + r_; yc[5] = ypos - 0.5 * R_; - std::pair rv = rLimits(zpos); + const auto& rv = rLimits(zpos); std::vector fine, coarse; for (unsigned int k = 0; k < HGCalParameters::k_CornerSize; ++k) { double rpos = std::sqrt(xc[k] * xc[k] + yc[k] * yc[k]); @@ -86,7 +86,7 @@ int HGCalWaferType::getType(double xpos, double ypos, double zpos) { ycn.emplace_back(yc[k1]); if (!ok) { double rr = (type == -1) ? rv.first : rv.second; - std::pair xy = intersection(k1, k2, xc, yc, xpos, ypos, rr); + const auto& xy = intersection(k1, k2, xc, yc, xpos, ypos, rr); xcn.emplace_back(xy.first); ycn.emplace_back(xy.second); } @@ -116,12 +116,17 @@ std::pair HGCalWaferType::rLimits(double zpos) { rcoarse *= zz; rcoarse += rad200_[i]; } - return std::pair(rfine * HGCalParameters::k_ScaleToDDD, rcoarse * HGCalParameters::k_ScaleToDDD); + rfine *= HGCalParameters::k_ScaleToDDD; + rcoarse *= HGCalParameters::k_ScaleToDDD; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "HGCalWaferType: Z " << zpos << ":" << zz << " R " << rfine << ":" << rcoarse; +#endif + return std::make_pair(rfine, rcoarse); } double HGCalWaferType::areaPolygon(std::vector const& x, std::vector const& y) { double area = 0.0; - int n = x.size(); + int n = static_cast(x.size()); int j = n - 1; for (int i = 0; i < n; ++i) { area += ((x[j] + x[i]) * (y[i] - y[j])); @@ -142,8 +147,12 @@ std::pair HGCalWaferType::intersection( xx[i] = (slope * yy[i] + interc); dist[i] = ((xx[i] - xpos) * (xx[i] - xpos)) + ((yy[i] - ypos) * (yy[i] - ypos)); } +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "HGCalWaferType: InterSection " << dist[0] << ":" << xx[0] << ":" << yy[0] << " vs " + << dist[1] << ":" << xx[1] << ":" << yy[1]; +#endif if (dist[0] > dist[1]) - return std::pair(xx[1], yy[1]); + return std::make_pair(xx[1], yy[1]); else - return std::pair(xx[0], yy[0]); + return std::make_pair(xx[0], yy[0]); } diff --git a/Geometry/HGCalCommonData/test/HGCalNumberingTester.cc b/Geometry/HGCalCommonData/test/HGCalNumberingTester.cc index 8b5d68fa1b5d9..87e0f6702a2db 100644 --- a/Geometry/HGCalCommonData/test/HGCalNumberingTester.cc +++ b/Geometry/HGCalCommonData/test/HGCalNumberingTester.cc @@ -42,7 +42,6 @@ class HGCalNumberingTester : public edm::one::EDAnalyzer<> { public: explicit HGCalNumberingTester(const edm::ParameterSet&); - ~HGCalNumberingTester() override; void beginJob() override {} void analyze(edm::Event const& iEvent, edm::EventSetup const&) override; @@ -89,8 +88,6 @@ HGCalNumberingTester::HGCalNumberingTester(const edm::ParameterSet& iC) { << std::endl; } -HGCalNumberingTester::~HGCalNumberingTester() {} - // ------------ method called to produce the data ------------ void HGCalNumberingTester::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { const HGCalDDDConstants& hgdc = iSetup.getData(dddToken_); @@ -99,9 +96,13 @@ void HGCalNumberingTester::analyze(const edm::Event& iEvent, const edm::EventSet if (detType_ != 0) { std::cout << "Minimum Wafer # " << hgdc.waferMin() << " Mamximum Wafer # " << hgdc.waferMax() << " Wafer counts " << hgdc.waferCount(0) << ":" << hgdc.waferCount(1) << std::endl; - for (unsigned int i = 0; i < hgdc.layers(true); ++i) - std::cout << "Layer " << i + 1 << " Wafers " << hgdc.wafers(i + 1, 0) << ":" << hgdc.wafers(i + 1, 1) << ":" - << hgdc.wafers(i + 1, 2) << std::endl; + for (unsigned int i = 0; i < hgdc.layers(true); ++i) { + int lay = i + 1; + double z = hgdc.waferZ(lay, reco_); + std::cout << "Layer " << lay << " Wafers " << hgdc.wafers(lay, 0) << ":" << hgdc.wafers(lay, 1) << ":" + << hgdc.wafers(lay, 2) << " Z " << z << " R " << hgdc.rangeR(z, reco_).first << ":" + << hgdc.rangeR(z, reco_).second << std::endl; + } } std::cout << std::endl << std::endl; std::pair xy; diff --git a/Geometry/HGCalCommonData/test/HGCalParameterTester.cc b/Geometry/HGCalCommonData/test/HGCalParameterTester.cc index eda67010aec7d..e039712fe93e6 100644 --- a/Geometry/HGCalCommonData/test/HGCalParameterTester.cc +++ b/Geometry/HGCalCommonData/test/HGCalParameterTester.cc @@ -22,6 +22,8 @@ class HGCalParameterTester : public edm::one::EDAnalyzer<> { private: template void myPrint(std::string const& s, std::vector const& obj, int n) const; + template + void myPrint(std::string const& s, std::vector > const& obj, int n) const; void myPrint(std::string const& s, std::vector const& obj1, std::vector const& obj2, int n) const; void myPrint(std::string const& s, HGCalParameters::wafer_map const& obj, int n) const; void printTrform(HGCalParameters const*) const; @@ -46,6 +48,7 @@ void HGCalParameterTester::analyze(const edm::Event& iEvent, const edm::EventSet std::cout << phgp->name_ << "\n"; if (mode_ == 0) { + // Wafers of 6-inch format std::cout << "DetectorType: " << phgp->detectorType_ << "\n"; std::cout << "WaferR_: " << phgp->waferR_ << "\n"; std::cout << "nCells_: " << phgp->nCells_ << "\n"; @@ -72,7 +75,7 @@ void HGCalParameterTester::analyze(const edm::Event& iEvent, const edm::EventSet myPrint("moduleDzR", phgp->moduleDzR_, 10); myPrint("moduleAlphaR", phgp->moduleAlphaR_, 10); myPrint("moduleCellR", phgp->moduleCellR_, 10); - myPrint("trformTranX", phgp->trformTranY_, 10); + myPrint("trformTranX", phgp->trformTranX_, 10); myPrint("trformTranY", phgp->trformTranY_, 10); myPrint("trformTranZ", phgp->trformTranZ_, 10); myPrint("trformRotXX", phgp->trformRotXX_, 10); @@ -112,6 +115,7 @@ void HGCalParameterTester::analyze(const edm::Event& iEvent, const edm::EventSet printWaferType(phgp); } else if (mode_ == 1) { + // Wafers of 8-inch format std::cout << "DetectorType: " << phgp->detectorType_ << "\n"; std::cout << "Wafer Parameters: " << phgp->waferSize_ << ":" << phgp->waferR_ << ":" << phgp->waferThick_ << ":" << phgp->sensorSeparation_ << ":" << phgp->mouseBite_ << "\n"; @@ -151,9 +155,9 @@ void HGCalParameterTester::analyze(const edm::Event& iEvent, const edm::EventSet myPrint("moduleDzR", phgp->moduleDzR_, 10); myPrint("moduleAlphaR", phgp->moduleAlphaR_, 10); myPrint("moduleCellR", phgp->moduleCellR_, 10); - myPrint("trformTranX", phgp->trformTranY_, 10); - myPrint("trformTranY", phgp->trformTranY_, 10); - myPrint("trformTranZ", phgp->trformTranZ_, 10); + myPrint("trformTranX", phgp->trformTranX_, 8); + myPrint("trformTranY", phgp->trformTranY_, 8); + myPrint("trformTranZ", phgp->trformTranZ_, 8); myPrint("trformRotXX", phgp->trformRotXX_, 10); myPrint("trformRotYX", phgp->trformRotYX_, 10); myPrint("trformRotZX", phgp->trformRotZX_, 10); @@ -163,15 +167,15 @@ void HGCalParameterTester::analyze(const edm::Event& iEvent, const edm::EventSet myPrint("trformRotXZ", phgp->trformRotXZ_, 10); myPrint("trformRotYZ", phgp->trformRotYZ_, 10); myPrint("trformRotZZ", phgp->trformRotZZ_, 10); - myPrint("xLayerHex", phgp->xLayerHex_, 10); - myPrint("yLayerHex", phgp->yLayerHex_, 10); - myPrint("zLayerHex", phgp->zLayerHex_, 10); - myPrint("rMinLayHex", phgp->rMinLayHex_, 10); - myPrint("rMaxLayHex", phgp->rMaxLayHex_, 10); + myPrint("xLayerHex", phgp->xLayerHex_, 8); + myPrint("yLayerHex", phgp->yLayerHex_, 8); + myPrint("zLayerHex", phgp->zLayerHex_, 8); + myPrint("rMinLayHex", phgp->rMinLayHex_, 8); + myPrint("rMaxLayHex", phgp->rMaxLayHex_, 8); myPrint("waferPos", phgp->waferPosX_, phgp->waferPosY_, 4); - myPrint("cellFineIndex", phgp->cellFineIndex_, 10); + myPrint("cellFineIndex", phgp->cellFineIndex_, 8); myPrint("cellFine", phgp->cellFineX_, phgp->cellFineY_, 4); - myPrint("cellCoarseIndex", phgp->cellCoarseIndex_, 10); + myPrint("cellCoarseIndex", phgp->cellCoarseIndex_, 8); myPrint("cellCoarse", phgp->cellCoarseX_, phgp->cellCoarseY_, 4); myPrint("layer", phgp->layer_, 18); myPrint("layerIndex", phgp->layerIndex_, 18); @@ -184,7 +188,17 @@ void HGCalParameterTester::analyze(const edm::Event& iEvent, const edm::EventSet myPrint("levelTop", phgp->levelT_, 10); printWaferType(phgp); + std::cout << "MaskMode: " << phgp->waferMaskMode_ << "\n"; + if (phgp->waferMaskMode_ > 1) { + std::cout << "WaferInfo with " << phgp->waferInfoMap_.size(); + unsigned int kk(0); + std::unordered_map::const_iterator itr = phgp->waferInfoMap_.begin(); + for (; itr != phgp->waferInfoMap_.end(); ++itr, ++kk) + std::cout << "[" << kk << "] " << itr->first << " (" << (itr->second).type << ", " << (itr->second).part << ", " + << (itr->second).orient << ")" << std::endl; + } } else { + // Tpaezoid (scintillator) type std::cout << "DetectorType: " << phgp->detectorType_ << "\n"; std::cout << "nCells_: " << phgp->nCellsFine_ << ":" << phgp->nCellsCoarse_ << "\n"; std::cout << "MinTileZize: " << phgp->minTileSize_ << "\n"; @@ -226,10 +240,10 @@ void HGCalParameterTester::analyze(const edm::Event& iEvent, const edm::EventSet myPrint("moduleHR", phgp->moduleHR_, 10); myPrint("moduleDzR", phgp->moduleDzR_, 10); myPrint("moduleAlphaR", phgp->moduleAlphaR_, 10); - myPrint("moduleCellR", phgp->moduleCellR_, 10); - myPrint("trformTranX", phgp->trformTranY_, 10); - myPrint("trformTranY", phgp->trformTranY_, 10); - myPrint("trformTranZ", phgp->trformTranZ_, 10); + myPrint("moduleCellR", phgp->moduleCellR_, 9); + myPrint("trformTranX", phgp->trformTranY_, 9); + myPrint("trformTranY", phgp->trformTranY_, 9); + myPrint("trformTranZ", phgp->trformTranZ_, 9); myPrint("trformRotXX", phgp->trformRotXX_, 10); myPrint("trformRotYX", phgp->trformRotYX_, 10); myPrint("trformRotZX", phgp->trformRotZX_, 10); @@ -242,8 +256,8 @@ void HGCalParameterTester::analyze(const edm::Event& iEvent, const edm::EventSet myPrint("xLayerHex", phgp->xLayerHex_, 10); myPrint("yLayerHex", phgp->yLayerHex_, 10); myPrint("zLayerHex", phgp->zLayerHex_, 10); - myPrint("rMinLayHex", phgp->rMinLayHex_, 10); - myPrint("rMaxLayHex", phgp->rMaxLayHex_, 10); + myPrint("rMinLayHex", phgp->rMinLayHex_, 9); + myPrint("rMaxLayHex", phgp->rMaxLayHex_, 9); myPrint("layer", phgp->layer_, 18); myPrint("layerIndex", phgp->layerIndex_, 18); myPrint("depth", phgp->depth_, 18); @@ -252,6 +266,19 @@ void HGCalParameterTester::analyze(const edm::Event& iEvent, const edm::EventSet printTrform(phgp); myPrint("levelTop", phgp->levelT_, 10); printWaferType(phgp); + + std::cout << "MaskMode: " << phgp->waferMaskMode_ << "\n"; + if (phgp->waferMaskMode_ > 1) { + myPrint("tileRingR", phgp->tileRingR_, 4); + myPrint("tileRingRange", phgp->tileRingRange_, 8); + std::cout << "TileInfo with " << phgp->tileInfoMap_.size(); + unsigned int kk(0); + std::unordered_map::const_iterator itr = phgp->tileInfoMap_.begin(); + for (; itr != phgp->tileInfoMap_.end(); ++itr, ++kk) + std::cout << "[" << kk << "] " << itr->first << " (" << (itr->second).type << ", " << (itr->second).sipm + << std::hex << ", " << (itr->second).hex1 << ", " << (itr->second).hex2 << ", " << (itr->second).hex3 + << ", " << (itr->second).hex4 << ")" << std::dec << std::endl; + } } auto finish = std::chrono::high_resolution_clock::now(); @@ -275,6 +302,22 @@ void HGCalParameterTester::myPrint(std::string const& s, std::vector const& o std::cout << "\n"; } +template +void HGCalParameterTester::myPrint(std::string const& s, std::vector > const& obj, int n) const { + int k(0); + std::cout << s << " with " << obj.size() << " elements\n"; + for (auto const& it : obj) { + std::cout << "(" << it.first << ", " << it.second << ") "; + ++k; + if (k == n) { + std::cout << "\n"; + k = 0; + } + } + if (k > 0) + std::cout << "\n"; +} + void HGCalParameterTester::myPrint(std::string const& s, std::vector const& obj1, std::vector const& obj2, @@ -315,7 +358,7 @@ void HGCalParameterTester::printTrform(HGCalParameters const* phgp) const { std::array id = phgp->getID(i); std::cout << id[0] << ":" << id[1] << ":" << id[2] << ":" << id[3] << ", "; ++k; - if (k == 10) { + if (k == 7) { std::cout << "\n"; k = 0; } diff --git a/Geometry/HGCalGeometry/interface/HGCalGeometry.h b/Geometry/HGCalGeometry/interface/HGCalGeometry.h index 5c1e8f89b5bdf..d8e2674d07f7c 100644 --- a/Geometry/HGCalGeometry/interface/HGCalGeometry.h +++ b/Geometry/HGCalGeometry/interface/HGCalGeometry.h @@ -72,6 +72,7 @@ class HGCalGeometry final : public CaloSubdetectorGeometry { CaloSubdetectorGeometry::IVec& dinsVector) const override; GlobalPoint getPosition(const DetId& id) const; + GlobalPoint getWaferPosition(const DetId& id) const; /// Returns area of a cell double getArea(const DetId& detid) const; diff --git a/Geometry/HGCalGeometry/plugins/HGCalGeometryESProducer.cc b/Geometry/HGCalGeometry/plugins/HGCalGeometryESProducer.cc index 98e8676a59e19..f82ce79c1c682 100644 --- a/Geometry/HGCalGeometry/plugins/HGCalGeometryESProducer.cc +++ b/Geometry/HGCalGeometry/plugins/HGCalGeometryESProducer.cc @@ -46,15 +46,16 @@ class HGCalGeometryESProducer : public edm::ESProducer { private: // ----------member data --------------------------- edm::ESGetToken topologyToken_; + std::string name_; }; HGCalGeometryESProducer::HGCalGeometryESProducer(const edm::ParameterSet& iConfig) { - auto name = iConfig.getUntrackedParameter("Name"); + name_ = iConfig.getUntrackedParameter("Name"); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "Constructing HGCalGeometry for " << name; + edm::LogVerbatim("HGCalGeom") << "Constructing HGCalGeometry for " << name_; #endif - auto cc = setWhatProduced(this, name); - topologyToken_ = cc.consumes(edm::ESInputTag{"", name}); + auto cc = setWhatProduced(this, name_); + topologyToken_ = cc.consumes(edm::ESInputTag{"", name_}); } HGCalGeometryESProducer::~HGCalGeometryESProducer() {} @@ -66,9 +67,7 @@ HGCalGeometryESProducer::~HGCalGeometryESProducer() {} // ------------ method called to produce the data ------------ HGCalGeometryESProducer::ReturnType HGCalGeometryESProducer::produce(const IdealGeometryRecord& iRecord) { const auto& topo = iRecord.get(topologyToken_); -#ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "Create HGCalGeometry (*topo)"; -#endif + edm::LogVerbatim("HGCalGeom") << "Create HGCalGeometry (*topo) for " << name_; HGCalGeometryLoader builder; return ReturnType(builder.build(topo)); diff --git a/Geometry/HGCalGeometry/src/HGCalGeometry.cc b/Geometry/HGCalGeometry/src/HGCalGeometry.cc index ecb4fc4be7089..7996aa2a2403c 100644 --- a/Geometry/HGCalGeometry/src/HGCalGeometry.cc +++ b/Geometry/HGCalGeometry/src/HGCalGeometry.cc @@ -226,6 +226,26 @@ GlobalPoint HGCalGeometry::getPosition(const DetId& detid) const { return glob; } +GlobalPoint HGCalGeometry::getWaferPosition(const DetId& detid) const { + unsigned int cellIndex = indexFor(detid); + GlobalPoint glob; + unsigned int maxSize = ((mode_ == HGCalGeometryMode::Trapezoid) ? m_cellVec2.size() : m_cellVec.size()); + if (cellIndex < maxSize) { + const HepGeom::Point3D lcoord(0, 0, 0); + if (mode_ == HGCalGeometryMode::Trapezoid) { + glob = m_cellVec2[cellIndex].getPosition(lcoord); + } else { + glob = m_cellVec[cellIndex].getPosition(lcoord); + } +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "getPositionTrap:: ID " << std::hex << detid << std::dec << " index " + << cellIndex < < < < + " Global " << glob; +#endif + } + return glob; +} + double HGCalGeometry::getArea(const DetId& detid) const { HGCalGeometry::CornersVec corners = getNewCorners(detid); double area(0);