CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/DataFormats/Provenance/interface/BranchDescription.h

Go to the documentation of this file.
00001 #ifndef DataFormats_Provenance_BranchDescription_h
00002 #define DataFormats_Provenance_BranchDescription_h
00003 
00004 /*----------------------------------------------------------------------
00005 
00006 BranchDescription: The full description of a Branch.
00007 This description also applies to every product instance on the branch.
00008 
00009 ----------------------------------------------------------------------*/
00010 #include <iosfwd>
00011 #include <string>
00012 #include <map>
00013 #include <set>
00014 
00015 #include "DataFormats/Provenance/interface/ProvenanceFwd.h"
00016 #include "DataFormats/Provenance/interface/BranchType.h"
00017 #include "DataFormats/Provenance/interface/BranchID.h"
00018 #include "DataFormats/Provenance/interface/ProductID.h"
00019 #include "DataFormats/Provenance/interface/ParameterSetID.h"
00020 #include "DataFormats/Provenance/interface/ProcessConfigurationID.h"
00021 #include "DataFormats/Provenance/interface/Transient.h"
00022 #include "FWCore/Utilities/interface/TypeID.h"
00023 
00024 #include "Reflex/Type.h"
00025 /*
00026   BranchDescription
00027 
00028   definitions:
00029   The event-independent description of an EDProduct.
00030 
00031 */
00032 
00033 namespace edm {
00034   class WrapperInterfaceBase;
00035   class BranchDescription {
00036   public:
00037     static int const invalidSplitLevel = -1;
00038     static int const invalidBasketSize = 0;
00039     enum MatchMode { Strict = 0,
00040                      Permissive };
00041 
00042     BranchDescription();
00043 
00044     BranchDescription(BranchType const& branchType,
00045                       std::string const& mdLabel,
00046                       std::string const& procName,
00047                       std::string const& name,
00048                       std::string const& fName,
00049                       std::string const& pin,
00050                       ModuleDescription const& modDesc,
00051                       TypeID const& theTypeID,
00052                       std::set<std::string> const& aliases = std::set<std::string>());
00053 
00054     ~BranchDescription() {}
00055 
00056     void init() const {
00057       initBranchName();
00058       initFromDictionary();
00059     }
00060 
00061     void initBranchName() const;
00062 
00063     void initFromDictionary() const;
00064 
00065     void write(std::ostream& os) const;
00066 
00067     void merge(BranchDescription const& other);
00068 
00069     std::string const& moduleLabel() const {return moduleLabel_;}
00070     std::string const& processName() const {return processName_;}
00071     BranchID const& branchID() const {return branchID_;}
00072     ProductID const& oldProductID() const {return productID_;}
00073     std::string const& fullClassName() const {return fullClassName_;}
00074     std::string const& className() const {return fullClassName();}
00075     std::string const& friendlyClassName() const {return friendlyClassName_;}
00076     std::string const& productInstanceName() const {return productInstanceName_;}
00077     bool& produced() const {return transients_.get().produced_;}
00078     bool present() const {return !transients_.get().dropped_;}
00079     bool& dropped() const {return transients_.get().dropped_;}
00080     bool& onDemand() const {return transients_.get().onDemand_;}
00081     bool& transient() const {return transients_.get().transient_;}
00082     Reflex::Type& type() const {return transients_.get().type_;}
00083     TypeID& typeID() const {return transients_.get().typeID_;}
00084     int& splitLevel() const {return transients_.get().splitLevel_;}
00085     int& basketSize() const {return transients_.get().basketSize_;}
00086 
00087     ParameterSetID const& parameterSetID() const {return transients_.get().parameterSetID_;}
00088     std::string const& moduleName() const {return transients_.get().moduleName_;}
00089 
00090     std::map<ProcessConfigurationID, ParameterSetID>& parameterSetIDs() const {
00091       return transients_.get().parameterSetIDs_;
00092     }
00093     std::map<ProcessConfigurationID, std::string>& moduleNames() const {
00094       return transients_.get().moduleNames_;
00095     }
00096     ParameterSetID const& psetID() const;
00097     bool isPsetIDUnique() const {return parameterSetIDs().size() == 1;}
00098     std::set<std::string> const& branchAliases() const {return branchAliases_;}
00099     std::set<std::string>& branchAliases() {return branchAliases_;}
00100     std::string& branchName() const {return transients_.get().branchName_;}
00101     BranchType const& branchType() const {return branchType_;}
00102     std::string& wrappedName() const {return transients_.get().wrappedName_;}
00103     WrapperInterfaceBase*& wrapperInterfaceBase() const {return transients_.get().wrapperInterfaceBase_;}
00104 
00105     WrapperInterfaceBase const* getInterface() const;
00106     void setDropped() const {dropped() = true;}
00107     void setOnDemand() const {onDemand() = true;}
00108     void updateFriendlyClassName();
00109 
00110     struct Transients {
00111       Transients();
00112 
00113       // The parameter set id of the producer.
00114       // This is set if and only if produced_ is true.
00115       ParameterSetID parameterSetID_;
00116 
00117       // The module name of the producer.
00118       // This is set if and only if produced_ is true.
00119       std::string moduleName_;
00120 
00121       // The branch name, which is currently derivable fron the other attributes.
00122       std::string branchName_;
00123 
00124       // The wrapped class name, which is currently derivable fron the other attributes.
00125       std::string wrappedName_;
00126 
00127       // Was this branch produced in this process rather than in a previous process
00128       bool produced_;
00129 
00130       // Was this branch produced in this current process and by unscheduled production
00131       // This item is set only in the framework, not by FWLite.
00132       bool onDemand_;
00133 
00134       // Has the branch been dropped from the product tree in this file
00135       // (or if this is a merged product registry, in the first file).
00136       // This item is set only in the framework, not by FWLite.
00137       bool dropped_;
00138 
00139       // ID's of process configurations for products on this branch
00140       //  with corresponding parameter set IDs,
00141       // This is initialized if and only if produced_ is false.
00142       mutable std::map<ProcessConfigurationID, ParameterSetID> parameterSetIDs_;
00143 
00144       // ID's of process configurations for products on this branch
00145       //  with corresponding module names
00146       // This is initialized if and only if produced_ is false.
00147       mutable std::map<ProcessConfigurationID, std::string> moduleNames_;
00148 
00149       // Is the class of the branch marked as transient
00150       // in the data dictionary
00151       bool transient_;
00152 
00153       // The Reflex Type of the wrapped object
00154       // in the data dictionary
00155       Reflex::Type type_;
00156 
00157       // A TypeID object for the unwrapped object
00158       TypeID typeID_;
00159 
00160       // A pointer to a polymorphic object to obtain typed Wrapper.
00161       mutable WrapperInterfaceBase* wrapperInterfaceBase_; 
00162 
00163       // The split level of the branch, as marked
00164       // in the data dictionary.
00165       int splitLevel_;
00166 
00167       // The basket size of the branch, as marked
00168       // in the data dictionary.
00169       int basketSize_;
00170     };
00171 
00172   private:
00173     void throwIfInvalid_() const;
00174 
00175     // What tree is the branch in?
00176     BranchType branchType_;
00177 
00178     // A human friendly string that uniquely identifies the EDProducer
00179     // and becomes part of the identity of a product that it produces
00180     std::string moduleLabel_;
00181 
00182     // the physical process that this program was part of (e.g. production)
00183     std::string processName_;
00184 
00185     // An ID uniquely identifying the branch
00186     mutable BranchID branchID_;
00187 
00188     // An ID uniquely identifying the branch
00189     // This field is obsolete and is needed only for backward compatibility
00190     // with file format 7 and earlier.
00191     ProductID productID_;
00192 
00193     // the full name of the type of product this is
00194     std::string fullClassName_;
00195 
00196     // a readable name of the type of product this is
00197     std::string friendlyClassName_;
00198 
00199     // a user-supplied name to distinguish multiple products of the same type
00200     // that are produced by the same producer
00201     std::string productInstanceName_;
00202 
00203     // The branch ROOT alias(es), which are settable by the user.
00204     std::set<std::string> branchAliases_;
00205 
00206     mutable Transient<Transients> transients_;
00207   };
00208 
00209   inline
00210   std::ostream&
00211   operator<<(std::ostream& os, BranchDescription const& p) {
00212     p.write(os);
00213     return os;
00214   }
00215 
00216   bool operator<(BranchDescription const& a, BranchDescription const& b);
00217 
00218   bool operator==(BranchDescription const& a, BranchDescription const& b);
00219 
00220   bool combinable(BranchDescription const& a, BranchDescription const& b);
00221 
00222   std::string match(BranchDescription const& a,
00223         BranchDescription const& b,
00224         std::string const& fileName,
00225         BranchDescription::MatchMode m);
00226 }
00227 #endif