Skip to content

Commit

Permalink
Merge pull request #38072 from bsunanda/Phase2-hgx313X
Browse files Browse the repository at this point in the history
Phase2-hgx312X Clean up the use of parameters in building V17 geometry of HGCal
  • Loading branch information
cmsbuild committed May 27, 2022
2 parents fe14891 + b065993 commit f6d76b8
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 24 deletions.
6 changes: 3 additions & 3 deletions Geometry/HGCalCommonData/interface/HGCalCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ class HGCalCell {
std::pair<double, double> cellUV2XY2(int32_t u, int32_t v, int32_t placementIndex, int32_t type);
// Get cell type and orientation index
std::pair<int32_t, int32_t> cellUV2Cell(int32_t u, int32_t v, int32_t placementIndex, int32_t type);
// Get the placement index from zside, forward-backward tag, orientation flag
static int32_t cellPlacementIndex(int32_t iz, int32_t fwdBack, int32_t orient);
// Get the orientation flag and forward-backward tag from placement index
// Get the placement index from zside, front-back tag, orientation flag
static int32_t cellPlacementIndex(int32_t iz, int32_t frontBack, int32_t orient);
// Get the orientation flag and front-back tag from placement index
static std::pair<int32_t, int32_t> cellOrient(int32_t placementIndex);
// Get cell type and position in the list
static std::pair<int32_t, int32_t> cellType(int32_t u, int32_t v, int32_t ncell, int32_t placementIndex);
Expand Down
7 changes: 7 additions & 0 deletions Geometry/HGCalCommonData/interface/HGCalTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,25 @@ class HGCalTypes {

enum TileSiPMType { SiPMUnknown = 0, SiPMSmall = 2, SiPMLarge = 4 };

// Packing and unpacking of type, u, v of wafers
static int32_t packTypeUV(int type, int u, int v);
static int32_t getUnpackedType(int id);
static int32_t getUnpackedU(int id);
static int32_t getUnpackedV(int id);
// Packing and unpacking of type, u, v of wafer cells
static int32_t packCellTypeUV(int type, int u, int v);
static int32_t getUnpackedCellType(int id);
static int32_t getUnpackedCellU(int id);
static int32_t getUnpackedCellV(int id);
// Packing and unpacking of type, cell# of wafer cells (6 inch wafers)
static int32_t packCellType6(int type, int cell);
static int32_t getUnpackedCellType6(int id);
static int32_t getUnpackedCell6(int id);
// Translate from flat file format to CMSSW format of Layer type
static int32_t layerType(int type);
// Get the front-back index from the layer orientation index
static int32_t layerFrontBack(int32_t layerOrient) { return ((layerOrient == WaferCenterB) ? 1 : -1); }
static int32_t waferFrontBack(int32_t index) { return ((index == 0) ? -1 : 1); }

private:
static constexpr int32_t facu_ = 1;
Expand Down
9 changes: 4 additions & 5 deletions Geometry/HGCalCommonData/plugins/DDHGCalMixRotatedLayer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ void DDHGCalMixRotatedLayer::initialize(const DDNumericArguments& nArgs,
layerType_ = dbl_to_int(vArgs["LayerType"]);
layerSense_ = dbl_to_int(vArgs["LayerSense"]);
layerOrient_ = dbl_to_int(vArgs["LayerTypes"]);
for (unsigned int k = 0; k < layerOrient_.size(); ++k)
layerOrient_[k] = HGCalTypes::layerType(layerOrient_[k]);
#ifdef EDM_ML_DEBUG
for (unsigned int i = 0; i < layerOrient_.size(); ++i)
edm::LogVerbatim("HGCalGeom") << "LayerTypes [" << i << "] " << layerOrient_[i];
Expand Down Expand Up @@ -506,11 +508,8 @@ void DDHGCalMixRotatedLayer::positionMix(const DDLogicalPart& glog,
// Make the bottom part next
int layer = (copyM - firstLayer_);
static const double sqrt3 = std::sqrt(3.0);
int layercenter = (layerOrient_[layer] == HGCalTypes::CornerCenteredLambda)
? HGCalTypes::CornerCenterYp
: ((layerOrient_[layer] == HGCalTypes::CornerCenteredY) ? HGCalTypes::CornerCenterYm
: HGCalTypes::WaferCenter);
int layertype = (layerOrient_[layer] == HGCalTypes::WaferCenteredBack) ? 1 : 0;
int layercenter = layerOrient_[layer];
int layertype = HGCalTypes::layerFrontBack(layerOrient_[layer]);
int firstWafer = waferLayerStart_[layer];
int lastWafer = ((layer + 1 < static_cast<int>(waferLayerStart_.size())) ? waferLayerStart_[layer + 1]
: static_cast<int>(waferIndex_.size()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void DDHGCalWaferFullRotated::execute(DDCompactView& cpv) {
for (int u = 0; u < 2 * nCells_; ++u) {
for (int v = 0; v < 2 * nCells_; ++v) {
if (((v - u) < nCells_) && ((u - v) <= nCells_)) {
int placeIndex = wafer.cellPlacementIndex(1, face_[k], orient_[k]);
int placeIndex = wafer.cellPlacementIndex(1, HGCalTypes::waferFrontBack(face_[k]), orient_[k]);
std::pair<double, double> xy1 = wafer.cellUV2XY1(u, v, placeIndex, cellType_);
double yp = xy1.second;
double xp = xy1.first;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ struct HGCalMixRotatedLayer {
layerType_ = args.value<std::vector<int>>("LayerType");
layerSense_ = args.value<std::vector<int>>("LayerSense");
layerOrient_ = args.value<std::vector<int>>("LayerTypes");
for (unsigned int k = 0; k < layerOrient_.size(); ++k)
layerOrient_[k] = HGCalTypes::layerType(layerOrient_[k]);
#ifdef EDM_ML_DEBUG
for (unsigned int i = 0; i < layerOrient_.size(); ++i)
edm::LogVerbatim("HGCalGeom") << "LayerTypes [" << i << "] " << layerOrient_[i];
Expand Down Expand Up @@ -439,11 +441,8 @@ struct HGCalMixRotatedLayer {
// Make the bottom part next
int layer = (copyM - firstLayer_);
static const double sqrt3 = std::sqrt(3.0);
int layercenter = (layerOrient_[layer] == HGCalTypes::CornerCenteredLambda)
? HGCalTypes::CornerCenterYp
: ((layerOrient_[layer] == HGCalTypes::CornerCenteredY) ? HGCalTypes::CornerCenterYm
: HGCalTypes::WaferCenter);
int layertype = (layerOrient_[layer] == HGCalTypes::WaferCenteredBack) ? 1 : 0;
int layercenter = layerOrient_[layer];
int layertype = HGCalTypes::layerFrontBack(layerOrient_[layer]);
int firstWafer = waferLayerStart_[layer];
int lastWafer = ((layer + 1 < static_cast<int>(waferLayerStart_.size())) ? waferLayerStart_[layer + 1]
: static_cast<int>(waferIndex_.size()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ static long algorithm(dd4hep::Detector& /* description */, cms::DDParsingContext
for (int u = 0; u < 2 * nCells; ++u) {
for (int v = 0; v < 2 * nCells; ++v) {
if (((v - u) < nCells) && ((u - v) <= nCells)) {
int placeIndex = wafer.cellPlacementIndex(1, face[k], orient[k]);
int placeIndex = wafer.cellPlacementIndex(1, HGCalTypes::waferFrontBack(face[k]), orient[k]);
std::pair<double, double> xy1 = wafer.cellUV2XY1(u, v, placeIndex, cellType);
double yp = xy1.second;
double xp = xy1.first;
Expand Down
8 changes: 4 additions & 4 deletions Geometry/HGCalCommonData/src/HGCalCell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -227,16 +227,16 @@ std::pair<int, int> HGCalCell::cellUV2Cell(int32_t u, int32_t v, int32_t placeme
return std::make_pair(cell, cellt);
}

int HGCalCell::cellPlacementIndex(int32_t iz, int32_t fwdBack, int32_t orient) {
int32_t indx = ((iz * fwdBack) > 0) ? orient : (orient + HGCalCell::cellPlacementExtra);
int HGCalCell::cellPlacementIndex(int32_t iz, int32_t frontBack, int32_t orient) {
int32_t indx = ((iz * frontBack) > 0) ? orient : (orient + HGCalCell::cellPlacementExtra);
return indx;
}

std::pair<int32_t, int32_t> HGCalCell::cellOrient(int32_t placementIndex) {
int32_t orient = (placementIndex >= HGCalCell::cellPlacementExtra) ? (placementIndex - HGCalCell::cellPlacementExtra)
: placementIndex;
int32_t fwdBack = (placementIndex >= HGCalCell::cellPlacementExtra) ? 1 : -1;
return std::make_pair(orient, fwdBack);
int32_t frontBackZside = (placementIndex >= HGCalCell::cellPlacementExtra) ? 1 : -1;
return std::make_pair(orient, frontBackZside);
}

std::pair<int32_t, int32_t> HGCalCell::cellType(int32_t u, int32_t v, int32_t ncell, int32_t placementIndex) {
Expand Down
10 changes: 5 additions & 5 deletions Geometry/HGCalCommonData/src/HGCalTypes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ int32_t HGCalTypes::getUnpackedCellType6(int id) { return (id / faccell6_); }
int32_t HGCalTypes::getUnpackedCell6(int id) { return (id % faccell6_); }

int32_t HGCalTypes::layerType(int type) {
int types[5] = {HGCalTypes::WaferCenter,
HGCalTypes::WaferCenterB,
HGCalTypes::CornerCenterYp,
HGCalTypes::CornerCenterYm,
HGCalTypes::WaferCenterR};
static constexpr int32_t types[5] = {HGCalTypes::WaferCenter,
HGCalTypes::WaferCenterB,
HGCalTypes::CornerCenterYp,
HGCalTypes::CornerCenterYm,
HGCalTypes::WaferCenterR};
return ((type >= 0 && type < 5) ? types[type] : HGCalTypes::WaferCenter);
}

0 comments on commit f6d76b8

Please sign in to comment.