File indexing completed on 2025-04-30 22:24:07
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include <cassert>
0015
0016
0017 #include "FWCore/Framework/interface/stream/ProducingModuleAdaptorBase.h"
0018 #include "FWCore/Framework/interface/LuminosityBlock.h"
0019 #include "FWCore/Framework/interface/Run.h"
0020 #include "FWCore/Framework/interface/LuminosityBlockPrincipal.h"
0021 #include "FWCore/Framework/interface/EventSetup.h"
0022 #include "FWCore/Framework/interface/RunPrincipal.h"
0023 #include "FWCore/Framework/interface/PreallocationConfiguration.h"
0024 #include "FWCore/Framework/interface/TransitionInfoTypes.h"
0025 #include "FWCore/Framework/interface/EventForTransformer.h"
0026 #include "FWCore/Framework/interface/ModuleConsumesMinimalESInfo.h"
0027 #include "FWCore/ServiceRegistry/interface/ESParentContext.h"
0028 #include "FWCore/ServiceRegistry/interface/ModuleConsumesInfo.h"
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041 namespace edm {
0042 namespace stream {
0043 template <typename T>
0044 ProducingModuleAdaptorBase<T>::ProducingModuleAdaptorBase() {}
0045
0046 template <typename T>
0047 ProducingModuleAdaptorBase<T>::~ProducingModuleAdaptorBase() {
0048 for (auto m : m_streamModules) {
0049 delete m;
0050 }
0051 }
0052
0053 template <typename T>
0054 void ProducingModuleAdaptorBase<T>::deleteModulesEarly() {
0055 for (auto m : m_streamModules) {
0056 delete m;
0057 }
0058 m_streamModules.clear();
0059 }
0060
0061
0062
0063
0064
0065 template <typename T>
0066 void ProducingModuleAdaptorBase<T>::doPreallocate(PreallocationConfiguration const& iPrealloc) {
0067 m_streamModules.resize(iPrealloc.numberOfStreams(), static_cast<T*>(nullptr));
0068 setupStreamModules();
0069 preallocRuns(iPrealloc.numberOfRuns());
0070 preallocLumis(iPrealloc.numberOfLuminosityBlocks());
0071 }
0072
0073 template <typename T>
0074 void ProducingModuleAdaptorBase<T>::registerProductsAndCallbacks(ProducingModuleAdaptorBase const*,
0075 SignallingProductRegistryFiller* reg) {
0076 auto firstMod = m_streamModules[0];
0077 if (firstMod->registrationCallback() and m_streamModules.size() > 1) {
0078
0079
0080 std::vector<std::function<void(ProductDescription const&)>> callbacks;
0081 callbacks.reserve(m_streamModules.size());
0082
0083 for (auto mod : m_streamModules) {
0084 callbacks.push_back(mod->registrationCallback());
0085 }
0086
0087
0088 firstMod->callWhenNewProductsRegistered([callbacks](ProductDescription const& iBD) {
0089 for (const auto& c : callbacks) {
0090 c(iBD);
0091 }
0092 });
0093 }
0094 firstMod->registerProducts(firstMod, reg, moduleDescription_);
0095 }
0096
0097 template <typename T>
0098 void ProducingModuleAdaptorBase<T>::itemsToGet(BranchType iType,
0099 std::vector<ProductResolverIndexAndSkipBit>& iIndices) const {
0100 assert(not m_streamModules.empty());
0101 m_streamModules[0]->itemsToGet(iType, iIndices);
0102 }
0103
0104 template <typename T>
0105 void ProducingModuleAdaptorBase<T>::itemsMayGet(BranchType iType,
0106 std::vector<ProductResolverIndexAndSkipBit>& iIndices) const {
0107 assert(not m_streamModules.empty());
0108 m_streamModules[0]->itemsMayGet(iType, iIndices);
0109 }
0110
0111 template <typename T>
0112 std::vector<edm::ProductResolverIndexAndSkipBit> const& ProducingModuleAdaptorBase<T>::itemsToGetFrom(
0113 BranchType iType) const {
0114 assert(not m_streamModules.empty());
0115 return m_streamModules[0]->itemsToGetFrom(iType);
0116 }
0117
0118 template <typename T>
0119 std::vector<ESResolverIndex> const& ProducingModuleAdaptorBase<T>::esGetTokenIndicesVector(
0120 edm::Transition iTrans) const {
0121 assert(not m_streamModules.empty());
0122 return m_streamModules[0]->esGetTokenIndicesVector(iTrans);
0123 }
0124
0125 template <typename T>
0126 std::vector<ESRecordIndex> const& ProducingModuleAdaptorBase<T>::esGetTokenRecordIndicesVector(
0127 edm::Transition iTrans) const {
0128 assert(not m_streamModules.empty());
0129 return m_streamModules[0]->esGetTokenRecordIndicesVector(iTrans);
0130 }
0131
0132 template <typename T>
0133 void ProducingModuleAdaptorBase<T>::convertCurrentProcessAlias(std::string const& processName) {
0134 for (auto mod : m_streamModules) {
0135 mod->convertCurrentProcessAlias(processName);
0136 }
0137 }
0138
0139 template <typename T>
0140 std::vector<edm::ModuleConsumesInfo> ProducingModuleAdaptorBase<T>::moduleConsumesInfos() const {
0141 assert(not m_streamModules.empty());
0142 return m_streamModules[0]->moduleConsumesInfos();
0143 }
0144
0145 template <typename T>
0146 std::vector<edm::ModuleConsumesMinimalESInfo> ProducingModuleAdaptorBase<T>::moduleConsumesMinimalESInfos() const {
0147 assert(not m_streamModules.empty());
0148 return m_streamModules[0]->moduleConsumesMinimalESInfos();
0149 }
0150
0151 template <typename T>
0152 void ProducingModuleAdaptorBase<T>::updateLookup(BranchType iType,
0153 ProductResolverIndexHelper const& iHelper,
0154 bool iPrefetchMayGet) {
0155 for (auto mod : m_streamModules) {
0156 mod->updateLookup(iType, iHelper, iPrefetchMayGet);
0157 }
0158 }
0159 template <typename T>
0160 void ProducingModuleAdaptorBase<T>::updateLookup(eventsetup::ESRecordsToProductResolverIndices const& iPI) {
0161 for (auto mod : m_streamModules) {
0162 mod->updateLookup(iPI);
0163 }
0164 }
0165
0166 template <typename T>
0167 void ProducingModuleAdaptorBase<T>::releaseMemoryPostLookupSignal() {
0168 for (auto mod : m_streamModules) {
0169 mod->releaseMemoryPostLookupSignal();
0170 }
0171 }
0172
0173 template <typename T>
0174 void ProducingModuleAdaptorBase<T>::resolvePutIndicies(BranchType iBranchType,
0175 ModuleToResolverIndicies const& iIndicies,
0176 std::string const& moduleLabel) {
0177 for (auto mod : m_streamModules) {
0178 mod->resolvePutIndicies(iBranchType, iIndicies, moduleLabel);
0179 }
0180 }
0181
0182 template <typename T>
0183 std::vector<edm::ProductResolverIndex> const& ProducingModuleAdaptorBase<T>::indiciesForPutProducts(
0184 BranchType iBranchType) const {
0185 return m_streamModules[0]->indiciesForPutProducts(iBranchType);
0186 }
0187
0188 template <typename T>
0189 ProductResolverIndex ProducingModuleAdaptorBase<T>::transformPrefetch_(size_t iTransformIndex) const noexcept {
0190 return 0;
0191 }
0192 template <typename T>
0193 size_t ProducingModuleAdaptorBase<T>::transformIndex_(edm::ProductDescription const& iBranch) const noexcept {
0194 return 0;
0195 }
0196 template <typename T>
0197 void ProducingModuleAdaptorBase<T>::doTransformAsync(WaitingTaskHolder iTask,
0198 size_t iTransformIndex,
0199 EventPrincipal const& iEvent,
0200 ActivityRegistry*,
0201 ModuleCallingContext iMCC,
0202 ServiceWeakToken const&) noexcept {}
0203
0204 template <typename T>
0205 void ProducingModuleAdaptorBase<T>::doBeginStream(StreamID id) {
0206 m_streamModules[id]->beginStream(id);
0207 }
0208 template <typename T>
0209 void ProducingModuleAdaptorBase<T>::doEndStream(StreamID id) {
0210 m_streamModules[id]->endStream();
0211 }
0212
0213 template <typename T>
0214 void ProducingModuleAdaptorBase<T>::doStreamBeginRun(StreamID id,
0215 RunTransitionInfo const& info,
0216 ModuleCallingContext const* mcc) {
0217 RunPrincipal const& rp = info.principal();
0218 auto mod = m_streamModules[id];
0219 setupRun(mod, rp.index());
0220
0221 Run r(rp, moduleDescription_, mcc, false);
0222 r.setConsumer(mod);
0223 ESParentContext parentC(mcc);
0224 const EventSetup c{
0225 info, static_cast<unsigned int>(Transition::BeginRun), mod->esGetTokenIndices(Transition::BeginRun), parentC};
0226 mod->beginRun(r, c);
0227 }
0228
0229 template <typename T>
0230 void ProducingModuleAdaptorBase<T>::doStreamEndRun(StreamID id,
0231 RunTransitionInfo const& info,
0232 ModuleCallingContext const* mcc) {
0233 auto mod = m_streamModules[id];
0234 Run r(info, moduleDescription_, mcc, true);
0235 r.setConsumer(mod);
0236 ESParentContext parentC(mcc);
0237 const EventSetup c{
0238 info, static_cast<unsigned int>(Transition::EndRun), mod->esGetTokenIndices(Transition::EndRun), parentC};
0239 mod->endRun(r, c);
0240 streamEndRunSummary(mod, r, c);
0241 }
0242
0243 template <typename T>
0244 void ProducingModuleAdaptorBase<T>::doStreamBeginLuminosityBlock(StreamID id,
0245 LumiTransitionInfo const& info,
0246 ModuleCallingContext const* mcc) {
0247 LuminosityBlockPrincipal const& lbp = info.principal();
0248 auto mod = m_streamModules[id];
0249 setupLuminosityBlock(mod, lbp.index());
0250
0251 LuminosityBlock lb(lbp, moduleDescription_, mcc, false);
0252 lb.setConsumer(mod);
0253 ESParentContext parentC(mcc);
0254 const EventSetup c{info,
0255 static_cast<unsigned int>(Transition::BeginLuminosityBlock),
0256 mod->esGetTokenIndices(Transition::BeginLuminosityBlock),
0257 parentC};
0258 mod->beginLuminosityBlock(lb, c);
0259 }
0260
0261 template <typename T>
0262 void ProducingModuleAdaptorBase<T>::doStreamEndLuminosityBlock(StreamID id,
0263 LumiTransitionInfo const& info,
0264 ModuleCallingContext const* mcc) {
0265 auto mod = m_streamModules[id];
0266 LuminosityBlock lb(info, moduleDescription_, mcc, true);
0267 lb.setConsumer(mod);
0268 ESParentContext parentC(mcc);
0269 const EventSetup c{info,
0270 static_cast<unsigned int>(Transition::EndLuminosityBlock),
0271 mod->esGetTokenIndices(Transition::EndLuminosityBlock),
0272 parentC};
0273 mod->endLuminosityBlock(lb, c);
0274 streamEndLuminosityBlockSummary(mod, lb, c);
0275 }
0276
0277 template <typename T>
0278 void ProducingModuleAdaptorBase<T>::doRegisterThinnedAssociations(ProductRegistry const& registry,
0279 ThinnedAssociationsHelper& helper) {
0280 assert(not m_streamModules.empty());
0281 auto mod = m_streamModules[0];
0282 mod->registerThinnedAssociations(registry, helper);
0283 }
0284 }
0285 }