Skip to content

Commit 3688ce9

Browse files
author
Sunanda
committed
Take into account that the flat file information refers to z=-1 wafers
1 parent ef9550b commit 3688ce9

File tree

6 files changed

+41
-17
lines changed

6 files changed

+41
-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: 23 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,7 @@ 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) : HGCalWaferIndex::waferIndex(layer, waferU, waferV);
17921794
celltype = HGCalWaferType::getType(index, hgpar_->waferInfoMap_);
17931795
if (debug)
17941796
edm::LogVerbatim("HGCalGeom")
@@ -1835,7 +1837,7 @@ void HGCalDDDConstants::waferFromPosition(const double x,
18351837
}
18361838
}
18371839
if (waferHexagon8File()) {
1838-
int index = HGCalWaferIndex::waferIndex(layer, waferU, waferV);
1840+
int index = (zside > 0) ? HGCalWaferIndex::waferIndex(layer, -waferU, waferV) : HGCalWaferIndex::waferIndex(layer, waferU, waferV);
18391841
celltype = HGCalWaferType::getType(index, hgpar_->waferInfoMap_);
18401842
if (debug)
18411843
edm::LogVerbatim("HGCalGeom") << "Position (" << x << ", " << y << ") Wafer type:partial:orient:cassette "
@@ -1853,6 +1855,8 @@ void HGCalDDDConstants::waferFromPosition(const double x,
18531855
}
18541856
}
18551857
}
1858+
if (debug)
1859+
edm::LogVerbatim("HGCalGeomX") << "waferFromPosition: waferu " << waferU << ":" << hgpar_->waferUVMax_ << ":" << (std::abs(waferU) <= hgpar_->waferUVMax_) << " celltype " << celltype;
18561860
if ((std::abs(waferU) <= hgpar_->waferUVMax_) && (celltype >= 0)) {
18571861
int place(HGCalCell::cellPlacementOld), part(HGCalTypes::WaferFull);
18581862
if (cassetteMode()) {
@@ -1870,9 +1874,18 @@ void HGCalDDDConstants::waferFromPosition(const double x,
18701874
bool fineCoarse =
18711875
((celltype == HGCSiliconDetId::HGCalHD120) || (celltype == HGCSiliconDetId::HGCalHD200)) ? false : true;
18721876
cellHex(xx, yy, fineCoarse, place, part, cellU, cellV, extend, debug);
1877+
auto info = (zside > 0) ? waferInfo(layer, -waferU, waferV) : waferInfo(layer, waferU, waferV);
1878+
celltype = info.type;
18731879
wt = (((celltype == HGCSiliconDetId::HGCalHD120) && (hgpar_->useSimWt_ > 0))
18741880
? (hgpar_->cellThickness_[celltype] / hgpar_->waferThick_)
18751881
: 1.0);
1882+
if (debug) {
1883+
std::ostringstream st1;
1884+
st1 << hgpar_->cellThickness_.size() << " CellThickneses";
1885+
for (unsigned j = 0; j < hgpar_->cellThickness_.size(); ++j)
1886+
st1 << ": " << hgpar_->cellThickness_[j];
1887+
edm::LogVerbatim("HGCalGeomX") << "waferfFromPosition: celltype " << celltype << " Layer " << layer << " Wafer " << waferU << ":" << waferV << " having " << st1.str() << " SimWt " << hgpar_->useSimWt_ << " waferThick "<< hgpar_->waferThick_ << " wt " << wt;
1888+
}
18761889
} else {
18771890
cellU = cellV = 2 * hgpar_->nCellsFine_;
18781891
wt = 1.0;
@@ -2058,12 +2071,12 @@ int HGCalDDDConstants::waferType(DetId const& id, bool fromFile) const {
20582071
if (id.det() != DetId::Forward) {
20592072
HGCSiliconDetId hid(id);
20602073
layer = hid.layer();
2061-
waferU = hid.waferU();
2074+
waferU = (hid.zside() > 0) ? -hid.waferU() : hid.waferU();
20622075
waferV = hid.waferV();
20632076
} else {
20642077
HFNoseDetId hid(id);
20652078
layer = hid.layer();
2066-
waferU = hid.waferU();
2079+
waferU = (hid.zside() > 0) ? -hid.waferU() : hid.waferU();
20672080
waferV = hid.waferV();
20682081
}
20692082
auto itr = hgpar_->waferInfoMap_.find(HGCalWaferIndex::waferIndex(layer, waferU, waferV));
@@ -2098,7 +2111,8 @@ int HGCalDDDConstants::waferType(int layer, int waferU, int waferV, bool fromFil
20982111
}
20992112

21002113
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());
2114+
int waferU = (id.zside() > 0) ? -id.waferU() : id.waferU();
2115+
const auto& index = HGCalWaferIndex::waferIndex(id.layer(), waferU, id.waferV());
21022116
int type(-1), part(-1), orient(-1);
21032117
if (fromFile && (waferFileSize() > 0)) {
21042118
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: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ 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")),
33+
debug_(iC.getParameter<bool>("debug")) {
3234
for (unsigned int k = 0; k < names_.size(); ++k) {
3335
edm::LogVerbatim("HGCalGeomX") << "Study detector [" << k << "] " << names_[k] << std::endl;
3436
geomTokens_.emplace_back(esConsumes<HGCalGeometry, IdealGeometryRecord>(edm::ESInputTag{"", names_[k]}));
@@ -39,6 +41,7 @@ void HGCalWaferSimWt::fillDescriptions(edm::ConfigurationDescriptions& descripti
3941
edm::ParameterSetDescription desc;
4042
std::vector<std::string> names = {"HGCalEESensitive", "HGCalHESiliconSensitive"};
4143
desc.add<std::vector<std::string>>("detectorNames", names);
44+
desc.add<bool>("debug", false);
4245
descriptions.add("hgcalWaferSimWt", desc);
4346
}
4447

@@ -57,18 +60,21 @@ void HGCalWaferSimWt::analyze(const edm::Event& /*iEvent*/, const edm::EventSetu
5760
std::vector<int> idxs;
5861
for (auto id : ids) {
5962
++nall;
60-
auto cell = geom->getGeometry(id);
6163
HGCSiliconDetId hid(id);
64+
auto cell = geom->getPosition(hid, false);
6265
int type = hid.type();
63-
int part = geom->topology().dddConstants().partialWaferType(hid.layer(), hid.waferU(), hid.waferV());
66+
int waferU = (hid.zside() > 0) ? -hid.waferU() : hid.waferU();
67+
int part = geom->topology().dddConstants().partialWaferType(hid.layer(), waferU, hid.waferV());
6468
int idx = part * 10 + type;
6569
if (std::find(idxs.begin(), idxs.end(), idx) == idxs.end()) {
6670
++ntypes;
6771
idxs.push_back(idx);
68-
double xpos = 10.0 * (cell->getPosition().x());
69-
double ypos = 10.0 * (cell->getPosition().y());
72+
double xpos = 10.0 * (cell.x());
73+
double ypos = 10.0 * (cell.y());
7074
int waferU, waferV, cellU, cellV, cellType;
7175
double wt;
76+
if (debug_)
77+
edm::LogVerbatim("HGCalGeomX") << hid << " at (" << xpos << ", " << ypos << ")";
7278
geom->topology().dddConstants().waferFromPosition(
7379
xpos, ypos, hid.zside(), hid.layer(), waferU, waferV, cellU, cellV, cellType, wt, false, true);
7480
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)