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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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_; } | ||
|
@@ -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; | ||
|
@@ -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) | ||
++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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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_); | ||
} | ||
|
@@ -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; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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); | ||
|
@@ -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()) { | ||
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
} | ||
|
||
|
@@ -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); | ||
} | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
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);