Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-14 11:45:08

0001 /*----------------------------------------------------------------------
0002   
0003 
0004 ----------------------------------------------------------------------*/
0005 
0006 #include "FWCore/Framework/interface/EDProducer.h"
0007 #include "FWCore/Framework/interface/Event.h"
0008 #include "FWCore/Framework/interface/LuminosityBlock.h"
0009 #include "FWCore/Framework/interface/Run.h"
0010 #include "FWCore/Framework/interface/EventSetup.h"
0011 #include "FWCore/Framework/src/edmodule_mightGet_config.h"
0012 #include "FWCore/Framework/src/EventSignalsSentry.h"
0013 #include "FWCore/Framework/interface/TransitionInfoTypes.h"
0014 #include "FWCore/ServiceRegistry/interface/ESParentContext.h"
0015 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0016 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0017 
0018 #include "FWCore/Framework/interface/SharedResourcesRegistry.h"
0019 
0020 namespace edm {
0021   EDProducer::EDProducer() : ProducerBase(), moduleDescription_(), previousParentage_(), previousParentageId_() {
0022     SharedResourcesRegistry::instance()->registerSharedResource(SharedResourcesRegistry::kLegacyModuleResourceName);
0023   }
0024 
0025   EDProducer::~EDProducer() {}
0026 
0027   bool EDProducer::doEvent(EventTransitionInfo const& info, ActivityRegistry* act, ModuleCallingContext const* mcc) {
0028     Event e(info, moduleDescription_, mcc);
0029     e.setConsumer(this);
0030     e.setProducer(this, &previousParentage_);
0031     e.setSharedResourcesAcquirer(&resourceAcquirer_);
0032     EventSignalsSentry sentry(act, mcc);
0033     ESParentContext parentC(mcc);
0034     const EventSetup c{
0035         info, static_cast<unsigned int>(Transition::Event), esGetTokenIndices(Transition::Event), parentC};
0036     this->produce(e, c);
0037     commit_(e, &previousParentageId_);
0038     return true;
0039   }
0040 
0041   void EDProducer::doBeginJob() {
0042     std::vector<std::string> res = {SharedResourcesRegistry::kLegacyModuleResourceName};
0043     resourceAcquirer_ = SharedResourcesRegistry::instance()->createAcquirer(res);
0044     this->beginJob();
0045   }
0046 
0047   void EDProducer::doEndJob() { this->endJob(); }
0048 
0049   void EDProducer::doBeginRun(RunTransitionInfo const& info, ModuleCallingContext const* mcc) {
0050     Run r(info, moduleDescription_, mcc, false);
0051     r.setConsumer(this);
0052     Run const& cnstR = r;
0053     ESParentContext parentC(mcc);
0054     const EventSetup c{
0055         info, static_cast<unsigned int>(Transition::BeginRun), esGetTokenIndices(Transition::BeginRun), parentC};
0056     this->beginRun(cnstR, c);
0057     commit_(r);
0058   }
0059 
0060   void EDProducer::doEndRun(RunTransitionInfo const& info, ModuleCallingContext const* mcc) {
0061     Run r(info, moduleDescription_, mcc, true);
0062     r.setConsumer(this);
0063     Run const& cnstR = r;
0064     ESParentContext parentC(mcc);
0065     const EventSetup c{
0066         info, static_cast<unsigned int>(Transition::EndRun), esGetTokenIndices(Transition::EndRun), parentC};
0067     this->endRun(cnstR, c);
0068     commit_(r);
0069   }
0070 
0071   void EDProducer::doBeginLuminosityBlock(LumiTransitionInfo const& info, ModuleCallingContext const* mcc) {
0072     LuminosityBlock lb(info, moduleDescription_, mcc, false);
0073     lb.setConsumer(this);
0074     LuminosityBlock const& cnstLb = lb;
0075     ESParentContext parentC(mcc);
0076     const EventSetup c{info,
0077                        static_cast<unsigned int>(Transition::BeginLuminosityBlock),
0078                        esGetTokenIndices(Transition::BeginLuminosityBlock),
0079                        parentC};
0080     this->beginLuminosityBlock(cnstLb, c);
0081     commit_(lb);
0082   }
0083 
0084   void EDProducer::doEndLuminosityBlock(LumiTransitionInfo const& info, ModuleCallingContext const* mcc) {
0085     LuminosityBlock lb(info, moduleDescription_, mcc, true);
0086     lb.setConsumer(this);
0087     ESParentContext parentC(mcc);
0088     const EventSetup c{info,
0089                        static_cast<unsigned int>(Transition::EndLuminosityBlock),
0090                        esGetTokenIndices(Transition::EndLuminosityBlock),
0091                        parentC};
0092     LuminosityBlock const& cnstLb = lb;
0093     this->endLuminosityBlock(cnstLb, c);
0094     commit_(lb);
0095   }
0096 
0097   void EDProducer::doRespondToOpenInputFile(FileBlock const& fb) { respondToOpenInputFile(fb); }
0098 
0099   void EDProducer::doRespondToCloseInputFile(FileBlock const& fb) { respondToCloseInputFile(fb); }
0100 
0101   void EDProducer::fillDescriptions(ConfigurationDescriptions& descriptions) {
0102     ParameterSetDescription desc;
0103     desc.setUnknown();
0104     descriptions.addDefault(desc);
0105   }
0106 
0107   void EDProducer::prevalidate(ConfigurationDescriptions& iConfig) { edmodule_mightGet_config(iConfig); }
0108 
0109   static const std::string kBaseType("EDProducer");
0110 
0111   const std::string& EDProducer::baseType() { return kBaseType; }
0112 }  // namespace edm