Skip to content

Commit

Permalink
Merge pull request #31774 from bsunanda/Phase2-hgx264x
Browse files Browse the repository at this point in the history
Phase2-hgx264x Correct a small issue in HGCalGeometry and update some test codes
  • Loading branch information
cmsbuild committed Oct 16, 2020
2 parents a78088d + 9494d94 commit 4e0b524
Show file tree
Hide file tree
Showing 17 changed files with 80 additions and 69 deletions.
12 changes: 8 additions & 4 deletions Geometry/CaloTopology/src/HGCalTopology.cc
Expand Up @@ -42,10 +42,10 @@ HGCalTopology::HGCalTopology(const HGCalDDDConstants& hdcons, int det) : hdcons_
}
kSizeForDenseIndexing = (unsigned int)(2 * kHGhalf_);
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HGCalGeom") << "HGCalTopology initialized for detector " << det_ << ":" << subdet_ << " having "
<< sectors_ << " Sectors, " << layers_ << " Layers from " << firstLay_ << ", " << cells_
<< " cells and total channels " << kSizeForDenseIndexing << ":" << (2 * kHGeomHalf_)
<< std::endl;
edm::LogVerbatim("HGCalGeom") << "HGCalTopology initialized for detector " << det << ":" << det_ << ":" << subdet_
<< " having " << sectors_ << " Sectors, " << layers_ << " Layers from " << firstLay_
<< ", " << cells_ << " cells and total channels " << kSizeForDenseIndexing << ":"
<< (2 * kHGeomHalf_);
#endif
}

Expand Down Expand Up @@ -633,6 +633,10 @@ HGCalTopology::DecodedDetId HGCalTopology::decode(const DetId& startId) const {

DetId HGCalTopology::encode(const HGCalTopology::DecodedDetId& idx) const {
DetId id;
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HGCalGeom") << "Encode " << idx.det << ":" << idx.zSide << ":" << idx.iType << ":" << idx.iLay
<< ":" << idx.iSec1 << ":" << idx.iSec2 << ":" << idx.iCell1 << ":" << idx.iCell2;
#endif
if (waferHexagon6()) {
id =
HGCalDetId((ForwardSubdetector)(idx.det), idx.zSide, idx.iLay, ((idx.iType > 0) ? 1 : 0), idx.iSec1, idx.iCell1)
Expand Down
8 changes: 5 additions & 3 deletions Geometry/HGCalGeometry/src/HGCalGeometry.cc
Expand Up @@ -465,6 +465,8 @@ DetId HGCalGeometry::getClosestCell(const GlobalPoint& r) const {
if ((cellIndex < m_cellVec.size() && m_det != DetId::HGCalHSc) ||
(cellIndex < m_cellVec2.size() && m_det == DetId::HGCalHSc)) {
HGCalTopology::DecodedDetId id = m_topology.decode(m_validGeomIds[cellIndex]);
if (id.det == 0)
id.det = static_cast<int>(m_topology.detector());
HepGeom::Point3D<float> local;
if (r.z() > 0) {
local = HepGeom::Point3D<float>(r.x(), r.y(), 0);
Expand Down Expand Up @@ -496,9 +498,9 @@ DetId HGCalGeometry::getClosestCell(const GlobalPoint& r) const {
id.iCell2 = kxy[4];
}
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HGCalGeom") << "getClosestCell: local " << local << " Id " << id.zSide << ":" << id.iLay << ":"
<< id.iSec1 << ":" << id.iSec2 << ":" << id.iType << ":" << id.iCell1 << ":"
<< id.iCell2;
edm::LogVerbatim("HGCalGeom") << "getClosestCell: local " << local << " Id " << id.det << ":" << id.zSide << ":"
<< id.iLay << ":" << id.iSec1 << ":" << id.iSec2 << ":" << id.iType << ":"
<< id.iCell1 << ":" << id.iCell2;
#endif

//check if returned cell is valid
Expand Down
15 changes: 9 additions & 6 deletions Geometry/HGCalGeometry/test/HGCalGeometryCheck.cc
Expand Up @@ -54,11 +54,11 @@ class HGCalGeometryCheck : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm:

HGCalGeometryCheck::HGCalGeometryCheck(const edm::ParameterSet& iC)
: nameDetectors_(iC.getParameter<std::vector<std::string>>("detectorNames")),
geomTokens_{
edm::vector_transform(nameDetectors_,
[this](const std::string& name) {
return esConsumes<HGCalGeometry, IdealGeometryRecord>(edm::ESInputTag{"", name});
})},
geomTokens_{edm::vector_transform(
nameDetectors_,
[this](const std::string& name) {
return esConsumes<HGCalGeometry, IdealGeometryRecord, edm::Transition::BeginRun>(edm::ESInputTag{"", name});
})},
rmin_(iC.getUntrackedParameter<double>("rMin", 0.0)),
rmax_(iC.getUntrackedParameter<double>("rMax", 300.0)),
zmin_(iC.getUntrackedParameter<double>("zMin", 300.0)),
Expand Down Expand Up @@ -111,7 +111,9 @@ void HGCalGeometryCheck::beginRun(const edm::Run&, const edm::EventSetup& iSetup

auto zz = geom->topology().dddConstants().waferZ(lay, true);
auto rr = geom->topology().dddConstants().rangeR(zz, true);
edm::LogVerbatim("HGCalGeom") << "Layer " << lay << " R " << rr.first << ":" << rr.second << " Z " << zz;
auto rr0 = geom->topology().dddConstants().rangeRLayer(lay, true);
edm::LogVerbatim("HGCalGeom") << "Layer " << lay << " R " << rr.first << ":" << rr.second << " (" << rr0.first
<< ":" << rr0.second << ") Z " << zz;
double r = rr.first;
while (r <= rr.second) {
h_RZ_[0]->Fill(zz, r);
Expand All @@ -120,6 +122,7 @@ void HGCalGeometryCheck::beginRun(const edm::Run&, const edm::EventSetup& iSetup
double phi = 2 * k * M_PI / 100.0;
GlobalPoint global1(r * cos(phi), r * sin(phi), zz);
DetId id = geom->getClosestCell(global1);

if (ifNose_) {
HFNoseDetId detId = HFNoseDetId(id);
h_Mod_.back()->Fill(detId.waferU());
Expand Down
12 changes: 7 additions & 5 deletions Geometry/HGCalGeometry/test/HGCalWaferInFileCheck.cc
Expand Up @@ -126,7 +126,7 @@ void HGCalWaferInFileCheck::analyze(const edm::Event& iEvent, const edm::EventSe
<< " extra ones\n\n";

// Now cross check the content
int allG(0), badT(0), badP(0), badR(0), badG(0), badT1(0), badT2(0);
int allG(0), badT(0), badP(0), badP2(0), badR(0), badG(0), badT1(0), badT2(0);
for (unsigned int k = 0; k < hgdc.waferFileSize(); ++k) {
int indx = hgdc.waferFileIndex(k);
int type1 = std::get<0>(hgdc.waferFileInfo(k));
Expand All @@ -144,6 +144,8 @@ void HGCalWaferInFileCheck::analyze(const edm::Event& iEvent, const edm::EventSe
bool typeOK = (type1 == type2);
bool partOK = ((part1 == part2) || ((part1 == HGCalTypes::WaferFull) && (part2 == HGCalTypes::WaferOut)));
bool rotnOK = ((rotn1 == rotn2) || (part1 == HGCalTypes::WaferFull) || (part2 == HGCalTypes::WaferFull));
if (part1 < part2)
++badP2;
if (!typeOK) {
++badT;
if (type1 == 0)
Expand All @@ -163,13 +165,13 @@ void HGCalWaferInFileCheck::analyze(const edm::Event& iEvent, const edm::EventSe
std::cout << "ID[" << k << "]: (" << (hgdc.getLayerOffset() + layer) << ", " << waferU << ", " << waferV
<< ", " << type1 << ":" << type2 << ", " << partx1 << ":" << partx2 << ", " << rotn1 << ":" << rotn2
<< ") at (" << std::setprecision(4) << xy.first << ", " << xy.second << ", "
<< hgdc.waferZ(layer, true) << ") failure flag " << typeOK << ":" << partOK << ":" << rotnOK
<< std::endl;
<< hgdc.waferZ(layer, true) << ") failure flag " << typeOK << ":" << partOK << ":" << rotnOK << ":"
<< (part1 >= part2) << std::endl;
}
}
}
std::cout << "\n\nFinds " << badG << " (" << badT << "[" << badT1 << ":" << badT2 << "]:" << badP << ":" << badR
<< ") mismatch among " << allG << " wafers with the same indices\n\n";
std::cout << "\n\nFinds " << badG << " (" << badT << "[" << badT1 << ":" << badT2 << "]:" << badP << ":" << badP2
<< ":" << badR << ") mismatch among " << allG << " wafers with the same indices\n\n";
}
}

Expand Down
23 changes: 15 additions & 8 deletions Geometry/HGCalGeometry/test/HGCalWaferInFileTest.cc
Expand Up @@ -152,8 +152,8 @@ void HGCalWaferInFileTest::analyze(const edm::Event& iEvent, const edm::EventSet
<< " wafers with the same indices\n\n";

// Now cross check the content (partial and orientation)
int allX(0), badG(0), badP(0), badR(0);
std::vector<int> wrongP(layers, 0), wrongR(layers, 0);
int allX(0), badG(0), badP(0), badP2(0), badR(0);
std::vector<int> wrongP(layers, 0), wrongP2(layers, 0), wrongR(layers, 0);
for (unsigned int k = 0; k < hgdc.waferFileSize(); ++k) {
int indx = hgdc.waferFileIndex(k);
int part1 = std::get<1>(hgdc.waferFileInfo(k));
Expand All @@ -169,11 +169,17 @@ void HGCalWaferInFileTest::analyze(const edm::Event& iEvent, const edm::EventSet
int rotn2 = hgdc.waferTypeRotation(id.layer(), id.waferU(), id.waferV(), false, false).second;
bool partOK = ((part1 == part2) || ((part1 == HGCalTypes::WaferFull) && (part2 == HGCalTypes::WaferOut)));
bool rotnOK = ((rotn1 == rotn2) || (part1 == HGCalTypes::WaferFull) || (part2 == HGCalTypes::WaferFull));
bool partOK2 = ((part1 > part2) || partOK);
if (!partOK) {
++badP;
if ((layer - layerf) < layers)
++wrongP[layer - layerf];
}
if (!partOK2) {
++badP2;
if ((layer - layerf) < layers)
++wrongP2[layer - layerf];
}
if (!rotnOK) {
++badR;
if ((layer - layerf) < layers)
Expand All @@ -188,20 +194,21 @@ void HGCalWaferInFileTest::analyze(const edm::Event& iEvent, const edm::EventSet
auto points = getPoints(xy.first, xy.second, delX, delY, rr.first, rr.second, layer, waferU, waferV);
std::cout << "ID[" << k << "]: (" << (hgdc.getLayerOffset() + layer) << ", " << waferU << ", " << waferV
<< "," << type2 << ", " << partx1 << ":" << partx2 << ":" << part1 << ":" << part2 << ", " << rotn1
<< ":" << rotn2 << ") at (" << std::setprecision(4) << xy.first << ", " << xy.second << ", "
<< hgdc.waferZ(layer, true) << ") failure flag " << partOK << ":" << rotnOK << " with "
<< points.size() << " points:";
<< ":" << rotn2 << ", " << partOK2 << ") at (" << std::setprecision(4) << xy.first << ", "
<< xy.second << ", " << hgdc.waferZ(layer, true) << ") failure flag " << partOK << ":" << rotnOK
<< " with " << points.size() << " points:";
for (auto point : points)
std::cout << " " << point;
std::cout << " in the region " << rr.first << ":" << rr.second << std::endl;
}
}
}
std::cout << "\n\nFinds " << badG << " (" << badP << ":" << badR << ") mismatch in partial|orientation among "
<< allX << " wafers with the same indices" << std::endl;
std::cout << "\n\nFinds " << badG << " (" << badP << ":" << badP2 << ":" << badR
<< ") mismatch in partial|orientation among " << allX << " wafers with the same indices" << std::endl;
for (int k = 0; k < layers; ++k) {
if ((wrongP[k] > 0) || (wrongR[k] > 0))
std::cout << "Layer[" << k << ":" << (layerf + k) << "] " << wrongP[k] << ":" << wrongR[k] << std::endl;
std::cout << "Layer[" << k << ":" << (layerf + k) << "] " << wrongP[k] << ":" << wrongP2[k] << ":" << wrongR[k]
<< std::endl;
}
std::cout << std::endl;
}
Expand Down
14 changes: 9 additions & 5 deletions Geometry/HGCalGeometry/test/python/hgcGeomAnalyzer_cfg.py
Expand Up @@ -10,13 +10,17 @@

fileName = "geom_output_"+options.geom

process = cms.Process("demo",eras.Phase2C8)
process = cms.Process("demo",eras.Phase2C11)

process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
if options.geom == 'v10':
process.load('Configuration.Geometry.GeometryExtended2026D41Reco_cff')
elif options.geom == 'v11':
process.load('Configuration.Geometry.GeometryExtended2026D46Reco_cff')
if options.geom == 'v11':
process.load('Configuration.Geometry.GeometryExtended2026D49Reco_cff')
elif options.geom == 'v12':
process.load('Configuration.Geometry.GeometryExtended2026D68Reco_cff')
elif options.geom == 'v13':
process.load('Configuration.Geometry.GeometryExtended202670Reco_cff')
elif options.geom == 'v14':
process.load('Configuration.Geometry.GeometryExtended2026D71Reco_cff')
else:
raise Exception('UNKNOWN GEOMETRY!')

Expand Down
@@ -1,9 +1,11 @@
import FWCore.ParameterSet.Config as cms

process = cms.Process("CaloCellGeometryTest")
from Configuration.Eras.Era_Phase2C11_cff import Phase2C11

process.load("Configuration.Geometry.GeometryExtended2026D35_cff")
process.load("Configuration.Geometry.GeometryExtended2026D35Reco_cff")
process = cms.Process("CaloCellGeometryTest",Phase2C11)

process.load("Configuration.Geometry.GeometryExtended2026D71_cff")
process.load("Configuration.Geometry.GeometryExtended2026D71Reco_cff")
process.load('FWCore.MessageService.MessageLogger_cfi')

if hasattr(process,'MessageLogger'):
Expand Down
Expand Up @@ -18,7 +18,7 @@
process.load("Geometry.HGCalGeometry.hgcalGeometryDump_cfi")

process.DDDetectorESProducer = cms.ESSource("DDDetectorESProducer",
confGeomXMLFiles = cms.FileInPath('Geometry/CMSCommonData/data/dd4hep/cmsExtendedGeometry2026D41.xml'),
confGeomXMLFiles = cms.FileInPath('Geometry/CMSCommonData/data/dd4hep/cmsExtendedGeometry2026D71.xml'),
appendToDataLabel = cms.string('')
)

Expand Down
Expand Up @@ -2,7 +2,7 @@

process = cms.Process("HcalGeometryTest")

process.load("Geometry.CMSCommonData.cmsExtendedGeometry2026D41XML_cfi")
process.load("Geometry.CMSCommonData.cmsExtendedGeometry2026D71XML_cfi")
process.load("Geometry.EcalCommonData.ecalSimulationParameters_cff")
process.load("Geometry.HcalCommonData.hcalDDDSimConstants_cff")
process.load("Geometry.HGCalCommonData.hgcalParametersInitialization_cfi")
Expand Down
7 changes: 1 addition & 6 deletions Geometry/HGCalGeometry/test/python/testHGCalCorner_cfg.py
Expand Up @@ -2,12 +2,7 @@

process = cms.Process("PROD")
process.load("SimGeneral.HepPDTESSource.pdt_cfi")

#process.load("Geometry.HGCalCommonData.testHGCV8XML_cfi")
#process.load("Geometry.HGCalCommonData.hgcalV6NumberingInitialization_cfi")
#process.load("Geometry.HGCalCommonData.hgcalV6ParametersInitialization_cfi")
#process.load("Geometry.CaloEventSetup.HGCalV6Topology_cfi")
process.load("Geometry.HGCalCommonData.testHGCV10XML_cfi")
process.load("Geometry.HGCalCommonData.testHGCalV14XML_cfi")
process.load("Geometry.HGCalCommonData.hgcalParametersInitialization_cfi")
process.load("Geometry.HGCalCommonData.hgcalNumberingInitialization_cfi")
process.load("Geometry.CaloEventSetup.HGCalV9Topology_cfi")
Expand Down
18 changes: 9 additions & 9 deletions Geometry/HGCalGeometry/test/python/testHGCalGeometryCheck_cfg.py
@@ -1,14 +1,14 @@
import FWCore.ParameterSet.Config as cms

#from Configuration.Eras.Era_Phase2C4_cff import Phase2C4
#process = cms.Process('PROD',Phase2C4)
#process.load('Configuration.Geometry.GeometryExtended2026D35_cff')
#process.load('Configuration.Geometry.GeometryExtended2026D35Reco_cff')

from Configuration.Eras.Era_Phase2C4_cff import Phase2C4
process = cms.Process('PROD',Phase2C4)
process.load('Configuration.Geometry.GeometryExtended2026D41_cff')
process.load('Configuration.Geometry.GeometryExtended2026D41Reco_cff')
#from Configuration.Eras.Era_Phase2C9_cff import Phase2C9
#process = cms.Process('PROD',Phase2C9)
#process.load('Configuration.Geometry.GeometryExtended2026D49_cff')
#process.load('Configuration.Geometry.GeometryExtended2026D49Reco_cff')

from Configuration.Eras.Era_Phase2C11_cff import Phase2C11
process = cms.Process('PROD',Phase2C11)
process.load('Configuration.Geometry.GeometryExtended2026D71_cff')
process.load('Configuration.Geometry.GeometryExtended2026D71Reco_cff')

process.load("SimGeneral.HepPDTESSource.pdt_cfi")
process.load('Geometry.HGCalGeometry.hgcalGeometryCheck_cfi')
Expand Down
Expand Up @@ -3,7 +3,7 @@
process = cms.Process("PROD")
process.load("SimGeneral.HepPDTESSource.pdt_cfi")

process.load("Configuration.Geometry.GeometryExtended2026D47Reco_cff")
process.load("Configuration.Geometry.GeometryExtended2026D60Reco_cff")
process.load('FWCore.MessageService.MessageLogger_cfi')

if hasattr(process,'MessageLogger'):
Expand Down
8 changes: 2 additions & 6 deletions Geometry/HGCalGeometry/test/python/testHGCalGeometry_cfg.py
Expand Up @@ -3,12 +3,8 @@
process = cms.Process("PROD")
process.load("SimGeneral.HepPDTESSource.pdt_cfi")

process.load("Configuration.Geometry.GeometryExtended2026D41Reco_cff")
#process.load("Geometry.HGCalCommonData.testHGCV8XML_cfi")
#process.load("Geometry.HGCalCommonData.hgcalV6NumberingInitialization_cfi")
#process.load("Geometry.HGCalCommonData.hgcalV6ParametersInitialization_cfi")
#process.load("Geometry.CaloEventSetup.HGCalV6Topology_cfi")
#process.load("Geometry.HGCalCommonData.testHGCV10XML_cfi")
process.load("Configuration.Geometry.GeometryExtended2026D71Reco_cff")
#process.load("Geometry.HGCalCommonData.testHGCalV14XML_cfi")
#process.load("Geometry.HGCalCommonData.hgcalParametersInitialization_cfi")
#process.load("Geometry.HGCalCommonData.hgcalNumberingInitialization_cfi")
#process.load("Geometry.CaloEventSetup.HGCalV9Topology_cfi")
Expand Down
6 changes: 3 additions & 3 deletions Geometry/HGCalGeometry/test/python/testHGCalNeighbor_cfg.py
@@ -1,10 +1,10 @@
import FWCore.ParameterSet.Config as cms

from Configuration.Eras.Era_Phase2C4_cff import Phase2C4
process = cms.Process("PROD",Phase2C4)
from Configuration.Eras.Era_Phase2C11_cff import Phase2C11
process = cms.Process("PROD",Phase2C11)

process.load("SimGeneral.HepPDTESSource.pdt_cfi")
process.load("Configuration.Geometry.GeometryExtended2026D35Reco_cff")
process.load("Configuration.Geometry.GeometryExtended2026D71Reco_cff")
process.load('Configuration.StandardSequences.MagneticField_cff')
process.load('TrackingTools.TrackAssociator.DetIdAssociatorESProducer_cff')
process.load('FWCore.MessageService.MessageLogger_cfi')
Expand Down
4 changes: 2 additions & 2 deletions Geometry/HGCalGeometry/test/python/testHGCalRecHitTool_cfg.py
Expand Up @@ -4,8 +4,8 @@
process.load("SimGeneral.HepPDTESSource.pdt_cfi")

process.load("Configuration.Geometry.GeometryExtended2026D49Reco_cff")
#process.load("Configuration.Geometry.GeometryExtended2026D35Reco_cff")
#process.load("Configuration.Geometry.GeometryExtended2026D41Reco_cff")
#process.load("Configuration.Geometry.GeometryExtended2026D67Reco_cff")
#process.load("Configuration.Geometry.GeometryExtended2026D71Reco_cff")
process.load('FWCore.MessageService.MessageLogger_cfi')

if hasattr(process,'MessageLogger'):
Expand Down
6 changes: 1 addition & 5 deletions Geometry/HGCalGeometry/test/python/testHGCalSize_cfg.py
Expand Up @@ -3,11 +3,7 @@
process = cms.Process("PROD")
process.load("SimGeneral.HepPDTESSource.pdt_cfi")

#process.load("Geometry.HGCalCommonData.testHGCV8XML_cfi")
#process.load("Geometry.HGCalCommonData.hgcalV6NumberingInitialization_cfi")
#process.load("Geometry.HGCalCommonData.hgcalV6ParametersInitialization_cfi")
#process.load("Geometry.CaloEventSetup.HGCalV6Topology_cfi")
process.load("Geometry.HGCalCommonData.testHGCXML_cfi")
process.load("Geometry.HGCalCommonData.testHGCalV14XML_cfi")
process.load("Geometry.HGCalCommonData.hgcalParametersInitialization_cfi")
process.load("Geometry.HGCalCommonData.hgcalNumberingInitialization_cfi")
process.load("Geometry.CaloEventSetup.HGCalV9Topology_cfi")
Expand Down
2 changes: 1 addition & 1 deletion Geometry/HGCalGeometry/test/python/testHGCalWafer_cfg.py
Expand Up @@ -2,7 +2,7 @@

process = cms.Process("PROD")
process.load("SimGeneral.HepPDTESSource.pdt_cfi")
process.load("Configuration.Geometry.GeometryExtended2026D46Reco_cff")
process.load("Configuration.Geometry.GeometryExtended2026D71Reco_cff")
process.load('FWCore.MessageService.MessageLogger_cfi')

if hasattr(process,'MessageLogger'):
Expand Down

0 comments on commit 4e0b524

Please sign in to comment.