Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:14:49

0001 // -*- C++ -*-
0002 //
0003 // Package:    HcalDDDGeometryAnalyzer
0004 // Class:      HcalDDDGeometryAnalyzer
0005 //
0006 /**\class HcalDDDGeometryAnalyzer HcalDDDGeometryAnalyzer.cc test/HcalDDDGeometryAnalyzer/src/HcalDDDGeometryAnalyzer.cc
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 
0015 // system include files
0016 #include <memory>
0017 #include <vector>
0018 
0019 // user include files
0020 #include "FWCore/Framework/interface/Frameworkfwd.h"
0021 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0022 
0023 #include "FWCore/Framework/interface/Event.h"
0024 #include "FWCore/Framework/interface/EventSetup.h"
0025 #include "FWCore/Framework/interface/MakerMacros.h"
0026 
0027 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0028 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0029 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0030 
0031 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
0032 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0033 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
0034 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
0035 #include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
0036 #include <fstream>
0037 
0038 //
0039 // class decleration
0040 //
0041 
0042 class HcalDDDGeometryAnalyzer : public edm::one::EDAnalyzer<> {
0043 public:
0044   explicit HcalDDDGeometryAnalyzer(const edm::ParameterSet&);
0045   ~HcalDDDGeometryAnalyzer() override;
0046 
0047   void beginJob() override {}
0048   void analyze(edm::Event const& iEvent, edm::EventSetup const&) override;
0049   void endJob() override {}
0050 
0051 private:
0052   edm::ESGetToken<CaloGeometry, CaloGeometryRecord> geometryToken_;
0053   int pass_;
0054 };
0055 
0056 HcalDDDGeometryAnalyzer::HcalDDDGeometryAnalyzer(const edm::ParameterSet&)
0057     : geometryToken_{esConsumes<CaloGeometry, CaloGeometryRecord>(edm::ESInputTag{})} {
0058   pass_ = 0;
0059 }
0060 
0061 HcalDDDGeometryAnalyzer::~HcalDDDGeometryAnalyzer() {}
0062 
0063 // ------------ method called to produce the data  ------------
0064 void HcalDDDGeometryAnalyzer::analyze(const edm::Event&, const edm::EventSetup& iSetup) {
0065   LogDebug("HCalGeom") << "HcalDDDGeometryAnalyzer::analyze at pass " << pass_;
0066 
0067   const auto& geometryR = iSetup.getData(geometryToken_);
0068   const auto* geometry = &geometryR;
0069   //
0070   // get the ecal & hcal geometry
0071   //
0072   if (pass_ == 0) {
0073     const std::vector<DetId>& hbCells = geometry->getValidDetIds(DetId::Hcal, HcalBarrel);
0074     const std::vector<DetId>& heCells = geometry->getValidDetIds(DetId::Hcal, HcalEndcap);
0075     const std::vector<DetId>& hoCells = geometry->getValidDetIds(DetId::Hcal, HcalOuter);
0076     const std::vector<DetId>& hfCells = geometry->getValidDetIds(DetId::Hcal, HcalForward);
0077     LogDebug("HCalGeom") << "HcalDDDGeometryAnalyzer:: Hcal Barrel (" << HcalBarrel << ") with " << hbCells.size()
0078                          << " valid cells; Hcal Endcap (" << HcalEndcap << ") with " << heCells.size()
0079                          << " valid cells; "
0080                          << "Hcal Outer (" << HcalOuter << ") with " << hoCells.size()
0081                          << " valid cells; and Hcal Forward"
0082                          << " (" << HcalForward << ") with " << hfCells.size() << " valid cells";
0083   }
0084 
0085   pass_++;
0086 }
0087 
0088 //define this as a plug-in
0089 
0090 DEFINE_FWK_MODULE(HcalDDDGeometryAnalyzer);