File indexing completed on 2025-01-15 23:24:58
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 "Geometry/Records/interface/CaloGeometryRecord.h"
0006 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0007 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
0008 #include "DataFormats/DetId/interface/DetId.h"
0009 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
0010 #include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
0011 #include <iostream>
0012 #include <string>
0013
0014 class HcalCellCount : public edm::one::EDAnalyzer<> {
0015 public:
0016 explicit HcalCellCount(const edm::ParameterSet&);
0017 ~HcalCellCount(void) override = default;
0018
0019 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0020 void beginJob() override {}
0021 void analyze(edm::Event const&, edm::EventSetup const&) override;
0022 void endJob() override {}
0023
0024 private:
0025 const int verbose_;
0026 edm::ESGetToken<CaloGeometry, CaloGeometryRecord> tok_geom_;
0027 };
0028
0029 HcalCellCount::HcalCellCount(const edm::ParameterSet& iConfig) : verbose_(iConfig.getParameter<int>("Verbosity")) {
0030 tok_geom_ = esConsumes<CaloGeometry, CaloGeometryRecord>();
0031 }
0032
0033 void HcalCellCount::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0034 edm::ParameterSetDescription desc;
0035 desc.add<int>("Verbosity", 0);
0036 descriptions.add("hcalCellCount", desc);
0037 }
0038
0039 void HcalCellCount::analyze(edm::Event const& , const edm::EventSetup& iSetup) {
0040 const CaloGeometry* geo = &iSetup.getData(tok_geom_);
0041
0042
0043 const CaloSubdetectorGeometry* bGeom = geo->getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
0044 if (bGeom != nullptr)
0045 edm::LogVerbatim("HCalGeom") << "Valid ID for EcalBarrel: "
0046 << bGeom->getValidDetIds(DetId::Ecal, EcalBarrel).size();
0047 else
0048 edm::LogVerbatim("HCalGeom") << "EB Geometry does not exist";
0049 const CaloSubdetectorGeometry* eGeom = geo->getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
0050 if (eGeom != nullptr)
0051 edm::LogVerbatim("HCalGeom") << "Valid ID for EcalEndcap: "
0052 << eGeom->getValidDetIds(DetId::Ecal, EcalEndcap).size();
0053 else
0054 edm::LogVerbatim("HCalGeom") << "EE Geometry does not exist";
0055 const CaloSubdetectorGeometry* sGeom = geo->getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
0056 if (sGeom != nullptr)
0057 edm::LogVerbatim("HCalGeom") << "Valid ID for EcalPreshower: "
0058 << sGeom->getValidDetIds(DetId::Ecal, EcalPreshower).size();
0059 else
0060 edm::LogVerbatim("HCalGeom") << "ES Geometry does not exist";
0061 const CaloSubdetectorGeometry* tGeom = geo->getSubdetectorGeometry(DetId::Ecal, EcalTriggerTower);
0062 if (tGeom != nullptr)
0063 edm::LogVerbatim("HCalGeom") << "Valid ID for EcalTriggerTower: "
0064 << tGeom->getValidDetIds(DetId::Ecal, EcalTriggerTower).size();
0065 else
0066 edm::LogVerbatim("HCalGeom") << "EcalTriggerTower Geometry does not exist";
0067
0068
0069 const CaloSubdetectorGeometry* gHB = geo->getSubdetectorGeometry(DetId::Hcal, HcalBarrel);
0070 if (gHB != nullptr) {
0071 edm::LogVerbatim("HCalGeom") << "Valid ID for HcalBarrel: " << gHB->getValidDetIds(DetId::Hcal, HcalBarrel).size();
0072 edm::LogVerbatim("HCalGeom") << "Valid ID for HcalEndcap: " << gHB->getValidDetIds(DetId::Hcal, HcalEndcap).size();
0073 edm::LogVerbatim("HCalGeom") << "Valid ID for HcalOuter: " << gHB->getValidDetIds(DetId::Hcal, HcalOuter).size();
0074 edm::LogVerbatim("HCalGeom") << "Valid ID for HcalForward: "
0075 << gHB->getValidDetIds(DetId::Hcal, HcalForward).size();
0076 edm::LogVerbatim("HCalGeom") << "Valid ID for HcalTriggerTower: "
0077 << gHB->getValidDetIds(DetId::Hcal, HcalTriggerTower).size();
0078 } else {
0079 edm::LogVerbatim("HCalGeom") << "HCAL Geometry does not exist";
0080 }
0081
0082
0083 const CaloSubdetectorGeometry* gHGEE = geo->getSubdetectorGeometry(DetId::HGCalEE, 0);
0084 if (gHGEE != nullptr)
0085 edm::LogVerbatim("HCalGeom") << "Valid ID for HGCalEE: " << gHGEE->getValidDetIds(DetId::HGCalEE, 0).size();
0086 else
0087 edm::LogVerbatim("HCalGeom") << "HGCaLEE Geometry does not exist";
0088 const CaloSubdetectorGeometry* gHGHSi = geo->getSubdetectorGeometry(DetId::HGCalHSi, 0);
0089 if (gHGHSi != nullptr)
0090 edm::LogVerbatim("HCalGeom") << "Valid ID for HGCalHSi: " << gHGHSi->getValidDetIds(DetId::HGCalHSi, 0).size();
0091 else
0092 edm::LogVerbatim("HCalGeom") << "HGCaLHSi Geometry does not exist";
0093 const CaloSubdetectorGeometry* gHGHSc = geo->getSubdetectorGeometry(DetId::HGCalHSc, 0);
0094 if (gHGHSc != nullptr)
0095 edm::LogVerbatim("HCalGeom") << "Valid ID for HGCalHSc: " << gHGHSc->getValidDetIds(DetId::HGCalHSc, 0).size();
0096 else
0097 edm::LogVerbatim("HCalGeom") << "HGCaLHSc Geometry does not exist";
0098 }
0099
0100 DEFINE_FWK_MODULE(HcalCellCount);