CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/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 "DataFormats/Provenance/interface/BranchID.h"
00011 #include "DataFormats/Provenance/interface/BranchType.h"
00012 #include "DataFormats/Provenance/interface/ParameterSetID.h"
00013 #include "DataFormats/Provenance/interface/ProcessConfigurationID.h"
00014 #include "DataFormats/Provenance/interface/ProductID.h"
00015 #include "DataFormats/Provenance/interface/ProvenanceFwd.h"
00016 #include "FWCore/Utilities/interface/TypeID.h"
00017 
00018 #include "Reflex/Type.h"
00019 
00020 #include <iosfwd>
00021 #include <map>
00022 #include <set>
00023 #include <string>
00024 
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& moduleLabel,
00046                       std::string const& processName,
00047                       std::string const& className,
00048                       std::string const& friendlyClassName,
00049                       std::string const& productInstanceName,
00050                       std::string const& moduleName,
00051                       ParameterSetID const& parameterSetID,
00052                       TypeID const& theTypeID,
00053                       bool produced = true,
00054                       std::set<std::string> const& aliases = std::set<std::string>());
00055 
00056     ~BranchDescription() {}
00057 
00058     void init() const {
00059       initBranchName();
00060       initFromDictionary();
00061     }
00062 
00063     void initBranchName() const;
00064 
00065     void initFromDictionary() const;
00066 
00067     void write(std::ostream& os) const;
00068 
00069     void merge(BranchDescription const& other);
00070 
00071     std::string const& moduleLabel() const {return moduleLabel_;}
00072     std::string const& processName() const {return processName_;}
00073     BranchID const& branchID() const {return branchID_;}
00074     std::string const& fullClassName() const {return fullClassName_;}
00075     std::string const& className() const {return fullClassName();}
00076     std::string const& friendlyClassName() const {return friendlyClassName_;}
00077     std::string const& productInstanceName() const {return productInstanceName_;}
00078     bool& produced() const {return transient_.produced_;}
00079     bool present() const {return !transient_.dropped_;}
00080     bool& dropped() const {return transient_.dropped_;}
00081     bool& onDemand() const {return transient_.onDemand_;}
00082     bool& transient() const {return transient_.transient_;}
00083     Reflex::Type& type() const {return transient_.type_;}
00084     TypeID& typeID() const {return transient_.typeID_;}
00085     int& splitLevel() const {return transient_.splitLevel_;}
00086     int& basketSize() const {return transient_.basketSize_;}
00087 
00088     ParameterSetID const& parameterSetID() const {return transient_.parameterSetID_;}
00089     std::string const& moduleName() const {return transient_.moduleName_;}
00090 
00091     std::map<ProcessConfigurationID, ParameterSetID>& parameterSetIDs() const {
00092       return transient_.parameterSetIDs_;
00093     }
00094     std::map<ProcessConfigurationID, std::string>& moduleNames() const {
00095       return transient_.moduleNames_;
00096     }
00097     ParameterSetID const& psetID() const;
00098     bool isPsetIDUnique() const {return parameterSetIDs().size() == 1;}
00099     std::set<std::string> const& branchAliases() const {return branchAliases_;}
00100     std::set<std::string>& branchAliases() {return branchAliases_;}
00101     std::string& branchName() const {return transient_.branchName_;}
00102     BranchType const& branchType() const {return branchType_;}
00103     std::string& wrappedName() const {return transient_.wrappedName_;}
00104     WrapperInterfaceBase*& wrapperInterfaceBase() const {return transient_.wrapperInterfaceBase_;}
00105 
00106     WrapperInterfaceBase const* getInterface() const;
00107     void setDropped() const {dropped() = true;}
00108     void setOnDemand() const {onDemand() = true;}
00109     void updateFriendlyClassName();
00110 
00111     void initializeTransients() const {transient_.reset();}
00112 
00113     struct Transients {
00114       Transients();
00115 
00116       void reset();
00117 
00118       // The parameter set id of the producer.
00119       // This is set if and only if produced_ is true.
00120       ParameterSetID parameterSetID_;
00121 
00122       // The module name of the producer.
00123       // This is set if and only if produced_ is true.
00124       std::string moduleName_;
00125 
00126       // The branch name, which is currently derivable fron the other attributes.
00127       std::string branchName_;
00128 
00129       // The wrapped class name, which is currently derivable fron the other attributes.
00130       std::string wrappedName_;
00131 
00132       // Was this branch produced in this process rather than in a previous process
00133       bool produced_;
00134 
00135       // Was this branch produced in this current process and by unscheduled production
00136       // This item is set only in the framework, not by FWLite.
00137       bool onDemand_;
00138 
00139       // Has the branch been dropped from the product tree in this file
00140       // (or if this is a merged product registry, in the first file).
00141       // This item is set only in the framework, not by FWLite.
00142       bool dropped_;
00143 
00144       // ID's of process configurations for products on this branch
00145       //  with corresponding parameter set IDs,
00146       // This is initialized if and only if produced_ is false.
00147       mutable std::map<ProcessConfigurationID, ParameterSetID> parameterSetIDs_;
00148 
00149       // ID's of process configurations for products on this branch
00150       //  with corresponding module names
00151       // This is initialized if and only if produced_ is false.
00152       mutable std::map<ProcessConfigurationID, std::string> moduleNames_;
00153 
00154       // Is the class of the branch marked as transient
00155       // in the data dictionary
00156       bool transient_;
00157 
00158       // The Reflex Type of the wrapped object
00159       // in the data dictionary
00160       Reflex::Type type_;
00161 
00162       // A TypeID object for the unwrapped object
00163       TypeID typeID_;
00164 
00165       // A pointer to a polymorphic object to obtain typed Wrapper.
00166       mutable WrapperInterfaceBase* wrapperInterfaceBase_;
00167 
00168       // The split level of the branch, as marked
00169       // in the data dictionary.
00170       int splitLevel_;
00171 
00172       // The basket size of the branch, as marked
00173       // in the data dictionary.
00174       int basketSize_;
00175     };
00176 
00177   private:
00178     void throwIfInvalid_() const;
00179 
00180     // What tree is the branch in?
00181     BranchType branchType_;
00182 
00183     // A human friendly string that uniquely identifies the EDProducer
00184     // and becomes part of the identity of a product that it produces
00185     std::string moduleLabel_;
00186 
00187     // the physical process that this program was part of (e.g. production)
00188     std::string processName_;
00189 
00190     // An ID uniquely identifying the branch
00191     mutable BranchID branchID_;
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 Transients transient_;
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