File indexing completed on 2024-05-23 03:13:11
0001 #include "ProducerWithPSetDesc.h"
0002 #include "DataFormats/TestObjects/interface/ThingCollection.h"
0003 #include "FWCore/Framework/interface/Event.h"
0004 #include "FWCore/Framework/interface/MakerMacros.h"
0005
0006 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0008 #include "FWCore/ParameterSet/interface/ParameterDescriptionBase.h"
0009 #include "FWCore/ParameterSet/interface/ParameterDescription.h"
0010 #include "FWCore/ParameterSet/interface/ParameterDescriptionNode.h"
0011 #include "FWCore/ParameterSet/interface/ParameterWildcard.h"
0012 #include "FWCore/ParameterSet/interface/EmptyGroupDescription.h"
0013 #include "DataFormats/Provenance/interface/EventRange.h"
0014 #include "DataFormats/Provenance/interface/LuminosityBlockID.h"
0015 #include "DataFormats/Provenance/interface/EventID.h"
0016 #include "FWCore/Utilities/interface/InputTag.h"
0017 #include "FWCore/Utilities/interface/FileInPath.h"
0018 #include "FWCore/ParameterSet/interface/PluginDescription.h"
0019 #include "FWCore/ParameterSet/interface/ValidatedPluginMacros.h"
0020 #include "FWCore/ParameterSet/interface/ValidatedPluginFactoryMacros.h"
0021
0022 #include <vector>
0023 #include <limits>
0024 #include <memory>
0025 #include <string>
0026 #include <iostream>
0027
0028 namespace edmtest {
0029
0030 struct AnotherIntMakerBase {
0031 virtual ~AnotherIntMakerBase() = default;
0032 virtual int value() const = 0;
0033 };
0034
0035 using AnotherIntFactory = edmplugin::PluginFactory<AnotherIntMakerBase*(edm::ParameterSet const&)>;
0036
0037 }
0038
0039 EDM_REGISTER_VALIDATED_PLUGINFACTORY(edmtest::AnotherIntFactory, "edmtestAnotherIntFactory");
0040
0041 namespace edmtest {
0042
0043 struct AnotherOneMaker : public AnotherIntMakerBase {
0044 explicit AnotherOneMaker(edm::ParameterSet const&) {}
0045 int value() const final { return 1; };
0046
0047 static void fillPSetDescription(edm::ParameterSetDescription&) {}
0048 };
0049
0050 struct AnotherValueMaker : public AnotherIntMakerBase {
0051 explicit AnotherValueMaker(edm::ParameterSet const& iPSet) : value_{iPSet.getParameter<int>("value")} {}
0052 int value() const final { return value_; };
0053
0054 static void fillPSetDescription(edm::ParameterSetDescription& iDesc) { iDesc.add<int>("value", 5); }
0055 int value_;
0056 };
0057
0058 struct AnotherMakerWithRecursivePlugin : public AnotherIntMakerBase {
0059 explicit AnotherMakerWithRecursivePlugin(edm::ParameterSet const& iPSet)
0060 : value_{iPSet.getParameter<int>("value")} {
0061 auto recursivePluginPSet = iPSet.getParameter<edm::ParameterSet>("pluginRecursive");
0062 recursivePluginHelper_ =
0063 AnotherIntFactory::get()->create(recursivePluginPSet.getParameter<std::string>("type"), recursivePluginPSet);
0064 }
0065 int value() const final { return value_; };
0066
0067 static void fillPSetDescription(edm::ParameterSetDescription& iDesc) {
0068 iDesc.add<int>("value", 5);
0069
0070 edm::ParameterSetDescription pluginDesc;
0071 pluginDesc.addNode(edm::PluginDescription<AnotherIntFactory>("type", true));
0072 iDesc.add<edm::ParameterSetDescription>("pluginRecursive", pluginDesc);
0073 }
0074
0075 std::unique_ptr<AnotherIntMakerBase> recursivePluginHelper_;
0076 int value_;
0077 };
0078
0079 }
0080 DEFINE_EDM_VALIDATED_PLUGIN(edmtest::AnotherIntFactory, edmtest::AnotherOneMaker, "edmtestAnotherOneMaker");
0081 DEFINE_EDM_VALIDATED_PLUGIN(edmtest::AnotherIntFactory, edmtest::AnotherValueMaker, "edmtestAnotherValueMaker");
0082 DEFINE_EDM_VALIDATED_PLUGIN(edmtest::AnotherIntFactory,
0083 edmtest::AnotherMakerWithRecursivePlugin,
0084 "edmtestAnotherMakerWithRecursivePlugin");
0085
0086 namespace edmtest {
0087
0088 ProducerWithPSetDesc::ProducerWithPSetDesc(edm::ParameterSet const& ps) {
0089 testingAutoGeneratedCfi = ps.getUntrackedParameter<bool>("testingAutoGeneratedCfi", true);
0090
0091 assert(ps.getParameter<int>("p_int") == 2147483647);
0092 assert(ps.getUntrackedParameter<int>("p_int_untracked") == -2147483647);
0093 if (testingAutoGeneratedCfi)
0094 assert(ps.getParameter<int>("p_int_opt") == 0);
0095 if (testingAutoGeneratedCfi) {
0096 assert(ps.getUntrackedParameter<int>("p_int_optuntracked") == 7);
0097 assert(!ps.exists("p_int_opt_nd"));
0098 assert(!ps.exists("p_int_optuntracked_nd"));
0099 } else {
0100 assert(!ps.exists("p_int_optuntracked"));
0101 assert(ps.getParameter<int>("p_int_opt_nd") == 11);
0102 assert(ps.getUntrackedParameter<int>("p_int_optuntracked_nd") == 12);
0103 }
0104
0105 std::vector<int> vint;
0106 vint = ps.getParameter<std::vector<int>>("vint1");
0107 assert(vint.empty());
0108 vint = ps.getParameter<std::vector<int>>("vint2");
0109 assert(vint[0] == 2147483647);
0110 vint = ps.getParameter<std::vector<int>>("vint3");
0111 assert(vint[0] == 2147483647);
0112 assert(vint[1] == -2147483647);
0113 std::array<int, 2> testArray = ps.getParameter<std::array<int, 2>>(std::string("vint3"));
0114 assert(testArray[0] == 2147483647);
0115 assert(testArray[1] == -2147483647);
0116 std::array<int, 2> testArray1 = ps.getParameter<std::array<int, 2>>("vint3");
0117 assert(testArray1[0] == 2147483647);
0118 assert(testArray1[1] == -2147483647);
0119 vint = ps.getParameter<std::vector<int>>("vint4");
0120 assert(vint[0] == 2147483647);
0121 assert(vint[1] == -2147483647);
0122 assert(vint[2] == 0);
0123
0124 assert(ps.getParameter<unsigned>("uint1") == 4294967295U);
0125 assert(ps.getUntrackedParameter<unsigned>("uint2") == 0);
0126
0127 std::vector<unsigned> vuint;
0128 vuint = ps.getParameter<std::vector<unsigned>>("vuint1");
0129 assert(vuint.empty());
0130 vuint = ps.getParameter<std::vector<unsigned>>("vuint2");
0131 assert(vuint[0] == 4294967295U);
0132 vuint = ps.getParameter<std::vector<unsigned>>("vuint3");
0133 assert(vuint[0] == 4294967295U);
0134 assert(vuint[1] == 0);
0135 vuint = ps.getParameter<std::vector<unsigned>>("vuint4");
0136 assert(vuint[0] == 4294967295U);
0137 assert(vuint[1] == 0);
0138 assert(vuint[2] == 11);
0139
0140 assert(ps.getParameter<long long>("int64v1") == 9000000000000000000LL);
0141 assert(ps.getParameter<long long>("int64v2") == -9000000000000000000LL);
0142 assert(ps.getParameter<long long>("int64v3") == 0);
0143
0144 std::vector<long long> vint64;
0145 vint64 = ps.getParameter<std::vector<long long>>("vint64v1");
0146 assert(vint64.empty());
0147 vint64 = ps.getParameter<std::vector<long long>>("vint64v2");
0148 assert(vint64[0] == 9000000000000000000LL);
0149 vint64 = ps.getParameter<std::vector<long long>>("vint64v3");
0150 assert(vint64[0] == 9000000000000000000LL);
0151 assert(vint64[1] == -9000000000000000000LL);
0152 vint64 = ps.getParameter<std::vector<long long>>("vint64v4");
0153 assert(vint64[0] == 9000000000000000000LL);
0154 assert(vint64[1] == -9000000000000000000LL);
0155 assert(vint64[2] == 0);
0156
0157 assert(ps.getParameter<unsigned long long>("uint64v1") == 18000000000000000000ULL);
0158 assert(ps.getUntrackedParameter<unsigned long long>("uint64v2") == 0);
0159
0160 std::vector<unsigned long long> vuint64;
0161 vuint64 = ps.getParameter<std::vector<unsigned long long>>("vuint64v1");
0162 assert(vuint64.empty());
0163 vuint64 = ps.getParameter<std::vector<unsigned long long>>("vuint64v2");
0164 assert(vuint64[0] == 18000000000000000000ULL);
0165 vuint64 = ps.getParameter<std::vector<unsigned long long>>("vuint64v3");
0166 assert(vuint64[0] == 18000000000000000000ULL);
0167 assert(vuint64[1] == 0);
0168 vuint64 = ps.getParameter<std::vector<unsigned long long>>("vuint64v4");
0169 assert(vuint64[0] == 18000000000000000000ULL);
0170 assert(vuint64[1] == 0);
0171 assert(vuint64[2] == 11);
0172
0173
0174
0175
0176 assert(ps.getUntrackedParameter<double>("doublev2") == 0.0);
0177 assert(fabs(ps.getUntrackedParameter<double>("doublev3") - 0.3) < 0.0000001);
0178
0179 std::vector<double> vdouble;
0180 vdouble = ps.getParameter<std::vector<double>>("vdoublev1");
0181 assert(vdouble.empty());
0182
0183
0184
0185 vdouble = ps.getParameter<std::vector<double>>("vdoublev2");
0186 assert(vdouble[0] == 1e+300);
0187 vdouble = ps.getParameter<std::vector<double>>("vdoublev3");
0188 assert(vdouble[0] == 1e+300);
0189 assert(vdouble[1] == 0.0);
0190 vdouble = ps.getParameter<std::vector<double>>("vdoublev4");
0191 assert(vdouble[0] == 1e+300);
0192 assert(vdouble[1] == 0.0);
0193 assert(vdouble[2] == 11.0);
0194 vdouble = ps.getParameter<std::vector<double>>("vdoublev5");
0195 assert(vdouble[0] == 1e+300);
0196 assert(vdouble[1] == 0.0);
0197 assert(vdouble[2] == 11.0);
0198 assert(fabs(vdouble[3] - 0.3) < 0.0000001);
0199
0200 assert(ps.getParameter<bool>("boolv1") == true);
0201 assert(ps.getParameter<bool>("boolv2") == false);
0202
0203 std::string test("Hello");
0204 assert(ps.getParameter<std::string>("stringv1") == test);
0205 test.clear();
0206 assert(ps.getParameter<std::string>("stringv2") == test);
0207
0208 std::vector<std::string> vstring;
0209 vstring = ps.getParameter<std::vector<std::string>>("vstringv1");
0210 assert(vstring.empty());
0211 vstring = ps.getParameter<std::vector<std::string>>("vstringv2");
0212 assert(vstring[0] == std::string("Hello"));
0213 vstring = ps.getParameter<std::vector<std::string>>("vstringv3");
0214 assert(vstring[0] == std::string("Hello"));
0215 assert(vstring[1] == std::string("World"));
0216 vstring = ps.getParameter<std::vector<std::string>>("vstringv4");
0217 assert(vstring[0] == std::string("Hello"));
0218 assert(vstring[1] == std::string("World"));
0219 assert(vstring[2] == std::string(""));
0220
0221 edm::EventID eventID1(11, 0, 12);
0222 assert(ps.getParameter<edm::EventID>("eventIDv1") == eventID1);
0223 edm::EventID eventID2(101, 0, 102);
0224 assert(ps.getParameter<edm::EventID>("eventIDv2") == eventID2);
0225
0226 std::vector<edm::EventID> vEventID;
0227 vEventID = ps.getParameter<std::vector<edm::EventID>>("vEventIDv1");
0228 assert(vEventID.empty());
0229 vEventID = ps.getParameter<std::vector<edm::EventID>>("vEventIDv2");
0230 assert(vEventID[0] == edm::EventID(1000, 0, 1100));
0231 vEventID = ps.getParameter<std::vector<edm::EventID>>("vEventIDv3");
0232 assert(vEventID[0] == edm::EventID(1000, 0, 1100));
0233 assert(vEventID[1] == edm::EventID(10000, 0, 11000));
0234 vEventID = ps.getParameter<std::vector<edm::EventID>>("vEventIDv4");
0235 assert(vEventID[0] == edm::EventID(1000, 0, 1100));
0236 assert(vEventID[1] == edm::EventID(10000, 0, 11000));
0237 assert(vEventID[2] == edm::EventID(100000, 0, 110000));
0238
0239 edm::LuminosityBlockID luminosityID1(11, 12);
0240 assert(ps.getParameter<edm::LuminosityBlockID>("luminosityIDv1") == luminosityID1);
0241 edm::LuminosityBlockID luminosityID2(101, 102);
0242 assert(ps.getParameter<edm::LuminosityBlockID>("luminosityIDv2") == luminosityID2);
0243
0244 std::vector<edm::LuminosityBlockID> vLuminosityBlockID;
0245 vLuminosityBlockID = ps.getParameter<std::vector<edm::LuminosityBlockID>>("vLuminosityBlockIDv1");
0246 assert(vLuminosityBlockID.empty());
0247 vLuminosityBlockID = ps.getParameter<std::vector<edm::LuminosityBlockID>>("vLuminosityBlockIDv2");
0248 assert(vLuminosityBlockID[0] == edm::LuminosityBlockID(1000, 1100));
0249 vLuminosityBlockID = ps.getParameter<std::vector<edm::LuminosityBlockID>>("vLuminosityBlockIDv3");
0250 assert(vLuminosityBlockID[0] == edm::LuminosityBlockID(1000, 1100));
0251 assert(vLuminosityBlockID[1] == edm::LuminosityBlockID(10000, 11000));
0252 vLuminosityBlockID = ps.getParameter<std::vector<edm::LuminosityBlockID>>("vLuminosityBlockIDv4");
0253 assert(vLuminosityBlockID[0] == edm::LuminosityBlockID(1000, 1100));
0254 assert(vLuminosityBlockID[1] == edm::LuminosityBlockID(10000, 11000));
0255 assert(vLuminosityBlockID[2] == edm::LuminosityBlockID(100000, 110000));
0256
0257 edm::LuminosityBlockRange lumiRange1(1, 1, 9, 9);
0258 assert(ps.getParameter<edm::LuminosityBlockRange>("lumiRangev1").startLumiID() == lumiRange1.startLumiID());
0259 assert(ps.getParameter<edm::LuminosityBlockRange>("lumiRangev1").endLumiID() == lumiRange1.endLumiID());
0260 edm::LuminosityBlockRange lumiRange2(3, 4, 1000, 1000);
0261 assert(ps.getParameter<edm::LuminosityBlockRange>("lumiRangev2").startLumiID() == lumiRange2.startLumiID());
0262 assert(ps.getParameter<edm::LuminosityBlockRange>("lumiRangev2").endLumiID() == lumiRange2.endLumiID());
0263
0264 std::vector<edm::LuminosityBlockRange> vLumiRange;
0265 vLumiRange = ps.getParameter<std::vector<edm::LuminosityBlockRange>>("vLumiRangev1");
0266 assert(vLumiRange.empty());
0267 vLumiRange = ps.getParameter<std::vector<edm::LuminosityBlockRange>>("vLumiRangev2");
0268 assert(vLumiRange[0].startLumiID() == lumiRange1.startLumiID());
0269 vLumiRange = ps.getParameter<std::vector<edm::LuminosityBlockRange>>("vLumiRangev3");
0270 assert(vLumiRange[0].startLumiID() == lumiRange1.startLumiID());
0271 assert(vLumiRange[1].startLumiID() == lumiRange2.startLumiID());
0272 assert(vLumiRange[1].endLumiID() == lumiRange2.endLumiID());
0273
0274 edm::EventRange eventRange1(1, 0, 1, 8, 0, 8);
0275 assert(ps.getParameter<edm::EventRange>("eventRangev1").startEventID() == eventRange1.startEventID());
0276 assert(ps.getParameter<edm::EventRange>("eventRangev1").endEventID() == eventRange1.endEventID());
0277 edm::EventRange eventRange2(3, 0, 4, 1001, 0, 1002);
0278 assert(ps.getParameter<edm::EventRange>("eventRangev2").startEventID() == eventRange2.startEventID());
0279 assert(ps.getParameter<edm::EventRange>("eventRangev2").endEventID() == eventRange2.endEventID());
0280
0281 std::vector<edm::EventRange> vEventRange;
0282 vEventRange = ps.getParameter<std::vector<edm::EventRange>>("vEventRangev1");
0283 assert(vEventRange.empty());
0284 vEventRange = ps.getParameter<std::vector<edm::EventRange>>("vEventRangev2");
0285 assert(vEventRange[0].startEventID() == eventRange1.startEventID());
0286 vEventRange = ps.getParameter<std::vector<edm::EventRange>>("vEventRangev3");
0287 assert(vEventRange[0].startEventID() == eventRange1.startEventID());
0288 assert(vEventRange[1].startEventID() == eventRange2.startEventID());
0289
0290 edm::InputTag inputTag1("One", "Two", "Three");
0291 assert(ps.getParameter<edm::InputTag>("inputTagv1") == inputTag1);
0292 edm::InputTag inputTag2("One", "Two");
0293 assert(ps.getParameter<edm::InputTag>("inputTagv2") == inputTag2);
0294 edm::InputTag inputTag3("One");
0295 assert(ps.getParameter<edm::InputTag>("inputTagv3") == inputTag3);
0296 edm::InputTag inputTag4("One", "", "Three");
0297 assert(ps.getParameter<edm::InputTag>("inputTagv4") == inputTag4);
0298
0299 std::vector<edm::InputTag> vInputTag;
0300 vInputTag = ps.getParameter<std::vector<edm::InputTag>>("vInputTagv1");
0301 assert(vInputTag.empty());
0302 vInputTag = ps.getParameter<std::vector<edm::InputTag>>("vInputTagv2");
0303 assert(vInputTag[0] == inputTag1);
0304 vInputTag = ps.getParameter<std::vector<edm::InputTag>>("vInputTagv3");
0305 assert(vInputTag[0] == inputTag1);
0306 assert(vInputTag[1] == inputTag2);
0307 vInputTag = ps.getParameter<std::vector<edm::InputTag>>("vInputTagv4");
0308 assert(vInputTag[0] == inputTag1);
0309 assert(vInputTag[1] == inputTag2);
0310 assert(vInputTag[2] == inputTag3);
0311 vInputTag = ps.getParameter<std::vector<edm::InputTag>>("vInputTagv5");
0312 assert(vInputTag[0] == inputTag1);
0313 assert(vInputTag[1] == inputTag2);
0314 assert(vInputTag[2] == inputTag3);
0315 assert(vInputTag[3] == inputTag4);
0316
0317 edm::ESInputTag esinputTag1("One", "Two");
0318 assert(ps.getParameter<edm::ESInputTag>("esinputTagv1") == esinputTag1);
0319 edm::ESInputTag esinputTag2("One", "");
0320 assert(ps.getParameter<edm::ESInputTag>("esinputTagv2") == esinputTag2);
0321 edm::ESInputTag esinputTag3("", "Two");
0322 assert(ps.getParameter<edm::ESInputTag>("esinputTagv3") == esinputTag3);
0323
0324 std::vector<edm::ESInputTag> vESInputTag;
0325 vESInputTag = ps.getParameter<std::vector<edm::ESInputTag>>("vESInputTagv1");
0326 assert(vESInputTag.empty());
0327 vESInputTag = ps.getParameter<std::vector<edm::ESInputTag>>("vESInputTagv2");
0328 assert(vESInputTag[0] == esinputTag1);
0329 vESInputTag = ps.getParameter<std::vector<edm::ESInputTag>>("vESInputTagv3");
0330 assert(vESInputTag[0] == esinputTag1);
0331 assert(vESInputTag[1] == esinputTag2);
0332 vESInputTag = ps.getParameter<std::vector<edm::ESInputTag>>("vESInputTagv4");
0333 assert(vESInputTag[0] == esinputTag1);
0334 assert(vESInputTag[1] == esinputTag2);
0335 assert(vESInputTag[2] == esinputTag3);
0336
0337
0338
0339 edm::FileInPath fileInPath("FWCore/Integration/plugins/ProducerWithPSetDesc.cc");
0340 assert(fileInPath == ps.getParameter<edm::FileInPath>("fileInPath"));
0341
0342 edm::ParameterSet const& pset = ps.getParameterSet("bar");
0343 assert(pset.getParameter<unsigned>("Drinks") == 5U);
0344 assert(pset.getUntrackedParameter<unsigned>("uDrinks") == 5U);
0345 if (testingAutoGeneratedCfi)
0346 assert(pset.getParameter<unsigned>("oDrinks") == 5U);
0347 if (testingAutoGeneratedCfi)
0348 assert(pset.getUntrackedParameter<unsigned>("ouDrinks") == 5U);
0349
0350
0351
0352
0353 std::vector<edm::ParameterSet> const& vpset = ps.getParameterSetVector("bars");
0354
0355 assert(vpset.size() == 2U);
0356
0357 const edm::ParameterSet& pset0 = vpset[0];
0358 assert(pset0.getParameter<unsigned>("Drinks") == 5U);
0359 assert(pset0.getUntrackedParameter<unsigned>("uDrinks") == 5U);
0360 assert(pset0.getParameter<unsigned>("oDrinks") == 11U);
0361 assert(pset0.exists("ouDrinks") == false);
0362 assert(pset0.exists("ndoDrinks") == false);
0363 assert(pset0.exists("ndouDrinks") == false);
0364
0365
0366 const edm::ParameterSet& pset1 = vpset[1];
0367 assert(pset1.getParameter<unsigned>("Drinks") == 5U);
0368 assert(pset1.getUntrackedParameter<unsigned>("uDrinks") == 5U);
0369 assert(pset1.getParameter<unsigned>("oDrinks") == 11U);
0370 assert(pset1.getUntrackedParameter<unsigned>("ouDrinks") == 11U);
0371 assert(pset1.exists("ndoDrinks") == false);
0372 assert(pset1.getUntrackedParameter<unsigned>("ndouDrinks") == 11U);
0373
0374 assert(ps.getParameter<double>("test1") == 0.1);
0375 if (testingAutoGeneratedCfi) {
0376 assert(ps.getParameter<double>("test2") == 0.2);
0377 assert(ps.exists("test3") == false);
0378
0379 assert(ps.getParameter<std::string>("testA") == std::string("fooA"));
0380 assert(ps.getParameter<int>("testB") == 100);
0381 assert(ps.getParameter<int>("testC") == 101);
0382
0383 assert(ps.getParameter<int>("oiswitch") == 1);
0384 assert(ps.getParameter<double>("oivalue1") == 101.0);
0385 assert(ps.getParameter<double>("oivalue2") == 101.0);
0386 } else {
0387 assert(!ps.exists("test2"));
0388 assert(!ps.exists("test3"));
0389
0390 assert(!ps.exists("testA"));
0391 assert(!ps.exists("testB"));
0392 assert(!ps.exists("testC"));
0393
0394 assert(!ps.exists("oiswitch"));
0395 assert(!ps.exists("oivalue1"));
0396 assert(!ps.exists("oivalue2"));
0397 }
0398
0399 edm::ParameterSet const& deeplyNestedPSet = pset1.getParameterSet("testDeeplyNested");
0400 if (testingAutoGeneratedCfi) {
0401 assert(!deeplyNestedPSet.exists("ndiswitch"));
0402 assert(!deeplyNestedPSet.exists("ndivalue1"));
0403 assert(!deeplyNestedPSet.exists("ndivalue2"));
0404 } else {
0405 assert(!deeplyNestedPSet.exists("ndiswitch"));
0406 assert(!deeplyNestedPSet.exists("ndivalue1"));
0407 assert(!deeplyNestedPSet.exists("ndivalue2"));
0408 }
0409
0410 assert(deeplyNestedPSet.getParameter<bool>("bswitch") == false);
0411 assert(deeplyNestedPSet.getParameter<double>("bvalue1") == 101.0);
0412 assert(deeplyNestedPSet.getParameter<double>("bvalue2") == 101.0);
0413 assert(!deeplyNestedPSet.exists("bvalue"));
0414
0415 assert(deeplyNestedPSet.getParameter<int>("iswitch") == 1);
0416 assert(deeplyNestedPSet.getParameter<double>("ivalue1") == 101.0);
0417 assert(deeplyNestedPSet.getUntrackedParameter<double>("ivalue2") == 101.0);
0418 assert(!deeplyNestedPSet.exists("ivalue"));
0419
0420 assert(deeplyNestedPSet.getParameter<std::string>("sswitch") == std::string("1"));
0421 assert(deeplyNestedPSet.getParameter<double>("svalue1") == 101.0);
0422 assert(deeplyNestedPSet.getParameter<double>("svalue2") == 101.0);
0423 assert(!deeplyNestedPSet.exists("svalue"));
0424
0425 if (testingAutoGeneratedCfi) {
0426 edm::ParameterSet const& pset11 = ps.getParameterSet("subpset");
0427 assert(pset11.getParameter<int>("xvalue") == 11);
0428 edm::ParameterSet const& pset111 = pset11.getUntrackedParameterSet("bar");
0429 assert(pset111.getParameter<unsigned>("Drinks") == 5U);
0430 assert(pset111.getUntrackedParameter<unsigned>("uDrinks") == 5U);
0431 assert(pset111.getParameter<unsigned>("oDrinks") == 5U);
0432 assert(pset111.getUntrackedParameter<unsigned>("ouDrinks") == 5U);
0433 }
0434
0435 edm::ParameterSet const& psetXor = ps.getParameterSet("xorPset");
0436 assert(psetXor.getParameter<std::string>("name1") == std::string("11"));
0437 assert(!psetXor.exists("name2"));
0438 if (testingAutoGeneratedCfi) {
0439 assert(psetXor.getParameter<std::string>("name") == std::string("11"));
0440 } else {
0441 assert(psetXor.getParameter<unsigned>("name") == 11U);
0442 }
0443
0444 edm::ParameterSet const& psetOr = ps.getParameterSet("orPset");
0445 assert(!psetOr.exists("z1"));
0446 assert(!psetOr.exists("z2"));
0447 if (testingAutoGeneratedCfi) {
0448 assert(psetOr.getParameter<std::string>("x1") == std::string("11"));
0449 assert(!psetOr.exists("x2"));
0450 assert(psetOr.getParameter<std::string>("y1") == std::string("11"));
0451 assert(!psetOr.exists("y2"));
0452 } else {
0453 assert(!psetOr.exists("x1"));
0454 assert(psetOr.getParameter<unsigned>("x2") == 11U);
0455 assert(psetOr.getParameter<std::string>("y1") == std::string("11"));
0456 assert(psetOr.getParameter<unsigned>("y2") == 11U);
0457 }
0458
0459 edm::ParameterSet const& psetAnd = ps.getParameterSet("andPset");
0460 assert(psetAnd.getParameter<std::string>("x1") == std::string("11"));
0461 assert(psetAnd.getParameter<unsigned>("x2") == 11U);
0462 assert(psetAnd.getParameter<std::string>("y1") == std::string("11"));
0463 assert(psetAnd.getParameter<unsigned>("y2") == 11U);
0464 assert(psetAnd.getParameter<std::string>("z1") == std::string("11"));
0465 assert(psetAnd.getParameter<unsigned>("z2") == 11U);
0466 assert(psetAnd.getParameter<std::string>("b1") == std::string("11"));
0467 assert(psetAnd.getParameter<unsigned>("b2") == 11U);
0468 assert(psetAnd.getParameter<unsigned>("b3") == 11U);
0469 assert(psetAnd.getParameter<unsigned>("b4") == 11U);
0470 assert(psetAnd.getParameter<unsigned>("b5") == 11U);
0471 assert(psetAnd.getParameter<unsigned>("b6") == 11U);
0472 if (testingAutoGeneratedCfi) {
0473 assert(!psetAnd.exists("a1"));
0474 assert(!psetAnd.exists("a2"));
0475 } else {
0476 assert(psetAnd.getParameter<std::string>("a1") == std::string("11"));
0477 assert(psetAnd.getParameter<unsigned>("a2") == 11U);
0478 }
0479
0480 edm::ParameterSet const& psetIfExists = ps.getParameterSet("ifExistsPset");
0481 assert(psetIfExists.getParameter<unsigned>("x1") == 11U);
0482 assert(psetIfExists.getParameter<std::string>("x2") == std::string("11"));
0483 assert(psetIfExists.getParameter<unsigned>("z1") == 11U);
0484 assert(psetIfExists.getParameter<std::string>("z2") == std::string("11"));
0485 if (testingAutoGeneratedCfi) {
0486 assert(!psetIfExists.exists("y1"));
0487 assert(!psetIfExists.exists("y2"));
0488 } else {
0489 assert(psetIfExists.getParameter<unsigned>("y1") == 11U);
0490 assert(!psetIfExists.exists("y2"));
0491 }
0492
0493 edm::ParameterSet const& psetAllowed = ps.getParameterSet("allowedLabelsPset");
0494 if (testingAutoGeneratedCfi) {
0495 assert(psetAllowed.getParameter<std::vector<std::string>>("testAllowedLabels").empty());
0496 assert(psetAllowed.getUntrackedParameter<std::vector<std::string>>("testAllowedLabelsUntracked").empty());
0497 assert(!psetAllowed.exists("testOptAllowedLabels"));
0498 assert(!psetAllowed.exists("testOptAllowedLabelsUntracked"));
0499 }
0500
0501 auto pluginPSet = ps.getParameter<edm::ParameterSet>("plugin");
0502 pluginHelper_ = AnotherIntFactory::get()->create(pluginPSet.getParameter<std::string>("type"), pluginPSet);
0503
0504 auto plugin1PSet = ps.getParameter<edm::ParameterSet>("plugin1");
0505 pluginHelper1_ = AnotherIntFactory::get()->create(plugin1PSet.getParameter<std::string>("type"), plugin1PSet);
0506
0507 std::vector<edm::ParameterSet> vpset2 = ps.getParameter<std::vector<edm::ParameterSet>>("plugin2");
0508 for (auto const& pset2 : vpset2) {
0509 pluginHelpers2_.emplace_back(AnotherIntFactory::get()->create(pset2.getParameter<std::string>("type"), pset2));
0510 }
0511
0512 std::vector<edm::ParameterSet> vpset3 = ps.getParameter<std::vector<edm::ParameterSet>>("plugin3");
0513 for (auto const& pset3 : vpset3) {
0514 pluginHelpers3_.emplace_back(AnotherIntFactory::get()->create(pset3.getParameter<std::string>("type"), pset3));
0515 }
0516
0517 auto plugin4PSet = ps.getParameter<edm::ParameterSet>("plugin4");
0518 pluginHelper4_ = AnotherIntFactory::get()->create(plugin4PSet.getParameter<std::string>("type"), plugin4PSet);
0519
0520 std::vector<edm::ParameterSet> vpset5 = ps.getParameter<std::vector<edm::ParameterSet>>("plugin5");
0521 for (auto const& pset5 : vpset5) {
0522 pluginHelpers5_.emplace_back(AnotherIntFactory::get()->create(pset5.getParameter<std::string>("type"), pset5));
0523 }
0524
0525 produces<ThingCollection>();
0526 }
0527
0528 void ProducerWithPSetDesc::produce(edm::StreamID, edm::Event& e, edm::EventSetup const&) const {
0529
0530
0531
0532 auto result = std::make_unique<ThingCollection>();
0533 e.put(std::move(result));
0534 }
0535
0536 namespace {
0537 edm::ParameterSetDescription description(int p_int) {
0538 edm::ParameterSetDescription iDesc;
0539
0540
0541
0542
0543
0544 iDesc.addOptionalUntracked<bool>("testingAutoGeneratedCfi", true);
0545
0546 edm::ParameterDescriptionNode* pn;
0547 pn = iDesc.add<int>("p_int", p_int);
0548 pn->setComment(
0549 "A big integer. I am trying to test the wrapping of comments in"
0550 " the printed output by putting in a long comment to see if it gets"
0551 " wrapped OK. The comment should get indented to the second column"
0552 " indent on every line. By default newlines should be inserted between"
0553 " words to make the lines fit in the terminal screen width. There is "
0554 "a command line parameter that can be set to override this width to "
0555 "any desired value. If there is no terminal then it should default to "
0556 "80. The logic for setting the width is in edmPluginHelp.cpp");
0557
0558 iDesc.addUntracked<int>("p_int_untracked", -2147483647);
0559 iDesc.addOptional<int>("p_int_opt", 0);
0560 iDesc.addOptionalUntracked<int>("p_int_optuntracked", 7);
0561 iDesc.addOptional<int>("p_int_opt_nd");
0562 iDesc.addOptionalUntracked<int>("p_int_optuntracked_nd");
0563
0564 std::vector<int> vint;
0565 iDesc.add<std::vector<int>>("vint1", vint);
0566 vint.push_back(2147483647);
0567 iDesc.add<std::vector<int>>(std::string("vint2"), vint);
0568 vint.push_back(-2147483647);
0569 iDesc.add<std::vector<int>>("vint3", vint);
0570 vint.push_back(0);
0571 iDesc.add<std::vector<int>>("vint4", vint);
0572
0573 iDesc.add<unsigned>("uint1", 4294967295U);
0574 iDesc.addUntracked<unsigned>("uint2", 0);
0575
0576 std::vector<unsigned> vuint;
0577 iDesc.add<std::vector<unsigned>>("vuint1", vuint);
0578 vuint.push_back(4294967295U);
0579 iDesc.add<std::vector<unsigned>>("vuint2", vuint);
0580 vuint.push_back(0);
0581 iDesc.add<std::vector<unsigned>>("vuint3", vuint);
0582 vuint.push_back(11);
0583 iDesc.add<std::vector<unsigned>>("vuint4", vuint);
0584 vuint.push_back(21);
0585 vuint.push_back(31);
0586 vuint.push_back(41);
0587 iDesc.add<std::vector<unsigned>>("vuint5", vuint);
0588
0589 iDesc.add<long long>("int64v1", 9000000000000000000LL);
0590 iDesc.add<long long>("int64v2", -9000000000000000000LL);
0591 iDesc.add<long long>("int64v3", 0);
0592
0593 std::vector<long long> vint64;
0594 iDesc.add<std::vector<long long>>("vint64v1", vint64);
0595 vint64.push_back(9000000000000000000LL);
0596 iDesc.add<std::vector<long long>>("vint64v2", vint64);
0597 vint64.push_back(-9000000000000000000LL);
0598 iDesc.add<std::vector<long long>>("vint64v3", vint64);
0599 vint64.push_back(0);
0600 iDesc.add<std::vector<long long>>("vint64v4", vint64);
0601
0602 iDesc.add<unsigned long long>("uint64v1", 18000000000000000000ULL);
0603 iDesc.addUntracked<unsigned long long>("uint64v2", 0);
0604
0605 std::vector<unsigned long long> vuint64;
0606 iDesc.add<std::vector<unsigned long long>>("vuint64v1", vuint64);
0607 vuint64.push_back(18000000000000000000ULL);
0608 iDesc.add<std::vector<unsigned long long>>("vuint64v2", vuint64);
0609 vuint64.push_back(0);
0610 iDesc.add<std::vector<unsigned long long>>("vuint64v3", vuint64);
0611 vuint64.push_back(11);
0612 iDesc.add<std::vector<unsigned long long>>("vuint64v4", vuint64);
0613
0614 iDesc.add<double>("doublev1", std::numeric_limits<double>::min());
0615 iDesc.addUntracked<double>("doublev2", 0.0);
0616 iDesc.addUntracked<double>("doublev3", 0.3);
0617
0618 std::vector<double> vdouble;
0619 iDesc.add<std::vector<double>>("vdoublev1", vdouble);
0620
0621
0622
0623 vdouble.push_back(1e+300);
0624 iDesc.add<std::vector<double>>("vdoublev2", vdouble);
0625 vdouble.push_back(0.0);
0626 iDesc.add<std::vector<double>>("vdoublev3", vdouble);
0627 vdouble.push_back(11.0);
0628 iDesc.add<std::vector<double>>("vdoublev4", vdouble);
0629 vdouble.push_back(0.3);
0630 iDesc.add<std::vector<double>>("vdoublev5", vdouble);
0631
0632 iDesc.add<bool>("boolv1", true);
0633 iDesc.add<bool>("boolv2", false);
0634
0635 std::string test("Hello");
0636 iDesc.add<std::string>("stringv1", test);
0637 test.clear();
0638 iDesc.add<std::string>("stringv2", test);
0639
0640 std::vector<std::string> vstring;
0641 iDesc.add<std::vector<std::string>>("vstringv1", vstring);
0642 test = "Hello";
0643 vstring.push_back(test);
0644 iDesc.add<std::vector<std::string>>("vstringv2", vstring);
0645 test = "World";
0646 vstring.push_back(test);
0647 iDesc.add<std::vector<std::string>>("vstringv3", vstring);
0648 test = "";
0649 vstring.push_back(test);
0650 iDesc.add<std::vector<std::string>>("vstringv4", vstring);
0651
0652 edm::EventID eventID(11, 0, 12);
0653 iDesc.add<edm::EventID>("eventIDv1", eventID);
0654 edm::EventID eventID2(101, 0, 102);
0655 iDesc.add<edm::EventID>("eventIDv2", eventID2);
0656 std::vector<edm::EventID> vEventID;
0657 iDesc.add<std::vector<edm::EventID>>("vEventIDv1", vEventID);
0658 edm::EventID eventID3(1000, 0, 1100);
0659 vEventID.push_back(eventID3);
0660 iDesc.add<std::vector<edm::EventID>>("vEventIDv2", vEventID);
0661 edm::EventID eventID4(10000, 0, 11000);
0662 vEventID.push_back(eventID4);
0663 iDesc.add<std::vector<edm::EventID>>("vEventIDv3", vEventID);
0664 edm::EventID eventID5(100000, 0, 110000);
0665 vEventID.push_back(eventID5);
0666 iDesc.add<std::vector<edm::EventID>>("vEventIDv4", vEventID);
0667
0668 edm::LuminosityBlockID luminosityID(11, 12);
0669 iDesc.add<edm::LuminosityBlockID>("luminosityIDv1", luminosityID);
0670 edm::LuminosityBlockID luminosityID2(101, 102);
0671 iDesc.add<edm::LuminosityBlockID>("luminosityIDv2", luminosityID2);
0672
0673 std::vector<edm::LuminosityBlockID> vLuminosityBlockID;
0674 iDesc.add<std::vector<edm::LuminosityBlockID>>("vLuminosityBlockIDv1", vLuminosityBlockID);
0675 edm::LuminosityBlockID luminosityID3(1000, 1100);
0676 vLuminosityBlockID.push_back(luminosityID3);
0677 iDesc.add<std::vector<edm::LuminosityBlockID>>("vLuminosityBlockIDv2", vLuminosityBlockID);
0678 edm::LuminosityBlockID luminosityID4(10000, 11000);
0679 vLuminosityBlockID.push_back(luminosityID4);
0680 iDesc.add<std::vector<edm::LuminosityBlockID>>("vLuminosityBlockIDv3", vLuminosityBlockID);
0681 edm::LuminosityBlockID luminosityID5(100000, 110000);
0682 vLuminosityBlockID.push_back(luminosityID5);
0683 iDesc.add<std::vector<edm::LuminosityBlockID>>("vLuminosityBlockIDv4", vLuminosityBlockID);
0684
0685 edm::LuminosityBlockRange lumiRange(1, 1, 9, 9);
0686 iDesc.add<edm::LuminosityBlockRange>("lumiRangev1", lumiRange);
0687 edm::LuminosityBlockRange lumiRange2(3, 4, 1000, 1000);
0688 iDesc.add<edm::LuminosityBlockRange>("lumiRangev2", lumiRange2);
0689
0690 std::vector<edm::LuminosityBlockRange> vLumiRange;
0691 iDesc.add<std::vector<edm::LuminosityBlockRange>>("vLumiRangev1", vLumiRange);
0692 vLumiRange.push_back(lumiRange);
0693 iDesc.add<std::vector<edm::LuminosityBlockRange>>("vLumiRangev2", vLumiRange);
0694 vLumiRange.push_back(lumiRange2);
0695 iDesc.add<std::vector<edm::LuminosityBlockRange>>("vLumiRangev3", vLumiRange);
0696
0697 edm::EventRange eventRange(1, 0, 1, 8, 0, 8);
0698 iDesc.add<edm::EventRange>("eventRangev1", eventRange);
0699 edm::EventRange eventRange2(3, 0, 4, 1001, 0, 1002);
0700 iDesc.add<edm::EventRange>("eventRangev2", eventRange2);
0701
0702 std::vector<edm::EventRange> vEventRange;
0703 iDesc.add<std::vector<edm::EventRange>>("vEventRangev1", vEventRange);
0704 vEventRange.push_back(eventRange);
0705 iDesc.add<std::vector<edm::EventRange>>("vEventRangev2", vEventRange);
0706 vEventRange.push_back(eventRange2);
0707 iDesc.add<std::vector<edm::EventRange>>("vEventRangev3", vEventRange);
0708
0709 edm::InputTag inputTag("One", "Two", "Three");
0710 iDesc.add<edm::InputTag>("inputTagv1", inputTag);
0711 edm::InputTag inputTag2("One", "Two");
0712 iDesc.add<edm::InputTag>("inputTagv2", inputTag2);
0713 edm::InputTag inputTag3("One");
0714 iDesc.add<edm::InputTag>("inputTagv3", inputTag3);
0715 edm::InputTag inputTag4("One", "", "Three");
0716 iDesc.add<edm::InputTag>("inputTagv4", inputTag4);
0717
0718 std::vector<edm::InputTag> vInputTag;
0719 iDesc.add<std::vector<edm::InputTag>>("vInputTagv1", vInputTag);
0720 vInputTag.push_back(inputTag);
0721 iDesc.add<std::vector<edm::InputTag>>("vInputTagv2", vInputTag);
0722 vInputTag.push_back(inputTag2);
0723 iDesc.add<std::vector<edm::InputTag>>("vInputTagv3", vInputTag);
0724 vInputTag.push_back(inputTag3);
0725 iDesc.add<std::vector<edm::InputTag>>("vInputTagv4", vInputTag);
0726 vInputTag.push_back(inputTag4);
0727 iDesc.add<std::vector<edm::InputTag>>("vInputTagv5", vInputTag);
0728
0729 edm::ESInputTag esinputTag("One", "Two");
0730 iDesc.add<edm::ESInputTag>("esinputTagv1", esinputTag);
0731 edm::ESInputTag esinputTag2("One", "");
0732 iDesc.add<edm::ESInputTag>("esinputTagv2", esinputTag2);
0733 edm::ESInputTag esinputTag3("", "Two");
0734 iDesc.add<edm::ESInputTag>("esinputTagv3", esinputTag3);
0735
0736 std::vector<edm::ESInputTag> vESInputTag;
0737 iDesc.add<std::vector<edm::ESInputTag>>("vESInputTagv1", vESInputTag);
0738 vESInputTag.push_back(esinputTag);
0739 iDesc.add<std::vector<edm::ESInputTag>>("vESInputTagv2", vESInputTag);
0740 vESInputTag.push_back(esinputTag2);
0741 iDesc.add<std::vector<edm::ESInputTag>>("vESInputTagv3", vESInputTag);
0742 vESInputTag.push_back(esinputTag3);
0743 iDesc.add<std::vector<edm::ESInputTag>>("vESInputTagv4", vESInputTag);
0744
0745
0746
0747 edm::FileInPath fileInPath("FWCore/Integration/plugins/ProducerWithPSetDesc.cc");
0748 iDesc.add<edm::FileInPath>("fileInPath", fileInPath);
0749
0750 edm::EmptyGroupDescription emptyGroup;
0751 iDesc.addNode(emptyGroup);
0752
0753 edm::ParameterSetDescription bar;
0754 bar.add<unsigned int>("Drinks", 5);
0755 bar.addUntracked<unsigned int>("uDrinks", 5);
0756 bar.addOptional<unsigned int>("oDrinks", 5);
0757 bar.addOptionalUntracked<unsigned int>("ouDrinks", 5);
0758 iDesc.add("bar", bar);
0759
0760 edm::ParameterDescription<edm::ParameterSetDescription> test101("test101", bar, true);
0761 iDesc.addOptionalNode(test101, false);
0762
0763 edm::ParameterSetDescription barx;
0764 barx.add<unsigned int>("Drinks", 5);
0765 barx.addUntracked<unsigned int>("uDrinks", 5);
0766 barx.addOptional<unsigned int>("oDrinks", 5);
0767 barx.addOptionalUntracked<unsigned int>("ouDrinks", 5);
0768 barx.addOptional<unsigned int>("ndoDrinks");
0769 barx.addOptionalUntracked<unsigned int>("ndouDrinks");
0770
0771 edm::ParameterDescription<std::vector<edm::ParameterSet>> test102(
0772 "test102", edm::ParameterSetDescription(), true);
0773 iDesc.addOptionalNode(test102, false);
0774
0775 edm::ParameterDescription<std::vector<edm::ParameterSet>> test103(std::string("test103"), barx, true);
0776 iDesc.addOptionalNode(test103, false);
0777
0778 std::vector<edm::ParameterSet> defaultVPSet104;
0779 defaultVPSet104.push_back(edm::ParameterSet());
0780 edm::ParameterDescription<std::vector<edm::ParameterSet>> test104(
0781 std::string("test104"), barx, false, defaultVPSet104);
0782 iDesc.addNode(test104);
0783
0784 std::vector<edm::ParameterSet> defaultVPSet105;
0785 edm::ParameterDescription<std::vector<edm::ParameterSet>> test105(
0786 std::string("test105"), barx, false, defaultVPSet105);
0787 iDesc.addNode(test105);
0788
0789 double d1 = 0.1;
0790 double d2 = 0.2;
0791 double d3 = 0.3;
0792 iDesc.addNode(edm::ParameterDescription<double>("test1", d1, true));
0793 iDesc.addOptionalNode(edm::ParameterDescription<double>("test2", d2, true), true);
0794
0795 iDesc.addOptionalNode(edm::ParameterDescription<double>("test3", d3, true), false);
0796
0797 iDesc.addOptionalNode(edm::ParameterDescription<std::string>("testA", "fooA", true) and
0798 edm::ParameterDescription<int>("testB", 100, true) &&
0799 edm::ParameterDescription<int>("testC", 101, true),
0800 true);
0801
0802 iDesc.ifValueOptional(edm::ParameterDescription<int>("oiswitch", 1, true),
0803 0 >> edm::ParameterDescription<int>("oivalue", 100, true) or
0804 1 >> (edm::ParameterDescription<double>("oivalue1", 101.0, true) and
0805 edm::ParameterDescription<double>("oivalue2", 101.0, true)) or
0806 2 >> edm::ParameterDescription<std::string>("oivalue", "102", true),
0807 true);
0808
0809 edm::ParameterSetDescription deeplyNested;
0810
0811 bool case0 = true;
0812 bool case1 = false;
0813 deeplyNested.ifValue(edm::ParameterDescription<bool>("bswitch", false, true),
0814 case0 >> edm::ParameterDescription<int>("bvalue", 100, true) or
0815 case1 >> (edm::ParameterDescription<double>("bvalue1", 101.0, true) and
0816 edm::ParameterDescription<double>("bvalue2", 101.0, true)));
0817 deeplyNested.ifValue(edm::ParameterDescription<int>("iswitch", 1, true),
0818 0 >> edm::ParameterDescription<int>("ivalue", 100, true) or
0819 1 >> (edm::ParameterDescription<double>("ivalue1", 101.0, true) and
0820 edm::ParameterDescription<double>("ivalue2", 101.0, false)) or
0821 2 >> edm::ParameterDescription<std::string>("ivalue", "102", true));
0822 deeplyNested.ifValue(edm::ParameterDescription<std::string>("sswitch", std::string("1"), true),
0823 std::string("0") >> edm::ParameterDescription<int>("svalue", 100, true) or
0824 "1" >> (edm::ParameterDescription<double>("svalue1", 101.0, true) and
0825 edm::ParameterDescription<double>("svalue2", 101.0, true)) or
0826 "2" >> edm::ParameterDescription<std::string>("svalue", "102", true));
0827
0828 deeplyNested.ifValueOptional(edm::ParameterDescription<int>("ndiswitch", 1, true),
0829 0 >> edm::ParameterDescription<int>("ndivalue", 100, true) or
0830 1 >> (edm::ParameterDescription<double>("ndivalue1", 101.0, true) and
0831 edm::ParameterDescription<double>("ndivalue2", 101.0, true)) or
0832 2 >> edm::ParameterDescription<std::string>("ndivalue", "102", true),
0833 false);
0834
0835 deeplyNested.add<int>("testint", 1000);
0836
0837 barx.add("testDeeplyNested", deeplyNested);
0838
0839 iDesc.add("testDeeplyNested2", deeplyNested);
0840
0841 edm::ParameterSetDescription validator;
0842 validator.add<int>("xvalue", 7);
0843 std::vector<edm::ParameterSet> vDefaults;
0844 edm::ParameterSet vDefaults0;
0845 vDefaults.push_back(vDefaults0);
0846 edm::ParameterSet vDefaults1;
0847 vDefaults1.addParameter<int>("xvalue", 100);
0848 vDefaults.push_back(vDefaults1);
0849 barx.addVPSet("anotherVPSet", validator, vDefaults);
0850
0851 std::vector<edm::ParameterSet> defaultVPSet;
0852
0853 edm::ParameterSet psetInVector1;
0854 psetInVector1.addParameter<unsigned int>("oDrinks", 11U);
0855 defaultVPSet.push_back(psetInVector1);
0856
0857 edm::ParameterSet psetInVector2;
0858 psetInVector2.addParameter<unsigned int>("oDrinks", 11U);
0859 psetInVector2.addUntrackedParameter<unsigned int>("ouDrinks", 11U);
0860 psetInVector2.addUntrackedParameter<unsigned int>("ndouDrinks", 11U);
0861
0862 std::vector<edm::ParameterSet> anotherDefaultVPSet;
0863 anotherDefaultVPSet.push_back(edm::ParameterSet());
0864 edm::ParameterSet anotherParameterSet;
0865 anotherParameterSet.addParameter<int>("xvalue", 17);
0866 anotherDefaultVPSet.push_back(anotherParameterSet);
0867 psetInVector2.addParameter<std::vector<edm::ParameterSet>>("anotherVPSet", anotherDefaultVPSet);
0868
0869 edm::ParameterSet defaultForDeeplyNested;
0870 defaultForDeeplyNested.addParameter<int>("testint", 2);
0871 psetInVector2.addParameter<edm::ParameterSet>("testDeeplyNested", defaultForDeeplyNested);
0872
0873 defaultVPSet.push_back(psetInVector2);
0874
0875 iDesc.addVPSet("bars", barx, defaultVPSet);
0876
0877
0878 edm::ParameterDescriptionBase* parDescription;
0879 parDescription = iDesc.addOptional("subpset", edm::ParameterSetDescription());
0880 edm::ParameterSetDescription* subPsetDescription = parDescription->parameterSetDescription();
0881
0882 subPsetDescription->add<int>("xvalue", 11);
0883 subPsetDescription->addUntracked<edm::ParameterSetDescription>(std::string("bar"), bar);
0884
0885
0886
0887 edm::ParameterSetDescription wildcardPset;
0888 wildcardPset.addOptional<unsigned>("p_uint_opt", 0);
0889 wildcardPset.addWildcard<int>("*");
0890 pn = wildcardPset.addWildcardUntracked<double>(std::string("*"));
0891 pn->setComment("A comment for a wildcard parameter");
0892
0893 std::unique_ptr<edm::ParameterDescriptionNode> wnode =
0894 std::make_unique<edm::ParameterWildcard<edm::ParameterSetDescription>>("*", edm::RequireExactlyOne, true);
0895 wildcardPset.addOptionalNode(std::move(wnode), false);
0896
0897 edm::ParameterSetDescription wSet1;
0898 wSet1.add<unsigned int>("Drinks", 5);
0899
0900 std::unique_ptr<edm::ParameterDescriptionNode> wnode2 =
0901 std::make_unique<edm::ParameterWildcard<edm::ParameterSetDescription>>(
0902 "*", edm::RequireAtLeastOne, true, wSet1);
0903 wildcardPset.addOptionalNode(std::move(wnode2), false);
0904
0905 std::unique_ptr<edm::ParameterDescriptionNode> wnode3 =
0906 std::make_unique<edm::ParameterWildcard<std::vector<edm::ParameterSet>>>("*", edm::RequireExactlyOne, true);
0907 wildcardPset.addOptionalNode(std::move(wnode3), false);
0908
0909 wSet1.add<unsigned int>("Drinks2", 11);
0910
0911 std::unique_ptr<edm::ParameterDescriptionNode> wnode4 =
0912 std::make_unique<edm::ParameterWildcard<std::vector<edm::ParameterSet>>>(
0913 "*", edm::RequireAtLeastOne, true, wSet1);
0914 wildcardPset.addOptionalNode(std::move(wnode4), false);
0915
0916 iDesc.add("wildcardPset", wildcardPset);
0917
0918
0919
0920 std::vector<int> testIntVector;
0921 testIntVector.push_back(21);
0922 testIntVector.push_back(22);
0923 edm::ParameterSetDescription switchPset;
0924 pn = switchPset.ifValue(edm::ParameterDescription<int>("iswitch", 1, true),
0925 0 >> edm::ParameterDescription<std::vector<int>>("ivalue", testIntVector, true) or
0926 1 >> (edm::ParameterDescription<double>("ivalue1", 101.0, true) and
0927 edm::ParameterDescription<double>("ivalue2", 101.0, true)) or
0928 2 >> edm::ParameterDescription<std::string>("ivalue", "102", true));
0929 pn->setComment("Comment for a ParameterSwitch");
0930
0931 switchPset
0932 .ifValue(edm::ParameterDescription<bool>("addTeVRefits", true, true),
0933 true >> (edm::ParameterDescription<edm::InputTag>("pickySrc", edm::InputTag(), true) and
0934 edm::ParameterDescription<edm::InputTag>("tpfmsSrc", edm::InputTag(), true)) or
0935 false >> edm::EmptyGroupDescription())
0936 ->setComment("If TeV refits are added, their sources need to be specified");
0937
0938 iDesc.add("switchPset", switchPset);
0939
0940
0941
0942 edm::ParameterSetDescription xorPset;
0943 xorPset.addNode(edm::ParameterDescription<std::string>("name", "11", true) xor
0944 edm::ParameterDescription<unsigned int>("name", 11U, true));
0945
0946 xorPset.addNode(edm::ParameterDescription<std::string>("name1", "11", true) xor
0947 edm::ParameterDescription<unsigned int>("name1", 11U, true));
0948
0949 xorPset.addOptionalNode(edm::ParameterDescription<std::string>("name2", "11", true) xor
0950 edm::ParameterDescription<unsigned int>("name2", 11U, true),
0951 false);
0952
0953 xorPset.addNode(edm::ParameterDescription<std::string>("name3", "11", true) xor
0954 edm::ParameterDescription<unsigned int>("name4", 11U, true) xor test101 xor test103);
0955
0956 iDesc.add("xorPset", xorPset);
0957
0958
0959
0960 edm::ParameterSetDescription orPset;
0961
0962 orPset.addNode(edm::ParameterDescription<std::string>("x1", "11", true) or
0963 edm::ParameterDescription<unsigned int>("x2", 11U, true));
0964
0965 orPset.addNode(edm::ParameterDescription<std::string>("y1", "11", true) or
0966 edm::ParameterDescription<unsigned int>("y2", 11U, true));
0967
0968 orPset.addOptionalNode(edm::ParameterDescription<std::string>("z1", "11", true) or
0969 edm::ParameterDescription<unsigned int>("z2", 11U, true) or test101 or test103,
0970 false);
0971
0972 iDesc.add("orPset", orPset);
0973
0974
0975
0976 edm::ParameterSetDescription andPset;
0977
0978 andPset.addNode(edm::ParameterDescription<std::string>("x1", "11", true) and
0979 edm::ParameterDescription<unsigned int>("x2", 11U, true));
0980
0981 andPset.addNode(edm::ParameterDescription<std::string>("y1", "11", true) and
0982 edm::ParameterDescription<unsigned int>("y2", 11U, true));
0983
0984 andPset.addNode(edm::ParameterDescription<std::string>("z1", "11", true) and
0985 edm::ParameterDescription<unsigned int>("z2", 11U, true));
0986
0987 andPset.addOptionalNode(edm::ParameterDescription<std::string>("a1", "11", true) and
0988 edm::ParameterDescription<unsigned int>("a2", 11U, true),
0989 false);
0990
0991 andPset.addOptionalNode((edm::ParameterDescription<std::string>("b1", "11", true) and
0992 edm::ParameterDescription<unsigned int>("b2", 11U, true)) and
0993 edm::ParameterDescription<unsigned int>("b3", 11U, true) and
0994 (edm::ParameterDescription<unsigned int>("b4", 11U, true) and
0995 (edm::ParameterDescription<unsigned int>("b5", 11U, true) and
0996 edm::ParameterDescription<unsigned int>("b6", 11U, true))),
0997 true);
0998
0999 iDesc.add("andPset", andPset);
1000
1001
1002
1003 edm::ParameterSetDescription ifExistsPset;
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
1019 edm::ParameterSetDescription allowedLabelsPset;
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 }
1140 void ProducerWithPSetDesc::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
1141 auto iDesc = description(2147483647);
1142
1143
1144 descriptions.add("testProducerWithPsetDesc", iDesc);
1145
1146
1147
1148 edm::ParameterSetDescription iDesc1 = description(1);
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 }
1220 using edmtest::ProducerWithPSetDesc;
1221 DEFINE_FWK_MODULE(ProducerWithPSetDesc);