Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-08 08:16:23

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/CaloGeometry/interface/CaloGeometry.h"
0008 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0009 #include "Geometry/HcalTowerAlgo/interface/HcalGeometry.h"
0010 #include <iomanip>
0011 #include <iostream>
0012 
0013 class HcalCellParameterDump : public edm::one::EDAnalyzer<> {
0014 public:
0015   explicit HcalCellParameterDump(const edm::ParameterSet&);
0016 
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   static constexpr int detMax_ = 4;
0025   int subdet_;
0026   edm::ESGetToken<CaloGeometry, CaloGeometryRecord> tok_geom_;
0027 };
0028 
0029 HcalCellParameterDump::HcalCellParameterDump(const edm::ParameterSet& iConfig) {
0030   subdet_ = std::min(detMax_, std::max(iConfig.getParameter<int>("SubDetector"), 1));
0031   subdet_ = std::min(detMax_, std::max(subdet_, 1));
0032   tok_geom_ = esConsumes<CaloGeometry, CaloGeometryRecord>();
0033   edm::LogVerbatim("HCalGeom") << "Dumps all cells for SubDetId: " << subdet_;
0034 }
0035 
0036 void HcalCellParameterDump::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0037   edm::ParameterSetDescription desc;
0038   desc.add<int>("SubDetector", 1);
0039   descriptions.add("hcalCellParameterDump", desc);
0040 }
0041 
0042 void HcalCellParameterDump::analyze(const edm::Event& /*iEvent*/, const edm::EventSetup& iSetup) {
0043   const CaloGeometry* geo = &iSetup.getData(tok_geom_);
0044   const HcalGeometry* hcalGeom = static_cast<const HcalGeometry*>(geo->getSubdetectorGeometry(DetId::Hcal, HcalBarrel));
0045 
0046   std::string subdets[detMax_] = {"HB", "HE", "HO", "HF"};
0047   HcalSubdetector subdetd[detMax_] = {HcalBarrel, HcalEndcap, HcalOuter, HcalForward};
0048 
0049   edm::LogVerbatim("HCalGeom") << "\n\nStudy Detector = Hcal SubDetector = " << subdets[subdet_ - 1]
0050                                << "\n======================================\n";
0051   const std::vector<DetId>& ids = hcalGeom->getValidDetIds(DetId::Hcal, subdetd[subdet_ - 1]);
0052   int nall(0);
0053   for (auto id : ids) {
0054     ++nall;
0055     std::shared_ptr<const CaloCellGeometry> geom = hcalGeom->getGeometry(id);
0056     edm::LogVerbatim("HCalGeom") << "[" << nall << "] " << HcalDetId(id) << " Reference " << std::setprecision(4)
0057                                  << geom->getPosition() << " Back " << geom->getBackPoint() << " [r,eta,phi] ("
0058                                  << geom->rhoPos() << ", " << geom->etaPos() << ":" << geom->etaSpan() << ", "
0059                                  << geom->phiPos() << ":" << geom->phiSpan() << ")";
0060   }
0061   edm::LogVerbatim("HCalGeom") << "\n\nDumps " << nall << " cells of the detector\n";
0062 }
0063 
0064 DEFINE_FWK_MODULE(HcalCellParameterDump);