File indexing completed on 2024-04-06 12:15:11
0001 #include "DataFormats/DetId/interface/DetId.h"
0002 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0003 #include "FWCore/Framework/interface/EventSetup.h"
0004 #include "FWCore/Framework/interface/MakerMacros.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0007 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0008 #include "Geometry/HGCalGeometry/interface/HGCalGeometry.h"
0009 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
0010 #include <iostream>
0011 #include <string>
0012
0013 class CaloCellGeometryTester : public edm::one::EDAnalyzer<> {
0014 public:
0015 explicit CaloCellGeometryTester(const edm::ParameterSet&);
0016 ~CaloCellGeometryTester(void) override = default;
0017
0018 void analyze(edm::Event const&, edm::EventSetup const&) override;
0019
0020 private:
0021 const edm::ESGetToken<CaloGeometry, CaloGeometryRecord> caloToken_;
0022 };
0023
0024 CaloCellGeometryTester::CaloCellGeometryTester(const edm::ParameterSet&)
0025 : caloToken_{esConsumes<CaloGeometry, CaloGeometryRecord>(edm::ESInputTag{})} {}
0026
0027 void CaloCellGeometryTester::analyze(const edm::Event& , const edm::EventSetup& iSetup) {
0028
0029 const CaloGeometry* geo = &iSetup.getData(caloToken_);
0030
0031 const int ncalo = 11;
0032 int dets[ncalo] = {3, 3, 3, 4, 4, 4, 4, 8, 9, 10, 6};
0033 int subd[ncalo] = {1, 2, 3, 1, 2, 4, 3, 0, 0, 0, 6};
0034 std::string name[ncalo] = {"EB", "EE", "ES", "HB", "HE", "HF", "HO", "HGCEE", "HGCHESil", "HGCHESci", "HFNose"};
0035 for (unsigned int k = 0; k < ncalo; ++k) {
0036 const CaloSubdetectorGeometry* geom = geo->getSubdetectorGeometry((DetId::Detector)(dets[k]), subd[k]);
0037 if (geom) {
0038 edm::LogVerbatim("HGCalGeomX") << name[k] << " has "
0039 << geom->getValidDetIds((DetId::Detector)(dets[k]), subd[k]).size()
0040 << " valid cells";
0041 if (k >= 7)
0042 edm::LogVerbatim("HGCalGeomX") << "Number of valid GeomID "
0043 << ((HGCalGeometry*)(geom))->getValidGeomDetIds().size();
0044 } else {
0045 edm::LogVerbatim("HGCalGeomX") << name[k] << " is not present in the current scenario";
0046 }
0047 }
0048 }
0049
0050 DEFINE_FWK_MODULE(CaloCellGeometryTester);