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 FileInPath;
19 } // namespace edm
20 
22  std::string const&,
23  bool,
25 
26 static std::map<edm::ParameterTypes, FillDescriptionFromParameter> s_findTheRightFunction;
27 
28 namespace {
29 
30  template <typename T>
31  void fillDescriptionFromParameter(edm::ParameterSet const& pset,
32  std::string const& name,
33  bool isTracked,
35  if (isTracked) {
36  desc.add<T>(name, pset.getParameter<T>(name));
37  } else {
38  desc.addUntracked<T>(name, pset.getUntrackedParameter<T>(name));
39  }
40  }
41 
42  void initMap() {
43  s_findTheRightFunction[static_cast<edm::ParameterTypes>('I')] = &fillDescriptionFromParameter<int>;
44  s_findTheRightFunction[static_cast<edm::ParameterTypes>('i')] = &fillDescriptionFromParameter<std::vector<int>>;
45  s_findTheRightFunction[static_cast<edm::ParameterTypes>('U')] = &fillDescriptionFromParameter<unsigned>;
46  s_findTheRightFunction[static_cast<edm::ParameterTypes>('u')] =
47  &fillDescriptionFromParameter<std::vector<unsigned>>;
48  s_findTheRightFunction[static_cast<edm::ParameterTypes>('L')] = &fillDescriptionFromParameter<long long>;
49  s_findTheRightFunction[static_cast<edm::ParameterTypes>('l')] =
50  &fillDescriptionFromParameter<std::vector<long long>>;
51  s_findTheRightFunction[static_cast<edm::ParameterTypes>('X')] = &fillDescriptionFromParameter<unsigned long long>;
52  s_findTheRightFunction[static_cast<edm::ParameterTypes>('x')] =
53  &fillDescriptionFromParameter<std::vector<unsigned long long>>;
54  s_findTheRightFunction[static_cast<edm::ParameterTypes>('D')] = &fillDescriptionFromParameter<double>;
55  s_findTheRightFunction[static_cast<edm::ParameterTypes>('d')] = &fillDescriptionFromParameter<std::vector<double>>;
56  s_findTheRightFunction[static_cast<edm::ParameterTypes>('B')] = &fillDescriptionFromParameter<bool>;
57  s_findTheRightFunction[static_cast<edm::ParameterTypes>('S')] = &fillDescriptionFromParameter<std::string>;
58  s_findTheRightFunction[static_cast<edm::ParameterTypes>('s')] =
59  &fillDescriptionFromParameter<std::vector<std::string>>;
60  s_findTheRightFunction[static_cast<edm::ParameterTypes>('E')] = &fillDescriptionFromParameter<edm::EventID>;
61  s_findTheRightFunction[static_cast<edm::ParameterTypes>('e')] =
62  &fillDescriptionFromParameter<std::vector<edm::EventID>>;
63  s_findTheRightFunction[static_cast<edm::ParameterTypes>('M')] =
64  &fillDescriptionFromParameter<edm::LuminosityBlockID>;
65  s_findTheRightFunction[static_cast<edm::ParameterTypes>('m')] =
66  &fillDescriptionFromParameter<std::vector<edm::LuminosityBlockID>>;
67  s_findTheRightFunction[static_cast<edm::ParameterTypes>('t')] = &fillDescriptionFromParameter<edm::InputTag>;
68  s_findTheRightFunction[static_cast<edm::ParameterTypes>('v')] =
69  &fillDescriptionFromParameter<std::vector<edm::InputTag>>;
70  s_findTheRightFunction[static_cast<edm::ParameterTypes>('F')] = &fillDescriptionFromParameter<edm::FileInPath>;
71  s_findTheRightFunction[static_cast<edm::ParameterTypes>('A')] =
72  &fillDescriptionFromParameter<edm::LuminosityBlockRange>;
73  s_findTheRightFunction[static_cast<edm::ParameterTypes>('a')] =
74  &fillDescriptionFromParameter<std::vector<edm::LuminosityBlockRange>>;
75  s_findTheRightFunction[static_cast<edm::ParameterTypes>('R')] = &fillDescriptionFromParameter<edm::EventRange>;
76  s_findTheRightFunction[static_cast<edm::ParameterTypes>('r')] =
77  &fillDescriptionFromParameter<std::vector<edm::EventRange>>;
78  }
79 
80  std::map<edm::ParameterTypes, FillDescriptionFromParameter>& findTheRightFunction() {
81  if (s_findTheRightFunction.empty())
82  initMap();
84  }
85 } // namespace
86 
87 namespace edm {
88 
89  // Note that the description this fills is used for purposes
90  // of printing documentation from edmPluginHelp and writing
91  // cfi files. In general, it will not be useful for validation
92  // purposes. First of all, if the ParameterSet contains a
93  // vector of ParameterSets, then the description of that vector
94  // of ParameterSets will have an empty ParameterSetDescription
95  // (so if you try to validate with such a description, it will
96  // always fail). Also, the ParameterSet has no concept of "optional"
97  // or the logical relationships between parameters in the
98  // description (like "and", "xor", "switches", ...), so there is
99  // no way a description generated from a ParameterSet can properly
100  // express those concepts.
101 
103  ParameterSet::table const& entries = pset.tbl();
104  for (ParameterSet::table::const_iterator entry = entries.begin(), endEntries = entries.end(); entry != endEntries;
105  ++entry) {
106  std::map<edm::ParameterTypes, FillDescriptionFromParameter>::iterator iter =
107  findTheRightFunction().find(static_cast<edm::ParameterTypes>(entry->second.typeCode()));
108  if (iter != findTheRightFunction().end()) {
109  iter->second(pset, entry->first, entry->second.isTracked(), desc);
110  }
111  }
112 
113  ParameterSet::psettable const& pset_entries = pset.psetTable();
114  for (ParameterSet::psettable::const_iterator pset_entry = pset_entries.begin(), endEntries = pset_entries.end();
115  pset_entry != endEntries;
116  ++pset_entry) {
117  edm::ParameterSet nestedPset;
118  if (pset_entry->second.isTracked()) {
119  nestedPset = pset.getParameterSet(pset_entry->first);
120  } else {
121  nestedPset = pset.getUntrackedParameterSet(pset_entry->first);
122  }
123  ParameterSetDescription nestedDescription;
124  fillDescriptionFromPSet(nestedPset, nestedDescription);
125  if (pset_entry->second.isTracked()) {
126  desc.add<edm::ParameterSetDescription>(pset_entry->first, nestedDescription);
127  } else {
128  desc.addUntracked<edm::ParameterSetDescription>(pset_entry->first, nestedDescription);
129  }
130  }
131 
132  ParameterSet::vpsettable const& vpset_entries = pset.vpsetTable();
133  for (ParameterSet::vpsettable::const_iterator vpset_entry = vpset_entries.begin(), endEntries = vpset_entries.end();
134  vpset_entry != endEntries;
135  ++vpset_entry) {
136  std::vector<edm::ParameterSet> nestedVPset;
137  if (vpset_entry->second.isTracked()) {
138  nestedVPset = pset.getParameterSetVector(vpset_entry->first);
139  } else {
140  nestedVPset = pset.getUntrackedParameterSetVector(vpset_entry->first);
141  }
142  ParameterSetDescription emptyDescription;
143 
144  auto pd = std::make_unique<ParameterDescription<std::vector<ParameterSet>>>(
145  vpset_entry->first, emptyDescription, vpset_entry->second.isTracked(), nestedVPset);
146 
147  pd->setPartOfDefaultOfVPSet(true);
148  std::unique_ptr<ParameterDescriptionNode> node(std::move(pd));
149  desc.addNode(std::move(node));
150  }
151  }
152 } // namespace edm
std::map< std::string, ParameterSetEntry > psettable
Definition: ParameterSet.h:235
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, Entry > table
Definition: ParameterSet.h:232
std::map< std::string, VParameterSetEntry > vpsettable
Definition: ParameterSet.h:238
HLT enums.
long double T
def move(src, dest)
Definition: eostools.py:511