Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run4-hgx280X Update some of the test codes for HGCal Geometry description #33298

Merged
merged 2 commits into from Apr 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
58 changes: 37 additions & 21 deletions Geometry/HGCalCommonData/test/HGCalValidHexTester.cc
Expand Up @@ -28,7 +28,9 @@
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"

#include "DataFormats/DetId/interface/DetId.h"
#include "DataFormats/ForwardDetId/interface/HGCSiliconDetId.h"
Expand All @@ -38,53 +40,67 @@
class HGCalValidHexTester : public edm::one::EDAnalyzer<> {
public:
explicit HGCalValidHexTester(const edm::ParameterSet&);
~HGCalValidHexTester() override;
~HGCalValidHexTester() override {}
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

void beginJob() override {}
void analyze(edm::Event const& iEvent, edm::EventSetup const&) override;
void endJob() override {}

private:
const std::string nameDetector_, nameSense_;
const std::vector<int> layers_, moduleU_, moduleV_, types_;
edm::ESGetToken<HGCalDDDConstants, IdealGeometryRecord> dddToken_;
std::string nameDetector_, nameSense_;
std::vector<int> layers_, moduleU_, moduleV_, types_;
};

HGCalValidHexTester::HGCalValidHexTester(const edm::ParameterSet& iC) {
nameDetector_ = iC.getParameter<std::string>("NameDevice");
nameSense_ = iC.getParameter<std::string>("NameSense");
layers_ = iC.getParameter<std::vector<int> >("Layers");
moduleU_ = iC.getParameter<std::vector<int> >("ModuleU");
moduleV_ = iC.getParameter<std::vector<int> >("ModuleV");
types_ = iC.getParameter<std::vector<int> >("Types");

HGCalValidHexTester::HGCalValidHexTester(const edm::ParameterSet& iC)
: nameDetector_(iC.getParameter<std::string>("NameDevice")),
nameSense_(iC.getParameter<std::string>("NameSense")),
layers_(iC.getParameter<std::vector<int> >("Layers")),
moduleU_(iC.getParameter<std::vector<int> >("ModuleU")),
moduleV_(iC.getParameter<std::vector<int> >("ModuleV")),
types_(iC.getParameter<std::vector<int> >("Types")) {
dddToken_ = esConsumes<HGCalDDDConstants, IdealGeometryRecord>(edm::ESInputTag{"", nameSense_});

std::cout << "Test valid cells for " << nameDetector_ << " using constants of " << nameSense_ << " for "
<< layers_.size() << " modules" << std::endl;
edm::LogVerbatim("HGCalGeom") << "Test valid cells for " << nameDetector_ << " using constants of " << nameSense_
<< " for " << layers_.size() << " modules";
for (unsigned int k = 0; k < layers_.size(); ++k)
std::cout << "Wafer[" << k << "] Layer " << layers_[k] << " Type " << types_[k] << " U:V " << moduleU_[k] << ":"
<< moduleV_[k] << std::endl;
edm::LogVerbatim("HGCalGeom") << "Wafer[" << k << "] Layer " << layers_[k] << " Type " << types_[k] << " U:V "
<< moduleU_[k] << ":" << moduleV_[k];
}

HGCalValidHexTester::~HGCalValidHexTester() {}
void HGCalValidHexTester::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
std::vector<int> layers = {21, 21, 22, 22};
std::vector<int> modU = {3, -3, 3, -3};
std::vector<int> modV = {6, -6, 6, -6};
std::vector<int> types = {2, 2, 2, 2};
edm::ParameterSetDescription desc;
desc.add<std::string>("NameDevice", "HGCal HE Silicon");
desc.add<std::string>("NameSense", "HGCalHESiliconSensitive");
desc.add<std::vector<int> >("Layers", layers);
desc.add<std::vector<int> >("ModuleU", modU);
desc.add<std::vector<int> >("ModuleV", modV);
desc.add<std::vector<int> >("Types", types);
descriptions.add("hgcalValidHexTesterHEF", desc);
}

// ------------ method called to produce the data ------------
void HGCalValidHexTester::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
const DetId::Detector det = (nameSense_ == "HGCalEESensitive") ? DetId::HGCalEE : DetId::HGCalHSi;
const HGCalDDDConstants& hgdc = iSetup.getData(dddToken_);
std::cout << nameDetector_ << " Layers = " << hgdc.layers(true) << " Sectors = " << hgdc.sectors() << std::endl
<< std::endl;
edm::LogVerbatim("HGCalGeom") << nameDetector_ << " Layers = " << hgdc.layers(true) << " Sectors = " << hgdc.sectors()
<< "\n";
for (unsigned int k = 0; k < layers_.size(); ++k) {
int nCells = (types_[k] == 0) ? HGCSiliconDetId::HGCalFineN : HGCSiliconDetId::HGCalCoarseN;
int ncell(0);
for (int u = 0; u < 2 * nCells; ++u) {
for (int v = 0; v < 2 * nCells; ++v) {
if (((v - u) < nCells) && (u - v) <= nCells) {
std::string state = hgdc.isValidHex8(layers_[k], moduleU_[k], moduleV_[k], u, v) ? "within" : "outside of";
std::cout << "Cell[" << k << "," << ncell << "] "
<< HGCSiliconDetId(det, 1, types_[k], layers_[k], moduleU_[k], moduleV_[k], u, v) << " is " << state
<< " fiducial volume" << std::endl;
edm::LogVerbatim("HGCalGeom") << "Cell[" << k << "," << ncell << "] "
<< HGCSiliconDetId(
det, 1, types_[k], layers_[k], moduleU_[k], moduleV_[k], u, v)
<< " is " << state << " fiducial volume";
++ncell;
}
}
Expand Down
43 changes: 27 additions & 16 deletions Geometry/HGCalCommonData/test/HGCalWaferTester.cc
Expand Up @@ -32,53 +32,64 @@
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/MakerMacros.h"

#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "Geometry/HGCalCommonData/interface/HGCalDDDConstants.h"
#include "Geometry/Records/interface/IdealGeometryRecord.h"

class HGCalWaferTester : public edm::one::EDAnalyzer<> {
public:
explicit HGCalWaferTester(const edm::ParameterSet&);
~HGCalWaferTester() override;
~HGCalWaferTester() override {}
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

void beginJob() override {}
void analyze(edm::Event const& iEvent, edm::EventSetup const&) override;
void endJob() override {}

private:
const std::string nameSense_, nameDetector_;
const bool reco_;
edm::ESGetToken<HGCalDDDConstants, IdealGeometryRecord> dddToken_;
std::string nameSense_, nameDetector_;
bool reco_;
};

HGCalWaferTester::HGCalWaferTester(const edm::ParameterSet& iC) {
nameSense_ = iC.getParameter<std::string>("NameSense");
nameDetector_ = iC.getParameter<std::string>("NameDevice");
reco_ = iC.getParameter<bool>("Reco");

HGCalWaferTester::HGCalWaferTester(const edm::ParameterSet& iC)
: nameSense_(iC.getParameter<std::string>("NameSense")),
nameDetector_(iC.getParameter<std::string>("NameDevice")),
reco_(iC.getParameter<bool>("Reco")) {
dddToken_ = esConsumes<HGCalDDDConstants, IdealGeometryRecord>(edm::ESInputTag{"", nameSense_});

std::cout << "Test numbering for " << nameDetector_ << " using constants of " << nameSense_ << " for RecoFlag "
<< reco_ << std::endl;
edm::LogVerbatim("HGCalGeom") << "Test numbering for " << nameDetector_ << " using constants of " << nameSense_
<< " for RecoFlag " << reco_;
}

HGCalWaferTester::~HGCalWaferTester() {}
void HGCalWaferTester::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<std::string>("NameSense", "HGCalEESensitive");
desc.add<std::string>("NameDevice", "HGCal EE");
desc.add<bool>("Reco", false);
descriptions.add("hgcalWaferTesterEE", desc);
}

// ------------ method called to produce the data ------------
void HGCalWaferTester::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
const HGCalDDDConstants& hgdc = iSetup.getData(dddToken_);
std::cout << nameDetector_ << " Layers = " << hgdc.layers(reco_) << " Sectors = " << hgdc.sectors() << std::endl;
edm::LogVerbatim("HGCalGeom") << nameDetector_ << " Layers = " << hgdc.layers(reco_)
<< " Sectors = " << hgdc.sectors() << std::endl;
if (hgdc.waferHexagon8()) {
int layer = hgdc.firstLayer();
for (int u = -12; u <= 12; ++u) {
std::pair<double, double> xy = hgdc.waferPosition(layer, u, 0, reco_);
std::cout << " iz = +, u = " << u << ", v = 0: x = " << xy.first << " y = " << xy.second << "\n"
<< " iz = -, u = " << u << ", v = 0: x = " << -xy.first << " y = " << xy.second << "\n";
edm::LogVerbatim("HGCalGeom") << " iz = +, u = " << u << ", v = 0: x = " << xy.first << " y = " << xy.second
<< "\n"
<< " iz = -, u = " << u << ", v = 0: x = " << -xy.first << " y = " << xy.second;
}
for (int v = -12; v <= 12; ++v) {
std::pair<double, double> xy = hgdc.waferPosition(layer, 0, v, reco_);
std::cout << " iz = +, u = 0, v = " << v << ": x = " << xy.first << " y = " << xy.second << "\n"
<< " iz = -, u = 0, v = " << v << ": x = " << -xy.first << " y = " << xy.second << "\n";
edm::LogVerbatim("HGCalGeom") << " iz = +, u = 0, v = " << v << ": x = " << xy.first << " y = " << xy.second
<< "\n"
<< " iz = -, u = 0, v = " << v << ": x = " << -xy.first << " y = " << xy.second;
}
}
}
Expand Down
11 changes: 2 additions & 9 deletions Geometry/HGCalCommonData/test/python/testHGCalValidHex_cfg.py
Expand Up @@ -39,13 +39,6 @@
input = cms.untracked.int32(1)
)

process.prodHEF = cms.EDAnalyzer("HGCalValidHexTester",
NameSense = cms.string("HGCalHESiliconSensitive"),
NameDevice = cms.string("HGCal HE Silicon"),
Layers = cms.vint32(21,21,22,22),
Types = cms.vint32(2,2,2,2),
ModuleU = cms.vint32(3,-3,3,-3),
ModuleV = cms.vint32(6,-6,6,-6)
)
process.load("Geometry.HGCalCommonData.hgcalValidHexTesterHEF_cfi")

process.p1 = cms.Path(process.generator*process.prodHEF)
process.p1 = cms.Path(process.generator*process.hgcalValidHexTesterHEF)
10 changes: 3 additions & 7 deletions Geometry/HGCalCommonData/test/python/testHGCalWafer_cfg.py
Expand Up @@ -39,16 +39,12 @@
input = cms.untracked.int32(1)
)

process.prodEE = cms.EDAnalyzer("HGCalWaferTester",
NameSense = cms.string("HGCalEESensitive"),
NameDevice = cms.string("HGCal EE"),
Reco = cms.bool(False)
)
process.load("Geometry.HGCalCommonData.hgcalWaferTesterEE_cfi")

process.prodHEF = process.prodEE.clone(
process.hgcalWaferTesterHEF = process.hgcalWaferTesterEE.clone(
NameSense = "HGCalHESiliconSensitive",
NameDevice = "HGCal HE Front",
)


process.p1 = cms.Path(process.generator*process.prodEE*process.prodHEF)
process.p1 = cms.Path(process.generator*process.hgcalWaferTesterEE*process.hgcalWaferTesterHEF)
@@ -1,6 +1,7 @@
import FWCore.ParameterSet.Config as cms
from Configuration.Eras.Era_Phase2C11_dd4hep_cff import Phase2C11_dd4hep

process = cms.Process("HcalGeometryTest")
process = cms.Process("HcalGeometryTest",Phase2C11_dd4hep)

process.load("Geometry.EcalCommonData.ecalSimulationParameters_cff")
process.load("Geometry.HcalCommonData.hcalDDDSimConstants_cff")
Expand Down Expand Up @@ -32,8 +33,4 @@
)
process.Timing = cms.Service("Timing")

process.hgcalEEParametersInitialize.fromDD4Hep = True
process.hgcalHESiParametersInitialize.fromDD4Hep = True
process.hgcalHEScParametersInitialize.fromDD4Hep = True

process.p1 = cms.Path(process.hgcalGeometryDump)
@@ -1,6 +1,7 @@
import FWCore.ParameterSet.Config as cms
from Configuration.Eras.Era_Phase2C11_cff import Phase2C11

process = cms.Process("HcalGeometryTest")
process = cms.Process("HcalGeometryTest",Phase2C11)

process.load("Geometry.CMSCommonData.cmsExtendedGeometry2026D71XML_cfi")
process.load("Geometry.EcalCommonData.ecalSimulationParameters_cff")
Expand Down
@@ -1,6 +1,7 @@
import FWCore.ParameterSet.Config as cms
from Configuration.Eras.Era_Phase2C11_cff import Phase2C11

process = cms.Process("PROD")
process = cms.Process("PROD",Phase2C11)
process.load("SimGeneral.HepPDTESSource.pdt_cfi")
process.load("Geometry.HGCalCommonData.testHGCalV14XML_cfi")
process.load("Geometry.HGCalCommonData.hgcalParametersInitialization_cfi")
Expand Down
@@ -1,6 +1,7 @@
import FWCore.ParameterSet.Config as cms
from Configuration.Eras.Era_Phase2C11_cff import Phase2C11

process = cms.Process("PROD")
process = cms.Process("PROD",Phase2C11)
process.load("SimGeneral.HepPDTESSource.pdt_cfi")
process.load("Geometry.HGCalCommonData.testHGCalV14XML_cfi")
process.load("Geometry.HGCalCommonData.hgcalParametersInitialization_cfi")
Expand Down