Skip to content

Commit

Permalink
Code check
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunanda committed Jan 9, 2023
1 parent 5f340e6 commit 24644df
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 73 deletions.
39 changes: 22 additions & 17 deletions Geometry/HGCalTBCommonData/src/HGCalTBDDDConstants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ HGCalTBDDDConstants::HGCalTBDDDConstants(const HGCalTBParameters* hp, const std:
hexsideT_ = 2.0 * rmaxT_ * tan30deg_;
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HGCalGeom") << "rmax_ " << rmax_ << ":" << rmaxT_ << ":" << hexside_ << ":" << hexsideT_
<< " CellSize " << 0.5 * HGCalTBParameters::k_ScaleFromDDD * hgpar_->cellSize_[0] << ":"
<< 0.5 * HGCalTBParameters::k_ScaleFromDDD * hgpar_->cellSize_[1];
<< " CellSize " << 0.5 * HGCalTBParameters::k_ScaleFromDDD * hgpar_->cellSize_[0]
<< ":" << 0.5 * HGCalTBParameters::k_ScaleFromDDD * hgpar_->cellSize_[1];
#endif
}
// init maps and constants
Expand Down Expand Up @@ -151,7 +151,7 @@ double HGCalTBDDDConstants::cellSizeHex(int type) const {
double HGCalTBDDDConstants::cellThickness(int layer, int wafer) const {
double thick(-1);
int type = waferType(layer, wafer);
if (type >= 0)
if (type >= 0)
thick = 100.0 * (type + 1); // type = 1,2,3 for 100,200,300 micron
return thick;
}
Expand Down Expand Up @@ -267,8 +267,8 @@ bool HGCalTBDDDConstants::isValidHex(int lay, int mod, int cell, bool reco) cons
result = resultMod = (moditr != the_modules.end());
#ifdef EDM_ML_DEBUG
if (!result)
edm::LogVerbatim("HGCalGeom") << "HGCalTBDDDConstants: Layer " << lay << ":" << lay_idx << " Copy " << copyNumber
<< ":" << mod << " Flag " << result;
edm::LogVerbatim("HGCalGeom") << "HGCalTBDDDConstants: Layer " << lay << ":" << lay_idx << " Copy "
<< copyNumber << ":" << mod << " Flag " << result;
#endif
if (result) {
if (moditr->second >= 0) {
Expand Down Expand Up @@ -382,9 +382,10 @@ int HGCalTBDDDConstants::maxCells(int lay, bool reco) const {
unsigned int cells(0);
for (unsigned int k = 0; k < hgpar_->waferTypeT_.size(); ++k) {
if (waferInLayerTest(k, index.first)) {
unsigned int cell = (hgpar_->waferTypeT_[k] - 1 == HGCalTBParameters::HGCalFine) ? (hgpar_->cellFineX_.size()) : (hgpar_->cellCoarseX_.size());
unsigned int cell = (hgpar_->waferTypeT_[k] - 1 == HGCalTBParameters::HGCalFine) ? (hgpar_->cellFineX_.size())
: (hgpar_->cellCoarseX_.size());
if (cell > cells)
cells = cell;
cells = cell;
}
}
return static_cast<int>(cells);
Expand Down Expand Up @@ -451,8 +452,10 @@ std::vector<int> HGCalTBDDDConstants::numberCells(int lay, bool reco) const {
if ((i >= 0) && (waferHexagon6())) {
for (unsigned int k = 0; k < hgpar_->waferTypeT_.size(); ++k) {
if (waferInLayerTest(k, i)) {
unsigned int cell = (hgpar_->waferTypeT_[k] - 1 == HGCalTBParameters::HGCalFine) ? (hgpar_->cellFineX_.size()) : (hgpar_->cellCoarseX_.size());
ncell.emplace_back(static_cast<int>(cell));
unsigned int cell = (hgpar_->waferTypeT_[k] - 1 == HGCalTBParameters::HGCalFine)
? (hgpar_->cellFineX_.size())
: (hgpar_->cellCoarseX_.size());
ncell.emplace_back(static_cast<int>(cell));
}
}
}
Expand All @@ -477,7 +480,8 @@ std::pair<double, double> HGCalTBDDDConstants::rangeR(double z, bool reco) const
rmax *= HGCalTBParameters::k_ScaleToDDD;
}
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HGCalGeom") << "HGCalTBDDDConstants:rangeR: " << z << ":0" << " R " << rmin << ":" << rmax;
edm::LogVerbatim("HGCalGeom") << "HGCalTBDDDConstants:rangeR: " << z << ":0"
<< " R " << rmin << ":" << rmax;
#endif
return std::make_pair(rmin, rmax);
}
Expand Down Expand Up @@ -573,8 +577,11 @@ void HGCalTBDDDConstants::waferFromPosition(const double x, const double y, int&
}
if (wafer < size_) {
if (celltyp - 1 == HGCalTBParameters::HGCalFine)
icell = cellHex(
xx, yy, 0.5 * HGCalTBParameters::k_ScaleFromDDD * hgpar_->cellSize_[0], hgpar_->cellFineX_, hgpar_->cellFineY_);
icell = cellHex(xx,
yy,
0.5 * HGCalTBParameters::k_ScaleFromDDD * hgpar_->cellSize_[0],
hgpar_->cellFineX_,
hgpar_->cellFineY_);
else
icell = cellHex(xx,
yy,
Expand Down Expand Up @@ -628,9 +635,7 @@ std::pair<double, double> HGCalTBDDDConstants::waferPosition(int wafer, bool rec
return std::make_pair(xx, yy);
}

int HGCalTBDDDConstants::wafers() const {
return static_cast<int>(hgpar_->moduleLayR_.size());
}
int HGCalTBDDDConstants::wafers() const { return static_cast<int>(hgpar_->moduleLayR_.size()); }

int HGCalTBDDDConstants::wafers(int layer, int type) const {
int wafer(0);
Expand All @@ -643,13 +648,13 @@ int HGCalTBDDDConstants::wafers(int layer, int type) const {
}

int HGCalTBDDDConstants::waferType(DetId const& id) const {
return waferType(HGCalDetId(id).layer(), HGCalDetId(id).wafer());
return waferType(HGCalDetId(id).layer(), HGCalDetId(id).wafer());
}

int HGCalTBDDDConstants::waferType(int layer, int wafer) const {
int type(HGCalTBParameters::HGCalCoarseThick);
if ((wafer >= 0) && (wafer < static_cast<int>(hgpar_->waferTypeL_.size())))
type = (hgpar_->waferTypeL_[wafer] - 1) ;
type = (hgpar_->waferTypeL_[wafer] - 1);
return type;
}

Expand Down
71 changes: 37 additions & 34 deletions Geometry/HGCalTBCommonData/src/HGCalTBGeomParameters.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ HGCalTBGeomParameters::HGCalTBGeomParameters() : sqrt3_(std::sqrt(3.0)) {
}

void HGCalTBGeomParameters::loadGeometryHexagon(const DDFilteredView& _fv,
HGCalTBParameters& php,
const std::string& sdTag1,
const DDCompactView* cpv,
const std::string& sdTag2,
const std::string& sdTag3,
HGCalGeometryMode::WaferMode mode) {
HGCalTBParameters& php,
const std::string& sdTag1,
const DDCompactView* cpv,
const std::string& sdTag2,
const std::string& sdTag3,
HGCalGeometryMode::WaferMode mode) {
DDFilteredView fv = _fv;
bool dodet(true);
std::map<int, HGCalTBGeomParameters::layerParameters> layers;
Expand Down Expand Up @@ -259,11 +259,11 @@ void HGCalTBGeomParameters::loadGeometryHexagon(const DDFilteredView& _fv,
}

void HGCalTBGeomParameters::loadGeometryHexagon(const cms::DDCompactView* cpv,
HGCalTBParameters& php,
const std::string& sdTag1,
const std::string& sdTag2,
const std::string& sdTag3,
HGCalGeometryMode::WaferMode mode) {
HGCalTBParameters& php,
const std::string& sdTag1,
const std::string& sdTag2,
const std::string& sdTag3,
HGCalGeometryMode::WaferMode mode) {
const cms::DDFilter filter("Volume", sdTag1);
cms::DDFilteredView fv((*cpv), filter);
std::map<int, HGCalTBGeomParameters::layerParameters> layers;
Expand Down Expand Up @@ -481,16 +481,16 @@ void HGCalTBGeomParameters::loadGeometryHexagon(const cms::DDCompactView* cpv,
}

void HGCalTBGeomParameters::loadGeometryHexagon(const std::map<int, HGCalTBGeomParameters::layerParameters>& layers,
std::vector<HGCalTBParameters::hgtrform>& trforms,
std::vector<bool>& trformUse,
const std::unordered_map<int32_t, int32_t>& copies,
const HGCalTBParameters::layer_map& copiesInLayers,
const std::vector<int32_t>& wafer2copy,
const std::vector<HGCalTBGeomParameters::cellParameters>& wafers,
const std::map<int, int>& wafertype,
const std::map<int, HGCalTBGeomParameters::cellParameters>& cellsf,
const std::map<int, HGCalTBGeomParameters::cellParameters>& cellsc,
HGCalTBParameters& php) {
std::vector<HGCalTBParameters::hgtrform>& trforms,
std::vector<bool>& trformUse,
const std::unordered_map<int32_t, int32_t>& copies,
const HGCalTBParameters::layer_map& copiesInLayers,
const std::vector<int32_t>& wafer2copy,
const std::vector<HGCalTBGeomParameters::cellParameters>& wafers,
const std::map<int, int>& wafertype,
const std::map<int, HGCalTBGeomParameters::cellParameters>& cellsf,
const std::map<int, HGCalTBGeomParameters::cellParameters>& cellsc,
HGCalTBParameters& php) {
if (((cellsf.size() + cellsc.size()) == 0) || (wafers.empty()) || (layers.empty())) {
throw cms::Exception("DDException") << "HGCalTBGeomParameters: mismatch between geometry and specpar: cells "
<< cellsf.size() << ":" << cellsc.size() << " wafers " << wafers.size()
Expand Down Expand Up @@ -669,12 +669,11 @@ void HGCalTBGeomParameters::loadGeometryHexagon(const std::map<int, HGCalTBGeomP
#endif
}


void HGCalTBGeomParameters::loadSpecParsHexagon(const DDFilteredView& fv,
HGCalTBParameters& php,
const DDCompactView* cpv,
const std::string& sdTag1,
const std::string& sdTag2) {
HGCalTBParameters& php,
const DDCompactView* cpv,
const std::string& sdTag1,
const std::string& sdTag2) {
DDsvalues_type sv(fv.mergedSpecifics());
php.boundR_ = getDDDArray("RadiusBound", sv, 4);
rescale(php.boundR_, HGCalTBParameters::k_ScaleFromDDD);
Expand Down Expand Up @@ -710,11 +709,11 @@ void HGCalTBGeomParameters::loadSpecParsHexagon(const DDFilteredView& fv,
}

void HGCalTBGeomParameters::loadSpecParsHexagon(const cms::DDFilteredView& fv,
HGCalTBParameters& php,
const std::string& sdTag1,
const std::string& sdTag2,
const std::string& sdTag3,
const std::string& sdTag4) {
HGCalTBParameters& php,
const std::string& sdTag1,
const std::string& sdTag2,
const std::string& sdTag3,
const std::string& sdTag4) {
php.boundR_ = fv.get<std::vector<double> >(sdTag4, "RadiusBound");
rescale(php.boundR_, HGCalTBParameters::k_ScaleFromDD4hep);
php.rLimit_ = fv.get<std::vector<double> >(sdTag4, "RadiusLimits");
Expand Down Expand Up @@ -745,9 +744,11 @@ void HGCalTBGeomParameters::loadSpecParsHexagon(const HGCalTBParameters& php) {
edm::LogVerbatim("HGCalGeom") << "HGCalTBGeomParameters: wafer radius ranges"
<< " for cell grouping " << php.boundR_[0] << ":" << php.boundR_[1] << ":"
<< php.boundR_[2] << ":" << php.boundR_[3];
edm::LogVerbatim("HGCalGeom") << "HGCalTBGeomParameters: Minimum/maximum R " << php.rLimit_[0] << ":" << php.rLimit_[1];
edm::LogVerbatim("HGCalGeom") << "HGCalTBGeomParameters: Minimum/maximum R " << php.rLimit_[0] << ":"
<< php.rLimit_[1];
edm::LogVerbatim("HGCalGeom") << "HGCalTBGeomParameters: LevelTop " << php.levelT_[0];
edm::LogVerbatim("HGCalGeom") << "HGCalTBGeomParameters: minimum slope " << php.slopeMin_[0] << " and layer groupings "
edm::LogVerbatim("HGCalGeom") << "HGCalTBGeomParameters: minimum slope " << php.slopeMin_[0]
<< " and layer groupings "
<< "for the 3 ranges:";
for (unsigned int k = 0; k < php.layerGroup_.size(); ++k)
edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << php.layerGroup_[k] << ":" << php.layerGroupM_[k] << ":"
Expand Down Expand Up @@ -897,7 +898,9 @@ void HGCalTBGeomParameters::loadCellParsHexagon(const HGCalTBParameters& php) {
#endif
}

std::vector<double> HGCalTBGeomParameters::getDDDArray(const std::string& str, const DDsvalues_type& sv, const int nmin) {
std::vector<double> HGCalTBGeomParameters::getDDDArray(const std::string& str,
const DDsvalues_type& sv,
const int nmin) {
DDValue value(str);
if (DDfetch(&sv, value)) {
const std::vector<double>& fvec = value.doubles();
Expand Down
34 changes: 17 additions & 17 deletions Geometry/HGCalTBCommonData/src/HGCalTBParametersFromDD.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
using namespace geant_units::operators;

bool HGCalTBParametersFromDD::build(const DDCompactView* cpv,
HGCalTBParameters& php,
const std::string& name,
const std::string& namew,
const std::string& namec,
const std::string& namet) {
HGCalTBParameters& php,
const std::string& name,
const std::string& namew,
const std::string& namec,
const std::string& namet) {
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HGCalGeom") << "HGCalTBParametersFromDD (DDD)::build called with "
<< "names " << name << ":" << namew << ":" << namec << ":" << namet;
Expand All @@ -40,9 +40,9 @@ bool HGCalTBParametersFromDD::build(const DDCompactView* cpv,
edm::LogVerbatim("HGCalGeom") << "Volume " << name << " GeometryMode " << php.mode_ << ":"
<< HGCalGeometryMode::Hexagon << ":" << HGCalGeometryMode::HexagonFull;
#endif
php.levelZSide_ = 3; // Default level for ZSide
php.detectorType_ = 0; // These two parameters are
php.useSimWt_ = 1; // energy weighting for SimHits
php.levelZSide_ = 3; // Default level for ZSide
php.detectorType_ = 0; // These two parameters are
php.useSimWt_ = 1; // energy weighting for SimHits
std::unique_ptr<HGCalTBGeomParameters> geom = std::make_unique<HGCalTBGeomParameters>();
if ((php.mode_ == HGCalGeometryMode::Hexagon) || (php.mode_ == HGCalGeometryMode::HexagonFull)) {
attribute = "OnlyForHGCalNumbering";
Expand Down Expand Up @@ -99,12 +99,12 @@ bool HGCalTBParametersFromDD::build(const DDCompactView* cpv,
}

bool HGCalTBParametersFromDD::build(const cms::DDCompactView* cpv,
HGCalTBParameters& php,
const std::string& name,
const std::string& namew,
const std::string& namec,
const std::string& namet,
const std::string& name2) {
HGCalTBParameters& php,
const std::string& name,
const std::string& namew,
const std::string& namec,
const std::string& namet,
const std::string& name2) {
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HGCalGeom") << "HGCalTBParametersFromDD (DD4hep)::build called with "
<< "names " << name << ":" << namew << ":" << namec << ":" << namet << ":" << name2;
Expand All @@ -131,9 +131,9 @@ bool HGCalTBParametersFromDD::build(const cms::DDCompactView* cpv,
edm::LogVerbatim("HGCalGeom") << "Volume " << name << " GeometryMode " << php.mode_ << ":"
<< HGCalGeometryMode::Hexagon << ":" << HGCalGeometryMode::HexagonFull;
#endif
php.levelZSide_ = 3; // Default level for ZSide
php.detectorType_ = 0; // These two parameters are
php.useSimWt_ = 1; // energy weighting for SimHits
php.levelZSide_ = 3; // Default level for ZSide
php.detectorType_ = 0; // These two parameters are
php.useSimWt_ = 1; // energy weighting for SimHits
std::unique_ptr<HGCalTBGeomParameters> geom = std::make_unique<HGCalTBGeomParameters>();
if ((php.mode_ == HGCalGeometryMode::Hexagon) || (php.mode_ == HGCalGeometryMode::HexagonFull)) {
tempS = fv.get<std::vector<std::string> >(namet, "WaferMode");
Expand Down
9 changes: 4 additions & 5 deletions Geometry/HGCalTBCommonData/test/HGCalTBParameterTester.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void HGCalTBParameterTester::analyze(const edm::Event& iEvent, const edm::EventS
edm::LogVerbatim("HGCalGeom") << "nSectors_: " << phgp->nSectors_;
edm::LogVerbatim("HGCalGeom") << "FirstLayer: " << phgp->firstLayer_;
edm::LogVerbatim("HGCalGeom") << "mode_: " << phgp->mode_;

myPrint("CellSize", phgp->cellSize_, 10);
myPrint("slopeMin", phgp->slopeMin_, 10);
myPrint("slopeTop", phgp->slopeTop_, 10);
Expand Down Expand Up @@ -146,11 +146,10 @@ void HGCalTBParameterTester::myPrint(std::string const& s, std::vector<T> const&
edm::LogVerbatim("HGCalGeom") << st1[kk].str();
}


void HGCalTBParameterTester::myPrint(std::string const& s,
std::vector<double> const& obj1,
std::vector<double> const& obj2,
int n) const {
std::vector<double> const& obj1,
std::vector<double> const& obj2,
int n) const {
int k(0), kk(0);
std::ostringstream st1[250];
edm::LogVerbatim("HGCalGeom") << s << " with " << obj1.size() << " elements with n " << n << ": 250";
Expand Down

0 comments on commit 24644df

Please sign in to comment.