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 noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
bool wantsStreamLuminosityBlocks () const noexcept final
 
bool wantsStreamRuns () const noexcept 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 137 of file TestInterProcessRandomProd.cc.

Constructor & Destructor Documentation

◆ TestInterProcessRandomProd()

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

Definition at line 175 of file TestInterProcessRandomProd.cc.

176  : token_{produces<edmtest::IntProduct>()},
177  blToken_{produces<edmtest::IntProduct, edm::Transition::BeginLuminosityBlock>("lumi")},
178  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 180 of file TestInterProcessRandomProd.cc.

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

180  {
181  auto const label = moduleDescription().moduleLabel();
182 
183  using namespace std::string_literals;
184 
185  std::string config = R"_(from FWCore.TestProcessor.TestProcess import *
186 process = TestProcess()
187 )_";
188  config += "process."s + label + "=" + config_ + "\n";
189  config += "process.moduleToTest(process."s + label + ")\n";
190  config += R"_(
191 process.add_(cms.Service("InitRootHandlers", UnloadRootSigHandler=cms.untracked.bool(True)))
192  )_";
193 
194  auto cache = std::make_unique<testinter::StreamCache>(config, iID.value());
195  if (iID.value() == 0) {
196  stream0Cache_ = cache.get();
197 
199  }
200 
201  return cache;
202 }
testinter::StreamCache * stream0Cache_
std::atomic< testinter::StreamCache * > availableForBeginLumi_
Definition: config.py:1
char const * label
ModuleDescription const & moduleDescription() const
def cache(function)
Definition: utilities.py:3
dictionary config
Read in AllInOne config in JSON format.
Definition: DiMuonV_cfg.py:30
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 209 of file TestInterProcessRandomProd.cc.

References relval_steps::gen(), and Hcal_Conditions_forGlobalTag_cff::iLumi.

210  {
212  auto& engine = gen->getEngine(iLumi.index());
213  return std::make_shared<edm::RandomNumberGeneratorState>(engine.put(), engine.getSeed());
214 }
def gen(fragment, howMuch)
Tau Embedding 2016 HIPM ###.

◆ globalBeginLuminosityBlockProduce()

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

Definition at line 216 of file TestInterProcessRandomProd.cc.

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

217  {
218  while (not availableForBeginLumi_.load()) {
219  }
220 
221  auto v = availableForBeginLumi_.load()->beginLumiProduce(
222  *luminosityBlockCache(iLuminosityBlock.index()), iLuminosityBlock.luminosityBlock(), iLuminosityBlock.index());
224  auto& engine = gen->getEngine(iLuminosityBlock.index());
225  if (v.second.state_[0] != CLHEP::engineIDulong<CLHEP::RanecuEngine>()) {
226  engine.setSeed(v.second.seed_, 0);
227  }
228  engine.get(v.second.state_);
229 
230  iLuminosityBlock.emplace(blToken_, v.first);
231 
232  lastLumiIndex_.store(iLuminosityBlock.index());
233 }
std::atomic< unsigned int > lastLumiIndex_
std::atomic< testinter::StreamCache * > availableForBeginLumi_
def gen(fragment, howMuch)
Tau Embedding 2016 HIPM ###.
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 152 of file TestInterProcessRandomProd.cc.

152 {}

◆ produce()

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

Implements edm::global::EDProducerBase.

Definition at line 204 of file TestInterProcessRandomProd.cc.

References iEvent, and token_.

204  {
205  auto value = streamCache(iID)->produce(iEvent.id().event(), iID);
206  iEvent.emplace(token_, value);
207 }
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 235 of file TestInterProcessRandomProd.cc.

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

237  {
238  auto cache = streamCache(iID);
239  if (cache != availableForBeginLumi_.load()) {
240  (void)cache->beginLumiProduce(
241  *luminosityBlockCache(iLuminosityBlock.index()), iLuminosityBlock.luminosityBlock(), iLuminosityBlock.index());
242  } else {
243  availableForBeginLumi_ = nullptr;
244  }
245 }
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 147 of file TestInterProcessRandomProd.cc.

147 {}

◆ streamEndLuminosityBlock()

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

Definition at line 247 of file TestInterProcessRandomProd.cc.

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

249  {
250  if (lastLumiIndex_ == iLuminosityBlock.index()) {
251  testinter::StreamCache* expected = nullptr;
252 
253  availableForBeginLumi_.compare_exchange_strong(expected, streamCache(iID));
254  }
255 }
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 148 of file TestInterProcessRandomProd.cc.

148 {}

Member Data Documentation

◆ availableForBeginLumi_

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

◆ blToken_

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

Definition at line 160 of file TestInterProcessRandomProd.cc.

Referenced by globalBeginLuminosityBlockProduce().

◆ config_

std::string TestInterProcessRandomProd::config_
private

Definition at line 162 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 166 of file TestInterProcessRandomProd.cc.

Referenced by beginStream().

◆ token_

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

Definition at line 159 of file TestInterProcessRandomProd.cc.

Referenced by produce().