CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_4/src/DataFormats/Provenance/interface/Provenance.h

Go to the documentation of this file.
00001 #ifndef DataFormats_Provenance_Provenance_h
00002 #define DataFormats_Provenance_Provenance_h
00003 
00004 /*----------------------------------------------------------------------
00005 
00006 Provenance: The full description of a product and how it came into
00007 existence.
00008 
00009 ----------------------------------------------------------------------*/
00010 
00011 #include "DataFormats/Provenance/interface/BranchDescription.h"
00012 #include "DataFormats/Provenance/interface/BranchMapper.h"
00013 #include "DataFormats/Provenance/interface/ParameterSetID.h"
00014 #include "DataFormats/Provenance/interface/ProcessConfigurationID.h"
00015 #include "DataFormats/Provenance/interface/ProcessHistoryID.h"
00016 #include "DataFormats/Provenance/interface/Parentage.h"
00017 #include "DataFormats/Provenance/interface/ConstBranchDescription.h"
00018 #include "DataFormats/Provenance/interface/ProductID.h"
00019 #include "DataFormats/Provenance/interface/ReleaseVersion.h"
00020 
00021 #include "boost/shared_ptr.hpp"
00022 
00023 #include <iosfwd>
00024 /*
00025   Provenance
00026 
00027   definitions:
00028   Product: The EDProduct to which a provenance object is associated
00029 
00030   Creator: The EDProducer that made the product.
00031 
00032   Parents: The EDProducts used as input by the creator.
00033 */
00034 
00035 namespace edm {
00036   class ProductProvenance;
00037   class Provenance {
00038   public:
00039     Provenance();
00040 
00041     Provenance(boost::shared_ptr<ConstBranchDescription> const& p, ProductID const& pid);
00042 
00043     Parentage const& event() const {return parentage();}
00044     BranchDescription const& product() const {return branchDescription_->me();}
00045 
00046     BranchDescription const& branchDescription() const {return branchDescription_->me();}
00047     ConstBranchDescription const& constBranchDescription() const {return *branchDescription_;}
00048     boost::shared_ptr<ConstBranchDescription> const& constBranchDescriptionPtr() const {return branchDescription_;}
00049 
00050     ProductProvenance* resolve() const;
00051     ProductProvenance* productProvenance() const {
00052       if (productProvenanceValid_) return productProvenancePtr_.get();
00053       return resolve();
00054     }
00055     bool productProvenanceValid() const {
00056       return productProvenanceValid_;
00057     }
00058     Parentage const& parentage() const {return productProvenance()->parentage();}
00059     BranchID const& branchID() const {return product().branchID();}
00060     std::string const& branchName() const {return product().branchName();}
00061     std::string const& className() const {return product().className();}
00062     std::string const& moduleLabel() const {return product().moduleLabel();}
00063     std::string const& processName() const {return product().processName();}
00064     std::string const& productInstanceName() const {return product().productInstanceName();}
00065     std::string const& friendlyClassName() const {return product().friendlyClassName();}
00066     boost::shared_ptr<BranchMapper> const& store() const {return store_;}
00067     ProcessHistoryID const& processHistoryID() const {return *processHistoryID_;}
00068     ProcessConfigurationID processConfigurationID() const;
00069     ParameterSetID psetID() const;
00070     std::string moduleName() const;
00071     ReleaseVersion const& releaseVersion() const;
00072     std::map<ProcessConfigurationID, ParameterSetID> const& parameterSetIDs() const {
00073       return product().parameterSetIDs();
00074     }
00075     std::map<ProcessConfigurationID, std::string> const& moduleNames() const {
00076       return product().moduleNames();
00077     }
00078     std::set<std::string> const& branchAliases() const {return product().branchAliases();}
00079 
00080     std::vector<BranchID> const& parents() const {return parentage().parents();}
00081 
00082     void write(std::ostream& os) const;
00083 
00084     void setStore(boost::shared_ptr<BranchMapper> store) const {store_ = store;}
00085 
00086     void setProcessHistoryID(ProcessHistoryID const& phid) {processHistoryID_ = &phid;}
00087 
00088     ProductID const& productID() const {return productID_;}
00089 
00090     void setProductProvenance(ProductProvenance const& prov) const;
00091 
00092     void setProductID(ProductID const& pid) {
00093       productID_ = pid;
00094     }
00095 
00096     void setBranchDescription(boost::shared_ptr<ConstBranchDescription> const& p) {
00097       branchDescription_ = p;
00098     }
00099 
00100     void resetProductProvenance() const;
00101 
00102     void swap(Provenance&);
00103 
00104   private:
00105     boost::shared_ptr<ConstBranchDescription> branchDescription_;
00106     ProductID productID_;
00107     ProcessHistoryID const* processHistoryID_; // Owned by Auxiliary
00108     mutable bool productProvenanceValid_;
00109     mutable boost::shared_ptr<ProductProvenance> productProvenancePtr_;
00110     mutable boost::shared_ptr<BranchMapper> store_;
00111   };
00112 
00113   inline
00114   std::ostream&
00115   operator<<(std::ostream& os, Provenance const& p) {
00116     p.write(os);
00117     return os;
00118   }
00119 
00120   bool operator==(Provenance const& a, Provenance const& b);
00121 
00122 }
00123 #endif