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:      DDCompactViewMFESProducer
0005 //
0006 /**\class DDCompactViewMFESProducer
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 //
0016 //
0017 
0018 #include <memory>
0019 
0020 #include "FWCore/Framework/interface/ModuleFactory.h"
0021 #include "FWCore/Framework/interface/ESProducer.h"
0022 #include "FWCore/Framework/interface/ESHandle.h"
0023 
0024 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0025 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0026 #include "DetectorDescription/DDCMS/interface/DDCompactView.h"
0027 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0028 #include "DetectorDescription/DDCMS/interface/DDDetector.h"
0029 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0030 #include "DD4hep/Detector.h"
0031 
0032 using namespace std;
0033 using namespace cms;
0034 
0035 class DDCompactViewMFESProducer : public edm::ESProducer, public edm::EventSetupRecordIntervalFinder {
0036 public:
0037   DDCompactViewMFESProducer(const edm::ParameterSet &);
0038   ~DDCompactViewMFESProducer() override;
0039 
0040   using ReturnType = unique_ptr<DDCompactView>;
0041 
0042   static void fillDescriptions(edm::ConfigurationDescriptions &);
0043 
0044   ReturnType produce(const IdealMagneticFieldRecord &);
0045 
0046 protected:
0047   void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &,
0048                       const edm::IOVSyncValue &,
0049                       edm::ValidityInterval &) override;
0050 
0051 private:
0052   const edm::ESGetToken<DDDetector, IdealMagneticFieldRecord> m_detToken;
0053 };
0054 
0055 DDCompactViewMFESProducer::DDCompactViewMFESProducer(const edm::ParameterSet &iConfig)
0056     : m_detToken(setWhatProduced(this).consumes<DDDetector>(
0057           edm::ESInputTag("", iConfig.getParameter<std::string>("appendToDataLabel")))) {
0058   findingRecord<IdealMagneticFieldRecord>();
0059 }
0060 
0061 DDCompactViewMFESProducer::~DDCompactViewMFESProducer() {}
0062 
0063 void DDCompactViewMFESProducer::fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
0064   edm::ParameterSetDescription desc;
0065   descriptions.addDefault(desc);
0066 }
0067 
0068 DDCompactViewMFESProducer::ReturnType DDCompactViewMFESProducer::produce(const IdealMagneticFieldRecord &iRecord) {
0069   auto product = std::make_unique<DDCompactView>(iRecord.get(m_detToken));
0070   return product;
0071 }
0072 
0073 void DDCompactViewMFESProducer::setIntervalFor(const edm::eventsetup::EventSetupRecordKey &,
0074                                                const edm::IOVSyncValue &iosv,
0075                                                edm::ValidityInterval &oValidity) {
0076   edm::ValidityInterval infinity(iosv.beginOfTime(), iosv.endOfTime());
0077   oValidity = infinity;
0078 }
0079 
0080 DEFINE_FWK_EVENTSETUP_MODULE(DDCompactViewMFESProducer);