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/Core
0004 // Class:      DDCompactViewESProducer
0005 //
0006 /**\class DDCompactViewESProducer
0007 
0008  Description: Produce DDCompactView
0009 
0010  Implementation:
0011      Allow users view a DDDetector as a legacy compact view
0012 */
0013 //
0014 // Original Author:  Ianna Osborne
0015 //         Created:  Wed, 22 May 2019 14:32:49 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/IdealGeometryRecord.h"
0028 #include "DetectorDescription/DDCMS/interface/DDCompactView.h"
0029 #include "DetectorDescription/DDCMS/interface/DDDetector.h"
0030 #include "DD4hep/Detector.h"
0031 
0032 using namespace std;
0033 using namespace cms;
0034 
0035 class DDCompactViewESProducer : public edm::ESProducer {
0036 public:
0037   DDCompactViewESProducer(const edm::ParameterSet&);
0038   ~DDCompactViewESProducer() override;
0039 
0040   using ReturnType = unique_ptr<DDCompactView>;
0041 
0042   static void fillDescriptions(edm::ConfigurationDescriptions&);
0043 
0044   ReturnType produce(const IdealGeometryRecord&);
0045 
0046 private:
0047   const edm::ESGetToken<DDDetector, IdealGeometryRecord> m_detToken;
0048 };
0049 
0050 DDCompactViewESProducer::DDCompactViewESProducer(const edm::ParameterSet& iConfig)
0051     : m_detToken(setWhatProduced(this).consumes<DDDetector>(
0052           edm::ESInputTag("", iConfig.getParameter<std::string>("appendToDataLabel")))) {}
0053 
0054 DDCompactViewESProducer::~DDCompactViewESProducer() {}
0055 
0056 void DDCompactViewESProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0057   edm::ParameterSetDescription desc;
0058   descriptions.addDefault(desc);
0059 }
0060 
0061 DDCompactViewESProducer::ReturnType DDCompactViewESProducer::produce(const IdealGeometryRecord& iRecord) {
0062   auto product = std::make_unique<DDCompactView>(iRecord.get(m_detToken));
0063   return product;
0064 }
0065 
0066 DEFINE_FWK_EVENTSETUP_MODULE(DDCompactViewESProducer);