CMS 3D CMS Logo

FillDescriptionFromPSet.cc
Go to the documentation of this file.
1 
7 
8 #include <string>
9 #include <map>
10 #include <vector>
11 
12 namespace edm {
13  class EventID;
14  class LuminosityBlockID;
16  class EventRange;
17  class InputTag;
18  class ESInputTag;
19  class FileInPath;
20 } // namespace edm
21 
23  std::string const&,
24  bool,
26 
27 static std::map<edm::ParameterTypes, FillDescriptionFromParameter> s_findTheRightFunction;
28 
29 namespace {
30 
31  template <typename T>
32  void fillDescriptionFromParameter(edm::ParameterSet const& pset,
33  std::string const& name,
34  bool isTracked,
36  if (isTracked) {
37  desc.add<T>(name, pset.getParameter<T>(name));
38  } else {
39  desc.addUntracked<T>(name, pset.getUntrackedParameter<T>(name));
40  }
41  }
42 
43  void initMap() {
44  s_findTheRightFunction[edm::k_int32] = &fillDescriptionFromParameter<int>;
45  s_findTheRightFunction[edm::k_vint32] = &fillDescriptionFromParameter<std::vector<int>>;
46  s_findTheRightFunction[edm::k_uint32] = &fillDescriptionFromParameter<unsigned>;
47  s_findTheRightFunction[edm::k_vuint32] = &fillDescriptionFromParameter<std::vector<unsigned>>;
48  s_findTheRightFunction[edm::k_int64] = &fillDescriptionFromParameter<long long>;
49  s_findTheRightFunction[edm::k_vint64] = &fillDescriptionFromParameter<std::vector<long long>>;
50  s_findTheRightFunction[edm::k_uint64] = &fillDescriptionFromParameter<unsigned long long>;
51  s_findTheRightFunction[edm::k_vuint64] = &fillDescriptionFromParameter<std::vector<unsigned long long>>;
52  s_findTheRightFunction[edm::k_double] = &fillDescriptionFromParameter<double>;
53  s_findTheRightFunction[edm::k_vdouble] = &fillDescriptionFromParameter<std::vector<double>>;
54  s_findTheRightFunction[edm::k_bool] = &fillDescriptionFromParameter<bool>;
55  s_findTheRightFunction[edm::k_stringRaw] = &fillDescriptionFromParameter<std::string>;
56  s_findTheRightFunction[edm::k_vstringRaw] = &fillDescriptionFromParameter<std::vector<std::string>>;
57  s_findTheRightFunction[edm::k_EventID] = &fillDescriptionFromParameter<edm::EventID>;
58  s_findTheRightFunction[edm::k_VEventID] = &fillDescriptionFromParameter<std::vector<edm::EventID>>;
59  s_findTheRightFunction[edm::k_LuminosityBlockID] = &fillDescriptionFromParameter<edm::LuminosityBlockID>;
61  &fillDescriptionFromParameter<std::vector<edm::LuminosityBlockID>>;
62  s_findTheRightFunction[edm::k_InputTag] = &fillDescriptionFromParameter<edm::InputTag>;
63  s_findTheRightFunction[edm::k_VInputTag] = &fillDescriptionFromParameter<std::vector<edm::InputTag>>;
64  s_findTheRightFunction[edm::k_ESInputTag] = &fillDescriptionFromParameter<edm::ESInputTag>;
65  s_findTheRightFunction[edm::k_VESInputTag] = &fillDescriptionFromParameter<std::vector<edm::ESInputTag>>;
66  s_findTheRightFunction[edm::k_FileInPath] = &fillDescriptionFromParameter<edm::FileInPath>;
67  s_findTheRightFunction[edm::k_LuminosityBlockRange] = &fillDescriptionFromParameter<edm::LuminosityBlockRange>;
69  &fillDescriptionFromParameter<std::vector<edm::LuminosityBlockRange>>;
70  s_findTheRightFunction[edm::k_EventRange] = &fillDescriptionFromParameter<edm::EventRange>;
71  s_findTheRightFunction[edm::k_VEventRange] = &fillDescriptionFromParameter<std::vector<edm::EventRange>>;
72  }
73 
74  std::map<edm::ParameterTypes, FillDescriptionFromParameter>& findTheRightFunction() {
75  if (s_findTheRightFunction.empty())
76  initMap();
78  }
79 } // namespace
80 
81 namespace edm {
82 
83  // Note that the description this fills is used for purposes
84  // of printing documentation from edmPluginHelp and writing
85  // cfi files. In general, it will not be useful for validation
86  // purposes. First of all, if the ParameterSet contains a
87  // vector of ParameterSets, then the description of that vector
88  // of ParameterSets will have an empty ParameterSetDescription
89  // (so if you try to validate with such a description, it will
90  // always fail). Also, the ParameterSet has no concept of "optional"
91  // or the logical relationships between parameters in the
92  // description (like "and", "xor", "switches", ...), so there is
93  // no way a description generated from a ParameterSet can properly
94  // express those concepts.
95 
97  ParameterSet::table const& entries = pset.tbl();
98  for (ParameterSet::table::const_iterator entry = entries.begin(), endEntries = entries.end(); entry != endEntries;
99  ++entry) {
100  std::map<edm::ParameterTypes, FillDescriptionFromParameter>::iterator iter =
101  findTheRightFunction().find(static_cast<edm::ParameterTypes>(entry->second.typeCode()));
102  if (iter != findTheRightFunction().end()) {
103  iter->second(pset, entry->first, entry->second.isTracked(), desc);
104  }
105  }
106 
107  ParameterSet::psettable const& pset_entries = pset.psetTable();
108  for (ParameterSet::psettable::const_iterator pset_entry = pset_entries.begin(), endEntries = pset_entries.end();
109  pset_entry != endEntries;
110  ++pset_entry) {
111  edm::ParameterSet nestedPset;
112  if (pset_entry->second.isTracked()) {
113  nestedPset = pset.getParameterSet(pset_entry->first);
114  } else {
115  nestedPset = pset.getUntrackedParameterSet(pset_entry->first);
116  }
117  ParameterSetDescription nestedDescription;
118  fillDescriptionFromPSet(nestedPset, nestedDescription);
119  if (pset_entry->second.isTracked()) {
120  desc.add<edm::ParameterSetDescription>(pset_entry->first, nestedDescription);
121  } else {
122  desc.addUntracked<edm::ParameterSetDescription>(pset_entry->first, nestedDescription);
123  }
124  }
125 
126  ParameterSet::vpsettable const& vpset_entries = pset.vpsetTable();
127  for (ParameterSet::vpsettable::const_iterator vpset_entry = vpset_entries.begin(), endEntries = vpset_entries.end();
128  vpset_entry != endEntries;
129  ++vpset_entry) {
130  std::vector<edm::ParameterSet> nestedVPset;
131  if (vpset_entry->second.isTracked()) {
132  nestedVPset = pset.getParameterSetVector(vpset_entry->first);
133  } else {
134  nestedVPset = pset.getUntrackedParameterSetVector(vpset_entry->first);
135  }
136  ParameterSetDescription emptyDescription;
137 
138  auto pd = std::make_unique<ParameterDescription<std::vector<ParameterSet>>>(
139  vpset_entry->first, emptyDescription, vpset_entry->second.isTracked(), nestedVPset);
140 
141  pd->setPartOfDefaultOfVPSet(true);
142  std::unique_ptr<ParameterDescriptionNode> node(std::move(pd));
143  desc.addNode(std::move(node));
144  }
145  }
146 } // namespace edm
std::map< std::string, ParameterSetEntry, std::less<> > psettable
Definition: ParameterSet.h:236
void fillDescriptionFromPSet(ParameterSet const &pset, ParameterSetDescription &desc)
TEMPL(T2) struct Divides void
Definition: Factorize.h:24
void(* FillDescriptionFromParameter)(edm::ParameterSet const &, std::string const &, bool, edm::ParameterSetDescription &)
static std::map< edm::ParameterTypes, FillDescriptionFromParameter > s_findTheRightFunction
std::map< std::string, VParameterSetEntry, std::less<> > vpsettable
Definition: ParameterSet.h:239
HLT enums.
std::map< std::string, Entry, std::less<> > table
Definition: ParameterSet.h:233
long double T
def move(src, dest)
Definition: eostools.py:511