Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-03-13 02:31:58

0001 // -*- C++ -*-
0002 //
0003 // Package:     FWCore/Sources
0004 // Class  :     PuttableSourceBase
0005 //
0006 // Implementation:
0007 //     [Notes on implementation]
0008 //
0009 // Original Author:  root
0010 //         Created:  Tue, 26 Sep 2017 20:52:26 GMT
0011 //
0012 
0013 // system include files
0014 
0015 // user include files
0016 #include "FWCore/Sources/interface/PuttableSourceBase.h"
0017 
0018 #include "DataFormats/Provenance/interface/ProductRegistry.h"
0019 #include "DataFormats/Provenance/interface/ProductResolverIndexHelper.h"
0020 
0021 #include "FWCore/Framework/interface/LuminosityBlock.h"
0022 #include "FWCore/Framework/interface/Run.h"
0023 #include "FWCore/Framework/interface/Event.h"
0024 #include "FWCore/Framework/interface/ExceptionHelpers.h"
0025 #include "FWCore/Framework/interface/SignallingProductRegistryFiller.h"
0026 
0027 using namespace edm;
0028 //
0029 // constants, enums and typedefs
0030 //
0031 
0032 //
0033 // static data member definitions
0034 //
0035 
0036 //
0037 // constructors and destructor
0038 //
0039 PuttableSourceBase::PuttableSourceBase(ParameterSet const& iPSet, InputSourceDescription const& iISD)
0040     : InputSource(iPSet, iISD) {}
0041 
0042 void PuttableSourceBase::registerProducts() {
0043   SignallingProductRegistryFiller reg;
0044   //this handled case were Source's construct injects items into the ProductRegistry
0045   reg.addFromInput(productRegistryUpdate());
0046   registerProducts(this, &reg, moduleDescription());
0047   productRegistryUpdate() = reg.moveTo();
0048 }
0049 
0050 void PuttableSourceBase::beginJob(edm::ProductRegistry const& r) {
0051   auto const runLookup = r.productLookup(InRun);
0052   auto const lumiLookup = r.productLookup(InLumi);
0053   auto const eventLookup = r.productLookup(InEvent);
0054   auto const& processName = moduleDescription().processName();
0055   auto const& moduleLabel = moduleDescription().moduleLabel();
0056 
0057   auto const& runModuleToIndicies = runLookup->indiciesForModulesInProcess(processName);
0058   auto const& lumiModuleToIndicies = lumiLookup->indiciesForModulesInProcess(processName);
0059   auto const& eventModuleToIndicies = eventLookup->indiciesForModulesInProcess(processName);
0060   resolvePutIndicies(InRun, runModuleToIndicies, moduleLabel);
0061   resolvePutIndicies(InLumi, lumiModuleToIndicies, moduleLabel);
0062   resolvePutIndicies(InEvent, eventModuleToIndicies, moduleLabel);
0063 }
0064 
0065 void PuttableSourceBase::doBeginRun(RunPrincipal& rp, ProcessContext const*) {
0066   Run run(rp, moduleDescription(), nullptr, false);
0067   run.setProducer(this);
0068   callWithTryCatchAndPrint<void>([this, &run]() { beginRun(run); }, "Calling Source::beginRun");
0069   commit_(run);
0070 }
0071 
0072 void PuttableSourceBase::doBeginLumi(LuminosityBlockPrincipal& lbp, ProcessContext const*) {
0073   LuminosityBlock lb(lbp, moduleDescription(), nullptr, false);
0074   lb.setProducer(this);
0075   callWithTryCatchAndPrint<void>([this, &lb]() { beginLuminosityBlock(lb); }, "Calling Source::beginLuminosityBlock");
0076   commit_(lb);
0077 }
0078 
0079 void PuttableSourceBase::beginRun(Run&) {}
0080 
0081 void PuttableSourceBase::beginLuminosityBlock(LuminosityBlock&) {}