CMS 3D CMS Logo

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