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