test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
edm::PrincipalGetAdapter Class Reference

#include <PrincipalGetAdapter.h>

Public Types

typedef std::vector< BasicHandleBasicHandleVec
 

Public Member Functions

template<typename PROD >
bool checkIfComplete () const
 
BranchDescription const & getBranchDescription (TypeID const &type, std::string const &productInstanceName) const
 
BasicHandle getByLabel_ (TypeID const &tid, InputTag const &tag, ModuleCallingContext const *mcc) const
 
BasicHandle getByLabel_ (TypeID const &tid, std::string const &label, std::string const &instance, std::string const &process, ModuleCallingContext const *mcc) const
 
BasicHandle getByToken_ (TypeID const &id, KindOfType kindOfType, EDGetToken token, ModuleCallingContext const *mcc) const
 
template<typename PROD >
void getManyByType (std::vector< Handle< PROD > > &results, ModuleCallingContext const *mcc) const
 
void getManyByType_ (TypeID const &tid, BasicHandleVec &results, ModuleCallingContext const *mcc) const
 
BasicHandle getMatchingSequenceByLabel_ (TypeID const &typeID, InputTag const &tag, ModuleCallingContext const *mcc) const
 
BasicHandle getMatchingSequenceByLabel_ (TypeID const &typeID, std::string const &label, std::string const &instance, std::string const &process, ModuleCallingContext const *mcc) const
 
bool isComplete () const
 
void labelsForToken (EDGetToken const &iToken, ProductLabels &oLabels) const
 
PrincipalGetAdapteroperator= (PrincipalGetAdapter const &)=delete
 
Principal const & principal () const
 
 PrincipalGetAdapter (Principal const &pcpl, ModuleDescription const &md)
 
 PrincipalGetAdapter (PrincipalGetAdapter const &)=delete
 
ProcessHistory const & processHistory () const
 
EDProductGetter const * prodGetter () const
 
void setConsumer (EDConsumerBase const *iConsumer)
 
void setSharedResourcesAcquirer (SharedResourcesAcquirer *iSra)
 
 ~PrincipalGetAdapter ()
 

Private Member Functions

BranchType const & branchType () const
 
BasicHandle makeFailToGetException (KindOfType, TypeID const &, EDGetToken) const
 
void throwAmbiguousException (TypeID const &productType, EDGetToken token) const
 

Private Attributes

EDConsumerBase const * consumer_
 
ModuleDescription const & md_
 
Principal const & principal_
 
SharedResourcesAcquirerresourcesAcquirer_
 

Detailed Description

Definition at line 127 of file PrincipalGetAdapter.h.

Member Typedef Documentation

Definition at line 166 of file PrincipalGetAdapter.h.

Constructor & Destructor Documentation

PrincipalGetAdapter::PrincipalGetAdapter ( Principal const &  pcpl,
ModuleDescription const &  md 
)

Definition at line 20 of file PrincipalGetAdapter.cc.

21  :
22  //putProducts_(),
23  principal_(pcpl),
24  md_(md),
25  consumer_(nullptr),
26  resourcesAcquirer_(nullptr)
27  {
28  }
SharedResourcesAcquirer * resourcesAcquirer_
EDConsumerBase const * consumer_
ModuleDescription const & md_
PrincipalGetAdapter::~PrincipalGetAdapter ( )

Definition at line 30 of file PrincipalGetAdapter.cc.

30  {
31  }
edm::PrincipalGetAdapter::PrincipalGetAdapter ( PrincipalGetAdapter const &  )
delete

Member Function Documentation

BranchType const & PrincipalGetAdapter::branchType ( ) const
private

Definition at line 143 of file PrincipalGetAdapter.cc.

References edm::Principal::branchType(), and principal_.

Referenced by getByToken_().

143  {
144  return principal_.branchType();
145  }
BranchType const & branchType() const
Definition: Principal.h:172
template<typename PROD >
bool PrincipalGetAdapter::checkIfComplete ( ) const
inline
BranchDescription const & PrincipalGetAdapter::getBranchDescription ( TypeID const &  type,
std::string const &  productInstanceName 
) const

Definition at line 223 of file PrincipalGetAdapter.cc.

References edm::ProductRegistry::allBranchDescriptions(), assert(), edm::ProductResolverBase::branchDescription(), Exception, edm::TypeID::friendlyClassName(), edm::Principal::getProductResolverByIndex(), edm::ProductResolverIndexHelper::index(), cmsHarvester::index, edm::errors::InsertFailure, md_, edm::ModuleDescription::moduleLabel(), principal_, edm::ModuleDescription::processName(), edm::PRODUCT_TYPE, edm::Principal::productLookup(), edm::Principal::productRegistry(), and edm::ProductResolverIndexInvalid.

Referenced by edm::Event::getRefBeforePut(), edm::LuminosityBlock::put(), edm::Run::put(), and edm::Event::put().

224  {
225  ProductResolverIndexHelper const& productResolverIndexHelper = principal_.productLookup();
226  ProductResolverIndex index = productResolverIndexHelper.index(PRODUCT_TYPE, type, md_.moduleLabel().c_str(),productInstanceName.c_str(), md_.processName().c_str());
227  if(index == ProductResolverIndexInvalid) {
228  std::ostringstream str;
229  for(auto branchDescription: principal_.productRegistry().allBranchDescriptions()) {
230  if (branchDescription->moduleLabel() == md_.moduleLabel() and branchDescription->processName() == md_.processName()) {
231  str << *branchDescription<< "-----\n";
232  }
233  }
235  << "Illegal attempt to 'put' an unregistered product.\n"
236  << "No product is registered for\n"
237  << " product friendly class name: '" << type.friendlyClassName() << "'\n"
238  << " module label: '" << md_.moduleLabel() << "'\n"
239  << " product instance name: '" << productInstanceName << "'\n"
240  << " process name: '" << md_.processName() << "'\n"
241 
242  << "The following data products are registered for production by "<<md_.moduleLabel()<<":\n"
243  << str.str()
244  << '\n'
245  << "To correct the problem:\n"
246  " 1) make sure the proper 'produce' call is being made in the module's constructor,\n"
247  " 2) if 'produce' exists and uses a product instance name make sure that same name is used during the 'put' call.";
248  }
249  ProductResolverBase const* phb = principal_.getProductResolverByIndex(index);
250  assert(phb != nullptr);
251  return phb->branchDescription();
252  }
type
Definition: HCALResponse.h:21
ProductRegistry const & productRegistry() const
Definition: Principal.h:145
unsigned int ProductResolverIndex
std::string const & processName() const
assert(m_qm.get())
std::string const & moduleLabel() const
std::vector< BranchDescription const * > allBranchDescriptions() const
ProductResolverIndexHelper const & productLookup() const
Definition: Principal.h:147
ConstProductResolverPtr getProductResolverByIndex(ProductResolverIndex const &oid) const
Definition: Principal.cc:442
ModuleDescription const & md_
BasicHandle PrincipalGetAdapter::getByLabel_ ( TypeID const &  tid,
InputTag const &  tag,
ModuleCallingContext const *  mcc 
) const

Definition at line 148 of file PrincipalGetAdapter.cc.

References consumer_, edm::Principal::getByLabel(), principal_, edm::PRODUCT_TYPE, and resourcesAcquirer_.

Referenced by edm::LuminosityBlock::getByLabel(), edm::Run::getByLabel(), edm::Event::getByLabel(), edm::LuminosityBlock::getByLabelImpl(), edm::Run::getByLabelImpl(), and edm::Event::getByLabelImpl().

150  {
152  }
SharedResourcesAcquirer * resourcesAcquirer_
EDConsumerBase const * consumer_
BasicHandle getByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumes, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
Definition: Principal.cc:449
BasicHandle PrincipalGetAdapter::getByLabel_ ( TypeID const &  tid,
std::string const &  label,
std::string const &  instance,
std::string const &  process,
ModuleCallingContext const *  mcc 
) const

Definition at line 155 of file PrincipalGetAdapter.cc.

References consumer_, edm::Principal::getByLabel(), principal_, edm::PRODUCT_TYPE, and resourcesAcquirer_.

159  {
161  }
SharedResourcesAcquirer * resourcesAcquirer_
static PFTauRenderPlugin instance
EDConsumerBase const * consumer_
BasicHandle getByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumes, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
Definition: Principal.cc:449
tuple process
Definition: LaserDQM_cfg.py:3
BasicHandle PrincipalGetAdapter::getByToken_ ( TypeID const &  id,
KindOfType  kindOfType,
EDGetToken  token,
ModuleCallingContext const *  mcc 
) const

Definition at line 164 of file PrincipalGetAdapter.cc.

References branchType(), consumer_, edm::Principal::getByToken(), h, cmsHarvester::index, edm::EDConsumerBase::indexFrom(), edm::BasicHandle::isValid(), makeFailToGetException(), principal_, edm::ProductResolverIndexAndSkipBit::productResolverIndex(), edm::ProductResolverIndexAmbiguous, edm::ProductResolverIndexInvalid, resourcesAcquirer_, edm::ProductResolverIndexAndSkipBit::skipCurrentProcess(), throwAmbiguousException(), and unlikely.

Referenced by edm::OccurrenceForOutput::getByToken(), edm::LuminosityBlock::getByToken(), edm::Run::getByToken(), and edm::Event::getByToken().

165  {
166  ProductResolverIndexAndSkipBit indexAndBit = consumer_->indexFrom(token,branchType(),id);
167  ProductResolverIndex index = indexAndBit.productResolverIndex();
168  bool skipCurrentProcess = indexAndBit.skipCurrentProcess();
169  if( unlikely(index == ProductResolverIndexInvalid)) {
170  return makeFailToGetException(kindOfType,id,token);
171  } else if( unlikely(index == ProductResolverIndexAmbiguous)) {
172  // This deals with ambiguities where the process is specified
173  throwAmbiguousException(id, token);
174  }
175  bool ambiguous = false;
176  BasicHandle h = principal_.getByToken(kindOfType, id, index, skipCurrentProcess, ambiguous, resourcesAcquirer_, mcc);
177  if (ambiguous) {
178  // This deals with ambiguities where the process is not specified
179  throwAmbiguousException(id, token);
180  } else if(!h.isValid()) {
181  return makeFailToGetException(kindOfType,id,token);
182  }
183  return h;
184  }
SharedResourcesAcquirer * resourcesAcquirer_
unsigned int ProductResolverIndex
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
EDConsumerBase const * consumer_
#define unlikely(x)
BranchType const & branchType() const
ProductResolverIndexAndSkipBit indexFrom(EDGetToken, BranchType, TypeID const &) const
BasicHandle makeFailToGetException(KindOfType, TypeID const &, EDGetToken) const
BasicHandle getByToken(KindOfType kindOfType, TypeID const &typeID, ProductResolverIndex index, bool skipCurrentProcess, bool &ambiguous, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
Definition: Principal.cc:485
void throwAmbiguousException(TypeID const &productType, EDGetToken token) const
template<typename PROD >
void PrincipalGetAdapter::getManyByType ( std::vector< Handle< PROD > > &  results,
ModuleCallingContext const *  mcc 
) const
inline

Definition at line 323 of file PrincipalGetAdapter.h.

References edm::convert_handle(), end, getManyByType_(), eostools::move(), PROD, edm::es::products(), mps_fire::result, and mps_update::results.

Referenced by edm::LuminosityBlock::getManyByType(), edm::Run::getManyByType(), and edm::Event::getManyByType().

324  {
325  BasicHandleVec bhv;
326  this->getManyByType_(TypeID(typeid(PROD)), bhv, mcc);
327 
328  // Go through the returned handles; for each element,
329  // 1. create a Handle<PROD> and
330  //
331  // This function presents an exception safety difficulty. If an
332  // exception is thrown when converting a handle, the "got
333  // products" record will be wrong.
334  //
335  // Since EDProducers are not allowed to use this function,
336  // the problem does not seem too severe.
337  //
338  // Question: do we even need to keep track of the "got products"
339  // for this function, since it is *not* to be used by EDProducers?
340  std::vector<Handle<PROD> > products;
341 
342  typename BasicHandleVec::iterator it = bhv.begin();
343  typename BasicHandleVec::iterator end = bhv.end();
344 
345  while (it != end) {
347  convert_handle(std::move(*it), result); // throws on conversion error
348  products.push_back(result);
349  ++it;
350  }
351  results.swap(products);
352  }
tuple result
Definition: mps_fire.py:84
ESProducts< T, S > products(const T &i1, const S &i2)
Definition: ESProducts.h:189
def move
Definition: eostools.py:510
tuple results
Definition: mps_update.py:44
#define end
Definition: vmac.h:37
void convert_handle(BasicHandle &&bh, Handle< T > &result)
Definition: ConvertHandle.h:19
void getManyByType_(TypeID const &tid, BasicHandleVec &results, ModuleCallingContext const *mcc) const
#define PROD(A, B)
std::vector< BasicHandle > BasicHandleVec
void PrincipalGetAdapter::getManyByType_ ( TypeID const &  tid,
BasicHandleVec results,
ModuleCallingContext const *  mcc 
) const

Definition at line 211 of file PrincipalGetAdapter.cc.

References consumer_, edm::Principal::getManyByType(), principal_, and resourcesAcquirer_.

Referenced by getManyByType().

213  {
215  }
SharedResourcesAcquirer * resourcesAcquirer_
EDConsumerBase const * consumer_
tuple results
Definition: mps_update.py:44
void getManyByType(TypeID const &typeID, BasicHandleVec &results, EDConsumerBase const *consumes, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
Definition: Principal.cc:518
BasicHandle PrincipalGetAdapter::getMatchingSequenceByLabel_ ( TypeID const &  typeID,
InputTag const &  tag,
ModuleCallingContext const *  mcc 
) const

Definition at line 187 of file PrincipalGetAdapter.cc.

References consumer_, edm::ELEMENT_TYPE, edm::Principal::getByLabel(), principal_, and resourcesAcquirer_.

Referenced by edm::Event::getByLabel().

189  {
191  }
SharedResourcesAcquirer * resourcesAcquirer_
EDConsumerBase const * consumer_
BasicHandle getByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumes, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
Definition: Principal.cc:449
BasicHandle PrincipalGetAdapter::getMatchingSequenceByLabel_ ( TypeID const &  typeID,
std::string const &  label,
std::string const &  instance,
std::string const &  process,
ModuleCallingContext const *  mcc 
) const

Definition at line 194 of file PrincipalGetAdapter.cc.

References consumer_, edm::ELEMENT_TYPE, edm::Principal::getByLabel(), h, principal_, and resourcesAcquirer_.

198  {
200  typeID,
201  label,
202  instance,
203  process,
204  consumer_,
206  mcc);
207  return h;
208  }
SharedResourcesAcquirer * resourcesAcquirer_
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
static PFTauRenderPlugin instance
EDConsumerBase const * consumer_
BasicHandle getByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumes, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
Definition: Principal.cc:449
tuple process
Definition: LaserDQM_cfg.py:3
bool PrincipalGetAdapter::isComplete ( ) const

Definition at line 260 of file PrincipalGetAdapter.cc.

References edm::Principal::isComplete(), and principal_.

Referenced by checkIfComplete(), and edm::OccurrenceForOutput::getByToken().

260  {
261  return principal_.isComplete();
262  }
bool isComplete() const
Definition: Principal.h:194
void PrincipalGetAdapter::labelsForToken ( EDGetToken const &  iToken,
ProductLabels oLabels 
) const

Definition at line 101 of file PrincipalGetAdapter.cc.

References consumer_, and edm::EDConsumerBase::labelsForToken().

Referenced by edm::LuminosityBlock::labelsForToken(), edm::Run::labelsForToken(), and edm::Event::labelsForToken().

101  {
102  consumer_->labelsForToken(iToken,oLabels);
103  }
EDConsumerBase const * consumer_
void labelsForToken(EDGetToken iToken, Labels &oLabels) const
BasicHandle PrincipalGetAdapter::makeFailToGetException ( KindOfType  kindOfType,
TypeID const &  productType,
EDGetToken  token 
) const
private

Definition at line 106 of file PrincipalGetAdapter.cc.

References consumer_, cppFunctionSkipper::exception, HLT_25ns10e33_v2_cff::labels, edm::EDConsumerBase::labelsForToken(), edm::makeHandleExceptionFactory(), edm::ProductLabels::module, edm::ProductLabels::process, edm::PRODUCT_TYPE, edm::ProductLabels::productInstance, and edm::errors::ProductNotFound.

Referenced by getByToken_().

108  {
110  consumer_->labelsForToken(token,labels);
111  //no need to copy memory since the exception will no occur after the
112  // const char* have been deleted
113  return BasicHandle(makeHandleExceptionFactory([labels,kindOfType,productType]()->std::shared_ptr<cms::Exception> {
114  std::shared_ptr<cms::Exception> exception(std::make_shared<Exception>(errors::ProductNotFound));
115  if (kindOfType == PRODUCT_TYPE) {
116  *exception << "Principal::getByToken: Found zero products matching all criteria\nLooking for type: " << productType << "\n"
117  << "Looking for module label: " << labels.module << "\n" << "Looking for productInstanceName: " << labels.productInstance << "\n"
118  << (0==labels.process[0] ? "" : "Looking for process: ") << labels.process << "\n";
119  } else {
120  *exception << "Principal::getByToken: Found zero products matching all criteria\nLooking for a container with elements of type: " << productType << "\n"
121  << "Looking for module label: " << labels.module << "\n" << "Looking for productInstanceName: " << labels.productInstance << "\n"
122  << (0==labels.process[0] ? "" : "Looking for process: ") << labels.process << "\n";
123  }
124  return exception;
125  }));
126  }
EDConsumerBase const * consumer_
std::shared_ptr< HandleExceptionFactory > makeHandleExceptionFactory(T &&iFunctor)
ProductLabels Labels
void labelsForToken(EDGetToken iToken, Labels &oLabels) const
PrincipalGetAdapter& edm::PrincipalGetAdapter::operator= ( PrincipalGetAdapter const &  )
delete
Principal const& edm::PrincipalGetAdapter::principal ( ) const
inline
ProcessHistory const & PrincipalGetAdapter::processHistory ( ) const
EDProductGetter const * PrincipalGetAdapter::prodGetter ( ) const

Definition at line 255 of file PrincipalGetAdapter.cc.

References principal_, and edm::Principal::prodGetter().

Referenced by edm::Event::getRefBeforePut().

255  {
256  return principal_.prodGetter();
257  }
EDProductGetter const * prodGetter() const
Definition: Principal.h:88
void edm::PrincipalGetAdapter::setConsumer ( EDConsumerBase const *  iConsumer)
inline

Definition at line 139 of file PrincipalGetAdapter.h.

References consumer_.

Referenced by edm::Run::setConsumer(), edm::OccurrenceForOutput::setConsumer(), edm::LuminosityBlock::setConsumer(), and edm::Event::setConsumer().

139  {
140  consumer_ = iConsumer;
141  }
EDConsumerBase const * consumer_
void edm::PrincipalGetAdapter::setSharedResourcesAcquirer ( SharedResourcesAcquirer iSra)
inline
void PrincipalGetAdapter::throwAmbiguousException ( TypeID const &  productType,
EDGetToken  token 
) const
private

Definition at line 129 of file PrincipalGetAdapter.cc.

References consumer_, cppFunctionSkipper::exception, HLT_25ns10e33_v2_cff::labels, edm::EDConsumerBase::labelsForToken(), edm::ProductLabels::module, edm::ProductLabels::process, and edm::ProductLabels::productInstance.

Referenced by getByToken_().

130  {
132  consumer_->labelsForToken(token,labels);
133  cms::Exception exception("AmbiguousProduct");
134  exception << "Principal::getByToken: More than 1 product matches all criteria\nLooking for a container with elements of type: " << productType << "\n"
135  << "Looking for module label: " << labels.module << "\n" << "Looking for productInstanceName: " << labels.productInstance << "\n"
136  << (0==labels.process[0] ? "" : "Looking for process: ") << labels.process << "\n"
137  << "This can only occur with get function calls using a Handle<View> argument.\n"
138  << "Try a get not using a View or change the instance name of one of the products";
139  throw exception;
140  }
EDConsumerBase const * consumer_
ProductLabels Labels
void labelsForToken(EDGetToken iToken, Labels &oLabels) const

Member Data Documentation

EDConsumerBase const* edm::PrincipalGetAdapter::consumer_
private
ModuleDescription const& edm::PrincipalGetAdapter::md_
private

Definition at line 234 of file PrincipalGetAdapter.h.

Referenced by getBranchDescription().

Principal const& edm::PrincipalGetAdapter::principal_
private
SharedResourcesAcquirer* edm::PrincipalGetAdapter::resourcesAcquirer_
private