Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:48:36

0001 // -*- C++ -*-
0002 //
0003 // Package:    HGCalGeometry
0004 // Class:      HGCalGeometryESProducer
0005 //
0006 /**\class HGCalGeometryESProducer HGCalGeometryESProducer.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 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0025 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0026 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
0027 #include "Geometry/CaloTopology/interface/HGCalTopology.h"
0028 #include "Geometry/HGCalGeometry/interface/HGCalGeometry.h"
0029 #include "Geometry/HGCalGeometry/interface/HGCalGeometryLoader.h"
0030 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0031 
0032 //#define EDM_ML_DEBUG
0033 
0034 //
0035 // class decleration
0036 //
0037 
0038 class HGCalGeometryESProducer : public edm::ESProducer {
0039 public:
0040   HGCalGeometryESProducer(const edm::ParameterSet& iP);
0041   ~HGCalGeometryESProducer() override;
0042 
0043   using ReturnType = std::unique_ptr<HGCalGeometry>;
0044 
0045   ReturnType produce(const IdealGeometryRecord&);
0046 
0047 private:
0048   // ----------member data ---------------------------
0049   edm::ESGetToken<HGCalTopology, IdealGeometryRecord> topologyToken_;
0050   std::string name_;
0051 };
0052 
0053 HGCalGeometryESProducer::HGCalGeometryESProducer(const edm::ParameterSet& iConfig) {
0054   name_ = iConfig.getUntrackedParameter<std::string>("Name");
0055 #ifdef EDM_ML_DEBUG
0056   edm::LogVerbatim("HGCalGeom") << "Constructing HGCalGeometry for " << name_;
0057 #endif
0058   auto cc = setWhatProduced(this, name_);
0059   topologyToken_ = cc.consumes<HGCalTopology>(edm::ESInputTag{"", name_});
0060 }
0061 
0062 HGCalGeometryESProducer::~HGCalGeometryESProducer() {}
0063 
0064 //
0065 // member functions
0066 //
0067 
0068 // ------------ method called to produce the data  ------------
0069 HGCalGeometryESProducer::ReturnType HGCalGeometryESProducer::produce(const IdealGeometryRecord& iRecord) {
0070   const auto& topo = iRecord.get(topologyToken_);
0071   edm::LogVerbatim("HGCalGeom") << "Create HGCalGeometry (*topo) for " << name_;
0072 
0073   HGCalGeometryLoader builder;
0074   return ReturnType(builder.build(topo));
0075 }
0076 
0077 DEFINE_FWK_EVENTSETUP_MODULE(HGCalGeometryESProducer);