File indexing completed on 2023-03-17 13:03:40
0001 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0002 #include "FWCore/Framework/interface/EventSetup.h"
0003 #include "FWCore/Framework/interface/MakerMacros.h"
0004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0007 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0008 #include "Geometry/HGCalGeometry/interface/HGCalGeometry.h"
0009 #include "DataFormats/ForwardDetId/interface/HFNoseDetId.h"
0010 #include "DataFormats/ForwardDetId/interface/HGCScintillatorDetId.h"
0011 #include "DataFormats/ForwardDetId/interface/HGCSiliconDetId.h"
0012 #include <iostream>
0013
0014 class HGCalGeometryDump : public edm::one::EDAnalyzer<> {
0015 public:
0016 explicit HGCalGeometryDump(const edm::ParameterSet&);
0017 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0018
0019 void beginJob() override {}
0020 void analyze(edm::Event const& iEvent, edm::EventSetup const&) override;
0021 void endJob() override {}
0022
0023 private:
0024 const std::vector<std::string> names_;
0025 const std::vector<int> types_;
0026 std::vector<edm::ESGetToken<HGCalGeometry, IdealGeometryRecord>> geomTokens_;
0027 };
0028
0029 HGCalGeometryDump::HGCalGeometryDump(const edm::ParameterSet& iC)
0030 : names_(iC.getParameter<std::vector<std::string>>("detectorNames")),
0031 types_(iC.getParameter<std::vector<int>>("detectorTypes")) {
0032 for (unsigned int k = 0; k < names_.size(); ++k) {
0033 edm::LogVerbatim("HGCalGeomX") << "Study detector [" << k << "] " << names_[k] << " of type " << types_[k]
0034 << std::endl;
0035 geomTokens_.emplace_back(esConsumes<HGCalGeometry, IdealGeometryRecord>(edm::ESInputTag{"", names_[k]}));
0036 }
0037 }
0038
0039 void HGCalGeometryDump::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0040 edm::ParameterSetDescription desc;
0041 std::vector<std::string> names = {"HGCalEESensitive", "HGCalHESiliconSensitive", "HGCalHEScintillatorSensitive"};
0042 desc.add<std::vector<std::string>>("detectorNames", names);
0043 std::vector<int> types = {0, 0, 1};
0044 desc.add<std::vector<int>>("detectorTypes", types);
0045 descriptions.add("hgcalGeometryDump", desc);
0046 }
0047
0048 void HGCalGeometryDump::analyze(const edm::Event& , const edm::EventSetup& iSetup) {
0049 for (unsigned int k = 0; k < names_.size(); ++k) {
0050 const auto& geomR = iSetup.getData(geomTokens_[k]);
0051 const HGCalGeometry* geom = &geomR;
0052 const std::vector<DetId>& ids = geom->getValidDetIds();
0053 edm::LogVerbatim("HGCalGeomX") << ids.size() << " valid Ids for detector " << names_[k];
0054 int nall(0);
0055 for (auto id : ids) {
0056 ++nall;
0057 auto cell = geom->getGeometry(id);
0058 if (types_[k] == 0) {
0059 HGCSiliconDetId hid(id);
0060 edm::LogVerbatim("HGCalGeomX") << "[" << nall << "] " << hid << " Reference " << std::setprecision(4)
0061 << cell->getPosition() << " Back " << cell->getBackPoint() << " [r,eta,phi] ("
0062 << cell->rhoPos() << ", " << cell->etaPos() << ":" << cell->etaSpan() << ", "
0063 << cell->phiPos() << ":" << cell->phiSpan() << ")";
0064 } else if (types_[k] == 1) {
0065 HGCScintillatorDetId hid(id);
0066 edm::LogVerbatim("HGCalGeomX") << "[" << nall << "] " << hid << " Reference " << std::setprecision(4)
0067 << cell->getPosition() << " Back " << cell->getBackPoint() << " [r,eta,phi] ("
0068 << cell->rhoPos() << ", " << cell->etaPos() << ":" << cell->etaSpan() << ", "
0069 << cell->phiPos() << ":" << cell->phiSpan() << ")";
0070 } else {
0071 HFNoseDetId hid(id);
0072 edm::LogVerbatim("HGCalGeomX") << "[" << nall << "] " << hid << " Reference " << std::setprecision(4)
0073 << cell->getPosition() << " Back " << cell->getBackPoint() << " [r,eta,phi] ("
0074 << cell->rhoPos() << ", " << cell->etaPos() << ":" << cell->etaSpan() << ", "
0075 << cell->phiPos() << ":" << cell->phiSpan() << ")";
0076 }
0077 }
0078 edm::LogVerbatim("HGCalGeomX") << "\n\nDumps " << nall << " cells of the detector\n";
0079 }
0080 }
0081
0082 DEFINE_FWK_MODULE(HGCalGeometryDump);