HcalSimulationConstantsESModule

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
// -*- C++ -*-
//
// Package:    HcalSimulationConstantsESModule
// Class:      HcalSimulationConstantsESModule
//
/**\class HcalSimulationConstantsESModule Geometry/HcalCommonData/plugins/HcalSimulationConstantsESModule.cc

 Description: <one line class summary>

 Implementation:
     <Notes on implementation>
*/
//
// Original Author:  Sunanda Banerjee
//         Created:  Mon Aug 12 16:40:29 PDT 2019
//
//

#include <memory>

#include <FWCore/Framework/interface/ModuleFactory.h>
#include <FWCore/Framework/interface/ESProducer.h>
#include <FWCore/MessageLogger/interface/MessageLogger.h>

#include <Geometry/HcalCommonData/interface/HcalSimulationConstants.h>
#include <Geometry/Records/interface/HcalSimNumberingRecord.h>

//#define EDM_ML_DEBUG

class HcalSimulationConstantsESModule : public edm::ESProducer {
public:
  HcalSimulationConstantsESModule(const edm::ParameterSet&);

  using ReturnType = std::unique_ptr<HcalSimulationConstants>;

  static void fillDescriptions(edm::ConfigurationDescriptions&);

  ReturnType produce(const HcalSimNumberingRecord&);

private:
  edm::ESGetToken<HcalSimulationParameters, HcalParametersRcd> parSimToken_;
};

HcalSimulationConstantsESModule::HcalSimulationConstantsESModule(const edm::ParameterSet&) {
#ifdef EDM_ML_DEBUG
  edm::LogVerbatim("HCalGeom") << "constructing HcalSimulationConstantsESModule";
#endif
  auto cc = setWhatProduced(this);
  parSimToken_ = cc.consumesFrom<HcalSimulationParameters, HcalParametersRcd>(edm::ESInputTag{});
}

void HcalSimulationConstantsESModule::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
  edm::ParameterSetDescription desc;
  descriptions.add("hcalSimulationConstants", desc);
}

// ------------ method called to produce the data  ------------
HcalSimulationConstantsESModule::ReturnType HcalSimulationConstantsESModule::produce(
    const HcalSimNumberingRecord& iRecord) {
  const auto& parSim = iRecord.get(parSimToken_);
  return std::make_unique<HcalSimulationConstants>(&parSim);
}

//define this as a plug-in
DEFINE_FWK_EVENTSETUP_MODULE(HcalSimulationConstantsESModule);