File indexing completed on 2022-10-18 04:13:18
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include <memory>
0017
0018 #include "FWCore/Framework/interface/Event.h"
0019 #include "FWCore/Framework/interface/EventSetup.h"
0020 #include "FWCore/Framework/interface/LuminosityBlock.h"
0021 #include "FWCore/Framework/interface/ProcessBlock.h"
0022 #include "FWCore/Framework/interface/Run.h"
0023 #include "FWCore/Framework/interface/global/EDProducerBase.h"
0024 #include "FWCore/Framework/src/EventAcquireSignalsSentry.h"
0025 #include "FWCore/Framework/src/EventSignalsSentry.h"
0026 #include "FWCore/Framework/interface/PreallocationConfiguration.h"
0027 #include "FWCore/Framework/src/edmodule_mightGet_config.h"
0028 #include "FWCore/Framework/interface/TransitionInfoTypes.h"
0029 #include "FWCore/Framework/interface/EventForTransformer.h"
0030 #include "FWCore/ServiceRegistry/interface/ESParentContext.h"
0031
0032 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0033 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0034
0035
0036
0037
0038 namespace edm {
0039
0040 class WaitingTaskWithArenaHolder;
0041
0042 namespace global {
0043
0044
0045
0046
0047
0048
0049
0050 EDProducerBase::EDProducerBase()
0051 : ProducerBase(),
0052 moduleDescription_(),
0053 previousParentages_(),
0054 gotBranchIDsFromAcquire_(),
0055 previousParentageIds_() {}
0056
0057 EDProducerBase::~EDProducerBase() {}
0058
0059 bool EDProducerBase::doEvent(EventTransitionInfo const& info,
0060 ActivityRegistry* act,
0061 ModuleCallingContext const* mcc) {
0062 Event e(info, moduleDescription_, mcc);
0063 e.setConsumer(this);
0064 const auto streamIndex = e.streamID().value();
0065 e.setProducer(
0066 this, &previousParentages_[streamIndex], hasAcquire() ? &gotBranchIDsFromAcquire_[streamIndex] : nullptr);
0067 EventSignalsSentry sentry(act, mcc);
0068 ESParentContext parentC(mcc);
0069 this->produce(
0070 e.streamID(),
0071 e,
0072 EventSetup{
0073 info, static_cast<unsigned int>(Transition::Event), esGetTokenIndices(Transition::Event), parentC});
0074 commit_(e, &previousParentageIds_[streamIndex]);
0075 return true;
0076 }
0077
0078 void EDProducerBase::doAcquire(EventTransitionInfo const& info,
0079 ActivityRegistry* act,
0080 ModuleCallingContext const* mcc,
0081 WaitingTaskWithArenaHolder& holder) {
0082 Event e(info, moduleDescription_, mcc);
0083 e.setConsumer(this);
0084 const auto streamIndex = e.streamID().value();
0085 e.setProducerForAcquire(this, nullptr, gotBranchIDsFromAcquire_[streamIndex]);
0086 EventAcquireSignalsSentry sentry(act, mcc);
0087 ESParentContext parentC(mcc);
0088 const EventSetup c{
0089 info, static_cast<unsigned int>(Transition::Event), esGetTokenIndices(Transition::Event), parentC};
0090 this->doAcquire_(e.streamID(), e, c, holder);
0091 }
0092
0093 void EDProducerBase::doTransformAsync(WaitingTaskHolder iTask,
0094 size_t iTransformIndex,
0095 EventPrincipal const& iEvent,
0096 ActivityRegistry*,
0097 ModuleCallingContext const* iMCC,
0098 ServiceWeakToken const& iToken) {
0099 EventForTransformer ev(iEvent, iMCC);
0100 transformAsync_(iTask, iTransformIndex, ev, iToken);
0101 }
0102
0103 size_t EDProducerBase::transformIndex_(edm::BranchDescription const& iBranch) const { return -1; }
0104 ProductResolverIndex EDProducerBase::transformPrefetch_(std::size_t iIndex) const { return 0; }
0105 void EDProducerBase::transformAsync_(WaitingTaskHolder iTask,
0106 std::size_t iIndex,
0107 edm::EventForTransformer& iEvent,
0108 ServiceWeakToken const& iToken) const {}
0109
0110 void EDProducerBase::doPreallocate(PreallocationConfiguration const& iPrealloc) {
0111 auto const nStreams = iPrealloc.numberOfStreams();
0112 previousParentages_ = std::make_unique<std::vector<BranchID>[]>(nStreams);
0113 if (hasAcquire()) {
0114 gotBranchIDsFromAcquire_ = std::make_unique<std::vector<BranchID>[]>(nStreams);
0115 }
0116 previousParentageIds_ = std::make_unique<ParentageID[]>(nStreams);
0117 preallocStreams(nStreams);
0118 preallocRuns(iPrealloc.numberOfRuns());
0119 preallocRunsSummary(iPrealloc.numberOfRuns());
0120 preallocLumis(iPrealloc.numberOfLuminosityBlocks());
0121 preallocLumisSummary(iPrealloc.numberOfLuminosityBlocks());
0122 preallocate(iPrealloc);
0123 }
0124
0125 void EDProducerBase::doBeginJob() { this->beginJob(); }
0126
0127 void EDProducerBase::doEndJob() { this->endJob(); }
0128
0129 void EDProducerBase::doBeginProcessBlock(ProcessBlockPrincipal const& pbp, ModuleCallingContext const* mcc) {
0130 ProcessBlock processBlock(pbp, moduleDescription_, mcc, false);
0131 processBlock.setConsumer(this);
0132 ProcessBlock const& constProcessBlock = processBlock;
0133 this->doBeginProcessBlock_(constProcessBlock);
0134 processBlock.setProducer(this);
0135 this->doBeginProcessBlockProduce_(processBlock);
0136 commit_(processBlock);
0137 }
0138
0139 void EDProducerBase::doAccessInputProcessBlock(ProcessBlockPrincipal const& pbp, ModuleCallingContext const* mcc) {
0140 ProcessBlock processBlock(pbp, moduleDescription_, mcc, false);
0141 processBlock.setConsumer(this);
0142 ProcessBlock const& constProcessBlock = processBlock;
0143 this->doAccessInputProcessBlock_(constProcessBlock);
0144 }
0145
0146 void EDProducerBase::doEndProcessBlock(ProcessBlockPrincipal const& pbp, ModuleCallingContext const* mcc) {
0147 ProcessBlock processBlock(pbp, moduleDescription_, mcc, true);
0148 processBlock.setConsumer(this);
0149 ProcessBlock const& constProcessBlock = processBlock;
0150 this->doEndProcessBlock_(constProcessBlock);
0151 processBlock.setProducer(this);
0152 this->doEndProcessBlockProduce_(processBlock);
0153 commit_(processBlock);
0154 }
0155
0156 void EDProducerBase::doBeginRun(RunTransitionInfo const& info, ModuleCallingContext const* mcc) {
0157 Run r(info, moduleDescription_, mcc, false);
0158 r.setConsumer(this);
0159 Run const& cnstR = r;
0160 ESParentContext parentC(mcc);
0161 const EventSetup c{
0162 info, static_cast<unsigned int>(Transition::BeginRun), esGetTokenIndices(Transition::BeginRun), parentC};
0163 this->doBeginRun_(cnstR, c);
0164 this->doBeginRunSummary_(cnstR, c);
0165 r.setProducer(this);
0166 this->doBeginRunProduce_(r, c);
0167 commit_(r);
0168 }
0169
0170 void EDProducerBase::doEndRun(RunTransitionInfo const& info, ModuleCallingContext const* mcc) {
0171 Run r(info, moduleDescription_, mcc, true);
0172 r.setConsumer(this);
0173 r.setProducer(this);
0174 Run const& cnstR = r;
0175 ESParentContext parentC(mcc);
0176 const EventSetup c{
0177 info, static_cast<unsigned int>(Transition::EndRun), esGetTokenIndices(Transition::EndRun), parentC};
0178 this->doEndRunSummary_(r, c);
0179 this->doEndRunProduce_(r, c);
0180 this->doEndRun_(cnstR, c);
0181 commit_(r);
0182 }
0183
0184 void EDProducerBase::doBeginLuminosityBlock(LumiTransitionInfo const& info, ModuleCallingContext const* mcc) {
0185 LuminosityBlock lb(info, moduleDescription_, mcc, false);
0186 lb.setConsumer(this);
0187 LuminosityBlock const& cnstLb = lb;
0188 ESParentContext parentC(mcc);
0189 const EventSetup c{info,
0190 static_cast<unsigned int>(Transition::BeginLuminosityBlock),
0191 esGetTokenIndices(Transition::BeginLuminosityBlock),
0192 parentC};
0193 this->doBeginLuminosityBlock_(cnstLb, c);
0194 this->doBeginLuminosityBlockSummary_(cnstLb, c);
0195 lb.setProducer(this);
0196 this->doBeginLuminosityBlockProduce_(lb, c);
0197 commit_(lb);
0198 }
0199
0200 void EDProducerBase::doEndLuminosityBlock(LumiTransitionInfo const& info, ModuleCallingContext const* mcc) {
0201 LuminosityBlock lb(info, moduleDescription_, mcc, true);
0202 lb.setConsumer(this);
0203 lb.setProducer(this);
0204 LuminosityBlock const& cnstLb = lb;
0205 ESParentContext parentC(mcc);
0206 const EventSetup c{info,
0207 static_cast<unsigned int>(Transition::EndLuminosityBlock),
0208 esGetTokenIndices(Transition::EndLuminosityBlock),
0209 parentC};
0210 this->doEndLuminosityBlockSummary_(cnstLb, c);
0211 this->doEndLuminosityBlockProduce_(lb, c);
0212 this->doEndLuminosityBlock_(cnstLb, c);
0213 commit_(lb);
0214 }
0215
0216 void EDProducerBase::doBeginStream(StreamID id) { doBeginStream_(id); }
0217 void EDProducerBase::doEndStream(StreamID id) { doEndStream_(id); }
0218 void EDProducerBase::doStreamBeginRun(StreamID id, RunTransitionInfo const& info, ModuleCallingContext const* mcc) {
0219 Run r(info, moduleDescription_, mcc, false);
0220 r.setConsumer(this);
0221 ESParentContext parentC(mcc);
0222 this->doStreamBeginRun_(
0223 id,
0224 r,
0225 EventSetup{
0226 info, static_cast<unsigned int>(Transition::BeginRun), esGetTokenIndices(Transition::BeginRun), parentC});
0227 }
0228 void EDProducerBase::doStreamEndRun(StreamID id, RunTransitionInfo const& info, ModuleCallingContext const* mcc) {
0229 Run r(info, moduleDescription_, mcc, true);
0230 r.setConsumer(this);
0231 ESParentContext parentC(mcc);
0232 const EventSetup c{
0233 info, static_cast<unsigned int>(Transition::EndRun), esGetTokenIndices(Transition::EndRun), parentC};
0234 this->doStreamEndRun_(id, r, c);
0235 this->doStreamEndRunSummary_(id, r, c);
0236 }
0237 void EDProducerBase::doStreamBeginLuminosityBlock(StreamID id,
0238 LumiTransitionInfo const& info,
0239 ModuleCallingContext const* mcc) {
0240 LuminosityBlock lb(info, moduleDescription_, mcc, false);
0241 lb.setConsumer(this);
0242 ESParentContext parentC(mcc);
0243
0244 this->doStreamBeginLuminosityBlock_(id,
0245 lb,
0246 EventSetup{info,
0247 static_cast<unsigned int>(Transition::BeginLuminosityBlock),
0248 esGetTokenIndices(Transition::BeginLuminosityBlock),
0249 parentC});
0250 }
0251
0252 void EDProducerBase::doStreamEndLuminosityBlock(StreamID id,
0253 LumiTransitionInfo const& info,
0254 ModuleCallingContext const* mcc) {
0255 LuminosityBlock lb(info, moduleDescription_, mcc, true);
0256 lb.setConsumer(this);
0257 ESParentContext parentC(mcc);
0258 const EventSetup c{info,
0259 static_cast<unsigned int>(Transition::EndLuminosityBlock),
0260 esGetTokenIndices(Transition::EndLuminosityBlock),
0261 parentC};
0262 this->doStreamEndLuminosityBlock_(id, lb, c);
0263 this->doStreamEndLuminosityBlockSummary_(id, lb, c);
0264 }
0265
0266 void EDProducerBase::preallocStreams(unsigned int) {}
0267 void EDProducerBase::preallocRuns(unsigned int) {}
0268 void EDProducerBase::preallocRunsSummary(unsigned int) {}
0269 void EDProducerBase::preallocLumis(unsigned int) {}
0270 void EDProducerBase::preallocLumisSummary(unsigned int) {}
0271 void EDProducerBase::preallocate(PreallocationConfiguration const&) {}
0272 void EDProducerBase::doBeginStream_(StreamID id) {}
0273 void EDProducerBase::doEndStream_(StreamID id) {}
0274 void EDProducerBase::doStreamBeginRun_(StreamID id, Run const& rp, EventSetup const& c) {}
0275 void EDProducerBase::doStreamEndRun_(StreamID id, Run const& rp, EventSetup const& c) {}
0276 void EDProducerBase::doStreamEndRunSummary_(StreamID id, Run const& rp, EventSetup const& c) {}
0277 void EDProducerBase::doStreamBeginLuminosityBlock_(StreamID id, LuminosityBlock const& lbp, EventSetup const& c) {}
0278 void EDProducerBase::doStreamEndLuminosityBlock_(StreamID id, LuminosityBlock const& lbp, EventSetup const& c) {}
0279 void EDProducerBase::doStreamEndLuminosityBlockSummary_(StreamID id,
0280 LuminosityBlock const& lbp,
0281 EventSetup const& c) {}
0282
0283 void EDProducerBase::doBeginProcessBlock_(ProcessBlock const&) {}
0284 void EDProducerBase::doAccessInputProcessBlock_(ProcessBlock const&) {}
0285 void EDProducerBase::doEndProcessBlock_(ProcessBlock const&) {}
0286 void EDProducerBase::doBeginRun_(Run const& rp, EventSetup const& c) {}
0287 void EDProducerBase::doEndRun_(Run const& rp, EventSetup const& c) {}
0288 void EDProducerBase::doBeginRunSummary_(Run const& rp, EventSetup const& c) {}
0289 void EDProducerBase::doEndRunSummary_(Run const& rp, EventSetup const& c) {}
0290
0291 void EDProducerBase::doBeginLuminosityBlock_(LuminosityBlock const& lbp, EventSetup const& c) {}
0292 void EDProducerBase::doEndLuminosityBlock_(LuminosityBlock const& lbp, EventSetup const& c) {}
0293 void EDProducerBase::doBeginLuminosityBlockSummary_(LuminosityBlock const& rp, EventSetup const& c) {}
0294 void EDProducerBase::doEndLuminosityBlockSummary_(LuminosityBlock const& lb, EventSetup const& c) {}
0295
0296 void EDProducerBase::doBeginProcessBlockProduce_(ProcessBlock&) {}
0297 void EDProducerBase::doEndProcessBlockProduce_(ProcessBlock&) {}
0298 void EDProducerBase::doBeginRunProduce_(Run& rp, EventSetup const& c) {}
0299 void EDProducerBase::doEndRunProduce_(Run& rp, EventSetup const& c) {}
0300 void EDProducerBase::doBeginLuminosityBlockProduce_(LuminosityBlock& lbp, EventSetup const& c) {}
0301 void EDProducerBase::doEndLuminosityBlockProduce_(LuminosityBlock& lbp, EventSetup const& c) {}
0302
0303 void EDProducerBase::clearInputProcessBlockCaches() {}
0304
0305 void EDProducerBase::doAcquire_(StreamID, Event const&, EventSetup const&, WaitingTaskWithArenaHolder&) {}
0306
0307 void EDProducerBase::fillDescriptions(ConfigurationDescriptions& descriptions) {
0308 ParameterSetDescription desc;
0309 desc.setUnknown();
0310 descriptions.addDefault(desc);
0311 }
0312
0313 void EDProducerBase::prevalidate(ConfigurationDescriptions& iConfig) { edmodule_mightGet_config(iConfig); }
0314
0315 static const std::string kBaseType("EDProducer");
0316
0317 const std::string& EDProducerBase::baseType() { return kBaseType; }
0318
0319 }
0320 }