Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:02:54

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