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-hgx292 Bug fix for real partial wafer simulations in versions V15 and V16 #35765

Merged
merged 4 commits into from
Oct 29, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Geometry/HGCalCommonData/data/hgcalCons/v15/hgcalCons.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<Parameter name="GeometryMode" value="HGCalGeometryMode::Hexagon8Module" eval="false"/>
<Parameter name="LevelZSide" value="3"/>
<Parameter name="LevelTop" value="9"/>
<Parameter name="LevelTop" value="11"/>
<Parameter name="LevelTop" value="12"/>
<Parameter name="WaferThickness" value="[hgcal:WaferThickness]"/>
<Parameter name="WaferThickness" value="[hgcal:WaferThickness]"/>
<Parameter name="WaferThickness" value="[hgcal:WaferThickness]"/>
Expand Down Expand Up @@ -88,7 +88,7 @@
<Parameter name="GeometryMode" value="HGCalGeometryMode::Hexagon8Module" eval="false"/>
<Parameter name="LevelZSide" value="3"/>
<Parameter name="LevelTop" value="9"/>
<Parameter name="LevelTop" value="11"/>
<Parameter name="LevelTop" value="12"/>
<Parameter name="WaferThickness" value="[hgcal:WaferThickness]"/>
<Parameter name="WaferThickness" value="[hgcal:WaferThickness]"/>
<Parameter name="WaferThickness" value="[hgcal:WaferThickness]"/>
Expand Down
4 changes: 2 additions & 2 deletions Geometry/HGCalCommonData/data/hgcalCons/v16/hgcalCons.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<Parameter name="GeometryMode" value="HGCalGeometryMode::Hexagon8Module" eval="false"/>
<Parameter name="LevelZSide" value="3"/>
<Parameter name="LevelTop" value="9"/>
<Parameter name="LevelTop" value="11"/>
<Parameter name="LevelTop" value="12"/>
<Parameter name="WaferThickness" value="[hgcal:WaferThicknessFine]"/>
<Parameter name="WaferThickness" value="[hgcal:WaferThicknessCoarse1]"/>
<Parameter name="WaferThickness" value="[hgcal:WaferThicknessCoarse2]"/>
Expand Down Expand Up @@ -89,7 +89,7 @@
<Parameter name="GeometryMode" value="HGCalGeometryMode::Hexagon8Module" eval="false"/>
<Parameter name="LevelZSide" value="3"/>
<Parameter name="LevelTop" value="9"/>
<Parameter name="LevelTop" value="11"/>
<Parameter name="LevelTop" value="12"/>
<Parameter name="WaferThickness" value="[hgcal:WaferThicknessFine]"/>
<Parameter name="WaferThickness" value="[hgcal:WaferThicknessCoarse1]"/>
<Parameter name="WaferThickness" value="[hgcal:WaferThicknessCoarse2]"/>
Expand Down
144 changes: 72 additions & 72 deletions Geometry/HGCalCommonData/data/hgcalcell/v15/hgcalcell.xml

Large diffs are not rendered by default.

144 changes: 72 additions & 72 deletions Geometry/HGCalCommonData/data/hgcalcell/v16/hgcalcell.xml

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Geometry/HGCalCommonData/data/hgcalwafer/v15/hgcalwafer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@
0, 0, 0, 0, 0, 1, 0 </Vector>
<Vector name="Layers" type="numeric" nEntries="9">
0, 1, 2, 3, 5, 3, 4, 3, 6 </Vector>
<String name="SenseName" value="HGCalHECellSensitive0Fine"/>
<String name="SenseName" value="HGCalHESiliconCellSensitive0Fine"/>
<Numeric name="SenseType" value="0"/>
<Numeric name="SenseThick" value="[CellThicknessFine]"/>
<Numeric name="PosSensitive" value="0"/>
Expand Down Expand Up @@ -603,7 +603,7 @@
0, 0, 0, 0, 0, 1, 0 </Vector>
<Vector name="Layers" type="numeric" nEntries="9">
0, 1, 2, 3, 5, 3, 4, 3, 6 </Vector>
<String name="SenseName" value="HGCalHECellSensitive0Coarse1"/>
<String name="SenseName" value="HGCalHESiliconCellSensitive0Coarse1"/>
<Numeric name="SenseType" value="1"/>
<Numeric name="SenseThick" value="[CellThicknessCoarse1]"/>
<Numeric name="PosSensitive" value="0"/>
Expand Down Expand Up @@ -640,7 +640,7 @@
0, 0, 0, 0, 0, 1, 0 </Vector>
<Vector name="Layers" type="numeric" nEntries="9">
0, 1, 2, 3, 5, 3, 4, 3, 6 </Vector>
<String name="SenseName" value="HGCalHECellSensitive0Coarse2"/>
<String name="SenseName" value="HGCalHESiliconCellSensitive0Coarse2"/>
<Numeric name="SenseType" value="2"/>
<Numeric name="SenseThick" value="[CellThicknessCoarse2]"/>
<Numeric name="PosSensitive" value="0"/>
Expand Down
6 changes: 3 additions & 3 deletions Geometry/HGCalCommonData/data/hgcalwafer/v16/hgcalwafer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@
0, 0, 0, 0, 0, 1, 0 </Vector>
<Vector name="Layers" type="numeric" nEntries="9">
0, 1, 2, 3, 5, 3, 4, 3, 6 </Vector>
<String name="SenseName" value="HGCalHECellSensitive0Fine"/>
<String name="SenseName" value="HGCalHESiliconCellSensitive0Fine"/>
<Numeric name="SenseType" value="0"/>
<Numeric name="SenseThick" value="[CellThicknessFine]"/>
<Numeric name="PosSensitive" value="0"/>
Expand Down Expand Up @@ -598,7 +598,7 @@
0, 0, 0, 0, 0, 1, 0 </Vector>
<Vector name="Layers" type="numeric" nEntries="9">
0, 1, 2, 3, 5, 3, 4, 3, 6 </Vector>
<String name="SenseName" value="HGCalHECellSensitive0Coarse1"/>
<String name="SenseName" value="HGCalHESiliconCellSensitive0Coarse1"/>
<Numeric name="SenseType" value="1"/>
<Numeric name="SenseThick" value="[CellThicknessCoarse1]"/>
<Numeric name="PosSensitive" value="0"/>
Expand Down Expand Up @@ -634,7 +634,7 @@
0, 0, 0, 0, 0, 1, 0 </Vector>
<Vector name="Layers" type="numeric" nEntries="9">
0, 1, 2, 3, 5, 3, 4, 3, 6 </Vector>
<String name="SenseName" value="HGCalHECellSensitive0Coarse2"/>
<String name="SenseName" value="HGCalHESiliconCellSensitive0Coarse2"/>
<Numeric name="SenseType" value="2"/>
<Numeric name="SenseThick" value="[CellThicknessCoarse2]"/>
<Numeric name="PosSensitive" value="0"/>
Expand Down
4 changes: 3 additions & 1 deletion Geometry/HGCalCommonData/src/HGCalDDDConstants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1226,7 +1226,9 @@ void HGCalDDDConstants::waferFromPosition(const double x,
}
if ((std::abs(waferU) <= hgpar_->waferUVMax_) && (celltype >= 0)) {
cellHex(xx, yy, celltype, cellU, cellV, extend, debug);
wt = ((celltype < 2) ? (hgpar_->cellThickness_[celltype] / hgpar_->waferThick_) : 1.0);
wt = (((celltype < 2) && (mode_ != HGCalGeometryMode::Hexagon8Module))
? (hgpar_->cellThickness_[celltype] / hgpar_->waferThick_)
: 1.0);
} else {
cellU = cellV = 2 * hgpar_->nCellsFine_;
wt = 1.0;
Expand Down
2 changes: 1 addition & 1 deletion Geometry/HGCalCommonData/test/python/dumpHGCalV16_cfg.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import FWCore.ParameterSet.Config as cms

process = cms.Process("DUMP")
process.load("Geometry.HGCalCommonData.testHGCV16XML_cfi")
process.load("Geometry.HGCalCommonData.testHGCalV16XML_cfi")
process.load('FWCore.MessageService.MessageLogger_cfi')

if 'MessageLogger' in process.__dict__:
Expand Down
9 changes: 7 additions & 2 deletions Geometry/HGCalGeometry/test/HGCalGeometryRotTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@

#include "Geometry/Records/interface/IdealGeometryRecord.h"
#include "Geometry/HGCalGeometry/interface/HGCalGeometry.h"
#include "DataFormats/Math/interface/angle_units.h"
#include "DataFormats/ForwardDetId/interface/HGCSiliconDetId.h"

using namespace angle_units::operators;

class HGCalGeometryRotTest : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
public:
explicit HGCalGeometryRotTest(const edm::ParameterSet&);
Expand Down Expand Up @@ -77,10 +80,12 @@ void HGCalGeometryRotTest::beginRun(const edm::Run&, const edm::EventSetup& iSet
for (auto lay : layers_) {
HGCSiliconDetId detId(det, 1, types_[k], lay - layerOff, waferU_[k], waferV_[k], cellU_[k], cellV_[k]);
GlobalPoint global = geom->getPosition(DetId(detId));
double phi2 = global.phi();
auto xy = geom->topology().dddConstants().waferPosition(lay - layerOff, waferU_[k], waferV_[k], true);
double phi1 = std::atan2(xy.second, xy.first);
edm::LogVerbatim("HGCalGeom") << "Layer: " << lay << " U " << waferU_[k] << " V " << waferV_[k] << " Position ("
<< xy.first << ", " << xy.second << ")";
edm::LogVerbatim("HGCalGeom") << detId << " Position " << global;
<< xy.first << ", " << xy.second << ") phi " << convertRadToDeg(phi1);
edm::LogVerbatim("HGCalGeom") << detId << " Position " << global << " phi " << convertRadToDeg(phi2);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Geometry/HGCalSimData/data/hgcsensv15.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

<SpecParSection label="hgcsens.xml" eval="true">
<SpecPar name="hgcee">
<PartSelector path="//HGCalEESensitive.*"/>
<PartSelector path="//HGCalEECellSensitive.*"/>
<Parameter name="SensitiveDetector" value="HGCalSensitiveDetector" eval="false"/>
<Parameter name="ReadOutName" value="HGCHitsEE" eval="false"/>
</SpecPar>
<SpecPar name="hgchesil">
<PartSelector path="//HGCalHESiliconSensitive.*"/>
<PartSelector path="//HGCalHESiliconCellSensitive.*"/>
<Parameter name="SensitiveDetector" value="HGCalSensitiveDetector" eval="false"/>
<Parameter name="ReadOutName" value="HGCHitsHEfront" eval="false"/>
</SpecPar>
Expand Down
9 changes: 9 additions & 0 deletions SimG4CMS/Calo/plugins/HGCalSensitiveDetectorBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include "FWCore/PluginManager/interface/ModuleDef.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

//#define EDM_ML_DEBUG

class HGCalSensitiveDetectorBuilder : public SensitiveDetectorMakerBase {
public:
explicit HGCalSensitiveDetectorBuilder(edm::ParameterSet const& p, edm::ConsumesCollector cc)
Expand Down Expand Up @@ -49,6 +51,13 @@ class HGCalSensitiveDetectorBuilder : public SensitiveDetectorMakerBase {
: nullptr));
auto sd = std::make_unique<HGCalSD>(iname, hgc, clg, p, man);
SimActivityRegistryEnroller::enroll(reg, sd.get());
#ifdef EDM_ML_DEBUG
const auto& dets = clg.logicalNames(iname);
edm::LogVerbatim("HGCSim") << "HGCalSensitiveDetectorBuilder for " << iname << " utilizes " << dets.size()
<< " detectors";
for (unsigned int k = 0; k < dets.size(); ++k)
edm::LogVerbatim("HGCSim") << "Detector [" << k << "] " << dets[k];
#endif
return sd;
}

Expand Down
28 changes: 17 additions & 11 deletions SimG4CMS/Calo/src/HGCalNumberingScheme.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ uint32_t HGCalNumberingScheme::getUnitID(int layer, int module, int cell, int iz
index = HGCSiliconDetId(det_, iz, waferType, layer, waferU, waferV, cellU, cellV).rawId();
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HGCSim") << "OK WaferType " << waferType << " Wafer " << waferU << ":" << waferV << " Cell "
<< cellU << ":" << cellV;
<< cellU << ":" << cellV << " input " << cell << " wt " << wt << " Mode " << mode_;
} else {
edm::LogVerbatim("HGCSim") << "Bad WaferType " << waferType << " for Layer:u:v " << layer << ":" << waferU << ":"
<< waferV;
Expand Down Expand Up @@ -96,11 +96,12 @@ uint32_t HGCalNumberingScheme::getUnitID(int layer, int module, int cell, int iz
}
}
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HGCSim") << "HGCalNumberingScheme::i/p " << det_ << ":" << layer << ":" << module << ":" << cell
<< ":" << iz << ":" << pos.x() << ":" << pos.y() << ":" << pos.z() << " ID " << std::hex
<< index << std::dec << " wt " << wt;
bool matchOnly = (mode_ == HGCalGeometryMode::Hexagon8Module) ? true : false;
bool debug = (mode_ == HGCalGeometryMode::Hexagon8Module) ? true : false;
bool matchOnly = (mode_ == HGCalGeometryMode::Hexagon8Module);
bool debug = (mode_ == HGCalGeometryMode::Hexagon8Module);
if (debug)
edm::LogVerbatim("HGCSim") << "HGCalNumberingScheme::i/p " << det_ << ":" << layer << ":" << module << ":" << cell
<< ":" << iz << ":" << pos.x() << ":" << pos.y() << ":" << pos.z() << " ID " << std::hex
<< index << std::dec << " wt " << wt;
checkPosition(index, pos, matchOnly, debug);
#endif
return index;
Expand All @@ -109,7 +110,7 @@ uint32_t HGCalNumberingScheme::getUnitID(int layer, int module, int cell, int iz
void HGCalNumberingScheme::checkPosition(uint32_t index, const G4ThreeVector& pos, bool matchOnly, bool debug) const {
std::pair<float, float> xy;
bool ok(false);
double z1(0), tolR(12.0), tolZ(1.0);
double z1(0), tolR(14.0), tolZ(1.0);
int lay(-1);
if (index == 0) {
} else if (DetId(index).det() == DetId::HGCalHSi) {
Expand All @@ -118,7 +119,7 @@ void HGCalNumberingScheme::checkPosition(uint32_t index, const G4ThreeVector& po
xy = hgcons_.locateCell(lay, id.waferU(), id.waferV(), id.cellU(), id.cellV(), false, true);
z1 = hgcons_.waferZ(lay, false);
ok = true;
tolR = 12.0;
tolR = 14.0;
tolZ = 1.0;
} else if (DetId(index).det() == DetId::HGCalHSc) {
HGCScintillatorDetId id = HGCScintillatorDetId(index);
Expand Down Expand Up @@ -151,13 +152,18 @@ void HGCalNumberingScheme::checkPosition(uint32_t index, const G4ThreeVector& po
<< outok << " " << ck;
edm::LogVerbatim("HGCSim") << "Original " << pos.x() << ":" << pos.y() << " return " << xy.first << ":"
<< xy.second;
if (DetId(index).det() == DetId::HGCalHSi) {
if ((DetId(index).det() == DetId::HGCalEE) || (DetId(index).det() == DetId::HGCalHSi)) {
double wt = 0, xx = ((pos.z() > 0) ? pos.x() : -pos.x());
int waferU, waferV, cellU, cellV, waferType;
hgcons_.waferFromPosition(xx, pos.y(), lay, waferU, waferV, cellU, cellV, waferType, wt, false, true);
xy = hgcons_.locateCell(lay, waferU, waferV, cellU, cellV, false, true, true);
edm::LogVerbatim("HGCSim") << "HGCalNumberingScheme " << HGCSiliconDetId(index) << " position " << xy.first
<< ":" << xy.second;
double dx = (xx - xy.first);
double dy = (pos.y() - xy.second);
double dR = std::sqrt(dx * dx + dy * dy);
Copy link
Contributor

Choose a reason for hiding this comment

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

(For a possible fix in a forthcoming PR):

Suggested change
double dR = std::sqrt(dx * dx + dy * dy);
double dR2 = dx * dx + dy * dy;

to be compared with tolR2

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We shall take care of that in future PR which we can do once this PR is merged

ck = (dR > tolR) ? " ***** ERROR *****" : "";
edm::LogVerbatim("HGCSim") << "HGCalNumberingScheme " << HGCSiliconDetId(index) << " original position " << xx
<< ":" << pos.y() << " derived " << xy.first << ":" << xy.second << " Difference "
<< dR << ck;
}
}
}
Expand Down
10 changes: 8 additions & 2 deletions SimG4CMS/Calo/src/HGCalSD.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,15 @@ uint32_t HGCalSD::setDetUnitId(const G4Step* aStep) {
module = touch->GetReplicaNumber(3);
cell = touch->GetReplicaNumber(1);
} else {
layer = touch->GetReplicaNumber(2);
module = touch->GetReplicaNumber(1);
layer = touch->GetReplicaNumber(3);
module = touch->GetReplicaNumber(2);
}
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HGCSim") << "DepthsTop: " << touch->GetHistoryDepth() << ":" << levelT1_ << ":" << levelT2_
<< " name " << touch->GetVolume(0)->GetName() << " layer:module:cell " << layer << ":"
<< module << ":" << cell;
printDetectorLevels(touch);
#endif
} else if ((touch->GetHistoryDepth() == levelT1_) || (touch->GetHistoryDepth() == levelT2_)) {
layer = touch->GetReplicaNumber(0);
#ifdef EDM_ML_DEBUG
Expand Down
8 changes: 4 additions & 4 deletions SimG4CMS/Calo/test/python/runHGC5_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi")
process.load("IOMC.EventVertexGenerators.VtxSmearedGauss_cfi")
process.load('Configuration.Geometry.GeometryExtended2026D84Reco_cff')
process.load('Configuration.Geometry.GeometryExtended2026D83Reco_cff')
process.load("Configuration.StandardSequences.MagneticField_cff")
process.load("Configuration.EventContent.EventContent_cff")
process.load('Configuration.StandardSequences.Generator_cff')
Expand All @@ -28,7 +28,7 @@
process.Timing = cms.Service("Timing")

process.maxEvents = cms.untracked.PSet(
input = cms.untracked.int32(10)
input = cms.untracked.int32(100)
)

process.source = cms.Source("EmptySource",
Expand All @@ -39,8 +39,8 @@
process.generator = cms.EDProducer("FlatRandomEGunProducer",
PGunParameters = cms.PSet(
PartID = cms.vint32(211),
MinEta = cms.double(1.75),
MaxEta = cms.double(2.50),
MinEta = cms.double(1.52),
MaxEta = cms.double(3.00),
MinPhi = cms.double(-3.1415926),
MaxPhi = cms.double(3.1415926),
MinE = cms.double(100.00),
Expand Down
6 changes: 3 additions & 3 deletions SimG4CMS/Calo/test/python/runHGC6_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
process.Timing = cms.Service("Timing")

process.maxEvents = cms.untracked.PSet(
input = cms.untracked.int32(10)
input = cms.untracked.int32(100)
)

process.source = cms.Source("EmptySource",
Expand All @@ -39,8 +39,8 @@
process.generator = cms.EDProducer("FlatRandomEGunProducer",
PGunParameters = cms.PSet(
PartID = cms.vint32(13),
MinEta = cms.double(1.75),
MaxEta = cms.double(2.50),
MinEta = cms.double(1.52),
MaxEta = cms.double(3.00),
MinPhi = cms.double(-3.1415926),
MaxPhi = cms.double(3.1415926),
MinE = cms.double(100.00),
Expand Down
8 changes: 4 additions & 4 deletions SimG4Core/PrintGeomInfo/test/python/g4OverlapCheck2026_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

from Configuration.Eras.Era_Phase2C11_cff import Phase2C11
process = cms.Process('SIM',Phase2C11)
#process.load('Configuration.Geometry.GeometryExtended2026D77Reco_cff')
process.load('Configuration.Geometry.GeometryExtended2026D83Reco_cff')
#process.load('Configuration.Geometry.GeometryExtended2026D77_cff')
process.load('Configuration.Geometry.GeometryExtended2026D86_cff')

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

Expand All @@ -18,9 +18,9 @@
process.g4SimHits.CheckGeometry = True

# Geant4 geometry check
process.g4SimHits.G4CheckOverlap.OutputBaseName = cms.string("cms2026D83")
process.g4SimHits.G4CheckOverlap.OutputBaseName = cms.string("cms2026D86")
process.g4SimHits.G4CheckOverlap.OverlapFlag = cms.bool(True)
process.g4SimHits.G4CheckOverlap.Tolerance = cms.double(0.1)
process.g4SimHits.G4CheckOverlap.Tolerance = cms.double(0.01)
process.g4SimHits.G4CheckOverlap.Resolution = cms.int32(10000)
process.g4SimHits.G4CheckOverlap.Depth = cms.int32(-1)
# tells if NodeName is G4Region or G4PhysicalVolume
Expand Down