CMS 3D CMS Logo

ParameterWildcardWithSpecifics.cc
Go to the documentation of this file.
2 
7 
8 #include <cassert>
9 #include <iomanip>
10 #include <ostream>
11 
12 namespace edm {
13 
15  std::string_view pattern,
17  bool isTracked,
19  std::map<std::string, ParameterSetDescription> exceptions)
20  : ParameterWildcardBase(k_PSet, isTracked, criteria), wildcardDesc_(desc), exceptions_(std::move(exceptions)) {
22  }
23 
25  return new ParameterWildcardWithSpecifics(*this);
26  }
27 
29  std::set<std::string>& validatedLabels,
30  bool optional) const {
31  std::vector<std::string> parameterNames = pset.getParameterNamesForType<ParameterSet>(isTracked());
32  validateMatchingNames(parameterNames, validatedLabels, optional);
33 
34  for (auto const& name : parameterNames) {
36  }
37  //inject exceptions if not already in the pset
38  for (auto const& v : exceptions_) {
39  if (std::find(parameterNames.begin(), parameterNames.end(), v.first) == parameterNames.end()) {
40  if (isTracked()) {
41  pset.addParameter<edm::ParameterSet>(v.first, edm::ParameterSet());
42  } else {
43  pset.addUntrackedParameter<edm::ParameterSet>(v.first, edm::ParameterSet());
44  }
45  validatedLabels.insert(v.first);
46  validateDescription(v.first, pset);
47  }
48  }
49  }
50 
52  ParameterSet* containedPSet = pset.getPSetForUpdate(parameterName);
53  auto itFound = exceptions_.find(parameterName);
54  if (itFound != exceptions_.end()) {
55  itFound->second.validate(*containedPSet);
56  } else {
57  wildcardDesc_.validate(*containedPSet);
58  }
59  }
60 
62 
64  bool /*optional*/,
65  DocFormatHelper& dfh) const {
66  int indentation = dfh.indentation();
67  if (dfh.parent() != DocFormatHelper::TOP) {
69  }
70 
72  os << "Section " << dfh.section() << "." << dfh.counter() << " description of PSet matching wildcard:";
73  os << "\n";
74  if (!dfh.brief())
75  os << "\n";
76 
77  std::stringstream ss;
78  ss << dfh.section() << "." << dfh.counter();
79  std::string newSection = ss.str();
80 
81  DocFormatHelper new_dfh(dfh);
82  new_dfh.setSection(newSection);
85 
86  wildcardDesc_.print(os, new_dfh);
87  //NOTE: need to extend to also include the specific cases.
88  }
89 
91  if (criteria() == RequireZeroOrMore)
92  return true;
93 
94  std::vector<std::string> parameterNames = pset.getParameterNamesForType<ParameterSet>(isTracked());
95 
96  if (criteria() == RequireAtLeastOne)
97  return !parameterNames.empty();
98  return parameterNames.size() == 1U;
99  }
100 
101 } // namespace edm
edm::DocFormatHelper::TOP
Definition: DocFormatHelper.h:17
edm::ParameterWildcardBase::throwIfInvalidPattern
void throwIfInvalidPattern(char const *pattern) const
Definition: ParameterWildcardBase.cc:20
edm::ParameterWildcardWithSpecifics::validateDescription
void validateDescription(std::string const &parameterName, ParameterSet &pset) const
Definition: ParameterWildcardWithSpecifics.cc:51
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::DocFormatHelper::setSection
void setSection(std::string const &value)
Definition: DocFormatHelper.h:44
edm::ParameterSetDescription::validate
void validate(ParameterSet &pset) const
Definition: ParameterSetDescription.cc:78
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::ParameterWildcardWithSpecifics::exists_
bool exists_(ParameterSet const &pset) const override
Definition: ParameterWildcardWithSpecifics.cc:90
Types.optional
optional
Definition: Types.py:198
Algorithms.h
edm::DocFormatHelper::parent
DescriptionParent parent() const
Definition: DocFormatHelper.h:71
findQualityFiles.v
v
Definition: findQualityFiles.py:179
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
edm::ParameterWildcardBase
Definition: ParameterWildcardBase.h:19
edm::ParameterWildcardWithSpecifics::exceptions_
std::map< std::string, ParameterSetDescription > exceptions_
Definition: ParameterWildcardWithSpecifics.h:39
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
edm::DocFormatHelper
Definition: DocFormatHelper.h:15
edm::ParameterWildcardWithSpecifics::ParameterWildcardWithSpecifics
ParameterWildcardWithSpecifics(std::string_view, WildcardValidationCriteria criteria, bool isTracked, ParameterSetDescription const &desc, std::map< std::string, ParameterSetDescription > exceptions)
Definition: ParameterWildcardWithSpecifics.cc:14
edm::ParameterSet::insert
void insert(bool ok_to_replace, char const *, Entry const &)
Definition: ParameterSet.cc:380
edm::RequireAtLeastOne
Definition: ParameterWildcardBase.h:17
edm::WildcardValidationCriteria
WildcardValidationCriteria
Definition: ParameterWildcardBase.h:17
VParameterSetEntry.h
ParameterSetDescription.h
edm::ParameterWildcardBase::isTracked
bool isTracked() const
Definition: ParameterWildcardBase.h:24
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
edm::ParameterWildcardWithSpecifics::hasNestedContent_
bool hasNestedContent_() const override
Definition: ParameterWildcardWithSpecifics.cc:61
edm::ParameterSet
Definition: ParameterSet.h:47
edm::ParameterWildcardWithSpecifics::wildcardDesc_
ParameterSetDescription wildcardDesc_
Definition: ParameterWildcardWithSpecifics.h:38
edm::DocFormatHelper::brief
bool brief() const
Definition: DocFormatHelper.h:34
ParameterWildcardWithSpecifics.h
edm::DocFormatHelper::setParent
void setParent(DescriptionParent value)
Definition: DocFormatHelper.h:72
edm::ParameterWildcardWithSpecifics::clone
ParameterDescriptionNode * clone() const override
Definition: ParameterWildcardWithSpecifics.cc:24
edm::DocFormatHelper::setIndentation
void setIndentation(int value)
Definition: DocFormatHelper.h:41
topSingleLeptonDQM_PU_cfi.pattern
pattern
Definition: topSingleLeptonDQM_PU_cfi.py:39
edm::ParameterSetDescription::print
void print(std::ostream &os, DocFormatHelper &dfh) const
Definition: ParameterSetDescription.cc:146
edm::ParameterWildcardWithSpecifics::validate_
void validate_(ParameterSet &pset, std::set< std::string > &validatedLabels, bool optional) const override
Definition: ParameterWildcardWithSpecifics.cc:28
edm::ParameterWildcardBase::validateMatchingNames
void validateMatchingNames(std::vector< std::string > const &matchingNames, std::set< std::string > &validatedLabels, bool optional) const
Definition: ParameterWildcardBase.cc:36
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::k_PSet
Definition: ParameterDescriptionNode.h:60
edm::ParameterDescriptionNode::printSpaces
static void printSpaces(std::ostream &os, int n)
Definition: ParameterDescriptionNode.cc:124
edm::DocFormatHelper::counter
int counter() const
Definition: DocFormatHelper.h:66
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
edm::ParameterWildcardWithSpecifics::printNestedContent_
void printNestedContent_(std::ostream &os, bool optional, DocFormatHelper &dfh) const override
Definition: ParameterWildcardWithSpecifics.cc:63
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
DocFormatHelper.h
edm::DocFormatHelper::offsetSectionContent
static int offsetSectionContent()
Definition: DocFormatHelper.h:83
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
printContent_cfi.indentation
indentation
Definition: printContent_cfi.py:10
edm::ParameterWildcardBase::criteria
WildcardValidationCriteria criteria() const
Definition: ParameterWildcardBase.h:25
edm::DocFormatHelper::section
std::string const & section() const
Definition: DocFormatHelper.h:43
edm::DocFormatHelper::OTHER
Definition: DocFormatHelper.h:17
edm::ParameterDescriptionNode
Definition: ParameterDescriptionNode.h:82
edm::RequireZeroOrMore
Definition: ParameterWildcardBase.h:17
edm::ParameterSet::empty
bool empty() const
Definition: ParameterSet.h:201
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
edm::DocFormatHelper::indentation
int indentation() const
Definition: DocFormatHelper.h:36