Skip to content

Commit 3af362a

Browse files
authored
Merge pull request cms-sw#31876 from bsunanda/Run4-hgx265
Run4-hgx265 Update tests for ESGetToken and also for checking content in geometry
2 parents cd8087b + 5ef8093 commit 3af362a

File tree

3 files changed

+59
-33
lines changed

3 files changed

+59
-33
lines changed

Geometry/HGCalGeometry/test/HGCGeomAnalyzer.cc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,18 @@ class HGCGeomAnalyzer : public edm::one::EDAnalyzer<edm::one::SharedResources> {
5353

5454
// ----------member data ---------------------------
5555
edm::Service<TFileService> fs_;
56-
std::string txtFileName_;
56+
const std::string txtFileName_;
57+
edm::ESGetToken<CaloGeometry, CaloGeometryRecord> geomToken_;
58+
5759
std::map<std::pair<DetId::Detector, int>, TProfile2D *> layerXYview_;
5860
std::map<std::pair<DetId::Detector, int>, TProfile *> layerThickR_;
5961
std::map<std::pair<DetId::Detector, int>, TProfile *> layerThickEta_;
6062
};
6163

6264
//
6365
HGCGeomAnalyzer::HGCGeomAnalyzer(const edm::ParameterSet &iConfig)
64-
: txtFileName_(iConfig.getParameter<std::string>("fileName")) {
66+
: txtFileName_(iConfig.getParameter<std::string>("fileName")),
67+
geomToken_{esConsumes<CaloGeometry, CaloGeometryRecord>()} {
6568
usesResource("TFileService");
6669
fs_->file().cd();
6770
}
@@ -76,13 +79,12 @@ void HGCGeomAnalyzer::analyze(const edm::Event &iEvent, const edm::EventSetup &e
7679
boundaries.open(txtFileName_);
7780

7881
//get geometry
79-
edm::ESHandle<CaloGeometry> geomhandle;
80-
es.get<CaloGeometryRecord>().get(geomhandle);
82+
const CaloGeometry *caloGeom = &es.getData(geomToken_);
8183

8284
std::vector<DetId::Detector> dets = {DetId::HGCalEE, DetId::HGCalHSi, DetId::HGCalHSc};
8385
for (const auto &d : dets) {
8486
const HGCalGeometry *geom =
85-
static_cast<const HGCalGeometry *>(geomhandle->getSubdetectorGeometry(d, ForwardSubdetector::ForwardEmpty));
87+
static_cast<const HGCalGeometry *>(caloGeom->getSubdetectorGeometry(d, ForwardSubdetector::ForwardEmpty));
8688
const HGCalTopology *topo = &(geom->topology());
8789
const HGCalDDDConstants *ddd = &(topo->dddConstants());
8890

Geometry/HGCalGeometry/test/HGCalGeomLocatorTester.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ HGCalGeomLocaterTester::HGCalGeomLocaterTester(const edm::ParameterSet& iC)
3333
geomToken_{esConsumes<HGCalGeometry, IdealGeometryRecord>(edm::ESInputTag{"", name_})} {}
3434

3535
void HGCalGeomLocaterTester::analyze(const edm::Event&, const edm::EventSetup& iSetup) {
36-
const auto& geomR = iSetup.getData(geomToken_);
37-
const HGCalGeometry* geom = &geomR;
36+
const HGCalGeometry* geom = &iSetup.getData(geomToken_);
3837
if (geom->topology().waferHexagon8()) {
3938
DetId::Detector det;
4039
if (name_ == "HGCalHESiliconSensitive")

Geometry/HGCalGeometry/test/HGCalWaferInFileTest.cc

Lines changed: 51 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class HGCalWaferInFileTest : public edm::one::EDAnalyzer<> {
5252
private:
5353
std::vector<std::string> getPoints(
5454
double xpos, double ypos, double delX, double delY, double rin, double rout, int lay, int waferU, int waferV);
55+
std::vector<double> getCorners(double xpos, double ypos, double delX, double delY);
5556
const std::string nameSense_, nameDetector_;
5657
const int verbosity_;
5758
const edm::ESGetToken<HGCalGeometry, IdealGeometryRecord> geomToken_;
@@ -104,12 +105,16 @@ void HGCalWaferInFileTest::analyze(const edm::Event& iEvent, const edm::EventSet
104105
const auto& xy = hgdc.waferPosition(layer, waferU, waferV, true, true);
105106
const auto& rr = hgdc.rangeRLayer(layer, true);
106107
auto points = getPoints(xy.first, xy.second, delX, delY, rr.first, rr.second, layer, waferU, waferV);
108+
auto rpos = getCorners(xy.first, xy.second, delX, delY);
107109
std::cout << "ID[" << k << "]: (" << (hgdc.getLayerOffset() + layer) << ", " << waferU << ", " << waferV << ", "
108110
<< typex << ") at (" << std::setprecision(4) << xy.first << ", " << xy.second << ", "
109111
<< hgdc.waferZ(layer, true) << ") not present with " << points.size() << " points:";
110112
for (auto point : points)
111113
std::cout << " " << point;
112-
std::cout << " in the region " << rr.first << ":" << rr.second << std::endl;
114+
std::cout << " in the region " << rr.first << ":" << rr.second << " Corners";
115+
for (auto point : rpos)
116+
std::cout << " " << point;
117+
std::cout << std::endl;
113118
++bad1;
114119
if ((layer - layerf) < layers)
115120
++miss[layer - layerf];
@@ -169,7 +174,7 @@ void HGCalWaferInFileTest::analyze(const edm::Event& iEvent, const edm::EventSet
169174
int rotn2 = hgdc.waferTypeRotation(id.layer(), id.waferU(), id.waferV(), false, false).second;
170175
bool partOK = ((part1 == part2) || ((part1 == HGCalTypes::WaferFull) && (part2 == HGCalTypes::WaferOut)));
171176
bool rotnOK = ((rotn1 == rotn2) || (part1 == HGCalTypes::WaferFull) || (part2 == HGCalTypes::WaferFull));
172-
bool partOK2 = ((part1 > part2) || partOK);
177+
bool partOK2 = (partOK) || (part2 < part1);
173178
if (!partOK) {
174179
++badP;
175180
if ((layer - layerf) < layers)
@@ -187,19 +192,25 @@ void HGCalWaferInFileTest::analyze(const edm::Event& iEvent, const edm::EventSet
187192
}
188193
if ((!partOK) || (!rotnOK)) {
189194
++badG;
190-
std::string partx1 = (part1 < static_cast<int>(types.size())) ? types[part1] : "X";
191-
std::string partx2 = (part2 < static_cast<int>(types.size())) ? types[part2] : "X";
192-
const auto& xy = hgdc.waferPosition(layer, waferU, waferV, true, false);
193-
const auto& rr = hgdc.rangeRLayer(layer, true);
194-
auto points = getPoints(xy.first, xy.second, delX, delY, rr.first, rr.second, layer, waferU, waferV);
195-
std::cout << "ID[" << k << "]: (" << (hgdc.getLayerOffset() + layer) << ", " << waferU << ", " << waferV
196-
<< "," << type2 << ", " << partx1 << ":" << partx2 << ":" << part1 << ":" << part2 << ", " << rotn1
197-
<< ":" << rotn2 << ", " << partOK2 << ") at (" << std::setprecision(4) << xy.first << ", "
198-
<< xy.second << ", " << hgdc.waferZ(layer, true) << ") failure flag " << partOK << ":" << rotnOK
199-
<< " with " << points.size() << " points:";
200-
for (auto point : points)
201-
std::cout << " " << point;
202-
std::cout << " in the region " << rr.first << ":" << rr.second << std::endl;
195+
if ((verbosity_ > 0) || (!partOK2)) {
196+
std::string partx1 = (part1 < static_cast<int>(types.size())) ? types[part1] : "X";
197+
std::string partx2 = (part2 < static_cast<int>(types.size())) ? types[part2] : "X";
198+
const auto& xy = hgdc.waferPosition(layer, waferU, waferV, true, false);
199+
const auto& rr = hgdc.rangeRLayer(layer, true);
200+
auto points = getPoints(xy.first, xy.second, delX, delY, rr.first, rr.second, layer, waferU, waferV);
201+
auto rpos = getCorners(xy.first, xy.second, delX, delY);
202+
std::cout << "ID[" << k << "]: (" << (hgdc.getLayerOffset() + layer) << ", " << waferU << ", " << waferV
203+
<< "," << type2 << ", " << partx1 << ":" << partx2 << ":" << part1 << ":" << part2 << ", "
204+
<< rotn1 << ":" << rotn2 << ") at (" << std::setprecision(4) << xy.first << ", " << xy.second
205+
<< ", " << hgdc.waferZ(layer, true) << ") failure flag " << partOK << ":" << rotnOK << " with "
206+
<< points.size() << " points:";
207+
for (auto point : points)
208+
std::cout << " " << point;
209+
std::cout << " in the region " << rr.first << ":" << rr.second << " Corners";
210+
for (auto point : rpos)
211+
std::cout << " " << point;
212+
std::cout << std::endl;
213+
}
203214
}
204215
}
205216
}
@@ -236,14 +247,14 @@ std::vector<std::string> HGCalWaferInFileTest::getPoints(
236247
iok *= base;
237248
}
238249
}
239-
if (verbosity_ > 0)
250+
if (verbosity_ > 1)
240251
std::cout << "I/p " << layer << ":" << waferU << ":" << waferV << ":" << xpos << ":" << ypos << ":" << delX << ":"
241252
<< delY << ":" << rin << ":" << rout << " Corners " << ncor << " iok " << iok << std::endl;
242253

243254
static const int parts = 3;
244255
static const std::string c1[parts] = {"A1", "A2", "A3"};
245-
double dx1[parts] = {0.25 * delX, 0.50 * delX, 0.75 * delX};
246-
double dy1[parts] = {-0.875 * delY, -0.75 * delY, -0.625 * delY};
256+
double dx1[parts] = {0.225 * delX, 0.50 * delX, 0.775 * delX};
257+
double dy1[parts] = {-0.8875 * delY, -0.75 * delY, -0.6125 * delY};
247258
if ((((iok / 10000) % 10) == 1) && (((iok / 100000) % 10) == 0)) {
248259
for (int k = 0; k < parts; ++k) {
249260
double xc1 = xpos + dx1[k];
@@ -270,7 +281,7 @@ std::vector<std::string> HGCalWaferInFileTest::getPoints(
270281

271282
static const std::string c2[parts] = {"B1", "B2", "B3"};
272283
double dx2[parts] = {delX, delX, delX};
273-
double dy2[parts] = {-0.5 * delY, 0.0, 0.5 * delY};
284+
double dy2[parts] = {-0.275 * delY, 0.0, 0.275 * delY};
274285
if ((((iok / 1000) % 10) == 1) && (((iok / 10000) % 10) == 0)) {
275286
for (int k = 0; k < parts; ++k) {
276287
double xc1 = xpos + dx2[k];
@@ -296,8 +307,8 @@ std::vector<std::string> HGCalWaferInFileTest::getPoints(
296307
}
297308

298309
static const std::string c3[parts] = {"C1", "C2", "C3"};
299-
double dx3[parts] = {0.75 * delX, 0.50 * delX, 0.25 * delX};
300-
double dy3[parts] = {0.625 * delY, 0.75 * delY, 0.875 * delY};
310+
double dx3[parts] = {0.775 * delX, 0.50 * delX, 0.225 * delX};
311+
double dy3[parts] = {0.6125 * delY, 0.75 * delY, 0.8875 * delY};
301312
if ((((iok / 100) % 10) == 1) && (((iok / 1000) % 10) == 0)) {
302313
for (int k = 0; k < parts; ++k) {
303314
double xc1 = xpos + dx3[k];
@@ -323,8 +334,8 @@ std::vector<std::string> HGCalWaferInFileTest::getPoints(
323334
}
324335

325336
static const std::string c4[parts] = {"D1", "D2", "D3"};
326-
double dx4[parts] = {-0.25 * delX, -0.50 * delX, -0.75 * delX};
327-
double dy4[parts] = {0.875 * delY, 0.75 * delY, 0.625 * delY};
337+
double dx4[parts] = {-0.225 * delX, -0.50 * delX, -0.775 * delX};
338+
double dy4[parts] = {0.8875 * delY, 0.75 * delY, 0.6125 * delY};
328339
if ((((iok / 10) % 10) == 1) && (((iok / 100) % 10) == 0)) {
329340
for (int k = 0; k < parts; ++k) {
330341
double xc1 = xpos + dx4[k];
@@ -351,7 +362,7 @@ std::vector<std::string> HGCalWaferInFileTest::getPoints(
351362

352363
static const std::string c5[parts] = {"E1", "E2", "E3"};
353364
double dx5[parts] = {-delX, -delX, -delX};
354-
double dy5[parts] = {0.5 * delY, 0.0, -0.5 * delY};
365+
double dy5[parts] = {0.275 * delY, 0.0, -0.275 * delY};
355366
if ((((iok / 1) % 10) == 1) && (((iok / 10) % 10) == 0)) {
356367
for (int k = 0; k < parts; ++k) {
357368
double xc1 = xpos + dx5[k];
@@ -377,8 +388,8 @@ std::vector<std::string> HGCalWaferInFileTest::getPoints(
377388
}
378389

379390
static const std::string c6[parts] = {"F1", "F2", "F3"};
380-
double dx6[parts] = {-0.75 * delX, -0.50 * delX, -0.25 * delX};
381-
double dy6[parts] = {-0.625 * delY, -0.75 * delY, -0.875 * delY};
391+
double dx6[parts] = {-0.775 * delX, -0.50 * delX, -0.225 * delX};
392+
double dy6[parts] = {-0.6125 * delY, -0.75 * delY, -0.8875 * delY};
382393
if ((((iok / 100000) % 10) == 1) && (((iok / 1) % 10) == 0)) {
383394
for (int k = 0; k < parts; ++k) {
384395
double xc1 = xpos + dx6[k];
@@ -406,5 +417,19 @@ std::vector<std::string> HGCalWaferInFileTest::getPoints(
406417
return points;
407418
}
408419

420+
std::vector<double> HGCalWaferInFileTest::getCorners(double xpos, double ypos, double delX, double delY) {
421+
std::vector<double> points;
422+
static const int corners = 6;
423+
double dx0[corners] = {0.0, delX, delX, 0.0, -delX, -delX};
424+
double dy0[corners] = {-delY, -0.5 * delY, 0.5 * delY, delY, 0.5 * delY, -0.5 * delY};
425+
for (int k = 0; k < corners; ++k) {
426+
double xc = xpos + dx0[k];
427+
double yc = ypos + dy0[k];
428+
double rpos = sqrt(xc * xc + yc * yc);
429+
points.emplace_back(rpos);
430+
}
431+
return points;
432+
}
433+
409434
// define this as a plug-in
410435
DEFINE_FWK_MODULE(HGCalWaferInFileTest);

0 commit comments

Comments
 (0)