Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:02

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<BranchDescription 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     BranchDescription const& branchDescription() const { return stable().branchDescription(); }
0046     std::shared_ptr<BranchDescription const> const& constBranchDescriptionPtr() const {
0047       return stable().constBranchDescriptionPtr();
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& moduleName() const { return stable().moduleName(); }
0057     std::string const& processName() const { return stable().processName(); }
0058     std::string const& productInstanceName() const { return stable().productInstanceName(); }
0059     std::string const& friendlyClassName() const { return stable().friendlyClassName(); }
0060     ProductProvenanceLookup const* store() const { return store_; }
0061     std::set<std::string> const& branchAliases() const { return stable().branchAliases(); }
0062 
0063     // Usually branchID() and originalBranchID() return exactly the same result.
0064     // The return values can differ only in cases where an EDAlias is involved.
0065     // For example, if you "get" a product and then get the Provenance object
0066     // available through the Handle, you will find that branchID() and originalBranchID()
0067     // will return different values if and only if an EDAlias was used to specify
0068     // the desired product and in a previous process the EDAlias was kept and
0069     // the original branch name was dropped. In that case, branchID() returns
0070     // the BranchID of the EDAlias and originalBranchID() returns the BranchID
0071     // of the branch name that was dropped. One reason the original BranchID can
0072     // be useful is that Parentage information is stored using the original BranchIDs.
0073     BranchID const& originalBranchID() const { return stable().originalBranchID(); }
0074 
0075     void write(std::ostream& os) const;
0076 
0077     void setStore(ProductProvenanceLookup const* store) { store_ = store; }
0078 
0079     ProductID const& productID() const { return stable().productID(); }
0080 
0081     void setProductID(ProductID const& pid) { stable().setProductID(pid); }
0082 
0083     void setMergeableRunProductMetadata(MergeableRunProductMetadataBase const* mrpm) {
0084       mergeableRunProductMetadata_ = mrpm;
0085     }
0086 
0087     void setBranchDescription(std::shared_ptr<BranchDescription const> const& p) { stable().setBranchDescription(p); }
0088 
0089     void swap(Provenance&);
0090 
0091   private:
0092     StableProvenance stableProvenance_;
0093     ProductProvenanceLookup const* store_;
0094     MergeableRunProductMetadataBase const* mergeableRunProductMetadata_;
0095   };
0096 
0097   inline std::ostream& operator<<(std::ostream& os, Provenance const& p) {
0098     p.write(os);
0099     return os;
0100   }
0101 
0102   bool operator==(Provenance const& a, Provenance const& b);
0103 
0104 }  // namespace edm
0105 #endif