Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-10-18 04:13:19

0001 // -*- C++ -*-
0002 //
0003 // Package:     FWCore/Framework
0004 // Class  :     one::EDProducerBase
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/EDProducerBase.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 
0037   namespace one {
0038     //
0039     // static data member definitions
0040     //
0041 
0042     //
0043     // constructors and destructor
0044     //
0045     EDProducerBase::EDProducerBase()
0046         : ProducerBase(), moduleDescription_(), previousParentage_(), previousParentageId_() {}
0047 
0048     EDProducerBase::~EDProducerBase() {}
0049 
0050     bool EDProducerBase::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       e.setSharedResourcesAcquirer(&resourcesAcquirer_);
0057       EventSignalsSentry sentry(act, mcc);
0058       ESParentContext parentC(mcc);
0059       const EventSetup c{
0060           info, static_cast<unsigned int>(Transition::Event), esGetTokenIndices(Transition::Event), parentC};
0061       this->produce(e, c);
0062       commit_(e, &previousParentageId_);
0063       return true;
0064     }
0065 
0066     SharedResourcesAcquirer EDProducerBase::createAcquirer() {
0067       return SharedResourcesAcquirer{
0068           std::vector<std::shared_ptr<SerialTaskQueue>>(1, std::make_shared<SerialTaskQueue>())};
0069     }
0070 
0071     SerialTaskQueue* EDProducerBase::globalRunsQueue() { return nullptr; }
0072     SerialTaskQueue* EDProducerBase::globalLuminosityBlocksQueue() { return nullptr; };
0073 
0074     void EDProducerBase::doTransformAsync(WaitingTaskHolder iTask,
0075                                           size_t iTransformIndex,
0076                                           EventPrincipal const& iEvent,
0077                                           ActivityRegistry*,
0078                                           ModuleCallingContext const* iMCC,
0079                                           ServiceWeakToken const& iToken) {
0080       EventForTransformer ev(iEvent, iMCC);
0081       transformAsync_(iTask, iTransformIndex, ev, iToken);
0082     }
0083 
0084     size_t EDProducerBase::transformIndex_(edm::BranchDescription const& iBranch) const { return -1; }
0085     ProductResolverIndex EDProducerBase::transformPrefetch_(std::size_t iIndex) const { return 0; }
0086     void EDProducerBase::transformAsync_(WaitingTaskHolder iTask,
0087                                          std::size_t iIndex,
0088                                          edm::EventForTransformer& iEvent,
0089                                          ServiceWeakToken const& iToken) const {}
0090 
0091     void EDProducerBase::doBeginJob() {
0092       resourcesAcquirer_ = createAcquirer();
0093 
0094       this->beginJob();
0095     }
0096 
0097     void EDProducerBase::doEndJob() { this->endJob(); }
0098 
0099     void EDProducerBase::doPreallocate(PreallocationConfiguration const& iPrealloc) {
0100       auto const nThreads = iPrealloc.numberOfThreads();
0101       preallocThreads(nThreads);
0102       preallocRuns(iPrealloc.numberOfRuns());
0103       preallocLumis(iPrealloc.numberOfLuminosityBlocks());
0104     }
0105 
0106     void EDProducerBase::preallocRuns(unsigned int) {}
0107     void EDProducerBase::preallocLumis(unsigned int) {}
0108 
0109     void EDProducerBase::doBeginProcessBlock(ProcessBlockPrincipal const& pbp, ModuleCallingContext const* mcc) {
0110       ProcessBlock processBlock(pbp, moduleDescription_, mcc, false);
0111       processBlock.setConsumer(this);
0112       ProcessBlock const& constProcessBlock = processBlock;
0113       this->doBeginProcessBlock_(constProcessBlock);
0114       processBlock.setProducer(this);
0115       this->doBeginProcessBlockProduce_(processBlock);
0116       commit_(processBlock);
0117     }
0118 
0119     void EDProducerBase::doAccessInputProcessBlock(ProcessBlockPrincipal const& pbp, ModuleCallingContext const* mcc) {
0120       ProcessBlock processBlock(pbp, moduleDescription_, mcc, false);
0121       processBlock.setConsumer(this);
0122       ProcessBlock const& constProcessBlock = processBlock;
0123       this->doAccessInputProcessBlock_(constProcessBlock);
0124     }
0125 
0126     void EDProducerBase::doEndProcessBlock(ProcessBlockPrincipal const& pbp, ModuleCallingContext const* mcc) {
0127       ProcessBlock processBlock(pbp, moduleDescription_, mcc, true);
0128       processBlock.setConsumer(this);
0129       ProcessBlock const& constProcessBlock = processBlock;
0130       this->doEndProcessBlock_(constProcessBlock);
0131       processBlock.setProducer(this);
0132       this->doEndProcessBlockProduce_(processBlock);
0133       commit_(processBlock);
0134     }
0135 
0136     void EDProducerBase::doBeginRun(RunTransitionInfo const& info, ModuleCallingContext const* mcc) {
0137       Run r(info, moduleDescription_, mcc, false);
0138       r.setConsumer(this);
0139       Run const& cnstR = r;
0140       ESParentContext parentC(mcc);
0141       const EventSetup c{
0142           info, static_cast<unsigned int>(Transition::BeginRun), esGetTokenIndices(Transition::BeginRun), parentC};
0143       this->doBeginRun_(cnstR, c);
0144       r.setProducer(this);
0145       this->doBeginRunProduce_(r, c);
0146       commit_(r);
0147     }
0148 
0149     void EDProducerBase::doEndRun(RunTransitionInfo const& info, ModuleCallingContext const* mcc) {
0150       Run r(info, moduleDescription_, mcc, true);
0151       r.setConsumer(this);
0152       Run const& cnstR = r;
0153       r.setProducer(this);
0154       ESParentContext parentC(mcc);
0155       const EventSetup c{
0156           info, static_cast<unsigned int>(Transition::EndRun), esGetTokenIndices(Transition::EndRun), parentC};
0157       this->doEndRunProduce_(r, c);
0158       this->doEndRun_(cnstR, c);
0159       commit_(r);
0160     }
0161 
0162     void EDProducerBase::doBeginLuminosityBlock(LumiTransitionInfo const& info, ModuleCallingContext const* mcc) {
0163       LuminosityBlock lb(info, moduleDescription_, mcc, false);
0164       lb.setConsumer(this);
0165       LuminosityBlock const& cnstLb = lb;
0166       ESParentContext parentC(mcc);
0167       const EventSetup c{info,
0168                          static_cast<unsigned int>(Transition::BeginLuminosityBlock),
0169                          esGetTokenIndices(Transition::BeginLuminosityBlock),
0170                          parentC};
0171       this->doBeginLuminosityBlock_(cnstLb, c);
0172       lb.setProducer(this);
0173       this->doBeginLuminosityBlockProduce_(lb, c);
0174       commit_(lb);
0175     }
0176 
0177     void EDProducerBase::doEndLuminosityBlock(LumiTransitionInfo const& info, ModuleCallingContext const* mcc) {
0178       LuminosityBlock lb(info, moduleDescription_, mcc, true);
0179       lb.setConsumer(this);
0180       lb.setProducer(this);
0181       ESParentContext parentC(mcc);
0182       const EventSetup c{info,
0183                          static_cast<unsigned int>(Transition::EndLuminosityBlock),
0184                          esGetTokenIndices(Transition::EndLuminosityBlock),
0185                          parentC};
0186       this->doEndLuminosityBlockProduce_(lb, c);
0187       LuminosityBlock const& cnstLb = lb;
0188       this->doEndLuminosityBlock_(cnstLb, c);
0189       commit_(lb);
0190     }
0191 
0192     void EDProducerBase::doBeginProcessBlock_(ProcessBlock const&) {}
0193     void EDProducerBase::doAccessInputProcessBlock_(ProcessBlock const&) {}
0194     void EDProducerBase::doEndProcessBlock_(ProcessBlock const&) {}
0195     void EDProducerBase::doBeginRun_(Run const& rp, EventSetup const& c) {}
0196     void EDProducerBase::doEndRun_(Run const& rp, EventSetup const& c) {}
0197     void EDProducerBase::doBeginLuminosityBlock_(LuminosityBlock const& lbp, EventSetup const& c) {}
0198     void EDProducerBase::doEndLuminosityBlock_(LuminosityBlock const& lbp, EventSetup const& c) {}
0199 
0200     void EDProducerBase::doBeginProcessBlockProduce_(ProcessBlock&) {}
0201     void EDProducerBase::doEndProcessBlockProduce_(ProcessBlock&) {}
0202     void EDProducerBase::doBeginRunProduce_(Run& rp, EventSetup const& c) {}
0203     void EDProducerBase::doEndRunProduce_(Run& rp, EventSetup const& c) {}
0204     void EDProducerBase::doBeginLuminosityBlockProduce_(LuminosityBlock& lbp, EventSetup const& c) {}
0205     void EDProducerBase::doEndLuminosityBlockProduce_(LuminosityBlock& lbp, EventSetup const& c) {}
0206 
0207     void EDProducerBase::clearInputProcessBlockCaches() {}
0208 
0209     void EDProducerBase::fillDescriptions(ConfigurationDescriptions& descriptions) {
0210       ParameterSetDescription desc;
0211       desc.setUnknown();
0212       descriptions.addDefault(desc);
0213     }
0214 
0215     void EDProducerBase::prevalidate(ConfigurationDescriptions& iConfig) { edmodule_mightGet_config(iConfig); }
0216 
0217     static const std::string kBaseType("EDProducer");
0218 
0219     const std::string& EDProducerBase::baseType() { return kBaseType; }
0220 
0221   }  // namespace one
0222 }  // namespace edm