CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Types | Protected Member Functions | Private Types | Private Attributes
edm::TransformerBase Class Reference

#include <TransformerBase.h>

Inheritance diagram for edm::TransformerBase:
edm::global::impl::Transformer< T > edm::limited::impl::Transformer< T > edm::one::impl::Transformer< T > edm::stream::impl::Transformer

Public Member Functions

 TransformerBase ()=default
 
virtual ~TransformerBase () noexcept(false)=default
 

Protected Types

using PreTransformFunction = std::function< std::any(edm::WrapperBase const &, edm::WaitingTaskWithArenaHolder)>
 
using TransformFunction = std::function< std::unique_ptr< edm::WrapperBase >(std::any)>
 

Protected Member Functions

void extendUpdateLookup (ProducerBase const &, ModuleDescription const &iModuleDesc, ProductResolverIndexHelper const &iHelper)
 
std::size_t findMatchingIndex (ProducerBase const &iBase, edm::BranchDescription const &) const
 
ProductResolverIndex prefetchImp (std::size_t iIndex) const
 
void registerTransformAsyncImp (ProducerBase &, EDPutToken, const TypeID &id, std::string instanceName, PreTransformFunction, TransformFunction)
 
void registerTransformImp (ProducerBase &, EDPutToken, const TypeID &id, std::string instanceName, TransformFunction)
 
void transformImpAsync (WaitingTaskHolder iTask, std::size_t iIndex, edm::ActivityRegistry *iAct, ProducerBase const &iBase, edm::EventForTransformer &) const
 

Private Types

enum  InfoColumns {
  kResolverIndex, kType, kToken, kPreTransform,
  kTransform
}
 

Private Attributes

SoATuple< ProductResolverIndex, TypeID, EDPutToken, PreTransformFunction, TransformFunctiontransformInfo_
 

Detailed Description

Definition at line 33 of file TransformerBase.h.

Member Typedef Documentation

◆ PreTransformFunction

Definition at line 42 of file TransformerBase.h.

◆ TransformFunction

using edm::TransformerBase::TransformFunction = std::function<std::unique_ptr<edm::WrapperBase>(std::any)>
protected

Definition at line 41 of file TransformerBase.h.

Member Enumeration Documentation

◆ InfoColumns

Constructor & Destructor Documentation

◆ TransformerBase()

edm::TransformerBase::TransformerBase ( )
default

◆ ~TransformerBase()

virtual edm::TransformerBase::~TransformerBase ( )
virtualdefaultnoexcept

Member Function Documentation

◆ extendUpdateLookup()

void edm::TransformerBase::extendUpdateLookup ( ProducerBase const &  iBase,
ModuleDescription const &  iModuleDesc,
ProductResolverIndexHelper const &  iHelper 
)
protected

Definition at line 94 of file TransformerBase.cc.

References edm::ProductResolverIndexHelper::index(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, edm::ModuleDescription::moduleLabel(), edm::ModuleDescription::processName(), edm::PRODUCT_TYPE, transformInfo_, and edm::ProducerBase::typeLabelList().

Referenced by edm::stream::impl::Transformer::extendUpdateLookup(), edm::one::impl::Transformer< T >::extendUpdateLookup(), edm::limited::impl::Transformer< T >::extendUpdateLookup(), and edm::global::impl::Transformer< T >::extendUpdateLookup().

96  {
97  auto const& list = iBase.typeLabelList();
98 
99  for (auto it = transformInfo_.begin<0>(); it != transformInfo_.end<0>(); ++it) {
100  auto const& putInfo = list[*it];
101  *it = iHelper.index(PRODUCT_TYPE,
102  putInfo.typeID_,
103  iModuleDesc.moduleLabel().c_str(),
104  putInfo.productInstanceName_.c_str(),
105  iModuleDesc.processName().c_str());
106  }
107  }
SoATuple< ProductResolverIndex, TypeID, EDPutToken, PreTransformFunction, TransformFunction > transformInfo_

◆ findMatchingIndex()

std::size_t edm::TransformerBase::findMatchingIndex ( ProducerBase const &  iBase,
edm::BranchDescription const &  iBranch 
) const
protected

Definition at line 73 of file TransformerBase.cc.

References cms::cuda::assert(), newFWLiteAna::found, edm::BranchDescription::productInstanceName(), edm::ProducerBase::typeLabelList(), and edm::BranchDescription::unwrappedTypeID().

Referenced by edm::stream::impl::Transformer::transformIndex_(), edm::one::impl::Transformer< T >::transformIndex_(), edm::limited::impl::Transformer< T >::transformIndex_(), and edm::global::impl::Transformer< T >::transformIndex_().

74  {
75  auto const& list = iBase.typeLabelList();
76 
77  std::size_t index = 0;
78  bool found = false;
79  for (auto const& element : list) {
80  if (not element.isTransform_) {
81  continue;
82  }
83  if (element.typeID_ == iBranch.unwrappedTypeID() &&
84  element.productInstanceName_ == iBranch.productInstanceName()) {
85  found = true;
86  break;
87  }
88  ++index;
89  }
90  assert(found);
91  return index;
92  }
assert(be >=bs)

◆ prefetchImp()

ProductResolverIndex edm::TransformerBase::prefetchImp ( std::size_t  iIndex) const
inlineprotected

◆ registerTransformAsyncImp()

void edm::TransformerBase::registerTransformAsyncImp ( ProducerBase iBase,
EDPutToken  iToken,
const TypeID id,
std::string  instanceName,
PreTransformFunction  iPreFunc,
TransformFunction  iFunc 
)
protected

Definition at line 63 of file TransformerBase.cc.

References l1ctLayer2EG_cff::id, edm::EDPutToken::index(), eostools::move(), transformInfo_, and edm::ProducerBase::transforms().

Referenced by edm::stream::impl::Transformer::registerTransformAsync(), edm::one::impl::Transformer< T >::registerTransformAsync(), edm::limited::impl::Transformer< T >::registerTransformAsync(), and edm::global::impl::Transformer< T >::registerTransformAsync().

68  {
69  auto transformPut = iBase.transforms(id, std::move(instanceName));
70  transformInfo_.emplace_back(iToken.index(), id, transformPut, std::move(iPreFunc), std::move(iFunc));
71  }
SoATuple< ProductResolverIndex, TypeID, EDPutToken, PreTransformFunction, TransformFunction > transformInfo_
def move(src, dest)
Definition: eostools.py:511

◆ registerTransformImp()

void edm::TransformerBase::registerTransformImp ( ProducerBase iBase,
EDPutToken  iToken,
const TypeID id,
std::string  instanceName,
TransformFunction  iFunc 
)
protected

Definition at line 56 of file TransformerBase.cc.

References l1ctLayer2EG_cff::id, edm::EDPutToken::index(), eostools::move(), transformInfo_, and edm::ProducerBase::transforms().

Referenced by edm::stream::impl::Transformer::registerTransform(), edm::one::impl::Transformer< T >::registerTransform(), edm::limited::impl::Transformer< T >::registerTransform(), and edm::global::impl::Transformer< T >::registerTransform().

57  {
58  auto transformPut = iBase.transforms(id, std::move(instanceName));
60  transformInfo_.emplace_back(iToken.index(), id, transformPut, std::move(ptf), std::move(iFunc));
61  }
std::function< std::any(edm::WrapperBase const &, edm::WaitingTaskWithArenaHolder)> PreTransformFunction
SoATuple< ProductResolverIndex, TypeID, EDPutToken, PreTransformFunction, TransformFunction > transformInfo_
def move(src, dest)
Definition: eostools.py:511

◆ transformImpAsync()

void edm::TransformerBase::transformImpAsync ( edm::WaitingTaskHolder  iHolder,
std::size_t  iIndex,
edm::ActivityRegistry iAct,
ProducerBase const &  iBase,
edm::EventForTransformer iEvent 
) const
protected

Definition at line 109 of file TransformerBase.cc.

References any(), utilities::cache(), CMS_SA_ALLOW, edm::WaitingTaskHolder::doneWaiting(), edm::ModuleCallingContext::getStreamContext(), edm::WaitingTaskHolder::group(), patZpeak::handle, iEvent, kPreTransform, kResolverIndex, kToken, kTransform, kType, edm::make_waiting_task(), eostools::move(), Types::optional, edm::ProducerBase::putTokenIndexToProductResolverIndex(), transformInfo_, and findQualityFiles::v.

Referenced by edm::stream::impl::Transformer::transformAsync_(), edm::one::impl::Transformer< T >::transformAsync_(), edm::limited::impl::Transformer< T >::transformAsync_(), and edm::global::impl::Transformer< T >::transformAsync_().

113  {
114  auto const& mcc = iEvent.moduleCallingContext();
115  if (transformInfo_.get<kPreTransform>(iIndex)) {
116  std::optional<decltype(iEvent.get(transformInfo_.get<kType>(iIndex), transformInfo_.get<kResolverIndex>(iIndex)))>
117  handle;
118  //transform acquiring signal
119  TransformAcquiringSignalSentry sentry(iAct, *mcc.getStreamContext(), mcc);
120  CMS_SA_ALLOW try {
121  handle = iEvent.get(transformInfo_.get<kType>(iIndex), transformInfo_.get<kResolverIndex>(iIndex));
122  } catch (...) {
123  iHolder.doneWaiting(std::current_exception());
124  return;
125  }
126  if (handle->wrapper()) {
127  auto cache = std::make_shared<std::any>();
128  auto nextTask =
129  edm::make_waiting_task([holder = iHolder, cache, iIndex, this, &iBase, handle = *handle, iEvent, iAct](
130  std::exception_ptr const* iPtr) mutable {
131  if (iPtr) {
132  holder.doneWaiting(*iPtr);
133  } else {
134  //transform signal
135  auto mcc = iEvent.moduleCallingContext();
136  TransformSignalSentry sentry(iAct, *mcc.getStreamContext(), mcc);
137  iEvent.put(iBase.putTokenIndexToProductResolverIndex()[transformInfo_.get<kToken>(iIndex).index()],
138  transformInfo_.get<kTransform>(iIndex)(std::move(*cache)),
139  handle);
140  }
141  });
142  WaitingTaskWithArenaHolder wta(*iHolder.group(), nextTask);
143  CMS_SA_ALLOW try {
144  *cache = transformInfo_.get<kPreTransform>(iIndex)(*(handle->wrapper()), wta);
145  } catch (...) {
146  wta.doneWaiting(std::current_exception());
147  }
148  }
149  } else {
150  CMS_SA_ALLOW try {
151  auto handle = iEvent.get(transformInfo_.get<kType>(iIndex), transformInfo_.get<kResolverIndex>(iIndex));
152 
153  if (handle.wrapper()) {
154  std::any v = handle.wrapper();
155  //transform signal
156  TransformSignalSentry sentry(iAct, *mcc.getStreamContext(), mcc);
157  iEvent.put(iBase.putTokenIndexToProductResolverIndex()[transformInfo_.get<kToken>(iIndex).index()],
158  transformInfo_.get<kTransform>(iIndex)(std::move(v)),
159  handle);
160  }
161  } catch (...) {
162  iHolder.doneWaiting(std::current_exception());
163  }
164  }
165  }
#define CMS_SA_ALLOW
SoATuple< ProductResolverIndex, TypeID, EDPutToken, PreTransformFunction, TransformFunction > transformInfo_
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:36
oneapi::tbb::task_group * group() const noexcept
int iEvent
Definition: GenABIO.cc:224
void doneWaiting(std::exception_ptr iExcept)
FunctorWaitingTask< F > * make_waiting_task(F f)
Definition: WaitingTask.h:92
optional
Definition: Types.py:239
def cache(function)
Definition: utilities.py:3
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ transformInfo_

SoATuple<ProductResolverIndex, TypeID, EDPutToken, PreTransformFunction, TransformFunction> edm::TransformerBase::transformInfo_
private