Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 13:03:41

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/HGCalTBGeometry.h"
0009 #include "DataFormats/ForwardDetId/interface/HGCalDetId.h"
0010 #include <iostream>
0011 
0012 class HGCalTBGeometryDump : public edm::one::EDAnalyzer<> {
0013 public:
0014   explicit HGCalTBGeometryDump(const edm::ParameterSet&);
0015   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0016 
0017   void beginJob() override {}
0018   void analyze(edm::Event const& iEvent, edm::EventSetup const&) override;
0019   void endJob() override {}
0020 
0021 private:
0022   const std::vector<std::string> names_;
0023   std::vector<edm::ESGetToken<HGCalTBGeometry, IdealGeometryRecord>> geomTokens_;
0024 };
0025 
0026 HGCalTBGeometryDump::HGCalTBGeometryDump(const edm::ParameterSet& iC)
0027     : names_(iC.getParameter<std::vector<std::string>>("detectorNames")) {
0028   for (unsigned int k = 0; k < names_.size(); ++k) {
0029     edm::LogVerbatim("HGCalGeomX") << "Study detector [" << k << "] " << names_[k] << std::endl;
0030     geomTokens_.emplace_back(esConsumes<HGCalTBGeometry, IdealGeometryRecord>(edm::ESInputTag{"", names_[k]}));
0031   }
0032 }
0033 
0034 void HGCalTBGeometryDump::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0035   edm::ParameterSetDescription desc;
0036   std::vector<std::string> names = {"HGCalEESensitive", "HGCalHESiliconSensitive"};
0037   desc.add<std::vector<std::string>>("detectorNames", names);
0038   descriptions.add("hgcalTBGeometryDump", desc);
0039 }
0040 
0041 void HGCalTBGeometryDump::analyze(const edm::Event& /*iEvent*/, const edm::EventSetup& iSetup) {
0042   for (unsigned int k = 0; k < names_.size(); ++k) {
0043     const auto& geomR = iSetup.getData(geomTokens_[k]);
0044     const HGCalTBGeometry* geom = &geomR;
0045     const std::vector<DetId>& ids = geom->getValidDetIds();
0046     edm::LogVerbatim("HGCalGeomX") << ids.size() << " valid Ids for detector " << names_[k];
0047     int nall(0);
0048     for (auto id : ids) {
0049       ++nall;
0050       auto cell = geom->getGeometry(id);
0051       HGCalDetId hid(id);
0052       edm::LogVerbatim("HGCalGeomX") << "[" << nall << "] " << hid << " Reference " << std::setprecision(4)
0053                                      << cell->getPosition() << " Back " << cell->getBackPoint() << " [r,eta,phi] ("
0054                                      << cell->rhoPos() << ", " << cell->etaPos() << ":" << cell->etaSpan() << ", "
0055                                      << cell->phiPos() << ":" << cell->phiSpan() << ")";
0056     }
0057     edm::LogVerbatim("HGCalGeomX") << "\n\nDumps " << nall << " cells of the detector\n";
0058   }
0059 }
0060 
0061 DEFINE_FWK_MODULE(HGCalTBGeometryDump);