51 std::set<std::string>& validatedLabels,
52 bool optional)
const {
64 if(!optional && !exists) {
70 validatedLabels.insert(
label());
80 psetDesc_->validate(*containedPSet);
89 os <<
"see Section " << dfh.
section()
91 if(!writeToCfi) os <<
" (do not write to cfi)";
111 std::stringstream ss;
116 os <<
"Section " << newSection
117 <<
" " <<
label() <<
" PSet description:\n";
118 if(!dfh.
brief()) os <<
"\n";
126 psetDesc_->print(os, new_dfh);
138 return psetDesc_.operator->();
144 return psetDesc_.operator->();
150 bool startWithComma =
false;
152 psetDesc_->writeCfi(os, startWithComma, indentation);
181 std::vector<ParameterSet>
const& vPset,
186 partOfDefaultOfVPSet_(
false) {
193 std::vector<ParameterSet>
const& vPset,
198 partOfDefaultOfVPSet_(
false) {
209 partOfDefaultOfVPSet_(
false) {
220 partOfDefaultOfVPSet_(
false) {
229 return psetDesc_.operator->();
235 return psetDesc_.operator->();
241 std::set<std::string>& validatedLabels,
242 bool optional)
const {
247 validatedLabels.insert(
label());
254 if(!exists && !optional) {
261 validatedLabels.insert(
label());
272 for(
unsigned i = 0;
i < vpsetEntry->
size(); ++
i) {
283 os <<
"see Section " << dfh.
section()
285 if(!writeToCfi) os <<
" (do not write to cfi)";
307 if(!partOfDefaultOfVPSet_) {
310 <<
" " <<
label() <<
" VPSet description:\n";
313 os <<
"All elements will be validated using the PSet description in Section " 318 <<
" " <<
" VPSet description for VPSet that is part of the default of a containing VPSet:\n";
323 unsigned subsectionOffset = 2;
324 if(partOfDefaultOfVPSet_) subsectionOffset = 1;
327 if(vPset_.empty()) os <<
"The default VPSet is empty.\n";
328 else if(vPset_.size() == 1
U) os <<
"The default VPSet has 1 element.\n";
329 else os <<
"The default VPSet has " << vPset_.size() <<
" elements.\n";
331 if(!vPset_.empty()) {
332 for(
unsigned i = 0;
i < vPset_.size(); ++
i) {
334 os <<
"[" << (
i) <<
"]: see Section " << dfh.
section()
335 <<
"." << dfh.
counter() <<
"." << (
i + subsectionOffset) <<
"\n";
339 os <<
"Does not have a default VPSet.\n";
342 if(!dfh.
brief()) os <<
"\n";
344 if(!partOfDefaultOfVPSet_) {
346 std::stringstream ss;
351 os <<
"Section " << newSection <<
" description of PSet used to validate elements of VPSet:\n";
352 if(!dfh.
brief()) os <<
"\n";
360 psetDesc_->print(os, new_dfh);
364 for(
unsigned i = 0;
i < vPset_.size(); ++
i) {
366 std::stringstream ss;
367 ss << dfh.
section() <<
"." << dfh.
counter() <<
"." << (
i + subsectionOffset);
371 os <<
"Section " << newSection <<
" PSet description of " 372 <<
"default VPSet element [" <<
i <<
"]\n";
373 if(!dfh.
brief()) os <<
"\n";
384 defaultDescription.
print(os, new_dfh);
400 bool& nextOneStartsWithAComma) {
401 if(nextOneStartsWithAComma) os <<
",";
402 nextOneStartsWithAComma =
true;
408 bool startWithComma =
false;
409 int indent = indentation + 4;
413 psetDesc.
writeCfi(os, startWithComma, indent);
421 bool nextOneStartsWithAComma =
false;
422 for_all(vPset_, std::bind(&writeOneElementToCfi,
423 std::placeholders::_1,
426 std::ref(nextOneStartsWithAComma)));
453 namespace writeParameterValue {
481 s << std::setprecision(17) <<
value;
484 if(result.size() > 15 && std::string::npos != result.find(
".")) {
486 s << std::setprecision(15) <<
value;
489 if(resultLessPrecision.size() < result.size() - 2) {
490 double test = std::strtod(resultLessPrecision.c_str(),
nullptr);
492 result = resultLessPrecision;
507 value ? os <<
"True" : os <<
"False";
512 os <<
"'" << value <<
"'";
518 os << value.run() <<
", " << value.luminosityBlock() <<
", " << value.event();
520 if(value.luminosityBlock() == 0
U) {
521 os << value.run() <<
":" << value.event();
523 os << value.run() <<
":" << value.luminosityBlock() <<
":" << value.event();
530 if(
format ==
CFI) os << value.run() <<
", " << value.luminosityBlock();
531 else os << value.run() <<
":" << value.luminosityBlock();
536 if(value.startLumi() == 0
U) {
537 if(
format ==
CFI) os <<
"'" << value.startRun() <<
":" << value.startEvent() <<
"-" 538 << value.endRun() <<
":" << value.endEvent() <<
"'";
539 else os << value.startRun() <<
":" << value.startEvent() <<
"-" 540 << value.endRun() <<
":" << value.endEvent();
542 if(
format ==
CFI) os <<
"'" << value.startRun() <<
":" << value.startLumi() <<
":" << value.startEvent() <<
"-" 543 << value.endRun() <<
":" << value.endLumi() <<
":" << value.endEvent() <<
"'";
544 else os << value.startRun() <<
":" << value.startLumi() <<
":" << value.startEvent() <<
"-" 545 << value.endRun() <<
":" << value.endLumi() <<
":" << value.endEvent();
551 if(
format ==
CFI) os <<
"'" << value.startRun() <<
":" << value.startLumi() <<
"-" 552 << value.endRun() <<
":" << value.endLumi() <<
"'";
553 else os << value.startRun() <<
":" << value.startLumi() <<
"-" 554 << value.endRun() <<
":" << value.endLumi();
560 os <<
"'" << value.label() <<
"'";
561 if(!value.instance().empty() || !value.process().empty()) {
562 os <<
", '" << value.instance() <<
"'";
564 if(!value.process().empty()) {
565 os <<
", '" << value.process() <<
"'";
568 os <<
"'" << value.label();
569 if(!value.instance().empty() || !value.process().empty()) {
570 os <<
":" << value.instance();
572 if(!value.process().empty()) {
573 os <<
":" << value.process();
581 os <<
"'" << value.relativePath() <<
"'";
601 if(value.luminosityBlock() == 0
U) {
602 if(
format ==
CFI) os <<
"'" << value.run() <<
":" << value.event() <<
"'";
603 else os << value.run() <<
":" << value.event();
605 if(
format ==
CFI) os <<
"'" << value.run() <<
":" << value.luminosityBlock() <<
":" << value.event() <<
"'";
606 else os << value.run() <<
":" << value.luminosityBlock() <<
":" << value.event();
612 if(
format ==
CFI) os <<
"'" << value.run() <<
":" << value.luminosityBlock() <<
"'";
613 else os << value.run() <<
":" << value.luminosityBlock();
618 os <<
"'" << value.label();
619 if(!value.instance().empty() || !value.process().empty()) {
620 os <<
":" << value.instance();
622 if(!value.process().empty()) {
623 os <<
":" << value.process();
632 bool& startWithComma,
635 if(startWithComma && format ==
CFI) os <<
",";
636 startWithComma =
true;
637 os <<
"\n" << std::setw(indentation) <<
"";
638 if(format ==
DOC) os <<
"[" << i <<
"]: ";
646 char oldFill = os.fill();
648 if(value_.empty() && format ==
DOC) {
650 }
else if(value_.size() == 1
U && format ==
CFI) {
651 writeValueInVector<T>(os, value_[0],
format);
652 }
else if(!value_.empty()) {
653 if(format ==
DOC) os <<
"(vector size = " << value_.size() <<
")";
654 if(format ==
CFI and value_.size() > 255
U) os <<
" *(";
656 bool startWithComma =
false;
658 for_all(value_, std::bind(&writeValueInVectorWithSpace<T>,
659 std::placeholders::_1,
662 std::ref(startWithComma),
665 if(format ==
CFI) os <<
"\n" << std::setw(indentation) <<
"";
666 if(format ==
CFI and value_.size() > 255
U) os <<
") ";
693 writeVector<long long>(os, indentation,
value_,
format);
701 writeVector<unsigned long long>(os, indentation,
value_,
format);
721 writeVector<std::string>(os, indentation,
value_,
format);
737 writeVector<LuminosityBlockID>(os, indentation,
value_,
format);
745 writeVector<LuminosityBlockRange>(os, indentation,
value_,
format);
753 writeVector<EventRange>(os, indentation,
value_,
format);
775 bool hasNestedContent(std::vector<unsigned long long>
const& value) {
return value.size() > 5
U; }
784 bool hasNestedContent(std::vector<LuminosityBlockID>
const& value) {
return value.size() > 5
U; }
786 bool hasNestedContent(std::vector<LuminosityBlockRange>
const& value) {
return value.size() > 5
U; }
void writeDoc_(std::ostream &os, int indentation) const override
void printNestedContent_(std::ostream &os, bool optional, DocFormatHelper &dfh) const override
void writeValueInVectorWithSpace(T const &value, std::ostream &os, int indentation, bool &startWithComma, ValueFormat format, int &i)
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
bool exists_(ParameterSet const &pset) const override
bool exists(std::string const ¶meterName) const
checks if a parameter exists
void writeSingleValue< double >(std::ostream &os, double const &value, ValueFormat)
void writeSingleValue< bool >(std::ostream &os, bool const &value, ValueFormat)
virtual void printDefault_(std::ostream &os, bool writeToCfi, DocFormatHelper &dfh) const
void insert(bool ok_to_replace, char const *, Entry const &)
void writeCfi(std::ostream &os, bool startWithComma, int indentation) const
void fillDescriptionFromPSet(ParameterSet const &pset, ParameterSetDescription &desc)
void writeSingleValue< FileInPath >(std::ostream &os, FileInPath const &value, ValueFormat)
void writeVector(std::ostream &os, int indentation, std::vector< T > const &value_, ValueFormat format)
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
void throwMissingRequiredNoDefault() const
void writeValue(std::ostream &os, T const &value_, ValueFormat format)
VParameterSetEntry * getPSetVectorForUpdate(std::string const &name)
void writeCfi_(std::ostream &os, int indentation) const override
void writeSingleValue< EventID >(std::ostream &os, EventID const &value, ValueFormat format)
void addParameter(std::string const &name, T const &value)
void writeSingleValue< EventRange >(std::ostream &os, EventRange const &value, ValueFormat format)
void writeValueInVector< EventID >(std::ostream &os, EventID const &value, ValueFormat format)
void print(std::ostream &os, DocFormatHelper &dfh) const
void throwParameterWrongType() const
void writeSingleValue(std::ostream &os, T const &value, ValueFormat)
format
Some error handling for the usage.
~ParameterDescription() override
bool isRegistered() const
void writeValueInVector< InputTag >(std::ostream &os, InputTag const &value, ValueFormat)
void writeValueInVector(std::ostream &os, T const &value, ValueFormat format)
void invalidateRegistration(std::string const &nameOfTracked)
ParameterDescription(std::string const &iLabel, T const &value, bool isTracked, Comment const &iComment=Comment())
static void printSpaces(std::ostream &os, int n)
bool exists(ParameterSet const &pset) const
void insertDefault_(ParameterSet &pset) const override
void validate_(ParameterSet &pset, std::set< std::string > &validatedLabels, bool optional) const override
void writeValueInVector< LuminosityBlockID >(std::ostream &os, LuminosityBlockID const &value, ValueFormat format)
void addUntrackedParameter(std::string const &name, T const &value)
bool hasNestedContent() const
bool hasNestedContent_() const override
void throwParameterWrongTrackiness() const
virtual ParameterSetDescription const * parameterSetDescription() const
void formatDouble(double value, std::string &result)
void writeSingleValue< InputTag >(std::ostream &os, InputTag const &value, ValueFormat format)
std::vector< ParameterSet >::size_type size() const
ParameterSet & psetInVector(int i)
void writeSingleValue< LuminosityBlockID >(std::ostream &os, LuminosityBlockID const &value, ValueFormat format)
void writeSingleValue< LuminosityBlockRange >(std::ostream &os, LuminosityBlockRange const &value, ValueFormat format)
ParameterSet * getPSetForUpdate(std::string const &name, bool &isTracked)
std::string const & label() const