CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
edm::ConfigurationDescriptions Class Reference

#include <ConfigurationDescriptions.h>

Classes

class  DescriptionCounter
 

Public Member Functions

void add (std::string const &label, ParameterSetDescription const &psetDescription)
 
void add (char const *label, ParameterSetDescription const &psetDescription)
 
void addDefault (ParameterSetDescription const &psetDescription)
 
std::string const & comment () const
 
 ConfigurationDescriptions (std::string const &baseType)
 
void print (std::ostream &os, std::string const &moduleLabel, bool brief, bool printOnlyLabels, size_t lineWidth, int indentation, int iPlugin) const
 
void setComment (std::string const &value)
 
void setComment (char const *value)
 
void validate (ParameterSet &pset, std::string const &moduleLabel) const
 
void writeCfis (std::string const &baseType, std::string const &pluginName) const
 
 ~ConfigurationDescriptions ()
 

Private Member Functions

void printForLabel (std::pair< std::string, ParameterSetDescription > const &labelAndDesc, std::ostream &os, std::string const &moduleLabel, bool brief, bool printOnlyLabels, size_t lineWidth, int indentationn, DescriptionCounter &counter) const
 
void printForLabel (std::ostream &os, std::string const &label, ParameterSetDescription const &description, std::string const &moduleLabel, bool brief, bool printOnlyLabels, size_t lineWidth, int indentationn, DescriptionCounter &counter) const
 

Static Private Member Functions

static void writeCfiForLabel (std::pair< std::string, ParameterSetDescription > const &labelAndDesc, std::string const &baseType, std::string const &pluginName)
 

Private Attributes

std::string baseType_
 
std::string comment_
 
ParameterSetDescription defaultDesc_
 
bool defaultDescDefined_
 
std::vector< std::pair
< std::string,
ParameterSetDescription > > 
descriptions_
 

Detailed Description

Definition at line 27 of file ConfigurationDescriptions.h.

Constructor & Destructor Documentation

ConfigurationDescriptions::ConfigurationDescriptions ( std::string const &  baseType)

Definition at line 37 of file ConfigurationDescriptions.cc.

ConfigurationDescriptions::~ConfigurationDescriptions ( )

Definition at line 42 of file ConfigurationDescriptions.cc.

42 {}

Member Function Documentation

void ConfigurationDescriptions::add ( std::string const &  label,
ParameterSetDescription const &  psetDescription 
)

Definition at line 60 of file ConfigurationDescriptions.cc.

References baseType_, defaultDescDefined_, descriptions_, edm::hlt::Exception, label, edm::errors::LogicError, and mergeVDriftHistosByStation::name.

Referenced by add(), edm::EmptySource::fillDescriptions(), edm::Prescaler::fillDescriptions(), edm::service::InitRootHandlers::fillDescriptions(), edm::EventAuxiliaryHistoryProducer::fillDescriptions(), HLTHPDFilter::fillDescriptions(), TFileAdaptor::fillDescriptions(), UpdaterService::fillDescriptions(), HLTHcalMETNoiseFilter::fillDescriptions(), HLTRFilter::fillDescriptions(), HLTRHemisphere::fillDescriptions(), HLTForwardBackwardJetsFilter::fillDescriptions(), edm::StreamerOutputModule< Consumer >::fillDescriptions(), edm::AsciiOutputModule::fillDescriptions(), HLTExclDiJetFilter::fillDescriptions(), HLTDiJetAveFilter::fillDescriptions(), edm::service::UnixSignalService::fillDescriptions(), HLTMhtHtFilter::fillDescriptions(), edm::service::SimpleProfiling::fillDescriptions(), edm::service::CPU::fillDescriptions(), edm::StreamerFileReader::fillDescriptions(), RandomEngineStateProducer::fillDescriptions(), HLTBool::fillDescriptions(), edm::ProvenanceCheckerOutputModule::fillDescriptions(), edm::PoolSource::fillDescriptions(), edm::GetProductCheckerOutputModule::fillDescriptions(), HLT1CaloJetEnergy::fillDescriptions(), HLTLevel1Pattern::fillDescriptions(), edm::rootfix::LockService::fillDescriptions(), LogErrorFilter::fillDescriptions(), edm::LogErrorHarvester::fillDescriptions(), edm::service::Timing::fillDescriptions(), edm::service::Tracer::fillDescriptions(), HLTLevel1Activity::fillDescriptions(), edm::service::LoadAllDictionaries::fillDescriptions(), EventIDChecker::fillDescriptions(), edm::PrintEventSetupDataRetrieval::fillDescriptions(), edm::service::SiteLocalConfigService::fillDescriptions(), edm::PrintEventSetupContent::fillDescriptions(), pat::PATPhotonProducer::fillDescriptions(), PrintLoadingPlugins::fillDescriptions(), edm::XMLOutputModule::fillDescriptions(), edm::PoolOutputModule::fillDescriptions(), edm::EventSetupRecordDataGetter::fillDescriptions(), edm::service::RandomNumberGeneratorService::fillDescriptions(), pat::PATJetProducer::fillDescriptions(), JetCollectionForEleHT::fillDescriptions(), MulticoreRunLumiEventChecker::fillDescriptions(), edm::service::SimpleMemoryCheck::fillDescriptions(), edm::service::PrescaleService::fillDescriptions(), pat::PATElectronProducer::fillDescriptions(), pat::JetCorrFactorsProducer::fillDescriptions(), edm::service::EnableFloatingPointExceptions::fillDescriptions(), and edm::EventContentAnalyzer::fillDescriptions().

61  {
62 
63  if (baseType_ == std::string("Source")) {
64  if (label != std::string("source")) {
66  "ConfigurationDescriptions::add, when adding a ParameterSetDescription for a source the label must be \"source\"\n");
67  }
68  if (descriptions_.size() != 0U ||
69  defaultDescDefined_ == true) {
71  "ConfigurationDescriptions::add, for a source only 1 ParameterSetDescription may be added\n");
72  }
73  }
74  else if (baseType_ == std::string("Service")) {
75  if (descriptions_.size() != 0U ||
76  defaultDescDefined_ == true) {
78  "ConfigurationDescriptions::add, for a service only 1 ParameterSetDescription may be added\n");
79  }
80  }
81 
82  // To minimize the number of copies involved create an empty description first
83  // and push it into the vector. Then perform the copy.
84  std::pair<std::string, ParameterSetDescription> pairWithEmptyDescription;
85  descriptions_.push_back(pairWithEmptyDescription);
86  std::pair<std::string, ParameterSetDescription> & pair = descriptions_.back();
87 
88  pair.first = label;
89  pair.second = psetDescription;
90 
91  if (baseType_ == std::string("ESSource") || baseType_ == std::string("ESProducer")) {
92  std::string name("appendToDataLabel");
93  if (pair.second.isLabelUnused(name)) {
94  pair.second.add<std::string>(name, std::string(""));
95  }
96  }
97  }
const std::string & label
Definition: MVAComputer.cc:186
std::vector< std::pair< std::string, ParameterSetDescription > > descriptions_
void ConfigurationDescriptions::add ( char const *  label,
ParameterSetDescription const &  psetDescription 
)

Definition at line 53 of file ConfigurationDescriptions.cc.

References add().

54  {
55  std::string labelString(label);
56  add(labelString, psetDescription);
57  }
const std::string & label
Definition: MVAComputer.cc:186
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void ConfigurationDescriptions::addDefault ( ParameterSetDescription const &  psetDescription)

Definition at line 100 of file ConfigurationDescriptions.cc.

References edm::ParameterSetDescription::add(), baseType_, defaultDesc_, defaultDescDefined_, descriptions_, edm::hlt::Exception, edm::ParameterSetDescription::isLabelUnused(), edm::errors::LogicError, and mergeVDriftHistosByStation::name.

Referenced by edm::EDAnalyzer::fillDescriptions(), edm::EDProducer::fillDescriptions(), edm::EDFilter::fillDescriptions(), PythonService::fillDescriptions(), fltrname::fillDescriptions(), anlzrname::fillDescriptions(), prodname::fillDescriptions(), EmDQMFeeder::fillDescriptions(), edm::service::JobReportService::fillDescriptions(), edm::OutputModule::fillDescriptions(), edm::InputSource::fillDescriptions(), DQMRootOutputModule::fillDescriptions(), DQMRootSource::fillDescriptions(), and edm::fillDetails::DoFillAsUnknown< T >::operator()().

100  {
101 
102  if (baseType_ == std::string("Source") || baseType_ == std::string("Service")) {
103  if (descriptions_.size() != 0U ||
104  defaultDescDefined_ == true) {
106  "ConfigurationDescriptions::addDefault, for a source or service only 1 ParameterSetDescription may be added\n");
107  }
108  }
109 
110  defaultDescDefined_ = true;
111  defaultDesc_ = psetDescription;
112 
113  if (baseType_ == std::string("ESSource") || baseType_ == std::string("ESProducer")) {
114  std::string name("appendToDataLabel");
116  defaultDesc_.add<std::string>(name, std::string(""));
117  }
118  }
119  }
std::vector< std::pair< std::string, ParameterSetDescription > > descriptions_
bool isLabelUnused(std::string const &label) const
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::string const& edm::ConfigurationDescriptions::comment ( ) const
inline

Definition at line 39 of file ConfigurationDescriptions.h.

References comment_.

Referenced by print().

void ConfigurationDescriptions::print ( std::ostream &  os,
std::string const &  moduleLabel,
bool  brief,
bool  printOnlyLabels,
size_t  lineWidth,
int  indentation,
int  iPlugin 
) const

Definition at line 199 of file ConfigurationDescriptions.cc.

References comment(), cmsDriverOptions::counter, defaultDesc_, defaultDescDefined_, descriptions_, relativeConstraints::empty, edm::for_all(), edm::ConfigurationDescriptions::DescriptionCounter::iModule, edm::ConfigurationDescriptions::DescriptionCounter::iPlugin, edm::ConfigurationDescriptions::DescriptionCounter::iSelectedModule, edm::ParameterSetDescription::isUnknown(), edm::DocFormatHelper::offsetModuleLabel(), printForLabel(), and edm::DocFormatHelper::wrapAndPrintText().

205  {
206  if (!brief) {
207  if (!comment().empty()) {
208  DocFormatHelper::wrapAndPrintText(os, comment(), indentation, lineWidth);
209  }
210  os << "\n";
211  }
212 
213  char oldFill = os.fill();
214  if (descriptions_.empty() && !defaultDescDefined_) {
215  indentation += DocFormatHelper::offsetModuleLabel();
216  os << std::setfill(' ') << std::setw(indentation) << "";
217  os << "There are no PSet descriptions defined for this plugin.\n";
218  os << std::setfill(' ') << std::setw(indentation) << "";
219  os << "PSets will not be validated and no cfi files will be generated.\n";
220  if (!brief) os << "\n";
221  os.fill(oldFill);
222  return;
223  }
224 
226  indentation += DocFormatHelper::offsetModuleLabel();
227  os << std::setfill(' ') << std::setw(indentation) << "";
228  os << "This plugin has not implemented the function which defines its\n";
229  os << std::setfill(' ') << std::setw(indentation) << "";
230  os << "configuration descriptions yet. No descriptions are available.\n";
231  os << std::setfill(' ') << std::setw(indentation) << "";
232  os << "Its PSets will not be validated, and no cfi files will be generated.\n";
233  if (!brief) os << "\n";
234  os.fill(oldFill);
235  return;
236  }
237 
238  if (!brief) {
239  std::stringstream ss;
240  if (defaultDescDefined_) {
241  if (descriptions_.empty()) {
242  ss << "This plugin has only one PSet description. "
243  << "This description is always used to validate configurations. "
244  << "Because this configuration has no label, no cfi files will be generated.";
245  }
246  else {
247  ss << "This plugin has " << (descriptions_.size() + 1U) << " PSet descriptions. "
248  << "The description used to validate a configuration is selected by "
249  << "matching the module labels. If none match, then the last description, "
250  << "which has no label, is selected. "
251  << "A cfi file will be generated for each configuration with a module label.";
252  }
253  }
254  else {
255  if (descriptions_.size() == 1U) {
256  ss << "This plugin has " << descriptions_.size() << " PSet description. "
257  << "This description is always used to validate configurations. "
258  << "The label below is used when generating the cfi file.";
259  }
260  else {
261  ss << "This plugin has " << descriptions_.size() << " PSet descriptions. "
262  << "The description used to validate a configuration is selected by "
263  << "matching the module labels. If none match the first description below is used. "
264  << "The module labels below are also used when generating the cfi files.";
265  }
266  }
267  DocFormatHelper::wrapAndPrintText(os, ss.str(), indentation, lineWidth);
268  os << "\n";
269  }
270 
271  indentation += DocFormatHelper::offsetModuleLabel();
272 
273  DescriptionCounter counter;
274  counter.iPlugin = iPlugin;
275  counter.iSelectedModule = 0;
276  counter.iModule = 0;
277 
279  this,
280  _1,
281  boost::ref(os),
282  boost::cref(moduleLabel),
283  brief,
284  printOnlyLabels,
285  lineWidth,
286  indentation,
287  boost::ref(counter)));
288 
289  if (defaultDescDefined_) {
290  printForLabel(os,
291  std::string("@default"),
292  defaultDesc_,
293  moduleLabel,
294  brief,
295  printOnlyLabels,
296  lineWidth,
297  indentation,
298  counter);
299  }
300  }
void printForLabel(std::pair< std::string, ParameterSetDescription > const &labelAndDesc, std::ostream &os, std::string const &moduleLabel, bool brief, bool printOnlyLabels, size_t lineWidth, int indentationn, DescriptionCounter &counter) const
static void wrapAndPrintText(std::ostream &os, std::string const &text, size_t indent, size_t suggestedWidth)
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:16
static int offsetModuleLabel()
std::vector< std::pair< std::string, ParameterSetDescription > > descriptions_
std::string const & comment() const
const std::string * moduleLabel() const
Definition: HLTadd.h:40
void ConfigurationDescriptions::printForLabel ( std::pair< std::string, ParameterSetDescription > const &  labelAndDesc,
std::ostream &  os,
std::string const &  moduleLabel,
bool  brief,
bool  printOnlyLabels,
size_t  lineWidth,
int  indentationn,
DescriptionCounter counter 
) const
private

Definition at line 303 of file ConfigurationDescriptions.cc.

Referenced by print().

311  {
312  printForLabel(os,
313  labelAndDesc.first,
314  labelAndDesc.second,
315  moduleLabel,
316  brief,
317  printOnlyLabels,
318  lineWidth,
319  indentation,
320  counter);
321  }
void printForLabel(std::pair< std::string, ParameterSetDescription > const &labelAndDesc, std::ostream &os, std::string const &moduleLabel, bool brief, bool printOnlyLabels, size_t lineWidth, int indentationn, DescriptionCounter &counter) const
const std::string * moduleLabel() const
Definition: HLTadd.h:40
void ConfigurationDescriptions::printForLabel ( std::ostream &  os,
std::string const &  label,
ParameterSetDescription const &  description,
std::string const &  moduleLabel,
bool  brief,
bool  printOnlyLabels,
size_t  lineWidth,
int  indentationn,
DescriptionCounter counter 
) const
private

Definition at line 324 of file ConfigurationDescriptions.cc.

References baseType_, edm::ParameterSetDescription::comment(), edm::ConfigurationDescriptions::DescriptionCounter::iModule, edm::ConfigurationDescriptions::DescriptionCounter::iPlugin, edm::ConfigurationDescriptions::DescriptionCounter::iSelectedModule, moduleLabel(), edm::DocFormatHelper::offsetTopLevelPSet(), edm::ParameterSetDescription::print(), edm::DocFormatHelper::setBrief(), edm::DocFormatHelper::setIndentation(), edm::DocFormatHelper::setLineWidth(), edm::DocFormatHelper::setParent(), edm::DocFormatHelper::setSection(), edm::DocFormatHelper::TOP, and edm::DocFormatHelper::wrapAndPrintText().

333  {
334  ++counter.iModule;
335  if (!moduleLabel.empty() && label != moduleLabel) return;
336  ++counter.iSelectedModule;
337 
338  std::stringstream ss;
339  ss << counter.iPlugin << "." << counter.iSelectedModule;
340  std::string section = ss.str();
341 
342  char oldFill = os.fill();
343  os << std::setfill(' ') << std::setw(indentation) << "";
344  os.fill(oldFill);
345  os << section << " ";
346  if (label == std::string("@default")) {
347  os << "description without a module label\n";
348  }
349  else {
350  if (!brief) {
351  if (baseType_ == std::string("Source") || baseType_ == std::string("Service")) {
352  os << "label: ";
353  }
354  else {
355  os << "module label: ";
356  }
357  }
358  os << label << "\n";
359  }
360 
361  if (!brief) {
362  if (!description.comment().empty()) {
363  DocFormatHelper::wrapAndPrintText(os, description.comment(), indentation, lineWidth - indentation);
364  }
365  os << "\n";
366  }
367  if (printOnlyLabels) return;
368 
369  DocFormatHelper dfh;
370  dfh.setBrief(brief);
371  dfh.setLineWidth(lineWidth);
372  dfh.setIndentation(indentation + DocFormatHelper::offsetTopLevelPSet());
373  dfh.setSection(section);
374  dfh.setParent(DocFormatHelper::TOP);
375 
376  description.print(os, dfh);
377  }
const std::string & label
Definition: MVAComputer.cc:186
static void wrapAndPrintText(std::ostream &os, std::string const &text, size_t indent, size_t suggestedWidth)
tuple description
Definition: idDealer.py:66
static int offsetTopLevelPSet()
const std::string * moduleLabel() const
Definition: HLTadd.h:40
void ConfigurationDescriptions::setComment ( std::string const &  value)
void ConfigurationDescriptions::setComment ( char const *  value)
void ConfigurationDescriptions::validate ( ParameterSet pset,
std::string const &  moduleLabel 
) const

Definition at line 122 of file ConfigurationDescriptions.cc.

References defaultDesc_, defaultDescDefined_, descriptions_, edm::for_all(), and edm::ParameterSetDescription::validate().

Referenced by edm::makeInput(), edm::Maker::makeWorker(), and edm::eventsetup::validateEventSetupParameters().

123  {
124 
125  ParameterSetDescription const* psetDesc = 0;
126  for_all(descriptions_, boost::bind(&matchLabel,
127  _1,
128  boost::cref(moduleLabel),
129  boost::ref(psetDesc)));
130 
131  // If there is a matching label
132  if (psetDesc != 0) {
133  psetDesc->validate(pset);
134  }
135  // Is there an explicit description to be used for a non standard label
136  else if (defaultDescDefined_) {
137  defaultDesc_.validate(pset);
138  }
139  // Otherwise use the first one.
140  else if (descriptions_.size() > 0U) {
141  descriptions_[0].second.validate(pset);
142  }
143  // It is possible for no descriptions to be defined and no validation occurs
144  // for this module ever.
145  }
void validate(ParameterSet &pset) const
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:16
std::vector< std::pair< std::string, ParameterSetDescription > > descriptions_
const std::string * moduleLabel() const
Definition: HLTadd.h:40
void ConfigurationDescriptions::writeCfiForLabel ( std::pair< std::string, ParameterSetDescription > const &  labelAndDesc,
std::string const &  baseType,
std::string const &  pluginName 
)
staticprivate

Definition at line 159 of file ConfigurationDescriptions.cc.

References gather_cfg::cout, edm::hlt::Exception, and edm::errors::LogicError.

Referenced by writeCfis().

162  {
163  if (baseType == std::string("Service") && labelAndDesc.first != pluginName) {
165  "ConfigurationDescriptions::writeCfiForLabel\nFor a service the label and the plugin name must be the same.\n")
166  << "This error probably is caused by an incorrect label being passed\nto the ConfigurationDescriptions::add function earlier.\n"
167  << "plugin name = \"" << pluginName << "\" label name = \"" << labelAndDesc.first << "\"\n";
168  }
169 
170  std::string cfi_filename;
171  if (baseType == std::string("Source")) {
172  cfi_filename = pluginName + "_cfi.py";
173  }
174  else {
175  cfi_filename = labelAndDesc.first + "_cfi.py";
176  }
177  std::ofstream outFile(cfi_filename.c_str());
178 
179 
180  outFile << "import FWCore.ParameterSet.Config as cms\n\n";
181  outFile << labelAndDesc.first << " = cms." << baseType << "('" << pluginName << "'";
182 
183  bool startWithComma = true;
184  int indentation = 2;
185  labelAndDesc.second.writeCfi(outFile, startWithComma, indentation);
186 
187  outFile << ")\n";
188 
189  outFile.close();
190 
191  if (baseType == std::string("Source")) {
192  std::cout << pluginName << "\n";
193  }
194  else {
195  std::cout << labelAndDesc.first << "\n";
196  }
197  }
tuple cout
Definition: gather_cfg.py:41
void ConfigurationDescriptions::writeCfis ( std::string const &  baseType,
std::string const &  pluginName 
) const

Definition at line 148 of file ConfigurationDescriptions.cc.

References descriptions_, edm::for_all(), and writeCfiForLabel().

149  {
150 
152  _1,
153  boost::cref(baseType),
154  boost::cref(pluginName)));
155  }
static void writeCfiForLabel(std::pair< std::string, ParameterSetDescription > const &labelAndDesc, std::string const &baseType, std::string const &pluginName)
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:16
std::vector< std::pair< std::string, ParameterSetDescription > > descriptions_

Member Data Documentation

std::string edm::ConfigurationDescriptions::baseType_
private

Definition at line 99 of file ConfigurationDescriptions.h.

Referenced by add(), addDefault(), and printForLabel().

std::string edm::ConfigurationDescriptions::comment_
private

Definition at line 106 of file ConfigurationDescriptions.h.

Referenced by comment(), and setComment().

ParameterSetDescription edm::ConfigurationDescriptions::defaultDesc_
private

Definition at line 104 of file ConfigurationDescriptions.h.

Referenced by addDefault(), print(), and validate().

bool edm::ConfigurationDescriptions::defaultDescDefined_
private

Definition at line 103 of file ConfigurationDescriptions.h.

Referenced by add(), addDefault(), print(), and validate().

std::vector<std::pair<std::string, ParameterSetDescription> > edm::ConfigurationDescriptions::descriptions_
private

Definition at line 101 of file ConfigurationDescriptions.h.

Referenced by add(), addDefault(), print(), validate(), and writeCfis().