Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:55:02

0001 // -*- C++ -*-
0002 //
0003 // Package:    DetectorDescription/DDCMS
0004 // Class:      DDSpecParRegistryESProducer
0005 //
0006 /**\class DDSpecParRegistryESProducer
0007 
0008  Description: Produce SpecPar registry
0009 
0010  Implementation:
0011      SpecPars are described in XML
0012 */
0013 //
0014 // Original Author:  Ianna Osborne
0015 //         Created:  Wed, 09 Jan 2019 16:04:31 GMT
0016 //
0017 //
0018 
0019 #include <memory>
0020 
0021 #include "FWCore/Framework/interface/ModuleFactory.h"
0022 #include "FWCore/Framework/interface/ESProducer.h"
0023 #include "FWCore/Framework/interface/ESHandle.h"
0024 
0025 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0026 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0027 #include "Geometry/Records/interface/DDSpecParRegistryRcd.h"
0028 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0029 #include "DetectorDescription/DDCMS/interface/DDDetector.h"
0030 #include <DD4hep/Detector.h>
0031 #include <DD4hep/SpecParRegistry.h>
0032 
0033 using namespace std;
0034 using namespace cms;
0035 
0036 class DDSpecParRegistryESProducer : public edm::ESProducer {
0037 public:
0038   DDSpecParRegistryESProducer(const edm::ParameterSet&);
0039   ~DDSpecParRegistryESProducer() override;
0040 
0041   using ReturnType = unique_ptr<dd4hep::SpecParRegistry>;
0042 
0043   static void fillDescriptions(edm::ConfigurationDescriptions&);
0044 
0045   ReturnType produce(const DDSpecParRegistryRcd&);
0046 
0047 private:
0048   const edm::ESGetToken<DDDetector, IdealGeometryRecord> m_token;
0049 };
0050 
0051 DDSpecParRegistryESProducer::DDSpecParRegistryESProducer(const edm::ParameterSet& iConfig)
0052     : m_token(
0053           setWhatProduced(this).consumes(edm::ESInputTag("", iConfig.getParameter<std::string>("appendToDataLabel")))) {
0054 }
0055 
0056 DDSpecParRegistryESProducer::~DDSpecParRegistryESProducer() {}
0057 
0058 void DDSpecParRegistryESProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0059   edm::ParameterSetDescription desc;
0060   descriptions.addDefault(desc);
0061 }
0062 
0063 DDSpecParRegistryESProducer::ReturnType DDSpecParRegistryESProducer::produce(const DDSpecParRegistryRcd& iRecord) {
0064   const dd4hep::SpecParRegistry& registry = iRecord.get(m_token).specpars();
0065   auto product = std::make_unique<dd4hep::SpecParRegistry>();
0066   product->specpars.insert(registry.specpars.begin(), registry.specpars.end());
0067   return product;
0068 }
0069 
0070 DEFINE_FWK_EVENTSETUP_MODULE(DDSpecParRegistryESProducer);