CMS 3D CMS Logo

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