Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-01-31 02:19:09

0001 #ifndef DataFormats_Provenance_Provenance_h
0002 #define DataFormats_Provenance_Provenance_h
0003 
0004 /*----------------------------------------------------------------------
0005 
0006 Provenance: The full description of a product and how it came into
0007 existence.
0008 
0009 ----------------------------------------------------------------------*/
0010 
0011 #include "DataFormats/Provenance/interface/ParameterSetID.h"
0012 #include "DataFormats/Provenance/interface/Parentage.h"
0013 #include "DataFormats/Provenance/interface/StableProvenance.h"
0014 
0015 #include <memory>
0016 
0017 #include <iosfwd>
0018 /*
0019   Provenance
0020 
0021   definitions:
0022   Product: The EDProduct to which a provenance object is associated
0023 
0024   Creator: The EDProducer that made the product.
0025 
0026   Parents: The EDProducts used as input by the creator.
0027 */
0028 
0029 namespace edm {
0030   class MergeableRunProductMetadataBase;
0031   class ProductProvenance;
0032   class ProductProvenanceLookup;
0033 
0034   class Provenance {
0035   public:
0036     Provenance();
0037 
0038     Provenance(std::shared_ptr<ProductDescription const> const& p, ProductID const& pid);
0039 
0040     Provenance(StableProvenance const&);
0041 
0042     StableProvenance const& stable() const { return stableProvenance_; }
0043     StableProvenance& stable() { return stableProvenance_; }
0044 
0045     ProductDescription const& productDescription() const { return stable().productDescription(); }
0046     std::shared_ptr<ProductDescription const> const& constProductDescriptionPtr() const {
0047       return stable().constProductDescriptionPtr();
0048     }
0049 
0050     ProductProvenance const* productProvenance() const;
0051     bool knownImproperlyMerged() const;
0052     BranchID const& branchID() const { return stable().branchID(); }
0053     std::string const& branchName() const { return stable().branchName(); }
0054     std::string const& className() const { return stable().className(); }
0055     std::string const& moduleLabel() const { return stable().moduleLabel(); }
0056     std::string const& processName() const { return stable().processName(); }
0057     std::string const& productInstanceName() const { return stable().productInstanceName(); }
0058     std::string const& friendlyClassName() const { return stable().friendlyClassName(); }
0059     ProductProvenanceLookup const* store() const { return store_; }
0060     std::set<std::string> const& branchAliases() const { return stable().branchAliases(); }
0061 
0062     // Usually branchID() and originalBranchID() return exactly the same result.
0063     // The return values can differ only in cases where an EDAlias is involved.
0064     // For example, if you "get" a product and then get the Provenance object
0065     // available through the Handle, you will find that branchID() and originalBranchID()
0066     // will return different values if and only if an EDAlias was used to specify
0067     // the desired product and in a previous process the EDAlias was kept and
0068     // the original branch name was dropped. In that case, branchID() returns
0069     // the BranchID of the EDAlias and originalBranchID() returns the BranchID
0070     // of the branch name that was dropped. One reason the original BranchID can
0071     // be useful is that Parentage information is stored using the original BranchIDs.
0072     BranchID const& originalBranchID() const { return stable().originalBranchID(); }
0073 
0074     void write(std::ostream& os) const;
0075 
0076     void setStore(ProductProvenanceLookup const* store) { store_ = store; }
0077 
0078     ProductID const& productID() const { return stable().productID(); }
0079 
0080     void setProductID(ProductID const& pid) { stable().setProductID(pid); }
0081 
0082     void setMergeableRunProductMetadata(MergeableRunProductMetadataBase const* mrpm) {
0083       mergeableRunProductMetadata_ = mrpm;
0084     }
0085 
0086     void setProductDescription(std::shared_ptr<ProductDescription const> const& p) {
0087       stable().setProductDescription(p);
0088     }
0089 
0090     void swap(Provenance&);
0091 
0092   private:
0093     StableProvenance stableProvenance_;
0094     ProductProvenanceLookup const* store_;
0095     MergeableRunProductMetadataBase const* mergeableRunProductMetadata_;
0096   };
0097 
0098   inline std::ostream& operator<<(std::ostream& os, Provenance const& p) {
0099     p.write(os);
0100     return os;
0101   }
0102 
0103   bool operator==(Provenance const& a, Provenance const& b);
0104 
0105 }  // namespace edm
0106 #endif