Skip to content

Commit a7e8572

Browse files
authored
Merge pull request #48699 from bsunanda/Phase2-hgx364
Phase2-hgx364 Take into account that the flat file information refers to z=-1 wafers
2 parents ad58b2c + 099d99c commit a7e8572

File tree

6 files changed

+45
-17
lines changed

6 files changed

+45
-17
lines changed

Geometry/HGCalCommonData/interface/HGCalDDDConstants.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ class HGCalDDDConstants {
149149
int numberCellsHexagon(int wafer) const;
150150
int numberCellsHexagon(int lay, int waferU, int waferV, bool flag) const;
151151
inline int partialWaferType(int lay, int waferU, int waferV) const {
152+
// Works for zside = -1
152153
int indx = HGCalWaferIndex::waferIndex(lay, waferU, waferV);
153154
auto ktr = hgpar_->waferInfoMap_.find(indx);
154155
int part = (ktr != hgpar_->waferInfoMap_.end()) ? (ktr->second).part : HGCalTypes::WaferFull;

Geometry/HGCalCommonData/src/HGCalDDDConstants.cc

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,8 @@ bool HGCalDDDConstants::cassetteShiftScintillator(int zside, int layer, int iphi
338338

339339
double HGCalDDDConstants::cellArea(const HGCSiliconDetId& id, bool reco) const {
340340
double area(0);
341-
int32_t indx = HGCalWaferIndex::waferIndex(id.layer(), id.waferU(), id.waferV());
341+
int waferU = (id.zside() > 0) ? -id.waferU() : id.waferU();
342+
int32_t indx = HGCalWaferIndex::waferIndex(id.layer(), waferU, id.waferV());
342343
auto ktr = hgpar_->waferInfoMap_.find(indx);
343344
if (ktr != hgpar_->waferInfoMap_.end()) {
344345
if (ktr->second.part == HGCalTypes::WaferFull) {
@@ -1150,15 +1151,15 @@ bool HGCalDDDConstants::maskCell(const DetId& detId, int corners) const {
11501151
HFNoseDetId id(detId);
11511152
N = getUVMax(id.type());
11521153
layer = id.layer();
1153-
waferU = id.waferU();
1154+
waferU = (id.zside() > 0) ? -id.waferU() : id.waferU();
11541155
waferV = id.waferV();
11551156
u = id.cellU();
11561157
v = id.cellV();
11571158
} else {
11581159
HGCSiliconDetId id(detId);
11591160
N = getUVMax(id.type());
11601161
layer = id.layer();
1161-
waferU = id.waferU();
1162+
waferU = (id.zside() > 0) ? -id.waferU() : id.waferU();
11621163
waferV = id.waferV();
11631164
u = id.cellU();
11641165
v = id.cellV();
@@ -1373,7 +1374,8 @@ int32_t HGCalDDDConstants::placementIndex(const HGCSiliconDetId& id) const {
13731374
int32_t place(0);
13741375
int32_t layer = id.layer();
13751376
int32_t layertype = layerType(layer);
1376-
int32_t indx = HGCalWaferIndex::waferIndex(layer, id.waferU(), id.waferV());
1377+
int32_t waferU = (id.zside() > 0) ? -id.waferU() : id.waferU();
1378+
int32_t indx = HGCalWaferIndex::waferIndex(layer, waferU, id.waferV());
13771379
auto ktr = hgpar_->waferInfoMap_.find(indx);
13781380
if (ktr != hgpar_->waferInfoMap_.end()) {
13791381
place = HGCalCell::cellPlacementIndex(id.zside(), layertype, (ktr->second).orient);
@@ -1788,7 +1790,8 @@ void HGCalDDDConstants::waferFromPosition(const double x,
17881790
if ((dx - rmax) <= tolc && (dy - hexside) <= tolc) {
17891791
if (((dy - 0.5 * hexside) <= tolc) || ((dx * tan30deg_ - (hexside - dy)) <= tolc)) {
17901792
if (waferHexagon8File()) {
1791-
int index = HGCalWaferIndex::waferIndex(layer, waferU, waferV);
1793+
int index = (zside > 0) ? HGCalWaferIndex::waferIndex(layer, -waferU, waferV)
1794+
: HGCalWaferIndex::waferIndex(layer, waferU, waferV);
17921795
celltype = HGCalWaferType::getType(index, hgpar_->waferInfoMap_);
17931796
if (debug)
17941797
edm::LogVerbatim("HGCalGeom")
@@ -1835,7 +1838,8 @@ void HGCalDDDConstants::waferFromPosition(const double x,
18351838
}
18361839
}
18371840
if (waferHexagon8File()) {
1838-
int index = HGCalWaferIndex::waferIndex(layer, waferU, waferV);
1841+
int index = (zside > 0) ? HGCalWaferIndex::waferIndex(layer, -waferU, waferV)
1842+
: HGCalWaferIndex::waferIndex(layer, waferU, waferV);
18391843
celltype = HGCalWaferType::getType(index, hgpar_->waferInfoMap_);
18401844
if (debug)
18411845
edm::LogVerbatim("HGCalGeom") << "Position (" << x << ", " << y << ") Wafer type:partial:orient:cassette "
@@ -1853,6 +1857,9 @@ void HGCalDDDConstants::waferFromPosition(const double x,
18531857
}
18541858
}
18551859
}
1860+
if (debug)
1861+
edm::LogVerbatim("HGCalGeomX") << "waferFromPosition: waferu " << waferU << ":" << hgpar_->waferUVMax_ << ":"
1862+
<< (std::abs(waferU) <= hgpar_->waferUVMax_) << " celltype " << celltype;
18561863
if ((std::abs(waferU) <= hgpar_->waferUVMax_) && (celltype >= 0)) {
18571864
int place(HGCalCell::cellPlacementOld), part(HGCalTypes::WaferFull);
18581865
if (cassetteMode()) {
@@ -1870,9 +1877,20 @@ void HGCalDDDConstants::waferFromPosition(const double x,
18701877
bool fineCoarse =
18711878
((celltype == HGCSiliconDetId::HGCalHD120) || (celltype == HGCSiliconDetId::HGCalHD200)) ? false : true;
18721879
cellHex(xx, yy, fineCoarse, place, part, cellU, cellV, extend, debug);
1880+
auto info = (zside > 0) ? waferInfo(layer, -waferU, waferV) : waferInfo(layer, waferU, waferV);
1881+
celltype = info.type;
18731882
wt = (((celltype == HGCSiliconDetId::HGCalHD120) && (hgpar_->useSimWt_ > 0))
18741883
? (hgpar_->cellThickness_[celltype] / hgpar_->waferThick_)
18751884
: 1.0);
1885+
if (debug) {
1886+
std::ostringstream st1;
1887+
st1 << hgpar_->cellThickness_.size() << " CellThickneses";
1888+
for (unsigned j = 0; j < hgpar_->cellThickness_.size(); ++j)
1889+
st1 << ": " << hgpar_->cellThickness_[j];
1890+
edm::LogVerbatim("HGCalGeomX") << "waferfFromPosition: celltype " << celltype << " Layer " << layer << " Wafer "
1891+
<< waferU << ":" << waferV << " having " << st1.str() << " SimWt "
1892+
<< hgpar_->useSimWt_ << " waferThick " << hgpar_->waferThick_ << " wt " << wt;
1893+
}
18761894
} else {
18771895
cellU = cellV = 2 * hgpar_->nCellsFine_;
18781896
wt = 1.0;
@@ -2058,12 +2076,12 @@ int HGCalDDDConstants::waferType(DetId const& id, bool fromFile) const {
20582076
if (id.det() != DetId::Forward) {
20592077
HGCSiliconDetId hid(id);
20602078
layer = hid.layer();
2061-
waferU = hid.waferU();
2079+
waferU = (hid.zside() > 0) ? -hid.waferU() : hid.waferU();
20622080
waferV = hid.waferV();
20632081
} else {
20642082
HFNoseDetId hid(id);
20652083
layer = hid.layer();
2066-
waferU = hid.waferU();
2084+
waferU = (hid.zside() > 0) ? -hid.waferU() : hid.waferU();
20672085
waferV = hid.waferV();
20682086
}
20692087
auto itr = hgpar_->waferInfoMap_.find(HGCalWaferIndex::waferIndex(layer, waferU, waferV));
@@ -2098,7 +2116,8 @@ int HGCalDDDConstants::waferType(int layer, int waferU, int waferV, bool fromFil
20982116
}
20992117

21002118
std::tuple<int, int, int> HGCalDDDConstants::waferType(HGCSiliconDetId const& id, bool fromFile) const {
2101-
const auto& index = HGCalWaferIndex::waferIndex(id.layer(), id.waferU(), id.waferV());
2119+
int waferU = (id.zside() > 0) ? -id.waferU() : id.waferU();
2120+
const auto& index = HGCalWaferIndex::waferIndex(id.layer(), waferU, id.waferV());
21022121
int type(-1), part(-1), orient(-1);
21032122
if (fromFile && (waferFileSize() > 0)) {
21042123
auto itr = hgpar_->waferInfoMap_.find(index);

Geometry/HGCalCommonData/test/HGCalWaferIDTester.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ void HGCalWaferIDTester::analyze(const edm::Event& iEvent, const edm::EventSetup
144144
double wt(0);
145145
int layer = detIds_[k].layer();
146146
int zside = detIds_[k].zside();
147-
int indx = HGCalWaferIndex::waferIndex(layer, detIds_[k].waferU(), detIds_[k].waferV());
147+
waferU = (zside > 0) ? -detIds_[k].waferU() : detIds_[k].waferU();
148+
int indx = HGCalWaferIndex::waferIndex(layer, waferU, detIds_[k].waferV());
148149
st1 << " Part:Orient:Cassette:Shift " << std::get<1>(hgdc.waferFileInfo(indx)) << ":"
149150
<< std::get<2>(hgdc.waferFileInfo(indx)) << ":" << std::get<3>(hgdc.waferFileInfo(indx)) << ":"
150151
<< hgdc.cassetteShiftSilicon(zside, layer, detIds_[k].waferU(), detIds_[k].waferV());
@@ -172,7 +173,7 @@ void HGCalWaferIDTester::analyze(const edm::Event& iEvent, const edm::EventSetup
172173
if (diff > tol)
173174
st1 << " ***** CheckID *****";
174175
bool valid1 = hgdc.isValidHex8(
175-
detIds_[k].layer(), detIds_[k].waferU(), detIds_[k].waferV(), detIds_[k].cellU(), detIds_[k].cellV(), true);
176+
detIds_[k].layer(), waferU, detIds_[k].waferV(), detIds_[k].cellU(), detIds_[k].cellV(), true);
176177
bool valid2 = hgdc.isValidHex8(id.layer(), id.waferU(), id.waferV(), id.cellU(), id.cellV(), true);
177178
st1 << " Validity flag: " << valid1 << ":" << valid2;
178179
if ((!valid1) || (!valid2))

Geometry/HGCalGeometry/test/HGCalWaferInfo.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,9 @@ void HGCalWaferInfo::analyze(const edm::Event& iEvent, const edm::EventSetup& iS
8080
for (auto const& id : ids) {
8181
if ((id.det() == DetId::HGCalEE) || (id.det() == DetId::HGCalHSi)) {
8282
HGCSiliconDetId detId(id);
83+
int waferU = (detId.zside() > 0) ? -detId.waferU() : detId.waferU();
8384
HGCalParameters::waferInfo info =
84-
geom->topology().dddConstants().waferInfo(detId.layer(), detId.waferU(), detId.waferV());
85+
geom->topology().dddConstants().waferInfo(detId.layer(), waferU, detId.waferV());
8586
edm::LogVerbatim("HGCalGeom") << "ID: " << detId << " Type " << info.type << ":" << types[info.type] << " Part "
8687
<< info.part << ":" << parts[info.part] << " Orient " << info.orient
8788
<< " placement " << geom->topology().dddConstants().placementIndex(detId)

Geometry/HGCalGeometry/test/HGCalWaferSimWt.cc

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ class HGCalWaferSimWt : public edm::one::EDAnalyzer<> {
2424

2525
private:
2626
const std::vector<std::string> names_;
27+
const bool debug_;
2728
std::vector<edm::ESGetToken<HGCalGeometry, IdealGeometryRecord>> geomTokens_;
2829
};
2930

3031
HGCalWaferSimWt::HGCalWaferSimWt(const edm::ParameterSet& iC)
31-
: names_(iC.getParameter<std::vector<std::string>>("detectorNames")) {
32+
: names_(iC.getParameter<std::vector<std::string>>("detectorNames")), debug_(iC.getParameter<bool>("debug")) {
3233
for (unsigned int k = 0; k < names_.size(); ++k) {
3334
edm::LogVerbatim("HGCalGeomX") << "Study detector [" << k << "] " << names_[k] << std::endl;
3435
geomTokens_.emplace_back(esConsumes<HGCalGeometry, IdealGeometryRecord>(edm::ESInputTag{"", names_[k]}));
@@ -39,6 +40,7 @@ void HGCalWaferSimWt::fillDescriptions(edm::ConfigurationDescriptions& descripti
3940
edm::ParameterSetDescription desc;
4041
std::vector<std::string> names = {"HGCalEESensitive", "HGCalHESiliconSensitive"};
4142
desc.add<std::vector<std::string>>("detectorNames", names);
43+
desc.add<bool>("debug", false);
4244
descriptions.add("hgcalWaferSimWt", desc);
4345
}
4446

@@ -57,18 +59,21 @@ void HGCalWaferSimWt::analyze(const edm::Event& /*iEvent*/, const edm::EventSetu
5759
std::vector<int> idxs;
5860
for (auto id : ids) {
5961
++nall;
60-
auto cell = geom->getGeometry(id);
6162
HGCSiliconDetId hid(id);
63+
auto cell = geom->getPosition(hid, false);
6264
int type = hid.type();
63-
int part = geom->topology().dddConstants().partialWaferType(hid.layer(), hid.waferU(), hid.waferV());
65+
int waferU = (hid.zside() > 0) ? -hid.waferU() : hid.waferU();
66+
int part = geom->topology().dddConstants().partialWaferType(hid.layer(), waferU, hid.waferV());
6467
int idx = part * 10 + type;
6568
if (std::find(idxs.begin(), idxs.end(), idx) == idxs.end()) {
6669
++ntypes;
6770
idxs.push_back(idx);
68-
double xpos = 10.0 * (cell->getPosition().x());
69-
double ypos = 10.0 * (cell->getPosition().y());
71+
double xpos = 10.0 * (cell.x());
72+
double ypos = 10.0 * (cell.y());
7073
int waferU, waferV, cellU, cellV, cellType;
7174
double wt;
75+
if (debug_)
76+
edm::LogVerbatim("HGCalGeomX") << hid << " at (" << xpos << ", " << ypos << ")";
7277
geom->topology().dddConstants().waferFromPosition(
7378
xpos, ypos, hid.zside(), hid.layer(), waferU, waferV, cellU, cellV, cellType, wt, false, true);
7479
std::string stype = (type >= 0 && type <= 3) ? detType[type] : ("JK" + std::to_string(type));

Geometry/HGCalGeometry/test/python/testHGCalWaferSimWt_cfg.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,6 @@
5454
input = cms.untracked.int32(1)
5555
)
5656
process.Timing = cms.Service("Timing")
57+
process.hgcalWaferSimWt.debug = True
5758

5859
process.p1 = cms.Path(process.hgcalWaferSimWt)

0 commit comments

Comments
 (0)