Skip to content

Commit 6b7cf86

Browse files
authored
Merge pull request cms-sw#31983 from ghugo83/fix_preshower_minusZ
Mini-PR: Fix Z side in Preshower
2 parents 8a7e27c + de23b83 commit 6b7cf86

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

Geometry/EcalCommonData/src/EcalPreshowerNumberingScheme.cc

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,15 @@ EcalPreshowerNumberingScheme::~EcalPreshowerNumberingScheme() {
9090
edm::LogVerbatim("EcalGeom") << "Deleting EcalPreshowerNumberingScheme";
9191
}
9292

93+
/*
94+
* Compute the Ecal Preshower DetId.
95+
* General NB: if possible, it would be way better to just access the DetID from a hash map from G4 Volume,
96+
* rather than recomputing it for each SimHit - see Tracker.
97+
*/
9398
uint32_t EcalPreshowerNumberingScheme::getUnitID(const EcalBaseNumber& baseNumber) const {
94-
int level = baseNumber.getLevels();
99+
const int numberOfHierarchyLevels = baseNumber.getLevels();
95100
uint32_t intIndex = 0;
96-
if (level > 0) {
101+
if (numberOfHierarchyLevels > 0) {
97102
// depth index - silicon layer 1-st or 2-nd
98103
int layer = 0;
99104
if (baseNumber.getLevelName(0).find("SFSX") != std::string::npos) {
@@ -105,18 +110,25 @@ uint32_t EcalPreshowerNumberingScheme::getUnitID(const EcalBaseNumber& baseNumbe
105110
<< " of Presh. Si. Strip : " << baseNumber.getLevelName(0);
106111
}
107112

113+
// Access different hierarchy levels
114+
static constexpr int stripHierachyLevel = 0;
115+
static constexpr int boxHierachyLevel = 2;
116+
static constexpr int ladderHierachyLevel = 3;
117+
static constexpr int regionHierachyLevel = 5;
118+
108119
// Z index +Z = 1 ; -Z = 2
109-
int zs = baseNumber.getCopyNumber("EREG");
120+
121+
int zs = baseNumber.getCopyNumber(regionHierachyLevel);
110122
int zside = 2 * (1 - zs) + 1;
111123

112124
// box number
113-
int box = baseNumber.getCopyNumber(2);
125+
int box = baseNumber.getCopyNumber(boxHierachyLevel);
114126

115127
int x = 0, y = 0, ix, iy, id;
116128
int mapX[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
117129
int mapY[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
118130
const std::string& ladd = baseNumber.getLevelName(3).substr(0, 6);
119-
int ladd_copy = baseNumber.getCopyNumber(3);
131+
int ladd_copy = baseNumber.getCopyNumber(ladderHierachyLevel);
120132

121133
if (ladd == "SFLX0a" || ladd == "SFLY0a") {
122134
mapX[5] = mapX[6] = mapX[7] = mapX[8] = mapX[9] = 1;
@@ -397,7 +409,7 @@ uint32_t EcalPreshowerNumberingScheme::getUnitID(const EcalBaseNumber& baseNumbe
397409
}
398410

399411
// strip number inside wafer
400-
int strip = baseNumber.getCopyNumber(0);
412+
int strip = baseNumber.getCopyNumber(stripHierachyLevel);
401413

402414
if (layer == 1) {
403415
if (zside > 0 && y <= 20)
@@ -419,7 +431,7 @@ uint32_t EcalPreshowerNumberingScheme::getUnitID(const EcalBaseNumber& baseNumbe
419431
<< " layer " << layer << " strip " << strip << " UnitID 0x" << std::hex << intIndex
420432
<< std::dec;
421433

422-
for (int ich = 0; ich < level; ich++)
434+
for (int ich = 0; ich < numberOfHierarchyLevels; ich++)
423435
edm::LogVerbatim("EcalGeom") << "Name = " << baseNumber.getLevelName(ich)
424436
<< " copy = " << baseNumber.getCopyNumber(ich);
425437
#endif

0 commit comments

Comments
 (0)