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)
 
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 95 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 6 of file ProcessBlock.cc.

Member Function Documentation

◆ cacheIdentifier()

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

Definition at line 18 of file ProcessBlock.cc.

18  {
20  }

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

◆ commit_()

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

Definition at line 26 of file ProcessBlock.cc.

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

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 169 of file ProcessBlock.h.

169  {
170  if (UNLIKELY(token.isUninitialized())) {
172  }
173  emplaceImpl<PROD>(token.index(), std::forward<Args>(args)...);
174  }

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 202 of file ProcessBlock.h.

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

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 105 of file ProcessBlock.h.

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

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 116 of file ProcessBlock.h.

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

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 22 of file ProcessBlock.cc.

22  {
23  return dynamic_cast<ProcessBlockPrincipal const&>(provRecorder_.principal());
24  }

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

Referenced by cacheIdentifier(), and commit_().

◆ 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 139 of file ProcessBlock.h.

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

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 189 of file ProcessBlock.h.

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

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 96 of file ProcessBlock.h.

96 { return putProducts_; }

References putProducts_.

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

◆ putProducts() [2/2]

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

Definition at line 97 of file ProcessBlock.h.

97 { 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::limited::EDFilterBase::doAccessInputProcessBlock(), edm::global::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::limited::EDFilterBase::doBeginProcessBlock(), edm::global::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::limited::EDFilterBase::doEndProcessBlock(), edm::global::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 89 of file ProcessBlock.h.

◆ stream::ProducingModuleAdaptorBase

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

Definition at line 91 of file ProcessBlock.h.

Member Data Documentation

◆ moduleCallingContext_

ModuleCallingContext const* edm::ProcessBlock::moduleCallingContext_
private

Definition at line 101 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 100 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:100
edm::ProcessBlock::putImpl
void putImpl(EDPutToken::value_type token, std::unique_ptr< PROD > product)
Definition: ProcessBlock.h:189
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::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:101
edm::PrincipalGetAdapter::putTokenIndexToProductResolverIndex
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex() const
Definition: PrincipalGetAdapter.cc:289
edm::Principal::getProductResolverByIndex
ConstProductResolverPtr getProductResolverByIndex(ProductResolverIndex const &oid) const
Definition: Principal.cc:553
UNLIKELY
#define UNLIKELY(x)
Definition: Likely.h:21
edm::ProcessBlock::putProducts
ProductPtrVec & putProducts()
Definition: ProcessBlock.h:96
edm::PrincipalGetAdapter::getByToken_
BasicHandle getByToken_(TypeID const &id, KindOfType kindOfType, EDGetToken token, ModuleCallingContext const *mcc) const
Definition: PrincipalGetAdapter.cc:147
edm::PrincipalGetAdapter::transition
Transition transition() const
Definition: PrincipalGetAdapter.cc:249
edm::ProcessBlock::processBlockPrincipal
ProcessBlockPrincipal const & processBlockPrincipal() const
Definition: ProcessBlock.cc:22
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:285
edm::PrincipalGetAdapter::productInstanceLabel
std::string const & productInstanceLabel(EDPutToken) const
Definition: PrincipalGetAdapter.cc:281
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:99
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:318