44 std::set<std::string>& validatedLabels,
45 bool optional)
const {
56 if (!optional && !exists) {
62 validatedLabels.insert(
label());
72 psetDesc_->validate(*containedPSet);
81 os <<
" (do not write to cfi)";
100 os <<
"Section " << newSection <<
" " <<
label() <<
" PSet description:\n";
110 psetDesc_->print(os, new_dfh);
118 return psetDesc_.operator->();
122 return psetDesc_.operator->();
126 bool startWithComma =
false;
128 psetDesc_->writeCfi(os, startWithComma, indentation);
149 std::vector<ParameterSet>
const& vPset,
154 partOfDefaultOfVPSet_(
false) {}
159 std::vector<ParameterSet>
const& vPset,
164 partOfDefaultOfVPSet_(
false) {}
173 partOfDefaultOfVPSet_(
false) {}
182 partOfDefaultOfVPSet_(
false) {}
187 return psetDesc_.operator->();
191 return psetDesc_.operator->();
195 std::set<std::string>& validatedLabels,
196 bool optional)
const {
200 validatedLabels.insert(
label());
207 if (!exists && !optional) {
214 validatedLabels.insert(
label());
225 for (
unsigned i = 0;
i < vpsetEntry->
size(); ++
i) {
236 os <<
" (do not write to cfi)";
250 if (!partOfDefaultOfVPSet_) {
252 os <<
"Section " << dfh.
section() <<
"." << dfh.
counter() <<
" " <<
label() <<
" VPSet description:\n";
255 os <<
"All elements will be validated using the PSet description in Section " << dfh.
section() <<
"." 260 <<
" VPSet description for VPSet that is part of the default of a containing VPSet:\n";
265 unsigned subsectionOffset = 2;
266 if (partOfDefaultOfVPSet_)
267 subsectionOffset = 1;
271 os <<
"The default VPSet is empty.\n";
272 else if (vPset_.size() == 1
U)
273 os <<
"The default VPSet has 1 element.\n";
275 os <<
"The default VPSet has " << vPset_.size() <<
" elements.\n";
277 if (!vPset_.empty()) {
278 for (
unsigned i = 0;
i < vPset_.size(); ++
i) {
280 os <<
"[" << (
i) <<
"]: see Section " << dfh.
section() <<
"." << dfh.
counter() <<
"." 281 << (
i + subsectionOffset) <<
"\n";
285 os <<
"Does not have a default VPSet.\n";
291 if (!partOfDefaultOfVPSet_) {
292 std::stringstream ss;
297 os <<
"Section " << newSection <<
" description of PSet used to validate elements of VPSet:\n";
307 psetDesc_->print(os, new_dfh);
311 for (
unsigned i = 0;
i < vPset_.size(); ++
i) {
312 std::stringstream ss;
313 ss << dfh.
section() <<
"." << dfh.
counter() <<
"." << (
i + subsectionOffset);
317 os <<
"Section " << newSection <<
" PSet description of " 318 <<
"default VPSet element [" <<
i <<
"]\n";
331 defaultDescription.
print(os, new_dfh);
343 bool& nextOneStartsWithAComma) {
344 if (nextOneStartsWithAComma)
346 nextOneStartsWithAComma =
true;
352 bool startWithComma =
false;
353 int indent = indentation + 4;
357 psetDesc.
writeCfi(os, startWithComma, indent);
363 bool nextOneStartsWithAComma =
false;
367 &writeOneElementToCfi, std::placeholders::_1, std::ref(os), indentation, std::ref(nextOneStartsWithAComma)));
387 namespace writeParameterValue {
389 template <
typename T>
415 s << std::setprecision(17) <<
value;
418 if (result.size() > 15 && std::string::npos != result.find(
".")) {
420 s << std::setprecision(15) <<
value;
423 if (resultLessPrecision.size() < result.size() - 2) {
424 double test = std::strtod(resultLessPrecision.c_str(),
nullptr);
426 result = resultLessPrecision;
441 value ? os <<
"True" : os <<
"False";
446 os <<
"'" << value <<
"'";
452 os << value.run() <<
", " << value.luminosityBlock() <<
", " << value.event();
454 if (value.luminosityBlock() == 0
U) {
455 os << value.run() <<
":" << value.event();
457 os << value.run() <<
":" << value.luminosityBlock() <<
":" << value.event();
465 os << value.run() <<
", " << value.luminosityBlock();
467 os << value.run() <<
":" << value.luminosityBlock();
472 if (value.startLumi() == 0
U) {
474 os <<
"'" << value.startRun() <<
":" << value.startEvent() <<
"-" << value.endRun() <<
":" << value.endEvent()
477 os << value.startRun() <<
":" << value.startEvent() <<
"-" << value.endRun() <<
":" << value.endEvent();
480 os <<
"'" << value.startRun() <<
":" << value.startLumi() <<
":" << value.startEvent() <<
"-" 481 << value.endRun() <<
":" << value.endLumi() <<
":" << value.endEvent() <<
"'";
483 os << value.startRun() <<
":" << value.startLumi() <<
":" << value.startEvent() <<
"-" << value.endRun()
484 <<
":" << value.endLumi() <<
":" << value.endEvent();
493 os <<
"'" << value.startRun() <<
":" << value.startLumi() <<
"-" << value.endRun() <<
":" << value.endLumi()
496 os << value.startRun() <<
":" << value.startLumi() <<
"-" << value.endRun() <<
":" << value.endLumi();
502 os <<
"'" << value.label() <<
"'";
503 if (!value.instance().empty() || !value.process().empty()) {
504 os <<
", '" << value.instance() <<
"'";
506 if (!value.process().empty()) {
507 os <<
", '" << value.process() <<
"'";
510 os <<
"'" << value.label();
511 if (!value.instance().empty() || !value.process().empty()) {
512 os <<
":" << value.instance();
514 if (!value.process().empty()) {
515 os <<
":" << value.process();
523 os <<
"'" << value.relativePath() <<
"'";
526 template <
typename T>
534 template <
typename T>
543 if (value.luminosityBlock() == 0
U) {
545 os <<
"'" << value.run() <<
":" << value.event() <<
"'";
547 os << value.run() <<
":" << value.event();
550 os <<
"'" << value.run() <<
":" << value.luminosityBlock() <<
":" << value.event() <<
"'";
552 os << value.run() <<
":" << value.luminosityBlock() <<
":" << value.event();
559 os <<
"'" << value.run() <<
":" << value.luminosityBlock() <<
"'";
561 os << value.run() <<
":" << value.luminosityBlock();
566 os <<
"'" << value.label();
567 if (!value.instance().empty() || !value.process().empty()) {
568 os <<
":" << value.instance();
570 if (!value.process().empty()) {
571 os <<
":" << value.process();
576 template <
typename T>
578 T const& value, std::ostream& os,
int indentation,
bool& startWithComma,
ValueFormat format,
int&
i) {
579 if (startWithComma && format ==
CFI)
581 startWithComma =
true;
582 os <<
"\n" << std::setw(indentation) <<
"";
584 os <<
"[" << i <<
"]: ";
589 template <
typename T>
592 char oldFill = os.fill();
594 if (value_.empty() && format ==
DOC) {
596 }
else if (value_.size() == 1
U && format ==
CFI) {
597 writeValueInVector<T>(os, value_[0],
format);
598 }
else if (!value_.empty()) {
600 os <<
"(vector size = " << value_.size() <<
")";
601 if (format ==
CFI and value_.size() > 255
U)
604 bool startWithComma =
false;
607 std::bind(&writeValueInVectorWithSpace<T>,
608 std::placeholders::_1,
611 std::ref(startWithComma),
615 os <<
"\n" << std::setw(indentation) <<
"";
616 if (format ==
CFI and value_.size() > 255
U)
644 writeVector<long long>(os, indentation,
value_,
format);
653 std::vector<unsigned long long>
const&
value_,
655 writeVector<unsigned long long>(os, indentation,
value_,
format);
675 writeVector<std::string>(os, indentation,
value_,
format);
692 std::vector<LuminosityBlockID>
const&
value_,
694 writeVector<LuminosityBlockID>(os, indentation,
value_,
format);
703 std::vector<LuminosityBlockRange>
const&
value_,
705 writeVector<LuminosityBlockRange>(os, indentation,
value_,
format);
713 writeVector<EventRange>(os, indentation,
value_,
format);
735 bool hasNestedContent(std::vector<unsigned long long>
const& value) {
return value.size() > 5
U; }
744 bool hasNestedContent(std::vector<LuminosityBlockID>
const& value) {
return value.size() > 5
U; }
746 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