Skip to content

Commit 8d4dbbe

Browse files
authored
Merge pull request cms-sw#31516 from bsunanda/Run4-hgx261
Run4-hgx261 Bug fix for the v14 geometry of HGCal
2 parents 3413cee + 5b33466 commit 8d4dbbe

File tree

10 files changed

+64
-18
lines changed

10 files changed

+64
-18
lines changed

Geometry/HGCalCommonData/plugins/DDHGCalEEFileAlgo.cc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ void DDHGCalEEFileAlgo::initialize(const DDNumericArguments& nArgs,
148148
break;
149149
}
150150
}
151+
} else {
152+
firstLayer_ = 1;
151153
}
152154
#ifdef EDM_ML_DEBUG
153155
edm::LogVerbatim("HGCalGeom") << "There are " << layerType_.size() << " layers";
@@ -309,9 +311,9 @@ void DDHGCalEEFileAlgo::constructLayers(const DDLogicalPart& module, DDCompactVi
309311
edm::LogVerbatim("HGCalGeom") << "DDHGCalEEFileAlgo: " << solid.name() << " Tubs made of " << matName << ":"
310312
<< &matter << " of dimensions " << rinB << ", " << routF << ", " << hthick
311313
<< ", 0.0, 360.0 and position " << glog.name() << " number " << copy << ":"
312-
<< layerCenter_[copy - 1];
314+
<< layerCenter_[copy - firstLayer_];
313315
#endif
314-
positionSensitive(glog, rinB, routF, zz, layerSense_[ly], (copy - 1), cpv);
316+
positionSensitive(glog, rinB, routF, zz, layerSense_[ly], (copy - firstLayer_), cpv);
315317
}
316318
DDTranslation r1(0, 0, zz);
317319
DDRotation rot;
@@ -374,10 +376,14 @@ void DDHGCalEEFileAlgo::positionSensitive(
374376
<< " with " << corner.first << " corners";
375377
}
376378
#endif
377-
int type = HGCalWaferType::getType(HGCalWaferIndex::waferIndex(layer, u, v, false), waferIndex_, waferTypes_);
379+
int indx = HGCalWaferIndex::waferIndex((layer + firstLayer_), u, v, false);
380+
int type = HGCalWaferType::getType(indx, waferIndex_, waferTypes_);
378381
if (corner.first > 0 && type >= 0) {
379382
int copy = HGCalTypes::packTypeUV(type, u, v);
380383
#ifdef EDM_ML_DEBUG
384+
edm::LogVerbatim("HGCalGeom") << " DDHGCalHEFileAlgo: " << wafers_[type] << " number " << copy << " type "
385+
<< type << " layer:u:v:indx " << (layer + firstLayer_) << ":" << u << ":" << v
386+
<< ":" << indx;
381387
if (iu > ium)
382388
ium = iu;
383389
if (iv > ivm)

Geometry/HGCalCommonData/plugins/DDHGCalHEFileAlgo.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ void DDHGCalHEFileAlgo::initialize(const DDNumericArguments& nArgs,
171171
break;
172172
}
173173
}
174+
} else {
175+
firstLayer_ = 1;
174176
}
175177
#ifdef EDM_ML_DEBUG
176178
edm::LogVerbatim("HGCalGeom") << "There are " << layerType_.size() << " layers";
@@ -558,10 +560,14 @@ void DDHGCalHEFileAlgo::positionSensitive(
558560
#ifdef EDM_ML_DEBUG
559561
++ntot;
560562
#endif
561-
int type = HGCalWaferType::getType(HGCalWaferIndex::waferIndex(layer, u, v, false), waferIndex_, waferTypes_);
563+
int indx = HGCalWaferIndex::waferIndex((layer + firstLayer_), u, v, false);
564+
int type = HGCalWaferType::getType(indx, waferIndex_, waferTypes_);
562565
if (corner.first > 0 && type >= 0) {
563566
int copy = HGCalTypes::packTypeUV(type, u, v);
564567
#ifdef EDM_ML_DEBUG
568+
edm::LogVerbatim("HGCalGeom") << " DDHGCalHEFileAlgo: " << wafers_[type] << " number " << copy << " type "
569+
<< type << " layer:u:v:indx " << (layer + firstLayer_) << ":" << u << ":" << v
570+
<< ":" << indx;
565571
if (iu > ium)
566572
ium = iu;
567573
if (iv > ivm)

Geometry/HGCalCommonData/plugins/dd4hep/DDHGCalEEFileAlgo.cc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ struct HGCalEEFileAlgo {
8484
break;
8585
}
8686
}
87+
} else {
88+
firstLayer_ = 1;
8789
}
8890
#ifdef EDM_ML_DEBUG
8991
edm::LogVerbatim("HGCalGeom") << "There are " << layerType_.size() << " layers";
@@ -227,9 +229,9 @@ struct HGCalEEFileAlgo {
227229
edm::LogVerbatim("HGCalGeom") << "DDHGCalEEFileAlgo: " << solid.name() << " Tubs made of " << matter.name()
228230
<< " of dimensions " << rinB << ", " << routF << ", " << hthick
229231
<< ", 0.0, 360.0 and position " << glog.name() << " number " << copy << ":"
230-
<< layerCenter_[copy - 1];
232+
<< layerCenter_[copy - firstLayer_];
231233
#endif
232-
positionSensitive(ctxt, e, glog, rinB, routF, zz, layerSense_[ly], (copy - 1));
234+
positionSensitive(ctxt, e, glog, rinB, routF, zz, layerSense_[ly], (copy - firstLayer_));
233235
}
234236

235237
dd4hep::Position r1(0, 0, zz);
@@ -309,10 +311,14 @@ struct HGCalEEFileAlgo {
309311
<< " with " << corner.first << " corners";
310312
}
311313
#endif
312-
int type = HGCalWaferType::getType(HGCalWaferIndex::waferIndex(layer, u, v, false), waferIndex_, waferTypes_);
314+
int indx = HGCalWaferIndex::waferIndex((layer + firstLayer_), u, v, false);
315+
int type = HGCalWaferType::getType(indx, waferIndex_, waferTypes_);
313316
if (corner.first > 0 && type >= 0) {
314317
int copy = HGCalTypes::packTypeUV(type, u, v);
315318
#ifdef EDM_ML_DEBUG
319+
edm::LogVerbatim("HGCalGeom") << " DDHGCalHEFileAlgo: " << wafers_[type] << " number " << copy << " type "
320+
<< type << " layer:u:v:indx " << (layer + firstLayer_) << ":" << u << ":" << v
321+
<< ":" << indx;
316322
if (iu > ium)
317323
ium = iu;
318324
if (iv > ivm)

Geometry/HGCalCommonData/plugins/dd4hep/DDHGCalHEFileAlgo.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ struct HGCalHEFileAlgo {
8585
break;
8686
}
8787
}
88+
} else {
89+
firstLayer_ = 1;
8890
}
8991
#ifdef EDM_ML_DEBUG
9092
edm::LogVerbatim("HGCalGeom") << "There are " << layerType_.size() << " layers";
@@ -493,10 +495,14 @@ struct HGCalHEFileAlgo {
493495
#ifdef EDM_ML_DEBUG
494496
++ntot;
495497
#endif
496-
int type = HGCalWaferType::getType(HGCalWaferIndex::waferIndex(layer, u, v, false), waferIndex_, waferTypes_);
498+
int indx = HGCalWaferIndex::waferIndex((layer + firstLayer_), u, v, false);
499+
int type = HGCalWaferType::getType(indx, waferIndex_, waferTypes_);
497500
if (corner.first > 0 && type >= 0) {
498501
int copy = HGCalTypes::packTypeUV(type, u, v);
499502
#ifdef EDM_ML_DEBUG
503+
edm::LogVerbatim("HGCalGeom") << " DDHGCalHEFileAlgo: " << wafers_[type] << " number " << copy << " type "
504+
<< type << " layer:u:v:indx " << (layer + firstLayer_) << ":" << u << ":" << v
505+
<< ":" << indx;
500506
if (iu > ium)
501507
ium = iu;
502508
if (iv > ivm)

Geometry/HGCalCommonData/src/HGCalWaferType.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ int HGCalWaferType::getType(double xpos, double ypos, double zpos) {
104104
}
105105

106106
int HGCalWaferType::getType(int index, const std::vector<int>& indices, const std::vector<int>& types) {
107-
auto itr = static_cast<unsigned int>(std::find(std::begin(indices), std::end(indices), index) - std::begin(indices));
108-
int type = (itr < indices.size()) ? types[itr] : -1;
107+
auto itr = std::find(std::begin(indices), std::end(indices), index);
108+
int type = (itr == std::end(indices)) ? -1 : types[static_cast<unsigned int>(itr - std::begin(indices))];
109109
return type;
110110
}
111111

SimG4CMS/Calo/interface/CaloSD.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ class CaloSD : public SensitiveCaloDetector,
9797
virtual uint16_t getDepth(const G4Step*);
9898
double getResponseWt(const G4Track*);
9999
int getNumberOfHits();
100+
void ignoreRejection() { ignoreReject = true; }
100101

101102
inline void setParameterized(bool val) { isParameterized = val; }
102103
inline void setUseMap(bool val) { useMap = val; }
@@ -150,6 +151,7 @@ class CaloSD : public SensitiveCaloDetector,
150151

151152
bool ignoreTrackID;
152153
bool isParameterized;
154+
bool ignoreReject;
153155
bool useMap; // use map for comparison of ID
154156
bool corrTOFBeam;
155157

SimG4CMS/Calo/src/CaloSD.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ CaloSD::~CaloSD() {}
107107

108108
G4bool CaloSD::ProcessHits(G4Step* aStep, G4TouchableHistory*) {
109109
NaNTrap(aStep);
110+
ignoreReject = false;
110111

111112
#ifdef EDM_ML_DEBUG
112113
edm::LogVerbatim("CaloSim") << "CaloSD::" << GetName() << " ID= " << aStep->GetTrack()->GetTrackID()
@@ -141,7 +142,7 @@ G4bool CaloSD::ProcessHits(G4Step* aStep, G4TouchableHistory*) {
141142
if (unitID > 0) {
142143
currentID.setID(unitID, time, primaryID, depth);
143144
} else {
144-
if (aStep->GetTotalEnergyDeposit() > 0.0) {
145+
if (aStep->GetTotalEnergyDeposit() > 0.0 && (!ignoreReject)) {
145146
const G4TouchableHistory* touch = static_cast<const G4TouchableHistory*>(theTrack->GetTouchable());
146147
edm::LogVerbatim("CaloSim") << "CaloSD::ProcessHits: unitID= " << unitID << " currUnit= " << currentID.unitID()
147148
<< " Detector: " << GetName() << " trackID= " << theTrack->GetTrackID() << " "

SimG4CMS/Calo/src/HGCalNumberingScheme.cc

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
#include "SimG4CMS/Calo/interface/HGCalNumberingScheme.h"
66
#include "FWCore/MessageLogger/interface/MessageLogger.h"
77
#include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h"
8+
#include "DataFormats/ForwardDetId/interface/HGCSiliconDetId.h"
89
#include "Geometry/HGCalCommonData/interface/HGCalTypes.h"
10+
#include "Geometry/HGCalCommonData/interface/HGCalWaferIndex.h"
911
#include <iostream>
1012

1113
//#define EDM_ML_DEBUG
@@ -36,8 +38,7 @@ uint32_t HGCalNumberingScheme::getUnitID(int layer, int module, int cell, int iz
3638
<< HGCalGeometryMode::Hexagon8File << ":" << HGCalGeometryMode::Trapezoid << ":"
3739
<< HGCalGeometryMode::TrapezoidFile;
3840
#endif
39-
if ((mode_ == HGCalGeometryMode::Hexagon8Full) || (mode_ == HGCalGeometryMode::Hexagon8) ||
40-
(mode_ == HGCalGeometryMode::Hexagon8File)) {
41+
if (hgcons_.waferHexagon8()) {
4142
int cellU(0), cellV(0), waferType(-1), waferU(0), waferV(0);
4243
if (cell >= 0) {
4344
waferType = HGCalTypes::getUnpackedType(module);
@@ -50,6 +51,19 @@ uint32_t HGCalNumberingScheme::getUnitID(int layer, int module, int cell, int iz
5051
hgcons_.waferFromPosition(xx, pos.y(), layer, waferU, waferV, cellU, cellV, waferType, wt);
5152
}
5253
if (waferType >= 0) {
54+
if (mode_ == HGCalGeometryMode::Hexagon8File) {
55+
int type = hgcons_.waferType(layer, waferU, waferV, true);
56+
if (type != waferType) {
57+
#ifdef EDM_ML_DEBUG
58+
edm::LogVerbatim("HGCSim") << "HGCalNumberingScheme:: " << name_ << " Layer|u|v|Index|module|cell " << layer
59+
<< ":" << waferU << ":" << waferV << ":"
60+
<< HGCalWaferIndex::waferIndex(layer, waferU, waferV, false) << ":" << module
61+
<< ":" << cell << " has a type mismatch " << waferType << ":" << type;
62+
#endif
63+
if (type != HGCSiliconDetId::HGCalCoarseThick)
64+
waferType = type;
65+
}
66+
}
5367
index = HGCSiliconDetId(det_, iz, waferType, layer, waferU, waferV, cellU, cellV).rawId();
5468
#ifdef EDM_ML_DEBUG
5569
edm::LogVerbatim("HGCSim") << "OK WaferType " << waferType << " Wafer " << waferU << ":" << waferV << " Cell "
@@ -59,7 +73,7 @@ uint32_t HGCalNumberingScheme::getUnitID(int layer, int module, int cell, int iz
5973
<< waferV;
6074
#endif
6175
}
62-
} else if ((mode_ == HGCalGeometryMode::Trapezoid) || (mode_ == HGCalGeometryMode::TrapezoidFile)) {
76+
} else if (hgcons_.tileTrapezoid()) {
6377
std::array<int, 3> id = hgcons_.assignCellTrap(pos.x(), pos.y(), pos.z(), layer, false);
6478
if (id[2] >= 0) {
6579
index = HGCScintillatorDetId(id[2], layer, iz * id[0], id[1]).rawId();

SimG4CMS/Calo/src/HGCalSD.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,13 @@ bool HGCalSD::filterHit(CaloG4Hit* aHit, double time) {
225225
uint32_t HGCalSD::setDetUnitId(int layer, int module, int cell, int iz, G4ThreeVector& pos) {
226226
uint32_t id = numberingScheme_ ? numberingScheme_->getUnitID(layer, module, cell, iz, pos, weight_) : 0;
227227
if (cornerMinMask_ > 2) {
228-
if (hgcons_->maskCell(DetId(id), cornerMinMask_))
228+
if (hgcons_->maskCell(DetId(id), cornerMinMask_)) {
229229
id = 0;
230+
ignoreRejection();
231+
}
230232
}
233+
if ((geom_mode_ == HGCalGeometryMode::Hexagon8File) || (id == 0))
234+
ignoreRejection();
231235
return id;
232236
}
233237

SimG4CMS/Calo/test/python/runHGC4_cfg.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import FWCore.ParameterSet.Config as cms
2+
from Configuration.Eras.Era_Phase2C11_cff import Phase2C11
23

3-
process = cms.Process("PROD")
4+
process = cms.Process("PROD",Phase2C11)
45
process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi")
56
process.load("IOMC.EventVertexGenerators.VtxSmearedGauss_cfi")
6-
process.load("Configuration.Geometry.GeometryExtended2026D41_cff")
7-
#process.load("Geometry.HGCalCommonData.testHGCV10XML_cfi")
7+
process.load("Configuration.Geometry.GeometryExtended2026D62_cff")
8+
#process.load("Geometry.HGCalCommonData.testHGCalV14XML_cfi")
89
#process.load("Geometry.HGCalCommonData.hgcalParametersInitialization_cfi")
910
#process.load("Geometry.HGCalCommonData.hgcalNumberingInitialization_cfi")
1011
process.load("Configuration.StandardSequences.MagneticField_cff")

0 commit comments

Comments
 (0)