Skip to content

Commit

Permalink
Merge pull request #31876 from bsunanda/Run4-hgx265
Browse files Browse the repository at this point in the history
Run4-hgx265 Update tests for ESGetToken and also for checking content in geometry
  • Loading branch information
cmsbuild committed Oct 21, 2020
2 parents cd8087b + 5ef8093 commit 3af362a
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 33 deletions.
12 changes: 7 additions & 5 deletions Geometry/HGCalGeometry/test/HGCGeomAnalyzer.cc
Expand Up @@ -53,15 +53,18 @@ class HGCGeomAnalyzer : public edm::one::EDAnalyzer<edm::one::SharedResources> {

// ----------member data ---------------------------
edm::Service<TFileService> fs_;
std::string txtFileName_;
const std::string txtFileName_;
edm::ESGetToken<CaloGeometry, CaloGeometryRecord> geomToken_;

std::map<std::pair<DetId::Detector, int>, TProfile2D *> layerXYview_;
std::map<std::pair<DetId::Detector, int>, TProfile *> layerThickR_;
std::map<std::pair<DetId::Detector, int>, TProfile *> layerThickEta_;
};

//
HGCGeomAnalyzer::HGCGeomAnalyzer(const edm::ParameterSet &iConfig)
: txtFileName_(iConfig.getParameter<std::string>("fileName")) {
: txtFileName_(iConfig.getParameter<std::string>("fileName")),
geomToken_{esConsumes<CaloGeometry, CaloGeometryRecord>()} {
usesResource("TFileService");
fs_->file().cd();
}
Expand All @@ -76,13 +79,12 @@ void HGCGeomAnalyzer::analyze(const edm::Event &iEvent, const edm::EventSetup &e
boundaries.open(txtFileName_);

//get geometry
edm::ESHandle<CaloGeometry> geomhandle;
es.get<CaloGeometryRecord>().get(geomhandle);
const CaloGeometry *caloGeom = &es.getData(geomToken_);

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

Expand Down
3 changes: 1 addition & 2 deletions Geometry/HGCalGeometry/test/HGCalGeomLocatorTester.cc
Expand Up @@ -33,8 +33,7 @@ HGCalGeomLocaterTester::HGCalGeomLocaterTester(const edm::ParameterSet& iC)
geomToken_{esConsumes<HGCalGeometry, IdealGeometryRecord>(edm::ESInputTag{"", name_})} {}

void HGCalGeomLocaterTester::analyze(const edm::Event&, const edm::EventSetup& iSetup) {
const auto& geomR = iSetup.getData(geomToken_);
const HGCalGeometry* geom = &geomR;
const HGCalGeometry* geom = &iSetup.getData(geomToken_);
if (geom->topology().waferHexagon8()) {
DetId::Detector det;
if (name_ == "HGCalHESiliconSensitive")
Expand Down
77 changes: 51 additions & 26 deletions Geometry/HGCalGeometry/test/HGCalWaferInFileTest.cc
Expand Up @@ -52,6 +52,7 @@ class HGCalWaferInFileTest : public edm::one::EDAnalyzer<> {
private:
std::vector<std::string> getPoints(
double xpos, double ypos, double delX, double delY, double rin, double rout, int lay, int waferU, int waferV);
std::vector<double> getCorners(double xpos, double ypos, double delX, double delY);
const std::string nameSense_, nameDetector_;
const int verbosity_;
const edm::ESGetToken<HGCalGeometry, IdealGeometryRecord> geomToken_;
Expand Down Expand Up @@ -104,12 +105,16 @@ void HGCalWaferInFileTest::analyze(const edm::Event& iEvent, const edm::EventSet
const auto& xy = hgdc.waferPosition(layer, waferU, waferV, true, true);
const auto& rr = hgdc.rangeRLayer(layer, true);
auto points = getPoints(xy.first, xy.second, delX, delY, rr.first, rr.second, layer, waferU, waferV);
auto rpos = getCorners(xy.first, xy.second, delX, delY);
std::cout << "ID[" << k << "]: (" << (hgdc.getLayerOffset() + layer) << ", " << waferU << ", " << waferV << ", "
<< typex << ") at (" << std::setprecision(4) << xy.first << ", " << xy.second << ", "
<< hgdc.waferZ(layer, true) << ") not present with " << points.size() << " points:";
for (auto point : points)
std::cout << " " << point;
std::cout << " in the region " << rr.first << ":" << rr.second << std::endl;
std::cout << " in the region " << rr.first << ":" << rr.second << " Corners";
for (auto point : rpos)
std::cout << " " << point;
std::cout << std::endl;
++bad1;
if ((layer - layerf) < layers)
++miss[layer - layerf];
Expand Down Expand Up @@ -169,7 +174,7 @@ void HGCalWaferInFileTest::analyze(const edm::Event& iEvent, const edm::EventSet
int rotn2 = hgdc.waferTypeRotation(id.layer(), id.waferU(), id.waferV(), false, false).second;
bool partOK = ((part1 == part2) || ((part1 == HGCalTypes::WaferFull) && (part2 == HGCalTypes::WaferOut)));
bool rotnOK = ((rotn1 == rotn2) || (part1 == HGCalTypes::WaferFull) || (part2 == HGCalTypes::WaferFull));
bool partOK2 = ((part1 > part2) || partOK);
bool partOK2 = (partOK) || (part2 < part1);
if (!partOK) {
++badP;
if ((layer - layerf) < layers)
Expand All @@ -187,19 +192,25 @@ void HGCalWaferInFileTest::analyze(const edm::Event& iEvent, const edm::EventSet
}
if ((!partOK) || (!rotnOK)) {
++badG;
std::string partx1 = (part1 < static_cast<int>(types.size())) ? types[part1] : "X";
std::string partx2 = (part2 < static_cast<int>(types.size())) ? types[part2] : "X";
const auto& xy = hgdc.waferPosition(layer, waferU, waferV, true, false);
const auto& rr = hgdc.rangeRLayer(layer, true);
auto points = getPoints(xy.first, xy.second, delX, delY, rr.first, rr.second, layer, waferU, waferV);
std::cout << "ID[" << k << "]: (" << (hgdc.getLayerOffset() + layer) << ", " << waferU << ", " << waferV
<< "," << type2 << ", " << partx1 << ":" << partx2 << ":" << part1 << ":" << part2 << ", " << rotn1
<< ":" << rotn2 << ", " << partOK2 << ") at (" << std::setprecision(4) << xy.first << ", "
<< xy.second << ", " << hgdc.waferZ(layer, true) << ") failure flag " << partOK << ":" << rotnOK
<< " with " << points.size() << " points:";
for (auto point : points)
std::cout << " " << point;
std::cout << " in the region " << rr.first << ":" << rr.second << std::endl;
if ((verbosity_ > 0) || (!partOK2)) {
std::string partx1 = (part1 < static_cast<int>(types.size())) ? types[part1] : "X";
std::string partx2 = (part2 < static_cast<int>(types.size())) ? types[part2] : "X";
const auto& xy = hgdc.waferPosition(layer, waferU, waferV, true, false);
const auto& rr = hgdc.rangeRLayer(layer, true);
auto points = getPoints(xy.first, xy.second, delX, delY, rr.first, rr.second, layer, waferU, waferV);
auto rpos = getCorners(xy.first, xy.second, delX, delY);
std::cout << "ID[" << k << "]: (" << (hgdc.getLayerOffset() + layer) << ", " << waferU << ", " << waferV
<< "," << type2 << ", " << partx1 << ":" << partx2 << ":" << part1 << ":" << part2 << ", "
<< rotn1 << ":" << rotn2 << ") at (" << std::setprecision(4) << xy.first << ", " << xy.second
<< ", " << hgdc.waferZ(layer, true) << ") failure flag " << partOK << ":" << rotnOK << " with "
<< points.size() << " points:";
for (auto point : points)
std::cout << " " << point;
std::cout << " in the region " << rr.first << ":" << rr.second << " Corners";
for (auto point : rpos)
std::cout << " " << point;
std::cout << std::endl;
}
}
}
}
Expand Down Expand Up @@ -236,14 +247,14 @@ std::vector<std::string> HGCalWaferInFileTest::getPoints(
iok *= base;
}
}
if (verbosity_ > 0)
if (verbosity_ > 1)
std::cout << "I/p " << layer << ":" << waferU << ":" << waferV << ":" << xpos << ":" << ypos << ":" << delX << ":"
<< delY << ":" << rin << ":" << rout << " Corners " << ncor << " iok " << iok << std::endl;

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

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

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

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

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

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

std::vector<double> HGCalWaferInFileTest::getCorners(double xpos, double ypos, double delX, double delY) {
std::vector<double> points;
static const int corners = 6;
double dx0[corners] = {0.0, delX, delX, 0.0, -delX, -delX};
double dy0[corners] = {-delY, -0.5 * delY, 0.5 * delY, delY, 0.5 * delY, -0.5 * delY};
for (int k = 0; k < corners; ++k) {
double xc = xpos + dx0[k];
double yc = ypos + dy0[k];
double rpos = sqrt(xc * xc + yc * yc);
points.emplace_back(rpos);
}
return points;
}

// define this as a plug-in
DEFINE_FWK_MODULE(HGCalWaferInFileTest);

0 comments on commit 3af362a

Please sign in to comment.