File indexing completed on 2024-11-19 23:20:03
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
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
0034
0035 namespace edm {
0036
0037 namespace one {
0038
0039
0040
0041
0042
0043
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 EventSignalsSentry sentry(act, mcc);
0054 Event e(info, moduleDescription_, mcc);
0055 e.setConsumer(this);
0056 e.setProducer(this, &previousParentage_);
0057 e.setSharedResourcesAcquirer(&resourcesAcquirer_);
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* iAct,
0078 ModuleCallingContext iMCC,
0079 ServiceWeakToken const& iToken) noexcept {
0080 EventForTransformer ev(iEvent, iMCC);
0081 transformAsync_(iTask, iTransformIndex, ev, iAct, iToken);
0082 }
0083
0084 size_t EDProducerBase::transformIndex_(edm::BranchDescription const& iBranch) const noexcept { return -1; }
0085 ProductResolverIndex EDProducerBase::transformPrefetch_(std::size_t iIndex) const noexcept { return 0; }
0086 void EDProducerBase::transformAsync_(WaitingTaskHolder iTask,
0087 std::size_t iIndex,
0088 edm::EventForTransformer& iEvent,
0089 edm::ActivityRegistry* iAct,
0090 ServiceWeakToken const& iToken) const noexcept {}
0091
0092 void EDProducerBase::doBeginJob() {
0093 resourcesAcquirer_ = createAcquirer();
0094
0095 this->beginJob();
0096 }
0097
0098 void EDProducerBase::doEndJob() { this->endJob(); }
0099
0100 void EDProducerBase::doPreallocate(PreallocationConfiguration const& iPrealloc) {
0101 auto const nThreads = iPrealloc.numberOfThreads();
0102 preallocThreads(nThreads);
0103 preallocRuns(iPrealloc.numberOfRuns());
0104 preallocLumis(iPrealloc.numberOfLuminosityBlocks());
0105 }
0106
0107 void EDProducerBase::preallocRuns(unsigned int) {}
0108 void EDProducerBase::preallocLumis(unsigned int) {}
0109
0110 void EDProducerBase::doBeginProcessBlock(ProcessBlockPrincipal const& pbp, ModuleCallingContext const* mcc) {
0111 ProcessBlock processBlock(pbp, moduleDescription_, mcc, false);
0112 processBlock.setConsumer(this);
0113 ProcessBlock const& constProcessBlock = processBlock;
0114 this->doBeginProcessBlock_(constProcessBlock);
0115 processBlock.setProducer(this);
0116 this->doBeginProcessBlockProduce_(processBlock);
0117 commit_(processBlock);
0118 }
0119
0120 void EDProducerBase::doAccessInputProcessBlock(ProcessBlockPrincipal const& pbp, ModuleCallingContext const* mcc) {
0121 ProcessBlock processBlock(pbp, moduleDescription_, mcc, false);
0122 processBlock.setConsumer(this);
0123 ProcessBlock const& constProcessBlock = processBlock;
0124 this->doAccessInputProcessBlock_(constProcessBlock);
0125 }
0126
0127 void EDProducerBase::doEndProcessBlock(ProcessBlockPrincipal const& pbp, ModuleCallingContext const* mcc) {
0128 ProcessBlock processBlock(pbp, moduleDescription_, mcc, true);
0129 processBlock.setConsumer(this);
0130 ProcessBlock const& constProcessBlock = processBlock;
0131 this->doEndProcessBlock_(constProcessBlock);
0132 processBlock.setProducer(this);
0133 this->doEndProcessBlockProduce_(processBlock);
0134 commit_(processBlock);
0135 }
0136
0137 void EDProducerBase::doBeginRun(RunTransitionInfo const& info, ModuleCallingContext const* mcc) {
0138 Run r(info, moduleDescription_, mcc, false);
0139 r.setConsumer(this);
0140 Run const& cnstR = r;
0141 ESParentContext parentC(mcc);
0142 const EventSetup c{
0143 info, static_cast<unsigned int>(Transition::BeginRun), esGetTokenIndices(Transition::BeginRun), parentC};
0144 this->doBeginRun_(cnstR, c);
0145 r.setProducer(this);
0146 this->doBeginRunProduce_(r, c);
0147 commit_(r);
0148 }
0149
0150 void EDProducerBase::doEndRun(RunTransitionInfo const& info, ModuleCallingContext const* mcc) {
0151 Run r(info, moduleDescription_, mcc, true);
0152 r.setConsumer(this);
0153 Run const& cnstR = r;
0154 r.setProducer(this);
0155 ESParentContext parentC(mcc);
0156 const EventSetup c{
0157 info, static_cast<unsigned int>(Transition::EndRun), esGetTokenIndices(Transition::EndRun), parentC};
0158 this->doEndRunProduce_(r, c);
0159 this->doEndRun_(cnstR, c);
0160 commit_(r);
0161 }
0162
0163 void EDProducerBase::doBeginLuminosityBlock(LumiTransitionInfo const& info, ModuleCallingContext const* mcc) {
0164 LuminosityBlock lb(info, moduleDescription_, mcc, false);
0165 lb.setConsumer(this);
0166 LuminosityBlock const& cnstLb = lb;
0167 ESParentContext parentC(mcc);
0168 const EventSetup c{info,
0169 static_cast<unsigned int>(Transition::BeginLuminosityBlock),
0170 esGetTokenIndices(Transition::BeginLuminosityBlock),
0171 parentC};
0172 this->doBeginLuminosityBlock_(cnstLb, c);
0173 lb.setProducer(this);
0174 this->doBeginLuminosityBlockProduce_(lb, c);
0175 commit_(lb);
0176 }
0177
0178 void EDProducerBase::doEndLuminosityBlock(LumiTransitionInfo const& info, ModuleCallingContext const* mcc) {
0179 LuminosityBlock lb(info, moduleDescription_, mcc, true);
0180 lb.setConsumer(this);
0181 lb.setProducer(this);
0182 ESParentContext parentC(mcc);
0183 const EventSetup c{info,
0184 static_cast<unsigned int>(Transition::EndLuminosityBlock),
0185 esGetTokenIndices(Transition::EndLuminosityBlock),
0186 parentC};
0187 this->doEndLuminosityBlockProduce_(lb, c);
0188 LuminosityBlock const& cnstLb = lb;
0189 this->doEndLuminosityBlock_(cnstLb, c);
0190 commit_(lb);
0191 }
0192
0193 void EDProducerBase::doBeginProcessBlock_(ProcessBlock const&) {}
0194 void EDProducerBase::doAccessInputProcessBlock_(ProcessBlock const&) {}
0195 void EDProducerBase::doEndProcessBlock_(ProcessBlock const&) {}
0196 void EDProducerBase::doBeginRun_(Run const& rp, EventSetup const& c) {}
0197 void EDProducerBase::doEndRun_(Run const& rp, EventSetup const& c) {}
0198 void EDProducerBase::doBeginLuminosityBlock_(LuminosityBlock const& lbp, EventSetup const& c) {}
0199 void EDProducerBase::doEndLuminosityBlock_(LuminosityBlock const& lbp, EventSetup const& c) {}
0200
0201 void EDProducerBase::doBeginProcessBlockProduce_(ProcessBlock&) {}
0202 void EDProducerBase::doEndProcessBlockProduce_(ProcessBlock&) {}
0203 void EDProducerBase::doBeginRunProduce_(Run& rp, EventSetup const& c) {}
0204 void EDProducerBase::doEndRunProduce_(Run& rp, EventSetup const& c) {}
0205 void EDProducerBase::doBeginLuminosityBlockProduce_(LuminosityBlock& lbp, EventSetup const& c) {}
0206 void EDProducerBase::doEndLuminosityBlockProduce_(LuminosityBlock& lbp, EventSetup const& c) {}
0207
0208 void EDProducerBase::clearInputProcessBlockCaches() {}
0209
0210 void EDProducerBase::fillDescriptions(ConfigurationDescriptions& descriptions) {
0211 ParameterSetDescription desc;
0212 desc.setUnknown();
0213 descriptions.addDefault(desc);
0214 }
0215
0216 void EDProducerBase::prevalidate(ConfigurationDescriptions& iConfig) { edmodule_mightGet_config(iConfig); }
0217
0218 static const std::string kBaseType("EDProducer");
0219
0220 const std::string& EDProducerBase::baseType() { return kBaseType; }
0221
0222 }
0223 }