CMS 3D CMS Logo

ProducerWithPSetDesc.cc
Go to the documentation of this file.
1 #include "ProducerWithPSetDesc.h"
2 #include "DataFormats/TestObjects/interface/ThingCollection.h"
5 
21 
22 #include <vector>
23 #include <limits>
24 #include <memory>
25 #include <string>
26 #include <iostream>
27 
28 namespace edmtest {
29 
31  virtual ~AnotherIntMakerBase() = default;
32  virtual int value() const = 0;
33  };
34 
36 
37 } // namespace edmtest
38 
40 
41 namespace edmtest {
42 
44  explicit AnotherOneMaker(edm::ParameterSet const&) {}
45  int value() const final { return 1; };
46 
48  };
49 
51  explicit AnotherValueMaker(edm::ParameterSet const& iPSet) : value_{iPSet.getParameter<int>("value")} {}
52  int value() const final { return value_; };
53 
54  static void fillPSetDescription(edm::ParameterSetDescription& iDesc) { iDesc.add<int>("value", 5); }
55  int value_;
56  };
57 
60  : value_{iPSet.getParameter<int>("value")} {
61  auto recursivePluginPSet = iPSet.getParameter<edm::ParameterSet>("pluginRecursive");
63  AnotherIntFactory::get()->create(recursivePluginPSet.getParameter<std::string>("type"), recursivePluginPSet);
64  }
65  int value() const final { return value_; };
66 
68  iDesc.add<int>("value", 5);
69 
71  pluginDesc.addNode(edm::PluginDescription<AnotherIntFactory>("type", true));
72  iDesc.add<edm::ParameterSetDescription>("pluginRecursive", pluginDesc);
73  }
74 
75  std::unique_ptr<AnotherIntMakerBase> recursivePluginHelper_;
76  int value_;
77  };
78 
79 } // namespace edmtest
84  "edmtestAnotherMakerWithRecursivePlugin");
85 
86 namespace edmtest {
87 
89  testingAutoGeneratedCfi = ps.getUntrackedParameter<bool>("testingAutoGeneratedCfi", true);
90 
91  assert(ps.getParameter<int>("p_int") == 2147483647);
92  assert(ps.getUntrackedParameter<int>("p_int_untracked") == -2147483647);
94  assert(ps.getParameter<int>("p_int_opt") == 0);
96  assert(ps.getUntrackedParameter<int>("p_int_optuntracked") == 7);
97  assert(!ps.exists("p_int_opt_nd"));
98  assert(!ps.exists("p_int_optuntracked_nd"));
99  } else {
100  assert(!ps.exists("p_int_optuntracked"));
101  assert(ps.getParameter<int>("p_int_opt_nd") == 11);
102  assert(ps.getUntrackedParameter<int>("p_int_optuntracked_nd") == 12);
103  }
104 
105  std::vector<int> vint;
106  vint = ps.getParameter<std::vector<int>>("vint1");
107  assert(vint.empty());
108  vint = ps.getParameter<std::vector<int>>("vint2");
109  assert(vint[0] == 2147483647);
110  vint = ps.getParameter<std::vector<int>>("vint3");
111  assert(vint[0] == 2147483647);
112  assert(vint[1] == -2147483647);
113  std::array<int, 2> testArray = ps.getParameter<std::array<int, 2>>(std::string("vint3"));
114  assert(testArray[0] == 2147483647);
115  assert(testArray[1] == -2147483647);
116  std::array<int, 2> testArray1 = ps.getParameter<std::array<int, 2>>("vint3");
117  assert(testArray1[0] == 2147483647);
118  assert(testArray1[1] == -2147483647);
119  vint = ps.getParameter<std::vector<int>>("vint4");
120  assert(vint[0] == 2147483647);
121  assert(vint[1] == -2147483647);
122  assert(vint[2] == 0);
123 
124  assert(ps.getParameter<unsigned>("uint1") == 4294967295U);
125  assert(ps.getUntrackedParameter<unsigned>("uint2") == 0);
126 
127  std::vector<unsigned> vuint;
128  vuint = ps.getParameter<std::vector<unsigned>>("vuint1");
129  assert(vuint.empty());
130  vuint = ps.getParameter<std::vector<unsigned>>("vuint2");
131  assert(vuint[0] == 4294967295U);
132  vuint = ps.getParameter<std::vector<unsigned>>("vuint3");
133  assert(vuint[0] == 4294967295U);
134  assert(vuint[1] == 0);
135  vuint = ps.getParameter<std::vector<unsigned>>("vuint4");
136  assert(vuint[0] == 4294967295U);
137  assert(vuint[1] == 0);
138  assert(vuint[2] == 11);
139 
140  assert(ps.getParameter<long long>("int64v1") == 9000000000000000000LL);
141  assert(ps.getParameter<long long>("int64v2") == -9000000000000000000LL);
142  assert(ps.getParameter<long long>("int64v3") == 0);
143 
144  std::vector<long long> vint64;
145  vint64 = ps.getParameter<std::vector<long long>>("vint64v1");
146  assert(vint64.empty());
147  vint64 = ps.getParameter<std::vector<long long>>("vint64v2");
148  assert(vint64[0] == 9000000000000000000LL);
149  vint64 = ps.getParameter<std::vector<long long>>("vint64v3");
150  assert(vint64[0] == 9000000000000000000LL);
151  assert(vint64[1] == -9000000000000000000LL);
152  vint64 = ps.getParameter<std::vector<long long>>("vint64v4");
153  assert(vint64[0] == 9000000000000000000LL);
154  assert(vint64[1] == -9000000000000000000LL);
155  assert(vint64[2] == 0);
156 
157  assert(ps.getParameter<unsigned long long>("uint64v1") == 18000000000000000000ULL);
158  assert(ps.getUntrackedParameter<unsigned long long>("uint64v2") == 0);
159 
160  std::vector<unsigned long long> vuint64;
161  vuint64 = ps.getParameter<std::vector<unsigned long long>>("vuint64v1");
162  assert(vuint64.empty());
163  vuint64 = ps.getParameter<std::vector<unsigned long long>>("vuint64v2");
164  assert(vuint64[0] == 18000000000000000000ULL);
165  vuint64 = ps.getParameter<std::vector<unsigned long long>>("vuint64v3");
166  assert(vuint64[0] == 18000000000000000000ULL);
167  assert(vuint64[1] == 0);
168  vuint64 = ps.getParameter<std::vector<unsigned long long>>("vuint64v4");
169  assert(vuint64[0] == 18000000000000000000ULL);
170  assert(vuint64[1] == 0);
171  assert(vuint64[2] == 11);
172 
173  // This one does not work because the precision in the ParameterSet stringified
174  // format is 16 instead of 17.
175  // assert(ps.getParameter<double>("doublev1") == std::numeric_limits<double>::min());
176  assert(ps.getUntrackedParameter<double>("doublev2") == 0.0);
177  assert(fabs(ps.getUntrackedParameter<double>("doublev3") - 0.3) < 0.0000001);
178 
179  std::vector<double> vdouble;
180  vdouble = ps.getParameter<std::vector<double>>("vdoublev1");
181  assert(vdouble.empty());
182  // cmsRun will fail with a value this big
183  // vdouble.push_back(std::numeric_limits<double>::max());
184  // This works though
185  vdouble = ps.getParameter<std::vector<double>>("vdoublev2");
186  assert(vdouble[0] == 1e+300);
187  vdouble = ps.getParameter<std::vector<double>>("vdoublev3");
188  assert(vdouble[0] == 1e+300);
189  assert(vdouble[1] == 0.0);
190  vdouble = ps.getParameter<std::vector<double>>("vdoublev4");
191  assert(vdouble[0] == 1e+300);
192  assert(vdouble[1] == 0.0);
193  assert(vdouble[2] == 11.0);
194  vdouble = ps.getParameter<std::vector<double>>("vdoublev5");
195  assert(vdouble[0] == 1e+300);
196  assert(vdouble[1] == 0.0);
197  assert(vdouble[2] == 11.0);
198  assert(fabs(vdouble[3] - 0.3) < 0.0000001);
199 
200  assert(ps.getParameter<bool>("boolv1") == true);
201  assert(ps.getParameter<bool>("boolv2") == false);
202 
203  std::string test("Hello");
204  assert(ps.getParameter<std::string>("stringv1") == test);
205  test.clear();
206  assert(ps.getParameter<std::string>("stringv2") == test);
207 
208  std::vector<std::string> vstring;
209  vstring = ps.getParameter<std::vector<std::string>>("vstringv1");
210  assert(vstring.empty());
211  vstring = ps.getParameter<std::vector<std::string>>("vstringv2");
212  assert(vstring[0] == std::string("Hello"));
213  vstring = ps.getParameter<std::vector<std::string>>("vstringv3");
214  assert(vstring[0] == std::string("Hello"));
215  assert(vstring[1] == std::string("World"));
216  vstring = ps.getParameter<std::vector<std::string>>("vstringv4");
217  assert(vstring[0] == std::string("Hello"));
218  assert(vstring[1] == std::string("World"));
219  assert(vstring[2] == std::string(""));
220 
221  edm::EventID eventID1(11, 0, 12);
222  assert(ps.getParameter<edm::EventID>("eventIDv1") == eventID1);
223  edm::EventID eventID2(101, 0, 102);
224  assert(ps.getParameter<edm::EventID>("eventIDv2") == eventID2);
225 
226  std::vector<edm::EventID> vEventID;
227  vEventID = ps.getParameter<std::vector<edm::EventID>>("vEventIDv1");
228  assert(vEventID.empty());
229  vEventID = ps.getParameter<std::vector<edm::EventID>>("vEventIDv2");
230  assert(vEventID[0] == edm::EventID(1000, 0, 1100));
231  vEventID = ps.getParameter<std::vector<edm::EventID>>("vEventIDv3");
232  assert(vEventID[0] == edm::EventID(1000, 0, 1100));
233  assert(vEventID[1] == edm::EventID(10000, 0, 11000));
234  vEventID = ps.getParameter<std::vector<edm::EventID>>("vEventIDv4");
235  assert(vEventID[0] == edm::EventID(1000, 0, 1100));
236  assert(vEventID[1] == edm::EventID(10000, 0, 11000));
237  assert(vEventID[2] == edm::EventID(100000, 0, 110000));
238 
239  edm::LuminosityBlockID luminosityID1(11, 12);
240  assert(ps.getParameter<edm::LuminosityBlockID>("luminosityIDv1") == luminosityID1);
241  edm::LuminosityBlockID luminosityID2(101, 102);
242  assert(ps.getParameter<edm::LuminosityBlockID>("luminosityIDv2") == luminosityID2);
243 
244  std::vector<edm::LuminosityBlockID> vLuminosityBlockID;
245  vLuminosityBlockID = ps.getParameter<std::vector<edm::LuminosityBlockID>>("vLuminosityBlockIDv1");
246  assert(vLuminosityBlockID.empty());
247  vLuminosityBlockID = ps.getParameter<std::vector<edm::LuminosityBlockID>>("vLuminosityBlockIDv2");
248  assert(vLuminosityBlockID[0] == edm::LuminosityBlockID(1000, 1100));
249  vLuminosityBlockID = ps.getParameter<std::vector<edm::LuminosityBlockID>>("vLuminosityBlockIDv3");
250  assert(vLuminosityBlockID[0] == edm::LuminosityBlockID(1000, 1100));
251  assert(vLuminosityBlockID[1] == edm::LuminosityBlockID(10000, 11000));
252  vLuminosityBlockID = ps.getParameter<std::vector<edm::LuminosityBlockID>>("vLuminosityBlockIDv4");
253  assert(vLuminosityBlockID[0] == edm::LuminosityBlockID(1000, 1100));
254  assert(vLuminosityBlockID[1] == edm::LuminosityBlockID(10000, 11000));
255  assert(vLuminosityBlockID[2] == edm::LuminosityBlockID(100000, 110000));
256 
257  edm::LuminosityBlockRange lumiRange1(1, 1, 9, 9);
258  assert(ps.getParameter<edm::LuminosityBlockRange>("lumiRangev1").startLumiID() == lumiRange1.startLumiID());
259  assert(ps.getParameter<edm::LuminosityBlockRange>("lumiRangev1").endLumiID() == lumiRange1.endLumiID());
260  edm::LuminosityBlockRange lumiRange2(3, 4, 1000, 1000);
261  assert(ps.getParameter<edm::LuminosityBlockRange>("lumiRangev2").startLumiID() == lumiRange2.startLumiID());
262  assert(ps.getParameter<edm::LuminosityBlockRange>("lumiRangev2").endLumiID() == lumiRange2.endLumiID());
263 
264  std::vector<edm::LuminosityBlockRange> vLumiRange;
265  vLumiRange = ps.getParameter<std::vector<edm::LuminosityBlockRange>>("vLumiRangev1");
266  assert(vLumiRange.empty());
267  vLumiRange = ps.getParameter<std::vector<edm::LuminosityBlockRange>>("vLumiRangev2");
268  assert(vLumiRange[0].startLumiID() == lumiRange1.startLumiID());
269  vLumiRange = ps.getParameter<std::vector<edm::LuminosityBlockRange>>("vLumiRangev3");
270  assert(vLumiRange[0].startLumiID() == lumiRange1.startLumiID());
271  assert(vLumiRange[1].startLumiID() == lumiRange2.startLumiID());
272  assert(vLumiRange[1].endLumiID() == lumiRange2.endLumiID());
273 
274  edm::EventRange eventRange1(1, 0, 1, 8, 0, 8);
275  assert(ps.getParameter<edm::EventRange>("eventRangev1").startEventID() == eventRange1.startEventID());
276  assert(ps.getParameter<edm::EventRange>("eventRangev1").endEventID() == eventRange1.endEventID());
277  edm::EventRange eventRange2(3, 0, 4, 1001, 0, 1002);
278  assert(ps.getParameter<edm::EventRange>("eventRangev2").startEventID() == eventRange2.startEventID());
279  assert(ps.getParameter<edm::EventRange>("eventRangev2").endEventID() == eventRange2.endEventID());
280 
281  std::vector<edm::EventRange> vEventRange;
282  vEventRange = ps.getParameter<std::vector<edm::EventRange>>("vEventRangev1");
283  assert(vEventRange.empty());
284  vEventRange = ps.getParameter<std::vector<edm::EventRange>>("vEventRangev2");
285  assert(vEventRange[0].startEventID() == eventRange1.startEventID());
286  vEventRange = ps.getParameter<std::vector<edm::EventRange>>("vEventRangev3");
287  assert(vEventRange[0].startEventID() == eventRange1.startEventID());
288  assert(vEventRange[1].startEventID() == eventRange2.startEventID());
289 
290  edm::InputTag inputTag1("One", "Two", "Three");
291  assert(ps.getParameter<edm::InputTag>("inputTagv1") == inputTag1);
292  edm::InputTag inputTag2("One", "Two");
293  assert(ps.getParameter<edm::InputTag>("inputTagv2") == inputTag2);
294  edm::InputTag inputTag3("One");
295  assert(ps.getParameter<edm::InputTag>("inputTagv3") == inputTag3);
296  edm::InputTag inputTag4("One", "", "Three");
297  assert(ps.getParameter<edm::InputTag>("inputTagv4") == inputTag4);
298 
299  std::vector<edm::InputTag> vInputTag;
300  vInputTag = ps.getParameter<std::vector<edm::InputTag>>("vInputTagv1");
301  assert(vInputTag.empty());
302  vInputTag = ps.getParameter<std::vector<edm::InputTag>>("vInputTagv2");
303  assert(vInputTag[0] == inputTag1);
304  vInputTag = ps.getParameter<std::vector<edm::InputTag>>("vInputTagv3");
305  assert(vInputTag[0] == inputTag1);
306  assert(vInputTag[1] == inputTag2);
307  vInputTag = ps.getParameter<std::vector<edm::InputTag>>("vInputTagv4");
308  assert(vInputTag[0] == inputTag1);
309  assert(vInputTag[1] == inputTag2);
310  assert(vInputTag[2] == inputTag3);
311  vInputTag = ps.getParameter<std::vector<edm::InputTag>>("vInputTagv5");
312  assert(vInputTag[0] == inputTag1);
313  assert(vInputTag[1] == inputTag2);
314  assert(vInputTag[2] == inputTag3);
315  assert(vInputTag[3] == inputTag4);
316 
317  edm::ESInputTag esinputTag1("One", "Two");
318  assert(ps.getParameter<edm::ESInputTag>("esinputTagv1") == esinputTag1);
319  edm::ESInputTag esinputTag2("One", "");
320  assert(ps.getParameter<edm::ESInputTag>("esinputTagv2") == esinputTag2);
321  edm::ESInputTag esinputTag3("", "Two");
322  assert(ps.getParameter<edm::ESInputTag>("esinputTagv3") == esinputTag3);
323 
324  std::vector<edm::ESInputTag> vESInputTag;
325  vESInputTag = ps.getParameter<std::vector<edm::ESInputTag>>("vESInputTagv1");
326  assert(vESInputTag.empty());
327  vESInputTag = ps.getParameter<std::vector<edm::ESInputTag>>("vESInputTagv2");
328  assert(vESInputTag[0] == esinputTag1);
329  vESInputTag = ps.getParameter<std::vector<edm::ESInputTag>>("vESInputTagv3");
330  assert(vESInputTag[0] == esinputTag1);
331  assert(vESInputTag[1] == esinputTag2);
332  vESInputTag = ps.getParameter<std::vector<edm::ESInputTag>>("vESInputTagv4");
333  assert(vESInputTag[0] == esinputTag1);
334  assert(vESInputTag[1] == esinputTag2);
335  assert(vESInputTag[2] == esinputTag3);
336 
337  // For purposes of the test, this just needs to point to any file
338  // that exists.
339  edm::FileInPath fileInPath("FWCore/Integration/plugins/ProducerWithPSetDesc.cc");
340  assert(fileInPath == ps.getParameter<edm::FileInPath>("fileInPath"));
341 
342  edm::ParameterSet const& pset = ps.getParameterSet("bar");
343  assert(pset.getParameter<unsigned>("Drinks") == 5U);
344  assert(pset.getUntrackedParameter<unsigned>("uDrinks") == 5U);
346  assert(pset.getParameter<unsigned>("oDrinks") == 5U);
348  assert(pset.getUntrackedParameter<unsigned>("ouDrinks") == 5U);
349 
350  //std::vector<edm::ParameterSet> const& vpsetUntracked =
351  // ps.getUntrackedParameterSetVector("test104");
352 
353  std::vector<edm::ParameterSet> const& vpset = ps.getParameterSetVector("bars");
354 
355  assert(vpset.size() == 2U);
356 
357  const edm::ParameterSet& pset0 = vpset[0];
358  assert(pset0.getParameter<unsigned>("Drinks") == 5U);
359  assert(pset0.getUntrackedParameter<unsigned>("uDrinks") == 5U);
360  assert(pset0.getParameter<unsigned>("oDrinks") == 11U);
361  assert(pset0.exists("ouDrinks") == false);
362  assert(pset0.exists("ndoDrinks") == false);
363  assert(pset0.exists("ndouDrinks") == false);
364  // assert(pset0.getUntrackedParameter<unsigned>("ndouDrinks") == 5);
365 
366  const edm::ParameterSet& pset1 = vpset[1];
367  assert(pset1.getParameter<unsigned>("Drinks") == 5U);
368  assert(pset1.getUntrackedParameter<unsigned>("uDrinks") == 5U);
369  assert(pset1.getParameter<unsigned>("oDrinks") == 11U);
370  assert(pset1.getUntrackedParameter<unsigned>("ouDrinks") == 11U);
371  assert(pset1.exists("ndoDrinks") == false);
372  assert(pset1.getUntrackedParameter<unsigned>("ndouDrinks") == 11U);
373 
374  assert(ps.getParameter<double>("test1") == 0.1);
376  assert(ps.getParameter<double>("test2") == 0.2);
377  assert(ps.exists("test3") == false);
378 
379  assert(ps.getParameter<std::string>("testA") == std::string("fooA"));
380  assert(ps.getParameter<int>("testB") == 100);
381  assert(ps.getParameter<int>("testC") == 101);
382 
383  assert(ps.getParameter<int>("oiswitch") == 1);
384  assert(ps.getParameter<double>("oivalue1") == 101.0);
385  assert(ps.getParameter<double>("oivalue2") == 101.0);
386  } else {
387  assert(!ps.exists("test2"));
388  assert(!ps.exists("test3"));
389 
390  assert(!ps.exists("testA"));
391  assert(!ps.exists("testB"));
392  assert(!ps.exists("testC"));
393 
394  assert(!ps.exists("oiswitch"));
395  assert(!ps.exists("oivalue1"));
396  assert(!ps.exists("oivalue2"));
397  }
398 
399  edm::ParameterSet const& deeplyNestedPSet = pset1.getParameterSet("testDeeplyNested");
401  assert(!deeplyNestedPSet.exists("ndiswitch"));
402  assert(!deeplyNestedPSet.exists("ndivalue1"));
403  assert(!deeplyNestedPSet.exists("ndivalue2"));
404  } else {
405  assert(!deeplyNestedPSet.exists("ndiswitch"));
406  assert(!deeplyNestedPSet.exists("ndivalue1"));
407  assert(!deeplyNestedPSet.exists("ndivalue2"));
408  }
409 
410  assert(deeplyNestedPSet.getParameter<bool>("bswitch") == false);
411  assert(deeplyNestedPSet.getParameter<double>("bvalue1") == 101.0);
412  assert(deeplyNestedPSet.getParameter<double>("bvalue2") == 101.0);
413  assert(!deeplyNestedPSet.exists("bvalue"));
414 
415  assert(deeplyNestedPSet.getParameter<int>("iswitch") == 1);
416  assert(deeplyNestedPSet.getParameter<double>("ivalue1") == 101.0);
417  assert(deeplyNestedPSet.getUntrackedParameter<double>("ivalue2") == 101.0);
418  assert(!deeplyNestedPSet.exists("ivalue"));
419 
420  assert(deeplyNestedPSet.getParameter<std::string>("sswitch") == std::string("1"));
421  assert(deeplyNestedPSet.getParameter<double>("svalue1") == 101.0);
422  assert(deeplyNestedPSet.getParameter<double>("svalue2") == 101.0);
423  assert(!deeplyNestedPSet.exists("svalue"));
424 
426  edm::ParameterSet const& pset11 = ps.getParameterSet("subpset");
427  assert(pset11.getParameter<int>("xvalue") == 11);
428  edm::ParameterSet const& pset111 = pset11.getUntrackedParameterSet("bar");
429  assert(pset111.getParameter<unsigned>("Drinks") == 5U);
430  assert(pset111.getUntrackedParameter<unsigned>("uDrinks") == 5U);
431  assert(pset111.getParameter<unsigned>("oDrinks") == 5U);
432  assert(pset111.getUntrackedParameter<unsigned>("ouDrinks") == 5U);
433  }
434 
435  edm::ParameterSet const& psetXor = ps.getParameterSet("xorPset");
436  assert(psetXor.getParameter<std::string>("name1") == std::string("11"));
437  assert(!psetXor.exists("name2"));
439  assert(psetXor.getParameter<std::string>("name") == std::string("11"));
440  } else {
441  assert(psetXor.getParameter<unsigned>("name") == 11U);
442  }
443 
444  edm::ParameterSet const& psetOr = ps.getParameterSet("orPset");
445  assert(!psetOr.exists("z1"));
446  assert(!psetOr.exists("z2"));
448  assert(psetOr.getParameter<std::string>("x1") == std::string("11"));
449  assert(!psetOr.exists("x2"));
450  assert(psetOr.getParameter<std::string>("y1") == std::string("11"));
451  assert(!psetOr.exists("y2"));
452  } else {
453  assert(!psetOr.exists("x1"));
454  assert(psetOr.getParameter<unsigned>("x2") == 11U);
455  assert(psetOr.getParameter<std::string>("y1") == std::string("11"));
456  assert(psetOr.getParameter<unsigned>("y2") == 11U);
457  }
458 
459  edm::ParameterSet const& psetAnd = ps.getParameterSet("andPset");
460  assert(psetAnd.getParameter<std::string>("x1") == std::string("11"));
461  assert(psetAnd.getParameter<unsigned>("x2") == 11U);
462  assert(psetAnd.getParameter<std::string>("y1") == std::string("11"));
463  assert(psetAnd.getParameter<unsigned>("y2") == 11U);
464  assert(psetAnd.getParameter<std::string>("z1") == std::string("11"));
465  assert(psetAnd.getParameter<unsigned>("z2") == 11U);
466  assert(psetAnd.getParameter<std::string>("b1") == std::string("11"));
467  assert(psetAnd.getParameter<unsigned>("b2") == 11U);
468  assert(psetAnd.getParameter<unsigned>("b3") == 11U);
469  assert(psetAnd.getParameter<unsigned>("b4") == 11U);
470  assert(psetAnd.getParameter<unsigned>("b5") == 11U);
471  assert(psetAnd.getParameter<unsigned>("b6") == 11U);
473  assert(!psetAnd.exists("a1"));
474  assert(!psetAnd.exists("a2"));
475  } else {
476  assert(psetAnd.getParameter<std::string>("a1") == std::string("11"));
477  assert(psetAnd.getParameter<unsigned>("a2") == 11U);
478  }
479 
480  edm::ParameterSet const& psetIfExists = ps.getParameterSet("ifExistsPset");
481  assert(psetIfExists.getParameter<unsigned>("x1") == 11U);
482  assert(psetIfExists.getParameter<std::string>("x2") == std::string("11"));
483  assert(psetIfExists.getParameter<unsigned>("z1") == 11U);
484  assert(psetIfExists.getParameter<std::string>("z2") == std::string("11"));
486  assert(!psetIfExists.exists("y1"));
487  assert(!psetIfExists.exists("y2"));
488  } else {
489  assert(psetIfExists.getParameter<unsigned>("y1") == 11U);
490  assert(!psetIfExists.exists("y2"));
491  }
492 
493  edm::ParameterSet const& psetAllowed = ps.getParameterSet("allowedLabelsPset");
495  assert(psetAllowed.getParameter<std::vector<std::string>>("testAllowedLabels").empty());
496  assert(psetAllowed.getUntrackedParameter<std::vector<std::string>>("testAllowedLabelsUntracked").empty());
497  assert(!psetAllowed.exists("testOptAllowedLabels"));
498  assert(!psetAllowed.exists("testOptAllowedLabelsUntracked"));
499  }
500 
501  auto pluginPSet = ps.getParameter<edm::ParameterSet>("plugin");
502  pluginHelper_ = AnotherIntFactory::get()->create(pluginPSet.getParameter<std::string>("type"), pluginPSet);
503 
504  auto plugin1PSet = ps.getParameter<edm::ParameterSet>("plugin1");
505  pluginHelper1_ = AnotherIntFactory::get()->create(plugin1PSet.getParameter<std::string>("type"), plugin1PSet);
506 
507  std::vector<edm::ParameterSet> vpset2 = ps.getParameter<std::vector<edm::ParameterSet>>("plugin2");
508  for (auto const& pset2 : vpset2) {
509  pluginHelpers2_.emplace_back(AnotherIntFactory::get()->create(pset2.getParameter<std::string>("type"), pset2));
510  }
511 
512  std::vector<edm::ParameterSet> vpset3 = ps.getParameter<std::vector<edm::ParameterSet>>("plugin3");
513  for (auto const& pset3 : vpset3) {
514  pluginHelpers3_.emplace_back(AnotherIntFactory::get()->create(pset3.getParameter<std::string>("type"), pset3));
515  }
516 
517  auto plugin4PSet = ps.getParameter<edm::ParameterSet>("plugin4");
518  pluginHelper4_ = AnotherIntFactory::get()->create(plugin4PSet.getParameter<std::string>("type"), plugin4PSet);
519 
520  std::vector<edm::ParameterSet> vpset5 = ps.getParameter<std::vector<edm::ParameterSet>>("plugin5");
521  for (auto const& pset5 : vpset5) {
522  pluginHelpers5_.emplace_back(AnotherIntFactory::get()->create(pset5.getParameter<std::string>("type"), pset5));
523  }
524 
525  produces<ThingCollection>();
526  }
527 
529  // This serves no purpose, I just put it here so the module does something
530  // Probably could just make this method do nothing and it would not
531  // affect the test.
532  auto result = std::make_unique<ThingCollection>(); //Empty
533  e.put(std::move(result));
534  }
535 
536  namespace {
539 
540  // Try to exercise the description code by adding all different
541  // types of parameters with a large range of values. Also
542  // nested ParameterSets and vectors of them at the end.
543 
544  iDesc.addOptionalUntracked<bool>("testingAutoGeneratedCfi", true);
545 
547  pn = iDesc.add<int>("p_int", p_int);
548  pn->setComment(
549  "A big integer. I am trying to test the wrapping of comments in"
550  " the printed output by putting in a long comment to see if it gets"
551  " wrapped OK. The comment should get indented to the second column"
552  " indent on every line. By default newlines should be inserted between"
553  " words to make the lines fit in the terminal screen width. There is "
554  "a command line parameter that can be set to override this width to "
555  "any desired value. If there is no terminal then it should default to "
556  "80. The logic for setting the width is in edmPluginHelp.cpp");
557 
558  iDesc.addUntracked<int>("p_int_untracked", -2147483647);
559  iDesc.addOptional<int>("p_int_opt", 0);
560  iDesc.addOptionalUntracked<int>("p_int_optuntracked", 7);
561  iDesc.addOptional<int>("p_int_opt_nd");
562  iDesc.addOptionalUntracked<int>("p_int_optuntracked_nd");
563 
564  std::vector<int> vint;
565  iDesc.add<std::vector<int>>("vint1", vint);
566  vint.push_back(2147483647);
567  iDesc.add<std::vector<int>>(std::string("vint2"), vint);
568  vint.push_back(-2147483647);
569  iDesc.add<std::vector<int>>("vint3", vint);
570  vint.push_back(0);
571  iDesc.add<std::vector<int>>("vint4", vint);
572 
573  iDesc.add<unsigned>("uint1", 4294967295U);
574  iDesc.addUntracked<unsigned>("uint2", 0);
575 
576  std::vector<unsigned> vuint;
577  iDesc.add<std::vector<unsigned>>("vuint1", vuint);
578  vuint.push_back(4294967295U);
579  iDesc.add<std::vector<unsigned>>("vuint2", vuint);
580  vuint.push_back(0);
581  iDesc.add<std::vector<unsigned>>("vuint3", vuint);
582  vuint.push_back(11);
583  iDesc.add<std::vector<unsigned>>("vuint4", vuint);
584  vuint.push_back(21);
585  vuint.push_back(31);
586  vuint.push_back(41);
587  iDesc.add<std::vector<unsigned>>("vuint5", vuint);
588 
589  iDesc.add<long long>("int64v1", 9000000000000000000LL);
590  iDesc.add<long long>("int64v2", -9000000000000000000LL);
591  iDesc.add<long long>("int64v3", 0);
592 
593  std::vector<long long> vint64;
594  iDesc.add<std::vector<long long>>("vint64v1", vint64);
595  vint64.push_back(9000000000000000000LL);
596  iDesc.add<std::vector<long long>>("vint64v2", vint64);
597  vint64.push_back(-9000000000000000000LL);
598  iDesc.add<std::vector<long long>>("vint64v3", vint64);
599  vint64.push_back(0);
600  iDesc.add<std::vector<long long>>("vint64v4", vint64);
601 
602  iDesc.add<unsigned long long>("uint64v1", 18000000000000000000ULL);
603  iDesc.addUntracked<unsigned long long>("uint64v2", 0);
604 
605  std::vector<unsigned long long> vuint64;
606  iDesc.add<std::vector<unsigned long long>>("vuint64v1", vuint64);
607  vuint64.push_back(18000000000000000000ULL);
608  iDesc.add<std::vector<unsigned long long>>("vuint64v2", vuint64);
609  vuint64.push_back(0);
610  iDesc.add<std::vector<unsigned long long>>("vuint64v3", vuint64);
611  vuint64.push_back(11);
612  iDesc.add<std::vector<unsigned long long>>("vuint64v4", vuint64);
613 
614  iDesc.add<double>("doublev1", std::numeric_limits<double>::min());
615  iDesc.addUntracked<double>("doublev2", 0.0);
616  iDesc.addUntracked<double>("doublev3", 0.3);
617 
618  std::vector<double> vdouble;
619  iDesc.add<std::vector<double>>("vdoublev1", vdouble);
620  // cmsRun will fail with a value this big
621  // vdouble.push_back(std::numeric_limits<double>::max());
622  // This works though
623  vdouble.push_back(1e+300);
624  iDesc.add<std::vector<double>>("vdoublev2", vdouble);
625  vdouble.push_back(0.0);
626  iDesc.add<std::vector<double>>("vdoublev3", vdouble);
627  vdouble.push_back(11.0);
628  iDesc.add<std::vector<double>>("vdoublev4", vdouble);
629  vdouble.push_back(0.3);
630  iDesc.add<std::vector<double>>("vdoublev5", vdouble);
631 
632  iDesc.add<bool>("boolv1", true);
633  iDesc.add<bool>("boolv2", false);
634 
635  std::string test("Hello");
636  iDesc.add<std::string>("stringv1", test);
637  test.clear();
638  iDesc.add<std::string>("stringv2", test);
639 
640  std::vector<std::string> vstring;
641  iDesc.add<std::vector<std::string>>("vstringv1", vstring);
642  test = "Hello";
643  vstring.push_back(test);
644  iDesc.add<std::vector<std::string>>("vstringv2", vstring);
645  test = "World";
646  vstring.push_back(test);
647  iDesc.add<std::vector<std::string>>("vstringv3", vstring);
648  test = "";
649  vstring.push_back(test);
650  iDesc.add<std::vector<std::string>>("vstringv4", vstring);
651 
652  edm::EventID eventID(11, 0, 12);
653  iDesc.add<edm::EventID>("eventIDv1", eventID);
654  edm::EventID eventID2(101, 0, 102);
655  iDesc.add<edm::EventID>("eventIDv2", eventID2);
656  std::vector<edm::EventID> vEventID;
657  iDesc.add<std::vector<edm::EventID>>("vEventIDv1", vEventID);
658  edm::EventID eventID3(1000, 0, 1100);
659  vEventID.push_back(eventID3);
660  iDesc.add<std::vector<edm::EventID>>("vEventIDv2", vEventID);
661  edm::EventID eventID4(10000, 0, 11000);
662  vEventID.push_back(eventID4);
663  iDesc.add<std::vector<edm::EventID>>("vEventIDv3", vEventID);
664  edm::EventID eventID5(100000, 0, 110000);
665  vEventID.push_back(eventID5);
666  iDesc.add<std::vector<edm::EventID>>("vEventIDv4", vEventID);
667 
668  edm::LuminosityBlockID luminosityID(11, 12);
669  iDesc.add<edm::LuminosityBlockID>("luminosityIDv1", luminosityID);
670  edm::LuminosityBlockID luminosityID2(101, 102);
671  iDesc.add<edm::LuminosityBlockID>("luminosityIDv2", luminosityID2);
672 
673  std::vector<edm::LuminosityBlockID> vLuminosityBlockID;
674  iDesc.add<std::vector<edm::LuminosityBlockID>>("vLuminosityBlockIDv1", vLuminosityBlockID);
675  edm::LuminosityBlockID luminosityID3(1000, 1100);
676  vLuminosityBlockID.push_back(luminosityID3);
677  iDesc.add<std::vector<edm::LuminosityBlockID>>("vLuminosityBlockIDv2", vLuminosityBlockID);
678  edm::LuminosityBlockID luminosityID4(10000, 11000);
679  vLuminosityBlockID.push_back(luminosityID4);
680  iDesc.add<std::vector<edm::LuminosityBlockID>>("vLuminosityBlockIDv3", vLuminosityBlockID);
681  edm::LuminosityBlockID luminosityID5(100000, 110000);
682  vLuminosityBlockID.push_back(luminosityID5);
683  iDesc.add<std::vector<edm::LuminosityBlockID>>("vLuminosityBlockIDv4", vLuminosityBlockID);
684 
686  iDesc.add<edm::LuminosityBlockRange>("lumiRangev1", lumiRange);
687  edm::LuminosityBlockRange lumiRange2(3, 4, 1000, 1000);
688  iDesc.add<edm::LuminosityBlockRange>("lumiRangev2", lumiRange2);
689 
690  std::vector<edm::LuminosityBlockRange> vLumiRange;
691  iDesc.add<std::vector<edm::LuminosityBlockRange>>("vLumiRangev1", vLumiRange);
692  vLumiRange.push_back(lumiRange);
693  iDesc.add<std::vector<edm::LuminosityBlockRange>>("vLumiRangev2", vLumiRange);
694  vLumiRange.push_back(lumiRange2);
695  iDesc.add<std::vector<edm::LuminosityBlockRange>>("vLumiRangev3", vLumiRange);
696 
697  edm::EventRange eventRange(1, 0, 1, 8, 0, 8);
698  iDesc.add<edm::EventRange>("eventRangev1", eventRange);
699  edm::EventRange eventRange2(3, 0, 4, 1001, 0, 1002);
700  iDesc.add<edm::EventRange>("eventRangev2", eventRange2);
701 
702  std::vector<edm::EventRange> vEventRange;
703  iDesc.add<std::vector<edm::EventRange>>("vEventRangev1", vEventRange);
704  vEventRange.push_back(eventRange);
705  iDesc.add<std::vector<edm::EventRange>>("vEventRangev2", vEventRange);
706  vEventRange.push_back(eventRange2);
707  iDesc.add<std::vector<edm::EventRange>>("vEventRangev3", vEventRange);
708 
709  edm::InputTag inputTag("One", "Two", "Three");
710  iDesc.add<edm::InputTag>("inputTagv1", inputTag);
711  edm::InputTag inputTag2("One", "Two");
712  iDesc.add<edm::InputTag>("inputTagv2", inputTag2);
713  edm::InputTag inputTag3("One");
714  iDesc.add<edm::InputTag>("inputTagv3", inputTag3);
715  edm::InputTag inputTag4("One", "", "Three");
716  iDesc.add<edm::InputTag>("inputTagv4", inputTag4);
717 
718  std::vector<edm::InputTag> vInputTag;
719  iDesc.add<std::vector<edm::InputTag>>("vInputTagv1", vInputTag);
720  vInputTag.push_back(inputTag);
721  iDesc.add<std::vector<edm::InputTag>>("vInputTagv2", vInputTag);
722  vInputTag.push_back(inputTag2);
723  iDesc.add<std::vector<edm::InputTag>>("vInputTagv3", vInputTag);
724  vInputTag.push_back(inputTag3);
725  iDesc.add<std::vector<edm::InputTag>>("vInputTagv4", vInputTag);
726  vInputTag.push_back(inputTag4);
727  iDesc.add<std::vector<edm::InputTag>>("vInputTagv5", vInputTag);
728 
729  edm::ESInputTag esinputTag("One", "Two");
730  iDesc.add<edm::ESInputTag>("esinputTagv1", esinputTag);
731  edm::ESInputTag esinputTag2("One", "");
732  iDesc.add<edm::ESInputTag>("esinputTagv2", esinputTag2);
733  edm::ESInputTag esinputTag3("", "Two");
734  iDesc.add<edm::ESInputTag>("esinputTagv3", esinputTag3);
735 
736  std::vector<edm::ESInputTag> vESInputTag;
737  iDesc.add<std::vector<edm::ESInputTag>>("vESInputTagv1", vESInputTag);
738  vESInputTag.push_back(esinputTag);
739  iDesc.add<std::vector<edm::ESInputTag>>("vESInputTagv2", vESInputTag);
740  vESInputTag.push_back(esinputTag2);
741  iDesc.add<std::vector<edm::ESInputTag>>("vESInputTagv3", vESInputTag);
742  vESInputTag.push_back(esinputTag3);
743  iDesc.add<std::vector<edm::ESInputTag>>("vESInputTagv4", vESInputTag);
744 
745  // For purposes of the test, this just needs to point to any file
746  // that exists.
747  edm::FileInPath fileInPath("FWCore/Integration/plugins/ProducerWithPSetDesc.cc");
748  iDesc.add<edm::FileInPath>("fileInPath", fileInPath);
749 
750  edm::EmptyGroupDescription emptyGroup;
751  iDesc.addNode(emptyGroup);
752 
754  bar.add<unsigned int>("Drinks", 5);
755  bar.addUntracked<unsigned int>("uDrinks", 5);
756  bar.addOptional<unsigned int>("oDrinks", 5);
757  bar.addOptionalUntracked<unsigned int>("ouDrinks", 5);
758  iDesc.add("bar", bar);
759 
760  edm::ParameterDescription<edm::ParameterSetDescription> test101("test101", bar, true);
761  iDesc.addOptionalNode(test101, false);
762 
764  barx.add<unsigned int>("Drinks", 5);
765  barx.addUntracked<unsigned int>("uDrinks", 5);
766  barx.addOptional<unsigned int>("oDrinks", 5);
767  barx.addOptionalUntracked<unsigned int>("ouDrinks", 5);
768  barx.addOptional<unsigned int>("ndoDrinks");
769  barx.addOptionalUntracked<unsigned int>("ndouDrinks");
770 
772  "test102", edm::ParameterSetDescription(), true);
773  iDesc.addOptionalNode(test102, false);
774 
776  iDesc.addOptionalNode(test103, false);
777 
778  std::vector<edm::ParameterSet> defaultVPSet104;
779  defaultVPSet104.push_back(edm::ParameterSet());
781  std::string("test104"), barx, false, defaultVPSet104);
782  iDesc.addNode(test104);
783 
784  std::vector<edm::ParameterSet> defaultVPSet105;
786  std::string("test105"), barx, false, defaultVPSet105);
787  iDesc.addNode(test105);
788 
789  double d1 = 0.1;
790  double d2 = 0.2;
791  double d3 = 0.3;
792  iDesc.addNode(edm::ParameterDescription<double>("test1", d1, true));
793  iDesc.addOptionalNode(edm::ParameterDescription<double>("test2", d2, true), true);
794  // The value in the second argument is not used in this case
795  iDesc.addOptionalNode(edm::ParameterDescription<double>("test3", d3, true), false);
796 
797  iDesc.addOptionalNode(edm::ParameterDescription<std::string>("testA", "fooA", true) and
798  edm::ParameterDescription<int>("testB", 100, true) &&
799  edm::ParameterDescription<int>("testC", 101, true),
800  true);
801 
802  iDesc.ifValueOptional(edm::ParameterDescription<int>("oiswitch", 1, true),
803  0 >> edm::ParameterDescription<int>("oivalue", 100, true) or
804  1 >> (edm::ParameterDescription<double>("oivalue1", 101.0, true) and
805  edm::ParameterDescription<double>("oivalue2", 101.0, true)) or
806  2 >> edm::ParameterDescription<std::string>("oivalue", "102", true),
807  true);
808 
809  edm::ParameterSetDescription deeplyNested;
810 
811  bool case0 = true;
812  bool case1 = false;
813  deeplyNested.ifValue(edm::ParameterDescription<bool>("bswitch", false, true),
814  case0 >> edm::ParameterDescription<int>("bvalue", 100, true) or
815  case1 >> (edm::ParameterDescription<double>("bvalue1", 101.0, true) and
816  edm::ParameterDescription<double>("bvalue2", 101.0, true)));
817  deeplyNested.ifValue(edm::ParameterDescription<int>("iswitch", 1, true),
818  0 >> edm::ParameterDescription<int>("ivalue", 100, true) or
819  1 >> (edm::ParameterDescription<double>("ivalue1", 101.0, true) and
820  edm::ParameterDescription<double>("ivalue2", 101.0, false)) or
821  2 >> edm::ParameterDescription<std::string>("ivalue", "102", true));
822  deeplyNested.ifValue(edm::ParameterDescription<std::string>("sswitch", std::string("1"), true),
823  std::string("0") >> edm::ParameterDescription<int>("svalue", 100, true) or
824  "1" >> (edm::ParameterDescription<double>("svalue1", 101.0, true) and
825  edm::ParameterDescription<double>("svalue2", 101.0, true)) or
826  "2" >> edm::ParameterDescription<std::string>("svalue", "102", true));
827 
828  deeplyNested.ifValueOptional(edm::ParameterDescription<int>("ndiswitch", 1, true),
829  0 >> edm::ParameterDescription<int>("ndivalue", 100, true) or
830  1 >> (edm::ParameterDescription<double>("ndivalue1", 101.0, true) and
831  edm::ParameterDescription<double>("ndivalue2", 101.0, true)) or
832  2 >> edm::ParameterDescription<std::string>("ndivalue", "102", true),
833  false);
834 
835  deeplyNested.add<int>("testint", 1000);
836 
837  barx.add("testDeeplyNested", deeplyNested);
838 
839  iDesc.add("testDeeplyNested2", deeplyNested);
840 
842  validator.add<int>("xvalue", 7);
843  std::vector<edm::ParameterSet> vDefaults;
844  edm::ParameterSet vDefaults0;
845  vDefaults.push_back(vDefaults0);
846  edm::ParameterSet vDefaults1;
847  vDefaults1.addParameter<int>("xvalue", 100);
848  vDefaults.push_back(vDefaults1);
849  barx.addVPSet("anotherVPSet", validator, vDefaults);
850 
851  std::vector<edm::ParameterSet> defaultVPSet;
852 
853  edm::ParameterSet psetInVector1;
854  psetInVector1.addParameter<unsigned int>("oDrinks", 11U);
855  defaultVPSet.push_back(psetInVector1);
856 
857  edm::ParameterSet psetInVector2;
858  psetInVector2.addParameter<unsigned int>("oDrinks", 11U);
859  psetInVector2.addUntrackedParameter<unsigned int>("ouDrinks", 11U);
860  psetInVector2.addUntrackedParameter<unsigned int>("ndouDrinks", 11U);
861 
862  std::vector<edm::ParameterSet> anotherDefaultVPSet;
863  anotherDefaultVPSet.push_back(edm::ParameterSet());
864  edm::ParameterSet anotherParameterSet;
865  anotherParameterSet.addParameter<int>("xvalue", 17);
866  anotherDefaultVPSet.push_back(anotherParameterSet);
867  psetInVector2.addParameter<std::vector<edm::ParameterSet>>("anotherVPSet", anotherDefaultVPSet);
868 
869  edm::ParameterSet defaultForDeeplyNested;
870  defaultForDeeplyNested.addParameter<int>("testint", 2);
871  psetInVector2.addParameter<edm::ParameterSet>("testDeeplyNested", defaultForDeeplyNested);
872 
873  defaultVPSet.push_back(psetInVector2);
874 
875  iDesc.addVPSet("bars", barx, defaultVPSet);
876 
877  // Alternate way to add a ParameterSetDescription
878  edm::ParameterDescriptionBase* parDescription;
879  parDescription = iDesc.addOptional("subpset", edm::ParameterSetDescription());
880  edm::ParameterSetDescription* subPsetDescription = parDescription->parameterSetDescription();
881 
882  subPsetDescription->add<int>("xvalue", 11);
883  subPsetDescription->addUntracked<edm::ParameterSetDescription>(std::string("bar"), bar);
884 
885  // -----------------------------------------------
886 
888  wildcardPset.addOptional<unsigned>("p_uint_opt", 0);
889  wildcardPset.addWildcard<int>("*");
890  pn = wildcardPset.addWildcardUntracked<double>(std::string("*"));
891  pn->setComment("A comment for a wildcard parameter");
892 
893  std::unique_ptr<edm::ParameterDescriptionNode> wnode =
894  std::make_unique<edm::ParameterWildcard<edm::ParameterSetDescription>>("*", edm::RequireExactlyOne, true);
895  wildcardPset.addOptionalNode(std::move(wnode), false);
896 
898  wSet1.add<unsigned int>("Drinks", 5);
899 
900  std::unique_ptr<edm::ParameterDescriptionNode> wnode2 =
901  std::make_unique<edm::ParameterWildcard<edm::ParameterSetDescription>>(
902  "*", edm::RequireAtLeastOne, true, wSet1);
903  wildcardPset.addOptionalNode(std::move(wnode2), false);
904 
905  std::unique_ptr<edm::ParameterDescriptionNode> wnode3 =
906  std::make_unique<edm::ParameterWildcard<std::vector<edm::ParameterSet>>>("*", edm::RequireExactlyOne, true);
907  wildcardPset.addOptionalNode(std::move(wnode3), false);
908 
909  wSet1.add<unsigned int>("Drinks2", 11);
910 
911  std::unique_ptr<edm::ParameterDescriptionNode> wnode4 =
912  std::make_unique<edm::ParameterWildcard<std::vector<edm::ParameterSet>>>(
913  "*", edm::RequireAtLeastOne, true, wSet1);
914  wildcardPset.addOptionalNode(std::move(wnode4), false);
915 
916  iDesc.add("wildcardPset", wildcardPset);
917 
918  // ---------------------------------------------
919 
920  std::vector<int> testIntVector;
921  testIntVector.push_back(21);
922  testIntVector.push_back(22);
924  pn = switchPset.ifValue(edm::ParameterDescription<int>("iswitch", 1, true),
925  0 >> edm::ParameterDescription<std::vector<int>>("ivalue", testIntVector, true) or
926  1 >> (edm::ParameterDescription<double>("ivalue1", 101.0, true) and
927  edm::ParameterDescription<double>("ivalue2", 101.0, true)) or
928  2 >> edm::ParameterDescription<std::string>("ivalue", "102", true));
929  pn->setComment("Comment for a ParameterSwitch");
930 
931  switchPset
932  .ifValue(edm::ParameterDescription<bool>("addTeVRefits", true, true),
933  true >> (edm::ParameterDescription<edm::InputTag>("pickySrc", edm::InputTag(), true) and
935  false >> edm::EmptyGroupDescription())
936  ->setComment("If TeV refits are added, their sources need to be specified");
937 
938  iDesc.add("switchPset", switchPset);
939 
940  // -----------------------------------------------
941 
943  xorPset.addNode(edm::ParameterDescription<std::string>("name", "11", true) xor
944  edm::ParameterDescription<unsigned int>("name", 11U, true));
945 
946  xorPset.addNode(edm::ParameterDescription<std::string>("name1", "11", true) xor
947  edm::ParameterDescription<unsigned int>("name1", 11U, true));
948 
949  xorPset.addOptionalNode(edm::ParameterDescription<std::string>("name2", "11", true) xor
950  edm::ParameterDescription<unsigned int>("name2", 11U, true),
951  false);
952 
953  xorPset.addNode(edm::ParameterDescription<std::string>("name3", "11", true) xor
954  edm::ParameterDescription<unsigned int>("name4", 11U, true) xor test101 xor test103);
955 
956  iDesc.add("xorPset", xorPset);
957 
958  // -----------------------------------------
959 
961 
962  orPset.addNode(edm::ParameterDescription<std::string>("x1", "11", true) or
964 
965  orPset.addNode(edm::ParameterDescription<std::string>("y1", "11", true) or
967 
968  orPset.addOptionalNode(edm::ParameterDescription<std::string>("z1", "11", true) or
969  edm::ParameterDescription<unsigned int>("z2", 11U, true) or test101 or test103,
970  false);
971 
972  iDesc.add("orPset", orPset);
973 
974  // ------------------------------------------------
975 
977 
978  andPset.addNode(edm::ParameterDescription<std::string>("x1", "11", true) and
980 
981  andPset.addNode(edm::ParameterDescription<std::string>("y1", "11", true) and
983 
984  andPset.addNode(edm::ParameterDescription<std::string>("z1", "11", true) and
986 
987  andPset.addOptionalNode(edm::ParameterDescription<std::string>("a1", "11", true) and
989  false);
990 
991  andPset.addOptionalNode((edm::ParameterDescription<std::string>("b1", "11", true) and
992  edm::ParameterDescription<unsigned int>("b2", 11U, true)) and
993  edm::ParameterDescription<unsigned int>("b3", 11U, true) and
994  (edm::ParameterDescription<unsigned int>("b4", 11U, true) and
995  (edm::ParameterDescription<unsigned int>("b5", 11U, true) and
997  true);
998 
999  iDesc.add("andPset", andPset);
1000 
1001  // --------------------------------------
1002 
1004 
1005  ifExistsPset.ifExists(edm::ParameterDescription<unsigned int>("x1", 11U, true),
1006  edm::ParameterDescription<std::string>("x2", "11", true));
1007 
1008  ifExistsPset.ifExistsOptional(edm::ParameterDescription<unsigned int>("y1", 11U, true),
1009  edm::ParameterDescription<std::string>("y2", "11", true),
1010  false);
1011 
1012  ifExistsPset.ifExists(edm::ParameterDescription<unsigned int>("z1", 11U, true),
1013  edm::ParameterDescription<std::string>("z2", "11", true));
1014 
1015  iDesc.add("ifExistsPset", ifExistsPset);
1016 
1017  // ------------------------------------------
1018 
1020 
1021  allowedLabelsPset.addOptional<int>("p_int_opt", 0);
1022  allowedLabelsPset.labelsFrom<int>("testAllowedLabels");
1023  allowedLabelsPset.labelsFromUntracked<unsigned>(std::string("testAllowedLabelsUntracked"));
1024  allowedLabelsPset.labelsFromOptional<int>("testOptAllowedLabels", false);
1025  allowedLabelsPset.labelsFromOptionalUntracked<unsigned>(std::string("testOptAllowedLabelsUntracked"), false);
1026  allowedLabelsPset.labelsFromOptionalUntracked<edm::ParameterSetDescription>(
1027  std::string("testWithSet"), true, bar);
1028 
1029  allowedLabelsPset.labelsFromOptionalUntracked<std::vector<edm::ParameterSet>>(
1030  std::string("testWithVectorOfSets"), true, bar);
1031 
1032  iDesc.add("allowedLabelsPset", allowedLabelsPset);
1033 
1034  edm::ParameterSetDescription noDefaultPset3;
1035 
1036  noDefaultPset3.addOptional<int>(std::string("noDefault1"));
1037  noDefaultPset3.addOptional<std::vector<int>>("noDefault2");
1038  noDefaultPset3.addOptional<unsigned>("noDefault3");
1039  noDefaultPset3.addOptional<std::vector<unsigned>>("noDefault4");
1040  noDefaultPset3.addOptional<long long>("noDefault5");
1041  noDefaultPset3.addOptional<std::vector<long long>>("noDefault6");
1042  noDefaultPset3.addOptional<unsigned long long>("noDefault7");
1043  noDefaultPset3.addOptional<std::vector<unsigned long long>>("noDefault8");
1044  noDefaultPset3.addOptional<double>("noDefault9");
1045  noDefaultPset3.addOptional<std::vector<double>>("noDefault10");
1046  noDefaultPset3.addOptional<bool>("noDefault11");
1047  noDefaultPset3.addOptional<std::string>("noDefault12");
1048  noDefaultPset3.addOptional<std::vector<std::string>>("noDefault13");
1049  noDefaultPset3.addOptional<edm::EventID>("noDefault14");
1050  noDefaultPset3.addOptional<std::vector<edm::EventID>>("noDefault15");
1051  noDefaultPset3.addOptional<edm::LuminosityBlockID>("noDefault16");
1052  noDefaultPset3.addOptional<std::vector<edm::LuminosityBlockID>>("noDefault17");
1053  noDefaultPset3.addOptional<edm::InputTag>("noDefault18");
1054  noDefaultPset3.addOptional<std::vector<edm::InputTag>>("noDefault19");
1055  noDefaultPset3.addOptional<edm::FileInPath>("noDefault20");
1056  noDefaultPset3.addOptional<edm::LuminosityBlockRange>("noDefault21");
1057  noDefaultPset3.addOptional<std::vector<edm::LuminosityBlockRange>>("noDefault22");
1058  noDefaultPset3.addOptional<edm::EventRange>("noDefault23");
1059  noDefaultPset3.addOptional<std::vector<edm::EventRange>>("noDefault24");
1060 
1061  iDesc.add("noDefaultPset3", noDefaultPset3);
1062 
1063  edm::ParameterSetDescription noDefaultPset4;
1064 
1065  noDefaultPset4.addOptionalUntracked<int>(std::string("noDefault1"));
1066  noDefaultPset4.addOptionalUntracked<std::vector<int>>("noDefault2");
1067  noDefaultPset4.addOptionalUntracked<unsigned>("noDefault3");
1068  noDefaultPset4.addOptionalUntracked<std::vector<unsigned>>("noDefault4");
1069  noDefaultPset4.addOptionalUntracked<long long>("noDefault5");
1070  noDefaultPset4.addOptionalUntracked<std::vector<long long>>("noDefault6");
1071  noDefaultPset4.addOptionalUntracked<unsigned long long>("noDefault7");
1072  noDefaultPset4.addOptionalUntracked<std::vector<unsigned long long>>("noDefault8");
1073  noDefaultPset4.addOptionalUntracked<double>("noDefault9");
1074  noDefaultPset4.addOptionalUntracked<std::vector<double>>("noDefault10");
1075  noDefaultPset4.addOptionalUntracked<bool>("noDefault11");
1076  noDefaultPset4.addOptionalUntracked<std::string>("noDefault12");
1077  noDefaultPset4.addOptionalUntracked<std::vector<std::string>>("noDefault13");
1078  noDefaultPset4.addOptionalUntracked<edm::EventID>("noDefault14");
1079  noDefaultPset4.addOptionalUntracked<std::vector<edm::EventID>>("noDefault15");
1080  noDefaultPset4.addOptionalUntracked<edm::LuminosityBlockID>("noDefault16");
1081  noDefaultPset4.addOptionalUntracked<std::vector<edm::LuminosityBlockID>>("noDefault17");
1082  noDefaultPset4.addOptionalUntracked<edm::InputTag>("noDefault18");
1083  noDefaultPset4.addOptionalUntracked<std::vector<edm::InputTag>>("noDefault19");
1084  noDefaultPset4.addOptionalUntracked<edm::FileInPath>("noDefault20");
1085  noDefaultPset4.addOptionalUntracked<edm::LuminosityBlockRange>("noDefault21");
1086  noDefaultPset4.addOptionalUntracked<std::vector<edm::LuminosityBlockRange>>("noDefault22");
1087  noDefaultPset4.addOptionalUntracked<edm::EventRange>("noDefault23");
1088  noDefaultPset4.addOptionalUntracked<std::vector<edm::EventRange>>("noDefault24");
1089 
1090  iDesc.add("noDefaultPset4", noDefaultPset4);
1091 
1092  edm::ParameterSetDescription pluginDesc;
1093  pluginDesc.addNode(edm::PluginDescription<AnotherIntFactory>("type", "edmtestAnotherValueMaker", true));
1094  iDesc.add<edm::ParameterSetDescription>("plugin", pluginDesc);
1095 
1096  edm::ParameterSetDescription pluginDesc1;
1097  pluginDesc1.addNode(edm::PluginDescription<AnotherIntFactory>("type", true));
1098  iDesc.add<edm::ParameterSetDescription>("plugin1", pluginDesc1);
1099 
1100  edm::ParameterSetDescription pluginDesc2;
1101  pluginDesc2.addNode(edm::PluginDescription<AnotherIntFactory>("type", true));
1102  std::vector<edm::ParameterSet> vDefaultsPlugins2;
1103  iDesc.addVPSet("plugin2", pluginDesc2, vDefaultsPlugins2);
1104 
1105  edm::ParameterSetDescription pluginDesc3;
1106  pluginDesc3.addNode(edm::PluginDescription<AnotherIntFactory>("type", true));
1107  std::vector<edm::ParameterSet> vDefaultsPlugins3;
1108  edm::ParameterSet vpsetDefault0;
1109  vpsetDefault0.addParameter<std::string>("type", "edmtestAnotherOneMaker");
1110  vDefaultsPlugins3.push_back(vpsetDefault0);
1111  edm::ParameterSet vpsetDefault1;
1112  vpsetDefault1.addParameter<std::string>("type", "edmtestAnotherValueMaker");
1113  vpsetDefault1.addParameter<int>("value", 11);
1114  vDefaultsPlugins3.push_back(vpsetDefault1);
1115 
1116  iDesc.addVPSet("plugin3", pluginDesc3, vDefaultsPlugins3);
1117 
1118  edm::ParameterSetDescription pluginDesc4;
1119  pluginDesc4.addNode(
1120  edm::PluginDescription<AnotherIntFactory>("type", "edmtestAnotherMakerWithRecursivePlugin", true));
1121  iDesc.add<edm::ParameterSetDescription>("plugin4", pluginDesc4);
1122 
1123  edm::ParameterSetDescription pluginDesc5;
1124  pluginDesc5.addNode(
1125  edm::PluginDescription<AnotherIntFactory>("type", "edmtestAnotherMakerWithRecursivePlugin", true));
1126  std::vector<edm::ParameterSet> vDefaultsPlugins5;
1127  {
1128  edm::ParameterSet vpsetDefault0;
1129  vpsetDefault0.addParameter<std::string>("type", "edmtestAnotherOneMaker");
1130  vDefaultsPlugins5.push_back(vpsetDefault0);
1131  edm::ParameterSet vpsetDefault1;
1132  vpsetDefault1.addParameter<std::string>("type", "edmtestAnotherMakerWithRecursivePlugin");
1133  vpsetDefault1.addParameter<int>("value", 11);
1134  vDefaultsPlugins5.push_back(vpsetDefault1);
1135  }
1136  iDesc.addVPSet("plugin5", pluginDesc5, vDefaultsPlugins5);
1137  return iDesc;
1138  }
1139  } // namespace
1141  auto iDesc = description(2147483647);
1142  // ------------------------------------------
1143 
1144  descriptions.add("testProducerWithPsetDesc", iDesc);
1145 
1146  // ------------------------------------------
1147 
1149  iDesc1.setAllowAnything();
1150  iDesc1.setComment("A comment for a ParameterSetDescription");
1151 
1152  edm::ParameterSetDescription noDefaultPset1;
1153 
1154  noDefaultPset1.add<int>(std::string("noDefault1"));
1155  noDefaultPset1.add<std::vector<int>>("noDefault2");
1156  noDefaultPset1.add<unsigned>("noDefault3");
1157  noDefaultPset1.add<std::vector<unsigned>>("noDefault4");
1158  noDefaultPset1.add<long long>("noDefault5");
1159  noDefaultPset1.add<std::vector<long long>>("noDefault6");
1160  noDefaultPset1.add<unsigned long long>("noDefault7");
1161  noDefaultPset1.add<std::vector<unsigned long long>>("noDefault8");
1162  noDefaultPset1.add<double>("noDefault9");
1163  noDefaultPset1.add<std::vector<double>>("noDefault10");
1164  noDefaultPset1.add<bool>("noDefault11");
1165  noDefaultPset1.add<std::string>("noDefault12");
1166  noDefaultPset1.add<std::vector<std::string>>("noDefault13");
1167  noDefaultPset1.add<edm::EventID>("noDefault14");
1168  noDefaultPset1.add<std::vector<edm::EventID>>("noDefault15");
1169  noDefaultPset1.add<edm::LuminosityBlockID>("noDefault16");
1170  noDefaultPset1.add<std::vector<edm::LuminosityBlockID>>("noDefault17");
1171  noDefaultPset1.add<edm::InputTag>("noDefault18");
1172  noDefaultPset1.add<std::vector<edm::InputTag>>("noDefault19");
1173  noDefaultPset1.add<edm::FileInPath>("noDefault20");
1174  noDefaultPset1.add<edm::LuminosityBlockRange>("noDefault21");
1175  noDefaultPset1.add<std::vector<edm::LuminosityBlockRange>>("noDefault22");
1176  noDefaultPset1.add<edm::EventRange>("noDefault23");
1177  noDefaultPset1.add<std::vector<edm::EventRange>>("noDefault24");
1178 
1179  iDesc1.add("noDefaultPset1", noDefaultPset1);
1180 
1181  edm::ParameterSetDescription noDefaultPset2;
1182 
1183  noDefaultPset2.addUntracked<int>(std::string("noDefault1"));
1184  noDefaultPset2.addUntracked<std::vector<int>>("noDefault2");
1185  noDefaultPset2.addUntracked<unsigned>("noDefault3");
1186  noDefaultPset2.addUntracked<std::vector<unsigned>>("noDefault4");
1187  noDefaultPset2.addUntracked<long long>("noDefault5");
1188  noDefaultPset2.addUntracked<std::vector<long long>>("noDefault6");
1189  noDefaultPset2.addUntracked<unsigned long long>("noDefault7");
1190  noDefaultPset2.addUntracked<std::vector<unsigned long long>>("noDefault8");
1191  noDefaultPset2.addUntracked<double>("noDefault9");
1192  noDefaultPset2.addUntracked<std::vector<double>>("noDefault10");
1193  noDefaultPset2.addUntracked<bool>("noDefault11");
1194  noDefaultPset2.addUntracked<std::string>("noDefault12");
1195  noDefaultPset2.addUntracked<std::vector<std::string>>("noDefault13");
1196  noDefaultPset2.addUntracked<edm::EventID>("noDefault14");
1197  noDefaultPset2.addUntracked<std::vector<edm::EventID>>("noDefault15");
1198  noDefaultPset2.addUntracked<edm::LuminosityBlockID>("noDefault16");
1199  noDefaultPset2.addUntracked<std::vector<edm::LuminosityBlockID>>("noDefault17");
1200  noDefaultPset2.addUntracked<edm::InputTag>("noDefault18");
1201  noDefaultPset2.addUntracked<std::vector<edm::InputTag>>("noDefault19");
1202  noDefaultPset2.addUntracked<edm::FileInPath>("noDefault20");
1203  noDefaultPset2.addUntracked<edm::LuminosityBlockRange>("noDefault21");
1204  noDefaultPset2.addUntracked<std::vector<edm::LuminosityBlockRange>>("noDefault22");
1205  noDefaultPset2.addUntracked<edm::EventRange>("noDefault23");
1206  noDefaultPset2.addUntracked<std::vector<edm::EventRange>>("noDefault24");
1207 
1208  iDesc1.add("noDefaultPset2", noDefaultPset2);
1209  descriptions.add("testLabel1", iDesc1);
1210 
1211  // ------------------------------------------
1212 
1213  descriptions.addDefault(description(2));
1214 
1215  // ------------------------------------------
1216 
1217  descriptions.addWithDefaultLabel(description(3));
1218  }
1219 } // namespace edmtest
void setComment(std::string const &value)
ParameterDescriptionNode * ifValue(ParameterDescription< T > const &switchParameter, std::unique_ptr< ParameterDescriptionCases< T >> cases)
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
EventID startEventID() const
Definition: EventRange.h:46
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
std::unique_ptr< AnotherIntMakerBase > pluginHelper_
ParameterDescriptionBase * addVPSet(U const &iLabel, ParameterSetDescription const &validator, std::vector< ParameterSet > const &defaults)
std::vector< std::unique_ptr< AnotherIntMakerBase > > pluginHelpers5_
#define EDM_REGISTER_VALIDATED_PLUGINFACTORY(_factory_, _category_)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
def create(alignables, pedeDump, additionalData, outputFile, config)
vector< string > vstring
Definition: ExoticaDQM.cc:7
void setAllowAnything()
allow any parameter label/value pairs
AnotherOneMaker(edm::ParameterSet const &)
std::unique_ptr< AnotherIntMakerBase > pluginHelper1_
virtual ~AnotherIntMakerBase()=default
bool exists(std::string const &parameterName) const
checks if a parameter exists
EventID endEventID() const
Definition: EventRange.h:47
ParameterSet const & getParameterSet(std::string const &) const
virtual ParameterSetDescription const * parameterSetDescription() const
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
std::vector< std::unique_ptr< AnotherIntMakerBase > > pluginHelpers2_
virtual int value() const =0
AnotherValueMaker(edm::ParameterSet const &iPSet)
assert(be >=bs)
double vint[400]
std::unique_ptr< AnotherIntMakerBase > recursivePluginHelper_
LuminosityBlockID endLumiID() const
T getUntrackedParameter(std::string const &, T const &) const
void setComment(std::string const &value)
AnotherMakerWithRecursivePlugin(edm::ParameterSet const &iPSet)
void addDefault(ParameterSetDescription const &psetDescription)
#define DEFINE_EDM_VALIDATED_PLUGIN(factory, type, name)
static void fillPSetDescription(edm::ParameterSetDescription &)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:136
ParameterDescriptionNode * addOptionalNode(ParameterDescriptionNode const &node, bool writeToCfi)
static void fillPSetDescription(edm::ParameterSetDescription &iDesc)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::vector< double > vdouble
std::unique_ptr< AnotherIntMakerBase > pluginHelper4_
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:193
ParameterDescriptionNode * ifValueOptional(ParameterDescription< T > const &switchParameter, std::unique_ptr< ParameterDescriptionCases< T >> cases, bool writeToCfi)
void produce(edm::StreamID, edm::Event &e, edm::EventSetup const &c) const override
void add(std::string const &label, ParameterSetDescription const &psetDescription)
ProducerWithPSetDesc(edm::ParameterSet const &ps)
VParameterSet const & getParameterSetVector(std::string const &name) const
std::vector< std::unique_ptr< AnotherIntMakerBase > > pluginHelpers3_
ParameterDescriptionBase * addOptionalUntracked(U const &iLabel, T const &value)
#define get
LuminosityBlockID startLumiID() const
static constexpr float d1
static void fillPSetDescription(edm::ParameterSetDescription &iDesc)
def move(src, dest)
Definition: eostools.py:511
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)