CMS 3D CMS Logo

ParameterWildcard.cc
Go to the documentation of this file.
2 
7 
8 #include <cassert>
9 #include <iomanip>
10 #include <ostream>
11 
12 namespace edm {
13 
16  bool isTracked)
17  : ParameterWildcardBase(k_PSet, isTracked, criteria), psetDesc_() {
19  }
20 
23  bool isTracked)
24  : ParameterWildcardBase(k_PSet, isTracked, criteria), psetDesc_() {
26  }
27 
30  bool isTracked,
31  ParameterSetDescription const& desc)
32  : ParameterWildcardBase(k_PSet, isTracked, criteria), psetDesc_(new ParameterSetDescription(desc)) {
34  }
35 
38  bool isTracked,
39  ParameterSetDescription const& desc)
40  : ParameterWildcardBase(k_PSet, isTracked, criteria), psetDesc_(new ParameterSetDescription(desc)) {
42  }
43 
45 
47  return new ParameterWildcard(*this);
48  }
49 
51  std::set<std::string>& validatedLabels,
52  bool optional) const {
53  std::vector<std::string> parameterNames = pset.getParameterNamesForType<ParameterSet>(isTracked());
54  validateMatchingNames(parameterNames, validatedLabels, optional);
55 
56  if (psetDesc_) {
57  for_all(parameterNames,
59  this,
60  std::placeholders::_1,
61  std::ref(pset)));
62  }
63  }
64 
66  ParameterSet& pset) const {
67  ParameterSet* containedPSet = pset.getPSetForUpdate(parameterName);
68  psetDesc_->validate(*containedPSet);
69  }
70 
72  if (psetDesc_)
73  return true;
74  return false;
75  }
76 
78  bool /*optional*/,
79  DocFormatHelper& dfh) const {
80  int indentation = dfh.indentation();
81  if (dfh.parent() != DocFormatHelper::TOP) {
83  }
84 
86  os << "Section " << dfh.section() << "." << dfh.counter() << " description of PSet matching wildcard:";
87  os << "\n";
88  if (!dfh.brief())
89  os << "\n";
90 
91  std::stringstream ss;
92  ss << dfh.section() << "." << dfh.counter();
93  std::string newSection = ss.str();
94 
95  DocFormatHelper new_dfh(dfh);
96  new_dfh.setSection(newSection);
99 
100  psetDesc_->print(os, new_dfh);
101  }
102 
104  if (criteria() == RequireZeroOrMore)
105  return true;
106 
107  std::vector<std::string> parameterNames = pset.getParameterNamesForType<ParameterSet>(isTracked());
108 
109  if (criteria() == RequireAtLeastOne)
110  return !parameterNames.empty();
111  return parameterNames.size() == 1U;
112  }
113 
114  // -------------------------------------------------------------------------
115 
118  bool isTracked)
119  : ParameterWildcardBase(k_VPSet, isTracked, criteria), psetDesc_() {
121  }
122 
125  bool isTracked)
126  : ParameterWildcardBase(k_VPSet, isTracked, criteria), psetDesc_() {
128  }
129 
132  bool isTracked,
133  ParameterSetDescription const& desc)
134  : ParameterWildcardBase(k_VPSet, isTracked, criteria), psetDesc_(new ParameterSetDescription(desc)) {
136  }
137 
140  bool isTracked,
141  ParameterSetDescription const& desc)
142  : ParameterWildcardBase(k_VPSet, isTracked, criteria), psetDesc_(new ParameterSetDescription(desc)) {
144  }
145 
147 
149  return new ParameterWildcard(*this);
150  }
151 
153  std::set<std::string>& validatedLabels,
154  bool optional) const {
155  std::vector<std::string> parameterNames = pset.getParameterNamesForType<std::vector<ParameterSet> >(isTracked());
156  validateMatchingNames(parameterNames, validatedLabels, optional);
157 
158  if (psetDesc_) {
159  for_all(parameterNames,
160  std::bind(&ParameterWildcard<std::vector<ParameterSet> >::validatePSetVector,
161  this,
162  std::placeholders::_1,
163  std::ref(pset)));
164  }
165  }
166 
167  void ParameterWildcard<std::vector<ParameterSet> >::validatePSetVector(std::string const& parameterName,
168  ParameterSet& pset) const {
169  VParameterSetEntry* vpsetEntry = pset.getPSetVectorForUpdate(parameterName);
170  assert(vpsetEntry);
171  for (unsigned i = 0; i < vpsetEntry->size(); ++i) {
172  psetDesc_->validate(vpsetEntry->psetInVector(i));
173  }
174  }
175 
176  bool ParameterWildcard<std::vector<ParameterSet> >::hasNestedContent_() const {
177  if (psetDesc_)
178  return true;
179  return false;
180  }
181 
182  void ParameterWildcard<std::vector<ParameterSet> >::printNestedContent_(std::ostream& os,
183  bool /*optional*/,
184  DocFormatHelper& dfh) const {
185  int indentation = dfh.indentation();
186  if (dfh.parent() != DocFormatHelper::TOP) {
188  }
189 
190  printSpaces(os, indentation);
191  os << "Section " << dfh.section() << "." << dfh.counter()
192  << " description used to validate all PSets which are in the VPSet matching the wildcard:";
193  os << "\n";
194  if (!dfh.brief())
195  os << "\n";
196 
197  std::stringstream ss;
198  ss << dfh.section() << "." << dfh.counter();
199  std::string newSection = ss.str();
200 
201  DocFormatHelper new_dfh(dfh);
202  new_dfh.setSection(newSection);
205 
206  psetDesc_->print(os, new_dfh);
207  }
208 
210  if (criteria() == RequireZeroOrMore)
211  return true;
212 
213  std::vector<std::string> parameterNames = pset.getParameterNamesForType<std::vector<ParameterSet> >(isTracked());
214 
215  if (criteria() == RequireAtLeastOne)
216  return !parameterNames.empty();
217  return parameterNames.size() == 1U;
218  }
219 } // namespace edm
edm::DocFormatHelper::TOP
Definition: DocFormatHelper.h:17
edm::ParameterWildcardBase::throwIfInvalidPattern
void throwIfInvalidPattern(char const *pattern) const
Definition: ParameterWildcardBase.cc:20
mps_fire.i
i
Definition: mps_fire.py:355
edm::ParameterWildcard
Definition: ParameterWildcard.h:23
edm::ParameterWildcard::exists_
bool exists_(ParameterSet const &pset) const override
Definition: ParameterWildcard.h:45
edm::VParameterSetEntry::size
std::vector< ParameterSet >::size_type size() const
Definition: VParameterSetEntry.cc:105
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::DocFormatHelper::setSection
void setSection(std::string const &value)
Definition: DocFormatHelper.h:44
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
Types.optional
optional
Definition: Types.py:167
Algorithms.h
edm::VParameterSetEntry::psetInVector
ParameterSet & psetInVector(int i)
Definition: VParameterSetEntry.cc:100
cms::cuda::assert
assert(be >=bs)
edm::DocFormatHelper::parent
DescriptionParent parent() const
Definition: DocFormatHelper.h:71
edm::ParameterWildcardBase
Definition: ParameterWildcardBase.h:19
edm::for_all
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:14
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
edm::DocFormatHelper
Definition: DocFormatHelper.h:15
edm::ParameterDescriptionNode::hasNestedContent_
virtual bool hasNestedContent_() const
Definition: ParameterDescriptionNode.h:227
ParameterWildcard.h
clone
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
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::ParameterWildcard::clone
ParameterDescriptionNode * clone() const override
Definition: ParameterWildcard.h:37
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterWildcard::validate_
void validate_(ParameterSet &pset, std::set< std::string > &validatedLabels, bool optional) const override
Definition: ParameterWildcard.h:40
edm::ParameterSet
Definition: ParameterSet.h:36
edm::DocFormatHelper::brief
bool brief() const
Definition: DocFormatHelper.h:34
edm::ParameterDescriptionNode::printNestedContent_
virtual void printNestedContent_(std::ostream &, bool, DocFormatHelper &) const
Definition: ParameterDescriptionNode.h:229
edm::DocFormatHelper::setParent
void setParent(DescriptionParent value)
Definition: DocFormatHelper.h:72
edm::ParameterWildcard::ParameterWildcard
ParameterWildcard(std::string const &pattern, WildcardValidationCriteria criteria, bool isTracked)
Definition: ParameterWildcard.h:25
edm::DocFormatHelper::setIndentation
void setIndentation(int value)
Definition: DocFormatHelper.h:41
topSingleLeptonDQM_PU_cfi.pattern
pattern
Definition: topSingleLeptonDQM_PU_cfi.py:39
edm::ParameterWildcardBase::validateMatchingNames
void validateMatchingNames(std::vector< std::string > const &matchingNames, std::set< std::string > &validatedLabels, bool optional) const
Definition: ParameterWildcardBase.cc:36
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
DocFormatHelper.h
edm::DocFormatHelper::offsetSectionContent
static int offsetSectionContent()
Definition: DocFormatHelper.h:83
edm::VParameterSetEntry
Definition: VParameterSetEntry.h:24
printContent_cfi.indentation
indentation
Definition: printContent_cfi.py:10
edm::ParameterWildcard::~ParameterWildcard
~ParameterWildcard() override
Definition: ParameterWildcard.h:35
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:190
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
edm::DocFormatHelper::indentation
int indentation() const
Definition: DocFormatHelper.h:36
edm::k_VPSet
Definition: ParameterDescriptionNode.h:61