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 
538 
539  // Try to exercise the description code by adding all different
540  // types of parameters with a large range of values. Also
541  // nested ParameterSets and vectors of them at the end.
542 
543  iDesc.addOptionalUntracked<bool>("testingAutoGeneratedCfi", true);
544 
546  pn = iDesc.add<int>("p_int", 2147483647);
547  pn->setComment(
548  "A big integer. I am trying to test the wrapping of comments in"
549  " the printed output by putting in a long comment to see if it gets"
550  " wrapped OK. The comment should get indented to the second column"
551  " indent on every line. By default newlines should be inserted between"
552  " words to make the lines fit in the terminal screen width. There is "
553  "a command line parameter that can be set to override this width to "
554  "any desired value. If there is no terminal then it should default to "
555  "80. The logic for setting the width is in edmPluginHelp.cpp");
556 
557  iDesc.addUntracked<int>("p_int_untracked", -2147483647);
558  iDesc.addOptional<int>("p_int_opt", 0);
559  iDesc.addOptionalUntracked<int>("p_int_optuntracked", 7);
560  iDesc.addOptional<int>("p_int_opt_nd");
561  iDesc.addOptionalUntracked<int>("p_int_optuntracked_nd");
562 
563  std::vector<int> vint;
564  iDesc.add<std::vector<int>>("vint1", vint);
565  vint.push_back(2147483647);
566  iDesc.add<std::vector<int>>(std::string("vint2"), vint);
567  vint.push_back(-2147483647);
568  iDesc.add<std::vector<int>>("vint3", vint);
569  vint.push_back(0);
570  iDesc.add<std::vector<int>>("vint4", vint);
571 
572  iDesc.add<unsigned>("uint1", 4294967295U);
573  iDesc.addUntracked<unsigned>("uint2", 0);
574 
575  std::vector<unsigned> vuint;
576  iDesc.add<std::vector<unsigned>>("vuint1", vuint);
577  vuint.push_back(4294967295U);
578  iDesc.add<std::vector<unsigned>>("vuint2", vuint);
579  vuint.push_back(0);
580  iDesc.add<std::vector<unsigned>>("vuint3", vuint);
581  vuint.push_back(11);
582  iDesc.add<std::vector<unsigned>>("vuint4", vuint);
583  vuint.push_back(21);
584  vuint.push_back(31);
585  vuint.push_back(41);
586  iDesc.add<std::vector<unsigned>>("vuint5", vuint);
587 
588  iDesc.add<long long>("int64v1", 9000000000000000000LL);
589  iDesc.add<long long>("int64v2", -9000000000000000000LL);
590  iDesc.add<long long>("int64v3", 0);
591 
592  std::vector<long long> vint64;
593  iDesc.add<std::vector<long long>>("vint64v1", vint64);
594  vint64.push_back(9000000000000000000LL);
595  iDesc.add<std::vector<long long>>("vint64v2", vint64);
596  vint64.push_back(-9000000000000000000LL);
597  iDesc.add<std::vector<long long>>("vint64v3", vint64);
598  vint64.push_back(0);
599  iDesc.add<std::vector<long long>>("vint64v4", vint64);
600 
601  iDesc.add<unsigned long long>("uint64v1", 18000000000000000000ULL);
602  iDesc.addUntracked<unsigned long long>("uint64v2", 0);
603 
604  std::vector<unsigned long long> vuint64;
605  iDesc.add<std::vector<unsigned long long>>("vuint64v1", vuint64);
606  vuint64.push_back(18000000000000000000ULL);
607  iDesc.add<std::vector<unsigned long long>>("vuint64v2", vuint64);
608  vuint64.push_back(0);
609  iDesc.add<std::vector<unsigned long long>>("vuint64v3", vuint64);
610  vuint64.push_back(11);
611  iDesc.add<std::vector<unsigned long long>>("vuint64v4", vuint64);
612 
613  iDesc.add<double>("doublev1", std::numeric_limits<double>::min());
614  iDesc.addUntracked<double>("doublev2", 0.0);
615  iDesc.addUntracked<double>("doublev3", 0.3);
616 
617  std::vector<double> vdouble;
618  iDesc.add<std::vector<double>>("vdoublev1", vdouble);
619  // cmsRun will fail with a value this big
620  // vdouble.push_back(std::numeric_limits<double>::max());
621  // This works though
622  vdouble.push_back(1e+300);
623  iDesc.add<std::vector<double>>("vdoublev2", vdouble);
624  vdouble.push_back(0.0);
625  iDesc.add<std::vector<double>>("vdoublev3", vdouble);
626  vdouble.push_back(11.0);
627  iDesc.add<std::vector<double>>("vdoublev4", vdouble);
628  vdouble.push_back(0.3);
629  iDesc.add<std::vector<double>>("vdoublev5", vdouble);
630 
631  iDesc.add<bool>("boolv1", true);
632  iDesc.add<bool>("boolv2", false);
633 
634  std::string test("Hello");
635  iDesc.add<std::string>("stringv1", test);
636  test.clear();
637  iDesc.add<std::string>("stringv2", test);
638 
639  std::vector<std::string> vstring;
640  iDesc.add<std::vector<std::string>>("vstringv1", vstring);
641  test = "Hello";
642  vstring.push_back(test);
643  iDesc.add<std::vector<std::string>>("vstringv2", vstring);
644  test = "World";
645  vstring.push_back(test);
646  iDesc.add<std::vector<std::string>>("vstringv3", vstring);
647  test = "";
648  vstring.push_back(test);
649  iDesc.add<std::vector<std::string>>("vstringv4", vstring);
650 
651  edm::EventID eventID(11, 0, 12);
652  iDesc.add<edm::EventID>("eventIDv1", eventID);
653  edm::EventID eventID2(101, 0, 102);
654  iDesc.add<edm::EventID>("eventIDv2", eventID2);
655  std::vector<edm::EventID> vEventID;
656  iDesc.add<std::vector<edm::EventID>>("vEventIDv1", vEventID);
657  edm::EventID eventID3(1000, 0, 1100);
658  vEventID.push_back(eventID3);
659  iDesc.add<std::vector<edm::EventID>>("vEventIDv2", vEventID);
660  edm::EventID eventID4(10000, 0, 11000);
661  vEventID.push_back(eventID4);
662  iDesc.add<std::vector<edm::EventID>>("vEventIDv3", vEventID);
663  edm::EventID eventID5(100000, 0, 110000);
664  vEventID.push_back(eventID5);
665  iDesc.add<std::vector<edm::EventID>>("vEventIDv4", vEventID);
666 
667  edm::LuminosityBlockID luminosityID(11, 12);
668  iDesc.add<edm::LuminosityBlockID>("luminosityIDv1", luminosityID);
669  edm::LuminosityBlockID luminosityID2(101, 102);
670  iDesc.add<edm::LuminosityBlockID>("luminosityIDv2", luminosityID2);
671 
672  std::vector<edm::LuminosityBlockID> vLuminosityBlockID;
673  iDesc.add<std::vector<edm::LuminosityBlockID>>("vLuminosityBlockIDv1", vLuminosityBlockID);
674  edm::LuminosityBlockID luminosityID3(1000, 1100);
675  vLuminosityBlockID.push_back(luminosityID3);
676  iDesc.add<std::vector<edm::LuminosityBlockID>>("vLuminosityBlockIDv2", vLuminosityBlockID);
677  edm::LuminosityBlockID luminosityID4(10000, 11000);
678  vLuminosityBlockID.push_back(luminosityID4);
679  iDesc.add<std::vector<edm::LuminosityBlockID>>("vLuminosityBlockIDv3", vLuminosityBlockID);
680  edm::LuminosityBlockID luminosityID5(100000, 110000);
681  vLuminosityBlockID.push_back(luminosityID5);
682  iDesc.add<std::vector<edm::LuminosityBlockID>>("vLuminosityBlockIDv4", vLuminosityBlockID);
683 
685  iDesc.add<edm::LuminosityBlockRange>("lumiRangev1", lumiRange);
686  edm::LuminosityBlockRange lumiRange2(3, 4, 1000, 1000);
687  iDesc.add<edm::LuminosityBlockRange>("lumiRangev2", lumiRange2);
688 
689  std::vector<edm::LuminosityBlockRange> vLumiRange;
690  iDesc.add<std::vector<edm::LuminosityBlockRange>>("vLumiRangev1", vLumiRange);
691  vLumiRange.push_back(lumiRange);
692  iDesc.add<std::vector<edm::LuminosityBlockRange>>("vLumiRangev2", vLumiRange);
693  vLumiRange.push_back(lumiRange2);
694  iDesc.add<std::vector<edm::LuminosityBlockRange>>("vLumiRangev3", vLumiRange);
695 
696  edm::EventRange eventRange(1, 0, 1, 8, 0, 8);
697  iDesc.add<edm::EventRange>("eventRangev1", eventRange);
698  edm::EventRange eventRange2(3, 0, 4, 1001, 0, 1002);
699  iDesc.add<edm::EventRange>("eventRangev2", eventRange2);
700 
701  std::vector<edm::EventRange> vEventRange;
702  iDesc.add<std::vector<edm::EventRange>>("vEventRangev1", vEventRange);
703  vEventRange.push_back(eventRange);
704  iDesc.add<std::vector<edm::EventRange>>("vEventRangev2", vEventRange);
705  vEventRange.push_back(eventRange2);
706  iDesc.add<std::vector<edm::EventRange>>("vEventRangev3", vEventRange);
707 
708  edm::InputTag inputTag("One", "Two", "Three");
709  iDesc.add<edm::InputTag>("inputTagv1", inputTag);
710  edm::InputTag inputTag2("One", "Two");
711  iDesc.add<edm::InputTag>("inputTagv2", inputTag2);
712  edm::InputTag inputTag3("One");
713  iDesc.add<edm::InputTag>("inputTagv3", inputTag3);
714  edm::InputTag inputTag4("One", "", "Three");
715  iDesc.add<edm::InputTag>("inputTagv4", inputTag4);
716 
717  std::vector<edm::InputTag> vInputTag;
718  iDesc.add<std::vector<edm::InputTag>>("vInputTagv1", vInputTag);
719  vInputTag.push_back(inputTag);
720  iDesc.add<std::vector<edm::InputTag>>("vInputTagv2", vInputTag);
721  vInputTag.push_back(inputTag2);
722  iDesc.add<std::vector<edm::InputTag>>("vInputTagv3", vInputTag);
723  vInputTag.push_back(inputTag3);
724  iDesc.add<std::vector<edm::InputTag>>("vInputTagv4", vInputTag);
725  vInputTag.push_back(inputTag4);
726  iDesc.add<std::vector<edm::InputTag>>("vInputTagv5", vInputTag);
727 
728  edm::ESInputTag esinputTag("One", "Two");
729  iDesc.add<edm::ESInputTag>("esinputTagv1", esinputTag);
730  edm::ESInputTag esinputTag2("One", "");
731  iDesc.add<edm::ESInputTag>("esinputTagv2", esinputTag2);
732  edm::ESInputTag esinputTag3("", "Two");
733  iDesc.add<edm::ESInputTag>("esinputTagv3", esinputTag3);
734 
735  std::vector<edm::ESInputTag> vESInputTag;
736  iDesc.add<std::vector<edm::ESInputTag>>("vESInputTagv1", vESInputTag);
737  vESInputTag.push_back(esinputTag);
738  iDesc.add<std::vector<edm::ESInputTag>>("vESInputTagv2", vESInputTag);
739  vESInputTag.push_back(esinputTag2);
740  iDesc.add<std::vector<edm::ESInputTag>>("vESInputTagv3", vESInputTag);
741  vESInputTag.push_back(esinputTag3);
742  iDesc.add<std::vector<edm::ESInputTag>>("vESInputTagv4", vESInputTag);
743 
744  // For purposes of the test, this just needs to point to any file
745  // that exists.
746  edm::FileInPath fileInPath("FWCore/Integration/plugins/ProducerWithPSetDesc.cc");
747  iDesc.add<edm::FileInPath>("fileInPath", fileInPath);
748 
749  edm::EmptyGroupDescription emptyGroup;
750  iDesc.addNode(emptyGroup);
751 
753  bar.add<unsigned int>("Drinks", 5);
754  bar.addUntracked<unsigned int>("uDrinks", 5);
755  bar.addOptional<unsigned int>("oDrinks", 5);
756  bar.addOptionalUntracked<unsigned int>("ouDrinks", 5);
757  iDesc.add("bar", bar);
758 
759  edm::ParameterDescription<edm::ParameterSetDescription> test101("test101", bar, true);
760  iDesc.addOptionalNode(test101, false);
761 
763  barx.add<unsigned int>("Drinks", 5);
764  barx.addUntracked<unsigned int>("uDrinks", 5);
765  barx.addOptional<unsigned int>("oDrinks", 5);
766  barx.addOptionalUntracked<unsigned int>("ouDrinks", 5);
767  barx.addOptional<unsigned int>("ndoDrinks");
768  barx.addOptionalUntracked<unsigned int>("ndouDrinks");
769 
771  iDesc.addOptionalNode(test102, false);
772 
774  iDesc.addOptionalNode(test103, false);
775 
776  std::vector<edm::ParameterSet> defaultVPSet104;
777  defaultVPSet104.push_back(edm::ParameterSet());
779  std::string("test104"), barx, false, defaultVPSet104);
780  iDesc.addNode(test104);
781 
782  std::vector<edm::ParameterSet> defaultVPSet105;
784  std::string("test105"), barx, false, defaultVPSet105);
785  iDesc.addNode(test105);
786 
787  double d1 = 0.1;
788  double d2 = 0.2;
789  double d3 = 0.3;
790  iDesc.addNode(edm::ParameterDescription<double>("test1", d1, true));
791  iDesc.addOptionalNode(edm::ParameterDescription<double>("test2", d2, true), true);
792  // The value in the second argument is not used in this case
793  iDesc.addOptionalNode(edm::ParameterDescription<double>("test3", d3, true), false);
794 
795  iDesc.addOptionalNode(edm::ParameterDescription<std::string>("testA", "fooA", true) and
796  edm::ParameterDescription<int>("testB", 100, true) &&
797  edm::ParameterDescription<int>("testC", 101, true),
798  true);
799 
800  iDesc.ifValueOptional(edm::ParameterDescription<int>("oiswitch", 1, true),
801  0 >> edm::ParameterDescription<int>("oivalue", 100, true) or
802  1 >> (edm::ParameterDescription<double>("oivalue1", 101.0, true) and
803  edm::ParameterDescription<double>("oivalue2", 101.0, true)) or
804  2 >> edm::ParameterDescription<std::string>("oivalue", "102", true),
805  true);
806 
807  edm::ParameterSetDescription deeplyNested;
808 
809  bool case0 = true;
810  bool case1 = false;
811  deeplyNested.ifValue(edm::ParameterDescription<bool>("bswitch", false, true),
812  case0 >> edm::ParameterDescription<int>("bvalue", 100, true) or
813  case1 >> (edm::ParameterDescription<double>("bvalue1", 101.0, true) and
814  edm::ParameterDescription<double>("bvalue2", 101.0, true)));
815  deeplyNested.ifValue(edm::ParameterDescription<int>("iswitch", 1, true),
816  0 >> edm::ParameterDescription<int>("ivalue", 100, true) or
817  1 >> (edm::ParameterDescription<double>("ivalue1", 101.0, true) and
818  edm::ParameterDescription<double>("ivalue2", 101.0, false)) or
819  2 >> edm::ParameterDescription<std::string>("ivalue", "102", true));
820  deeplyNested.ifValue(edm::ParameterDescription<std::string>("sswitch", std::string("1"), true),
821  std::string("0") >> edm::ParameterDescription<int>("svalue", 100, true) or
822  "1" >> (edm::ParameterDescription<double>("svalue1", 101.0, true) and
823  edm::ParameterDescription<double>("svalue2", 101.0, true)) or
824  "2" >> edm::ParameterDescription<std::string>("svalue", "102", true));
825 
826  deeplyNested.ifValueOptional(edm::ParameterDescription<int>("ndiswitch", 1, true),
827  0 >> edm::ParameterDescription<int>("ndivalue", 100, true) or
828  1 >> (edm::ParameterDescription<double>("ndivalue1", 101.0, true) and
829  edm::ParameterDescription<double>("ndivalue2", 101.0, true)) or
830  2 >> edm::ParameterDescription<std::string>("ndivalue", "102", true),
831  false);
832 
833  deeplyNested.add<int>("testint", 1000);
834 
835  barx.add("testDeeplyNested", deeplyNested);
836 
837  iDesc.add("testDeeplyNested2", deeplyNested);
838 
840  validator.add<int>("xvalue", 7);
841  std::vector<edm::ParameterSet> vDefaults;
842  edm::ParameterSet vDefaults0;
843  vDefaults.push_back(vDefaults0);
844  edm::ParameterSet vDefaults1;
845  vDefaults1.addParameter<int>("xvalue", 100);
846  vDefaults.push_back(vDefaults1);
847  barx.addVPSet("anotherVPSet", validator, vDefaults);
848 
849  std::vector<edm::ParameterSet> defaultVPSet;
850 
851  edm::ParameterSet psetInVector1;
852  psetInVector1.addParameter<unsigned int>("oDrinks", 11U);
853  defaultVPSet.push_back(psetInVector1);
854 
855  edm::ParameterSet psetInVector2;
856  psetInVector2.addParameter<unsigned int>("oDrinks", 11U);
857  psetInVector2.addUntrackedParameter<unsigned int>("ouDrinks", 11U);
858  psetInVector2.addUntrackedParameter<unsigned int>("ndouDrinks", 11U);
859 
860  std::vector<edm::ParameterSet> anotherDefaultVPSet;
861  anotherDefaultVPSet.push_back(edm::ParameterSet());
862  edm::ParameterSet anotherParameterSet;
863  anotherParameterSet.addParameter<int>("xvalue", 17);
864  anotherDefaultVPSet.push_back(anotherParameterSet);
865  psetInVector2.addParameter<std::vector<edm::ParameterSet>>("anotherVPSet", anotherDefaultVPSet);
866 
867  edm::ParameterSet defaultForDeeplyNested;
868  defaultForDeeplyNested.addParameter<int>("testint", 2);
869  psetInVector2.addParameter<edm::ParameterSet>("testDeeplyNested", defaultForDeeplyNested);
870 
871  defaultVPSet.push_back(psetInVector2);
872 
873  iDesc.addVPSet("bars", barx, defaultVPSet);
874 
875  // Alternate way to add a ParameterSetDescription
876  edm::ParameterDescriptionBase* parDescription;
877  parDescription = iDesc.addOptional("subpset", edm::ParameterSetDescription());
878  edm::ParameterSetDescription* subPsetDescription = parDescription->parameterSetDescription();
879 
880  subPsetDescription->add<int>("xvalue", 11);
881  subPsetDescription->addUntracked<edm::ParameterSetDescription>(std::string("bar"), bar);
882 
883  // -----------------------------------------------
884 
886  wildcardPset.addOptional<unsigned>("p_uint_opt", 0);
887  wildcardPset.addWildcard<int>("*");
888  pn = wildcardPset.addWildcardUntracked<double>(std::string("*"));
889  pn->setComment("A comment for a wildcard parameter");
890 
891  std::unique_ptr<edm::ParameterDescriptionNode> wnode =
892  std::make_unique<edm::ParameterWildcard<edm::ParameterSetDescription>>("*", edm::RequireExactlyOne, true);
893  wildcardPset.addOptionalNode(std::move(wnode), false);
894 
896  wSet1.add<unsigned int>("Drinks", 5);
897 
898  std::unique_ptr<edm::ParameterDescriptionNode> wnode2 =
899  std::make_unique<edm::ParameterWildcard<edm::ParameterSetDescription>>(
900  "*", edm::RequireAtLeastOne, true, wSet1);
901  wildcardPset.addOptionalNode(std::move(wnode2), false);
902 
903  std::unique_ptr<edm::ParameterDescriptionNode> wnode3 =
904  std::make_unique<edm::ParameterWildcard<std::vector<edm::ParameterSet>>>("*", edm::RequireExactlyOne, true);
905  wildcardPset.addOptionalNode(std::move(wnode3), false);
906 
907  wSet1.add<unsigned int>("Drinks2", 11);
908 
909  std::unique_ptr<edm::ParameterDescriptionNode> wnode4 =
910  std::make_unique<edm::ParameterWildcard<std::vector<edm::ParameterSet>>>(
911  "*", edm::RequireAtLeastOne, true, wSet1);
912  wildcardPset.addOptionalNode(std::move(wnode4), false);
913 
914  iDesc.add("wildcardPset", wildcardPset);
915 
916  // ---------------------------------------------
917 
918  std::vector<int> testIntVector;
919  testIntVector.push_back(21);
920  testIntVector.push_back(22);
922  pn = switchPset.ifValue(edm::ParameterDescription<int>("iswitch", 1, true),
923  0 >> edm::ParameterDescription<std::vector<int>>("ivalue", testIntVector, true) or
924  1 >> (edm::ParameterDescription<double>("ivalue1", 101.0, true) and
925  edm::ParameterDescription<double>("ivalue2", 101.0, true)) or
926  2 >> edm::ParameterDescription<std::string>("ivalue", "102", true));
927  pn->setComment("Comment for a ParameterSwitch");
928 
929  switchPset
930  .ifValue(edm::ParameterDescription<bool>("addTeVRefits", true, true),
931  true >> (edm::ParameterDescription<edm::InputTag>("pickySrc", edm::InputTag(), true) and
933  false >> edm::EmptyGroupDescription())
934  ->setComment("If TeV refits are added, their sources need to be specified");
935 
936  iDesc.add("switchPset", switchPset);
937 
938  // -----------------------------------------------
939 
941  xorPset.addNode(edm::ParameterDescription<std::string>("name", "11", true) xor
942  edm::ParameterDescription<unsigned int>("name", 11U, true));
943 
944  xorPset.addNode(edm::ParameterDescription<std::string>("name1", "11", true) xor
945  edm::ParameterDescription<unsigned int>("name1", 11U, true));
946 
947  xorPset.addOptionalNode(edm::ParameterDescription<std::string>("name2", "11", true) xor
948  edm::ParameterDescription<unsigned int>("name2", 11U, true),
949  false);
950 
951  xorPset.addNode(edm::ParameterDescription<std::string>("name3", "11", true) xor
952  edm::ParameterDescription<unsigned int>("name4", 11U, true) xor test101 xor test103);
953 
954  iDesc.add("xorPset", xorPset);
955 
956  // -----------------------------------------
957 
959 
960  orPset.addNode(edm::ParameterDescription<std::string>("x1", "11", true) or
962 
963  orPset.addNode(edm::ParameterDescription<std::string>("y1", "11", true) or
965 
966  orPset.addOptionalNode(edm::ParameterDescription<std::string>("z1", "11", true) or
967  edm::ParameterDescription<unsigned int>("z2", 11U, true) or test101 or test103,
968  false);
969 
970  iDesc.add("orPset", orPset);
971 
972  // ------------------------------------------------
973 
975 
976  andPset.addNode(edm::ParameterDescription<std::string>("x1", "11", true) and
978 
979  andPset.addNode(edm::ParameterDescription<std::string>("y1", "11", true) and
981 
982  andPset.addNode(edm::ParameterDescription<std::string>("z1", "11", true) and
984 
985  andPset.addOptionalNode(edm::ParameterDescription<std::string>("a1", "11", true) and
987  false);
988 
989  andPset.addOptionalNode((edm::ParameterDescription<std::string>("b1", "11", true) and
990  edm::ParameterDescription<unsigned int>("b2", 11U, true)) and
991  edm::ParameterDescription<unsigned int>("b3", 11U, true) and
992  (edm::ParameterDescription<unsigned int>("b4", 11U, true) and
993  (edm::ParameterDescription<unsigned int>("b5", 11U, true) and
995  true);
996 
997  iDesc.add("andPset", andPset);
998 
999  // --------------------------------------
1000 
1002 
1003  ifExistsPset.ifExists(edm::ParameterDescription<unsigned int>("x1", 11U, true),
1004  edm::ParameterDescription<std::string>("x2", "11", true));
1005 
1006  ifExistsPset.ifExistsOptional(edm::ParameterDescription<unsigned int>("y1", 11U, true),
1007  edm::ParameterDescription<std::string>("y2", "11", true),
1008  false);
1009 
1010  ifExistsPset.ifExists(edm::ParameterDescription<unsigned int>("z1", 11U, true),
1011  edm::ParameterDescription<std::string>("z2", "11", true));
1012 
1013  iDesc.add("ifExistsPset", ifExistsPset);
1014 
1015  // ------------------------------------------
1016 
1018 
1019  allowedLabelsPset.addOptional<int>("p_int_opt", 0);
1020  allowedLabelsPset.labelsFrom<int>("testAllowedLabels");
1021  allowedLabelsPset.labelsFromUntracked<unsigned>(std::string("testAllowedLabelsUntracked"));
1022  allowedLabelsPset.labelsFromOptional<int>("testOptAllowedLabels", false);
1023  allowedLabelsPset.labelsFromOptionalUntracked<unsigned>(std::string("testOptAllowedLabelsUntracked"), false);
1024  allowedLabelsPset.labelsFromOptionalUntracked<edm::ParameterSetDescription>(std::string("testWithSet"), true, bar);
1025 
1026  allowedLabelsPset.labelsFromOptionalUntracked<std::vector<edm::ParameterSet>>(
1027  std::string("testWithVectorOfSets"), true, bar);
1028 
1029  iDesc.add("allowedLabelsPset", allowedLabelsPset);
1030 
1031  edm::ParameterSetDescription noDefaultPset3;
1032 
1033  noDefaultPset3.addOptional<int>(std::string("noDefault1"));
1034  noDefaultPset3.addOptional<std::vector<int>>("noDefault2");
1035  noDefaultPset3.addOptional<unsigned>("noDefault3");
1036  noDefaultPset3.addOptional<std::vector<unsigned>>("noDefault4");
1037  noDefaultPset3.addOptional<long long>("noDefault5");
1038  noDefaultPset3.addOptional<std::vector<long long>>("noDefault6");
1039  noDefaultPset3.addOptional<unsigned long long>("noDefault7");
1040  noDefaultPset3.addOptional<std::vector<unsigned long long>>("noDefault8");
1041  noDefaultPset3.addOptional<double>("noDefault9");
1042  noDefaultPset3.addOptional<std::vector<double>>("noDefault10");
1043  noDefaultPset3.addOptional<bool>("noDefault11");
1044  noDefaultPset3.addOptional<std::string>("noDefault12");
1045  noDefaultPset3.addOptional<std::vector<std::string>>("noDefault13");
1046  noDefaultPset3.addOptional<edm::EventID>("noDefault14");
1047  noDefaultPset3.addOptional<std::vector<edm::EventID>>("noDefault15");
1048  noDefaultPset3.addOptional<edm::LuminosityBlockID>("noDefault16");
1049  noDefaultPset3.addOptional<std::vector<edm::LuminosityBlockID>>("noDefault17");
1050  noDefaultPset3.addOptional<edm::InputTag>("noDefault18");
1051  noDefaultPset3.addOptional<std::vector<edm::InputTag>>("noDefault19");
1052  noDefaultPset3.addOptional<edm::FileInPath>("noDefault20");
1053  noDefaultPset3.addOptional<edm::LuminosityBlockRange>("noDefault21");
1054  noDefaultPset3.addOptional<std::vector<edm::LuminosityBlockRange>>("noDefault22");
1055  noDefaultPset3.addOptional<edm::EventRange>("noDefault23");
1056  noDefaultPset3.addOptional<std::vector<edm::EventRange>>("noDefault24");
1057 
1058  iDesc.add("noDefaultPset3", noDefaultPset3);
1059 
1060  edm::ParameterSetDescription noDefaultPset4;
1061 
1062  noDefaultPset4.addOptionalUntracked<int>(std::string("noDefault1"));
1063  noDefaultPset4.addOptionalUntracked<std::vector<int>>("noDefault2");
1064  noDefaultPset4.addOptionalUntracked<unsigned>("noDefault3");
1065  noDefaultPset4.addOptionalUntracked<std::vector<unsigned>>("noDefault4");
1066  noDefaultPset4.addOptionalUntracked<long long>("noDefault5");
1067  noDefaultPset4.addOptionalUntracked<std::vector<long long>>("noDefault6");
1068  noDefaultPset4.addOptionalUntracked<unsigned long long>("noDefault7");
1069  noDefaultPset4.addOptionalUntracked<std::vector<unsigned long long>>("noDefault8");
1070  noDefaultPset4.addOptionalUntracked<double>("noDefault9");
1071  noDefaultPset4.addOptionalUntracked<std::vector<double>>("noDefault10");
1072  noDefaultPset4.addOptionalUntracked<bool>("noDefault11");
1073  noDefaultPset4.addOptionalUntracked<std::string>("noDefault12");
1074  noDefaultPset4.addOptionalUntracked<std::vector<std::string>>("noDefault13");
1075  noDefaultPset4.addOptionalUntracked<edm::EventID>("noDefault14");
1076  noDefaultPset4.addOptionalUntracked<std::vector<edm::EventID>>("noDefault15");
1077  noDefaultPset4.addOptionalUntracked<edm::LuminosityBlockID>("noDefault16");
1078  noDefaultPset4.addOptionalUntracked<std::vector<edm::LuminosityBlockID>>("noDefault17");
1079  noDefaultPset4.addOptionalUntracked<edm::InputTag>("noDefault18");
1080  noDefaultPset4.addOptionalUntracked<std::vector<edm::InputTag>>("noDefault19");
1081  noDefaultPset4.addOptionalUntracked<edm::FileInPath>("noDefault20");
1082  noDefaultPset4.addOptionalUntracked<edm::LuminosityBlockRange>("noDefault21");
1083  noDefaultPset4.addOptionalUntracked<std::vector<edm::LuminosityBlockRange>>("noDefault22");
1084  noDefaultPset4.addOptionalUntracked<edm::EventRange>("noDefault23");
1085  noDefaultPset4.addOptionalUntracked<std::vector<edm::EventRange>>("noDefault24");
1086 
1087  iDesc.add("noDefaultPset4", noDefaultPset4);
1088 
1089  edm::ParameterSetDescription pluginDesc;
1090  pluginDesc.addNode(edm::PluginDescription<AnotherIntFactory>("type", "edmtestAnotherValueMaker", true));
1091  iDesc.add<edm::ParameterSetDescription>("plugin", pluginDesc);
1092 
1093  edm::ParameterSetDescription pluginDesc1;
1094  pluginDesc1.addNode(edm::PluginDescription<AnotherIntFactory>("type", true));
1095  iDesc.add<edm::ParameterSetDescription>("plugin1", pluginDesc1);
1096 
1097  edm::ParameterSetDescription pluginDesc2;
1098  pluginDesc2.addNode(edm::PluginDescription<AnotherIntFactory>("type", true));
1099  std::vector<edm::ParameterSet> vDefaultsPlugins2;
1100  iDesc.addVPSet("plugin2", pluginDesc2, vDefaultsPlugins2);
1101 
1102  edm::ParameterSetDescription pluginDesc3;
1103  pluginDesc3.addNode(edm::PluginDescription<AnotherIntFactory>("type", true));
1104  std::vector<edm::ParameterSet> vDefaultsPlugins3;
1105  edm::ParameterSet vpsetDefault0;
1106  vpsetDefault0.addParameter<std::string>("type", "edmtestAnotherOneMaker");
1107  vDefaultsPlugins3.push_back(vpsetDefault0);
1108  edm::ParameterSet vpsetDefault1;
1109  vpsetDefault1.addParameter<std::string>("type", "edmtestAnotherValueMaker");
1110  vpsetDefault1.addParameter<int>("value", 11);
1111  vDefaultsPlugins3.push_back(vpsetDefault1);
1112 
1113  iDesc.addVPSet("plugin3", pluginDesc3, vDefaultsPlugins3);
1114 
1115  edm::ParameterSetDescription pluginDesc4;
1116  pluginDesc4.addNode(
1117  edm::PluginDescription<AnotherIntFactory>("type", "edmtestAnotherMakerWithRecursivePlugin", true));
1118  iDesc.add<edm::ParameterSetDescription>("plugin4", pluginDesc4);
1119 
1120  edm::ParameterSetDescription pluginDesc5;
1121  pluginDesc5.addNode(
1122  edm::PluginDescription<AnotherIntFactory>("type", "edmtestAnotherMakerWithRecursivePlugin", true));
1123  std::vector<edm::ParameterSet> vDefaultsPlugins5;
1124  {
1125  edm::ParameterSet vpsetDefault0;
1126  vpsetDefault0.addParameter<std::string>("type", "edmtestAnotherOneMaker");
1127  vDefaultsPlugins5.push_back(vpsetDefault0);
1128  edm::ParameterSet vpsetDefault1;
1129  vpsetDefault1.addParameter<std::string>("type", "edmtestAnotherMakerWithRecursivePlugin");
1130  vpsetDefault1.addParameter<int>("value", 11);
1131  vDefaultsPlugins5.push_back(vpsetDefault1);
1132  }
1133  iDesc.addVPSet("plugin5", pluginDesc5, vDefaultsPlugins5);
1134 
1135  // ------------------------------------------
1136 
1137  descriptions.add("testProducerWithPsetDesc", iDesc);
1138 
1139  // ------------------------------------------
1140 
1142  iDesc1.add<int>("p_int", 1);
1143  iDesc1.setAllowAnything();
1144  iDesc1.setComment("A comment for a ParameterSetDescription");
1145 
1146  edm::ParameterSetDescription noDefaultPset1;
1147 
1148  noDefaultPset1.add<int>(std::string("noDefault1"));
1149  noDefaultPset1.add<std::vector<int>>("noDefault2");
1150  noDefaultPset1.add<unsigned>("noDefault3");
1151  noDefaultPset1.add<std::vector<unsigned>>("noDefault4");
1152  noDefaultPset1.add<long long>("noDefault5");
1153  noDefaultPset1.add<std::vector<long long>>("noDefault6");
1154  noDefaultPset1.add<unsigned long long>("noDefault7");
1155  noDefaultPset1.add<std::vector<unsigned long long>>("noDefault8");
1156  noDefaultPset1.add<double>("noDefault9");
1157  noDefaultPset1.add<std::vector<double>>("noDefault10");
1158  noDefaultPset1.add<bool>("noDefault11");
1159  noDefaultPset1.add<std::string>("noDefault12");
1160  noDefaultPset1.add<std::vector<std::string>>("noDefault13");
1161  noDefaultPset1.add<edm::EventID>("noDefault14");
1162  noDefaultPset1.add<std::vector<edm::EventID>>("noDefault15");
1163  noDefaultPset1.add<edm::LuminosityBlockID>("noDefault16");
1164  noDefaultPset1.add<std::vector<edm::LuminosityBlockID>>("noDefault17");
1165  noDefaultPset1.add<edm::InputTag>("noDefault18");
1166  noDefaultPset1.add<std::vector<edm::InputTag>>("noDefault19");
1167  noDefaultPset1.add<edm::FileInPath>("noDefault20");
1168  noDefaultPset1.add<edm::LuminosityBlockRange>("noDefault21");
1169  noDefaultPset1.add<std::vector<edm::LuminosityBlockRange>>("noDefault22");
1170  noDefaultPset1.add<edm::EventRange>("noDefault23");
1171  noDefaultPset1.add<std::vector<edm::EventRange>>("noDefault24");
1172 
1173  iDesc1.add("noDefaultPset1", noDefaultPset1);
1174 
1175  edm::ParameterSetDescription noDefaultPset2;
1176 
1177  noDefaultPset2.addUntracked<int>(std::string("noDefault1"));
1178  noDefaultPset2.addUntracked<std::vector<int>>("noDefault2");
1179  noDefaultPset2.addUntracked<unsigned>("noDefault3");
1180  noDefaultPset2.addUntracked<std::vector<unsigned>>("noDefault4");
1181  noDefaultPset2.addUntracked<long long>("noDefault5");
1182  noDefaultPset2.addUntracked<std::vector<long long>>("noDefault6");
1183  noDefaultPset2.addUntracked<unsigned long long>("noDefault7");
1184  noDefaultPset2.addUntracked<std::vector<unsigned long long>>("noDefault8");
1185  noDefaultPset2.addUntracked<double>("noDefault9");
1186  noDefaultPset2.addUntracked<std::vector<double>>("noDefault10");
1187  noDefaultPset2.addUntracked<bool>("noDefault11");
1188  noDefaultPset2.addUntracked<std::string>("noDefault12");
1189  noDefaultPset2.addUntracked<std::vector<std::string>>("noDefault13");
1190  noDefaultPset2.addUntracked<edm::EventID>("noDefault14");
1191  noDefaultPset2.addUntracked<std::vector<edm::EventID>>("noDefault15");
1192  noDefaultPset2.addUntracked<edm::LuminosityBlockID>("noDefault16");
1193  noDefaultPset2.addUntracked<std::vector<edm::LuminosityBlockID>>("noDefault17");
1194  noDefaultPset2.addUntracked<edm::InputTag>("noDefault18");
1195  noDefaultPset2.addUntracked<std::vector<edm::InputTag>>("noDefault19");
1196  noDefaultPset2.addUntracked<edm::FileInPath>("noDefault20");
1197  noDefaultPset2.addUntracked<edm::LuminosityBlockRange>("noDefault21");
1198  noDefaultPset2.addUntracked<std::vector<edm::LuminosityBlockRange>>("noDefault22");
1199  noDefaultPset2.addUntracked<edm::EventRange>("noDefault23");
1200  noDefaultPset2.addUntracked<std::vector<edm::EventRange>>("noDefault24");
1201 
1202  iDesc1.add("noDefaultPset2", noDefaultPset2);
1203  descriptions.add("testLabel1", iDesc1);
1204 
1205  // ------------------------------------------
1206 
1208  iDesc2.add<int>("p_int", 2);
1209  descriptions.addDefault(iDesc2);
1210 
1211  // ------------------------------------------
1212 
1214  iDesc3.add<int>("p_int", 3);
1215  descriptions.addWithDefaultLabel(iDesc3);
1216  }
1217 } // 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)