Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-09-11 22:29:31

0001 // -*- C++ -*-
0002 //
0003 // Package:     FWCore/Framework
0004 // Class  :     one::EDFilterBase
0005 //
0006 // Implementation:
0007 //     [Notes on implementation]
0008 //
0009 // Original Author:  Chris Jones
0010 //         Created:  Thu, 02 May 2013 21:56:04 GMT
0011 //
0012 
0013 // system include files
0014 
0015 // user include files
0016 #include "FWCore/Framework/interface/one/EDFilterBase.h"
0017 #include "FWCore/Framework/interface/Event.h"
0018 #include "FWCore/Framework/interface/LuminosityBlock.h"
0019 #include "FWCore/Framework/interface/ProcessBlock.h"
0020 #include "FWCore/Framework/interface/Run.h"
0021 #include "FWCore/Framework/interface/EventSetup.h"
0022 #include "FWCore/Framework/src/edmodule_mightGet_config.h"
0023 #include "FWCore/Framework/interface/PreallocationConfiguration.h"
0024 #include "FWCore/Framework/src/EventSignalsSentry.h"
0025 #include "FWCore/Framework/interface/TransitionInfoTypes.h"
0026 #include "FWCore/Framework/interface/EventForTransformer.h"
0027 #include "FWCore/ServiceRegistry/interface/ESParentContext.h"
0028 
0029 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0030 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0031 
0032 //
0033 // constants, enums and typedefs
0034 //
0035 namespace edm {
0036   class ModuleCallingContext;
0037 
0038   namespace one {
0039     //
0040     // static data member definitions
0041     //
0042 
0043     //
0044     // constructors and destructor
0045     //
0046     EDFilterBase::EDFilterBase() : ProducerBase(), moduleDescription_(), previousParentage_(), previousParentageId_() {}
0047 
0048     EDFilterBase::~EDFilterBase() {}
0049 
0050     bool EDFilterBase::doEvent(EventTransitionInfo const& info,
0051                                ActivityRegistry* act,
0052                                ModuleCallingContext const* mcc) {
0053       Event e(info, moduleDescription_, mcc);
0054       e.setConsumer(this);
0055       e.setProducer(this, &previousParentage_);
0056       bool returnValue = true;
0057       e.setSharedResourcesAcquirer(&resourcesAcquirer_);
0058       EventSignalsSentry sentry(act, mcc);
0059       ESParentContext parentC(mcc);
0060       const EventSetup c{
0061           info, static_cast<unsigned int>(Transition::Event), esGetTokenIndices(Transition::Event), parentC};
0062       returnValue = this->filter(e, c);
0063       commit_(e, &previousParentageId_);
0064       return returnValue;
0065     }
0066 
0067     SharedResourcesAcquirer EDFilterBase::createAcquirer() {
0068       return SharedResourcesAcquirer{
0069           std::vector<std::shared_ptr<SerialTaskQueue>>(1, std::make_shared<SerialTaskQueue>())};
0070     }
0071 
0072     SerialTaskQueue* EDFilterBase::globalRunsQueue() { return nullptr; }
0073     SerialTaskQueue* EDFilterBase::globalLuminosityBlocksQueue() { return nullptr; };
0074 
0075     void EDFilterBase::doBeginJob() {
0076       resourcesAcquirer_ = createAcquirer();
0077 
0078       this->beginJob();
0079     }
0080 
0081     void EDFilterBase::doEndJob() { this->endJob(); }
0082 
0083     void EDFilterBase::doTransform(size_t iTransformIndex,
0084                                    EventPrincipal const& iEvent,
0085                                    ActivityRegistry*,
0086                                    ModuleCallingContext const* iMCC) {
0087       EventForTransformer ev(iEvent, iMCC);
0088       transform_(iTransformIndex, ev);
0089     }
0090 
0091     size_t EDFilterBase::transformIndex_(edm::BranchDescription const& iBranch) const { return -1; }
0092     ProductResolverIndex EDFilterBase::transformPrefetch_(std::size_t iIndex) const { return 0; }
0093     void EDFilterBase::transform_(std::size_t iIndex, edm::EventForTransformer& iEvent) const {}
0094 
0095     void EDFilterBase::doPreallocate(PreallocationConfiguration const& iPrealloc) {
0096       auto const nThreads = iPrealloc.numberOfThreads();
0097       preallocThreads(nThreads);
0098       preallocLumis(iPrealloc.numberOfLuminosityBlocks());
0099     }
0100     void EDFilterBase::preallocLumis(unsigned int){};
0101 
0102     void EDFilterBase::doBeginProcessBlock(ProcessBlockPrincipal const& pbp, ModuleCallingContext const* mcc) {
0103       ProcessBlock processBlock(pbp, moduleDescription_, mcc, false);
0104       processBlock.setConsumer(this);
0105       ProcessBlock const& constProcessBlock = processBlock;
0106       this->doBeginProcessBlock_(constProcessBlock);
0107       processBlock.setProducer(this);
0108       this->doBeginProcessBlockProduce_(processBlock);
0109       commit_(processBlock);
0110     }
0111 
0112     void EDFilterBase::doAccessInputProcessBlock(ProcessBlockPrincipal const& pbp, ModuleCallingContext const* mcc) {
0113       ProcessBlock processBlock(pbp, moduleDescription_, mcc, false);
0114       processBlock.setConsumer(this);
0115       ProcessBlock const& constProcessBlock = processBlock;
0116       this->doAccessInputProcessBlock_(constProcessBlock);
0117     }
0118 
0119     void EDFilterBase::doEndProcessBlock(ProcessBlockPrincipal const& pbp, ModuleCallingContext const* mcc) {
0120       ProcessBlock processBlock(pbp, moduleDescription_, mcc, true);
0121       processBlock.setConsumer(this);
0122       ProcessBlock const& constProcessBlock = processBlock;
0123       this->doEndProcessBlock_(constProcessBlock);
0124       processBlock.setProducer(this);
0125       this->doEndProcessBlockProduce_(processBlock);
0126       commit_(processBlock);
0127     }
0128 
0129     void EDFilterBase::doBeginRun(RunTransitionInfo const& info, ModuleCallingContext const* mcc) {
0130       Run r(info, moduleDescription_, mcc, false);
0131       r.setConsumer(this);
0132       Run const& cnstR = r;
0133       ESParentContext parentC(mcc);
0134       const EventSetup c{
0135           info, static_cast<unsigned int>(Transition::BeginRun), esGetTokenIndices(Transition::BeginRun), parentC};
0136       this->doBeginRun_(cnstR, c);
0137       r.setProducer(this);
0138       this->doBeginRunProduce_(r, c);
0139       commit_(r);
0140     }
0141 
0142     void EDFilterBase::doEndRun(RunTransitionInfo const& info, ModuleCallingContext const* mcc) {
0143       Run r(info, moduleDescription_, mcc, true);
0144       r.setConsumer(this);
0145       Run const& cnstR = r;
0146       ESParentContext parentC(mcc);
0147       const EventSetup c{
0148           info, static_cast<unsigned int>(Transition::EndRun), esGetTokenIndices(Transition::EndRun), parentC};
0149       this->doEndRun_(cnstR, c);
0150       r.setProducer(this);
0151       this->doEndRunProduce_(r, c);
0152       commit_(r);
0153     }
0154 
0155     void EDFilterBase::doBeginLuminosityBlock(LumiTransitionInfo const& info, ModuleCallingContext const* mcc) {
0156       LuminosityBlock lb(info, moduleDescription_, mcc, false);
0157       lb.setConsumer(this);
0158       LuminosityBlock const& cnstLb = lb;
0159       ESParentContext parentC(mcc);
0160       const EventSetup c{info,
0161                          static_cast<unsigned int>(Transition::BeginLuminosityBlock),
0162                          esGetTokenIndices(Transition::BeginLuminosityBlock),
0163                          parentC};
0164       this->doBeginLuminosityBlock_(cnstLb, c);
0165       lb.setProducer(this);
0166       this->doBeginLuminosityBlockProduce_(lb, c);
0167       commit_(lb);
0168     }
0169 
0170     void EDFilterBase::doEndLuminosityBlock(LumiTransitionInfo const& info, ModuleCallingContext const* mcc) {
0171       LuminosityBlock lb(info, moduleDescription_, mcc, true);
0172       lb.setConsumer(this);
0173       LuminosityBlock const& cnstLb = lb;
0174       ESParentContext parentC(mcc);
0175       const EventSetup c{info,
0176                          static_cast<unsigned int>(Transition::EndLuminosityBlock),
0177                          esGetTokenIndices(Transition::EndLuminosityBlock),
0178                          parentC};
0179       this->doEndLuminosityBlock_(cnstLb, c);
0180       lb.setProducer(this);
0181       this->doEndLuminosityBlockProduce_(lb, c);
0182       commit_(lb);
0183     }
0184 
0185     void EDFilterBase::doBeginProcessBlock_(ProcessBlock const&) {}
0186     void EDFilterBase::doAccessInputProcessBlock_(ProcessBlock const&) {}
0187     void EDFilterBase::doEndProcessBlock_(ProcessBlock const&) {}
0188     void EDFilterBase::doBeginRun_(Run const& rp, EventSetup const& c) {}
0189     void EDFilterBase::doEndRun_(Run const& rp, EventSetup const& c) {}
0190     void EDFilterBase::doBeginLuminosityBlock_(LuminosityBlock const& lbp, EventSetup const& c) {}
0191     void EDFilterBase::doEndLuminosityBlock_(LuminosityBlock const& lbp, EventSetup const& c) {}
0192 
0193     void EDFilterBase::doBeginProcessBlockProduce_(ProcessBlock&) {}
0194     void EDFilterBase::doEndProcessBlockProduce_(ProcessBlock&) {}
0195     void EDFilterBase::doBeginRunProduce_(Run& rp, EventSetup const& c) {}
0196     void EDFilterBase::doEndRunProduce_(Run& rp, EventSetup const& c) {}
0197     void EDFilterBase::doBeginLuminosityBlockProduce_(LuminosityBlock& lbp, EventSetup const& c) {}
0198     void EDFilterBase::doEndLuminosityBlockProduce_(LuminosityBlock& lbp, EventSetup const& c) {}
0199 
0200     void EDFilterBase::clearInputProcessBlockCaches() {}
0201 
0202     void EDFilterBase::fillDescriptions(ConfigurationDescriptions& descriptions) {
0203       ParameterSetDescription desc;
0204       desc.setUnknown();
0205       descriptions.addDefault(desc);
0206     }
0207 
0208     void EDFilterBase::prevalidate(ConfigurationDescriptions& iConfig) { edmodule_mightGet_config(iConfig); }
0209 
0210     static const std::string kBaseType("EDFilter");
0211 
0212     const std::string& EDFilterBase::baseType() { return kBaseType; }
0213 
0214   }  // namespace one
0215 }  // namespace edm