CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends
edm::ProcessBlock Class Reference

#include <ProcessBlock.h>

Public Types

using CacheIdentifier_t = unsigned long
 

Public Member Functions

CacheIdentifier_t cacheIdentifier () const
 
template<typename PROD , typename... Args>
void emplace (EDPutToken token, Args &&... args)
 
template<typename PROD , typename... Args>
void emplace (EDPutTokenT< PROD > token, Args &&... args)
 
template<typename PROD >
PROD const & get (EDGetTokenT< PROD > token) const noexcept(false)
 
template<typename PROD >
bool getByToken (EDGetToken token, Handle< PROD > &result) const
 
template<typename PROD >
bool getByToken (EDGetTokenT< PROD > token, Handle< PROD > &result) const
 
template<typename PROD >
Handle< PRODgetHandle (EDGetTokenT< PROD > token) const
 
ModuleCallingContext const * moduleCallingContext () const
 
 ProcessBlock (ProcessBlockPrincipal const &, ModuleDescription const &, ModuleCallingContext const *, bool isAtEnd)
 
std::string const & processName () const
 
template<typename PROD >
void put (EDPutToken token, std::unique_ptr< PROD > product)
 
template<typename PROD >
void put (EDPutTokenT< PROD > token, std::unique_ptr< PROD > product)
 
void setConsumer (EDConsumerBase const *iConsumer)
 
void setProducer (ProducerBase const *iProducer)
 

Private Types

using ProductPtrVec = std::vector< edm::propagate_const< std::unique_ptr< WrapperBase > >>
 

Private Member Functions

void commit_ (std::vector< edm::ProductResolverIndex > const &iShouldPut)
 
template<typename PROD , typename... Args>
void emplaceImpl (EDPutToken::value_type token, Args &&... args)
 
ProcessBlockPrincipal const & processBlockPrincipal () const
 
template<typename PROD >
void putImpl (EDPutToken::value_type token, std::unique_ptr< PROD > product)
 
ProductPtrVecputProducts ()
 
ProductPtrVec const & putProducts () const
 

Private Attributes

ModuleCallingContext const * moduleCallingContext_
 
PrincipalGetAdapter provRecorder_
 
ProductPtrVec putProducts_
 

Friends

class ProducerBase
 
template<typename T >
class stream::ProducingModuleAdaptorBase
 

Detailed Description

Author
W. David Dagenhart, created 19 March, 2020

Definition at line 36 of file ProcessBlock.h.

Member Typedef Documentation

◆ CacheIdentifier_t

using edm::ProcessBlock::CacheIdentifier_t = unsigned long

If you are caching data from the ProcessBlock, you should also keep this number. If this number changes then you know that the data you have cached is invalid. The value of '0' will never be returned so you can use that to denote that you have not yet checked the value.

Definition at line 63 of file ProcessBlock.h.

◆ ProductPtrVec

using edm::ProcessBlock::ProductPtrVec = std::vector<edm::propagate_const<std::unique_ptr<WrapperBase> >>
private

Definition at line 97 of file ProcessBlock.h.

Constructor & Destructor Documentation

◆ ProcessBlock()

edm::ProcessBlock::ProcessBlock ( ProcessBlockPrincipal const &  pbp,
ModuleDescription const &  md,
ModuleCallingContext const *  moduleCallingContext,
bool  isAtEnd 
)

Definition at line 7 of file ProcessBlock.cc.

Member Function Documentation

◆ cacheIdentifier()

ProcessBlock::CacheIdentifier_t edm::ProcessBlock::cacheIdentifier ( ) const

Definition at line 19 of file ProcessBlock.cc.

19  {
21  }

References edm::Principal::cacheIdentifier(), and processBlockPrincipal().

◆ commit_()

void edm::ProcessBlock::commit_ ( std::vector< edm::ProductResolverIndex > const &  iShouldPut)
private

Definition at line 29 of file ProcessBlock.cc.

29  {
30  ProcessBlockPrincipal const& pbp = processBlockPrincipal();
31  size_t nPut = 0;
32  for (size_t i = 0; i < putProducts().size(); ++i) {
33  auto& product = get_underlying_safe(putProducts()[i]);
34  if (product) {
36  ++nPut;
37  }
38  }
39 
40  auto sz = iShouldPut.size();
41  if (sz != 0 and sz != nPut) {
42  //some were missed
43  auto& principal = provRecorder_.principal();
44  for (auto index : iShouldPut) {
45  auto resolver = principal.getProductResolverByIndex(index);
46  if (not resolver->productResolved() and isEndTransition(provRecorder_.transition()) ==
47  resolver->branchDescription().availableOnlyAtEndTransition()) {
48  dynamic_cast<ProductPutterBase const*>(resolver)->putProduct(std::unique_ptr<WrapperBase>());
49  }
50  }
51  }
52 
53  // the cleanup is all or none
54  putProducts().clear();
55  }

References edm::get_underlying_safe(), edm::Principal::getProductResolverByIndex(), mps_fire::i, edm::isEndTransition(), eostools::move(), edm::PrincipalGetAdapter::principal(), processBlockPrincipal(), provRecorder_, edm::ProcessBlockPrincipal::put(), putProducts(), edm::PrincipalGetAdapter::putTokenIndexToProductResolverIndex(), and edm::PrincipalGetAdapter::transition().

Referenced by edm::stream::ProducingModuleAdaptorBase< EDProducerBase >::commit().

◆ emplace() [1/2]

template<typename PROD , typename... Args>
void edm::ProcessBlock::emplace ( EDPutToken  token,
Args &&...  args 
)

◆ emplace() [2/2]

template<typename PROD , typename... Args>
void edm::ProcessBlock::emplace ( EDPutTokenT< PROD token,
Args &&...  args 
)

Definition at line 171 of file ProcessBlock.h.

171  {
172  if (UNLIKELY(token.isUninitialized())) {
174  }
175  emplaceImpl<PROD>(token.index(), std::forward<Args>(args)...);
176  }

References writedatasetfile::args, PROD, edm::principal_get_adapter_detail::throwOnPutOfUninitializedToken(), unpackBuffers-CaloStage2::token, and UNLIKELY.

Referenced by AlignmentProducerAsAnalyzer::endProcessBlockProduce().

◆ emplaceImpl()

template<typename PROD , typename... Args>
void edm::ProcessBlock::emplaceImpl ( EDPutToken::value_type  token,
Args &&...  args 
)
private

Definition at line 204 of file ProcessBlock.h.

204  {
205  assert(index < putProducts().size());
206 
207  std::unique_ptr<Wrapper<PROD>> wp(new Wrapper<PROD>(WrapperBase::Emplace{}, std::forward<Args>(args)...));
208 
209  // The following will call post_insert if T has such a function,
210  // and do nothing if T has no such function.
211  std::conditional_t<detail::has_postinsert<PROD>::value, DoPostInsert<PROD>, DoNotPostInsert<PROD>> maybe_inserter;
212  maybe_inserter(&(wp->bareProduct()));
213 
215  }

References writedatasetfile::args, cms::cuda::assert(), eostools::move(), putProducts(), findQualityFiles::size, relativeConstraints::value, and pfClustersFromHGC3DClusters_cfi::wp.

◆ get()

template<typename PROD >
PROD const & edm::ProcessBlock::get ( EDGetTokenT< PROD token) const
noexcept

◆ getByToken() [1/2]

template<typename PROD >
bool edm::ProcessBlock::getByToken ( EDGetToken  token,
Handle< PROD > &  result 
) const

Definition at line 107 of file ProcessBlock.h.

107  {
108  result.clear();
109  BasicHandle bh = provRecorder_.getByToken_(TypeID(typeid(PROD)), PRODUCT_TYPE, token, moduleCallingContext_);
110  result = convert_handle<PROD>(std::move(bh)); // throws on conversion error
111  if (result.failedToGet()) {
112  return false;
113  }
114  return true;
115  }

References edm::PrincipalGetAdapter::getByToken_(), moduleCallingContext_, eostools::move(), PROD, edm::PRODUCT_TYPE, provRecorder_, mps_fire::result, and unpackBuffers-CaloStage2::token.

Referenced by edm::get().

◆ getByToken() [2/2]

template<typename PROD >
bool edm::ProcessBlock::getByToken ( EDGetTokenT< PROD token,
Handle< PROD > &  result 
) const

Definition at line 118 of file ProcessBlock.h.

118  {
119  result.clear();
120  BasicHandle bh = provRecorder_.getByToken_(TypeID(typeid(PROD)), PRODUCT_TYPE, token, moduleCallingContext_);
121  result = convert_handle<PROD>(std::move(bh)); // throws on conversion error
122  if (result.failedToGet()) {
123  return false;
124  }
125  return true;
126  }

References edm::PrincipalGetAdapter::getByToken_(), moduleCallingContext_, eostools::move(), PROD, edm::PRODUCT_TYPE, provRecorder_, mps_fire::result, and unpackBuffers-CaloStage2::token.

◆ getHandle()

template<typename PROD >
Handle< PROD > edm::ProcessBlock::getHandle ( EDGetTokenT< PROD token) const

◆ moduleCallingContext()

ModuleCallingContext const* edm::ProcessBlock::moduleCallingContext ( ) const
inline

Definition at line 78 of file ProcessBlock.h.

78 { return moduleCallingContext_; }

References moduleCallingContext_.

◆ processBlockPrincipal()

ProcessBlockPrincipal const & edm::ProcessBlock::processBlockPrincipal ( ) const
private

Definition at line 25 of file ProcessBlock.cc.

25  {
26  return dynamic_cast<ProcessBlockPrincipal const&>(provRecorder_.principal());
27  }

References edm::PrincipalGetAdapter::principal(), and provRecorder_.

Referenced by cacheIdentifier(), commit_(), and processName().

◆ processName()

std::string const & edm::ProcessBlock::processName ( ) const

◆ put() [1/2]

template<typename PROD >
void edm::ProcessBlock::put ( EDPutToken  token,
std::unique_ptr< PROD product 
)

◆ put() [2/2]

template<typename PROD >
void edm::ProcessBlock::put ( EDPutTokenT< PROD token,
std::unique_ptr< PROD product 
)

Definition at line 141 of file ProcessBlock.h.

141  {
142  if (UNLIKELY(product.get() == 0)) { // null pointer is illegal
143  TypeID typeID(typeid(PROD));
145  "ProcessBlock", typeID, provRecorder_.productInstanceLabel(token));
146  }
147  if (UNLIKELY(token.isUninitialized())) {
149  }
150  putImpl(token.index(), std::move(product));
151  }

References eostools::move(), PROD, edm::PrincipalGetAdapter::productInstanceLabel(), provRecorder_, putImpl(), edm::principal_get_adapter_detail::throwOnPutOfNullProduct(), edm::principal_get_adapter_detail::throwOnPutOfUninitializedToken(), unpackBuffers-CaloStage2::token, and UNLIKELY.

◆ putImpl()

template<typename PROD >
void edm::ProcessBlock::putImpl ( EDPutToken::value_type  token,
std::unique_ptr< PROD product 
)
private

Definition at line 191 of file ProcessBlock.h.

191  {
192  // The following will call post_insert if T has such a function,
193  // and do nothing if T has no such function.
194  std::conditional_t<detail::has_postinsert<PROD>::value, DoPostInsert<PROD>, DoNotPostInsert<PROD>> maybe_inserter;
195  maybe_inserter(product.get());
196 
197  assert(index < putProducts().size());
198 
199  std::unique_ptr<Wrapper<PROD>> wp(new Wrapper<PROD>(std::move(product)));
201  }

References cms::cuda::assert(), eostools::move(), putProducts(), findQualityFiles::size, relativeConstraints::value, and pfClustersFromHGC3DClusters_cfi::wp.

Referenced by put().

◆ putProducts() [1/2]

ProductPtrVec& edm::ProcessBlock::putProducts ( )
inlineprivate

Definition at line 98 of file ProcessBlock.h.

98 { return putProducts_; }

References putProducts_.

Referenced by commit_(), emplaceImpl(), and putImpl().

◆ putProducts() [2/2]

ProductPtrVec const& edm::ProcessBlock::putProducts ( ) const
inlineprivate

Definition at line 99 of file ProcessBlock.h.

99 { return putProducts_; }

References putProducts_.

◆ setConsumer()

void edm::ProcessBlock::setConsumer ( EDConsumerBase const *  iConsumer)
inline

Definition at line 53 of file ProcessBlock.h.

53 { provRecorder_.setConsumer(iConsumer); }

References provRecorder_, and edm::PrincipalGetAdapter::setConsumer().

Referenced by edm::one::EDFilterBase::doAccessInputProcessBlock(), edm::one::EDProducerBase::doAccessInputProcessBlock(), edm::one::EDAnalyzerBase::doAccessInputProcessBlock(), edm::global::EDAnalyzerBase::doAccessInputProcessBlock(), edm::global::EDProducerBase::doAccessInputProcessBlock(), edm::limited::EDProducerBase::doAccessInputProcessBlock(), edm::global::EDFilterBase::doAccessInputProcessBlock(), edm::limited::EDFilterBase::doAccessInputProcessBlock(), edm::limited::EDAnalyzerBase::doAccessInputProcessBlock(), edm::stream::EDAnalyzerAdaptor< T >::doAccessInputProcessBlock(), edm::stream::ProducingModuleAdaptor< T, M, B >::doAccessInputProcessBlock(), edm::one::EDFilterBase::doBeginProcessBlock(), edm::one::EDProducerBase::doBeginProcessBlock(), edm::one::EDAnalyzerBase::doBeginProcessBlock(), edm::global::EDAnalyzerBase::doBeginProcessBlock(), edm::global::EDProducerBase::doBeginProcessBlock(), edm::limited::EDProducerBase::doBeginProcessBlock(), edm::global::EDFilterBase::doBeginProcessBlock(), edm::limited::EDFilterBase::doBeginProcessBlock(), edm::limited::EDAnalyzerBase::doBeginProcessBlock(), edm::stream::EDAnalyzerAdaptor< T >::doBeginProcessBlock(), edm::stream::ProducingModuleAdaptor< T, M, B >::doBeginProcessBlock(), edm::one::EDFilterBase::doEndProcessBlock(), edm::one::EDProducerBase::doEndProcessBlock(), edm::one::EDAnalyzerBase::doEndProcessBlock(), edm::global::EDAnalyzerBase::doEndProcessBlock(), edm::global::EDProducerBase::doEndProcessBlock(), edm::limited::EDProducerBase::doEndProcessBlock(), edm::global::EDFilterBase::doEndProcessBlock(), edm::limited::EDFilterBase::doEndProcessBlock(), edm::limited::EDAnalyzerBase::doEndProcessBlock(), edm::stream::EDAnalyzerAdaptor< T >::doEndProcessBlock(), and edm::stream::ProducingModuleAdaptor< T, M, B >::doEndProcessBlock().

◆ setProducer()

void edm::ProcessBlock::setProducer ( ProducerBase const *  iProducer)

Friends And Related Function Documentation

◆ ProducerBase

friend class ProducerBase
friend

Definition at line 91 of file ProcessBlock.h.

◆ stream::ProducingModuleAdaptorBase

template<typename T >
friend class stream::ProducingModuleAdaptorBase
friend

Definition at line 93 of file ProcessBlock.h.

Member Data Documentation

◆ moduleCallingContext_

ModuleCallingContext const* edm::ProcessBlock::moduleCallingContext_
private

Definition at line 103 of file ProcessBlock.h.

Referenced by getByToken(), getHandle(), and moduleCallingContext().

◆ provRecorder_

PrincipalGetAdapter edm::ProcessBlock::provRecorder_
private

◆ putProducts_

ProductPtrVec edm::ProcessBlock::putProducts_
private

Definition at line 102 of file ProcessBlock.h.

Referenced by putProducts(), and setProducer().

writedatasetfile.args
args
Definition: writedatasetfile.py:18
edm::PrincipalGetAdapter::setConsumer
void setConsumer(EDConsumerBase const *iConsumer)
Definition: PrincipalGetAdapter.h:143
edm::PrincipalGetAdapter::principal
Principal const & principal() const
Definition: PrincipalGetAdapter.h:165
edm::principal_get_adapter_detail::throwOnPutOfWrongType
void throwOnPutOfWrongType(std::type_info const &wrongType, TypeID const &rightType)
Definition: PrincipalGetAdapter.cc:48
mps_fire.i
i
Definition: mps_fire.py:428
edm::PrincipalGetAdapter::setProducer
void setProducer(ProducerBase const *iProd)
Definition: PrincipalGetAdapter.h:149
edm::PRODUCT_TYPE
Definition: ProductKindOfType.h:5
edm::isEndTransition
constexpr bool isEndTransition(Transition iValue)
Definition: Transition.h:37
pfClustersFromHGC3DClusters_cfi.wp
wp
Definition: pfClustersFromHGC3DClusters_cfi.py:20
edm::ProcessBlock::putProducts_
ProductPtrVec putProducts_
Definition: ProcessBlock.h:102
edm::ProcessBlock::putImpl
void putImpl(EDPutToken::value_type token, std::unique_ptr< PROD > product)
Definition: ProcessBlock.h:191
cms::cuda::assert
assert(be >=bs)
edm::principal_get_adapter_detail::throwOnPutOfUninitializedToken
void throwOnPutOfUninitializedToken(char const *principalType, std::type_info const &productType)
Definition: PrincipalGetAdapter.cc:41
edm::ProcessBlockPrincipal::processName
std::string const & processName() const
Definition: ProcessBlockPrincipal.h:30
edm::get_underlying_safe
constexpr std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
Definition: get_underlying_safe.h:41
edm::ProcessBlock::moduleCallingContext_
ModuleCallingContext const * moduleCallingContext_
Definition: ProcessBlock.h:103
edm::PrincipalGetAdapter::putTokenIndexToProductResolverIndex
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex() const
Definition: PrincipalGetAdapter.cc:293
edm::Principal::getProductResolverByIndex
ConstProductResolverPtr getProductResolverByIndex(ProductResolverIndex const &oid) const
Definition: Principal.cc:562
UNLIKELY
#define UNLIKELY(x)
Definition: Likely.h:21
edm::ProcessBlock::putProducts
ProductPtrVec & putProducts()
Definition: ProcessBlock.h:98
edm::PrincipalGetAdapter::getByToken_
BasicHandle getByToken_(TypeID const &id, KindOfType kindOfType, EDGetToken token, ModuleCallingContext const *mcc) const
Definition: PrincipalGetAdapter.cc:151
edm::PrincipalGetAdapter::transition
Transition transition() const
Definition: PrincipalGetAdapter.cc:253
edm::ProcessBlock::processBlockPrincipal
ProcessBlockPrincipal const & processBlockPrincipal() const
Definition: ProcessBlock.cc:25
edm::ProcessBlock::moduleCallingContext
ModuleCallingContext const * moduleCallingContext() const
Definition: ProcessBlock.h:78
edm::PrincipalGetAdapter::getTypeIDForPutTokenIndex
TypeID const & getTypeIDForPutTokenIndex(EDPutToken::value_type index) const
Definition: PrincipalGetAdapter.cc:289
edm::PrincipalGetAdapter::productInstanceLabel
std::string const & productInstanceLabel(EDPutToken) const
Definition: PrincipalGetAdapter.cc:285
edm::principal_get_adapter_detail::throwOnPutOfNullProduct
void throwOnPutOfNullProduct(char const *principalType, TypeID const &productType, std::string const &productInstanceName)
Definition: PrincipalGetAdapter.cc:32
eostools.move
def move(src, dest)
Definition: eostools.py:511
relativeConstraints.value
value
Definition: relativeConstraints.py:53
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
mps_fire.result
result
Definition: mps_fire.py:311
PROD
#define PROD(A, B)
Definition: Simplify_begin.h:55
edm::ProcessBlock::provRecorder_
PrincipalGetAdapter provRecorder_
Definition: ProcessBlock.h:101
edm::Principal::cacheIdentifier
CacheIdentifier_t cacheIdentifier() const
Definition: Principal.h:185
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316