CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/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     ProcessHistoryID processHistoryID() const {return store_->processHistoryID();}
00067     ProcessConfigurationID processConfigurationID() const;
00068     ParameterSetID psetID() const;
00069     std::string moduleName() const;
00070     ReleaseVersion const& releaseVersion() const;
00071     std::map<ProcessConfigurationID, ParameterSetID> const& parameterSetIDs() const {
00072       return product().parameterSetIDs();
00073     }
00074     std::map<ProcessConfigurationID, std::string> const& moduleNames() const {
00075       return product().moduleNames();
00076     }
00077     std::set<std::string> const& branchAliases() const {return product().branchAliases();}
00078 
00079     std::vector<BranchID> const& parents() const {return parentage().parents();}
00080 
00081     void write(std::ostream& os) const;
00082 
00083     void setStore(boost::shared_ptr<BranchMapper> store) const {store_ = store;}
00084 
00085     ProductID const& productID() const {return productID_;}
00086 
00087     void setProductProvenance(ProductProvenance const& prov) const;
00088 
00089     void setProductID(ProductID const& pid) {
00090       productID_ = pid;
00091     }
00092 
00093     void setBranchDescription(boost::shared_ptr<ConstBranchDescription> const& p) {
00094       branchDescription_ = p;
00095     }
00096 
00097     void resetProductProvenance() const;
00098 
00099     void swap(Provenance&);
00100 
00101   private:
00102     boost::shared_ptr<ConstBranchDescription> branchDescription_;
00103     ProductID productID_;
00104     mutable bool productProvenanceValid_;
00105     mutable boost::shared_ptr<ProductProvenance> productProvenancePtr_;
00106     mutable boost::shared_ptr<BranchMapper> store_;
00107   };
00108 
00109   inline
00110   std::ostream&
00111   operator<<(std::ostream& os, Provenance const& p) {
00112     p.write(os);
00113     return os;
00114   }
00115 
00116   bool operator==(Provenance const& a, Provenance const& b);
00117 
00118 }
00119 #endif