49 std::set<std::string>& validatedLabels,
50 bool optional)
const {
62 if(!optional && !exists) {
68 validatedLabels.insert(
label());
78 psetDesc_->validate(*containedPSet);
87 os <<
"see Section " << dfh.
section()
89 if(!writeToCfi) os <<
" (do not write to cfi)";
109 std::stringstream ss;
114 os <<
"Section " << newSection
115 <<
" " <<
label() <<
" PSet description:\n";
116 if(!dfh.
brief()) os <<
"\n";
124 psetDesc_->print(os, new_dfh);
136 return psetDesc_.operator->();
142 return psetDesc_.operator->();
148 bool startWithComma =
false;
150 psetDesc_->writeCfi(os, startWithComma, indentation);
179 std::vector<ParameterSet>
const& vPset) :
183 partOfDefaultOfVPSet_(
false) {
190 std::vector<ParameterSet>
const& vPset) :
194 partOfDefaultOfVPSet_(
false) {
204 partOfDefaultOfVPSet_(
false) {
214 partOfDefaultOfVPSet_(
false) {
223 return psetDesc_.operator->();
229 return psetDesc_.operator->();
235 std::set<std::string>& validatedLabels,
236 bool optional)
const {
241 validatedLabels.insert(
label());
248 if(!exists && !optional) {
255 validatedLabels.insert(
label());
266 for(
unsigned i = 0;
i < vpsetEntry->
size(); ++
i) {
277 os <<
"see Section " << dfh.
section()
279 if(!writeToCfi) os <<
" (do not write to cfi)";
301 if(!partOfDefaultOfVPSet_) {
304 <<
" " <<
label() <<
" VPSet description:\n";
307 os <<
"All elements will be validated using the PSet description in Section " 312 <<
" " <<
" VPSet description for VPSet that is part of the default of a containing VPSet:\n";
317 unsigned subsectionOffset = 2;
318 if(partOfDefaultOfVPSet_) subsectionOffset = 1;
321 if(vPset_.size() == 0
U) os <<
"The default VPSet is empty.\n";
322 else if(vPset_.size() == 1
U) os <<
"The default VPSet has 1 element.\n";
323 else os <<
"The default VPSet has " << vPset_.size() <<
" elements.\n";
325 if(vPset_.size() > 0
U) {
326 for(
unsigned i = 0;
i < vPset_.size(); ++
i) {
328 os <<
"[" << (
i) <<
"]: see Section " << dfh.
section()
329 <<
"." << dfh.
counter() <<
"." << (
i + subsectionOffset) <<
"\n";
333 os <<
"Does not have a default VPSet.\n";
336 if(!dfh.
brief()) os <<
"\n";
338 if(!partOfDefaultOfVPSet_) {
340 std::stringstream ss;
345 os <<
"Section " << newSection <<
" description of PSet used to validate elements of VPSet:\n";
346 if(!dfh.
brief()) os <<
"\n";
354 psetDesc_->print(os, new_dfh);
358 for(
unsigned i = 0;
i < vPset_.size(); ++
i) {
360 std::stringstream ss;
361 ss << dfh.
section() <<
"." << dfh.
counter() <<
"." << (
i + subsectionOffset);
365 os <<
"Section " << newSection <<
" PSet description of " 366 <<
"default VPSet element [" <<
i <<
"]\n";
367 if(!dfh.
brief()) os <<
"\n";
378 defaultDescription.
print(os, new_dfh);
394 bool& nextOneStartsWithAComma) {
395 if(nextOneStartsWithAComma) os <<
",";
396 nextOneStartsWithAComma =
true;
402 bool startWithComma =
false;
403 int indent = indentation + 4;
407 psetDesc.
writeCfi(os, startWithComma, indent);
415 bool nextOneStartsWithAComma =
false;
416 for_all(vPset_, std::bind(&writeOneElementToCfi,
417 std::placeholders::_1,
420 std::ref(nextOneStartsWithAComma)));
447 namespace writeParameterValue {
475 s << std::setprecision(17) <<
value;
478 if(result.size() > 15 && std::string::npos != result.find(
".")) {
480 s << std::setprecision(15) <<
value;
483 if(resultLessPrecision.size() < result.size() - 2) {
484 double test = std::strtod(resultLessPrecision.c_str(), 0);
486 result = resultLessPrecision;
501 value ? os <<
"True" : os <<
"False";
506 os <<
"'" << value <<
"'";
512 os << value.run() <<
", " << value.luminosityBlock() <<
", " << value.event();
514 if(value.luminosityBlock() == 0
U) {
515 os << value.run() <<
":" << value.event();
517 os << value.run() <<
":" << value.luminosityBlock() <<
":" << value.event();
524 if(
format ==
CFI) os << value.run() <<
", " << value.luminosityBlock();
525 else os << value.run() <<
":" << value.luminosityBlock();
530 if(value.startLumi() == 0
U) {
531 if(
format ==
CFI) os <<
"'" << value.startRun() <<
":" << value.startEvent() <<
"-" 532 << value.endRun() <<
":" << value.endEvent() <<
"'";
533 else os << value.startRun() <<
":" << value.startEvent() <<
"-" 534 << value.endRun() <<
":" << value.endEvent();
536 if(
format ==
CFI) os <<
"'" << value.startRun() <<
":" << value.startLumi() <<
":" << value.startEvent() <<
"-" 537 << value.endRun() <<
":" << value.endLumi() <<
":" << value.endEvent() <<
"'";
538 else os << value.startRun() <<
":" << value.startLumi() <<
":" << value.startEvent() <<
"-" 539 << value.endRun() <<
":" << value.endLumi() <<
":" << value.endEvent();
545 if(
format ==
CFI) os <<
"'" << value.startRun() <<
":" << value.startLumi() <<
"-" 546 << value.endRun() <<
":" << value.endLumi() <<
"'";
547 else os << value.startRun() <<
":" << value.startLumi() <<
"-" 548 << value.endRun() <<
":" << value.endLumi();
554 os <<
"'" << value.label() <<
"'";
555 if(!value.instance().empty() || !value.process().empty()) {
556 os <<
", '" << value.instance() <<
"'";
558 if(!value.process().empty()) {
559 os <<
", '" << value.process() <<
"'";
562 os <<
"'" << value.label();
563 if(!value.instance().empty() || !value.process().empty()) {
564 os <<
":" << value.instance();
566 if(!value.process().empty()) {
567 os <<
":" << value.process();
575 os <<
"'" << value.relativePath() <<
"'";
595 if(value.luminosityBlock() == 0
U) {
596 if(
format ==
CFI) os <<
"'" << value.run() <<
":" << value.event() <<
"'";
597 else os << value.run() <<
":" << value.event();
599 if(
format ==
CFI) os <<
"'" << value.run() <<
":" << value.luminosityBlock() <<
":" << value.event() <<
"'";
600 else os << value.run() <<
":" << value.luminosityBlock() <<
":" << value.event();
606 if(
format ==
CFI) os <<
"'" << value.run() <<
":" << value.luminosityBlock() <<
"'";
607 else os << value.run() <<
":" << value.luminosityBlock();
612 os <<
"'" << value.label();
613 if(!value.instance().empty() || !value.process().empty()) {
614 os <<
":" << value.instance();
616 if(!value.process().empty()) {
617 os <<
":" << value.process();
626 bool& startWithComma,
629 if(startWithComma && format ==
CFI) os <<
",";
630 startWithComma =
true;
631 os <<
"\n" << std::setw(indentation) <<
"";
632 if(format ==
DOC) os <<
"[" << i <<
"]: ";
640 char oldFill = os.fill();
642 if(value_.size() == 0
U && format ==
DOC) {
644 }
else if(value_.size() == 1
U && format ==
CFI) {
645 writeValueInVector<T>(os, value_[0],
format);
646 }
else if(value_.size() >= 1
U) {
647 if(format ==
DOC) os <<
"(vector size = " << value_.size() <<
")";
648 if(format ==
CFI and value_.size() > 255
U) os <<
" *(";
650 bool startWithComma =
false;
652 for_all(value_, std::bind(&writeValueInVectorWithSpace<T>,
653 std::placeholders::_1,
656 std::ref(startWithComma),
659 if(format ==
CFI) os <<
"\n" << std::setw(indentation) <<
"";
660 if(format ==
CFI and value_.size() > 255
U) os <<
") ";
687 writeVector<long long>(os, indentation,
value_,
format);
695 writeVector<unsigned long long>(os, indentation,
value_,
format);
715 writeVector<std::string>(os, indentation,
value_,
format);
731 writeVector<LuminosityBlockID>(os, indentation,
value_,
format);
739 writeVector<LuminosityBlockRange>(os, indentation,
value_,
format);
747 writeVector<EventRange>(os, indentation,
value_,
format);
769 bool hasNestedContent(std::vector<unsigned long long>
const& value) {
return value.size() > 5
U; }
778 bool hasNestedContent(std::vector<LuminosityBlockID>
const& value) {
return value.size() > 5
U; }
780 bool hasNestedContent(std::vector<LuminosityBlockRange>
const& value) {
return value.size() > 5
U; }
ParameterDescription(std::string const &iLabel, T const &value, bool isTracked)
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
virtual void printNestedContent_(std::ostream &os, bool optional, DocFormatHelper &dfh) const
virtual bool exists_(ParameterSet const &pset) const
virtual ~ParameterDescription()
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
virtual void validate_(ParameterSet &pset, std::set< std::string > &validatedLabels, bool optional) const
void throwMissingRequiredNoDefault() const
void writeValue(std::ostream &os, T const &value_, ValueFormat format)
VParameterSetEntry * getPSetVectorForUpdate(std::string const &name)
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.
virtual void insertDefault_(ParameterSet &pset) const
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)
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)
bool hasNestedContent() const
virtual bool hasNestedContent_() const
void throwParameterWrongTrackiness() const
virtual ParameterSetDescription const * parameterSetDescription() const
std::vector< ParameterSet >::size_type size() const
void formatDouble(double value, std::string &result)
void writeSingleValue< InputTag >(std::ostream &os, InputTag const &value, ValueFormat format)
ParameterSet & psetInVector(int i)
virtual void writeDoc_(std::ostream &os, int indentation) const
void writeSingleValue< LuminosityBlockID >(std::ostream &os, LuminosityBlockID const &value, ValueFormat format)
void writeSingleValue< LuminosityBlockRange >(std::ostream &os, LuminosityBlockRange const &value, ValueFormat format)
virtual void writeCfi_(std::ostream &os, int indentation) const
ParameterSet * getPSetForUpdate(std::string const &name, bool &isTracked)
std::string const & label() const