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 fwkJobReportPSets(ParameterSet const& pset);
85  void fwkJobReportPSet(ParameterSet const& pset, std::string const& psetName);
86  void categoryPSets(ParameterSet const& pset, std::string const& psetName);
87  void categoryPSet(ParameterSet const& pset, std::string const& OuterPsetName, std::string const& categoryName);
88  void catInts(ParameterSet const& pset, std::string const& psetName, std::string const& categoryName);
89  void catNoPSets(ParameterSet const& pset, std::string const& psetName, std::string const& categoryName);
91  std::string const& psetName,
92  std::string const& categoryName,
93  std::string const& type);
94 
95  template <typename T>
96  T check(ParameterSet const& pset, std::string const& psetName, std::string const& parameterLabel) {
97  T val = T();
98  try {
99  if (!pset.exists(parameterLabel))
100  return val;
101  if (pset.existsAs<T>(parameterLabel, false)) {
102  val = pset.getUntrackedParameter<T>(parameterLabel, val);
103  return val;
104  }
105  if (pset.existsAs<T>(parameterLabel, true)) {
106  flaws << psetName << " PSet: \n" << parameterLabel << " is declared as tracked - needs to be untracked \n";
107  val = pset.getParameter<T>(parameterLabel);
108  } else {
109  flaws << psetName << " PSet: \n" << parameterLabel << " is declared with incorrect type \n";
110  }
111  return val;
112  } catch (cms::Exception& e) {
113  flaws << psetName << " PSet: \n"
114  << parameterLabel << " is declared but causes an exception when processed: \n"
115  << e.what() << "\n";
116  return val;
117  }
118  } // check()
119 
120  template <typename T>
122  vString const& v,
123  std::string const& psetName,
124  std::string const& parameterLabel,
125  std::string const& type) {
126  vString params = pset.getParameterNamesForType<T>(true);
127  noBadParams(v, params, psetName, parameterLabel, type);
128  params = pset.getParameterNamesForType<T>(false);
129  noBadParams(v, params, psetName, parameterLabel, type);
130  } // disallowedParam()
131 
132  template <typename T>
133  void noneExcept(ParameterSet const& pset, std::string const& psetName, std::string const& type) {
134  vString x = pset.template getParameterNamesForType<T>(false);
135  vString::const_iterator end = x.end();
136  for (vString::const_iterator i = x.begin(); i != end; ++i) {
137  flaws << psetName << " PSet: \n"
138  << (*i) << " is used as a " << type << "\n"
139  << "Usage of " << type << " is not recognized here\n";
140  }
141  x = pset.template getParameterNamesForType<T>(true);
142  end = x.end();
143  for (vString::const_iterator i = x.begin(); i != end; ++i) {
144  if ((*i) == "@service_type")
145  continue;
146  flaws << psetName << " PSet: \n"
147  << (*i) << " is used as a tracked " << type << "\n"
148  << "Tracked parameters not allowed here, "
149  << " and even untracked it would not be recognized\n";
150  }
151  } // noneExcept()
152 
153  template <typename T>
155  std::string const& psetName,
156  std::string const& type,
157  std::string const& ok) {
158  vString x = pset.template getParameterNamesForType<T>(false);
159  vString::const_iterator end = x.end();
160  for (vString::const_iterator i = x.begin(); i != end; ++i) {
161  std::string val = (*i);
162  if (val != ok) {
163  flaws << psetName << " PSet: \n"
164  << val << " is used as a " << type << "\n"
165  << "This usage is not recognized in this type of PSet\n";
166  }
167  }
168  x = pset.template getParameterNamesForType<T>(true);
169  end = x.end();
170  for (vString::const_iterator i = x.begin(); i != end; ++i) {
171  if ((*i) == "@service_type")
172  continue;
173  flaws << psetName << " PSet: \n"
174  << (*i) << " is used as a tracked " << type << "\n"
175  << "Tracked parameters not allowed here\n";
176  }
177  } // noneExcept(okValue)
178 
179  template <typename T>
181  ParameterSet const& pset, std::string const& psetName, std::string const& type, T const& ok1, T const& ok2) {
182  vString x = pset.template getParameterNamesForType<T>(false);
183  vString::const_iterator end = x.end();
184  for (vString::const_iterator i = x.begin(); i != end; ++i) {
185  std::string val = (*i);
186  if ((val != ok1) && (val != ok2)) {
187  flaws << psetName << " PSet: \n"
188  << val << " is used as a " << type << "\n"
189  << "This usage is not recognized in this type of PSet\n";
190  }
191  }
192  x = pset.template getParameterNamesForType<T>(true);
193  end = x.end();
194  for (vString::const_iterator i = x.begin(); i != end; ++i) {
195  if ((*i) == "@service_type")
196  continue;
197  flaws << psetName << " PSet: \n"
198  << (*i) << " is used as a tracked " << type << "\n"
199  << "Tracked parameters not allowed here\n";
200  }
201  } // noneExcept(okValue1, okValue2)
202 
203  template <typename T>
205  std::string const& psetName,
206  std::string const& type,
207  vString const& vok) {
208  vString x = pset.template getParameterNamesForType<T>(false);
209  vString::const_iterator end = x.end();
210  vString::const_iterator vend = vok.end();
211  for (vString::const_iterator i = x.begin(); i != end; ++i) {
212  bool found = false;
213  for (vString::const_iterator vit = vok.begin(); vit != vend; ++vit) {
214  if (*i == *vit)
215  found = true;
216  }
217  if (!found) {
218  flaws << psetName << " PSet: \n"
219  << *i << " is used as a " << type << "\n"
220  << "This usage is not recognized in this type of PSet\n";
221  }
222  }
223  x = pset.template getParameterNamesForType<T>(true);
224  end = x.end();
225  for (vString::const_iterator i = x.begin(); i != end; ++i) {
226  if ((*i) == "@service_type")
227  continue;
228  flaws << psetName << " PSet: \n"
229  << (*i) << " is used as a tracked " << type << "\n"
230  << "Tracked parameters not allowed here\n";
231  }
232  } // noneExcept(vok)
233 
234  template <typename T>
235  void catNone(ParameterSet const& pset,
236  std::string const& psetName,
237  std::string const& categoryName,
238  std::string const& type) {
239  vString x = pset.template getParameterNamesForType<T>(false);
240  vString::const_iterator end = x.end();
241  for (vString::const_iterator i = x.begin(); i != end; ++i) {
242  flaws << categoryName << " category PSet nested in " << psetName << " PSet: \n"
243  << (*i) << " is used as a " << type << "\n"
244  << "Usage of " << type << " is not recognized here\n";
245  }
246  x = pset.template getParameterNamesForType<T>(true);
247  end = x.end();
248  for (vString::const_iterator i = x.begin(); i != end; ++i) {
249  flaws << categoryName << " category PSet nested in " << psetName << " PSet: \n"
250  << (*i) << " is used as a tracked " << type << "\n"
251  << "Tracked parameters not allowed here, "
252  << " and even untracked it would not be recognized\n";
253  }
254  } // catNone()
255 
256  // private data
257  std::ostringstream flaws;
258  std::vector<std::string> destinations;
259  std::vector<std::string> statistics;
260  std::vector<std::string> fwkJobReports;
261  std::vector<std::string> categories;
262  std::vector<std::string> messageIDs;
263  std::vector<std::string> debugModules;
264  std::vector<std::string> suppressInfo;
265  std::vector<std::string> suppressDebug;
266  std::vector<std::string> suppressWarning;
267  std::vector<std::string> suppressError;
268 
269  }; // MessageServicePSetValidation
270 
271  } // namespace service
272 
273 } // namespace edm
274 
275 #endif // FWCore_MessageService_MessageServicePSetValidation_h
vend
#define vend()
Definition: vmac.h:43
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:773
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:382
mps_fire.i
i
Definition: mps_fire.py:355
edm::service::MessageServicePSetValidation::noneExcept
void noneExcept(ParameterSet const &pset, std::string const &psetName, std::string const &type, vString const &vok)
Definition: MessageServicePSetValidation.h:204
edm::service::MessageServicePSetValidation::suppressError
std::vector< std::string > suppressError
Definition: MessageServicePSetValidation.h:267
edm::service::MessageServicePSetValidation::noneExcept
void noneExcept(ParameterSet const &pset, std::string const &psetName, std::string const &type)
Definition: MessageServicePSetValidation.h:133
edm::service::MessageServicePSetValidation::noDuplicates
void noDuplicates(vString const &v, std::string const &psetName, std::string const &parameterLabel)
Definition: MessageServicePSetValidation.cc:248
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:297
edm::service::MessageServicePSetValidation::checkThreshold
bool checkThreshold(std::string const &thresh)
Definition: MessageServicePSetValidation.cc:236
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:235
edm::service::MessageServicePSetValidation::statisticsPSets
void statisticsPSets(ParameterSet const &pset)
Definition: MessageServicePSetValidation.cc:565
edm::service::MessageServicePSetValidation::noOtherPsets
void noOtherPsets(ParameterSet const &pset)
Definition: MessageServicePSetValidation.cc:410
edm::service::MessageServicePSetValidation::keywordCheck
bool keywordCheck(std::string const &word)
Definition: MessageServicePSetValidation.cc:309
edm::service::MessageServicePSetValidation::destinations
std::vector< std::string > destinations
Definition: MessageServicePSetValidation.h:258
edm::service::MessageServicePSetValidation::catBoolRestriction
void catBoolRestriction(ParameterSet const &pset, std::string const &psetName, std::string const &categoryName, std::string const &type)
Definition: MessageServicePSetValidation.cc:797
edm::service::MessageServicePSetValidation::operator()
std::string operator()(ParameterSet const &pset)
Definition: MessageServicePSetValidation.cc:30
edm::service::MessageServicePSetValidation::categories
std::vector< std::string > categories
Definition: MessageServicePSetValidation.h:261
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:459
end
#define end
Definition: vmac.h:39
edm::service::MessageServicePSetValidation::defaultPSet
void defaultPSet(ParameterSet const &main_pset)
Definition: MessageServicePSetValidation.cc:516
edm::service::MessageServicePSetValidation::allowedVstring
bool allowedVstring(std::string const &s)
Definition: MessageServicePSetValidation.cc:201
edm::service::MessageServicePSetValidation::categoryPSet
void categoryPSet(ParameterSet const &pset, std::string const &OuterPsetName, std::string const &categoryName)
Definition: MessageServicePSetValidation.cc:728
word
uint64_t word
Definition: CTPPSTotemDataFormatter.cc:29
edm::service::MessageServicePSetValidation::flaws
std::ostringstream flaws
Definition: MessageServicePSetValidation.h:257
alignCSCRings.s
s
Definition: alignCSCRings.py:92
edm::service::MessageServicePSetValidation::messageLoggerPSet
void messageLoggerPSet(ParameterSet const &pset)
Definition: MessageServicePSetValidation.cc:35
edm::service::MessageServicePSetValidation::psetLists
void psetLists(ParameterSet const &pset)
Definition: MessageServicePSetValidation.cc:97
edm::service::MessageServicePSetValidation::fwkJobReportPSets
void fwkJobReportPSets(ParameterSet const &pset)
Definition: MessageServicePSetValidation.cc:621
edm::service::MessageServicePSetValidation::validateThreshold
bool validateThreshold(std::string const &thresh, std::string const &psetName)
Definition: MessageServicePSetValidation.cc:227
edm::service::MessageServicePSetValidation::String
std::string String
Definition: MessageServicePSetValidation.h:47
p2
double p2[4]
Definition: TauolaWrapper.h:90
edm::service::MessageServicePSetValidation::suppressionLists
void suppressionLists(ParameterSet const &pset)
Definition: MessageServicePSetValidation.cc:135
edm::service::MessageServicePSetValidation::noNoncategoryPsets
void noNoncategoryPsets(ParameterSet const &pset, std::string const &psetName)
Definition: MessageServicePSetValidation.cc:669
edm::service::MessageServicePSetValidation::debugModules
std::vector< std::string > debugModules
Definition: MessageServicePSetValidation.h:263
edm::service::MessageServicePSetValidation
Definition: MessageServicePSetValidation.h:42
edm::service::MessageServicePSetValidation::messageIDs
std::vector< std::string > messageIDs
Definition: MessageServicePSetValidation.h:262
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:749
edm::ParameterSet
Definition: ParameterSet.h:36
edm::service::MessageServicePSetValidation::suppressInfo
std::vector< std::string > suppressInfo
Definition: MessageServicePSetValidation.h:264
p1
double p1[4]
Definition: TauolaWrapper.h:89
edm::service::MessageServicePSetValidation::lookForMatch
bool lookForMatch(vString const &v, std::string const &s)
Definition: MessageServicePSetValidation.cc:453
edm::service::MessageServicePSetValidation::vStringsCheck
void vStringsCheck(ParameterSet const &pset, std::string const &psetName)
Definition: MessageServicePSetValidation.cc:179
edm::service::MessageServicePSetValidation::statisticsPSet
void statisticsPSet(ParameterSet const &pset, std::string const &psetName)
Definition: MessageServicePSetValidation.cc:576
edm::service::MessageServicePSetValidation::categoryPSets
void categoryPSets(ParameterSet const &pset, std::string const &psetName)
Definition: MessageServicePSetValidation.cc:712
edm::service::MessageServicePSetValidation::noneExcept
void noneExcept(ParameterSet const &pset, std::string const &psetName, std::string const &type, std::string const &ok)
Definition: MessageServicePSetValidation.h:154
GOODCOLL_filter_cfg.thresh
thresh
Definition: GOODCOLL_filter_cfg.py:74
edm::service::MessageServicePSetValidation::suppressWarning
std::vector< std::string > suppressWarning
Definition: MessageServicePSetValidation.h:266
type
type
Definition: HCALResponse.h:21
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:121
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:401
edm::service::MessageServicePSetValidation::destinationPSet
void destinationPSet(ParameterSet const &pset, std::string const &psetName)
Definition: MessageServicePSetValidation.cc:468
edm::service::MessageServicePSetValidation::check
T check(ParameterSet const &pset, std::string const &psetName, std::string const &parameterLabel)
Definition: MessageServicePSetValidation.h:96
Exception.h
edm::service::MessageServicePSetValidation::fwkJobReports
std::vector< std::string > fwkJobReports
Definition: MessageServicePSetValidation.h:260
cms::Exception
Definition: Exception.h:70
edm::service::MessageServicePSetValidation::suppressDebug
std::vector< std::string > suppressDebug
Definition: MessageServicePSetValidation.h:265
ParameterSet.h
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:180
edm::service::MessageServicePSetValidation::noNonPSetUsage
void noNonPSetUsage(ParameterSet const &pset, vString const &v, std::string const &psetName, std::string const &parameterLabel)
Definition: MessageServicePSetValidation.cc:369
edm::service::MessageServicePSetValidation::statistics
std::vector< std::string > statistics
Definition: MessageServicePSetValidation.h:259
edm::service::MessageServicePSetValidation::noCoutCerrClash
void noCoutCerrClash(vString const &v, std::string const &psetName, std::string const &parameterLabel)
Definition: MessageServicePSetValidation.cc:279
edm::service::MessageServicePSetValidation::fwkJobReportPSet
void fwkJobReportPSet(ParameterSet const &pset, std::string const &psetName)
Definition: MessageServicePSetValidation.cc:630
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37