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::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::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 36 of file ProductResolvers.h.

Member Enumeration Documentation

Enumerator
ProductSet 
NotPut 
ResolveFailed 
ResolveNotRun 
ProductDeleted 

Definition at line 38 of file ProductResolvers.h.

38  {
39  ProductSet,
40  NotPut,
41  ResolveFailed,
42  ResolveNotRun,
43  ProductDeleted
44  };

Constructor & Destructor Documentation

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

Definition at line 46 of file ProductResolvers.h.

References connectTo().

47  productData_(bd),
48  theStatus_(iDefaultStatus),
49  defaultStatus_(iDefaultStatus){}
ProductStatus const defaultStatus_
std::atomic< ProductStatus > theStatus_

Member Function Documentation

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

Implements edm::ProductResolverBase.

Definition at line 83 of file ProductResolvers.h.

References edm::ProductData::branchDescription(), and getProductData().

Referenced by mergeProduct(), and edm::SingleChoiceNoProcessProductResolver::SingleChoiceNoProcessProductResolver().

83 {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 532 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(), setFailedStatus(), and setProduct().

532  {
533  // Check if the types match.
534  TypeID typeID(prod.dynamicTypeInfo());
535  if(typeID !=TypeID{branchDescription().unwrappedType().unvalidatedTypeInfo()}) {
536  // Types do not match.
538  << "Product on branch " << branchDescription().branchName() << " is of wrong type.\n"
539  << "It is supposed to be of type " << branchDescription().className() << ".\n"
540  << "It is actually of type " << typeID.className() << ".\n";
541  }
542  }
std::string const & branchName() const
std::string const & className() const
TypeWithDict const & unwrappedType() const
std::type_info const & unvalidatedTypeInfo() const
Definition: TypeWithDict.h:76
BranchDescription const & branchDescription() const
void edm::DataManagingProductResolver::connectTo ( ProductResolverBase const &  iOther,
Principal const *   
)
finalvirtual
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 80 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 getProductData(), and putOrMergeProduct_().

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

Implements edm::ProductResolverBase.

Definition at line 568 of file ProductResolvers.cc.

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

Referenced by getProductData(), and edm::SingleChoiceNoProcessProductResolver::SingleChoiceNoProcessProductResolver().

568  {
569  auto s = status();
570  return (s != defaultStatus() ) or (s == ProductStatus::ProductDeleted);
571  }
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
bool edm::DataManagingProductResolver::productWasDeleted_ ( ) const
finalprivatevirtual
bool edm::DataManagingProductResolver::productWasFetchedAndIsValid_ ( bool  iSkipCurrentProcess) const
finalprivatevirtual

Implements edm::ProductResolverBase.

Definition at line 581 of file ProductResolvers.cc.

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

Referenced by getProductData(), and edm::SingleChoiceNoProcessProductResolver::SingleChoiceNoProcessProductResolver().

581  {
582  if (iSkipCurrentProcess and isFromCurrentProcess() ) {
583  return false;
584  }
586  if(getProductData().wrapper()->isPresent()) {
587  return true;
588  }
589  }
590  return false;
591  }
ProductStatus status() const
virtual bool isFromCurrentProcess() const =0
ProductData const & getProductData() const
static HepMC::HEPEVT_Wrapper wrapper
Provenance const* edm::DataManagingProductResolver::provenance_ ( ) const
inlinefinalprivatevirtual
void edm::DataManagingProductResolver::putOrMergeProduct_ ( std::unique_ptr< WrapperBase prod,
MergeableRunProductMetadata const *  mergeableRunProductMetadata 
) const
finalprivatevirtual

Implements edm::ProductResolverBase.

Definition at line 519 of file ProductResolvers.cc.

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

Referenced by getProductData(), edm::AliasProductResolver::productWasFetchedAndIsValid_(), edm::ParentProcessProductResolver::productWasFetchedAndIsValid_(), and edm::SingleChoiceNoProcessProductResolver::SingleChoiceNoProcessProductResolver().

519  {
520  if(not prod) {return;}
521  if(status() == defaultStatus()) {
522  //resolveProduct has not been called or it failed
523  putProduct(std::move(prod));
524  } else {
525  mergeProduct(std::move(prod), mergeableRunProductMetadata);
526  }
527  }
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
void edm::DataManagingProductResolver::resetProductData_ ( bool  deleteEarly)
overridevirtual

Implements edm::ProductResolverBase.

Reimplemented in edm::UnscheduledProductResolver, edm::PuttableProductResolver, and edm::InputProductResolver.

Definition at line 610 of file ProductResolvers.cc.

References productData_, ProductDeleted, ProductSet, edm::ProductData::resetProductData(), resetStatus(), and theStatus_.

Referenced by edm::InputProductResolver::resetProductData_(), edm::PuttableProductResolver::resetProductData_(), edm::UnscheduledProductResolver::resetProductData_(), resetStatus(), edm::AliasProductResolver::resolvedModuleLabel_(), edm::ParentProcessProductResolver::resolvedModuleLabel_(), edm::NoProcessProductResolver::resolvedModuleLabel_(), edm::SingleChoiceNoProcessProductResolver::resolvedModuleLabel_(), edm::InputProductResolver::unscheduledWasNotRun_(), edm::PuttableProductResolver::unscheduledWasNotRun_(), and edm::UnscheduledProductResolver::unscheduledWasNotRun_().

void edm::DataManagingProductResolver::resetStatus ( )
inline

Definition at line 53 of file ProductResolvers.h.

References defaultStatus_, resetProductData_(), setProduct(), and theStatus_.

Referenced by resetProductData_().

ProductStatus const defaultStatus_
std::atomic< ProductStatus > theStatus_
std::string const& edm::DataManagingProductResolver::resolvedModuleLabel_ ( ) const
inlinefinalprivatevirtual
template<bool callResolver, typename FUNC >
ProductResolverBase::Resolution edm::DataManagingProductResolver::resolveProductImpl ( FUNC  resolver) const

Definition at line 46 of file ProductResolvers.cc.

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

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

Referenced by setFailedStatus().

void edm::DataManagingProductResolver::setFailedStatus ( ) const
inlineprotected
void edm::DataManagingProductResolver::setMergeableRunProductMetadataInProductData ( MergeableRunProductMetadata const *  mrpm)
protected

Definition at line 598 of file ProductResolvers.cc.

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

Referenced by setFailedStatus(), and edm::InputProductResolver::setMergeableRunProductMetadata_().

598  {
600  }
void setMergeableRunProductMetadata(MergeableRunProductMetadataBase const *mrpm)
Definition: ProductData.h:71
void edm::DataManagingProductResolver::setProcessHistory_ ( ProcessHistory const &  ph)
finalprivatevirtual
void edm::DataManagingProductResolver::setProduct ( std::unique_ptr< WrapperBase edp) const
protected
void edm::DataManagingProductResolver::setProvenance_ ( ProductProvenanceRetriever const *  provRetriever,
ProcessHistory const &  ph,
ProductID const &  pid 
)
finalprivatevirtual
bool edm::DataManagingProductResolver::singleProduct_ ( ) const
finalprivatevirtual
ProductStatus edm::DataManagingProductResolver::status ( void  ) const
inlineprotected
void edm::DataManagingProductResolver::throwProductDeletedException ( ) const
private

Definition at line 30 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(), and setFailedStatus().

30  {
32  exception << "ProductResolverBase::resolveProduct_: The product matching all criteria was already deleted\n"
33  << "Looking for type: " << branchDescription().unwrappedTypeID() << "\n"
34  << "Looking for module label: " << moduleLabel() << "\n"
35  << "Looking for productInstanceName: " << productInstanceName() << "\n"
36  << (processName().empty() ? "" : "Looking for process: ") << processName() << "\n"
37  << "This means there is a configuration error.\n"
38  << "The module which is asking for this data must be configured to state that it will read this data.";
39  throw exception;
40 
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 95 of file ProductResolvers.h.

Referenced by defaultStatus(), and resetStatus().

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