Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-08 02:27:19

0001 #include "FWCore/Integration/test/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.  I guess pointing to itself cannot ever fail ...
0308     edm::FileInPath fileInPath("FWCore/Integration/test/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") == std::vector<std::string>());
0465       assert(psetAllowed.getUntrackedParameter<std::vector<std::string>>("testAllowedLabelsUntracked") ==
0466              std::vector<std::string>());
0467       assert(!psetAllowed.exists("testOptAllowedLabels"));
0468       assert(!psetAllowed.exists("testOptAllowedLabelsUntracked"));
0469     }
0470 
0471     produces<ThingCollection>();
0472   }
0473 
0474   void ProducerWithPSetDesc::produce(edm::StreamID, edm::Event& e, edm::EventSetup const&) const {
0475     // This serves no purpose, I just put it here so the module does something
0476     // Probably could just make this method do nothing and it would not
0477     // affect the test.
0478     auto result = std::make_unique<ThingCollection>();  //Empty
0479     e.put(std::move(result));
0480   }
0481 
0482   void ProducerWithPSetDesc::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0483     edm::ParameterSetDescription iDesc;
0484 
0485     // Try to exercise the description code by adding all different
0486     // types of parameters with a large range of values.  Also
0487     // nested ParameterSets and vectors of them at the end.
0488 
0489     iDesc.addOptionalUntracked<bool>("testingAutoGeneratedCfi", true);
0490 
0491     edm::ParameterDescriptionNode* pn;
0492     pn = iDesc.add<int>("p_int", 2147483647);
0493     pn->setComment(
0494         "A big integer. I am trying to test the wrapping of comments in"
0495         " the printed output by putting in a long comment to see if it gets"
0496         " wrapped OK. The comment should get indented to the second column"
0497         " indent on every line. By default newlines should be inserted between"
0498         " words to make the lines fit in the terminal screen width. There is "
0499         "a command line parameter that can be set to override this width to "
0500         "any desired value. If there is no terminal then it should default to "
0501         "80. The logic for setting the width is in edmPluginHelp.cpp");
0502 
0503     iDesc.addUntracked<int>("p_int_untracked", -2147483647);
0504     iDesc.addOptional<int>("p_int_opt", 0);
0505     iDesc.addOptionalUntracked<int>("p_int_optuntracked", 7);
0506     iDesc.addOptional<int>("p_int_opt_nd");
0507     iDesc.addOptionalUntracked<int>("p_int_optuntracked_nd");
0508 
0509     std::vector<int> vint;
0510     iDesc.add<std::vector<int>>("vint1", vint);
0511     vint.push_back(2147483647);
0512     iDesc.add<std::vector<int>>(std::string("vint2"), vint);
0513     vint.push_back(-2147483647);
0514     iDesc.add<std::vector<int>>("vint3", vint);
0515     vint.push_back(0);
0516     iDesc.add<std::vector<int>>("vint4", vint);
0517 
0518     iDesc.add<unsigned>("uint1", 4294967295U);
0519     iDesc.addUntracked<unsigned>("uint2", 0);
0520 
0521     std::vector<unsigned> vuint;
0522     iDesc.add<std::vector<unsigned>>("vuint1", vuint);
0523     vuint.push_back(4294967295U);
0524     iDesc.add<std::vector<unsigned>>("vuint2", vuint);
0525     vuint.push_back(0);
0526     iDesc.add<std::vector<unsigned>>("vuint3", vuint);
0527     vuint.push_back(11);
0528     iDesc.add<std::vector<unsigned>>("vuint4", vuint);
0529     vuint.push_back(21);
0530     vuint.push_back(31);
0531     vuint.push_back(41);
0532     iDesc.add<std::vector<unsigned>>("vuint5", vuint);
0533 
0534     iDesc.add<long long>("int64v1", 9000000000000000000LL);
0535     iDesc.add<long long>("int64v2", -9000000000000000000LL);
0536     iDesc.add<long long>("int64v3", 0);
0537 
0538     std::vector<long long> vint64;
0539     iDesc.add<std::vector<long long>>("vint64v1", vint64);
0540     vint64.push_back(9000000000000000000LL);
0541     iDesc.add<std::vector<long long>>("vint64v2", vint64);
0542     vint64.push_back(-9000000000000000000LL);
0543     iDesc.add<std::vector<long long>>("vint64v3", vint64);
0544     vint64.push_back(0);
0545     iDesc.add<std::vector<long long>>("vint64v4", vint64);
0546 
0547     iDesc.add<unsigned long long>("uint64v1", 18000000000000000000ULL);
0548     iDesc.addUntracked<unsigned long long>("uint64v2", 0);
0549 
0550     std::vector<unsigned long long> vuint64;
0551     iDesc.add<std::vector<unsigned long long>>("vuint64v1", vuint64);
0552     vuint64.push_back(18000000000000000000ULL);
0553     iDesc.add<std::vector<unsigned long long>>("vuint64v2", vuint64);
0554     vuint64.push_back(0);
0555     iDesc.add<std::vector<unsigned long long>>("vuint64v3", vuint64);
0556     vuint64.push_back(11);
0557     iDesc.add<std::vector<unsigned long long>>("vuint64v4", vuint64);
0558 
0559     iDesc.add<double>("doublev1", std::numeric_limits<double>::min());
0560     iDesc.addUntracked<double>("doublev2", 0.0);
0561     iDesc.addUntracked<double>("doublev3", 0.3);
0562 
0563     std::vector<double> vdouble;
0564     iDesc.add<std::vector<double>>("vdoublev1", vdouble);
0565     // cmsRun will fail with a value this big
0566     // vdouble.push_back(std::numeric_limits<double>::max());
0567     // This works though
0568     vdouble.push_back(1e+300);
0569     iDesc.add<std::vector<double>>("vdoublev2", vdouble);
0570     vdouble.push_back(0.0);
0571     iDesc.add<std::vector<double>>("vdoublev3", vdouble);
0572     vdouble.push_back(11.0);
0573     iDesc.add<std::vector<double>>("vdoublev4", vdouble);
0574     vdouble.push_back(0.3);
0575     iDesc.add<std::vector<double>>("vdoublev5", vdouble);
0576 
0577     iDesc.add<bool>("boolv1", true);
0578     iDesc.add<bool>("boolv2", false);
0579 
0580     std::string test("Hello");
0581     iDesc.add<std::string>("stringv1", test);
0582     test.clear();
0583     iDesc.add<std::string>("stringv2", test);
0584 
0585     std::vector<std::string> vstring;
0586     iDesc.add<std::vector<std::string>>("vstringv1", vstring);
0587     test = "Hello";
0588     vstring.push_back(test);
0589     iDesc.add<std::vector<std::string>>("vstringv2", vstring);
0590     test = "World";
0591     vstring.push_back(test);
0592     iDesc.add<std::vector<std::string>>("vstringv3", vstring);
0593     test = "";
0594     vstring.push_back(test);
0595     iDesc.add<std::vector<std::string>>("vstringv4", vstring);
0596 
0597     edm::EventID eventID(11, 0, 12);
0598     iDesc.add<edm::EventID>("eventIDv1", eventID);
0599     edm::EventID eventID2(101, 0, 102);
0600     iDesc.add<edm::EventID>("eventIDv2", eventID2);
0601     std::vector<edm::EventID> vEventID;
0602     iDesc.add<std::vector<edm::EventID>>("vEventIDv1", vEventID);
0603     edm::EventID eventID3(1000, 0, 1100);
0604     vEventID.push_back(eventID3);
0605     iDesc.add<std::vector<edm::EventID>>("vEventIDv2", vEventID);
0606     edm::EventID eventID4(10000, 0, 11000);
0607     vEventID.push_back(eventID4);
0608     iDesc.add<std::vector<edm::EventID>>("vEventIDv3", vEventID);
0609     edm::EventID eventID5(100000, 0, 110000);
0610     vEventID.push_back(eventID5);
0611     iDesc.add<std::vector<edm::EventID>>("vEventIDv4", vEventID);
0612 
0613     edm::LuminosityBlockID luminosityID(11, 12);
0614     iDesc.add<edm::LuminosityBlockID>("luminosityIDv1", luminosityID);
0615     edm::LuminosityBlockID luminosityID2(101, 102);
0616     iDesc.add<edm::LuminosityBlockID>("luminosityIDv2", luminosityID2);
0617 
0618     std::vector<edm::LuminosityBlockID> vLuminosityBlockID;
0619     iDesc.add<std::vector<edm::LuminosityBlockID>>("vLuminosityBlockIDv1", vLuminosityBlockID);
0620     edm::LuminosityBlockID luminosityID3(1000, 1100);
0621     vLuminosityBlockID.push_back(luminosityID3);
0622     iDesc.add<std::vector<edm::LuminosityBlockID>>("vLuminosityBlockIDv2", vLuminosityBlockID);
0623     edm::LuminosityBlockID luminosityID4(10000, 11000);
0624     vLuminosityBlockID.push_back(luminosityID4);
0625     iDesc.add<std::vector<edm::LuminosityBlockID>>("vLuminosityBlockIDv3", vLuminosityBlockID);
0626     edm::LuminosityBlockID luminosityID5(100000, 110000);
0627     vLuminosityBlockID.push_back(luminosityID5);
0628     iDesc.add<std::vector<edm::LuminosityBlockID>>("vLuminosityBlockIDv4", vLuminosityBlockID);
0629 
0630     edm::LuminosityBlockRange lumiRange(1, 1, 9, 9);
0631     iDesc.add<edm::LuminosityBlockRange>("lumiRangev1", lumiRange);
0632     edm::LuminosityBlockRange lumiRange2(3, 4, 1000, 1000);
0633     iDesc.add<edm::LuminosityBlockRange>("lumiRangev2", lumiRange2);
0634 
0635     std::vector<edm::LuminosityBlockRange> vLumiRange;
0636     iDesc.add<std::vector<edm::LuminosityBlockRange>>("vLumiRangev1", vLumiRange);
0637     vLumiRange.push_back(lumiRange);
0638     iDesc.add<std::vector<edm::LuminosityBlockRange>>("vLumiRangev2", vLumiRange);
0639     vLumiRange.push_back(lumiRange2);
0640     iDesc.add<std::vector<edm::LuminosityBlockRange>>("vLumiRangev3", vLumiRange);
0641 
0642     edm::EventRange eventRange(1, 0, 1, 8, 0, 8);
0643     iDesc.add<edm::EventRange>("eventRangev1", eventRange);
0644     edm::EventRange eventRange2(3, 0, 4, 1001, 0, 1002);
0645     iDesc.add<edm::EventRange>("eventRangev2", eventRange2);
0646 
0647     std::vector<edm::EventRange> vEventRange;
0648     iDesc.add<std::vector<edm::EventRange>>("vEventRangev1", vEventRange);
0649     vEventRange.push_back(eventRange);
0650     iDesc.add<std::vector<edm::EventRange>>("vEventRangev2", vEventRange);
0651     vEventRange.push_back(eventRange2);
0652     iDesc.add<std::vector<edm::EventRange>>("vEventRangev3", vEventRange);
0653 
0654     edm::InputTag inputTag("One", "Two", "Three");
0655     iDesc.add<edm::InputTag>("inputTagv1", inputTag);
0656     edm::InputTag inputTag2("One", "Two");
0657     iDesc.add<edm::InputTag>("inputTagv2", inputTag2);
0658     edm::InputTag inputTag3("One");
0659     iDesc.add<edm::InputTag>("inputTagv3", inputTag3);
0660     edm::InputTag inputTag4("One", "", "Three");
0661     iDesc.add<edm::InputTag>("inputTagv4", inputTag4);
0662 
0663     std::vector<edm::InputTag> vInputTag;
0664     iDesc.add<std::vector<edm::InputTag>>("vInputTagv1", vInputTag);
0665     vInputTag.push_back(inputTag);
0666     iDesc.add<std::vector<edm::InputTag>>("vInputTagv2", vInputTag);
0667     vInputTag.push_back(inputTag2);
0668     iDesc.add<std::vector<edm::InputTag>>("vInputTagv3", vInputTag);
0669     vInputTag.push_back(inputTag3);
0670     iDesc.add<std::vector<edm::InputTag>>("vInputTagv4", vInputTag);
0671     vInputTag.push_back(inputTag4);
0672     iDesc.add<std::vector<edm::InputTag>>("vInputTagv5", vInputTag);
0673 
0674     edm::ESInputTag esinputTag("One", "Two");
0675     iDesc.add<edm::ESInputTag>("esinputTagv1", esinputTag);
0676     edm::ESInputTag esinputTag2("One", "");
0677     iDesc.add<edm::ESInputTag>("esinputTagv2", esinputTag2);
0678     edm::ESInputTag esinputTag3("", "Two");
0679     iDesc.add<edm::ESInputTag>("esinputTagv3", esinputTag3);
0680 
0681     std::vector<edm::ESInputTag> vESInputTag;
0682     iDesc.add<std::vector<edm::ESInputTag>>("vESInputTagv1", vESInputTag);
0683     vESInputTag.push_back(esinputTag);
0684     iDesc.add<std::vector<edm::ESInputTag>>("vESInputTagv2", vESInputTag);
0685     vESInputTag.push_back(esinputTag2);
0686     iDesc.add<std::vector<edm::ESInputTag>>("vESInputTagv3", vESInputTag);
0687     vESInputTag.push_back(esinputTag3);
0688     iDesc.add<std::vector<edm::ESInputTag>>("vESInputTagv4", vESInputTag);
0689 
0690     // For purposes of the test, this just needs to point to any file
0691     // that exists.  I guess pointing to itself cannot ever fail ...
0692     edm::FileInPath fileInPath("FWCore/Integration/test/ProducerWithPSetDesc.cc");
0693     iDesc.add<edm::FileInPath>("fileInPath", fileInPath);
0694 
0695     edm::EmptyGroupDescription emptyGroup;
0696     iDesc.addNode(emptyGroup);
0697 
0698     edm::ParameterSetDescription bar;
0699     bar.add<unsigned int>("Drinks", 5);
0700     bar.addUntracked<unsigned int>("uDrinks", 5);
0701     bar.addOptional<unsigned int>("oDrinks", 5);
0702     bar.addOptionalUntracked<unsigned int>("ouDrinks", 5);
0703     iDesc.add("bar", bar);
0704 
0705     edm::ParameterDescription<edm::ParameterSetDescription> test101("test101", bar, true);
0706     iDesc.addOptionalNode(test101, false);
0707 
0708     edm::ParameterSetDescription barx;
0709     barx.add<unsigned int>("Drinks", 5);
0710     barx.addUntracked<unsigned int>("uDrinks", 5);
0711     barx.addOptional<unsigned int>("oDrinks", 5);
0712     barx.addOptionalUntracked<unsigned int>("ouDrinks", 5);
0713     barx.addOptional<unsigned int>("ndoDrinks");
0714     barx.addOptionalUntracked<unsigned int>("ndouDrinks");
0715 
0716     edm::ParameterDescription<std::vector<edm::ParameterSet>> test102("test102", edm::ParameterSetDescription(), true);
0717     iDesc.addOptionalNode(test102, false);
0718 
0719     edm::ParameterDescription<std::vector<edm::ParameterSet>> test103(std::string("test103"), barx, true);
0720     iDesc.addOptionalNode(test103, false);
0721 
0722     std::vector<edm::ParameterSet> defaultVPSet104;
0723     defaultVPSet104.push_back(edm::ParameterSet());
0724     edm::ParameterDescription<std::vector<edm::ParameterSet>> test104(
0725         std::string("test104"), barx, false, defaultVPSet104);
0726     iDesc.addNode(test104);
0727 
0728     std::vector<edm::ParameterSet> defaultVPSet105;
0729     edm::ParameterDescription<std::vector<edm::ParameterSet>> test105(
0730         std::string("test105"), barx, false, defaultVPSet105);
0731     iDesc.addNode(test105);
0732 
0733     double d1 = 0.1;
0734     double d2 = 0.2;
0735     double d3 = 0.3;
0736     iDesc.addNode(edm::ParameterDescription<double>("test1", d1, true));
0737     iDesc.addOptionalNode(edm::ParameterDescription<double>("test2", d2, true), true);
0738     // The value in the second argument is not used in this case
0739     iDesc.addOptionalNode(edm::ParameterDescription<double>("test3", d3, true), false);
0740 
0741     iDesc.addOptionalNode(edm::ParameterDescription<std::string>("testA", "fooA", true) and
0742                               edm::ParameterDescription<int>("testB", 100, true) &&
0743                               edm::ParameterDescription<int>("testC", 101, true),
0744                           true);
0745 
0746     iDesc.ifValueOptional(edm::ParameterDescription<int>("oiswitch", 1, true),
0747                           0 >> edm::ParameterDescription<int>("oivalue", 100, true) or
0748                               1 >> (edm::ParameterDescription<double>("oivalue1", 101.0, true) and
0749                                     edm::ParameterDescription<double>("oivalue2", 101.0, true)) or
0750                               2 >> edm::ParameterDescription<std::string>("oivalue", "102", true),
0751                           true);
0752 
0753     edm::ParameterSetDescription deeplyNested;
0754 
0755     bool case0 = true;
0756     bool case1 = false;
0757     deeplyNested.ifValue(edm::ParameterDescription<bool>("bswitch", false, true),
0758                          case0 >> edm::ParameterDescription<int>("bvalue", 100, true) or
0759                              case1 >> (edm::ParameterDescription<double>("bvalue1", 101.0, true) and
0760                                        edm::ParameterDescription<double>("bvalue2", 101.0, true)));
0761     deeplyNested.ifValue(edm::ParameterDescription<int>("iswitch", 1, true),
0762                          0 >> edm::ParameterDescription<int>("ivalue", 100, true) or
0763                              1 >> (edm::ParameterDescription<double>("ivalue1", 101.0, true) and
0764                                    edm::ParameterDescription<double>("ivalue2", 101.0, false)) or
0765                              2 >> edm::ParameterDescription<std::string>("ivalue", "102", true));
0766     deeplyNested.ifValue(edm::ParameterDescription<std::string>("sswitch", std::string("1"), true),
0767                          std::string("0") >> edm::ParameterDescription<int>("svalue", 100, true) or
0768                              "1" >> (edm::ParameterDescription<double>("svalue1", 101.0, true) and
0769                                      edm::ParameterDescription<double>("svalue2", 101.0, true)) or
0770                              "2" >> edm::ParameterDescription<std::string>("svalue", "102", true));
0771 
0772     deeplyNested.ifValueOptional(edm::ParameterDescription<int>("ndiswitch", 1, true),
0773                                  0 >> edm::ParameterDescription<int>("ndivalue", 100, true) or
0774                                      1 >> (edm::ParameterDescription<double>("ndivalue1", 101.0, true) and
0775                                            edm::ParameterDescription<double>("ndivalue2", 101.0, true)) or
0776                                      2 >> edm::ParameterDescription<std::string>("ndivalue", "102", true),
0777                                  false);
0778 
0779     deeplyNested.add<int>("testint", 1000);
0780 
0781     barx.add("testDeeplyNested", deeplyNested);
0782 
0783     iDesc.add("testDeeplyNested2", deeplyNested);
0784 
0785     edm::ParameterSetDescription validator;
0786     validator.add<int>("xvalue", 7);
0787     std::vector<edm::ParameterSet> vDefaults;
0788     edm::ParameterSet vDefaults0;
0789     vDefaults.push_back(vDefaults0);
0790     edm::ParameterSet vDefaults1;
0791     vDefaults1.addParameter<int>("xvalue", 100);
0792     vDefaults.push_back(vDefaults1);
0793     barx.addVPSet("anotherVPSet", validator, vDefaults);
0794 
0795     std::vector<edm::ParameterSet> defaultVPSet;
0796 
0797     edm::ParameterSet psetInVector1;
0798     psetInVector1.addParameter<unsigned int>("oDrinks", 11U);
0799     defaultVPSet.push_back(psetInVector1);
0800 
0801     edm::ParameterSet psetInVector2;
0802     psetInVector2.addParameter<unsigned int>("oDrinks", 11U);
0803     psetInVector2.addUntrackedParameter<unsigned int>("ouDrinks", 11U);
0804     psetInVector2.addUntrackedParameter<unsigned int>("ndouDrinks", 11U);
0805 
0806     std::vector<edm::ParameterSet> anotherDefaultVPSet;
0807     anotherDefaultVPSet.push_back(edm::ParameterSet());
0808     edm::ParameterSet anotherParameterSet;
0809     anotherParameterSet.addParameter<int>("xvalue", 17);
0810     anotherDefaultVPSet.push_back(anotherParameterSet);
0811     psetInVector2.addParameter<std::vector<edm::ParameterSet>>("anotherVPSet", anotherDefaultVPSet);
0812 
0813     edm::ParameterSet defaultForDeeplyNested;
0814     defaultForDeeplyNested.addParameter<int>("testint", 2);
0815     psetInVector2.addParameter<edm::ParameterSet>("testDeeplyNested", defaultForDeeplyNested);
0816 
0817     defaultVPSet.push_back(psetInVector2);
0818 
0819     iDesc.addVPSet("bars", barx, defaultVPSet);
0820 
0821     // Alternate way to add a ParameterSetDescription
0822     edm::ParameterDescriptionBase* parDescription;
0823     parDescription = iDesc.addOptional("subpset", edm::ParameterSetDescription());
0824     edm::ParameterSetDescription* subPsetDescription = parDescription->parameterSetDescription();
0825 
0826     subPsetDescription->add<int>("xvalue", 11);
0827     subPsetDescription->addUntracked<edm::ParameterSetDescription>(std::string("bar"), bar);
0828 
0829     // -----------------------------------------------
0830 
0831     edm::ParameterSetDescription wildcardPset;
0832     wildcardPset.addOptional<unsigned>("p_uint_opt", 0);
0833     wildcardPset.addWildcard<int>("*");
0834     pn = wildcardPset.addWildcardUntracked<double>(std::string("*"));
0835     pn->setComment("A comment for a wildcard parameter");
0836 
0837     std::unique_ptr<edm::ParameterDescriptionNode> wnode =
0838         std::make_unique<edm::ParameterWildcard<edm::ParameterSetDescription>>("*", edm::RequireExactlyOne, true);
0839     wildcardPset.addOptionalNode(std::move(wnode), false);
0840 
0841     edm::ParameterSetDescription wSet1;
0842     wSet1.add<unsigned int>("Drinks", 5);
0843 
0844     std::unique_ptr<edm::ParameterDescriptionNode> wnode2 =
0845         std::make_unique<edm::ParameterWildcard<edm::ParameterSetDescription>>(
0846             "*", edm::RequireAtLeastOne, true, wSet1);
0847     wildcardPset.addOptionalNode(std::move(wnode2), false);
0848 
0849     std::unique_ptr<edm::ParameterDescriptionNode> wnode3 =
0850         std::make_unique<edm::ParameterWildcard<std::vector<edm::ParameterSet>>>("*", edm::RequireExactlyOne, true);
0851     wildcardPset.addOptionalNode(std::move(wnode3), false);
0852 
0853     wSet1.add<unsigned int>("Drinks2", 11);
0854 
0855     std::unique_ptr<edm::ParameterDescriptionNode> wnode4 =
0856         std::make_unique<edm::ParameterWildcard<std::vector<edm::ParameterSet>>>(
0857             "*", edm::RequireAtLeastOne, true, wSet1);
0858     wildcardPset.addOptionalNode(std::move(wnode4), false);
0859 
0860     iDesc.add("wildcardPset", wildcardPset);
0861 
0862     // ---------------------------------------------
0863 
0864     std::vector<int> testIntVector;
0865     testIntVector.push_back(21);
0866     testIntVector.push_back(22);
0867     edm::ParameterSetDescription switchPset;
0868     pn = switchPset.ifValue(edm::ParameterDescription<int>("iswitch", 1, true),
0869                             0 >> edm::ParameterDescription<std::vector<int>>("ivalue", testIntVector, true) or
0870                                 1 >> (edm::ParameterDescription<double>("ivalue1", 101.0, true) and
0871                                       edm::ParameterDescription<double>("ivalue2", 101.0, true)) or
0872                                 2 >> edm::ParameterDescription<std::string>("ivalue", "102", true));
0873     pn->setComment("Comment for a ParameterSwitch");
0874 
0875     switchPset
0876         .ifValue(edm::ParameterDescription<bool>("addTeVRefits", true, true),
0877                  true >> (edm::ParameterDescription<edm::InputTag>("pickySrc", edm::InputTag(), true) and
0878                           edm::ParameterDescription<edm::InputTag>("tpfmsSrc", edm::InputTag(), true)) or
0879                      false >> edm::EmptyGroupDescription())
0880         ->setComment("If TeV refits are added, their sources need to be specified");
0881 
0882     iDesc.add("switchPset", switchPset);
0883 
0884     // -----------------------------------------------
0885 
0886     edm::ParameterSetDescription xorPset;
0887     xorPset.addNode(edm::ParameterDescription<std::string>("name", "11", true) xor
0888                     edm::ParameterDescription<unsigned int>("name", 11U, true));
0889 
0890     xorPset.addNode(edm::ParameterDescription<std::string>("name1", "11", true) xor
0891                     edm::ParameterDescription<unsigned int>("name1", 11U, true));
0892 
0893     xorPset.addOptionalNode(edm::ParameterDescription<std::string>("name2", "11", true) xor
0894                                 edm::ParameterDescription<unsigned int>("name2", 11U, true),
0895                             false);
0896 
0897     xorPset.addNode(edm::ParameterDescription<std::string>("name3", "11", true) xor
0898                     edm::ParameterDescription<unsigned int>("name4", 11U, true) xor test101 xor test103);
0899 
0900     iDesc.add("xorPset", xorPset);
0901 
0902     // -----------------------------------------
0903 
0904     edm::ParameterSetDescription orPset;
0905 
0906     orPset.addNode(edm::ParameterDescription<std::string>("x1", "11", true) or
0907                    edm::ParameterDescription<unsigned int>("x2", 11U, true));
0908 
0909     orPset.addNode(edm::ParameterDescription<std::string>("y1", "11", true) or
0910                    edm::ParameterDescription<unsigned int>("y2", 11U, true));
0911 
0912     orPset.addOptionalNode(edm::ParameterDescription<std::string>("z1", "11", true) or
0913                                edm::ParameterDescription<unsigned int>("z2", 11U, true) or test101 or test103,
0914                            false);
0915 
0916     iDesc.add("orPset", orPset);
0917 
0918     // ------------------------------------------------
0919 
0920     edm::ParameterSetDescription andPset;
0921 
0922     andPset.addNode(edm::ParameterDescription<std::string>("x1", "11", true) and
0923                     edm::ParameterDescription<unsigned int>("x2", 11U, true));
0924 
0925     andPset.addNode(edm::ParameterDescription<std::string>("y1", "11", true) and
0926                     edm::ParameterDescription<unsigned int>("y2", 11U, true));
0927 
0928     andPset.addNode(edm::ParameterDescription<std::string>("z1", "11", true) and
0929                     edm::ParameterDescription<unsigned int>("z2", 11U, true));
0930 
0931     andPset.addOptionalNode(edm::ParameterDescription<std::string>("a1", "11", true) and
0932                                 edm::ParameterDescription<unsigned int>("a2", 11U, true),
0933                             false);
0934 
0935     andPset.addOptionalNode((edm::ParameterDescription<std::string>("b1", "11", true) and
0936                              edm::ParameterDescription<unsigned int>("b2", 11U, true)) and
0937                                 edm::ParameterDescription<unsigned int>("b3", 11U, true) and
0938                                 (edm::ParameterDescription<unsigned int>("b4", 11U, true) and
0939                                  (edm::ParameterDescription<unsigned int>("b5", 11U, true) and
0940                                   edm::ParameterDescription<unsigned int>("b6", 11U, true))),
0941                             true);
0942 
0943     iDesc.add("andPset", andPset);
0944 
0945     // --------------------------------------
0946 
0947     edm::ParameterSetDescription ifExistsPset;
0948 
0949     ifExistsPset.ifExists(edm::ParameterDescription<unsigned int>("x1", 11U, true),
0950                           edm::ParameterDescription<std::string>("x2", "11", true));
0951 
0952     ifExistsPset.ifExistsOptional(edm::ParameterDescription<unsigned int>("y1", 11U, true),
0953                                   edm::ParameterDescription<std::string>("y2", "11", true),
0954                                   false);
0955 
0956     ifExistsPset.ifExists(edm::ParameterDescription<unsigned int>("z1", 11U, true),
0957                           edm::ParameterDescription<std::string>("z2", "11", true));
0958 
0959     iDesc.add("ifExistsPset", ifExistsPset);
0960 
0961     // ------------------------------------------
0962 
0963     edm::ParameterSetDescription allowedLabelsPset;
0964 
0965     allowedLabelsPset.addOptional<int>("p_int_opt", 0);
0966     allowedLabelsPset.labelsFrom<int>("testAllowedLabels");
0967     allowedLabelsPset.labelsFromUntracked<unsigned>(std::string("testAllowedLabelsUntracked"));
0968     allowedLabelsPset.labelsFromOptional<int>("testOptAllowedLabels", false);
0969     allowedLabelsPset.labelsFromOptionalUntracked<unsigned>(std::string("testOptAllowedLabelsUntracked"), false);
0970     allowedLabelsPset.labelsFromOptionalUntracked<edm::ParameterSetDescription>(std::string("testWithSet"), true, bar);
0971 
0972     allowedLabelsPset.labelsFromOptionalUntracked<std::vector<edm::ParameterSet>>(
0973         std::string("testWithVectorOfSets"), true, bar);
0974 
0975     iDesc.add("allowedLabelsPset", allowedLabelsPset);
0976 
0977     edm::ParameterSetDescription noDefaultPset3;
0978 
0979     noDefaultPset3.addOptional<int>(std::string("noDefault1"));
0980     noDefaultPset3.addOptional<std::vector<int>>("noDefault2");
0981     noDefaultPset3.addOptional<unsigned>("noDefault3");
0982     noDefaultPset3.addOptional<std::vector<unsigned>>("noDefault4");
0983     noDefaultPset3.addOptional<long long>("noDefault5");
0984     noDefaultPset3.addOptional<std::vector<long long>>("noDefault6");
0985     noDefaultPset3.addOptional<unsigned long long>("noDefault7");
0986     noDefaultPset3.addOptional<std::vector<unsigned long long>>("noDefault8");
0987     noDefaultPset3.addOptional<double>("noDefault9");
0988     noDefaultPset3.addOptional<std::vector<double>>("noDefault10");
0989     noDefaultPset3.addOptional<bool>("noDefault11");
0990     noDefaultPset3.addOptional<std::string>("noDefault12");
0991     noDefaultPset3.addOptional<std::vector<std::string>>("noDefault13");
0992     noDefaultPset3.addOptional<edm::EventID>("noDefault14");
0993     noDefaultPset3.addOptional<std::vector<edm::EventID>>("noDefault15");
0994     noDefaultPset3.addOptional<edm::LuminosityBlockID>("noDefault16");
0995     noDefaultPset3.addOptional<std::vector<edm::LuminosityBlockID>>("noDefault17");
0996     noDefaultPset3.addOptional<edm::InputTag>("noDefault18");
0997     noDefaultPset3.addOptional<std::vector<edm::InputTag>>("noDefault19");
0998     noDefaultPset3.addOptional<edm::FileInPath>("noDefault20");
0999     noDefaultPset3.addOptional<edm::LuminosityBlockRange>("noDefault21");
1000     noDefaultPset3.addOptional<std::vector<edm::LuminosityBlockRange>>("noDefault22");
1001     noDefaultPset3.addOptional<edm::EventRange>("noDefault23");
1002     noDefaultPset3.addOptional<std::vector<edm::EventRange>>("noDefault24");
1003 
1004     iDesc.add("noDefaultPset3", noDefaultPset3);
1005 
1006     edm::ParameterSetDescription noDefaultPset4;
1007 
1008     noDefaultPset4.addOptionalUntracked<int>(std::string("noDefault1"));
1009     noDefaultPset4.addOptionalUntracked<std::vector<int>>("noDefault2");
1010     noDefaultPset4.addOptionalUntracked<unsigned>("noDefault3");
1011     noDefaultPset4.addOptionalUntracked<std::vector<unsigned>>("noDefault4");
1012     noDefaultPset4.addOptionalUntracked<long long>("noDefault5");
1013     noDefaultPset4.addOptionalUntracked<std::vector<long long>>("noDefault6");
1014     noDefaultPset4.addOptionalUntracked<unsigned long long>("noDefault7");
1015     noDefaultPset4.addOptionalUntracked<std::vector<unsigned long long>>("noDefault8");
1016     noDefaultPset4.addOptionalUntracked<double>("noDefault9");
1017     noDefaultPset4.addOptionalUntracked<std::vector<double>>("noDefault10");
1018     noDefaultPset4.addOptionalUntracked<bool>("noDefault11");
1019     noDefaultPset4.addOptionalUntracked<std::string>("noDefault12");
1020     noDefaultPset4.addOptionalUntracked<std::vector<std::string>>("noDefault13");
1021     noDefaultPset4.addOptionalUntracked<edm::EventID>("noDefault14");
1022     noDefaultPset4.addOptionalUntracked<std::vector<edm::EventID>>("noDefault15");
1023     noDefaultPset4.addOptionalUntracked<edm::LuminosityBlockID>("noDefault16");
1024     noDefaultPset4.addOptionalUntracked<std::vector<edm::LuminosityBlockID>>("noDefault17");
1025     noDefaultPset4.addOptionalUntracked<edm::InputTag>("noDefault18");
1026     noDefaultPset4.addOptionalUntracked<std::vector<edm::InputTag>>("noDefault19");
1027     noDefaultPset4.addOptionalUntracked<edm::FileInPath>("noDefault20");
1028     noDefaultPset4.addOptionalUntracked<edm::LuminosityBlockRange>("noDefault21");
1029     noDefaultPset4.addOptionalUntracked<std::vector<edm::LuminosityBlockRange>>("noDefault22");
1030     noDefaultPset4.addOptionalUntracked<edm::EventRange>("noDefault23");
1031     noDefaultPset4.addOptionalUntracked<std::vector<edm::EventRange>>("noDefault24");
1032 
1033     iDesc.add("noDefaultPset4", noDefaultPset4);
1034 
1035     edm::ParameterSetDescription pluginDesc;
1036     pluginDesc.addNode(edm::PluginDescription<AnotherIntFactory>("type", "edmtestAnotherValueMaker", true));
1037     iDesc.add<edm::ParameterSetDescription>("plugin", pluginDesc);
1038 
1039     edm::ParameterSetDescription pluginDesc1;
1040     pluginDesc1.addNode(edm::PluginDescription<AnotherIntFactory>("type", true));
1041     iDesc.add<edm::ParameterSetDescription>("plugin1", pluginDesc1);
1042 
1043     edm::ParameterSetDescription pluginDesc2;
1044     pluginDesc2.addNode(edm::PluginDescription<AnotherIntFactory>("type", true));
1045     std::vector<edm::ParameterSet> vDefaultsPlugins2;
1046     iDesc.addVPSet("plugin2", pluginDesc2, vDefaultsPlugins2);
1047 
1048     edm::ParameterSetDescription pluginDesc3;
1049     pluginDesc3.addNode(edm::PluginDescription<AnotherIntFactory>("type", true));
1050     std::vector<edm::ParameterSet> vDefaultsPlugins3;
1051     edm::ParameterSet vpsetDefault0;
1052     vpsetDefault0.addParameter<std::string>("type", "edmtestAnotherOneMaker");
1053     vDefaultsPlugins3.push_back(vpsetDefault0);
1054     edm::ParameterSet vpsetDefault1;
1055     vpsetDefault1.addParameter<std::string>("type", "edmtestAnotherValueMaker");
1056     vpsetDefault1.addParameter<int>("value", 11);
1057     vDefaultsPlugins3.push_back(vpsetDefault1);
1058 
1059     iDesc.addVPSet("plugin3", pluginDesc3, vDefaultsPlugins3);
1060 
1061     // ------------------------------------------
1062 
1063     descriptions.add("testProducerWithPsetDesc", iDesc);
1064 
1065     // ------------------------------------------
1066 
1067     edm::ParameterSetDescription iDesc1;
1068     iDesc1.add<int>("p_int", 1);
1069     iDesc1.setAllowAnything();
1070     iDesc1.setComment("A comment for a ParameterSetDescription");
1071 
1072     edm::ParameterSetDescription noDefaultPset1;
1073 
1074     noDefaultPset1.add<int>(std::string("noDefault1"));
1075     noDefaultPset1.add<std::vector<int>>("noDefault2");
1076     noDefaultPset1.add<unsigned>("noDefault3");
1077     noDefaultPset1.add<std::vector<unsigned>>("noDefault4");
1078     noDefaultPset1.add<long long>("noDefault5");
1079     noDefaultPset1.add<std::vector<long long>>("noDefault6");
1080     noDefaultPset1.add<unsigned long long>("noDefault7");
1081     noDefaultPset1.add<std::vector<unsigned long long>>("noDefault8");
1082     noDefaultPset1.add<double>("noDefault9");
1083     noDefaultPset1.add<std::vector<double>>("noDefault10");
1084     noDefaultPset1.add<bool>("noDefault11");
1085     noDefaultPset1.add<std::string>("noDefault12");
1086     noDefaultPset1.add<std::vector<std::string>>("noDefault13");
1087     noDefaultPset1.add<edm::EventID>("noDefault14");
1088     noDefaultPset1.add<std::vector<edm::EventID>>("noDefault15");
1089     noDefaultPset1.add<edm::LuminosityBlockID>("noDefault16");
1090     noDefaultPset1.add<std::vector<edm::LuminosityBlockID>>("noDefault17");
1091     noDefaultPset1.add<edm::InputTag>("noDefault18");
1092     noDefaultPset1.add<std::vector<edm::InputTag>>("noDefault19");
1093     noDefaultPset1.add<edm::FileInPath>("noDefault20");
1094     noDefaultPset1.add<edm::LuminosityBlockRange>("noDefault21");
1095     noDefaultPset1.add<std::vector<edm::LuminosityBlockRange>>("noDefault22");
1096     noDefaultPset1.add<edm::EventRange>("noDefault23");
1097     noDefaultPset1.add<std::vector<edm::EventRange>>("noDefault24");
1098 
1099     iDesc1.add("noDefaultPset1", noDefaultPset1);
1100 
1101     edm::ParameterSetDescription noDefaultPset2;
1102 
1103     noDefaultPset2.addUntracked<int>(std::string("noDefault1"));
1104     noDefaultPset2.addUntracked<std::vector<int>>("noDefault2");
1105     noDefaultPset2.addUntracked<unsigned>("noDefault3");
1106     noDefaultPset2.addUntracked<std::vector<unsigned>>("noDefault4");
1107     noDefaultPset2.addUntracked<long long>("noDefault5");
1108     noDefaultPset2.addUntracked<std::vector<long long>>("noDefault6");
1109     noDefaultPset2.addUntracked<unsigned long long>("noDefault7");
1110     noDefaultPset2.addUntracked<std::vector<unsigned long long>>("noDefault8");
1111     noDefaultPset2.addUntracked<double>("noDefault9");
1112     noDefaultPset2.addUntracked<std::vector<double>>("noDefault10");
1113     noDefaultPset2.addUntracked<bool>("noDefault11");
1114     noDefaultPset2.addUntracked<std::string>("noDefault12");
1115     noDefaultPset2.addUntracked<std::vector<std::string>>("noDefault13");
1116     noDefaultPset2.addUntracked<edm::EventID>("noDefault14");
1117     noDefaultPset2.addUntracked<std::vector<edm::EventID>>("noDefault15");
1118     noDefaultPset2.addUntracked<edm::LuminosityBlockID>("noDefault16");
1119     noDefaultPset2.addUntracked<std::vector<edm::LuminosityBlockID>>("noDefault17");
1120     noDefaultPset2.addUntracked<edm::InputTag>("noDefault18");
1121     noDefaultPset2.addUntracked<std::vector<edm::InputTag>>("noDefault19");
1122     noDefaultPset2.addUntracked<edm::FileInPath>("noDefault20");
1123     noDefaultPset2.addUntracked<edm::LuminosityBlockRange>("noDefault21");
1124     noDefaultPset2.addUntracked<std::vector<edm::LuminosityBlockRange>>("noDefault22");
1125     noDefaultPset2.addUntracked<edm::EventRange>("noDefault23");
1126     noDefaultPset2.addUntracked<std::vector<edm::EventRange>>("noDefault24");
1127 
1128     iDesc1.add("noDefaultPset2", noDefaultPset2);
1129     descriptions.add("testLabel1", iDesc1);
1130 
1131     // ------------------------------------------
1132 
1133     edm::ParameterSetDescription iDesc2;
1134     iDesc2.add<int>("p_int", 2);
1135     descriptions.addDefault(iDesc2);
1136 
1137     // ------------------------------------------
1138 
1139     edm::ParameterSetDescription iDesc3;
1140     iDesc3.add<int>("p_int", 3);
1141     descriptions.addWithDefaultLabel(iDesc3);
1142   }
1143 }  // namespace edmtest
1144 using edmtest::ProducerWithPSetDesc;
1145 DEFINE_FWK_MODULE(ProducerWithPSetDesc);