Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:07:35

0001 // -*- C++ -*-
0002 //
0003 // Package:    CaloEventSetup
0004 // Class:      HGCalTopologyBuilder
0005 //
0006 /**\class HGCalTopologyBuilder HGCalTopologyBuilder.h 
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Sunanda Banerjee
0015 //
0016 //
0017 
0018 // system include files
0019 #include <memory>
0020 
0021 // user include files
0022 #include <FWCore/Framework/interface/ModuleFactory.h>
0023 #include "FWCore/Framework/interface/ESProducer.h"
0024 
0025 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0026 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0027 #include "FWCore/Utilities/interface/ESGetToken.h"
0028 
0029 #include "Geometry/CaloTopology/interface/HGCalTopology.h"
0030 #include "Geometry/CaloTopology/interface/CaloSubdetectorTopology.h"
0031 #include "Geometry/HGCalCommonData/interface/HGCalDDDConstants.h"
0032 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0033 #include "Geometry/CaloTopology/interface/CaloSubdetectorTopology.h"
0034 #include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h"
0035 
0036 //#define EDM_ML_DEBUG
0037 
0038 //
0039 // class decleration
0040 //
0041 
0042 class HGCalTopologyBuilder : public edm::ESProducer {
0043 public:
0044   HGCalTopologyBuilder(const edm::ParameterSet& iP);
0045   ~HGCalTopologyBuilder() override;
0046 
0047   using ReturnType = std::unique_ptr<HGCalTopology>;
0048 
0049   ReturnType produce(const IdealGeometryRecord&);
0050 
0051 private:
0052   // ----------member data ---------------------------
0053   edm::ESGetToken<HGCalDDDConstants, IdealGeometryRecord> hgcToken_;
0054   int det_;
0055 };
0056 
0057 HGCalTopologyBuilder::HGCalTopologyBuilder(const edm::ParameterSet& iConfig) {
0058   auto name = iConfig.getParameter<std::string>("Name");
0059   det_ = iConfig.getParameter<int>("Type");
0060 #ifdef EDM_ML_DEBUG
0061   edm::LogVerbatim("HGCalGeom") << "constructing HGCalTopology for " << name << " and det " << det_;
0062 #endif
0063   hgcToken_ = setWhatProduced(this, name).consumes<HGCalDDDConstants>(edm::ESInputTag{"", name});
0064 }
0065 
0066 HGCalTopologyBuilder::~HGCalTopologyBuilder() {}
0067 
0068 //
0069 // member functions
0070 //
0071 
0072 // ------------ method called to produce the data  ------------
0073 HGCalTopologyBuilder::ReturnType HGCalTopologyBuilder::produce(const IdealGeometryRecord& iRecord) {
0074   const HGCalDDDConstants& hgdc = iRecord.get(hgcToken_);
0075 
0076 #ifdef EDM_ML_DEBUG
0077   edm::LogVerbatim("HGCalGeom") << "Create HGCalTopology(hgdc,det)";
0078 #endif
0079   return std::make_unique<HGCalTopology>(hgdc, det_);
0080 }
0081 
0082 DEFINE_FWK_EVENTSETUP_MODULE(HGCalTopologyBuilder);