Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:49:25

0001 #ifndef HeterogeneousCore_CUDACore_interface_ConvertingESProducerT_h
0002 #define HeterogeneousCore_CUDACore_interface_ConvertingESProducerT_h
0003 
0004 #include "FWCore/Framework/interface/ESProducer.h"
0005 #include "FWCore/Framework/interface/ESTransientHandle.h"
0006 #include "FWCore/Framework/interface/MakerMacros.h"
0007 #include "FWCore/Framework/interface/ModuleFactory.h"
0008 #include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h"
0009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0010 #include "FWCore/Utilities/interface/typelookup.h"
0011 
0012 /* class template: ConvertingESProducerT
0013  * 
0014  * This class template can be used to simplify the implementation of any ESProducer that reads
0015  * conditions data from a record and pushes derived conditions data to the same record.
0016  * The current use case is to convert and copy the calibrations from the CPU to the GPUs.
0017  */
0018 
0019 template <typename Record, typename Target, typename Source>
0020 class ConvertingESProducerT : public edm::ESProducer {
0021 public:
0022   explicit ConvertingESProducerT(edm::ParameterSet const& ps) {
0023     auto const& label = ps.getParameter<std::string>("label");
0024     auto const& name = ps.getParameter<std::string>("ComponentName");
0025     auto cc = setWhatProduced(this, name);
0026     token_ = cc.consumes(edm::ESInputTag{"", label});
0027   }
0028 
0029   std::unique_ptr<Target> produce(Record const& record) {
0030     // retrieve conditions in the old format and build a product in the new format
0031     return std::make_unique<Target>(record.get(token_));
0032   }
0033 
0034   static void fillDescriptions(edm::ConfigurationDescriptions& confDesc) {
0035     edm::ParameterSetDescription desc;
0036 
0037     desc.add<std::string>("ComponentName", "");
0038     desc.add<std::string>("label", "")->setComment("ESProduct label");
0039     confDesc.addWithDefaultLabel(desc);
0040   }
0041 
0042 private:
0043   edm::ESGetToken<Source, Record> token_;
0044 };
0045 
0046 #endif  // HeterogeneousCore_CUDACore_interface_ConvertingESProducerT_h