Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:28:04

0001 #include "CondFormats/DataRecord/interface/BeamSpotObjectsRcd.h"
0002 #include "CondFormats/BeamSpotObjects/interface/BeamSpotObjects.h"
0003 #include "CondFormats/DataRecord/interface/BeamSpotTransientObjectsRcd.h"
0004 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0005 #include "FWCore/Framework/interface/ESProductHost.h"
0006 #include "FWCore/Utilities/interface/ReusableObjectHolder.h"
0007 #include "FWCore/Framework/interface/ESProducer.h"
0008 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0009 
0010 #include "FWCore/Framework/interface/EventSetup.h"
0011 #include "FWCore/Framework/interface/ESHandle.h"
0012 #include "FWCore/Framework/interface/ModuleFactory.h"
0013 #include "FWCore/Framework/interface/ESProducer.h"
0014 #include "FWCore/Utilities/interface/do_nothing_deleter.h"
0015 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0016 
0017 #include <iostream>
0018 #include <memory>
0019 #include <string>
0020 
0021 using namespace edm;
0022 class OfflineToTransientBeamSpotESProducer : public edm::ESProducer {
0023 public:
0024   OfflineToTransientBeamSpotESProducer(const edm::ParameterSet& p);
0025   std::shared_ptr<const BeamSpotObjects> produce(const BeamSpotTransientObjectsRcd&);
0026   static void fillDescriptions(edm::ConfigurationDescriptions& desc);
0027 
0028 private:
0029   const BeamSpotObjects dummyBS_;
0030   edm::ESGetToken<BeamSpotObjects, BeamSpotTransientObjectsRcd> const bsToken_;
0031   edm::ESGetToken<BeamSpotObjects, BeamSpotObjectsRcd> bsOfflineToken_;
0032 };
0033 
0034 OfflineToTransientBeamSpotESProducer::OfflineToTransientBeamSpotESProducer(const edm::ParameterSet& p) {
0035   auto cc = setWhatProduced(this);
0036 
0037   bsOfflineToken_ = cc.consumesFrom<BeamSpotObjects, BeamSpotObjectsRcd>();
0038 }
0039 
0040 void OfflineToTransientBeamSpotESProducer::fillDescriptions(edm::ConfigurationDescriptions& desc) {
0041   edm::ParameterSetDescription dsc;
0042   desc.addWithDefaultLabel(dsc);
0043 }
0044 std::shared_ptr<const BeamSpotObjects> OfflineToTransientBeamSpotESProducer::produce(
0045     const BeamSpotTransientObjectsRcd& iRecord) {
0046   auto optionalRec = iRecord.tryToGetRecord<BeamSpotObjectsRcd>();
0047   if (not optionalRec) {
0048     return std::shared_ptr<const BeamSpotObjects>(&dummyBS_, edm::do_nothing_deleter());
0049   }
0050   return std::shared_ptr<const BeamSpotObjects>(&optionalRec->get(bsOfflineToken_), edm::do_nothing_deleter());
0051 };
0052 
0053 DEFINE_FWK_EVENTSETUP_MODULE(OfflineToTransientBeamSpotESProducer);