CMS 3D CMS Logo

validateTopLevelParameterSets.cc
Go to the documentation of this file.
2 
5 
7 
8 #include <sstream>
9 #include <vector>
10 #include <string>
11 
12 namespace edm {
13 
15  description.addUntracked<unsigned int>("numberOfThreads", s_defaultNumberOfThreads)
16  ->setComment("If zero, let TBB use its default which is normally the number of CPUs on the machine");
17  description.addUntracked<unsigned int>("numberOfStreams", 0)
18  ->setComment("If zero, then set the number of streams to be the same as the number of threads");
19  description.addUntracked<unsigned int>("numberOfConcurrentRuns", 1);
20  description.addUntracked<unsigned int>("numberOfConcurrentLuminosityBlocks", 1)
21  ->setComment("If zero, then set the same as the number of runs");
22  description.addUntracked<bool>("wantSummary", false)
23  ->setComment("Set true to print a report on the trigger decisions and timing of modules");
24  description.addUntracked<std::string>("fileMode", "FULLMERGE")
25  ->setComment("Legal values are 'NOMERGE' and 'FULLMERGE'");
26  description.addUntracked<bool>("forceEventSetupCacheClearOnNewRun", false);
27  description.addUntracked<bool>("throwIfIllegalParameter", true)
28  ->setComment("Set false to disable exception throws when configuration validation detects illegal parameters");
29  description.addUntracked<bool>("printDependencies", false)->setComment("Print data dependencies between modules");
30 
31  // No default for this one because the parameter value is
32  // actually used in the main function in cmsRun.cpp before
33  // the parameter set is validated here.
34  description.addOptionalUntracked<unsigned int>("sizeOfStackForThreadsInKB");
35 
36  std::vector<std::string> emptyVector;
37 
38  description.addUntracked<std::vector<std::string>>("Rethrow", emptyVector);
39  description.addUntracked<std::vector<std::string>>("SkipEvent", emptyVector);
40  description.addUntracked<std::vector<std::string>>("FailPath", emptyVector);
41  description.addUntracked<std::vector<std::string>>("IgnoreCompletely", emptyVector);
42 
43  description.addUntracked<std::vector<std::string>>("canDeleteEarly", emptyVector)
44  ->setComment("Branch names of products that the Framework can try to delete before the end of the Event");
45 
46  description.addOptionalUntracked<bool>("allowUnscheduled")
47  ->setComment(
48  "Obsolete. Has no effect. Allowed only for backward compatibility for old Python configuration files.");
49  description.addOptionalUntracked<std::string>("emptyRunLumiMode")
50  ->setComment(
51  "Obsolete. Has no effect. Allowed only for backward compatibility for old Python configuration files.");
52  description.addOptionalUntracked<bool>("makeTriggerResults")
53  ->setComment(
54  "Obsolete. Has no effect. Allowed only for backward compatibility for old Python configuration files.");
55  }
56 
58  description.addUntracked<int>("input", -1)->setComment("Default of -1 implies no limit.");
59 
60  ParameterSetDescription nestedDescription;
61  nestedDescription.addWildcardUntracked<int>("*");
62  description.addOptionalNode(ParameterDescription<int>("output", false) xor
63  ParameterDescription<ParameterSetDescription>("output", nestedDescription, false),
64  false);
65  }
66 
68  description.addUntracked<int>("input", -1)->setComment("Default of -1 implies no limit.");
69  }
70 
72  description.addUntracked<int>("input", -1)->setComment("Default of -1 implies no limit.");
73  }
74 
75  void validateTopLevelParameterSets(ParameterSet* processParameterSet) {
76  std::string processName = processParameterSet->getParameter<std::string>("@process_name");
77 
78  std::vector<std::string> psetNames{"options", "maxEvents", "maxLuminosityBlocks", "maxSecondsUntilRampdown"};
79 
80  for (auto const& psetName : psetNames) {
81  bool isTracked{false};
82  ParameterSet* pset = processParameterSet->getPSetForUpdate(psetName, isTracked);
83  if (pset == nullptr) {
84  ParameterSet emptyPset;
85  processParameterSet->addUntrackedParameter<ParameterSet>(psetName, emptyPset);
86  pset = processParameterSet->getPSetForUpdate(psetName, isTracked);
87  }
88  if (isTracked) {
89  throw Exception(errors::Configuration) << "In the configuration the top level parameter set named \'"
90  << psetName << "\' in process \'" << processName << "\' is tracked.\n"
91  << "It must be untracked";
92  }
93 
95  if (psetName == "options") {
96  fillOptionsDescription(description);
97  } else if (psetName == "maxEvents") {
98  fillMaxEventsDescription(description);
99  } else if (psetName == "maxLuminosityBlocks") {
101  } else if (psetName == "maxSecondsUntilRampdown") {
103  }
104 
105  try {
106  description.validate(*pset);
107  } catch (cms::Exception& ex) {
108  std::ostringstream ost;
109  ost << "Validating top level \'" << psetName << "\' ParameterSet for process \'" << processName << "\'";
110  ex.addContext(ost.str());
111  throw;
112  }
113  }
114  }
115 
116 } // namespace edm
T getParameter(std::string const &) const
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void validate(ParameterSet &pset) const
ParameterWildcardBase * addWildcardUntracked(U const &pattern)
void validateTopLevelParameterSets(ParameterSet *processParameterSet)
void fillOptionsDescription(ParameterSetDescription &description)
void fillMaxEventsDescription(ParameterSetDescription &description)
ParameterDescriptionNode * addOptionalNode(ParameterDescriptionNode const &node, bool writeToCfi)
constexpr unsigned int s_defaultNumberOfThreads
void fillMaxLuminosityBlocksDescription(ParameterSetDescription &description)
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:182
void addContext(std::string const &context)
Definition: Exception.cc:165
HLT enums.
void fillMaxSecondsUntilRampdownDescription(ParameterSetDescription &description)
ParameterDescriptionBase * addOptionalUntracked(U const &iLabel, T const &value)
ParameterSet * getPSetForUpdate(std::string const &name, bool &isTracked)