CMS 3D CMS Logo

MessageServicePSetValidation.h
Go to the documentation of this file.
1 #ifndef FWCore_MessageService_MessageServicePSetValidation_h
2 #define FWCore_MessageService_MessageServicePSetValidation_h
3 
4 // -*- C++ -*-
5 //
6 // Package: Services
7 // Class : MessageServicePSetValidation_h
8 //
21 //
22 // Original Author: M. Fischler
23 // Created: Tue May 19 2009
24 //
25 
26 // system include files
27 
28 #include <string>
29 #include <sstream>
30 #include <vector>
31 
32 // user include files
33 
36 
37 // forward declarations
38 
39 namespace edm {
40  namespace service {
41 
43  public:
45 
46  private:
48  typedef std::vector<String> vString;
49 
50  void messageLoggerPSet(ParameterSet const& pset);
51  void psetLists(ParameterSet const& pset);
52  void suppressionLists(ParameterSet const& pset);
53  bool validateThreshold(std::string const& thresh, std::string const& psetName);
54  bool checkThreshold(std::string const& thresh);
55  void noDuplicates(vString const& v, std::string const& psetName, std::string const& parameterLabel);
56  void noDuplicates(vString const& v1,
57  vString const& v2,
58  std::string const& psetName,
59  std::string const& p1,
60  std::string const& p2);
61  void noCoutCerrClash(vString const& v, std::string const& psetName, std::string const& parameterLabel);
62  void noKeywords(vString const& v, std::string const& psetName, std::string const& parameterLabel);
63  bool keywordCheck(std::string const& word);
64  void noNonPSetUsage(ParameterSet const& pset,
65  vString const& v,
66  std::string const& psetName,
67  std::string const& parameterLabel);
68  void noBadParams(vString const& v,
69  vString const& params,
70  std::string const& psetName,
71  std::string const& parameterLabel,
72  std::string const& type);
73  void vStringsCheck(ParameterSet const& pset, std::string const& psetName);
74  bool wildcard(vString const& v);
75  bool allowedVstring(std::string const& s);
76  void noOtherPsets(ParameterSet const& pset);
77  void noNoncategoryPsets(ParameterSet const& pset, std::string const& psetName);
78  bool lookForMatch(vString const& v, std::string const& s);
79  void destinationPSets(ParameterSet const& pset);
80  void destinationPSet(ParameterSet const& pset, std::string const& psetName);
81  void defaultPSet(ParameterSet const& main_pset);
82  void statisticsPSets(ParameterSet const& pset);
83  void statisticsPSet(ParameterSet const& pset, std::string const& psetName);
84  void categoryPSets(ParameterSet const& pset, std::string const& psetName);
85  void categoryPSet(ParameterSet const& pset, std::string const& OuterPsetName, std::string const& categoryName);
86  void catInts(ParameterSet const& pset, std::string const& psetName, std::string const& categoryName);
87  void catNoPSets(ParameterSet const& pset, std::string const& psetName, std::string const& categoryName);
89  std::string const& psetName,
90  std::string const& categoryName,
91  std::string const& type);
92 
93  template <typename T>
94  T check(ParameterSet const& pset, std::string const& psetName, std::string const& parameterLabel) {
95  T val = T();
96  try {
97  if (!pset.exists(parameterLabel))
98  return val;
99  if (pset.existsAs<T>(parameterLabel, false)) {
100  val = pset.getUntrackedParameter<T>(parameterLabel, val);
101  return val;
102  }
103  if (pset.existsAs<T>(parameterLabel, true)) {
104  flaws_ << psetName << " PSet: \n" << parameterLabel << " is declared as tracked - needs to be untracked \n";
105  val = pset.getParameter<T>(parameterLabel);
106  } else {
107  flaws_ << psetName << " PSet: \n" << parameterLabel << " is declared with incorrect type \n";
108  }
109  return val;
110  } catch (cms::Exception& e) {
111  flaws_ << psetName << " PSet: \n"
112  << parameterLabel << " is declared but causes an exception when processed: \n"
113  << e.what() << "\n";
114  return val;
115  }
116  } // check()
117 
118  template <typename T>
120  vString const& v,
121  std::string const& psetName,
122  std::string const& parameterLabel,
123  std::string const& type) {
124  vString params = pset.getParameterNamesForType<T>(true);
125  noBadParams(v, params, psetName, parameterLabel, type);
126  params = pset.getParameterNamesForType<T>(false);
127  noBadParams(v, params, psetName, parameterLabel, type);
128  } // disallowedParam()
129 
130  template <typename T>
131  void noneExcept(ParameterSet const& pset, std::string const& psetName, std::string const& type) {
132  vString x = pset.template getParameterNamesForType<T>(false);
133  vString::const_iterator end = x.end();
134  for (vString::const_iterator i = x.begin(); i != end; ++i) {
135  flaws_ << psetName << " PSet: \n"
136  << (*i) << " is used as a " << type << "\n"
137  << "Usage of " << type << " is not recognized here\n";
138  }
139  x = pset.template getParameterNamesForType<T>(true);
140  end = x.end();
141  for (vString::const_iterator i = x.begin(); i != end; ++i) {
142  if ((*i) == "@service_type")
143  continue;
144  flaws_ << psetName << " PSet: \n"
145  << (*i) << " is used as a tracked " << type << "\n"
146  << "Tracked parameters not allowed here, "
147  << " and even untracked it would not be recognized\n";
148  }
149  } // noneExcept()
150 
151  template <typename T>
153  std::string const& psetName,
154  std::string const& type,
155  std::string const& ok) {
156  vString x = pset.template getParameterNamesForType<T>(false);
157  vString::const_iterator end = x.end();
158  for (vString::const_iterator i = x.begin(); i != end; ++i) {
159  std::string val = (*i);
160  if (val != ok) {
161  flaws_ << psetName << " PSet: \n"
162  << val << " is used as a " << type << "\n"
163  << "This usage is not recognized in this type of PSet\n";
164  }
165  }
166  x = pset.template getParameterNamesForType<T>(true);
167  end = x.end();
168  for (vString::const_iterator i = x.begin(); i != end; ++i) {
169  if ((*i) == "@service_type")
170  continue;
171  flaws_ << psetName << " PSet: \n"
172  << (*i) << " is used as a tracked " << type << "\n"
173  << "Tracked parameters not allowed here\n";
174  }
175  } // noneExcept(okValue)
176 
177  template <typename T>
179  ParameterSet const& pset, std::string const& psetName, std::string const& type, T const& ok1, T const& ok2) {
180  vString x = pset.template getParameterNamesForType<T>(false);
181  vString::const_iterator end = x.end();
182  for (vString::const_iterator i = x.begin(); i != end; ++i) {
183  std::string val = (*i);
184  if ((val != ok1) && (val != ok2)) {
185  flaws_ << psetName << " PSet: \n"
186  << val << " is used as a " << type << "\n"
187  << "This usage is not recognized in this type of PSet\n";
188  }
189  }
190  x = pset.template getParameterNamesForType<T>(true);
191  end = x.end();
192  for (vString::const_iterator i = x.begin(); i != end; ++i) {
193  if ((*i) == "@service_type")
194  continue;
195  flaws_ << psetName << " PSet: \n"
196  << (*i) << " is used as a tracked " << type << "\n"
197  << "Tracked parameters not allowed here\n";
198  }
199  } // noneExcept(okValue1, okValue2)
200 
201  template <typename T>
203  std::string const& psetName,
204  std::string const& type,
205  vString const& vok) {
206  vString x = pset.template getParameterNamesForType<T>(false);
207  vString::const_iterator end = x.end();
208  vString::const_iterator vend = vok.end();
209  for (vString::const_iterator i = x.begin(); i != end; ++i) {
210  bool found = false;
211  for (vString::const_iterator vit = vok.begin(); vit != vend; ++vit) {
212  if (*i == *vit)
213  found = true;
214  }
215  if (!found) {
216  flaws_ << psetName << " PSet: \n"
217  << *i << " is used as a " << type << "\n"
218  << "This usage is not recognized in this type of PSet\n";
219  }
220  }
221  x = pset.template getParameterNamesForType<T>(true);
222  end = x.end();
223  for (vString::const_iterator i = x.begin(); i != end; ++i) {
224  if ((*i) == "@service_type")
225  continue;
226  flaws_ << psetName << " PSet: \n"
227  << (*i) << " is used as a tracked " << type << "\n"
228  << "Tracked parameters not allowed here\n";
229  }
230  } // noneExcept(vok)
231 
232  template <typename T>
233  void catNone(ParameterSet const& pset,
234  std::string const& psetName,
235  std::string const& categoryName,
236  std::string const& type) {
237  vString x = pset.template getParameterNamesForType<T>(false);
238  vString::const_iterator end = x.end();
239  for (vString::const_iterator i = x.begin(); i != end; ++i) {
240  flaws_ << categoryName << " category PSet nested in " << psetName << " PSet: \n"
241  << (*i) << " is used as a " << type << "\n"
242  << "Usage of " << type << " is not recognized here\n";
243  }
244  x = pset.template getParameterNamesForType<T>(true);
245  end = x.end();
246  for (vString::const_iterator i = x.begin(); i != end; ++i) {
247  flaws_ << categoryName << " category PSet nested in " << psetName << " PSet: \n"
248  << (*i) << " is used as a tracked " << type << "\n"
249  << "Tracked parameters not allowed here, "
250  << " and even untracked it would not be recognized\n";
251  }
252  } // catNone()
253 
254  // private data
255  std::ostringstream flaws_;
256  std::vector<std::string> destinations_;
257  std::vector<std::string> statistics_;
258  std::vector<std::string> categories_;
259  std::vector<std::string> debugModules_;
260  std::vector<std::string> suppressInfo_;
261  std::vector<std::string> suppressFwkInfo_;
262  std::vector<std::string> suppressDebug_;
263  std::vector<std::string> suppressWarning_;
264  std::vector<std::string> suppressError_;
265 
266  }; // MessageServicePSetValidation
267 
268  } // namespace service
269 
270 } // namespace edm
271 
272 #endif // FWCore_MessageService_MessageServicePSetValidation_h
service
Definition: service.py:1
edm::service::MessageServicePSetValidation::catNoPSets
void catNoPSets(ParameterSet const &pset, std::string const &psetName, std::string const &categoryName)
Definition: MessageServicePSetValidation.cc:731
edm::service::MessageServicePSetValidation::noBadParams
void noBadParams(vString const &v, vString const &params, std::string const &psetName, std::string const &parameterLabel, std::string const &type)
Definition: MessageServicePSetValidation.cc:381
mps_fire.i
i
Definition: mps_fire.py:428
edm::service::MessageServicePSetValidation::noneExcept
void noneExcept(ParameterSet const &pset, std::string const &psetName, std::string const &type, vString const &vok)
Definition: MessageServicePSetValidation.h:202
edm::service::MessageServicePSetValidation::noneExcept
void noneExcept(ParameterSet const &pset, std::string const &psetName, std::string const &type)
Definition: MessageServicePSetValidation.h:131
edm::service::MessageServicePSetValidation::noDuplicates
void noDuplicates(vString const &v, std::string const &psetName, std::string const &parameterLabel)
Definition: MessageServicePSetValidation.cc:241
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
edm::service::MessageServicePSetValidation::noKeywords
void noKeywords(vString const &v, std::string const &psetName, std::string const &parameterLabel)
Definition: MessageServicePSetValidation.cc:290
edm::service::MessageServicePSetValidation::checkThreshold
bool checkThreshold(std::string const &thresh)
Definition: MessageServicePSetValidation.cc:227
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::service::MessageServicePSetValidation::catNone
void catNone(ParameterSet const &pset, std::string const &psetName, std::string const &categoryName, std::string const &type)
Definition: MessageServicePSetValidation.h:233
edm::service::MessageServicePSetValidation::statisticsPSets
void statisticsPSets(ParameterSet const &pset)
Definition: MessageServicePSetValidation.cc:570
edm::service::MessageServicePSetValidation::noOtherPsets
void noOtherPsets(ParameterSet const &pset)
Definition: MessageServicePSetValidation.cc:409
edm::service::MessageServicePSetValidation::suppressFwkInfo_
std::vector< std::string > suppressFwkInfo_
Definition: MessageServicePSetValidation.h:261
edm::service::MessageServicePSetValidation::keywordCheck
bool keywordCheck(std::string const &word)
Definition: MessageServicePSetValidation.cc:302
edm::service::MessageServicePSetValidation::catBoolRestriction
void catBoolRestriction(ParameterSet const &pset, std::string const &psetName, std::string const &categoryName, std::string const &type)
Definition: MessageServicePSetValidation.cc:755
edm::service::MessageServicePSetValidation::operator()
std::string operator()(ParameterSet const &pset)
Definition: MessageServicePSetValidation.cc:28
findQualityFiles.v
v
Definition: findQualityFiles.py:179
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
edm::service::MessageServicePSetValidation::destinationPSets
void destinationPSets(ParameterSet const &pset)
Definition: MessageServicePSetValidation.cc:454
edm::service::MessageServicePSetValidation::destinations_
std::vector< std::string > destinations_
Definition: MessageServicePSetValidation.h:256
edm::service::MessageServicePSetValidation::defaultPSet
void defaultPSet(ParameterSet const &main_pset)
Definition: MessageServicePSetValidation.cc:521
edm::service::MessageServicePSetValidation::allowedVstring
bool allowedVstring(std::string const &s)
Definition: MessageServicePSetValidation.cc:194
edm::service::MessageServicePSetValidation::categoryPSet
void categoryPSet(ParameterSet const &pset, std::string const &OuterPsetName, std::string const &categoryName)
Definition: MessageServicePSetValidation.cc:686
word
uint64_t word
Definition: CTPPSTotemDataFormatter.cc:29
alignCSCRings.s
s
Definition: alignCSCRings.py:92
edm::service::MessageServicePSetValidation::messageLoggerPSet
void messageLoggerPSet(ParameterSet const &pset)
Definition: MessageServicePSetValidation.cc:33
edm::service::MessageServicePSetValidation::psetLists
void psetLists(ParameterSet const &pset)
Definition: MessageServicePSetValidation.cc:101
edm::service::MessageServicePSetValidation::validateThreshold
bool validateThreshold(std::string const &thresh, std::string const &psetName)
Definition: MessageServicePSetValidation.cc:218
edm::service::MessageServicePSetValidation::suppressError_
std::vector< std::string > suppressError_
Definition: MessageServicePSetValidation.h:264
edm::service::MessageServicePSetValidation::String
std::string String
Definition: MessageServicePSetValidation.h:47
mps_fire.end
end
Definition: mps_fire.py:242
p2
double p2[4]
Definition: TauolaWrapper.h:90
edm::service::MessageServicePSetValidation::suppressionLists
void suppressionLists(ParameterSet const &pset)
Definition: MessageServicePSetValidation.cc:122
edm::service::MessageServicePSetValidation::noNoncategoryPsets
void noNoncategoryPsets(ParameterSet const &pset, std::string const &psetName)
Definition: MessageServicePSetValidation.cc:626
edm::service::MessageServicePSetValidation
Definition: MessageServicePSetValidation.h:42
edm::service::MessageServicePSetValidation::suppressInfo_
std::vector< std::string > suppressInfo_
Definition: MessageServicePSetValidation.h:260
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::service::MessageServicePSetValidation::catInts
void catInts(ParameterSet const &pset, std::string const &psetName, std::string const &categoryName)
Definition: MessageServicePSetValidation.cc:707
edm::ParameterSet
Definition: ParameterSet.h:47
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
edm::service::MessageServicePSetValidation::debugModules_
std::vector< std::string > debugModules_
Definition: MessageServicePSetValidation.h:259
edm::service::MessageServicePSetValidation::flaws_
std::ostringstream flaws_
Definition: MessageServicePSetValidation.h:255
p1
double p1[4]
Definition: TauolaWrapper.h:89
edm::service::MessageServicePSetValidation::lookForMatch
bool lookForMatch(vString const &v, std::string const &s)
Definition: MessageServicePSetValidation.cc:448
edm::service::MessageServicePSetValidation::vStringsCheck
void vStringsCheck(ParameterSet const &pset, std::string const &psetName)
Definition: MessageServicePSetValidation.cc:172
edm::service::MessageServicePSetValidation::statisticsPSet
void statisticsPSet(ParameterSet const &pset, std::string const &psetName)
Definition: MessageServicePSetValidation.cc:581
edm::service::MessageServicePSetValidation::categoryPSets
void categoryPSets(ParameterSet const &pset, std::string const &psetName)
Definition: MessageServicePSetValidation.cc:669
edm::service::MessageServicePSetValidation::noneExcept
void noneExcept(ParameterSet const &pset, std::string const &psetName, std::string const &type, std::string const &ok)
Definition: MessageServicePSetValidation.h:152
GOODCOLL_filter_cfg.thresh
thresh
Definition: GOODCOLL_filter_cfg.py:74
edm::service::MessageServicePSetValidation::disallowedParam
void disallowedParam(ParameterSet const &pset, vString const &v, std::string const &psetName, std::string const &parameterLabel, std::string const &type)
Definition: MessageServicePSetValidation.h:119
heppy_batch.val
val
Definition: heppy_batch.py:351
edm::service::MessageServicePSetValidation::vString
std::vector< String > vString
Definition: MessageServicePSetValidation.h:48
T
long double T
Definition: Basic3DVectorLD.h:48
edm::service::MessageServicePSetValidation::wildcard
bool wildcard(vString const &v)
Definition: MessageServicePSetValidation.cc:400
edm::service::MessageServicePSetValidation::destinationPSet
void destinationPSet(ParameterSet const &pset, std::string const &psetName)
Definition: MessageServicePSetValidation.cc:463
edm::service::MessageServicePSetValidation::check
T check(ParameterSet const &pset, std::string const &psetName, std::string const &parameterLabel)
Definition: MessageServicePSetValidation.h:94
Exception.h
edm::service::MessageServicePSetValidation::categories_
std::vector< std::string > categories_
Definition: MessageServicePSetValidation.h:258
cms::Exception
Definition: Exception.h:70
ParameterSet.h
edm::service::MessageServicePSetValidation::statistics_
std::vector< std::string > statistics_
Definition: MessageServicePSetValidation.h:257
edm::service::MessageServicePSetValidation::suppressWarning_
std::vector< std::string > suppressWarning_
Definition: MessageServicePSetValidation.h:263
edm::service::MessageServicePSetValidation::noneExcept
void noneExcept(ParameterSet const &pset, std::string const &psetName, std::string const &type, T const &ok1, T const &ok2)
Definition: MessageServicePSetValidation.h:178
edm::service::MessageServicePSetValidation::noNonPSetUsage
void noNonPSetUsage(ParameterSet const &pset, vString const &v, std::string const &psetName, std::string const &parameterLabel)
Definition: MessageServicePSetValidation.cc:368
edm::service::MessageServicePSetValidation::noCoutCerrClash
void noCoutCerrClash(vString const &v, std::string const &psetName, std::string const &parameterLabel)
Definition: MessageServicePSetValidation.cc:272
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
edm::service::MessageServicePSetValidation::suppressDebug_
std::vector< std::string > suppressDebug_
Definition: MessageServicePSetValidation.h:262
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37