CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
TestInterProcessRandomProd Class Reference
Inheritance diagram for TestInterProcessRandomProd:
edm::global::EDProducer< edm::StreamCache< testinter::StreamCache >, edm::LuminosityBlockCache< edm::RandomNumberGeneratorState >, edm::BeginLuminosityBlockProducer > edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

std::unique_ptr< testinter::StreamCachebeginStream (edm::StreamID) const final
 
std::shared_ptr< edm::RandomNumberGeneratorStateglobalBeginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) const final
 
void globalBeginLuminosityBlockProduce (edm::LuminosityBlock &, edm::EventSetup const &) const final
 
void globalEndLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) const final
 
void produce (edm::StreamID, edm::Event &, edm::EventSetup const &) const final
 
void streamBeginLuminosityBlock (edm::StreamID, edm::LuminosityBlock const &, edm::EventSetup const &) const final
 
void streamBeginRun (edm::StreamID, edm::Run const &, edm::EventSetup const &) const final
 
void streamEndLuminosityBlock (edm::StreamID, edm::LuminosityBlock const &, edm::EventSetup const &) const final
 
void streamEndRun (edm::StreamID, edm::Run const &, edm::EventSetup const &) const final
 
 TestInterProcessRandomProd (edm::ParameterSet const &)
 
- Public Member Functions inherited from edm::global::EDProducer< edm::StreamCache< testinter::StreamCache >, edm::LuminosityBlockCache< edm::RandomNumberGeneratorState >, edm::BeginLuminosityBlockProducer >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

std::atomic< testinter::StreamCache * > availableForBeginLumi_
 
edm::EDPutTokenT< edmtest::IntProduct > const blToken_
 
std::string config_
 
std::atomic< unsigned int > lastLumiIndex_ = 0
 
testinter::StreamCachestream0Cache_ = nullptr
 
edm::EDPutTokenT< edmtest::IntProduct > const token_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 136 of file TestInterProcessRandomProd.cc.

Constructor & Destructor Documentation

◆ TestInterProcessRandomProd()

TestInterProcessRandomProd::TestInterProcessRandomProd ( edm::ParameterSet const &  iPSet)

Definition at line 174 of file TestInterProcessRandomProd.cc.

175  : token_{produces<edmtest::IntProduct>()},
176  blToken_{produces<edmtest::IntProduct, edm::Transition::BeginLuminosityBlock>("lumi")},
177  config_{iPSet.getUntrackedParameter<std::string>("@python_config")} {}
edm::EDPutTokenT< edmtest::IntProduct > const token_
edm::EDPutTokenT< edmtest::IntProduct > const blToken_

Member Function Documentation

◆ beginStream()

std::unique_ptr< testinter::StreamCache > TestInterProcessRandomProd::beginStream ( edm::StreamID  iID) const
final

Definition at line 179 of file TestInterProcessRandomProd.cc.

References availableForBeginLumi_, utilities::cache(), DMR_cfg::config, config_, label, edm::global::EDProducerBase::moduleDescription(), edm::ModuleDescription::moduleLabel(), alignCSCRings::s, stream0Cache_, AlCaHLTBitMon_QueryRunRegistry::string, and edm::StreamID::value().

179  {
180  auto const label = moduleDescription().moduleLabel();
181 
182  using namespace std::string_literals;
183 
184  std::string config = R"_(from FWCore.TestProcessor.TestProcess import *
185 process = TestProcess()
186 )_";
187  config += "process."s + label + "=" + config_ + "\n";
188  config += "process.moduleToTest(process."s + label + ")\n";
189  config += R"_(
190 process.add_(cms.Service("InitRootHandlers", UnloadRootSigHandler=cms.untracked.bool(True)))
191  )_";
192 
193  auto cache = std::make_unique<testinter::StreamCache>(config, iID.value());
194  if (iID.value() == 0) {
195  stream0Cache_ = cache.get();
196 
198  }
199 
200  return cache;
201 }
testinter::StreamCache * stream0Cache_
std::atomic< testinter::StreamCache * > availableForBeginLumi_
dictionary config
Read in AllInOne config in JSON format.
Definition: DMR_cfg.py:21
Definition: config.py:1
char const * label
ModuleDescription const & moduleDescription() const
def cache(function)
Definition: utilities.py:3
unsigned int value() const
Definition: StreamID.h:43
std::string const & moduleLabel() const

◆ globalBeginLuminosityBlock()

std::shared_ptr< edm::RandomNumberGeneratorState > TestInterProcessRandomProd::globalBeginLuminosityBlock ( edm::LuminosityBlock const &  iLumi,
edm::EventSetup const &   
) const
final

Definition at line 208 of file TestInterProcessRandomProd.cc.

References relval_steps::gen(), and edm::LuminosityBlock::index().

209  {
211  auto& engine = gen->getEngine(iLumi.index());
212  return std::make_shared<edm::RandomNumberGeneratorState>(engine.put(), engine.getSeed());
213 }
def gen(fragment, howMuch)
Production test section ####.

◆ globalBeginLuminosityBlockProduce()

void TestInterProcessRandomProd::globalBeginLuminosityBlockProduce ( edm::LuminosityBlock iLuminosityBlock,
edm::EventSetup const &   
) const
final

Definition at line 215 of file TestInterProcessRandomProd.cc.

References availableForBeginLumi_, blToken_, edm::LuminosityBlock::emplace(), relval_steps::gen(), edm::LuminosityBlock::index(), lastLumiIndex_, edm::LuminosityBlockBase::luminosityBlock(), and findQualityFiles::v.

216  {
217  while (not availableForBeginLumi_.load()) {
218  }
219 
220  auto v = availableForBeginLumi_.load()->beginLumiProduce(
221  *luminosityBlockCache(iLuminosityBlock.index()), iLuminosityBlock.luminosityBlock(), iLuminosityBlock.index());
223  auto& engine = gen->getEngine(iLuminosityBlock.index());
224  if (v.second.state_[0] != CLHEP::engineIDulong<CLHEP::RanecuEngine>()) {
225  engine.setSeed(v.second.seed_, 0);
226  }
227  engine.get(v.second.state_);
228 
229  iLuminosityBlock.emplace(blToken_, v.first);
230 
231  lastLumiIndex_.store(iLuminosityBlock.index());
232 }
std::atomic< unsigned int > lastLumiIndex_
std::atomic< testinter::StreamCache * > availableForBeginLumi_
def gen(fragment, howMuch)
Production test section ####.
edm::EDPutTokenT< edmtest::IntProduct > const blToken_
void emplace(EDPutTokenT< PROD > token, Args &&... args)
puts a new product
LuminosityBlockIndex index() const
LuminosityBlockNumber_t luminosityBlock() const

◆ globalEndLuminosityBlock()

void TestInterProcessRandomProd::globalEndLuminosityBlock ( edm::LuminosityBlock const &  ,
edm::EventSetup const &   
) const
inlinefinal

Definition at line 151 of file TestInterProcessRandomProd.cc.

151 {}

◆ produce()

void TestInterProcessRandomProd::produce ( edm::StreamID  iID,
edm::Event iEvent,
edm::EventSetup const &   
) const
finalvirtual

Implements edm::global::EDProducerBase.

Definition at line 203 of file TestInterProcessRandomProd.cc.

References iEvent, and token_.

203  {
204  auto value = streamCache(iID)->produce(iEvent.id().event(), iID);
205  iEvent.emplace(token_, value);
206 }
edm::EDPutTokenT< edmtest::IntProduct > const token_
int iEvent
Definition: GenABIO.cc:224
Definition: value.py:1

◆ streamBeginLuminosityBlock()

void TestInterProcessRandomProd::streamBeginLuminosityBlock ( edm::StreamID  iID,
edm::LuminosityBlock const &  iLuminosityBlock,
edm::EventSetup const &   
) const
final

Definition at line 234 of file TestInterProcessRandomProd.cc.

References availableForBeginLumi_, utilities::cache(), edm::LuminosityBlock::index(), edm::LuminosityBlockBase::luminosityBlock(), and funct::void.

236  {
237  auto cache = streamCache(iID);
238  if (cache != availableForBeginLumi_.load()) {
239  (void)cache->beginLumiProduce(
240  *luminosityBlockCache(iLuminosityBlock.index()), iLuminosityBlock.luminosityBlock(), iLuminosityBlock.index());
241  } else {
242  availableForBeginLumi_ = nullptr;
243  }
244 }
std::atomic< testinter::StreamCache * > availableForBeginLumi_
TEMPL(T2) struct Divides void
Definition: Factorize.h:24
def cache(function)
Definition: utilities.py:3

◆ streamBeginRun()

void TestInterProcessRandomProd::streamBeginRun ( edm::StreamID  ,
edm::Run const &  ,
edm::EventSetup const &   
) const
inlinefinal

Definition at line 146 of file TestInterProcessRandomProd.cc.

146 {}

◆ streamEndLuminosityBlock()

void TestInterProcessRandomProd::streamEndLuminosityBlock ( edm::StreamID  iID,
edm::LuminosityBlock const &  iLuminosityBlock,
edm::EventSetup const &   
) const
final

Definition at line 246 of file TestInterProcessRandomProd.cc.

References availableForBeginLumi_, edm::LuminosityBlock::index(), and lastLumiIndex_.

248  {
249  if (lastLumiIndex_ == iLuminosityBlock.index()) {
250  testinter::StreamCache* expected = nullptr;
251 
252  availableForBeginLumi_.compare_exchange_strong(expected, streamCache(iID));
253  }
254 }
std::atomic< unsigned int > lastLumiIndex_
std::atomic< testinter::StreamCache * > availableForBeginLumi_

◆ streamEndRun()

void TestInterProcessRandomProd::streamEndRun ( edm::StreamID  ,
edm::Run const &  ,
edm::EventSetup const &   
) const
inlinefinal

Definition at line 147 of file TestInterProcessRandomProd.cc.

147 {}

Member Data Documentation

◆ availableForBeginLumi_

std::atomic<testinter::StreamCache*> TestInterProcessRandomProd::availableForBeginLumi_
mutableprivate

◆ blToken_

edm::EDPutTokenT<edmtest::IntProduct> const TestInterProcessRandomProd::blToken_
private

Definition at line 159 of file TestInterProcessRandomProd.cc.

Referenced by globalBeginLuminosityBlockProduce().

◆ config_

std::string TestInterProcessRandomProd::config_
private

Definition at line 161 of file TestInterProcessRandomProd.cc.

Referenced by beginStream().

◆ lastLumiIndex_

std::atomic<unsigned int> TestInterProcessRandomProd::lastLumiIndex_ = 0
mutableprivate

◆ stream0Cache_

testinter::StreamCache* TestInterProcessRandomProd::stream0Cache_ = nullptr
mutableprivate

Definition at line 165 of file TestInterProcessRandomProd.cc.

Referenced by beginStream().

◆ token_

edm::EDPutTokenT<edmtest::IntProduct> const TestInterProcessRandomProd::token_
private

Definition at line 158 of file TestInterProcessRandomProd.cc.

Referenced by produce().