Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phase2-hgx316C Add a few utility methods in HGCalDDDConstants #38547

Merged
merged 5 commits into from Jul 3, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions Geometry/HGCalCommonData/interface/HGCalDDDConstants.h
Expand Up @@ -23,6 +23,7 @@
#include "Geometry/HGCalCommonData/interface/HGCalParameters.h"
#include "Geometry/HGCalCommonData/interface/HGCalTileIndex.h"
#include "Geometry/HGCalCommonData/interface/HGCalTypes.h"
#include "Geometry/HGCalCommonData/interface/HGCalWaferIndex.h"
#include <CLHEP/Geometry/Point3D.h>

#include <array>
Expand Down Expand Up @@ -86,6 +87,9 @@ class HGCalDDDConstants {
int layerIndex(int lay, bool reco) const;
unsigned int layers(bool reco) const;
unsigned int layersInit(bool reco) const;
int layerType(int lay) const {
return ((hgpar_->layerType_.empty()) ? HGCalTypes::WaferCenter : hgpar_->layerType_[lay - hgpar_->firstLayer_]);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMS coding rule 4.3:
Header files must not contain any implementation except for class templates and code to be inlined.

Add inline if you intend these methods to be inlined.

std::pair<float, float> localToGlobal8(
int lay, int waferU, int waferV, double localX, double localY, bool reco, bool debug) const;
std::pair<float, float> locateCell(int cell, int lay, int type, bool reco) const;
Expand Down Expand Up @@ -132,6 +136,11 @@ class HGCalDDDConstants {
bool ok = (itr == hgpar_->tileInfoMap_.end()) ? false : HGCalTileIndex::tileExist(itr->second.hex, zside, phi);
return ok;
}
HGCalParameters::tileInfo tileInfo(int zside, int layer, int ring) const {
int indx = HGCalTileIndex::tileIndex(layer, ring, 0);
auto itr = hgpar_->tileInfoMap_.find(indx);
return ((itr == hgpar_->tileInfoMap_.end()) ? HGCalParameters::tileInfo() : itr->second);
}
std::pair<int, int> tileRings(int layer) const {
if ((mode_ == HGCalGeometryMode::TrapezoidFile) || (mode_ == HGCalGeometryMode::TrapezoidModule) ||
(mode_ == HGCalGeometryMode::TrapezoidCassette)) {
Expand Down Expand Up @@ -189,6 +198,11 @@ class HGCalDDDConstants {
bool waferInLayer(int wafer, int lay, bool reco) const;
bool waferFullInLayer(int wafer, int lay, bool reco) const;
int waferCount(const int type) const { return ((type == 0) ? waferMax_[2] : waferMax_[3]); }
HGCalParameters::waferInfo waferInfo(int lay, int waferU, int waferV) const {
int indx = HGCalWaferIndex::waferIndex(lay, waferU, waferV);
auto itr = hgpar_->waferInfoMap_.find(indx);
return ((itr == hgpar_->waferInfoMap_.end()) ? HGCalParameters::waferInfo() : itr->second);
}
int waferMax() const { return waferMax_[1]; }
int waferMin() const { return waferMax_[0]; }
std::pair<double, double> waferParameters(bool reco) const;
Expand Down
8 changes: 2 additions & 6 deletions Geometry/HGCalCommonData/src/HGCalDDDConstants.cc
Expand Up @@ -8,11 +8,8 @@
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Utilities/interface/Exception.h"
#include "Geometry/HGCalCommonData/interface/HGCalGeomParameters.h"
#include "Geometry/HGCalCommonData/interface/HGCalGeomTools.h"
#include "Geometry/HGCalCommonData/interface/HGCalGeometryMode.h"
#include "Geometry/HGCalCommonData/interface/HGCalCell.h"
#include "Geometry/HGCalCommonData/interface/HGCalTypes.h"
#include "Geometry/HGCalCommonData/interface/HGCalWaferIndex.h"
#include "Geometry/HGCalCommonData/interface/HGCalWaferMask.h"
#include "Geometry/HGCalCommonData/interface/HGCalWaferType.h"

Expand Down Expand Up @@ -695,8 +692,7 @@ std::pair<float, float> HGCalDDDConstants::locateCell(
int indx = HGCalWaferIndex::waferIndex(lay, waferU, waferV);
auto itr = hgpar_->typesInLayers_.find(indx);
int type = ((itr == hgpar_->typesInLayers_.end()) ? 2 : hgpar_->waferTypeL_[itr->second]);
int layertype =
(hgpar_->layerType_.empty()) ? HGCalTypes::WaferCenter : hgpar_->layerType_[lay - hgpar_->firstLayer_];
int layertype = layerType(lay);
bool rotx = (norot) ? false : (layertype == HGCalTypes::WaferCenterR);
if (debug) {
edm::LogVerbatim("HGCalGeom") << "LocateCell " << lay << ":" << (lay - hgpar_->firstLayer_) << ":" << layertype
Expand Down Expand Up @@ -1264,7 +1260,7 @@ void HGCalDDDConstants::waferFromPosition(const double x,
if ((hgpar_->xLayerHex_.empty()) || (hgpar_->yLayerHex_.empty()))
return;
int ll = layer - hgpar_->firstLayer_;
int layertype = (hgpar_->layerType_.empty()) ? HGCalTypes::WaferCenter : hgpar_->layerType_[ll];
int layertype = layerType(layer);
bool rotx = ((!hgpar_->layerType_.empty()) && (layertype == HGCalTypes::WaferCenterR));
double xx(0), yy(0);
if (rotx) {
Expand Down