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-hgx250 Comparison of results from flat file and from insitu checks #30423

Merged
merged 5 commits into from Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
1 change: 1 addition & 0 deletions Geometry/CaloTopology/interface/HGCalTopology.h
Expand Up @@ -87,6 +87,7 @@ class HGCalTopology : public CaloSubdetectorTopology {
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_); }
Expand Down
15 changes: 14 additions & 1 deletion Geometry/CaloTopology/src/HGCalTopology.cc
Expand Up @@ -481,13 +481,26 @@ 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, true));
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);
Expand Down
28 changes: 14 additions & 14 deletions Geometry/HGCalCommonData/data/hgcal/v13/hgcal.xml
Expand Up @@ -27,20 +27,20 @@
<Constant name="ChoiceType" value="0"/>
<Constant name="NCornerCut" value="2"/>
<Constant name="FracAreaMin" value="0.2"/>
<Constant name="radMixL0" value="1537.0*mm"/>
<Constant name="radMixL1" value="1537.0*mm"/>
<Constant name="radMixL2" value="1537.0*mm"/>
<Constant name="radMixL3" value="1537.0*mm"/>
<Constant name="radMixL4" value="1378.2*mm"/>
<Constant name="radMixL5" value="1378.2*mm"/>
<Constant name="radMixL6" value="1183.0*mm"/>
<Constant name="radMixL7" value="1183.0*mm"/>
<Constant name="radMixL8" value="1183.0*mm"/>
<Constant name="radMixL9" value="1183.0*mm"/>
<Constant name="radMixL10" value="1037.8*mm"/>
<Constant name="radMixL11" value="1037.8*mm"/>
<Constant name="radMixL12" value="1037.8*mm"/>
<Constant name="radMixL13" value="1037.8*mm"/>
<Constant name="radMixL0" value="1537.05*mm"/>
<Constant name="radMixL1" value="1537.05*mm"/>
<Constant name="radMixL2" value="1537.05*mm"/>
<Constant name="radMixL3" value="1537.05*mm"/>
<Constant name="radMixL4" value="1537.05*mm"/>
<Constant name="radMixL5" value="1209.37*mm"/>
<Constant name="radMixL6" value="1209.37*mm"/>
<Constant name="radMixL7" value="1209.37*mm"/>
<Constant name="radMixL8" value="1209.37*mm"/>
<Constant name="radMixL9" value="1209.37*mm"/>
<Constant name="radMixL10" value="1060.98*mm"/>
<Constant name="radMixL11" value="1060.98*mm"/>
<Constant name="radMixL12" value="1060.98*mm"/>
<Constant name="radMixL13" value="1060.98*mm"/>
<Constant name="slope1" value="[etaMax:slope]"/>
<Constant name="ZposV0" value="3210.5*mm"/>
<Constant name="RposV0" value="1523.3*mm"/>
Expand Down
37 changes: 34 additions & 3 deletions Geometry/HGCalCommonData/interface/HGCalDDDConstants.h
Expand Up @@ -51,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<HGCalParameters::hgtrap> getModules() const;
const HGCalParameters* getParameter() const { return hgpar_; }
Expand All @@ -68,6 +69,7 @@ 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 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;
Expand Down Expand Up @@ -126,6 +128,33 @@ class HGCalDDDConstants {
std::pair<double, double> waferParameters(bool reco) const;
std::pair<double, double> waferPosition(int wafer, bool reco) const;
std::pair<double, double> 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();
for (unsigned int k = 0; k < kk; ++k)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can replace this with: std::advance(itr,kk);

++itr;
return itr->first;
} else
return 0;
}
std::tuple<int, int, int> waferFileInfo(unsigned int kk) const {
if (kk < hgpar_->waferInfoMap_.size()) {
auto itr = hgpar_->waferInfoMap_.begin();
for (unsigned int k = 0; k < kk; ++k)
Copy link
Contributor

Choose a reason for hiding this comment

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

also here

++itr;
return std::make_tuple(itr->second.type, itr->second.part, itr->second.orient);
} else
return std::make_tuple(0, 0, 0);
}
std::tuple<int, int, int> 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_);
}
Expand All @@ -146,9 +175,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;
std::pair<int, int> waferTypeRotation(int layer, int waferU, int waferV, bool debug = false) const;
int waferType(DetId const& id, bool fromFile = false) const;
int waferType(int layer, int waferU, int waferV, bool fromFile = false) const;
std::tuple<int, int, int> waferType(HGCSiliconDetId const& id, bool fromFile = false) const;
std::pair<int, int> 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;
Expand Down
6 changes: 3 additions & 3 deletions Geometry/HGCalCommonData/python/testHGCalV13XML_cfi.py
Expand Up @@ -8,12 +8,12 @@
'Geometry/CMSCommonData/data/materials.xml',
'Geometry/CMSCommonData/data/rotations.xml',
'Geometry/CMSCommonData/data/extend/cmsextent.xml',
'Geometry/CMSCommonData/data/cms/2026/v4/cms.xml',
'Geometry/CMSCommonData/data/cms/2026/v5/cms.xml',
'Geometry/CMSCommonData/data/eta3/etaMax.xml',
'Geometry/CMSCommonData/data/cmsMother.xml',
'Geometry/CMSCommonData/data/caloBase/2026/v4/caloBase.xml',
'Geometry/CMSCommonData/data/cmsCalo.xml',
'Geometry/CMSCommonData/data/beampipe/2026/v1/beampipe.xml',
'Geometry/CMSCommonData/data/beampipe/2026/v3/beampipe.xml',
'Geometry/CMSCommonData/data/cmsBeam/2026/v1/cmsBeam.xml',
'Geometry/CMSCommonData/data/cavernData/2017/v1/cavernData.xml',
'Geometry/CMSCommonData/data/muonBase/2026/v5/muonBase.xml',
Expand Down Expand Up @@ -45,7 +45,7 @@
'Geometry/HGCalCommonData/data/hgcalHEmix/v12/hgcalHEmix.xml',
'Geometry/HGCalCommonData/data/hgcalCons/v13/hgcalCons.xml',
'Geometry/HGCalCommonData/data/hgcalConsData/v13/hgcalConsData.xml',
'Geometry/ForwardCommonData/data/forwardshield/2017/v1/forwardshield.xml',
'Geometry/ForwardCommonData/data/forwardshield/2026/v4/forwardshield.xml',
'Geometry/MuonCommonData/data/mbCommon/2021/v1/mbCommon.xml',
'Geometry/MuonCommonData/data/mb1/2015/v2/mb1.xml',
'Geometry/MuonCommonData/data/mb2/2015/v2/mb2.xml',
Expand Down
145 changes: 112 additions & 33 deletions Geometry/HGCalCommonData/src/HGCalDDDConstants.cc
Expand Up @@ -221,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
Expand Down Expand Up @@ -491,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, bool fullAndPart) 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);
Expand All @@ -508,17 +508,6 @@ bool HGCalDDDConstants::isValidHex8(int layer, int modU, int modV, int cellU, in
if (!(jtr->second))
return false;

int N = ((hgpar_->waferTypeL_[itr->second] == 0) ? hgpar_->nCellsFine_ : hgpar_->nCellsCoarse_);
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HGCalGeom") << "HGCalDDDConstants::isValidHex8:Cell " << cellU << ":" << cellV << ":" << N
<< " Tests " << (cellU >= 0) << ":" << (cellU < 2 * N) << ":" << (cellV >= 0) << ":"
<< (cellV < 2 * N) << ":" << ((cellV - cellU) < N) << ":" << ((cellU - cellV) <= N);
#endif
if ((cellU < 0) || (cellU >= 2 * N) || (cellV < 0) || (cellV >= 2 * N))
return false;
if (((cellV - cellU) >= N) || ((cellU - cellV) > N))
return false;

if (fullAndPart) {
auto ktr = hgpar_->waferTypes_.find(indx);
if (ktr != hgpar_->waferTypes_.end()) {
Expand All @@ -531,9 +520,27 @@ bool HGCalDDDConstants::isValidHex8(int layer, int modU, int modV, int cellU, in
}
}
}
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);
Copy link
Contributor

Choose a reason for hiding this comment

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

do you need to check for the case where indx is not found?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

indx is basically a packed id. It is a calculated number.

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
<< " Tests " << (cellU >= 0) << ":" << (cellU < 2 * N) << ":" << (cellV >= 0) << ":"
<< (cellV < 2 * N) << ":" << ((cellV - cellU) < N) << ":" << ((cellU - cellV) <= N);
#endif
if ((cellU < 0) || (cellU >= 2 * N) || (cellV < 0) || (cellV >= 2 * N))
return false;
if (((cellV - cellU) >= N) || ((cellU - cellV) > N))
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);
}

Expand Down Expand Up @@ -1218,49 +1225,121 @@ std::pair<double, double> HGCalDDDConstants::waferPosition(
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);
}
return type;
}

std::pair<int, int> HGCalDDDConstants::waferTypeRotation(int layer, int waferU, int waferV, bool debug) const {
int type(HGCalTypes::WaferOut), rotn(0);
int wl = HGCalWaferIndex::waferIndex(layer, waferU, waferV);
auto itr = hgpar_->waferTypes_.find(wl);
if ((mode_ == HGCalGeometryMode::Hexagon8) || (mode_ == HGCalGeometryMode::Hexagon8Full)) {
std::tuple<int, int, int> 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) {
rotn = (itr->second).second;
orient = (itr->second).second;
if ((itr->second).first == HGCalGeomTools::k_allCorners) {
type = HGCalTypes::WaferFull;
part = HGCalTypes::WaferFull;
} else if ((itr->second).first == HGCalGeomTools::k_fiveCorners) {
type = HGCalTypes::WaferFive;
part = HGCalTypes::WaferFive;
} else if ((itr->second).first == HGCalGeomTools::k_fourCorners) {
type = HGCalTypes::WaferHalf;
part = HGCalTypes::WaferHalf;
} else if ((itr->second).first == HGCalGeomTools::k_threeCorners) {
type = HGCalTypes::WaferThree;
part = HGCalTypes::WaferThree;
}
} else {
type = (itr->second).first;
rotn = ((itr->second).second - HGCalWaferMask::k_OffsetRotation);
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<int, int> 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);
}
}
}
}
Expand Down