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