CMS 3D CMS Logo

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 <set>
00013 
00014 #include "DataFormats/Provenance/interface/ProvenanceFwd.h"
00015 #include "DataFormats/Provenance/interface/BranchType.h"
00016 #include "DataFormats/Provenance/interface/BranchID.h"
00017 #include "DataFormats/Provenance/interface/ProductID.h"
00018 #include "DataFormats/Provenance/interface/ParameterSetID.h"
00019 #include "DataFormats/Provenance/interface/ModuleDescriptionID.h"
00020 #include "DataFormats/Provenance/interface/ProcessConfigurationID.h"
00021 #include "DataFormats/Provenance/interface/Transient.h"
00022 
00023 #include "Reflex/Type.h"
00024 /*
00025   BranchDescription
00026 
00027   definitions:
00028   The event-independent description of an EDProduct.
00029 
00030 */
00031 
00032 namespace edm {
00033   struct BranchDescription {
00034     static int const invalidSplitLevel = -1;
00035     static int const invalidBasketSize = 0;
00036     enum MatchMode { Strict = 0,
00037                      Permissive };
00038 
00039     BranchDescription();
00040 
00041     BranchDescription(BranchType const& branchType,
00042                       std::string const& mdLabel, 
00043                       std::string const& procName, 
00044                       std::string const& name, 
00045                       std::string const& fName, 
00046                       std::string const& pin, 
00047                       ModuleDescription const& modDesc,
00048                       std::set<std::string> const& aliases = std::set<std::string>());
00049 
00050 
00051     BranchDescription(BranchType const& branchType,
00052                       std::string const& mdLabel, 
00053                       std::string const& procName, 
00054                       std::string const& name, 
00055                       std::string const& fName, 
00056                       std::string const& pin, 
00057                       ModuleDescriptionID const& mdID, // = ModuleDescriptionID(),
00058                       std::set<ParameterSetID> const& psIDs, // = std::set<ParameterSetID>(),
00059                       std::set<ProcessConfigurationID> const& procConfigIDs, // = std::set<ProcessConfigurationID>(),
00060                       std::set<std::string> const& aliases = std::set<std::string>());
00061 
00062     ~BranchDescription() {}
00063 
00064     void init() const;
00065 
00066     void write(std::ostream& os) const;
00067 
00068     void merge(BranchDescription const& other);
00069 
00070     std::string const& moduleLabel() const {return moduleLabel_;}
00071     std::string const& processName() const {return processName_;}
00072     BranchID const& branchID() const {return branchID_;}
00073     ProductID const& oldProductID() const {return productID_;}
00074     ProductID & productIDtoAssign() const {return transients_.get().productIDtoAssign_;}
00075     std::string const& fullClassName() const {return fullClassName_;}
00076     std::string const& className() const {return fullClassName();}
00077     std::string const& friendlyClassName() const {return friendlyClassName_;}
00078     std::string const& productInstanceName() const {return productInstanceName_;} 
00079     bool & produced() const {return transients_.get().produced_;}
00080     bool & present() const {return transients_.get().present_;}
00081     bool & transient() const {return transients_.get().transient_;}
00082     ROOT::Reflex::Type & type() const {return transients_.get().type_;}
00083     int & splitLevel() const {return transients_.get().splitLevel_;}
00084     int & basketSize() const {return transients_.get().basketSize_;}
00085 
00086     ModuleDescriptionID & moduleDescriptionID() const {return transients_.get().moduleDescriptionID_;}
00087     std::set<ParameterSetID> const& psetIDs() const {return psetIDs_;}
00088     ParameterSetID const& psetID() const;
00089     bool isPsetIDUnique() const {return psetIDs().size() == 1;}
00090     std::set<ProcessConfigurationID> const& processConfigurationIDs() const {return processConfigurationIDs_;}
00091     std::set<std::string> const& branchAliases() const {return branchAliases_;}
00092     std::set<std::string> & branchAliases() {return branchAliases_;}
00093     std::string & branchName() const {return transients_.get().branchName_;}
00094     BranchType const& branchType() const {return branchType_;}
00095     std::string & wrappedName() const {return transients_.get().wrappedName_;}
00096 
00097     void setPresent(bool isPresent) const {present() = isPresent;}
00098     void setProductIDtoAssign(ProductID const& id) const {productIDtoAssign() = id;}
00099     void updateFriendlyClassName();
00100 
00101     void setDefaultTransients() const {
00102         transients_ = Transients();
00103     };
00104 
00105     struct Transients {
00106       Transients();
00107 
00108       // The module description id of the producer.
00109       // This is only valid if produced_ is true.
00110       // This is just used as a cache, and is not logically
00111       // part of the branch description.
00112       ModuleDescriptionID moduleDescriptionID_;
00113 
00114       // An ID to be assigned to products on the branch,
00115       // This is only valid if produced_ is true.
00116       ProductID productIDtoAssign_;
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
00125       // rather than in a previous process
00126       bool produced_;
00127 
00128       // Is the branch present in the product tree
00129       // in the input file (or any of the input files)
00130       bool present_;
00131 
00132       // Is the class of the branch marked as transient
00133       // in the data dictionary
00134       bool transient_;
00135 
00136       // The Reflex Type of the wrapped object.
00137       ROOT::Reflex::Type type_;
00138 
00139       // The split level of the branch, as marked
00140       // in the data dictionary.
00141       int splitLevel_;
00142 
00143       // The basket size of the branch, as marked
00144       // in the data dictionary.
00145       int basketSize_;
00146     };
00147 
00148   private:
00149     void throwIfInvalid_() const;
00150 
00151     // What tree is the branch in?
00152     BranchType branchType_;
00153 
00154     // A human friendly string that uniquely identifies the EDProducer
00155     // and becomes part of the identity of a product that it produces
00156     std::string moduleLabel_;
00157 
00158     // the physical process that this program was part of (e.g. production)
00159     std::string processName_;
00160 
00161     // An ID uniquely identifying the branch
00162     mutable BranchID branchID_;
00163 
00164     // An ID uniquely identifying the branch
00165     // This field is obsolete and is needed only for backward compatibility
00166     // with file format 7 and earlier.  
00167     ProductID productID_;
00168 
00169     // the full name of the type of product this is
00170     std::string fullClassName_;
00171 
00172   public:
00173     // a readable name of the type of product this is
00174     std::string friendlyClassName_;
00175 
00176     // a user-supplied name to distinguish multiple products of the same type
00177     // that are produced by the same producer
00178     std::string productInstanceName_;
00179 
00180   private:
00181     // ID's of parameter set of the creators of products
00182     // on this branch
00183     std::set<ParameterSetID> psetIDs_;
00184 
00185     // ID's of process configurations for products
00186     // on this branch
00187     std::set<ProcessConfigurationID> processConfigurationIDs_;
00188 
00189     // The branch ROOT alias(es), which are settable by the user.
00190     std::set<std::string> branchAliases_;
00191 
00192     mutable Transient<Transients> transients_;
00193   };
00194   
00195   inline
00196   std::ostream&
00197   operator<<(std::ostream& os, BranchDescription const& p) {
00198     p.write(os);
00199     return os;
00200   }
00201 
00202   bool operator<(BranchDescription const& a, BranchDescription const& b);
00203 
00204   bool operator==(BranchDescription const& a, BranchDescription const& b);
00205 
00206   bool combinable(BranchDescription const& a, BranchDescription const& b);
00207 
00208   std::string match(BranchDescription const& a,
00209         BranchDescription const& b,
00210         std::string const& fileName,
00211         BranchDescription::MatchMode m);
00212 }
00213 #endif

Generated on Tue Jun 9 17:31:30 2009 for CMSSW by  doxygen 1.5.4