CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
edm::DataManagingProductResolver Class Referenceabstract

#include <ProductResolvers.h>

Inheritance diagram for edm::DataManagingProductResolver:
edm::DataManagingOrAliasProductResolver edm::ProductResolverBase edm::InputProductResolver edm::ProducedProductResolver edm::PuttableProductResolver edm::UnscheduledProductResolver

Public Types

enum  ProductStatus {
  ProductStatus::ProductSet, ProductStatus::NotPut, ProductStatus::ResolveFailed, ProductStatus::ResolveNotRun,
  ProductStatus::ProductDeleted
}
 

Public Member Functions

void connectTo (ProductResolverBase const &, Principal const *) final
 
 DataManagingProductResolver (std::shared_ptr< BranchDescription const > bd, ProductStatus iDefaultStatus)
 
void resetProductData_ (bool deleteEarly) override
 
void resetStatus ()
 
template<bool callResolver, typename FUNC >
ProductResolverBase::Resolution resolveProductImpl (FUNC resolver) const
 
- Public Member Functions inherited from edm::DataManagingOrAliasProductResolver
 DataManagingOrAliasProductResolver ()
 
- Public Member Functions inherited from edm::ProductResolverBase
BranchDescription const & branchDescription () const
 
std::string const & moduleLabel () const
 
ProductResolverBaseoperator= (ProductResolverBase const &)=delete
 
void prefetchAsync (WaitingTask *waitTask, Principal const &principal, bool skipCurrentProcess, ServiceToken const &token, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
 
std::string const & processName () const
 
ProductID const & productID () const
 
std::string const & productInstanceName () const
 
ProductProvenance const * productProvenancePtr () const
 
bool productResolved () const
 
 ProductResolverBase ()
 
 ProductResolverBase (ProductResolverBase const &)=delete
 
TypeID productType () const
 
bool productUnavailable () const
 
bool productWasDeleted () const
 
bool productWasFetchedAndIsValid (bool iSkipCurrentProcess) const
 
Provenance const * provenance () const
 
bool provenanceAvailable () const
 
void putOrMergeProduct (std::unique_ptr< WrapperBase > edp, MergeableRunProductMetadata const *mergeableRunProductMetadata=nullptr) const
 
void putProduct (std::unique_ptr< WrapperBase > edp) const
 
void resetBranchDescription (std::shared_ptr< BranchDescription const > bd)
 
void resetProductData ()
 
std::string const & resolvedModuleLabel () const
 
Resolution resolveProduct (Principal const &principal, bool skipCurrentProcess, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
 
void retrieveAndMerge (Principal const &principal, MergeableRunProductMetadata const *mergeableRunProductMetadata) const
 
void setMergeableRunProductMetadata (MergeableRunProductMetadata const *mrpm)
 
void setProcessHistory (ProcessHistory const &ph)
 
void setProvenance (ProductProvenanceRetriever const *provRetriever, ProcessHistory const &ph, ProductID const &pid)
 
virtual void setupUnscheduled (UnscheduledConfigurator const &)
 
bool singleProduct () const
 
StableProvenance const * stableProvenance () const
 
void unsafe_deleteProduct () const
 
bool unscheduledWasNotRun () const
 
void write (std::ostream &os) const
 
virtual ~ProductResolverBase ()
 

Protected Member Functions

ProductStatus defaultStatus () const
 
template<bool callResolver, typename FUNC >
Resolution resolveProductImpl (FUNC resolver) const
 
void setFailedStatus () const
 
void setMergeableRunProductMetadataInProductData (MergeableRunProductMetadata const *)
 
void setProduct (std::unique_ptr< WrapperBase > edp) const
 
ProductStatus status () const
 

Private Member Functions

BranchDescription const & branchDescription_ () const final
 
void checkType (WrapperBase const &prod) const
 
ProductData const & getProductData () const
 
virtual bool isFromCurrentProcess () const =0
 
void mergeProduct (std::unique_ptr< WrapperBase > edp, MergeableRunProductMetadata const *) const
 
ProductProvenance const * productProvenancePtr_ () const final
 
bool productResolved_ () const final
 
bool productUnavailable_ () const final
 
bool productWasDeleted_ () const final
 
bool productWasFetchedAndIsValid_ (bool iSkipCurrentProcess) const final
 
Provenance const * provenance_ () const final
 
void putOrMergeProduct_ (std::unique_ptr< WrapperBase > prod, MergeableRunProductMetadata const *mergeableRunProductMetadata) const final
 
void resetBranchDescription_ (std::shared_ptr< BranchDescription const > bd) final
 
std::string const & resolvedModuleLabel_ () const final
 
void setProcessHistory_ (ProcessHistory const &ph) final
 
void setProvenance_ (ProductProvenanceRetriever const *provRetriever, ProcessHistory const &ph, ProductID const &pid) final
 
bool singleProduct_ () const final
 
void throwProductDeletedException () const
 

Private Attributes

ProductStatus const defaultStatus_
 
ProductData productData_
 
std::atomic< ProductStatustheStatus_
 

Detailed Description

Definition at line 44 of file ProductResolvers.h.

Member Enumeration Documentation

Enumerator
ProductSet 
NotPut 
ResolveFailed 
ResolveNotRun 
ProductDeleted 

Definition at line 46 of file ProductResolvers.h.

46 { ProductSet, NotPut, ResolveFailed, ResolveNotRun, ProductDeleted };

Constructor & Destructor Documentation

edm::DataManagingProductResolver::DataManagingProductResolver ( std::shared_ptr< BranchDescription const >  bd,
ProductStatus  iDefaultStatus 
)
inline

Definition at line 48 of file ProductResolvers.h.

References edm::ProductResolverBase::connectTo().

50  productData_(bd),
51  theStatus_(iDefaultStatus),
52  defaultStatus_(iDefaultStatus) {}
std::atomic< ProductStatus > theStatus_

Member Function Documentation

BranchDescription const& edm::DataManagingProductResolver::branchDescription_ ( ) const
inlinefinalprivatevirtual

Implements edm::ProductResolverBase.

Definition at line 85 of file ProductResolvers.h.

Referenced by mergeProduct().

85 { return *getProductData().branchDescription(); }
std::shared_ptr< BranchDescription const > const & branchDescription() const
Definition: ProductData.h:28
ProductData const & getProductData() const
void edm::DataManagingProductResolver::checkType ( WrapperBase const &  prod) const
private

Definition at line 489 of file ProductResolvers.cc.

References edm::ProductResolverBase::branchDescription(), edm::BranchDescription::branchName(), edm::BranchDescription::className(), edm::WrapperBase::dynamicTypeInfo(), edm::errors::EventCorruption, Exception, edm::TypeWithDict::unvalidatedTypeInfo(), and edm::BranchDescription::unwrappedType().

Referenced by mergeProduct(), and setProduct().

489  {
490  // Check if the types match.
491  TypeID typeID(prod.dynamicTypeInfo());
492  if (typeID != TypeID{branchDescription().unwrappedType().unvalidatedTypeInfo()}) {
493  // Types do not match.
495  << "Product on branch " << branchDescription().branchName() << " is of wrong type.\n"
496  << "It is supposed to be of type " << branchDescription().className() << ".\n"
497  << "It is actually of type " << typeID.className() << ".\n";
498  }
499  }
std::string const & branchName() const
std::string const & className() const
TypeWithDict const & unwrappedType() const
std::type_info const & unvalidatedTypeInfo() const
Definition: TypeWithDict.h:81
BranchDescription const & branchDescription() const
void edm::DataManagingProductResolver::connectTo ( ProductResolverBase const &  iOther,
Principal const *   
)
finalvirtual

Implements edm::ProductResolverBase.

Definition at line 474 of file ProductResolvers.cc.

474 { assert(false); }
ProductStatus edm::DataManagingProductResolver::defaultStatus ( ) const
inlineprotected
ProductData const& edm::DataManagingProductResolver::getProductData ( ) const
inlineprivate
virtual bool edm::DataManagingProductResolver::isFromCurrentProcess ( ) const
privatepure virtual
void edm::DataManagingProductResolver::mergeProduct ( std::unique_ptr< WrapperBase edp,
MergeableRunProductMetadata const *  mergeableRunProductMetadata 
) const
private

Definition at line 77 of file ProductResolvers.cc.

References edm::ProductResolverBase::branchDescription(), branchDescription_(), edm::BranchDescription::branchName(), edm::BranchDescription::branchType(), checkType(), Exception, edm::MergeableRunProductMetadata::getMergeDecision(), getProductData(), edm::InRun, edm::MergeableRunProductMetadata::MERGE, edm::errors::MismatchedInputFiles, eostools::move(), definitions::original, edm::BranchDescription::processName(), ProductSet, edm::MergeableRunProductMetadata::REPLACE, ResolveFailed, setProduct(), status(), and edm::ProductData::unsafe_wrapper().

Referenced by putOrMergeProduct_().

78  {
79  // if its not mergeable and the previous read failed, go ahead and use this one
81  setProduct(std::move(iFrom));
82  return;
83  }
84 
85  assert(status() == ProductStatus::ProductSet);
86  if (not iFrom) {
87  return;
88  }
89 
90  checkType(*iFrom);
91 
93  if (original->isMergeable()) {
94  if (original->isPresent() != iFrom->isPresent()) {
96  << "Merge of Run or Lumi product failed for branch " << branchDescription().branchName() << "\n"
97  << "Was trying to merge objects where one product had been put in the input file and the other had not "
98  "been."
99  << "\n"
100  << "The solution is to drop the branch on input. Or better do not create inconsistent files\n"
101  << "that need to be merged in the first place.\n";
102  }
103  if (original->isPresent()) {
104  BranchDescription const& desc = branchDescription_();
105  if (mergeableRunProductMetadata == nullptr || desc.branchType() != InRun) {
106  original->mergeProduct(iFrom.get());
107  } else {
109  mergeableRunProductMetadata->getMergeDecision(desc.processName());
110  if (decision == MergeableRunProductMetadata::MERGE) {
111  original->mergeProduct(iFrom.get());
112  } else if (decision == MergeableRunProductMetadata::REPLACE) {
113  // Note this swaps the content of the product where the
114  // both products branches are present and the product is
115  // also present (was put) in the branch. A module might
116  // have already gotten a pointer to the product so we
117  // keep those pointers valid. This does not call swap
118  // on the Wrapper.
119  original->swapProduct(iFrom.get());
120  }
121  // If the decision is IGNORE, do nothing
122  }
123  }
124  // If both have isPresent false, do nothing
125 
126  } else if (original->hasIsProductEqual()) {
127  if (original->isPresent() && iFrom->isPresent()) {
128  if (!original->isProductEqual(iFrom.get())) {
129  auto const& bd = branchDescription();
130  edm::LogError("RunLumiMerging")
131  << "ProductResolver::mergeTheProduct\n"
132  << "Two run/lumi products for the same run/lumi which should be equal are not\n"
133  << "Using the first, ignoring the second\n"
134  << "className = " << bd.className() << "\n"
135  << "moduleLabel = " << bd.moduleLabel() << "\n"
136  << "instance = " << bd.productInstanceName() << "\n"
137  << "process = " << bd.processName() << "\n";
138  }
139  } else if (!original->isPresent() && iFrom->isPresent()) {
140  setProduct(std::move(iFrom));
141  }
142  // if not iFrom->isPresent(), do nothing
143  } else {
144  auto const& bd = branchDescription();
145  edm::LogWarning("RunLumiMerging") << "ProductResolver::mergeTheProduct\n"
146  << "Run/lumi product has neither a mergeProduct nor isProductEqual function\n"
147  << "Using the first, ignoring the second in merge\n"
148  << "className = " << bd.className() << "\n"
149  << "moduleLabel = " << bd.moduleLabel() << "\n"
150  << "instance = " << bd.productInstanceName() << "\n"
151  << "process = " << bd.processName() << "\n";
152  if (!original->isPresent() && iFrom->isPresent()) {
153  setProduct(std::move(iFrom));
154  }
155  // In other cases, do nothing
156  }
157  }
std::string const & branchName() const
void checkType(WrapperBase const &prod) const
ProductStatus status() const
BranchDescription const & branchDescription_() const final
void setProduct(std::unique_ptr< WrapperBase > edp) const
BranchDescription const & branchDescription() const
ProductData const & getProductData() const
def move(src, dest)
Definition: eostools.py:511
WrapperBase * unsafe_wrapper() const
Definition: ProductData.h:35
ProductProvenance const * edm::DataManagingProductResolver::productProvenancePtr_ ( ) const
finalprivatevirtual

Implements edm::ProductResolverBase.

Definition at line 554 of file ProductResolvers.cc.

References edm::Provenance::productProvenance(), and edm::ProductResolverBase::provenance().

554  {
555  return provenance()->productProvenance();
556  }
Provenance const * provenance() const
ProductProvenance const * productProvenance() const
Definition: Provenance.cc:35
bool edm::DataManagingProductResolver::productResolved_ ( ) const
finalprivatevirtual

Implements edm::ProductResolverBase.

Definition at line 521 of file ProductResolvers.cc.

References defaultStatus(), or, ProductDeleted, alignCSCRings::s, and status().

521  {
522  auto s = status();
523  return (s != defaultStatus()) or (s == ProductStatus::ProductDeleted);
524  }
ProductStatus status() const
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
ProductStatus defaultStatus() const
bool edm::DataManagingProductResolver::productUnavailable_ ( ) const
finalprivatevirtual

Implements edm::ProductResolverBase.

Definition at line 513 of file ProductResolvers.cc.

References getProductData(), edm::WrapperBase::isPresent(), ProductSet, ResolveNotRun, status(), and edm::ProductData::wrapper().

513  {
514  auto presentStatus = status();
515  if (presentStatus == ProductStatus::ProductSet) {
516  return !(getProductData().wrapper()->isPresent());
517  }
518  return presentStatus != ProductStatus::ResolveNotRun;
519  }
ProductStatus status() const
WrapperBase const * wrapper() const
Definition: ProductData.h:34
bool isPresent() const
Definition: WrapperBase.h:30
ProductData const & getProductData() const
bool edm::DataManagingProductResolver::productWasDeleted_ ( ) const
finalprivatevirtual
bool edm::DataManagingProductResolver::productWasFetchedAndIsValid_ ( bool  iSkipCurrentProcess) const
finalprivatevirtual

Implements edm::ProductResolverBase.

Definition at line 529 of file ProductResolvers.cc.

References getProductData(), isFromCurrentProcess(), ProductSet, status(), and wrapper.

529  {
530  if (iSkipCurrentProcess and isFromCurrentProcess()) {
531  return false;
532  }
534  if (getProductData().wrapper()->isPresent()) {
535  return true;
536  }
537  }
538  return false;
539  }
ProductStatus status() const
virtual bool isFromCurrentProcess() const =0
ProductData const & getProductData() const
static HepMC::HEPEVT_Wrapper wrapper
Provenance const* edm::DataManagingProductResolver::provenance_ ( ) const
inlinefinalprivatevirtual

Implements edm::ProductResolverBase.

Definition at line 89 of file ProductResolvers.h.

89 { return &productData_.provenance(); }
Provenance const & provenance() const
Definition: ProductData.h:32
void edm::DataManagingProductResolver::putOrMergeProduct_ ( std::unique_ptr< WrapperBase prod,
MergeableRunProductMetadata const *  mergeableRunProductMetadata 
) const
finalprivatevirtual

Implements edm::ProductResolverBase.

Definition at line 476 of file ProductResolvers.cc.

References defaultStatus(), mergeProduct(), eostools::move(), edm::ProductResolverBase::putProduct(), and status().

477  {
478  if (not prod) {
479  return;
480  }
481  if (status() == defaultStatus()) {
482  //resolveProduct has not been called or it failed
483  putProduct(std::move(prod));
484  } else {
485  mergeProduct(std::move(prod), mergeableRunProductMetadata);
486  }
487  }
ProductStatus status() const
void putProduct(std::unique_ptr< WrapperBase > edp) const
void mergeProduct(std::unique_ptr< WrapperBase > edp, MergeableRunProductMetadata const *) const
ProductStatus defaultStatus() const
def move(src, dest)
Definition: eostools.py:511
void edm::DataManagingProductResolver::resetBranchDescription_ ( std::shared_ptr< BranchDescription const >  bd)
inlinefinalprivatevirtual

Implements edm::ProductResolverBase.

Definition at line 86 of file ProductResolvers.h.

86  {
88  }
void resetBranchDescription(std::shared_ptr< BranchDescription const > bd)
Definition: ProductData.cc:29
void edm::DataManagingProductResolver::resetProductData_ ( bool  deleteEarly)
overridevirtual
void edm::DataManagingProductResolver::resetStatus ( )
inline
std::string const& edm::DataManagingProductResolver::resolvedModuleLabel_ ( ) const
inlinefinalprivatevirtual
template<bool callResolver, typename FUNC >
ProductResolverBase::Resolution edm::DataManagingProductResolver::resolveProductImpl ( FUNC  resolver) const

Definition at line 45 of file ProductResolvers.cc.

References getProductData(), ProductSet, edm::ProductResolverBase::productWasDeleted(), Resolution, ResolveNotRun, setFailedStatus(), status(), and throwProductDeletedException().

45  {
46  if (productWasDeleted()) {
48  }
49  auto presentStatus = status();
50 
51  if (callResolver && presentStatus == ProductStatus::ResolveNotRun) {
52  //if resolver fails because of exception or not setting product
53  // make sure the status goes to failed
54  auto failedStatusSetter = [this](ProductStatus* presentStatus) {
55  if (this->status() == ProductStatus::ResolveNotRun) {
56  this->setFailedStatus();
57  }
58  *presentStatus = this->status();
59  };
60  std::unique_ptr<ProductStatus, decltype(failedStatusSetter)> failedStatusGuard(&presentStatus,
61  failedStatusSetter);
62 
63  //If successful, this will call setProduct
64  resolver();
65  }
66 
67  if (presentStatus == ProductStatus::ProductSet) {
68  auto pd = &getProductData();
69  if (pd->wrapper()->isPresent()) {
70  return Resolution(pd);
71  }
72  }
73 
74  return Resolution(nullptr);
75  }
ProductStatus status() const
ProductData const & getProductData() const
template<bool callResolver, typename FUNC >
Resolution edm::DataManagingProductResolver::resolveProductImpl ( FUNC  resolver) const
protected
void edm::DataManagingProductResolver::setFailedStatus ( ) const
inlineprotected
void edm::DataManagingProductResolver::setMergeableRunProductMetadataInProductData ( MergeableRunProductMetadata const *  mrpm)
protected

Definition at line 547 of file ProductResolvers.cc.

References productData_, and edm::ProductData::setMergeableRunProductMetadata().

Referenced by edm::InputProductResolver::setMergeableRunProductMetadata_().

548  {
550  }
void setMergeableRunProductMetadata(MergeableRunProductMetadataBase const *mrpm)
Definition: ProductData.h:71
void edm::DataManagingProductResolver::setProcessHistory_ ( ProcessHistory const &  ph)
finalprivatevirtual

Implements edm::ProductResolverBase.

Definition at line 552 of file ProductResolvers.cc.

References productData_, and edm::ProductData::setProcessHistory().

void setProcessHistory(ProcessHistory const &ph)
Definition: ProductData.h:61
void edm::DataManagingProductResolver::setProduct ( std::unique_ptr< WrapperBase edp) const
protected

Definition at line 501 of file ProductResolvers.cc.

References checkType(), eostools::move(), productData_, ProductSet, setFailedStatus(), theStatus_, and edm::ProductData::unsafe_setWrapper().

Referenced by mergeProduct(), edm::InputProductResolver::putProduct_(), and edm::ProducedProductResolver::putProduct_().

501  {
502  if (edp) {
503  checkType(*edp);
506  } else {
507  setFailedStatus();
508  }
509  }
void checkType(WrapperBase const &prod) const
void unsafe_setWrapper(std::unique_ptr< WrapperBase > iValue) const
Definition: ProductData.cc:38
std::atomic< ProductStatus > theStatus_
def move(src, dest)
Definition: eostools.py:511
void edm::DataManagingProductResolver::setProvenance_ ( ProductProvenanceRetriever const *  provRetriever,
ProcessHistory const &  ph,
ProductID const &  pid 
)
finalprivatevirtual

Implements edm::ProductResolverBase.

Definition at line 541 of file ProductResolvers.cc.

References productData_, and edm::ProductData::setProvenance().

543  {
544  productData_.setProvenance(provRetriever, ph, pid);
545  }
void setProvenance(ProductProvenanceRetriever const *provRetriever, ProcessHistory const &ph, ProductID const &pid)
Definition: ProductData.h:65
bool edm::DataManagingProductResolver::singleProduct_ ( ) const
finalprivatevirtual

Implements edm::ProductResolverBase.

Definition at line 569 of file ProductResolvers.cc.

569 { return true; }
ProductStatus edm::DataManagingProductResolver::status ( void  ) const
inlineprotected
void edm::DataManagingProductResolver::throwProductDeletedException ( ) const
private

Definition at line 31 of file ProductResolvers.cc.

References edm::ProductResolverBase::branchDescription(), cppFunctionSkipper::exception, edm::ProductResolverBase::moduleLabel(), edm::ProductResolverBase::processName(), edm::ProductResolverBase::productInstanceName(), and edm::BranchDescription::unwrappedTypeID().

Referenced by resolveProductImpl().

31  {
33  exception << "ProductResolverBase::resolveProduct_: The product matching all criteria was already deleted\n"
34  << "Looking for type: " << branchDescription().unwrappedTypeID() << "\n"
35  << "Looking for module label: " << moduleLabel() << "\n"
36  << "Looking for productInstanceName: " << productInstanceName() << "\n"
37  << (processName().empty() ? "" : "Looking for process: ") << processName() << "\n"
38  << "This means there is a configuration error.\n"
39  << "The module which is asking for this data must be configured to state that it will read this data.";
40  throw exception;
41  }
std::string const & productInstanceName() const
std::string const & processName() const
TypeID unwrappedTypeID() const
BranchDescription const & branchDescription() const
std::string const & moduleLabel() const

Member Data Documentation

ProductStatus const edm::DataManagingProductResolver::defaultStatus_
private

Definition at line 101 of file ProductResolvers.h.

ProductData edm::DataManagingProductResolver::productData_
private
std::atomic<ProductStatus> edm::DataManagingProductResolver::theStatus_
mutableprivate

Definition at line 100 of file ProductResolvers.h.

Referenced by resetProductData_(), and setProduct().