From d3b6963f38c2a99a0683b7303a78c22679e374ec Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Fri, 2 Aug 2019 22:15:33 +0200 Subject: [PATCH] Add support for ESInputTag to ParameterDescription --- .../Integration/test/ProducerWithPSetDesc.cc | 36 +++++++++++++++++++ .../testProducerWithPsetDesc_briefdoc.txt | 13 +++++++ .../testProducerWithPsetDesc_cfi.py | 14 ++++++++ .../testProducerWithPsetDesc_doc.txt | 34 ++++++++++++++++++ .../interface/ParameterDescription.h | 5 +++ .../interface/ParameterDescriptionNode.h | 2 ++ .../ParameterSet/src/ParameterDescription.cc | 25 +++++++++++++ .../src/ParameterDescriptionNode.cc | 5 +++ .../test/parameterSetDescription_t.cc | 12 +++++++ 9 files changed, 146 insertions(+) diff --git a/FWCore/Integration/test/ProducerWithPSetDesc.cc b/FWCore/Integration/test/ProducerWithPSetDesc.cc index 2ba8b6df3a919..510c63e6e365b 100644 --- a/FWCore/Integration/test/ProducerWithPSetDesc.cc +++ b/FWCore/Integration/test/ProducerWithPSetDesc.cc @@ -284,6 +284,26 @@ namespace edmtest { assert(vInputTag[2] == inputTag3); assert(vInputTag[3] == inputTag4); + edm::ESInputTag esinputTag1("One", "Two"); + assert(ps.getParameter("esinputTagv1") == esinputTag1); + edm::ESInputTag esinputTag2("One", ""); + assert(ps.getParameter("esinputTagv2") == esinputTag2); + edm::ESInputTag esinputTag3("", "Two"); + assert(ps.getParameter("esinputTagv3") == esinputTag3); + + std::vector vESInputTag; + vESInputTag = ps.getParameter>("vESInputTagv1"); + assert(vESInputTag.empty()); + vESInputTag = ps.getParameter>("vESInputTagv2"); + assert(vESInputTag[0] == esinputTag1); + vESInputTag = ps.getParameter>("vESInputTagv3"); + assert(vESInputTag[0] == esinputTag1); + assert(vESInputTag[1] == esinputTag2); + vESInputTag = ps.getParameter>("vESInputTagv4"); + assert(vESInputTag[0] == esinputTag1); + assert(vESInputTag[1] == esinputTag2); + assert(vESInputTag[2] == esinputTag3); + // For purposes of the test, this just needs to point to any file // that exists. I guess pointing to itself cannot ever fail ... edm::FileInPath fileInPath("FWCore/Integration/test/ProducerWithPSetDesc.cc"); @@ -654,6 +674,22 @@ namespace edmtest { vInputTag.push_back(inputTag4); iDesc.add>("vInputTagv5", vInputTag); + edm::ESInputTag esinputTag("One", "Two"); + iDesc.add("esinputTagv1", esinputTag); + edm::ESInputTag esinputTag2("One", ""); + iDesc.add("esinputTagv2", esinputTag2); + edm::ESInputTag esinputTag3("", "Two"); + iDesc.add("esinputTagv3", esinputTag3); + + std::vector vESInputTag; + iDesc.add>("vESInputTagv1", vESInputTag); + vESInputTag.push_back(esinputTag); + iDesc.add>("vESInputTagv2", vESInputTag); + vESInputTag.push_back(esinputTag2); + iDesc.add>("vESInputTagv3", vESInputTag); + vESInputTag.push_back(esinputTag3); + iDesc.add>("vESInputTagv4", vESInputTag); + // For purposes of the test, this just needs to point to any file // that exists. I guess pointing to itself cannot ever fail ... edm::FileInPath fileInPath("FWCore/Integration/test/ProducerWithPSetDesc.cc"); diff --git a/FWCore/Integration/test/unit_test_outputs/testProducerWithPsetDesc_briefdoc.txt b/FWCore/Integration/test/unit_test_outputs/testProducerWithPsetDesc_briefdoc.txt index c0980bfdccbf7..63dcce4b9efb5 100644 --- a/FWCore/Integration/test/unit_test_outputs/testProducerWithPsetDesc_briefdoc.txt +++ b/FWCore/Integration/test/unit_test_outputs/testProducerWithPsetDesc_briefdoc.txt @@ -146,6 +146,19 @@ [1]: 'One:Two' [2]: 'One' [3]: 'One::Three' + esinputTagv1 ESInputTag 'One:Two' + esinputTagv2 ESInputTag 'One:' + esinputTagv3 ESInputTag ':Two' + vESInputTagv1 VESInputTag empty + vESInputTagv2 VESInputTag (vector size = 1) + [0]: 'One:Two' + vESInputTagv3 VESInputTag (vector size = 2) + [0]: 'One:Two' + [1]: 'One:' + vESInputTagv4 VESInputTag (vector size = 3) + [0]: 'One:Two' + [1]: 'One:' + [2]: ':Two' fileInPath FileInPath 'FWCore/Integration/test/ProducerWithPSetDesc.cc' Empty group description bar PSet see Section 1.1.2 diff --git a/FWCore/Integration/test/unit_test_outputs/testProducerWithPsetDesc_cfi.py b/FWCore/Integration/test/unit_test_outputs/testProducerWithPsetDesc_cfi.py index 6d326541d3aa4..539e5b920d53a 100644 --- a/FWCore/Integration/test/unit_test_outputs/testProducerWithPsetDesc_cfi.py +++ b/FWCore/Integration/test/unit_test_outputs/testProducerWithPsetDesc_cfi.py @@ -165,6 +165,20 @@ 'One', 'One::Three' ), + esinputTagv1 = cms.ESInputTag('One', 'Two'), + esinputTagv2 = cms.ESInputTag('One', ''), + esinputTagv3 = cms.ESInputTag('', 'Two'), + vESInputTagv1 = cms.VESInputTag(), + vESInputTagv2 = cms.VESInputTag('One:Two'), + vESInputTagv3 = cms.VESInputTag( + 'One:Two', + 'One:' + ), + vESInputTagv4 = cms.VESInputTag( + 'One:Two', + 'One:', + ':Two' + ), fileInPath = cms.FileInPath('FWCore/Integration/test/ProducerWithPSetDesc.cc'), bar = cms.PSet( Drinks = cms.uint32(5), diff --git a/FWCore/Integration/test/unit_test_outputs/testProducerWithPsetDesc_doc.txt b/FWCore/Integration/test/unit_test_outputs/testProducerWithPsetDesc_doc.txt index 615c22bc2edec..d8d9d43f679d5 100644 --- a/FWCore/Integration/test/unit_test_outputs/testProducerWithPsetDesc_doc.txt +++ b/FWCore/Integration/test/unit_test_outputs/testProducerWithPsetDesc_doc.txt @@ -397,6 +397,40 @@ generated for each configuration with a module label. [2]: 'One' [3]: 'One::Three' + esinputTagv1 + type: ESInputTag + default: 'One:Two' + + esinputTagv2 + type: ESInputTag + default: 'One:' + + esinputTagv3 + type: ESInputTag + default: ':Two' + + vESInputTagv1 + type: VESInputTag + default: empty + + vESInputTagv2 + type: VESInputTag + default: (vector size = 1) + [0]: 'One:Two' + + vESInputTagv3 + type: VESInputTag + default: (vector size = 2) + [0]: 'One:Two' + [1]: 'One:' + + vESInputTagv4 + type: VESInputTag + default: (vector size = 3) + [0]: 'One:Two' + [1]: 'One:' + [2]: ':Two' + fileInPath type: FileInPath default: 'FWCore/Integration/test/ProducerWithPSetDesc.cc' diff --git a/FWCore/ParameterSet/interface/ParameterDescription.h b/FWCore/ParameterSet/interface/ParameterDescription.h index 6ef3288a002e2..a3987f07c292c 100644 --- a/FWCore/ParameterSet/interface/ParameterDescription.h +++ b/FWCore/ParameterSet/interface/ParameterDescription.h @@ -37,6 +37,7 @@ namespace edm { class LuminosityBlockRange; class EventRange; class InputTag; + class ESInputTag; class FileInPath; class DocFormatHelper; @@ -73,6 +74,8 @@ namespace edm { void writeValue(std::ostream& os, int indentation, std::vector const& value_, ValueFormat format); void writeValue(std::ostream& os, int indentation, InputTag const& value_, ValueFormat format); void writeValue(std::ostream& os, int indentation, std::vector const& value_, ValueFormat format); + void writeValue(std::ostream& os, int indentation, ESInputTag const& value_, ValueFormat format); + void writeValue(std::ostream& os, int indentation, std::vector const& value_, ValueFormat format); void writeValue(std::ostream& os, int indentation, FileInPath const& value_, ValueFormat format); bool hasNestedContent(int const& value); @@ -98,6 +101,8 @@ namespace edm { bool hasNestedContent(std::vector const& value); bool hasNestedContent(InputTag const& value); bool hasNestedContent(std::vector const& value); + bool hasNestedContent(ESInputTag const& value); + bool hasNestedContent(std::vector const& value); bool hasNestedContent(FileInPath const& value); } // namespace writeParameterValue diff --git a/FWCore/ParameterSet/interface/ParameterDescriptionNode.h b/FWCore/ParameterSet/interface/ParameterDescriptionNode.h index 0ca3be960df71..a567b92cfe271 100644 --- a/FWCore/ParameterSet/interface/ParameterDescriptionNode.h +++ b/FWCore/ParameterSet/interface/ParameterDescriptionNode.h @@ -50,6 +50,8 @@ namespace edm { k_VLuminosityBlockID = 'm', k_InputTag = 't', k_VInputTag = 'v', + k_ESInputTag = 'g', + k_VESInputTag = 'G', k_FileInPath = 'F', k_LuminosityBlockRange = 'A', k_VLuminosityBlockRange = 'a', diff --git a/FWCore/ParameterSet/src/ParameterDescription.cc b/FWCore/ParameterSet/src/ParameterDescription.cc index e6551fb645420..493297ab53067 100644 --- a/FWCore/ParameterSet/src/ParameterDescription.cc +++ b/FWCore/ParameterSet/src/ParameterDescription.cc @@ -13,6 +13,7 @@ #include "FWCore/Utilities/interface/Algorithms.h" #include "FWCore/Utilities/interface/EDMException.h" #include "FWCore/Utilities/interface/InputTag.h" +#include "FWCore/Utilities/interface/ESInputTag.h" #include #include @@ -518,6 +519,15 @@ namespace edm { } } + template <> + void writeSingleValue(std::ostream& os, ESInputTag const& value, ValueFormat format) { + if (format == CFI) { + os << "'" << value.module() << "', '" << value.data() << "'"; + } else { + os << "'" << value.module() << ":" << value.data() << "'"; + } + } + template <> void writeSingleValue(std::ostream& os, FileInPath const& value, ValueFormat) { os << "'" << value.relativePath() << "'"; @@ -573,6 +583,11 @@ namespace edm { os << "'"; } + template <> + void writeValueInVector(std::ostream& os, ESInputTag const& value, ValueFormat) { + os << "'" << value.module() << ":" << value.data() << "'"; + } + template void writeValueInVectorWithSpace( T const& value, std::ostream& os, int indentation, bool& startWithComma, ValueFormat format, int& i) { @@ -721,6 +736,14 @@ namespace edm { writeVector(os, indentation, value_, format); } + void writeValue(std::ostream& os, int, ESInputTag const& value_, ValueFormat format) { + writeValue(os, value_, format); + } + + void writeValue(std::ostream& os, int indentation, std::vector const& value_, ValueFormat format) { + writeVector(os, indentation, value_, format); + } + void writeValue(std::ostream& os, int, FileInPath const& value_, ValueFormat format) { writeValue(os, value_, format); } @@ -748,6 +771,8 @@ namespace edm { bool hasNestedContent(std::vector const& value) { return value.size() > 5U; } bool hasNestedContent(InputTag const&) { return false; } bool hasNestedContent(std::vector const& value) { return value.size() > 5U; } + bool hasNestedContent(ESInputTag const&) { return false; } + bool hasNestedContent(std::vector const& value) { return value.size() > 5U; } bool hasNestedContent(FileInPath const&) { return false; } } // namespace writeParameterValue } // namespace edm diff --git a/FWCore/ParameterSet/src/ParameterDescriptionNode.cc b/FWCore/ParameterSet/src/ParameterDescriptionNode.cc index 046510b6fa76c..1fa1a6bf2edf1 100644 --- a/FWCore/ParameterSet/src/ParameterDescriptionNode.cc +++ b/FWCore/ParameterSet/src/ParameterDescriptionNode.cc @@ -26,6 +26,7 @@ namespace edm { class LuminosityBlockRange; class EventRange; class InputTag; + class ESInputTag; class FileInPath; TYPE_TO_ENUM(int, k_int32) @@ -47,6 +48,8 @@ namespace edm { TYPE_TO_ENUM(std::vector, k_VLuminosityBlockID) TYPE_TO_ENUM(InputTag, k_InputTag) TYPE_TO_ENUM(std::vector, k_VInputTag) + TYPE_TO_ENUM(ESInputTag, k_ESInputTag) + TYPE_TO_ENUM(std::vector, k_VESInputTag) TYPE_TO_ENUM(FileInPath, k_FileInPath) TYPE_TO_ENUM(LuminosityBlockRange, k_LuminosityBlockRange) TYPE_TO_ENUM(std::vector, k_VLuminosityBlockRange) @@ -79,6 +82,8 @@ namespace edm { TYPE_TO_NAME(VLuminosityBlockID); TYPE_TO_NAME(InputTag); TYPE_TO_NAME(VInputTag); + TYPE_TO_NAME(ESInputTag); + TYPE_TO_NAME(VESInputTag); TYPE_TO_NAME(FileInPath); TYPE_TO_NAME(PSet); TYPE_TO_NAME(VPSet); diff --git a/FWCore/ParameterSet/test/parameterSetDescription_t.cc b/FWCore/ParameterSet/test/parameterSetDescription_t.cc index cdbc4732bc7e6..e26a0486a1271 100644 --- a/FWCore/ParameterSet/test/parameterSetDescription_t.cc +++ b/FWCore/ParameterSet/test/parameterSetDescription_t.cc @@ -1481,6 +1481,12 @@ int main(int, char**) try { assert(par->type() == edm::k_InputTag); assert(edm::parameterTypeEnumToString(par->type()) == std::string("InputTag")); + edm::ESInputTag k; + par = psetDesc.add("esinput", k); + pset.addParameter("esinput", k); + assert(par->type() == edm::k_ESInputTag); + assert(edm::parameterTypeEnumToString(par->type()) == std::string("ESInputTag")); + std::vector v1; par = psetDesc.add>("v1", v1); pset.addParameter>("v1", v1); @@ -1535,6 +1541,12 @@ int main(int, char**) try { assert(par->type() == edm::k_VInputTag); assert(edm::parameterTypeEnumToString(par->type()) == std::string("VInputTag")); + std::vector v11; + par = psetDesc.add>("v11", v11); + pset.addParameter>("v11", v11); + assert(par->type() == edm::k_VESInputTag); + assert(edm::parameterTypeEnumToString(par->type()) == std::string("VESInputTag")); + edm::ParameterSetDescription m; par = psetDesc.add("psetDesc", m); assert(par->exists(pset) == false);