45 std::set<std::string>& validatedLabels,
57 if (!optional && !exists) {
63 validatedLabels.insert(
label());
73 psetDesc_->validate(*containedPSet);
82 os <<
" (do not write to cfi)";
101 os <<
"Section " << newSection <<
" " <<
label() <<
" PSet description:\n";
111 psetDesc_->print(os, new_dfh);
119 return psetDesc_.operator->();
123 return psetDesc_.operator->();
127 bool startWithComma =
false;
129 psetDesc_->writeCfi(os, startWithComma, indentation);
150 std::vector<ParameterSet>
const& vPset,
155 partOfDefaultOfVPSet_(
false) {}
160 std::vector<ParameterSet>
const& vPset,
165 partOfDefaultOfVPSet_(
false) {}
174 partOfDefaultOfVPSet_(
false) {}
183 partOfDefaultOfVPSet_(
false) {}
188 return psetDesc_.operator->();
192 return psetDesc_.operator->();
196 std::set<std::string>& validatedLabels,
198 bool exists = pset.
existsAs<std::vector<ParameterSet> >(
label(), isTracked());
201 validatedLabels.insert(
label());
202 }
else if (pset.
existsAs<std::vector<ParameterSet> >(
label(), !isTracked())) {
203 throwParameterWrongTrackiness();
205 throwParameterWrongType();
208 if (!exists && !optional) {
215 validatedLabels.insert(
label());
217 throwMissingRequiredNoDefault();
221 exists = pset.
existsAs<std::vector<ParameterSet> >(
label(), isTracked());
226 for (
unsigned i = 0;
i < vpsetEntry->
size(); ++
i) {
237 os <<
" (do not write to cfi)";
251 if (!partOfDefaultOfVPSet_) {
252 printSpaces(os, indentation);
253 os <<
"Section " << dfh.
section() <<
"." << dfh.
counter() <<
" " <<
label() <<
" VPSet description:\n";
256 os <<
"All elements will be validated using the PSet description in Section " << dfh.
section() <<
"."
259 printSpaces(os, indentation);
261 <<
" VPSet description for VPSet that is part of the default of a containing VPSet:\n";
266 unsigned subsectionOffset = 2;
267 if (partOfDefaultOfVPSet_)
268 subsectionOffset = 1;
272 os <<
"The default VPSet is empty.\n";
273 else if (vPset_.size() == 1U)
274 os <<
"The default VPSet has 1 element.\n";
276 os <<
"The default VPSet has " << vPset_.size() <<
" elements.\n";
278 if (!vPset_.empty()) {
279 for (
unsigned i = 0;
i < vPset_.size(); ++
i) {
281 os <<
"[" << (
i) <<
"]: see Section " << dfh.
section() <<
"." << dfh.
counter() <<
"."
282 << (
i + subsectionOffset) <<
"\n";
286 os <<
"Does not have a default VPSet.\n";
292 if (!partOfDefaultOfVPSet_) {
293 std::stringstream
ss;
297 printSpaces(os, indentation);
298 os <<
"Section " << newSection <<
" description of PSet used to validate elements of VPSet:\n";
308 psetDesc_->print(os, new_dfh);
312 for (
unsigned i = 0;
i < vPset_.size(); ++
i) {
313 std::stringstream
ss;
314 ss << dfh.
section() <<
"." << dfh.
counter() <<
"." << (
i + subsectionOffset);
317 printSpaces(os, indentation);
318 os <<
"Section " << newSection <<
" PSet description of "
319 <<
"default VPSet element [" <<
i <<
"]\n";
332 defaultDescription.
print(os, new_dfh);
338 return pset.
existsAs<std::vector<ParameterSet> >(
label(), isTracked());
344 bool& nextOneStartsWithAComma) {
345 if (nextOneStartsWithAComma)
347 nextOneStartsWithAComma =
true;
349 printSpaces(os, indentation + 2);
353 bool startWithComma =
false;
354 int indent = indentation + 4;
358 psetDesc.
writeCfi(os, startWithComma, indent);
364 bool nextOneStartsWithAComma =
false;
368 &writeOneElementToCfi, std::placeholders::_1, std::ref(os), indentation, std::ref(nextOneStartsWithAComma)));
370 printSpaces(os, indentation);
388 namespace writeParameterValue {
390 template <
typename T>
416 std::stringstream
ss;
417 ss << std::setprecision(17) <<
value;
420 if (result.size() > 15 && std::string::npos != result.find(
'.')) {
421 std::stringstream
ss;
422 ss << std::setprecision(15) <<
value;
425 if (resultLessPrecision.size() < result.size() - 2) {
426 double test = std::strtod(resultLessPrecision.c_str(),
nullptr);
428 result = resultLessPrecision;
443 value ? os <<
"True" : os <<
"False";
448 os <<
"'" <<
value <<
"'";
454 os <<
value.run() <<
", " <<
value.luminosityBlock() <<
", " <<
value.event();
456 if (
value.luminosityBlock() == 0U) {
459 os <<
value.run() <<
":" <<
value.luminosityBlock() <<
":" <<
value.event();
467 os <<
value.run() <<
", " <<
value.luminosityBlock();
469 os <<
value.run() <<
":" <<
value.luminosityBlock();
474 if (
value.startLumi() == 0U) {
476 os <<
"'" <<
value.startRun() <<
":" <<
value.startEvent() <<
"-" <<
value.endRun() <<
":" <<
value.endEvent()
479 os <<
value.startRun() <<
":" <<
value.startEvent() <<
"-" <<
value.endRun() <<
":" <<
value.endEvent();
482 os <<
"'" <<
value.startRun() <<
":" <<
value.startLumi() <<
":" <<
value.startEvent() <<
"-"
483 <<
value.endRun() <<
":" <<
value.endLumi() <<
":" <<
value.endEvent() <<
"'";
485 os <<
value.startRun() <<
":" <<
value.startLumi() <<
":" <<
value.startEvent() <<
"-" <<
value.endRun()
486 <<
":" <<
value.endLumi() <<
":" <<
value.endEvent();
495 os <<
"'" <<
value.startRun() <<
":" <<
value.startLumi() <<
"-" <<
value.endRun() <<
":" <<
value.endLumi()
498 os <<
value.startRun() <<
":" <<
value.startLumi() <<
"-" <<
value.endRun() <<
":" <<
value.endLumi();
504 os <<
"'" <<
value.label() <<
"'";
505 if (!
value.instance().empty() || !
value.process().empty()) {
506 os <<
", '" <<
value.instance() <<
"'";
508 if (!
value.process().empty()) {
509 os <<
", '" <<
value.process() <<
"'";
512 os <<
"'" <<
value.label();
513 if (!
value.instance().empty() || !
value.process().empty()) {
514 os <<
":" <<
value.instance();
516 if (!
value.process().empty()) {
517 os <<
":" <<
value.process();
526 os <<
"'" <<
value.module() <<
"', '" <<
value.data() <<
"'";
528 os <<
"'" <<
value.module() <<
":" <<
value.data() <<
"'";
534 os <<
"'" <<
value.relativePath() <<
"'";
537 template <
typename T>
541 writeSingleValue<T>(os, value_,
format);
545 template <
typename T>
554 if (
value.luminosityBlock() == 0U) {
556 os <<
"'" <<
value.run() <<
":" <<
value.event() <<
"'";
561 os <<
"'" <<
value.run() <<
":" <<
value.luminosityBlock() <<
":" <<
value.event() <<
"'";
563 os <<
value.run() <<
":" <<
value.luminosityBlock() <<
":" <<
value.event();
570 os <<
"'" <<
value.run() <<
":" <<
value.luminosityBlock() <<
"'";
572 os <<
value.run() <<
":" <<
value.luminosityBlock();
577 os <<
"'" <<
value.label();
578 if (!
value.instance().empty() || !
value.process().empty()) {
579 os <<
":" <<
value.instance();
581 if (!
value.process().empty()) {
582 os <<
":" <<
value.process();
589 os <<
"'" <<
value.module() <<
":" <<
value.data() <<
"'";
592 template <
typename T>
595 if (startWithComma && format ==
CFI)
597 startWithComma =
true;
598 os <<
"\n" << std::setw(indentation) <<
"";
600 os <<
"[" << i <<
"]: ";
605 template <
typename T>
608 char oldFill = os.fill();
610 if (value_.empty() && format ==
DOC) {
612 }
else if (value_.size() == 1U && format ==
CFI) {
613 writeValueInVector<T>(os, value_[0],
format);
614 }
else if (!value_.empty()) {
616 os <<
"(vector size = " << value_.size() <<
")";
617 if (format ==
CFI and value_.size() > 255U)
620 bool startWithComma =
false;
623 std::bind(&writeValueInVectorWithSpace<T>,
624 std::placeholders::_1,
627 std::ref(startWithComma),
631 os <<
"\n" << std::setw(indentation) <<
"";
632 if (format ==
CFI and value_.size() > 255U)
640 writeValue<int>(os, value_,
format);
644 writeVector<int>(os, indentation, value_,
format);
648 writeValue<unsigned>(os, value_,
format);
652 writeVector<unsigned>(os, indentation, value_,
format);
656 writeValue<long long>(os, value_,
format);
660 writeVector<long long>(os, indentation, value_,
format);
664 writeValue<unsigned long long>(os, value_,
format);
669 std::vector<unsigned long long>
const& value_,
671 writeVector<unsigned long long>(os, indentation, value_,
format);
675 writeValue<double>(os, value_,
format);
679 writeVector<double>(os, indentation, value_,
format);
683 writeValue<bool>(os, value_,
format);
687 writeValue<std::string>(os, value_,
format);
691 writeVector<std::string>(os, indentation, value_,
format);
695 writeValue<EventID>(os, value_,
format);
699 writeVector<EventID>(os, indentation, value_,
format);
703 writeValue<LuminosityBlockID>(os, value_,
format);
708 std::vector<LuminosityBlockID>
const& value_,
710 writeVector<LuminosityBlockID>(os, indentation, value_,
format);
714 writeValue<LuminosityBlockRange>(os, value_,
format);
719 std::vector<LuminosityBlockRange>
const& value_,
721 writeVector<LuminosityBlockRange>(os, indentation, value_,
format);
725 writeValue<EventRange>(os, value_,
format);
729 writeVector<EventRange>(os, indentation, value_,
format);
733 writeValue<InputTag>(os, value_,
format);
737 writeVector<InputTag>(os, indentation, value_,
format);
741 writeValue<ESInputTag>(os, value_,
format);
745 writeVector<ESInputTag>(os, indentation, value_,
format);
749 writeValue<FileInPath>(os, value_,
format);
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
void writeSingleValue< ESInputTag >(std::ostream &os, ESInputTag const &value, ValueFormat format)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
void writeSingleValue< double >(std::ostream &os, double const &value, ValueFormat)
void validate_(ParameterSet &pset, std::set< std::string > &validatedLabels, bool optional) const override
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
VParameterSetEntry * getPSetVectorForUpdate(std::string const &name)
void writeCfi_(std::ostream &os, int indentation) const override
bool exists_(ParameterSet const &pset) 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)
~ParameterDescription() override
bool isRegistered() const
void writeValueInVector< InputTag >(std::ostream &os, InputTag const &value, ValueFormat)
bool hasNestedContent_() const override
void writeValueInVector(std::ostream &os, T const &value, ValueFormat format)
void writeValueInVector< ESInputTag >(std::ostream &os, ESInputTag const &value, ValueFormat)
void invalidateRegistration(std::string const &nameOfTracked)
static void printSpaces(std::ostream &os, int n)
bool exists(ParameterSet const &pset) const
void writeValueInVector< LuminosityBlockID >(std::ostream &os, LuminosityBlockID const &value, ValueFormat format)
void addUntrackedParameter(std::string const &name, T const &value)
void throwParameterWrongTrackiness() const
virtual ParameterSetDescription const * parameterSetDescription() const
void writeValue(std::ostream &os, int indentation, int const &value_, ValueFormat format)
void writeDoc_(std::ostream &os, int indentation) const override
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)
bool hasNestedContent(int const &value)
void insertDefault_(ParameterSet &pset) const override
void printNestedContent_(std::ostream &os, bool optional, DocFormatHelper &dfh) const override
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