00001 #ifndef DataFormats_Provenance_BranchDescription_h
00002 #define DataFormats_Provenance_BranchDescription_h
00003
00004
00005
00006
00007
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
00026
00027
00028
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,
00058 std::set<ParameterSetID> const& psIDs,
00059 std::set<ProcessConfigurationID> const& procConfigIDs,
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
00109
00110
00111
00112 ModuleDescriptionID moduleDescriptionID_;
00113
00114
00115
00116 ProductID productIDtoAssign_;
00117
00118
00119 std::string branchName_;
00120
00121
00122 std::string wrappedName_;
00123
00124
00125
00126 bool produced_;
00127
00128
00129
00130 bool present_;
00131
00132
00133
00134 bool transient_;
00135
00136
00137 ROOT::Reflex::Type type_;
00138
00139
00140
00141 int splitLevel_;
00142
00143
00144
00145 int basketSize_;
00146 };
00147
00148 private:
00149 void throwIfInvalid_() const;
00150
00151
00152 BranchType branchType_;
00153
00154
00155
00156 std::string moduleLabel_;
00157
00158
00159 std::string processName_;
00160
00161
00162 mutable BranchID branchID_;
00163
00164
00165
00166
00167 ProductID productID_;
00168
00169
00170 std::string fullClassName_;
00171
00172 public:
00173
00174 std::string friendlyClassName_;
00175
00176
00177
00178 std::string productInstanceName_;
00179
00180 private:
00181
00182
00183 std::set<ParameterSetID> psetIDs_;
00184
00185
00186
00187 std::set<ProcessConfigurationID> processConfigurationIDs_;
00188
00189
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