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-hgx319C Modify the test scrpts to check if all wafers in the flat file are in the list of valid modules #38847

Merged
merged 2 commits into from Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
20 changes: 10 additions & 10 deletions Geometry/HGCalGeometry/test/HGCalWaferInFileCheck.cc
Expand Up @@ -77,7 +77,10 @@ void HGCalWaferInFileCheck::analyze(const edm::Event& iEvent, const edm::EventSe
<< "\n";
if (hgdc.waferHexagon8()) {
DetId::Detector det = (nameSense_ == "HGCalHESiliconSensitive") ? DetId::HGCalHSi : DetId::HGCalEE;
static std::vector<std::string> types = {"F", "b", "g", "gm", "a", "d", "dm", "c", "am", "bm", "X"};
edm::LogVerbatim("HGCalGeom")
<< "Old Partial types: 1|Five, 2|ChopTwo, 3|ChopTwoM, 4|Half, 5|Semi, 6|Semi2, 7|Three, 8|Half2, 9|Five2\nNew "
"Partial types: 11|LDTop, 12|LDBottom, 13|LDLeft, 14|LDRight, 15|LDFive, 16|LDThree, 21|HDTop, 22|HDBottom, "
"23|HDLeft, 24|HDRight, 25|HDFive\nCommon Partial types: 0|Full, 99|Out";
// See if all entries in the file are valid
int bad1(0);
for (unsigned int k = 0; k < hgdc.waferFileSize(); ++k) {
Expand All @@ -89,10 +92,9 @@ void HGCalWaferInFileCheck::analyze(const edm::Event& iEvent, const edm::EventSe
HGCSiliconDetId id(det, 1, type, layer, waferU, waferV, 0, 0);
if (!geom->topology().validModule(id, 3)) {
int part = std::get<1>(hgdc.waferFileInfoFromIndex(indx));
std::string typex = (part < static_cast<int>(types.size())) ? types[part] : "X";
const auto& xy = hgdc.waferPosition(layer, waferU, waferV, true, false);
edm::LogVerbatim("HGCalGeom") << "ID[" << k << "]: (" << (hgdc.getLayerOffset() + layer) << ", " << waferU
<< ", " << waferV << ", " << typex << ") at (" << std::setprecision(4) << xy.first
<< ", " << waferV << ", " << part << ") at (" << std::setprecision(4) << xy.first
<< ", " << xy.second << ", " << hgdc.waferZ(layer, true) << ") not valid";
++bad1;
}
Expand All @@ -111,11 +113,10 @@ void HGCalWaferInFileCheck::analyze(const edm::Event& iEvent, const edm::EventSe
if (!hgdc.waferFileInfoExist(indx)) {
int part = hgdc.waferTypeRotation(id.layer(), id.waferU(), id.waferV(), false, false).first;
if (part != HGCalTypes::WaferOut) {
std::string typex = (part < static_cast<int>(types.size())) ? types[part] : "X";
const auto& xy = hgdc.waferPosition(id.layer(), id.waferU(), id.waferV(), true, false);
edm::LogVerbatim("HGCalGeom")
<< "ID[" << k << "]: (" << (hgdc.getLayerOffset() + id.layer()) << ", " << id.waferU() << ", "
<< id.waferV() << ", " << typex << ") at (" << std::setprecision(4) << xy.first << ", " << xy.second
<< id.waferV() << ", " << part << ") at (" << std::setprecision(4) << xy.first << ", " << xy.second
<< ", " << hgdc.waferZ(id.layer(), true) << ") not in wafer-list";
++bad2;
} else {
Expand Down Expand Up @@ -144,7 +145,8 @@ void HGCalWaferInFileCheck::analyze(const edm::Event& iEvent, const edm::EventSe
int part2 = hgdc.waferTypeRotation(id.layer(), id.waferU(), id.waferV(), false, false).first;
int rotn2 = hgdc.waferTypeRotation(id.layer(), id.waferU(), id.waferV(), false, false).second;
bool typeOK = (type1 == type2);
bool partOK = ((part1 == part2) || ((part1 == HGCalTypes::WaferFull) && (part2 == HGCalTypes::WaferOut)));
bool partOK = ((part1 == part2) || ((part1 == HGCalTypes::WaferFull) && (part2 == HGCalTypes::WaferOut)) ||
((part2 == HGCalTypes::WaferFull) && (part1 != HGCalTypes::WaferOut)));
bool rotnOK = ((rotn1 == rotn2) || (part1 == HGCalTypes::WaferFull) || (part2 == HGCalTypes::WaferFull));
if (part1 < part2)
++badP2;
Expand All @@ -161,12 +163,10 @@ void HGCalWaferInFileCheck::analyze(const edm::Event& iEvent, const edm::EventSe
++badR;
if ((!typeOK) || (!partOK) || (!rotnOK)) {
++badG;
std::string partx1 = (part1 < static_cast<int>(types.size())) ? types[part1] : "X";
std::string partx2 = (part2 < static_cast<int>(types.size())) ? types[part2] : "X";
const auto& xy = hgdc.waferPosition(layer, waferU, waferV, true, false);
edm::LogVerbatim("HGCalGeom") << "ID[" << k << "]: (" << (hgdc.getLayerOffset() + layer) << ", " << waferU
<< ", " << waferV << ", " << type1 << ":" << type2 << ", " << partx1 << ":"
<< partx2 << ", " << rotn1 << ":" << rotn2 << ") at (" << std::setprecision(4)
<< ", " << waferV << ", " << type1 << ":" << type2 << ", " << part1 << ":"
<< part2 << ", " << rotn1 << ":" << rotn2 << ") at (" << std::setprecision(4)
<< xy.first << ", " << xy.second << ", " << hgdc.waferZ(layer, true)
<< ") failure flag " << typeOK << ":" << partOK << ":" << rotnOK << ":"
<< (part1 >= part2);
Expand Down
38 changes: 34 additions & 4 deletions Geometry/HGCalGeometry/test/HGCalWaferTypeTester.cc
Expand Up @@ -100,6 +100,27 @@ void HGCalWaferTypeTester::analyze(const edm::Event& iEvent, const edm::EventSet
0xFFF001, 0xFF001F, 0xF001FF, 0x001FFF, 0x01FFF0, 0x1FFF00, 0xFFC007, 0xFC007F, 0xC007FF,
0x007FFC, 0x07FFC0, 0x7FFC00, 0xFF8003, 0xF8003F, 0x8003FF, 0x003FF8, 0x03FF80, 0x3FF800,
0xFF0001, 0xF0001F, 0x0001FF, 0x001FF0, 0x01FF00, 0x1FF000, 0xFFFFFF};
const std::vector<int> partTypeNew = {HGCalTypes::WaferLDBottom,
HGCalTypes::WaferLDLeft,
HGCalTypes::WaferLDRight,
HGCalTypes::WaferLDFive,
HGCalTypes::WaferLDThree,
HGCalTypes::WaferHDTop,
HGCalTypes::WaferHDBottom,
HGCalTypes::WaferHDLeft,
HGCalTypes::WaferHDRight,
HGCalTypes::WaferHDFive};
const std::vector<int> partTypeOld = {HGCalTypes::WaferHalf,
HGCalTypes::WaferHalf,
HGCalTypes::WaferSemi,
HGCalTypes::WaferSemi,
HGCalTypes::WaferFive,
HGCalTypes::WaferThree,
HGCalTypes::WaferHalf2,
HGCalTypes::WaferChopTwoM,
HGCalTypes::WaferSemi2,
HGCalTypes::WaferSemi2,
HGCalTypes::WaferFive2};
const std::vector<DetId>& ids = geom->getValidGeomDetIds();
int all(0), total(0), good(0), bad(0);
for (auto id : ids) {
Expand All @@ -108,10 +129,18 @@ void HGCalWaferTypeTester::analyze(const edm::Event& iEvent, const edm::EventSet
if (hid.zside() > 0)
++all;
// Not a full wafer
if (type.first > 0 && type.first < 10 && hid.zside() > 0) {
int part = type.first;
if (part > 10) {
auto itr = std::find(partTypeNew.begin(), partTypeNew.end(), part);
if (itr != partTypeNew.end()) {
unsigned int indx = static_cast<unsigned int>(itr - partTypeNew.begin());
part = partTypeOld[indx];
}
}
if (part > 0 && part < 10 && hid.zside() > 0) {
++total;
int wtype = hgdc.waferType(hid.layer(), hid.waferU(), hid.waferV());
int indx = (type.first - 1) * 6 + type.second;
int indx = (part - 1) * 6 + type.second;
GlobalPoint xyz = geom->getWaferPosition(id);
auto range = hgdc.rangeRLayer(hid.layer(), true);
unsigned int ipat(0), ii(1);
Expand Down Expand Up @@ -154,8 +183,9 @@ void HGCalWaferTypeTester::analyze(const edm::Event& iEvent, const edm::EventSet
}
std::string cherr = (!match) ? " ***** ERROR *****" : "";
edm::LogVerbatim("HGCalGeomX") << "Wafer[" << wtype << ", " << hid.layer() << ", " << hid.waferU() << ", "
<< hid.waferV() << "] with type: rotation " << type.first << ":" << type.second
<< " Pattern " << std::hex << pat[indx] << ":" << ipat << std::dec << cherr;
<< hid.waferV() << "] with type: rotation " << type.first << "(" << part
<< "):" << type.second << " Pattern " << std::hex << pat[indx] << ":" << ipat
<< std::dec << cherr;
if (!match) {
++bad;
// Need debug information here
Expand Down
56 changes: 42 additions & 14 deletions Geometry/HGCalGeometry/test/python/testHGCalWaferInFileCheck_cfg.py
@@ -1,22 +1,50 @@
###############################################################################
# Way to use this:
# cmsRun testHGCalWaferInFileCheck_cfg.py geometry=D88
#
# Options for geometry D83, D88, D92, D93
#
###############################################################################
import FWCore.ParameterSet.Config as cms
from Configuration.Eras.Era_Phase2C11_cff import Phase2C11
import os, sys, imp, re
import FWCore.ParameterSet.VarParsing as VarParsing

####################################################################
### SETUP OPTIONS
options = VarParsing.VarParsing('standard')
options.register('geometry',
"D88",
VarParsing.VarParsing.multiplicity.singleton,
VarParsing.VarParsing.varType.string,
"geometry of operations: D83, D88, D92, D93")

### get and parse the command line arguments
options.parseArguments()
print(options)

####################################################################
# Use the options
if (options.geometry == "D92"):
from Configuration.Eras.Era_Phase2C11M9_cff import Phase2C11M9
Copy link
Contributor

Choose a reason for hiding this comment

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

Why duplications of

from Configuration.Eras.Era_Phase2C11M9_cff import Phase2C11M9
process = cms.Process('WaferInFileCheck',Phase2C11M9)

in all conditions?

process = cms.Process('WaferInFileCheck',Phase2C11M9)
process.load('Configuration.Geometry.GeometryExtended2026D92Reco_cff')
elif (options.geometry == "D93"):
from Configuration.Eras.Era_Phase2C11M9_cff import Phase2C11M9
process = cms.Process('WaferInFileCheck',Phase2C11M9)
process.load('Configuration.Geometry.GeometryExtended2026D93Reco_cff')
elif (options.geometry == "D83"):
from Configuration.Eras.Era_Phase2C11M9_cff import Phase2C11M9
process = cms.Process('WaferInFileCheck',Phase2C11M9)
process.load('Configuration.Geometry.GeometryExtended2026D83Reco_cff')
else:
from Configuration.Eras.Era_Phase2C11M9_cff import Phase2C11M9
process = cms.Process('WaferInFileCheck',Phase2C11M9)
process.load('Configuration.Geometry.GeometryExtended2026D88Reco_cff')

process = cms.Process("PROD",Phase2C11)
process.load("SimGeneral.HepPDTESSource.pdt_cfi")
process.load("Geometry.HGCalCommonData.testHGCalV16XML_cfi")
process.load("Geometry.TrackerNumberingBuilder.trackerNumberingGeometry_cff")
process.load("Geometry.EcalCommonData.ecalSimulationParameters_cff")
process.load("Geometry.HcalCommonData.hcalDDDSimConstants_cff")
process.load("Geometry.HGCalCommonData.hgcalV15ParametersInitialization_cfi")
process.load("Geometry.HGCalCommonData.hgcalNumberingInitialization_cfi")
process.load("Geometry.MuonNumbering.muonGeometryConstants_cff")
process.load("Geometry.MuonNumbering.muonOffsetESProducer_cff")
process.load("Geometry.MTDNumberingBuilder.mtdNumberingGeometry_cff")
process.load("Geometry.CaloEventSetup.HGCalV9Topology_cfi")
process.load("Geometry.HGCalGeometry.HGCalGeometryESProducer_cfi")
process.load("Geometry.HGCalGeometry.hgcalEEWaferInFileCheck_cfi")

process.load('FWCore.MessageService.MessageLogger_cfi')

if hasattr(process,'MessageLogger'):
process.MessageLogger.HGCalGeom=dict()

Expand Down
45 changes: 42 additions & 3 deletions Geometry/HGCalGeometry/test/python/testHGCalWaferTypeTester_cfg.py
@@ -1,14 +1,53 @@
###############################################################################
# Way to use this:
# cmsRun testHGCalWaferTypeTester_cfg.py geometry=D88
#
# Options for geometry D83, D88, D92, D93
#
###############################################################################
import FWCore.ParameterSet.Config as cms
from Configuration.Eras.Era_Phase2C11_cff import Phase2C11
import os, sys, imp, re
import FWCore.ParameterSet.VarParsing as VarParsing

####################################################################
### SETUP OPTIONS
options = VarParsing.VarParsing('standard')
options.register('geometry',
"D88",
VarParsing.VarParsing.multiplicity.singleton,
VarParsing.VarParsing.varType.string,
"geometry of operations: D83, D88, D92, D93")

### get and parse the command line arguments
options.parseArguments()
print(options)

####################################################################
# Use the options
if (options.geometry == "D92"):
from Configuration.Eras.Era_Phase2C11M9_cff import Phase2C11M9
Copy link
Contributor

Choose a reason for hiding this comment

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

Same question as above.

process = cms.Process('WaferTypeTester',Phase2C11M9)
process.load('Configuration.Geometry.GeometryExtended2026D92Reco_cff')
elif (options.geometry == "D93"):
from Configuration.Eras.Era_Phase2C11M9_cff import Phase2C11M9
process = cms.Process('WaferTypeTester',Phase2C11M9)
process.load('Configuration.Geometry.GeometryExtended2026D93Reco_cff')
elif (options.geometry == "D83"):
from Configuration.Eras.Era_Phase2C11M9_cff import Phase2C11M9
process = cms.Process('WaferTypeTester',Phase2C11M9)
process.load('Configuration.Geometry.GeometryExtended2026D83Reco_cff')
else:
from Configuration.Eras.Era_Phase2C11M9_cff import Phase2C11M9
process = cms.Process('WaferTypeTester',Phase2C11M9)
process.load('Configuration.Geometry.GeometryExtended2026D88Reco_cff')

process = cms.Process("PROD",Phase2C11)
process.load("SimGeneral.HepPDTESSource.pdt_cfi")
process.load("Configuration.Geometry.GeometryExtended2026D86Reco_cff")
process.load("Geometry.HGCalGeometry.hgcalEEWaferTypeTester_cfi")

process.load('FWCore.MessageService.MessageLogger_cfi')
if hasattr(process,'MessageLogger'):
process.MessageLogger.HGCalGeom=dict()
process.MessageLogger.HGCalGeomX=dict()

process.load("IOMC.RandomEngine.IOMC_cff")
process.RandomNumberGeneratorService.generator.initialSeed = 456789
Expand Down